3 /* $Revision: 1.12 $ */
7 include('includes/DefineSpecialOrderClass.php');
8 /* Session started in header.inc for password checking and authorisation level check */
9 include('includes/session.inc');
11 $title = _('Special Order Entry');
13 include('includes/header.inc');
15 echo "<FORM ACTION='" . $_SERVER['PHP_SELF'] . "?" . SID
. "' METHOD=POST>";
18 if ($_GET['NewSpecial']=='yes'){
19 unset($_SESSION['SPL']);
22 if (!isset($_SESSION['SupplierID'])){
24 prnMsg(_('To set up a special') . ', ' . _('the supplier must first be selected from the Select Supplier page'),'info');
25 echo "<BR><A HREF='$rootpath/SelectSupplier.php?" . SID
. "'>" . _('Select the supplier now') . "</A>";
29 if (!isset($_SESSION['CustomerID']) OR $_SESSION['CustomerID']==""){
30 echo "<BR><BR>" . _('To set up a special') . ', ' . _('the customer must first be selected from the Select Customer page') . "<BR><A HREF='$rootpath/SelectCustomer.php?" . SID
. "'>" . _('Select the customer now') . "</A>";
34 if (isset($_POST['Cancel'])){
35 unset($_SESSION['SPL']);
39 if (!isset($_SESSION['SPL'])){
40 /* It must be a new special order being created $_SESSION['SPL'] would be set up from the order modification code above if a modification to an existing order. */
42 $_SESSION['SPL'] = new SpecialOrder
;
47 /*if not already done populate the SPL object with supplier data */
48 if (!isset($_SESSION['SPL']->SupplierID
)){
49 $sql = "SELECT suppliers.suppname,
52 FROM suppliers INNER JOIN currencies
53 ON suppliers.currcode=currencies.currabrev
54 WHERE supplierid='" . $_SESSION['SupplierID'] . "'";
55 $ErrMsg = _('The supplier record of the supplier selected') . ": " . $_SESSION['SupplierID'] . ' ' . _('cannot be retrieved because');
56 $DbgMsg = _('The SQL used to retrieve the supplier details and failed was');
57 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg);
59 $myrow = DB_fetch_row($result);
60 $_SESSION['SPL']->SupplierID
= $_SESSION['SupplierID'];
61 $_SESSION['SPL']->SupplierName
= $myrow[0];
62 $_SESSION['SPL']->SuppCurrCode
= $myrow[1];
63 $_SESSION['SPL']->SuppCurrExRate
= $myrow[2];
65 if (!isset($_SESSION['SPL']->CustomerID
)){
66 // Now check to ensure this account is not on hold */
67 $sql = "SELECT debtorsmaster.name,
68 holdreasons.dissallowinvoices,
69 debtorsmaster.currcode,
74 WHERE debtorsmaster.holdreason=holdreasons.reasoncode
75 AND debtorsmaster.currcode=currencies.currabrev
76 AND debtorsmaster.debtorno = '" . $_SESSION['CustomerID'] . "'";
78 $ErrMsg = _('The customer record for') . ' : ' . $_SESSION['CustomerID'] . ' ' . _('cannot be retrieved because');
79 $DbgMsg = _('The SQL used to retrieve the customer details and failed was');
80 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg);
82 $myrow = DB_fetch_row($result);
85 prnMsg(_('The') . ' ' . $myrow[0] . ' ' . _('account is currently flagged as an account that needs to be watched please contact the credit control personnel to discuss'),'warn');
88 $_SESSION['SPL']->CustomerID
= $_SESSION['CustomerID'];
89 $_SESSION['SPL']->CustomerName
= $myrow[0];
90 $_SESSION['SPL']->CustCurrCode
= $myrow[2];
91 $_SESSION['SPL']->CustCurrExRate
= $myrow[3];
96 if (isset($_POST['SelectBranch'])){
100 WHERE debtorno='" . $_SESSION['SPL']->CustomerID
. "'
101 AND branchcode='" . $_POST['SelectBranch'] . "'";
102 $BranchResult = DB_query($sql,$db);
103 $myrow=DB_fetch_array($BranchResult);
104 $_SESSION['SPL']->BranchCode
= $_POST['SelectBranch'];
105 $_SESSION['SPL']->BranchName
= $myrow['brname'];
108 if (!isset($_SESSION['SPL']->BranchCode
)){
109 echo "<BR><FONT SIZE=4 COLOR=BLUE>" . _('Purchase from') . " " . $_SESSION['SPL']->SupplierName
. " " . _('in') . " " . $_SESSION['SPL']->SuppCurrCode
. " " . _('for') . " " . $_SESSION['SPL']->CustomerName
. " (" . $_SESSION['SPL']->CustCurrCode
. ")";
111 echo '<BR><FONT SIZE=4 COLOR=BLUE>' . _('Purchase from') . ' ' . $_SESSION['SPL']->SupplierName
. ' ' . _('in') . ' ' . $_SESSION['SPL']->SuppCurrCode
. ' ' . _('for') . ' ' . $_SESSION['SPL']->CustomerName
. ' (' . $_SESSION['SPL']->CustCurrCode
. ') - ' . _('delivered to') . ' ' . $_SESSION['SPL']->BranchName
. ' ' . _('branch');
114 /*if the branch details and delivery details have not been entered then select them from the list */
115 if (!isset($_SESSION['SPL']->BranchCode
)){
117 $sql = "SELECT branchcode,
120 WHERE debtorno='" . $_SESSION['CustomerID'] . "'";
121 $BranchResult = DB_query($sql,$db);
123 If (DB_num_rows($BranchResult)>0) {
125 echo '<BR><BR>' . _('Select the customer branch to deliver the special to from the list below');
127 echo '<BR><CENTER><TABLE CELLPADDING=3 COLSPAN=2 BORDER=1>';
129 $tableheader = "<TR><TD class='tableheader'>" ._('Code') . "</TD>
130 <TD class='tableheader'>" . _('Branch Name') . '</TD></TR>';
134 $k = 0; //row counter to determine background colour
136 while ($myrow=DB_fetch_array($BranchResult)) {
139 echo "<tr bgcolor='#CCCCCC'>";
142 echo "<tr bgcolor='#EEEEEE'>";
146 printf("<td><INPUT TYPE=SUBMIT NAME='SelectBranch' VALUE='%s'</td><td>%s</td></tr>", $myrow['branchcode'], $myrow['brname']);
153 //end of page full new headings if
157 echo '</TABLE></CENTER>';
159 include('includes/footer.inc');
163 prnMsg( _('There are no branches defined for the customer selected') . '. ' . _('Please select a customer that has branches defined'),'info');
164 include('includes/footer.inc');
170 If(isset($_GET['Delete'])){ /*User hit the delete link on a line */
171 $_SESSION['SPL']->remove_from_order($_GET['Delete']);
175 If(isset($_POST['EnterLine'])){
177 /*Add the header info to the session variable in any event */
179 if (strlen($_POST['QuotationRef'])<3){
180 prnMsg(_('The reference for this order is less than 3 characters') . ' - ' . _('a reference more than 3 characters is required before the order can be added'),'warn');
182 if ($_POST['Initiator']==""){
183 prnMsg( _('The person entering this order must be specified in the initiator field') . ' - ' . _('a blank initiator is not allowed'),'warn');
186 $AllowAdd = True; /*always assume the best */
188 /*THEN CHECK FOR THE WORST */
190 if (!is_numeric($_POST['Qty'])){
192 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The quantity of the order item must be numeric'),'warn');
195 if ($_POST['Qty']<0){
197 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The quantity of the ordered item entered must be a positive amount'),'warn');
200 if (!is_numeric($_POST['Price'])){
202 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The price entered must be numeric'),'warn');
205 if (!is_numeric($_POST['Cost'])){
207 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The cost entered must be numeric'),'warn');
210 if ($_POST['Price']-$_POST['Cost']<0){
212 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The sale is at a lower price than the cost'),'warn');
215 if (!is_date($_POST['ReqDelDate'])){
217 prnMsg( _('Cannot Enter this order line') . '<BR>' . _('The date entered must be in the format') . ' ' . $_SESSION['DefaultDateFormat'],'warn');
219 If ($AllowAdd == True){
221 $_SESSION['SPL']->add_to_order ($_POST['LineNo'], $_POST['Qty'], $_POST["ItemDescription"], $_POST['Price'], $_POST['Cost'], $_POST['StkCat'], $_POST['ReqDelDate']);
223 unset($_POST['Price']);
224 unset($_POST['Cost']);
225 unset($_POST['ItemDescription']);
226 unset($_POST['StkCat']);
227 unset($_POST['ReqDelDate']);
228 unset($_POST['Qty']);
232 $_SESSION['SPL']->StkLocation
= $_POST['StkLocation'];
233 $_SESSION['SPL']->Initiator
= $_POST['Initiator'];
234 $_SESSION['SPL']->QuotationRef
= $_POST['QuotationRef'];
235 $_SESSION['SPL']->Comments
= $_POST['Comments'];
236 $_SESSION['SPL']->CustRef
= $_POST['CustRef'];
239 if (isset($_POST['Commit'])){ /*User wishes to commit the order to the database */
241 /*First do some validation
242 Is the delivery information all entered*/
243 $InputError=0; /*Start off assuming the best */
244 if ($_SESSION['SPL']->StkLocation
=='' OR ! isset($_SESSION['SPL']->StkLocation
)){
245 prnMsg( _('The purchase order can not be committed to the database because there is no stock location specified to book any stock items into'),'error');
247 } elseif ($_SESSION['SPL']->LinesOnOrder
<=0){
249 prnMsg(_('The purchase order can not be committed to the database because there are no lines entered on this order'),'error');
250 }elseif (strlen($_POST['QuotationRef'])<3){
252 prnMsg( _('The reference for this order is less than 3 characters') . ' - ' . _('a reference more than 3 characters is required before the order can be added'),'error');
253 }elseif ($_POST['Initiator']==""){
255 prnMsg( _('The person entering this order must be specified in the initiator field') . ' - ' . _('a blank initiator is not allowed'),'error');
261 $sql = "SELECT contact,
269 WHERE loccode='" . $_SESSION['SPL']->StkLocation
. "'";
271 $StkLocAddResult = DB_query($sql,$db);
272 $StkLocAddress = DB_fetch_array($StkLocAddResult);
275 $result = DB_query($sql,$db);
277 /*Insert to purchase order header record */
278 $sql = "INSERT INTO purchorders (supplierno,
294 $sql = $sql . "'" . $_SESSION['SPL']->SupplierID
. "',
295 '" . $_SESSION['SPL']->Comments
. "',
296 '" . Date("Y-m-d") . "',
297 " . $_SESSION['SPL']->SuppCurrExRate
. ",
298 '" . $_SESSION['SPL']->Initiator
. "',
299 '" . $_SESSION['SPL']->QuotationRef
. "',
300 '" . $_SESSION['SPL']->StkLocation
. "',
301 '" . $StkLocAddress['deladd1'] . "',
302 '" . $StkLocAddress['deladd2'] . "',
303 '" . $StkLocAddress['deladd3'] . "',
304 '" . $StkLocAddress['deladd4'] . "',
305 '" . $StkLocAddress['deladd5'] . "',
306 '" . $StkLocAddress['deladd6'] . "',
307 '" . $StkLocAddress['contact'] . "')";
310 $ErrMsg = _('The purchase order header record could not be inserted into the database because');
311 $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was') . "<BR>$sql";
312 $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
314 /*Get the auto increment value of the order number created from the SQL above */
315 $_SESSION['SPL']->PurchOrderNo
= DB_Last_Insert_ID($db,'purchorders','orderno');
318 /*Insert the purchase order detail records */
319 foreach ($_SESSION['SPL']->LineItems
as $SPLLine) {
321 /*Set up the part codes required for this order */
323 $PartCode = "*" . $_SESSION['SPL']->PurchOrderNo
. "_" . $SPLLine->LineNo
;
325 $PartAlreadyExists =True; /*assume the worst */
327 While ($PartAlreadyExists==True) {
328 $sql = "SELECT COUNT(*) FROM stockmaster WHERE stockid = '" . $PartCode . "'";
329 $PartCountResult = DB_query($sql,$db);
330 $PartCount = DB_fetch_row($PartCountResult);
331 if ($PartCount[0]!=0){
332 $PartAlreadyExists =True;
333 if (strlen($PartCode)==20){
334 $PartCode = "*" . strtoupper(substr($_SESSION['SPL']->PurchOrderNo
,0,13)) . "_" . $SPLLine->LineNo
;
336 $PartCode = $PartCode . $Counter;
339 $PartAlreadyExists =False;
343 $_SESSION['SPL']->LineItems
[$SPLLine->LineNo
]->PartCode
= $PartCode;
345 $sql = "INSERT INTO stockmaster (stockid,
350 VALUES ('" . $PartCode . "',
351 '" . $SPLLine->StkCat
. "',
352 '" . $SPLLine->ItemDescription
. "',
353 '" . $SPLLine->ItemDescription
. "',
354 " . $SPLLine->Cost
. ")";
357 $ErrMsg = _('The item record for line') . " " . $SPLLine->LineNo
. " " . _('could not be create because');
358 $DbgMsg = _('The SQL statement used to insert the item and failed was') . "<BR>$sql";
360 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
362 $sql = "INSERT INTO locstock (loccode, stockid) SELECT loccode,'" . $PartCode . "' FROM locations";
363 $ErrMsg = _('The item stock locations for the special order line') . " " . $SPLLine->LineNo
. " " ._('could not be created because');
364 $DbgMsg = _('The SQL statement used to insert the location stock records and failed was');
365 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
367 /*need to get the stock category GL information */
368 $sql = "SELECT stockact FROM stockcategory WHERE categoryid = '" . $SPLLine->StkCat
. "'";
369 $ErrMsg = _('The item stock category information for the special order line') ." " . $SPLLine->LineNo
. " " . _('could not be retrieved because');
370 $DbgMsg = _('The SQL statement used to get the category information and that failed was');
371 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
373 $StkCatGL=DB_fetch_row($result);
374 $GLCode = $StkCatGL[0];
376 $OrderDate = FormatDateForSQL($SPLLine->ReqDelDate
);
378 $sql = "INSERT INTO purchorderdetails (orderno,
386 $sql = $sql . $_SESSION['SPL']->PurchOrderNo
. ",
388 '" . $OrderDate . "',
389 '" . $SPLLine->ItemDescription
. "',
391 " . $SPLLine->Cost
. ",
392 " . $SPLLine->Quantity
. ")";
394 $ErrMsg = _('One of the purchase order detail records could not be inserted into the database because');
395 $DbgMsg = _('The SQL statement used to insert the purchase order detail record and failed was');
396 $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
398 } /* end of the loop round the detail line items on the order */
400 echo '<BR><BR>' . _('Purchase order') . ' ' . $_SESSION['SPL']->PurchOrderNo
. ' ' . _('on') . ' ' . $_SESSION['SPL']->SupplierName
. ' ' . _('has been created');
401 echo "<BR><A HREF='$rootpath/PO_PDFPurchOrder.php?" . SID
. '&OrderNo=' . $_SESSION['SPL']->PurchOrderNo
. "'>" . _('Print Purchase Order') . '</A>';
403 /*Now insert the sales order too */
405 /*First get the customer delivery information */
406 $sql = "SELECT salestype,
417 FROM custbranch INNER JOIN debtorsmaster
418 ON custbranch.debtorno=debtorsmaster.debtorno
419 WHERE custbranch.debtorno='" . $_SESSION['SPL']->CustomerID
. "'
420 AND custbranch.branchcode = '" . $_SESSION['SPL']->BranchCode
. "'";
422 $ErrMsg = _('The delivery and sales type for the customer could not be retrieved for this special order') . " " . $SPLLine->LineNo
. " " . _('because');
423 $DbgMsg = _('The SQL statement used to get the delivery details and that failed was');
424 $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
426 $BranchDetails=DB_fetch_array($result);
428 $HeaderSQL = "INSERT INTO salesorders (debtorno,
445 VALUES ('" . $_SESSION['SPL']->CustomerID
. "',
446 '" . $_SESSION['SPL']->BranchCode
. "',
447 '". $_SESSION['SPL']->CustRef
."',
448 '" . Date("Y-m-d") . "',
449 '" . $BranchDetails['salestype'] . "',
450 " . $BranchDetails['defaultshipvia'] .",
451 '" . $BranchDetails['brname'] . "',
452 '" . $BranchDetails['braddress1'] . "',
453 '" . $BranchDetails['braddress2'] . "',
454 '" . $BranchDetails['braddress3'] . "',
455 '" . $BranchDetails['braddress4'] . "',
456 '" . $BranchDetails['braddress5'] . "',
457 '" . $BranchDetails['braddress6'] . "',
458 '" . $BranchDetails['phoneno'] . "',
459 '" . $BranchDetails['email'] . "',
460 '" . $_SESSION['SPL']->StkLocation
."',
461 '" . $OrderDate . "')";
463 $ErrMsg = _('The sales order cannot be added because');
464 $InsertQryResult = DB_query($HeaderSQL,$db,$ErrMsg);
466 $SalesOrderNo = DB_Last_Insert_ID($db,'salesorders','orderno');
468 $StartOf_LineItemsSQL = "INSERT INTO salesorderdetails (orderno,
473 VALUES (" . $SalesOrderNo;
475 $ErrMsg = _('There was a problem inserting a line into the sales order because');
477 foreach ($_SESSION['SPL']->LineItems
as $StockItem) {
479 $LineItemsSQL = $StartOf_LineItemsSQL . ", '" . $StockItem->PartCode
. "',". $StockItem->Price
. ", " . $StockItem->Quantity
. ", " . $StockItem->LineNo
. ")";
480 $Ins_LineItemResult = DB_query($LineItemsSQL,$db,$ErrMsg);
482 } /* inserted line items into sales order details */
484 unset ($_SESSION['SPL']);
485 prnMsg(_('Sales Order Number') . ' ' . $SalesOrderNo . ' ' . _('has been entered') . '. <P>' . _('Orders created on a cash sales account may need the delivery details for the order to be modified') . '. <br><br>' . _('A freight charge may also be applicable'),'success');
487 if (count($_SESSION['AllowedPageSecurityTokens'])>1){
489 /* Only allow print of packing slip for internal staff - customer logon's cannot go here */
490 echo "<P><A HREF='$rootpath/PrintCustOrder.php?" . SID
. "&TransNo=" . $SalesOrderNo . "'>" . _('Print packing slip') . ' (' . _('Preprinted stationery') . ')</A>';
491 echo "<P><A HREF='$rootpath/PrintCustOrder_generic.php?" . SID
. '&TransNo=' . $SalesOrderNo . "'>" . _('Print packing slip') . ' (' . _('Laser') . ')</A>';
495 $Result = DB_query('COMMIT',$db);
497 unset($_SESSION['SPL']); /*Clear the PO data to allow a newy to be input*/
498 echo "<BR><BR><A HREF='$rootpath/SpecialOrder.php?" . SID
. "'>" . _('Enter A New Special Order') . "</A>";
500 } /*end if there were no input errors trapped */
501 } /* end of the code to do transfer the SPL object to the database - user hit the place Order*/
504 /*Show the header information for modification */
506 echo "<TABLE><TR><TD>" . _('Receive Purchase Into and Sell From') . ": <SELECT NAME='StkLocation'>";
508 $sql = "SELECT loccode, locationname FROM locations";
509 $LocnResult = DB_query($sql,$db);
510 if (!isset($_SESSION['SPL']->StkLocation
) OR $_SESSION['SPL']->StkLocation
==""){ /*If this is the first time the form loaded set up defaults */
511 $_SESSION['SPL']->StkLocation
= $_SESSION['UserStockLocation'];
514 while ($LocnRow=DB_fetch_array($LocnResult)){
515 if ($_SESSION['SPL']->StkLocation
== $LocnRow['loccode']){
516 echo "<OPTION SELECTED Value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname'];
518 echo "<OPTION Value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname'];
521 echo "</SELECT></TD>";
523 echo "<TD>" . _('Initiated By') . ": <INPUT TYPE=TEXT NAME='Initiator' SIZE=11 MAXLENGTH=10 VALUE=" . $_SESSION['SPL']->Initiator
. "></TD>";
524 echo "<TD>" . _('Special Ref') . ": <INPUT TYPE=TEXT NAME='QuotationRef' SIZE=16 MAXLENGTH=15 VALUE=" . $_SESSION['SPL']->QuotationRef
. "></TD>";
525 echo "<TD>" . _('Customer Ref') . ": <INPUT TYPE=TEXT NAME='CustRef' SIZE=11 MAXLENGTH=10 VALUE=" . $_SESSION['SPL']->CustRef
. "></TD></TR>";
527 echo "<TR><TD VALIGN=TOP COLSPAN=2>" . _('Comments') . ":";
528 echo "<textarea name='Comments' cols=70 rows=2>" . $_SESSION['SPL']->Comments
. "</textarea></TD></TR></TABLE>";
530 echo "<HR>"; /* Rule off the header */
532 /*Now show the order so far */
534 if (count($_SESSION['SPL']->LineItems
)>0){
536 echo "<CENTER><B>" . _('Special Order Summary') . "</B>";
537 echo "<TABLE CELLPADDING=2 COLSPAN=7 BORDER=1>";
540 <TD class='tableheader'>" . _('Item Description') . "</TD>
541 <TD class='tableheader'>" . _('Delivery') . "</TD>
542 <TD class='tableheader'>" . _('Quantity') . "</TD>
543 <TD class='tableheader'>" . _('Purchase Cost') . "</TD>
544 <TD class='tableheader'>" . _('Sell Price') . "</TD>
545 <TD class='tableheader'>" . _('Total Cost') . "</TD>
546 <TD class='tableheader'>" . _('Total Price') . "</TD>
549 $_SESSION['SPL']->total
= 0;
550 $k = 0; //row colour counter
551 foreach ($_SESSION['SPL']->LineItems
as $SPLLine) {
553 $LineTotal = $SPLLine->Quantity
* $SPLLine->Price
;
554 $LineCostTotal = $SPLLine->Quantity
* $SPLLine->Cost
;
555 $DisplayLineTotal = number_format($LineTotal,2);
556 $DisplayLineCostTotal = number_format($LineCostTotal,2);
557 $DisplayCost = number_format($SPLLine->Cost
,2);
558 $DisplayPrice = number_format($SPLLine->Price
,2);
559 $DisplayQuantity = number_format($SPLLine->Quantity
,2);
562 echo "<tr bgcolor='#CCCCCC'>";
565 echo "<tr bgcolor='#EEEEEE'>";
568 echo '<TD>' . $SPLLine->ItemDescription
. '</TD>
569 <TD>' . $SPLLine->ReqDelDate
. "</TD>
570 <TD ALIGN=RIGHT>$DisplayQuantity</TD>
571 <TD ALIGN=RIGHT>$DisplayCost</TD>
572 <TD ALIGN=RIGHT>$DisplayPrice</TD>
573 <TD ALIGN=RIGHT>$DisplayLineCostTotal</TD>
574 <TD ALIGN=RIGHT>$DisplayLineTotal</TD>
575 <TD><A HREF='" . $_SERVER['PHP_SELF'] . "?" . SID
.'&Delete=' . $SPLLine->LineNo
. "'>" . _('Delete') . '</A></TD></TR>';
577 $_SESSION['SPL']->total
= $_SESSION['SPL']->total +
$LineTotal;
580 $DisplayTotal = number_format($_SESSION['SPL']->total
,2);
582 <TD COLSPAN=6 ALIGN=RIGHT>' . _('TOTAL Excl Tax') . "</TD>
583 <TD ALIGN=RIGHT><B>$DisplayTotal</B></TD>
588 /*Set up the form to enter new special items into */
590 echo "<CENTER><TABLE>";
592 echo "<input type='hidden' name='LineNo' value=" . ($_SESSION['SPL']->LinesOnOrder +
1) .">";
594 echo '<TR><TD>' . _('Ordered item Description') . ":</TD><TD><INPUT TYPE=TEXT NAME='ItemDescription' SIZE=40 MAXLENGTH=40 VALUE='" . $_POST['ItemDescription'] . "'></TD></TR>";
596 echo '<TR><TD>' . _('Category') . ':</TD><TD><SELECT name=StkCat>';
598 $sql = "SELECT categoryid, categorydescription FROM stockcategory";
599 $ErrMsg = _('The stock categories could not be retrieved because');
600 $DbgMsg = _('The SQL used to retrieve stock categories and failed was');
601 $result = DB_query($sql,$db, $ErrMsg, $DbgMsg);
603 while ($myrow=DB_fetch_array($result)){
604 if ($myrow['categoryid']==$_POST['StkCat']){
605 echo "<OPTION SELECTED VALUE='". $myrow['categoryid'] . "'>" . $myrow['categorydescription'];
607 echo "<OPTION VALUE='". $myrow['categoryid'] . "'>" . $myrow['categorydescription'];
610 echo '</SELECT></TD></TR>';
613 /*default the order quantity to 1 unit */
616 echo '<TR><TD>' . _('Order Quantity') . ":</TD>
617 <TD><input type='Text' SIZE=7 MAXLENGTH=6 name='Qty' value=" . $_POST['Qty'] . "></TD></TR>";
618 echo '<TR><TD>' . _('Unit Cost') . ":</TD>
619 <TD><input type='Text' SIZE=15 MAXLENGTH=14 name='Cost' value=" . $_POST['Cost'] . "></TD></TR>";
620 echo '<TR><TD>' . _('Unit Price') . ":</TD>
621 <TD><input type='Text' SIZE=15 MAXLENGTH=14 name='Price' value=" . $_POST['Price'] . "></TD></TR>";
623 /*Default the required delivery date to tomorrow as a starting point */
624 $_POST['ReqDelDate'] = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,Date('m'),Date('d')+
1,Date('y')));
626 echo '<TR><TD>' . _('Required Delivery Date') . ":</TD>
627 <TD><input type='Text' SIZE=12 MAXLENGTH=11 name='ReqDelDate' value=" . $_POST['ReqDelDate'] . "></TD></TR>";
629 echo '</TABLE>'; /* end of main table */
631 echo "<INPUT TYPE=SUBMIT Name='EnterLine' VALUE='" . _('Add Item to Order') . "'>";
633 echo "<BR><BR><INPUT TYPE=SUBMIT Name='Cancel' VALUE='" . _('Start Again') . "'>";
634 echo "<BR><BR><INPUT TYPE=SUBMIT Name='Commit' VALUE='" . _('Process This Order') . "'>";
637 include('includes/footer.inc');