-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheoe.php
More file actions
245 lines (239 loc) · 8.24 KB
/
eoe.php
File metadata and controls
245 lines (239 loc) · 8.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
include ("config.php");
include ("bapi_salesorder_createfromdat2.php");
// set default values
if (! isset($_POST['doc_type'])) $doc_type = set_default('eoe_doc_type'); else $doc_type = $_POST['doc_type'];
if (! isset($_POST['sales_org'])) $sales_org = set_default('eoe_sales_org'); else $sales_org = $_POST['sales_org'];
if (! isset($_POST['distr_chann'])) $distr_chann = set_default('eoe_distr_chann'); else $distr_chann = $_POST['distr_chann'];
if (! isset($_POST['division'])) $division = set_default('eoe_division'); else $division = $_POST['division'];
if (! isset($_POST['sales_off'])) $sales_off = set_default('eoe_sales_off'); else $sales_off = $_POST['sales_off'];
if (! isset($_POST['sales_grp'])) $sales_grp = set_default('eoe_sales_grp'); else $sales_grp = $_POST['sales_grp'];
if (! isset($_POST['partn_role'])) $partn_role = set_default('eoe_partn_role'); else $partn_role = $_POST['partn_role'];// table TPART-PARVW lang. DE
if (! isset($_POST['partn_numb'])) $partn_numb = set_default('eoe_partn_numb'); else $partn_numb = $_POST['partn_numb'];
if (! isset($_POST['sunit'])) $sunit = set_default('eoe_sunit'); else $sunit = $_POST['sunit'];
// reading _POST data
if (! isset($_POST['ponumb'])) ; else $ponumb = $_POST['ponumb'];
if (! isset($_POST['inumb'])) ; else $inumb = $_POST['inumb'];
if (! isset($_POST['matnr'])) $matnr = 1; else $matnr = $_POST['matnr'];
$mat_nr = str_pad($matnr, 18, "0", STR_PAD_LEFT);
if (! isset($_POST['oqty'])) ; else $oqty = $_POST['oqty'];
if (! isset($_POST['rate'])) $rate = 0.01 ; else $rate = $_POST['rate'];
?>
<html>
<head>
<title>Easy Order Entry - SAP R/3</title>
<script language="JavaScript">
<!--
function validateSubmit() {
// very basic missing data handling
checkentry=myform.ponumb.value;
if (checkentry=='') {
alert('Purchase Order number (PO number) must be specified. Please enter a value.');
document.myform.ponumb.focus();
event.returnValue=false;
}
checkentry=myform.inumb.value;
if (checkentry=='') {
alert('Item number is a mandatory entry. Please try again.');
document.myform.inumb.focus();
event.returnValue=false;
}
checkentry=myform.matnr.value;
if (checkentry==1) {
alert('A Material code must be specified. Please select one.');
document.myform.matnr.focus();
event.returnValue=false;
}
checkentry=myform.oqty.value;
if (checkentry=='') {
alert('Order quantity must be specified. Please try again.');
document.myform.oqty.focus();
event.returnValue=false;
}
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" align="center" border="0">
<h1><font color="#3366CC">SAPRFC:<br>SD - Easy Order Entry</font></h1>
<form name="myform" method="post" action="<?php echo($PHP_SELF); ?>" onSubmit="validateSubmit();">
<tr>
<td width="18%" style="font-size:14px;">Order type</td>
<td width="16%">
<select name="doc_type" id="doc_type" style="WIDTH: 80px; font-size:9px;">
<?php $vals = draw_sel('eoe_doc_type', $doc_type).'~'; ?>
</select>
</td>
<td width="66%">
<input type="submit" name="Submit" value="create order">
</td>
</tr>
<tr>
<td colspan="3">
<hr>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#999999"><b><font color="#FFFFFF">Header data</font></b></td>
</tr>
<tr>
<td width="18%">Sales organization</td>
<td width="16%">
<select name="sales_org" id="sales_org" style="WIDTH: 60px; font-size:9px;">
<?php $vals .= draw_sel('eoe_sales_org', $sales_org).'~'; ?>
</select>
</td>
<td width="66%"> </td>
</tr>
<tr>
<td width="18%">Distribution channel</td>
<td width="16%">
<select name="distr_chann" id="distr_chann" style="WIDTH: 46px; font-size:9px;">
<?php $vals .= draw_sel('eoe_distr_chann', $distr_chann).'~'; ?>
</select>
</td>
<td width="66%"> </td>
</tr>
<tr>
<td width="18%">Division</td>
<td width="16%">
<select name="division" id="division" style="WIDTH: 46px; font-size:9px;">
<?php $vals .= draw_sel('eoe_division', $division).'~'; ?>
</select>
</td>
<td width="66%"> </td>
</tr>
<tr>
<td width="18%">Sales office</td>
<td width="16%">
<select name="sales_off" id="sales_off" style="WIDTH: 56px; font-size:9px;">
<?php $vals .= draw_sel('eoe_sales_off', $sales_off).'~'; ?>
</select>
</td>
<td width="66%"> </td>
</tr>
<tr>
<td width="18%" height="24">Sales group</td>
<td width="16%" height="24">
<select name="sales_grp" id="sales_grp" style="WIDTH: 56px; font-size:9px;">
<?php $vals .= draw_sel('eoe_sales_grp', $sales_grp).'~'; ?>
</select>
</td>
<td width="66%"> </td>
</tr>
<tr>
<td colspan="3">
<hr>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#999999"><b><font color="#FFFFFF">Partner data</font></b></td>
</tr>
<tr>
<td width="18%">Partner function</td>
<td width="16%">
<select name="partn_role" id="partn_role" style="WIDTH: 46px; font-size:9px;">
<?php $vals .= draw_sel('eoe_partn_role', $partn_role).'~'; ?>
</select>
</td>
<td> </td>
</tr>
<tr>
<td width="18%">Partner number</td>
<td width="16%">
<select name="partn_numb" id="partn_numb" style="WIDTH: 80px; font-size:9px;">
<?php $vals .= draw_sel('eoe_partn_numb', $partn_numb).'~'; ?>
</select>
</td>
<td> </td>
</tr>
<tr>
<td width="18%">PO number</td>
<td>
<input type="text" name="ponumb" style="WIDTH: 120px; HEIGHT: 20px; font-size:9px;" value="<? echo $ponumb; ?>">
<?php $vals .= $ponumb.'~'; ?>
</td>
<td> </td>
</tr>
<tr>
<td colspan="3">
<hr>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#999999"><b><font color="#FFFFFF">Item data</font></b></td>
</tr>
<tr>
<td>Item number</td>
<td>
<input type="text" name="inumb" style="WIDTH: 40px; HEIGHT: 20px; font-size:9px;" value="<? echo $inumb; ?>">
<?php $vals .= $inumb.'~'; ?>
</td>
<td> </td>
</tr>
<tr>
<td>Material</td>
<td>
<select name="matnr" id="matnr" style="WIDTH: 80px; font-size:9px;">
<?php $vals .= draw_sel('eoe_matnr', $matnr).'~'; ?>
</select>
</td>
<td> </td>
</tr>
<tr>
<td>Order quantity</td>
<td>
<input type="text" name="oqty" style="WIDTH: 60px; HEIGHT: 20px; font-size:9px;" value="<? echo $oqty; ?>">
<?php $vals .= $oqty.'~'; ?>
</td>
<td> </td>
</tr>
<tr>
<td>Unit of measure</td>
<td>
<select name="sunit" id="sunit" style="WIDTH: 45px; font-size:9px;">
<?php $vals .= draw_sel('eoe_sunit', $sunit).'~'; ?>
</select>
</td>
<td> </td>
</tr>
<tr>
<td>Rate</td>
<td>
<input type="text" name="rate" style="WIDTH: 55px; HEIGHT: 20px; font-size:9px;" value="<? echo $rate; ?>">
<?php $vals .= $rate.'~'; ?>
</td>
<td> </td>
</tr>
</form>
</table>
<?php
//calling function
if (isset($_POST['Submit'])) bapi_salesorder_createfromdat2($vals); ?>
</body>
</html>
<?php
function draw_sel($table, $idx)
{
$qry = "SELECT * FROM $table";
$result = mysql_query($qry) or die("Problem with the query: ".$qry.'<br>'.mysql_error());
while ($row = mysql_fetch_array($result)) {
if (intval($row['eoe_idx']) == $idx) {
$txt = substr($table, 4);
$v = $row[$table];?>
<option selected value=" <?php echo($row['eoe_idx']); ?> "> <?php
} else { ?>
<option value=" <?php echo($row['eoe_idx']); ?> "> <?php
}
echo($row[$table]); ?></option> <?php
}
return $v;
}
function set_default($table)
{
$qry = "SELECT eoe_idx FROM $table WHERE eoe_default = 'x'";
$result = mysql_query($qry) or die("Problem with the query: ".$qry.'<br>'.mysql_error());
return (mysql_result ($result, 0));
}
?>