From: <dai...@us...> - 2012-12-05 08:39:19
|
Revision: 5752 http://sourceforge.net/p/web-erp/reponame/5752 Author: daintree Date: 2012-12-05 08:39:15 +0000 (Wed, 05 Dec 2012) Log Message: ----------- Allow auto receiving of purchase orders and populating of supplier invoice for authorised purchase orders to short circuit entry of supplier invoices Modified Paths: -------------- trunk/Customers.php trunk/GoodsReceived.php trunk/PO_Header.php trunk/PO_Items.php trunk/PO_PDFPurchOrder.php trunk/PO_SelectOSPurchOrder.php trunk/SuppFixedAssetChgs.php trunk/SuppInvGRNs.php trunk/SupplierInvoice.php trunk/doc/Change.log trunk/doc/Manual/ManualPurchaseOrdering.html Removed Paths: ------------- trunk/companies/companies.inf Modified: trunk/Customers.php =================================================================== --- trunk/Customers.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/Customers.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -334,9 +334,6 @@ unset($_POST['Address4']); unset($_POST['Address5']); unset($_POST['Address6']); - unset($_POST['Phone']); - unset($_POST['Fax']); - unset($_POST['Email']); unset($_POST['HoldReason']); unset($_POST['PaymentTerms']); unset($_POST['Discount']); @@ -440,13 +437,7 @@ echo '<tr><td>' . _('Customer Name') . ':</td> <td><input tabindex="2" type="text" name="CustName" size="42" maxlength="40" /></td></tr>'; - echo '<tr><td>' . _('Telephone') . ':</td> - <td><input tabindex="2" type="text" name="Phone" size="30" maxlength="40" /></td></tr>'; - echo '<tr><td>' . _('Facsimile') . ':</td> - <td><input tabindex="2" type="text" name="Fax" size="30" maxlength="40" /></td></tr>'; - echo '<tr><td>' . _('Email Address') . ':</td> - <td><input tabindex="2" type="text" name="Email" size="30" maxlength="40" /></td></tr>'; - echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td> + echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td> <td><input tabindex="3" type="text" name="Address1" size="42" maxlength="40" /></td></tr>'; echo '<tr><td>' . _('Address Line 2 (Street)') . ':</td> <td><input tabindex="4" type="text" name="Address2" size="42" maxlength="40" /></td></tr>'; Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/GoodsReceived.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -25,7 +25,7 @@ echo '<a href="'. $rootpath . '/PO_SelectOSPurchOrder.php">' . _('Back to Purchase Orders'). '</a> <br />'; -if (isset($_GET['PONumber']) and $_GET['PONumber']<=0 and !isset($_SESSION['PO'.$identifier])) { +if (isset($_GET['PONumber']) AND $_GET['PONumber']<=0 AND !isset($_SESSION['PO'.$identifier])) { /* This page can only be called with a purchase order number for invoicing*/ echo '<div class="centre"> <a href= "' . $rootpath . '/PO_SelectOSPurchOrder.php">' . _('Select a purchase order to receive').'</a> Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/PO_Header.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -8,15 +8,18 @@ if (isset($_GET['ModifyOrderNumber'])) { $title = _('Modify Purchase Order') . ' ' . $_GET['ModifyOrderNumber']; -} //isset($_GET['ModifyOrderNumber']) -else { +} else { $title = _('Purchase Order Entry'); } if (isset($_GET['SupplierID'])) { $_POST['Select'] = $_GET['SupplierID']; -} //isset($_GET['SupplierID']) +} +/* webERP manual links before header.inc */ +$ViewTopic= 'PurchaseOrdering'; +$BookMark = 'PurchaseOrdering'; + include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); @@ -30,8 +33,7 @@ if (empty($_GET['identifier'])) { $identifier = date('U'); -} //empty($_GET['identifier']) -else { +} else { $identifier = $_GET['identifier']; } @@ -39,10 +41,10 @@ * the session variable that holds all the PO data $_SESSION['PO'][$identifier] * is unset to allow all new details to be created */ -if (isset($_GET['NewOrder']) and isset($_SESSION['PO' . $identifier])) { +if (isset($_GET['NewOrder']) AND isset($_SESSION['PO' . $identifier])) { unset($_SESSION['PO' . $identifier]); $_SESSION['ExistingOrder'] = 0; -} //isset($_GET['NewOrder']) and isset($_SESSION['PO' . $identifier]) +} if (isset($_POST['Select']) AND empty($_POST['SupplierContact'])) { $sql = "SELECT contact @@ -53,18 +55,17 @@ if (DB_num_rows($SuppCoResult) > 0) { $myrow = DB_fetch_row($SuppCoResult); $_POST['SupplierContact'] = $myrow[0]; - } //DB_num_rows($SuppCoResult) > 0 - else { + } else { $_POST['SupplierContact'] = ''; } -} //isset($_POST['Select']) AND empty($_POST['SupplierContact']) +} if ((isset($_POST['UpdateStatus']) AND $_POST['UpdateStatus'] != '')) { + if ($_SESSION['ExistingOrder'] == 0) { prnMsg(_('This is a new order. It must be created before you can change the status'), 'warn'); $OKToUpdateStatus = 0; - } //$_SESSION['ExistingOrder'] == 0 - elseif ($_SESSION['PO' . $identifier]->Status != $_POST['Status']) { //the old status != new status + } elseif ($_SESSION['PO' . $identifier]->Status != $_POST['Status']) { //the old status != new status $OKToUpdateStatus = 1; $AuthSQL = "SELECT authlevel FROM purchorderauth @@ -78,11 +79,10 @@ if ($_POST['StatusComments'] != '') { $_POST['StatusComments'] = ' - ' . $_POST['StatusComments']; - } //$_POST['StatusComments'] != '' + } if (IsEmailAddress($_SESSION['UserEmail'])) { $UserChangedStatus = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName'] . '</a>'; - } //IsEmailAddress($_SESSION['UserEmail']) - else { + } else { $UserChangedStatus = ' ' . $_SESSION['UsersRealName'] . ' '; } @@ -90,32 +90,29 @@ if ($AuthorityLevel > $OrderTotal) { $_SESSION['PO' . $identifier]->StatusComments = date($_SESSION['DefaultDateFormat']) . ' - ' . _('Authorised by') . $UserChangedStatus . $_POST['StatusComments'] . '<br />' . html_entity_decode($_POST['StatusCommentsComplete'], ENT_QUOTES, 'UTF-8'); $_SESSION['PO' . $identifier]->AllowPrintPO = 1; - } //$AuthorityLevel > $OrderTotal - else { + } else { $OKToUpdateStatus = 0; prnMsg(_('You do not have permission to authorise this purchase order') . '.<br />' . _('This order is for') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $OrderTotal . '. ' . _('You can only authorise up to') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $AuthorityLevel . '.<br />' . _('If you think this is a mistake please contact the systems administrator'), 'warn'); } - } //$_POST['Status'] == 'Authorised' + } - if ($_POST['Status'] == 'Rejected' OR $_POST['Status'] == 'Cancelled') { if (!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder'] != 0) { /* need to check that not already dispatched or invoiced by the supplier */ if ($_SESSION['PO' . $identifier]->Any_Already_Received() == 1) { $OKToUpdateStatus = 0; //not ok to update the status prnMsg(_('This order cannot be cancelled or rejected because some of it has already been received') . '. ' . _('The line item quantities may be modified to quantities more than already received') . '. ' . _('Prices cannot be altered for lines that have already been received') . ' ' . _('and quantities cannot be reduced below the quantity already received'), 'warn'); - } //$_SESSION['PO' . $identifier]->Any_Already_Received() == 1 + } $ShipmentExists = $_SESSION['PO' . $identifier]->Any_Lines_On_A_Shipment(); if ($ShipmentExists != false) { $OKToUpdateStatus = 0; //not ok to update the status prnMsg(_('This order cannot be cancelled or rejected because there is at least one line that is allocated to a shipment') . '. ' . _('See shipment number') . ' ' . $ShipmentExists, 'warn'); - } //$ShipmentExists != false + } } //!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder'] != 0 if ($OKToUpdateStatus == 1) { // none of the order has been received if ($AuthorityLevel > $OrderTotal) { $_SESSION['PO' . $identifier]->StatusComments = date($_SESSION['DefaultDateFormat']) . ' - ' . $_POST['Status'] . ' ' . _('by') . $UserChangedStatus . $_POST['StatusComments'] . '<br />' . html_entity_decode($_POST['StatusCommentsComplete'], ENT_QUOTES, 'UTF-8'); - } //$AuthorityLevel > $OrderTotal - else { + } else { $OKToUpdateStatus = 0; prnMsg(_('You do not have permission to reject this purchase order') . '.<br />' . _('This order is for') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $OrderTotal . '. ' . _('Your authorisation limit is set at') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $AuthorityLevel . '.<br />' . _('If you think this is a mistake please contact the systems administrator'), 'warn'); } @@ -123,16 +120,16 @@ } //$_POST['Status'] == 'Rejected' OR $_POST['Status'] == 'Cancelled' if ($_POST['Status'] == 'Pending') { + if ($_SESSION['PO' . $identifier]->Any_Already_Received() == 1) { $OKToUpdateStatus = 0; //not OK to update status prnMsg(_('This order could not have the status changed back to pending because some of it has already been received. Quantities received will need to be returned to change the order back to pending.'), 'warn'); - } //$_SESSION['PO' . $identifier]->Any_Already_Received() == 1 + } if (($AuthorityLevel > $OrderTotal OR $_SESSION['UserID'] == $_SESSION['PO' . $identifier]->Initiator) AND $OKToUpdateStatus == 1) { $_SESSION['PO' . $identifier]->StatusComments = date($_SESSION['DefaultDateFormat']) . ' - ' . _('Order set to pending status by') . $UserChangedStatus . $_POST['StatusComments'] . '<br />' . html_entity_decode($_POST['StatusCommentsComplete'], ENT_QUOTES, 'UTF-8'); - } //($AuthorityLevel > $OrderTotal OR $_SESSION['UserID'] == $_SESSION['PO' . $identifier]->Initiator) AND $OKToUpdateStatus == 1 - elseif ($AuthorityLevel < $OrderTotal AND $_SESSION['UserID'] != $_SESSION['PO' . $identifier]->Initiator) { + } elseif ($AuthorityLevel < $OrderTotal AND $_SESSION['UserID'] != $_SESSION['PO' . $identifier]->Initiator) { $OKToUpdateStatus = 0; prnMsg(_('You do not have permission to change the status of this purchase order') . '.<br />' . _('This order is for') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $OrderTotal . '. ' . _('Your authorisation limit is set at') . ' ' . $_SESSION['PO' . $identifier]->CurrCode . ' ' . $AuthorityLevel . '.<br />' . _('If you think this is a mistake please contact the systems administrator'), 'warn'); } //$AuthorityLevel < $OrderTotal AND $_SESSION['UserID'] != $_SESSION['PO' . $identifier]->Initiator @@ -155,7 +152,7 @@ $UpdateResult = DB_query($SQL, $db, $ErrMsg); } //$OKToUpdateStatus == 1 } //end if there is actually a status change the class Status != the POST['Status'] -} //(isset($_POST['UpdateStatus']) AND $_POST['UpdateStatus'] != '') +} //End if user hit Update Status if (isset($_GET['NewOrder']) AND isset($_GET['StockID']) AND isset($_GET['SelectedSupplier'])) { /* @@ -183,7 +180,7 @@ */ $Purch_Item = $_GET['StockID']; -} //isset($_GET['NewOrder']) AND isset($_GET['StockID']) AND isset($_GET['SelectedSupplier']) +} //End if it's a new order sent with supplier code and the item to order if (isset($_POST['EnterLines']) OR isset($_POST['AllowRePrint'])) { /*User hit the button to enter line items - @@ -213,7 +210,7 @@ $_SESSION['PO' . $identifier]->DeliveryBy = $_POST['DeliveryBy']; if (isset($_POST['StatusComments'])) { $_SESSION['PO' . $identifier]->StatusComments = $_POST['StatusComments']; - } //isset($_POST['StatusComments']) + } $_SESSION['PO' . $identifier]->PaymentTerms = $_POST['PaymentTerms']; $_SESSION['PO' . $identifier]->Contact = $_POST['Contact']; $_SESSION['PO' . $identifier]->Tel = $_POST['Tel']; @@ -228,7 +225,7 @@ $ErrMsg = _('An error occurred updating the purchase order to allow reprints') . '. ' . _('The error says'); $UpdateResult = DB_query($sql, $db, $ErrMsg); - } //isset($_POST['RePrint']) AND $_POST['RePrint'] == 1 + } //end if change to allow reprint else { $_POST['RePrint'] = 0; } @@ -238,7 +235,7 @@ prnMsg(_('You should automatically be forwarded to the entry of the purchase order line items page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $rootpath . '/PO_Items.php?identifier=' . $identifier . '">' . _('click here') . '</a> ' . _('to continue'), 'info'); include('includes/footer.inc'); exit; - } //!isset($_POST['AllowRePrint']) + } // end if reprint not allowed } //isset($_POST['EnterLines']) OR isset($_POST['AllowRePrint']) /* end of if isset _POST'EnterLines' */ @@ -275,31 +272,33 @@ * variable supplierID holds the supplier code already * as determined from user id /password entry */ $_SESSION['RequireSupplierSelection'] = 1; - } //$_SESSION['PO' . $identifier]->SupplierID == '' OR !isset($_SESSION['PO' . $identifier]->SupplierID) - else { + } else { $_SESSION['RequireSupplierSelection'] = 0; } -} //!isset($_SESSION['PO' . $identifier]) +} //end if initiating a new PO if (isset($_POST['ChangeSupplier'])) { if ($_SESSION['PO' . $identifier]->Status == 'Pending' AND $_SESSION['UserID'] == $_SESSION['PO' . $identifier]->Initiator) { + if ($_SESSION['PO' . $identifier]->Any_Already_Received() == 0) { + $_SESSION['RequireSupplierSelection'] = 1; $_SESSION['PO' . $identifier]->Status = 'Pending'; $_SESSION['PO' . $identifier]->StatusComments == date($_SESSION['DefaultDateFormat']) . ' - ' . _('Supplier changed by') . ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UserID'] . '</a> - ' . $_POST['StatusComments'] . '<br />' . html_entity_decode($_POST['StatusCommentsComplete'], ENT_QUOTES, 'UTF-8'); - } //$_SESSION['PO' . $identifier]->Any_Already_Received() == 0 - else { + + } else { + echo '<br /><br />'; prnMsg(_('Cannot modify the supplier of the order once some of the order has been received'), 'warn'); } - } //$_SESSION['PO' . $identifier]->Status == 'Pending' AND $_SESSION['UserID'] == $_SESSION['PO' . $identifier]->Initiator -} //isset($_POST['ChangeSupplier']) + } +} //user hit ChangeSupplier if (isset($_POST['SearchSuppliers'])) { if (mb_strlen($_POST['Keywords']) > 0 AND mb_strlen($_SESSION['PO' . $identifier]->SupplierID) > 0) { prnMsg(_('Supplier name keywords have been used in preference to the supplier code extract entered'), 'warn'); - } //mb_strlen($_POST['Keywords']) > 0 AND mb_strlen($_SESSION['PO' . $identifier]->SupplierID) > 0 + } if (mb_strlen($_POST['Keywords']) > 0) { //insert wildcard characters in spaces $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; @@ -317,8 +316,8 @@ WHERE suppliers.suppname " . LIKE . " '" . $SearchString . "' ORDER BY suppliers.suppname"; - } //mb_strlen($_POST['Keywords']) > 0 - elseif (mb_strlen($_POST['SuppCode']) > 0) { + } elseif (mb_strlen($_POST['SuppCode']) > 0) { + $SQL = "SELECT suppliers.supplierid, suppliers.suppname, suppliers.address1, @@ -331,19 +330,19 @@ FROM suppliers WHERE suppliers.supplierid " . LIKE . " '%" . $_POST['SuppCode'] . "%' ORDER BY suppliers.supplierid"; - } //mb_strlen($_POST['SuppCode']) > 0 - else { + } else { + $SQL = "SELECT suppliers.supplierid, - suppliers.suppname, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.currcode - FROM suppliers - ORDER BY suppliers.supplierid"; + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + ORDER BY suppliers.supplierid"; } $ErrMsg = _('The searched supplier records requested cannot be retrieved because'); @@ -352,15 +351,12 @@ if (DB_num_rows($result_SuppSelect) == 1) { $myrow = DB_fetch_array($result_SuppSelect); $_POST['Select'] = $myrow['supplierid']; - } //DB_num_rows($result_SuppSelect) == 1 - elseif (DB_num_rows($result_SuppSelect) == 0) { + } elseif (DB_num_rows($result_SuppSelect) == 0) { prnMsg(_('No supplier records contain the selected text') . ' - ' . _('please alter your search criteria and try again'), 'info'); - } //DB_num_rows($result_SuppSelect) == 0 -} //isset($_POST['SearchSuppliers']) + } +} /*end of if search for supplier codes/names */ -/*end of if search for supplier codes/names */ - if ((!isset($_POST['SearchSuppliers']) or $_POST['SearchSuppliers'] == '') AND (isset($_SESSION['PO' . $identifier]->SupplierID) AND $_SESSION['PO' . $identifier]->SupplierID != '')) { /*The session variables are set but the form variables could have been lost * need to restore the form variables from the session */ @@ -383,7 +379,7 @@ $_POST['SuppDelAdd6'] = $_SESSION['PO' . $identifier]->SuppDelAdd6; $_POST['DeliveryDate'] = $_SESSION['PO' . $identifier]->DeliveryDate; -} //(!isset($_POST['SearchSuppliers']) or $_POST['SearchSuppliers'] == '') AND (isset($_SESSION['PO' . $identifier]->SupplierID) AND $_SESSION['PO' . $identifier]->SupplierID != '') +} if (isset($_POST['Select'])) { /* will only be true if page called from supplier selection form or item purchasing data order link @@ -451,8 +447,8 @@ $_SESSION['PO' . $identifier]->SuppTel = $_POST['SuppTel']; $_SESSION['PO' . $identifier]->Port = $_POST['Port']; - } //($AuthRow = DB_fetch_array($AuthResult) and $AuthRow['cancreate'] == 0) - else { + } else { + prnMsg(_('You do not have the authority to raise Purchase Orders for') . ' ' . $myrow['suppname'] . '. ' . _('Please Consult your system administrator for more information.') . '<br />' . _('You can setup authorisations') . ' ' . '<a href="PO_AuthorisationLevels.php">' . _('here') . '</a>', 'warn'); include('includes/footer.inc'); exit; @@ -460,7 +456,9 @@ // end of added for suppliers lookup fields -} //isset($_POST['Select']) +} /* isset($_POST['Select']) will only be true if page called from supplier selection form or item purchasing data order link + * or set because only one supplier record returned from a search + */ else { $_POST['Select'] = $_SESSION['PO' . $identifier]->SupplierID; $sql = "SELECT suppliers.suppname, @@ -518,8 +516,8 @@ $_SESSION['PO' . $identifier]->SuppTel = $_POST['SuppTel']; $_SESSION['PO' . $identifier]->Port = $_POST['Port']; // end of added for suppliers lookup fields - } //!isset($_SESSION['PO' . $identifier]) -} + } +} // NOT isset($_POST['Select']) - not called with supplier selection so update variables // part of step 1 if ($_SESSION['RequireSupplierSelection'] == 1 OR !isset($_SESSION['PO' . $identifier]->SupplierID) OR $_SESSION['PO' . $identifier]->SupplierID == '') { @@ -527,17 +525,18 @@ echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier=' . $identifier . '" method="post" id="choosesupplier">'; echo '<div>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + if (isset($SuppliersReturned)) { echo '<input type="hidden" name="SuppliersReturned" value="' . $SuppliersReturned . '" />'; - } //isset($SuppliersReturned) - + } + echo '<table cellpadding="3" class="selection"> <tr> - <td>' . _('Enter text in the supplier name') . ':</td> - <td><input type="text" name="Keywords" size="20" maxlength="25" /></td> - <td><h3><b>' . _('OR') . '</b></h3></td> - <td>' . _('Enter text extract in the supplier code') . ':</td> - <td><input type="text" name="SuppCode" size="15" maxlength="18" /></td> + <td>' . _('Enter text in the supplier name') . ':</td> + <td><input type="text" name="Keywords" size="20" maxlength="25" /></td> + <td><h3><b>' . _('OR') . '</b></h3></td> + <td>' . _('Enter text extract in the supplier code') . ':</td> + <td><input type="text" name="SuppCode" size="15" maxlength="18" /></td> </tr> </table> <br /> @@ -551,12 +550,12 @@ echo '<br /><table cellpadding="3" class="selection">'; $tableheader = '<tr> - <th>' . _('Code') . '</th> - <th>' . _('Supplier Name') . '</th> - <th>' . _('Address') . '</th> - <th>' . _('Currency') . '</th> - </tr>'; - + <th>' . _('Code') . '</th> + <th>' . _('Supplier Name') . '</th> + <th>' . _('Address') . '</th> + <th>' . _('Currency') . '</th> + </tr>'; + echo $tableheader; $j = 1; @@ -567,8 +566,7 @@ if ($k == 1) { echo '<tr class="EvenTableRows">'; $k = 0; - } //$k == 1 - else { + } else { echo '<tr class="OddTableRows">'; $k++; } @@ -579,22 +577,22 @@ for ($i = 1; $i <= 6; $i++) { if ($myrow['address' . $i] != '') { echo $myrow['address' . $i] . '<br />'; - } //$myrow['address' . $i] != '' - } //$i = 1; $i <= 6; $i++ - echo '</td><td>' . $myrow['currcode'] . '</td></tr>'; + } + } + echo '</td> + <td>' . $myrow['currcode'] . '</td> + </tr>'; //end of page full new headings if - } //$myrow = DB_fetch_array($result_SuppSelect) - //end of while loop + } //end of while loop echo '</table>'; - } //isset($result_SuppSelect) + } //end if results to show //end if RequireSupplierSelection -} //$_SESSION['RequireSupplierSelection'] == 1 OR !isset($_SESSION['PO' . $identifier]->SupplierID) OR $_SESSION['PO' . $identifier]->SupplierID == '' -else { +} else { /* everything below here only do if a supplier is selected */ echo '<form id="form1" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier=' . $identifier . '" method="post">'; @@ -608,8 +606,8 @@ if ($_SESSION['ExistingOrder']) { echo _(' Modify Purchase Order Number') . ' ' . $_SESSION['PO' . $identifier]->OrderNo; - } //$_SESSION['ExistingOrder'] - + } + if (isset($Purch_Item)) { /*This is set if the user hits the link from the supplier purchasing info shown on SelectProduct.php */ prnMsg(_('Purchase Item(s) with this code') . ': ' . $Purch_Item, 'info'); @@ -631,8 +629,7 @@ if (isset($_GET['Quantity'])) { $Qty = $_GET['Quantity']; - } //isset($_GET['Quantity']) - else { + } else { $Qty = 1; } @@ -658,16 +655,17 @@ if (!isset($PurchItemRow['conversionfactor'])) { $PurchItemRow['conversionfactor'] = 1; - } //!isset($PurchItemRow['conversionfactor']) + } + if (!isset($PurchItemRow['leadtime'])) { $PurchItemRow['leadtime'] = 1; - } //!isset($PurchItemRow['leadtime']) - + } + $_SESSION['PO' . $identifier]->add_to_order(1, $Purch_Item, $PurchItemRow['serialised'], $PurchItemRow['controlled'], $Qty * $PurchItemRow['conversionfactor'], $PurchItemRow['description'], $PurchItemRow['price'] / $PurchItemRow['conversionfactor'], $PurchItemRow['units'], $PurchItemRow['stockact'], $_SESSION['PO' . $identifier]->DeliveryDate, 0, 0, '', 0, 0, '', $PurchItemRow['decimalplaces'], $PurchItemRow['suppliersuom'], $PurchItemRow['conversionfactor'], $PurchItemRow['leadtime'], $PurchItemRow['suppliers_partno']); echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/PO_Items.php?identifier=' . $identifier . '">'; - } //isset($Purch_Item) - + } + /*Set up form for entry of order header stuff */ if (!isset($_POST['LookupDeliveryAddress']) and (!isset($_POST['StkLocation']) or $_POST['StkLocation']) AND (isset($_SESSION['PO' . $identifier]->Location) AND $_SESSION['PO' . $identifier]->Location != '')) { @@ -695,8 +693,8 @@ $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); $_POST['InitiatorName'] = $myrow['realname']; - } //!isset($_POST['LookupDeliveryAddress']) and (!isset($_POST['StkLocation']) or $_POST['StkLocation']) AND (isset($_SESSION['PO' . $identifier]->Location) AND $_SESSION['PO' . $identifier]->Location != '') - + } + echo '<br /><table width="80%"> <tr> <th><h3>' . _('Order Initiation Details') . '</h3></th> @@ -705,11 +703,12 @@ <tr><td style="width:50%">'; //sub table starts echo '<table class="selection" width="100%">'; - echo '<tr><td>' . _('PO Date') . ':</td><td>'; + echo '<tr> + <td>' . _('PO Date') . ':</td> + <td>'; if ($_SESSION['ExistingOrder'] != 0) { echo ConvertSQLDate($_SESSION['PO' . $identifier]->Orig_OrderDate); - } //$_SESSION['ExistingOrder'] != 0 - else { + } else { /* DefaultDateFormat defined in config.php */ echo Date($_SESSION['DefaultDateFormat']); } @@ -718,43 +717,49 @@ if (isset($_GET['ModifyOrderNumber']) AND $_GET['ModifyOrderNumber'] != '') { $_SESSION['PO' . $identifier]->Version += 1; $_POST['Version'] = $_SESSION['PO' . $identifier]->Version; - } //isset($_GET['ModifyOrderNumber']) AND $_GET['ModifyOrderNumber'] != '' - elseif (isset($_SESSION['PO' . $identifier]->Version) AND $_SESSION['PO' . $identifier]->Version != '') { + } elseif (isset($_SESSION['PO' . $identifier]->Version) AND $_SESSION['PO' . $identifier]->Version != '') { $_POST['Version'] = $_SESSION['PO' . $identifier]->Version; - } //isset($_SESSION['PO' . $identifier]->Version) AND $_SESSION['PO' . $identifier]->Version != '' - else { + } else { $_POST['Version'] = '1'; } if (!isset($_POST['DeliveryDate'])) { $_POST['DeliveryDate'] = date($_SESSION['DefaultDateFormat']); - } //!isset($_POST['DeliveryDate']) + } + + echo '<tr> + <td>' . _('Version') . ' #' . ':</td> + <td><input type="hidden" name="Version" size="16" maxlength="15" value="' . $_POST['Version'] . '" />' . $_POST['Version'] . '</td> + </tr> + <tr> + <td>' . _('Revised') . ':</td> + <td><input type="hidden" name="Revised" size="11" maxlength="15" value="' . date($_SESSION['DefaultDateFormat']) . '" />' . date($_SESSION['DefaultDateFormat']) . '</td> + </tr> + <tr> + <td>' . _('Delivery Date') . ':</td> + <td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="DeliveryDate" size="11" value="' . $_POST['DeliveryDate'] . '" /></td> + </tr>'; - echo '<tr><td>' . _('Version') . ' #' . ':</td> - <td><input type="hidden" name="Version" size="16" maxlength="15" value="' . $_POST['Version'] . '" />' . $_POST['Version'] . '</td></tr>'; - echo '<tr><td>' . _('Revised') . ':</td> - <td><input type="hidden" name="Revised" size="11" maxlength="15" value="' . date($_SESSION['DefaultDateFormat']) . '" />' . date($_SESSION['DefaultDateFormat']) . '</td></tr>'; - - echo '<tr><td>' . _('Delivery Date') . ':</td> - <td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="DeliveryDate" size="11" value="' . $_POST['DeliveryDate'] . '" /></td></tr>'; - if (!isset($_POST['Initiator'])) { $_POST['Initiator'] = $_SESSION['UserID']; $_POST['InitiatorName'] = $_SESSION['UsersRealName']; $_POST['Requisition'] = ''; - } //!isset($_POST['Initiator']) - - echo '<tr><td>' . _('Initiated By') . ':</td> - <td><input type="hidden" name="Initiator" size="11" maxlength="10" value="' . $_POST['Initiator'] . '" />' . $_POST['InitiatorName'] . '</td></tr>'; - echo '<tr><td>' . _('Requisition Ref') . ':</td> - <td><input type="text" name="Requisition" size="16" maxlength="15" value="' . $_POST['Requisition'] . '" /></td></tr>'; - - echo '<tr><td>' . _('Date Printed') . ':</td><td>'; + } + + echo '<tr> + <td>' . _('Initiated By') . ':</td> + <td><input type="hidden" name="Initiator" size="11" maxlength="10" value="' . $_POST['Initiator'] . '" />' . $_POST['InitiatorName'] . '</td> + </tr> + <tr> + <td>' . _('Requisition Ref') . ':</td> + <td><input type="text" name="Requisition" size="16" maxlength="15" value="' . $_POST['Requisition'] . '" /></td> + </tr> + <tr><td>' . _('Date Printed') . ':</td><td>'; + if (isset($_SESSION['PO' . $identifier]->DatePurchaseOrderPrinted) AND mb_strlen($_SESSION['PO' . $identifier]->DatePurchaseOrderPrinted) > 6) { echo ConvertSQLDate($_SESSION['PO' . $identifier]->DatePurchaseOrderPrinted); $Printed = True; - } //isset($_SESSION['PO' . $identifier]->DatePurchaseOrderPrinted) AND mb_strlen($_SESSION['PO' . $identifier]->DatePurchaseOrderPrinted) > 6 - else { + } else { $Printed = False; echo _('Not yet printed') . '</td></tr>'; } @@ -762,18 +767,19 @@ if (isset($_POST['AllowRePrint'])) { $sql = "UPDATE purchorders SET allowprint=1 WHERE orderno='" . $_SESSION['PO' . $identifier]->OrderNo . "'"; $result = DB_query($sql, $db); - } //isset($_POST['AllowRePrint']) - + } + if ($_SESSION['PO' . $identifier]->AllowPrintPO == 0 AND empty($_POST['RePrint'])) { - echo '<tr><td>' . _('Allow Reprint') . ':</td> + echo '<tr> + <td>' . _('Allow Reprint') . ':</td> <td><select name="RePrint" onchange="ReloadForm(form1.AllowRePrint)"> <option selected="selected" value="0">' . _('No') . '</option> <option value="1">' . _('Yes') . '</option> </select></td>'; echo '<td><input type="submit" name="AllowRePrint" value="Update" /></td></tr>'; - } //$_SESSION['PO' . $identifier]->AllowPrintPO == 0 AND empty($_POST['RePrint']) - elseif ($Printed) { - echo '<tr><td colspan="2"><a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?OrderNo=' . $_SESSION['ExistingOrder'] . '&identifier=' . $identifier . '">' . _('Reprint Now') . '</a></td></tr>'; + } elseif ($Printed) { + echo '<tr> + <td colspan="2"><a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?OrderNo=' . $_SESSION['ExistingOrder'] . '&identifier=' . $identifier . '">' . _('Reprint Now') . '</a></td></tr>'; } //$Printed echo '</table></td>'; @@ -782,14 +788,16 @@ <table class="selection" width="100%">'; if ($_SESSION['ExistingOrder'] != 0 AND $_SESSION['PO' . $identifier]->Status == 'Printed') { - echo '<tr><td><a href="' . $rootpath . '/GoodsReceived.php?PONumber=' . $_SESSION['PO' . $identifier]->OrderNo . '&identifier=' . $identifier . '">' . _('Receive this order') . '</a></td></tr>'; - } //$_SESSION['ExistingOrder'] != 0 AND $_SESSION['PO' . $identifier]->Status == 'Printed' + echo '<tr><td><a href="' . $rootpath . '/GoodsReceived.php?PONumber=' . $_SESSION['PO' . $identifier]->OrderNo . '&identifier=' . $identifier . '">' . _('Receive this order') . '</a></td></tr>'; + } + if ($_SESSION['PO' . $identifier]->Status == '') { //then its a new order - echo '<tr><td><input type="hidden" name="Status" value="NewOrder" />'; - echo _('New Purchase Order') . '</td></tr>'; - } //$_SESSION['PO' . $identifier]->Status == '' - else { - echo '<tr><td>' . _('Status') . ' : </td> + echo '<tr> + <td><input type="hidden" name="Status" value="NewOrder" />' . _('New Purchase Order') . '</td> + </tr>'; + } else { + echo '<tr> + <td>' . _('Status') . ' : </td> <td><select name="Status" onchange="ReloadForm(form1.UpdateStatus)">'; switch ($_SESSION['PO' . $identifier]->Status) { @@ -821,11 +829,11 @@ <option value="Authorised">' . _('Authorised') . '</option> <option value="Pending">' . _('Pending') . '</option>'; break; - } //$_SESSION['PO' . $identifier]->Status - + } echo '</select></td></tr>'; - echo '<tr><td>' . _('Status Comment') . ':</td> + echo '<tr> + <td>' . _('Status Comment') . ':</td> <td><input type="text" name="StatusComments" size="50" /></td> </tr> <tr> @@ -839,7 +847,7 @@ echo '</table></td></tr>'; echo '<tr> - <th><h3>' . _('Warehouse Info') . '</h3></th> + <th><h3>' . _('Warehouse Info') . '</h3></th> <!-- <th><h3>' . _('Delivery To') . '</h3></th> --> <th><h3>' . _('Supplier Info') . '</h3></th> </tr> @@ -859,11 +867,10 @@ while ($LocnRow = DB_fetch_array($LocnResult)) { if (isset($_POST['StkLocation']) AND ($_POST['StkLocation'] == $LocnRow['loccode']) OR (empty($_POST['StkLocation']) AND $LocnRow['loccode'] == $_SESSION['UserStockLocation'])) { echo '<option selected="selected" value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>'; - } //isset($_POST['StkLocation']) AND ($_POST['StkLocation'] == $LocnRow['loccode']) OR (empty($_POST['StkLocation']) AND $LocnRow['loccode'] == $_SESSION['UserStockLocation']) - else { + } else { echo '<option value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>'; } - } //$LocnRow = DB_fetch_array($LocnResult) + } echo '</select> <input type="submit" name="LookupDeliveryAddress" value="' . _('Select') . '" /></td> @@ -899,7 +906,6 @@ $_POST['Contact'] = $LocnRow['contact']; $_SESSION['PO' . $identifier]->Location = $_POST['StkLocation']; - // $_SESSION['PO'.$identifier]->SupplierContact= $_POST['SupplierContact']; $_SESSION['PO' . $identifier]->DelAdd1 = $_POST['DelAdd1']; $_SESSION['PO' . $identifier]->DelAdd2 = $_POST['DelAdd2']; $_SESSION['PO' . $identifier]->DelAdd3 = $_POST['DelAdd3']; @@ -909,14 +915,14 @@ $_SESSION['PO' . $identifier]->Tel = $_POST['Tel']; $_SESSION['PO' . $identifier]->Contact = $_POST['Contact']; - } //DB_num_rows($LocnAddrResult) == 1 + } //end a location record was returned else { /*The default location of the user is crook */ prnMsg(_('The default stock location set up for this user is not a currently defined stock location') . '. ' . _('Your system administrator needs to amend your user record'), 'error'); } - } //!isset($_POST['StkLocation']) OR $_POST['StkLocation'] == '' + } //end StkLocation was not set elseif (isset($_POST['LookupDeliveryAddress'])) { $sql = "SELECT deladd1, deladd2, @@ -950,49 +956,58 @@ $_SESSION['PO' . $identifier]->DelAdd6 = $_POST['DelAdd6']; $_SESSION['PO' . $identifier]->Tel = $_POST['Tel']; $_SESSION['PO' . $identifier]->Contact = $_POST['Contact']; - } //DB_num_rows($LocnAddrResult) == 1 - } //isset($_POST['LookupDeliveryAddress']) + } //There was a location record returned + } //user clicked Lookup Delivery Address - echo '<tr><td>' . _('Delivery Contact') . ':</td> - <td><input type="text" name="Contact" size="41" value="' . $_SESSION['PO' . $identifier]->Contact . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 1 :</td> - <td><input type="text" name="DelAdd1" size="41" maxlength="40" value="' . $_POST['DelAdd1'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 2 :</td> - <td><input type="text" name="DelAdd2" size="41" maxlength="40" value="' . $_POST['DelAdd2'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 3 :</td> - <td><input type="text" name="DelAdd3" size="41" maxlength="40" value="' . $_POST['DelAdd3'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 4 :</td> - <td><input type="text" name="DelAdd4" size="21" maxlength="20" value="' . $_POST['DelAdd4'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 5 :</td> - <td><input type="text" name="DelAdd5" size="16" maxlength="15" value="' . $_POST['DelAdd5'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Address') . ' 6 :</td> - <td><input type="text" name="DelAdd6" size="16" maxlength="15" value="' . $_POST['DelAdd6'] . '" /></td> - </tr>'; - echo '<tr><td>' . _('Phone') . ':</td> - <td><input type="text" name="Tel" size="31" maxlength="30" value="' . $_SESSION['PO' . $identifier]->Tel . '" /></td> - </tr>'; + echo '<tr> + <td>' . _('Delivery Contact') . ':</td> + <td><input type="text" name="Contact" size="41" value="' . $_SESSION['PO' . $identifier]->Contact . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 1 :</td> + <td><input type="text" name="DelAdd1" size="41" maxlength="40" value="' . $_POST['DelAdd1'] . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 2 :</td> + <td><input type="text" name="DelAdd2" size="41" maxlength="40" value="' . $_POST['DelAdd2'] . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 3 :</td> + <td><input type="text" name="DelAdd3" size="41" maxlength="40" value="' . $_POST['DelAdd3'] . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 4 :</td> + <td><input type="text" name="DelAdd4" size="21" maxlength="20" value="' . $_POST['DelAdd4'] . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 5 :</td> + <td><input type="text" name="DelAdd5" size="16" maxlength="15" value="' . $_POST['DelAdd5'] . '" /></td> + </tr> + <tr> + <td>' . _('Address') . ' 6 :</td> + <td><input type="text" name="DelAdd6" size="16" maxlength="15" value="' . $_POST['DelAdd6'] . '" /></td> + </tr> + <tr> + <td>' . _('Phone') . ':</td> + <td><input type="text" name="Tel" size="31" maxlength="30" value="' . $_SESSION['PO' . $identifier]->Tel . '" /></td> + </tr> + <tr> + <td>' . _('Delivery By') . ':</td><td><select name="DeliveryBy">'; - echo '<tr><td>' . _('Delivery By') . ':</td><td><select name="DeliveryBy">'; - $ShipperResult = DB_query("SELECT shipper_id, shippername FROM shippers", $db); while ($ShipperRow = DB_fetch_array($ShipperResult)) { if (isset($_POST['DeliveryBy']) and ($_POST['DeliveryBy'] == $ShipperRow['shipper_id'])) { echo '<option selected="selected" value="' . $ShipperRow['shipper_id'] . '">' . $ShipperRow['shippername'] . '</option>'; - } //isset($_POST['DeliveryBy']) and ($_POST['DeliveryBy'] == $ShipperRow['shipper_id']) - else { + } else { echo '<option value="' . $ShipperRow['shipper_id'] . '">' . $ShipperRow['shippername'] . '</option>'; } - } //$ShipperRow = DB_fetch_array($ShipperResult) + } - echo '</select></td></tr></table>'; + echo '</select></td> + </tr> + </table>'; /* end of sub table */ echo '</td><td>'; @@ -1007,11 +1022,10 @@ while ($SuppCoRow = DB_fetch_array($SuppCoResult)) { if ($SuppCoRow['suppname'] == $_SESSION['PO' . $identifier]->SupplierName) { echo '<option selected="selected" value="' . $SuppCoRow['suppname'] . '">' . $SuppCoRow['suppname'] . '</option>'; - } //$SuppCoRow['suppname'] == $_SESSION['PO' . $identifier]->SupplierName - else { + } else { echo '<option value="' . $SuppCoRow['suppname'] . '">' . $SuppCoRow['suppname'] . '</option>'; } - } //$SuppCoRow = DB_fetch_array($SuppCoResult) + } echo '</select> '; echo '<input type="submit" name="SearchSuppliers" value="' . _('Select Now') . '" /></td> @@ -1027,36 +1041,34 @@ while ($SuppCoRow = DB_fetch_array($SuppCoResult)) { if ($_POST['SupplierContact'] == $SuppCoRow['contact'] OR ($_POST['SupplierContact'] == '' AND $SuppCoRow['contact'] == $_SESSION['PO' . $identifier]->SupplierContact)) { echo '<option selected="selected" value="' . $SuppCoRow['contact'] . '">' . $SuppCoRow['contact'] . '</option>'; - } //$_POST['SupplierContact'] == $SuppCoRow['contact'] OR ($_POST['SupplierContact'] == '' AND $SuppCoRow['contact'] == $_SESSION['PO' . $identifier]->SupplierContact) - else { + } else { echo '<option value="' . $SuppCoRow['contact'] . '">' . $SuppCoRow['contact'] . '</option>'; } - } //$SuppCoRow = DB_fetch_array($SuppCoResult) + } - echo '</select> '; - echo '</td></tr>'; - - echo '<tr> + echo '</select> </td> + </tr> + <tr> <td>' . _('Address') . ' 1 :</td> <td><input type="text" name="SuppDelAdd1" size="41" maxlength="40" value="' . $_POST['SuppDelAdd1'] . '" /></td> - </tr>'; - echo '<tr> + </tr> + <tr> <td>' . _('Address') . ' 2 :</td> <td><input type="text" name="SuppDelAdd2" size="41" maxlength="40" value="' . $_POST['SuppDelAdd2'] . '" /></td> - </tr>'; - echo '<tr> + </tr> + <tr> <td>' . _('Address') . ' 3 :</td> <td><input type="text" name="SuppDelAdd3" size="41" maxlength="40" value="' . $_POST['SuppDelAdd3'] . '" /></td> - </tr>'; - echo '<tr> + </tr> + <tr> <td>' . _('Address') . ' 4 :</td> <td><input type="text" name="SuppDelAdd5" size="21" maxlength="20" value="' . $_POST['SuppDelAdd5'] . '" /></td> - </tr>'; - echo '<tr> + </tr> + <tr> <td>' . _('Address') . ' 5 :</td> <td><input type="text" name="SuppDelAdd4" size="41" maxlength="40" value="' . $_POST['SuppDelAdd4'] . '" /></td> - </tr>'; - echo '<tr> + </tr> + <tr> <td>' . _('Phone') . ':</td> <td><input type="text" name="SuppTel" size="31" maxlength="30" value="' . $_SESSION['PO' . $identifier]->SuppTel . '" /></td> </tr>'; @@ -1070,11 +1082,10 @@ while ($myrow = DB_fetch_array($result)) { if ($myrow['termsindicator'] == $_SESSION['PO' . $identifier]->PaymentTerms) { echo '<option selected="selected" value="' . $myrow['termsindicator'] . '">' . $myrow['terms'] . '</option>'; - } //$myrow['termsindicator'] == $_SESSION['PO' . $identifier]->PaymentTerms - else { + } else { echo '<option value="' . $myrow['termsindicator'] . '">' . $myrow['terms'] . '</option>'; } //end while loop - } //$myrow = DB_fetch_array($result) + } DB_data_seek($result, 0); echo '</select></td></tr>'; @@ -1093,9 +1104,10 @@ echo '<tr><td>' . _('Exchange Rate') . ':' . '</td> <td><input type="text" name="ExRate" value="' . locale_number_format($_POST['ExRate'], 5) . '" class="number" size="11" /></td> </tr>'; - } //$_SESSION['PO' . $identifier]->CurrCode != $_SESSION['CompanyRecord']['currencydefault'] - else { - echo '<tr><td><input type="hidden" name="ExRate" value="1" /></td></tr>'; + } else { + echo '<tr> + <td><input type="hidden" name="ExRate" value="1" /></td> + </tr>'; } echo '</table>'; /*end of sub table */ @@ -1107,12 +1119,15 @@ if (!isset($_POST['Comments'])) { $_POST['Comments'] = $Default_Comments; - } //!isset($_POST['Comments']) + } - echo ':</h3></th></tr> - <tr><td colspan="4"><textarea name="Comments" style="width:100%" rows="5" cols="200">' . $_POST['Comments'] . '</textarea>'; - - echo '</td></tr></table><br />'; + echo ':</h3></th> + </tr> + <tr> + <td colspan="4"><textarea name="Comments" style="width:100%" rows="5" cols="200">' . $_POST['Comments'] . '</textarea></td> + </tr> + </table> + <br />'; /* end of main table */ echo '<div class="centre"> Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/PO_Items.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -22,6 +22,9 @@ exit; } //end if (!isset($_SESSION['PO'.$identifier])) +/* webERP manual links before header.inc */ +$ViewTopic= 'PurchaseOrdering'; +$BookMark = 'PurchaseOrdering'; include('includes/header.inc'); if (!isset($_POST['Commit'])) { @@ -230,8 +233,9 @@ } } /* end of the loop round the detail line items on the order */ echo '<p />'; - prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . - $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); + prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); + + } else { /*its an existing order need to update the old order info */ /*Check to see if there are any incomplete lines on the order */ $Completed = true; //assume it is completed i.e. all lines are flagged as completed @@ -374,10 +378,15 @@ echo '<br /><div class="centre"><a target="_blank" href="'.$rootpath.'/PO_PDFPurchOrder.php?OrderNo=' . $_SESSION['PO'.$identifier]->OrderNo . '">' . _('Print Purchase Order') . '</a></div>'; } + } /*end of if its a new order or an existing one */ $Result = DB_Txn_Commit($db); + if ($_SESSION['PO'.$identifier]->Status == 'Authorised'){; + echo '<a href="SupplierInvoice.php?SupplierID=' . $_SESSION['PO'.$identifier]->SupplierID . '&ReceivePO=' . $_SESSION['PO'.$identifier]->OrderNo . '&DeliveryDate=' . $_SESSION['PO'.$identifier]->DeliveryDate . '">' . _('Receive and Enter Purchase Invoice') . '</a>'; + } + unset($_SESSION['PO'.$identifier]); /*Clear the PO data to allow a newy to be input*/ include('includes/footer.inc'); exit; Modified: trunk/PO_PDFPurchOrder.php =================================================================== --- trunk/PO_PDFPurchOrder.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/PO_PDFPurchOrder.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -30,13 +30,13 @@ echo '<div class="centre"><br /><br /><br />' . _('This page must be called with a purchase order number to print'); echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a></div>'; exit; -} //!isset($_GET['OrderNo']) AND !isset($_POST['OrderNo']) +} if (isset($_GET['OrderNo'])) { $OrderNo = $_GET['OrderNo']; -} //isset($_GET['OrderNo']) +} elseif (isset($_POST['OrderNo'])) { $OrderNo = $_POST['OrderNo']; -} //isset($_POST['OrderNo']) +} $title = _('Print Purchase Order Number') . ' ' . $OrderNo; if (isset($_POST['PrintOrEmail']) AND isset($_POST['EmailTo'])) { @@ -45,16 +45,16 @@ prnMsg(_('The email address entered does not appear to be valid. No emails have been sent.'), 'warn'); include('includes/footer.inc'); exit; - } //$_POST['PrintOrEmail'] == 'Email' AND !IsEmailAddress($_POST['EmailTo']) -} //isset($_POST['PrintOrEmail']) AND isset($_POST['EmailTo']) + } +} $ViewingOnly = 0; if (isset($_GET['ViewingOnly']) AND $_GET['ViewingOnly'] != '') { $ViewingOnly = $_GET['ViewingOnly']; -} //isset($_GET['ViewingOnly']) AND $_GET['ViewingOnly'] != '' +} elseif (isset($_POST['ViewingOnly']) AND $_POST['ViewingOnly'] != '') { $ViewingOnly = $_POST['ViewingOnly']; -} //isset($_POST['ViewingOnly']) AND $_POST['ViewingOnly'] != '' +} /* If we are previewing the order then we dont want to email it */ if ($OrderNo == 'Preview') { //OrderNo is set to 'Preview' when just looking at the format of the printed order @@ -68,11 +68,11 @@ if (isset($_POST['DoIt']) AND ($_POST['PrintOrEmail'] == 'Print' OR $ViewingOnly == 1)) { $MakePDFThenDisplayIt = True; $MakePDFThenEmailIt = False; -} //isset($_POST['DoIt']) AND ($_POST['PrintOrEmail'] == 'Print' OR $ViewingOnly == 1) -elseif (isset($_POST['DoIt']) AND $_POST['PrintOrEmail'] == 'Email' AND isset($_POST['EmailTo'])) { +} elseif (isset($_POST['DoIt']) AND $_POST['PrintOrEmail'] == 'Email' AND isset($_POST['EmailTo'])) { $MakePDFThenEmailIt = True; $MakePDFThenDisplayIt = False; -} //isset($_POST['DoIt']) AND $_POST['PrintOrEmail'] == 'Email' AND isset($_POST['EmailTo']) +} + if (isset($OrderNo) AND $OrderNo != '' AND $OrderNo > 0 AND $OrderNo != 'Preview') { /*retrieve the order details from the database to print */ $ErrMsg = _('There was a problem retrieving the purchase order header details for Order Number') . ' ' . $OrderNo . ' ' . _('from the database'); @@ -127,8 +127,7 @@ </div><br /><br /><br />'; include('includes/footer.inc'); exit(); - } //DB_num_rows($result) == 0 - elseif (DB_num_rows($result) == 1) { + } elseif (DB_num_rows($result) == 1) { /*There is only one order header returned (as it should be!)*/ $POHeader = DB_fetch_array($result); @@ -138,8 +137,8 @@ prnMsg(_('Purchase orders can only be printed once they have been authorised') . '. ' . _('This order is currently at a status of') . ' ' . _($POHeader['status']), 'warn'); include('includes/footer.inc'); exit; - } //$POHeader['status'] != 'Authorised' AND $POHeader['status'] != 'Printed' - + } + if ($ViewingOnly == 0) { if ($POHeader['allowprint'] == 0) { $title = _('Purchase Order Already Printed'); @@ -147,7 +146,6 @@ echo '<p>'; prnMsg(_('Purchase Order Number') . ' ' . $OrderNo . ' ' . _('has previously been printed') . '. ' . _('It was printed on') . ' ' . ConvertSQLDate($POHeader['dateprinted']) . '<br />' . _('To re-print the order it must be modified to allow a reprint') . '<br />' . _('This check is there to ensure that duplicate purchase orders are not sent to the supplier resulting in several deliveries of the same supplies'), 'warn'); - //=HJ= fixed missing closing tags and replace table with div, for visual conformity echo '<div class="centre"> <li><a href="' . $rootpath . '/PO_PDFPurchOrder.php?OrderNo=' . $OrderNo . '&ViewingOnly=1">' . _('Print This Order as a Copy') . '</a> <li><a href="' . $rootpath . '/PO_Header.php?ModifyOrderNumber=' . $OrderNo . '">' . _('Modify the order to allow a real reprint') . '</a> @@ -190,8 +188,7 @@ if (isset($MakePDFThenDisplayIt) or isset($MakePDFThenEmailIt)) { if ($OrderNo == 'Preview') { $FormDesign = simplexml_load_file(sys_get_temp_dir() . '/PurchaseOrder.xml'); - } //$OrderNo == 'Preview' - else { + } else { $FormDesign = simplexml_load_file($PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/FormDesigns/PurchaseOrder.xml'); } // Set the paper size/orintation @@ -218,7 +215,7 @@ ON purchorderdetails.itemcode=stockmaster.stockid WHERE orderno ='" . $OrderNo . "'"; $result = DB_query($sql, $db); - } //$OrderNo != 'Preview' + } if ($OrderNo == 'Preview' or DB_num_rows($result) > 0) { /*Yes there are line items to start the ball rolling with a page header */ include('includes/PO_PDFOrderPageHeader.inc'); @@ -237,25 +234,23 @@ $POLine['quantityord'] = 9999.99; $POLine['conversionfactor'] = 1; $POLine['decimalplaces'] = 2; - } //$OrderNo == 'Preview' + } if ($POLine['decimalplaces'] != NULL) { $DecimalPlaces = $POLine['decimalplaces']; - } //$POLine['decimalplaces'] != NULL + } else { $DecimalPlaces = 2; } $DisplayQty = locale_number_format($POLine['quantityord'] / $POLine['conversionfactor'], $DecimalPlaces); if ($_POST['ShowAmounts'] == 'Yes') { $DisplayPrice = locale_number_format($POLine['unitprice'] * $POLine['conversionfactor'], $POHeader['currdecimalplaces']); - } //$_POST['ShowAmounts'] == 'Yes' - else { + } else { $DisplayPrice = '----'; } $DisplayDelDate = ConvertSQLDate($POLine['deliverydate']); if ($_POST['ShowAmounts'] == 'Yes') { $DisplayLineTotal = locale_number_format($POLine['unitprice'] * $POLine['quantityord'], $POHeader['currdecimalplaces']); - } //$_POST['ShowAmounts'] == 'Yes' - else { + } else { $DisplayLineTotal = '----'; } $Desc = $POLine['suppliers_partno'] . " " . $POLine['itemdescription']; @@ -271,7 +266,7 @@ $PageNumber++; $YPos = $Page_Height - $FormDesign->Data->y; include('includes/PO_PDFOrderPageHeader.inc'); - } //$YPos - $line_height <= $Bottom_Margin + } //end if we reached the end of page $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x, $YPos, $FormDesign->Data->Column2->Length, $FormDesign->Data->Column2->FontSize, $LeftOvers, 'left'); } //end if need a new page headed up $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x, $YPos, $FormDesign->Data->Column3->Length, $FormDesign->Data->Column3->FontSize, $DisplayQty, 'left'); @@ -282,7 +277,7 @@ if (mb_strlen($LeftOvers) > 1) { $LeftOvers = $pdf->addTextWrap($Left_Margin + 1 + 94, $YPos - $line_height, 270, $FontSize, $LeftOvers, 'left'); $YPos -= $line_height; - } //mb_strlen($LeftOvers) > 1 + } if ($YPos - $line_height <= $Bottom_Margin) { /* We reached the end of the page so finsih off the page and start a newy */ $PageNumber++; @@ -303,24 +298,19 @@ include('includes/PO_PDFOrderPageHeader.inc'); } //end if need a new page headed up if ($_POST['ShowAmounts'] == 'Yes') { - $DisplayOrderTotal = locale_number_format($OrderTotal, $POHeader['currdecimalplaces']); - } //$_POST['ShowAmounts'] == 'Yes' - else { + $DisplayOrderTotal = locale_number_format($OrdendrTotal, $POHeader['currdecimalplaces']); + } else { $DisplayOrderTotal = '----'; } $pdf->addText($FormDesign->OrderTotalCaption->x, $Page_Height - $FormDesign->OrderTotalCaption->y, $FormDesign->OrderTotalCaption->FontSize, _('Order Total - excl tax') . ' ' . $POHeader['currcode']); $LeftOvers = $pdf->addTextWrap($FormDesign->OrderTotal->x, $Page_Height - $FormDesign->OrderTotal->y, $FormDesign->OrderTotal->Length, $FormDesign->OrderTotal->FontSize, $DisplayOrderTotal, 'right'); - } //$OrderNo == 'Preview' or DB_num_rows($result) > 0 - - /*end if there are order details to show on the order*/ - //} /* end of check to see that there was an order selected to print */ - + } /*end if there are order details to show on the order - or its a preview*/ + $Success = 1; //assume the best and email goes - has to be set to 1 to allow update status if ($MakePDFThenDisplayIt) { $pdf->OutputD($_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf'); $pdf->__destruct(); - } //$MakePDFThenDisplayIt - else { + } else { /* must be MakingPDF to email it */ $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf'; @@ -342,8 +332,7 @@ echo '<div class="centre"><br /><br /><br />'; prnMsg(_('Purchase Order') . ' ' . $OrderNo . ' ' . _('has been emailed to') . ' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success'); - } //$Success == 1 - else { //email failed + } else { //email failed $title = _('Email a Purchase Order'); include('includes/header.inc'); echo '<div class="centre"><br /><br /><br />'; @@ -359,9 +348,9 @@ stat_comment = '" . htmlspecialchars($StatusComment, ENT_QUOTES, 'UTF-8') . "' WHERE purchorders.orderno = '" . $OrderNo . "'"; $result = DB_query($sql, $db); - } //$ViewingOnly == 0 AND $Success == 1 + } include('includes/footer.inc'); -} //isset($MakePDFThenDisplayIt) or isset($MakePDFThenEmailIt) +} //isset($MakePDFThenDisplayIt) OR isset($MakePDFThenEmailIt) /* There was enough info to either print or email the purchase order */ else { @@ -382,16 +371,15 @@ if (!isset($_POST['PrintOrEmail'])) { $_POST['PrintOrEmail'] = 'Print'; - } //!isset($_POST['PrintOrEmail']) + } if ($ViewingOnly != 0) { echo '<option selected="selected" value="Print">' . _('Print') . '</option>'; - } //$ViewingOnly != 0 + } else { if ($_POST['PrintOrEmail'] == 'Print') { echo '<option selected="selected" value="Print">' . _('Print') . '</option>'; echo '<option value="Email">' . _('Email') . '</option>'; - } //$_POST['PrintOrEmail'] == 'Print' - else { + } else { echo '<option value="Print">' . _('Print') . '</option>'; echo '<option selected="selected" value="Email">' . _('Email') . '</option>'; } @@ -401,12 +389,11 @@ <select name="ShowAmounts">'; if (!isset($_POST['ShowAmounts'])) { $_POST['ShowAmounts'] = 'Yes'; - } //!isset($_POST['ShowAmounts']) + } if ($_POST['ShowAmounts'] == 'Yes') { echo '<option selected="selected" value="Yes">' . _('Yes') . '</option>'; echo '<option value="No">' . _('No') . '</option>'; - } //$_POST['ShowAmounts'] == 'Yes' - else { + } else { echo '<option value="Yes">' . _('Yes') . '</option>'; echo '<option selected="selected" value="No">' . _('No') . '</option>'; } @@ -425,21 +412,18 @@ if (mb_strlen($ContactDetails['email']) > 2 AND mb_strpos($ContactDetails['email'], '@') > 0) { if ($_POST['EmailTo'] == $ContactDetails['email']) { echo '<option selected="selected" value="' . $ContactDetails['email'] . '">' . $ContactDetails['Contact'] . ' - ' . $ContactDetails['email'] . '</option>'; - } //$_POST['EmailTo'] == $ContactDetails['email'] - else { + } else { echo '<option value="' . $ContactDetails['email'] . '">' . $ContactDetails['contact'] . ' - ' . $ContactDetails['email'] . '</option>'; } - } //mb_strlen($ContactDetails['email']) > 2 AND mb_strpos($ContactDetails['email'], '@') > 0 - } //$ContactDetails = DB_fetch_array($ContactsResult) + } + } echo '</select></td></tr></table>'; - } //DB_num_rows($ContactsResult) > 0 - else { + } else { echo '</table><br />'; prnMsg(_('There are no contacts defined for the supplier of this order') . '. ' . _('You must first set up supplier contacts before emailing an order'), 'error'); echo '<br />'; } - } //$_POST['PrintOrEmail'] == 'Email' - else { + } else { echo '</table>'; } echo '<br /> Modified: trunk/PO_SelectOSPurchOrder.php =================================================================== --- trunk/PO_SelectOSPurchOrder.php 2012-12-04 16:02:13 UTC (rev 5751) +++ trunk/PO_SelectOSPurchOrder.php 2012-12-05 08:39:15 UTC (rev 5752) @@ -13,24 +13,24 @@ if (isset($_GET['SelectedStockItem'])) { $SelectedStockItem = trim($_GET['SelectedStockItem']); -} //isset($_GET['SelectedStockItem']) +} elseif (isset($_POST['SelectedStockItem'])) { $SelectedStockItem = trim($_POST['SelectedStockItem']); -} //isset($_POST['SelectedStockItem']) +} if (isset($_GET['OrderNumber'])) { $OrderNumber = $_GET['OrderNumber']; -} //isset($_GET['OrderNumber']) +} elseif (isset($_POST['OrderNumber'])) { $OrderNumber = $_POST['OrderNumber']; -} //isset($_POST['OrderNumber']) +} if (isset($_GET['SelectedSupplier'])) { $SelectedSupplier = trim($_GET['SelectedSupplier']); -} //isset($_GET['SelectedSupplier']) +} elseif (isset($_POST['SelectedSupplier'])) { $SelectedSupplier = trim($_POST['SelectedSupplier']); -} //isset($_POST['SelectedSupplier']) +} echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; echo '<div>'; @@ -39,92 +39,89 @@ if (isset($_POST['ResetPart'])) { unset($SelectedStockItem); -} //isset($_POST['ResetPart']) +} if (isset($OrderNumber) AND $OrderNumber != '') { if (!is_numeric($OrderNumber)) { echo '<br /><b>' . _('The Order Number entered') . ' <u>' . _('MUST') . '</u> ' . _('be numeric') . '.</b><br />'; unset($OrderNumber); - } //!is_numeric($OrderNumber) - else { + } else { echo _('Order Number') . ' - ' . $OrderNumber; } -} //isset($OrderNumber) AND $OrderNumber != '' -else { +} else { if (isset($SelectedSupplier)) { echo '<br /> <div class="page_help_text">' . _('For supplier') . ': ' . $SelectedSupplier . ' ' . _('and') . ' '; echo '<input type="hidden" name="SelectedSupplier" value="' . $SelectedSupplier . '" /> </div>'; - } //isset($SelectedSupplier) + } if (isset($SelectedStockItem)) { echo '<input type="hidden" name="SelectedStockItem" value="' . $SelectedStockItem . '" />'; - } //isset($SelectedStockItem) + } } if (isset($_POST['SearchParts'])) { if (isset($_POST['Keywords']) AND isset($_POST['StockCode'])) { echo '<div class="page_help_text">' . _('Stock description keywords have been used in preference to the Stock code extract entered') . '.</div>'; - } //isset($_POST['Keywords']) AND isset($_POST['StockCode']) + } If ($_POST['Keywords']) { //insert wildcard characters in spaces $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - SUM(locstock.quantity) AS qoh, - stockmaster.units, - SUM(purchorderdetails.quantityord-purchorderdetails.quantityrecd) AS qord - FROM stockmaster INNER JOIN locstock - ON stockmaster.stockid = locstock.stockid - INNER JOIN purchorderdetails - ON stockmaster.stockid=purchorderdetails.itemcode - WHERE purchorderdetails.completed=0 - AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.units - ORDER BY stockmaster.stockid"; + stockmaster.description, + SUM(locstock.quantity) AS qoh, + stockmaster.units, + SUM(purchorderdetails.quantityord-purchorderdetails.quantityrecd) AS qord + FROM stockmaster INNER JOIN locstock + ON stockmaster.stockid = locstock.stockid + INNER JOIN purchorderdetails + ON stockmaster.stockid=purchorderdetails.itemcode + WHERE purchorderdetails.completed=0 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units + ORDER BY stockmaster.stockid"; - } //$_POST['Keywords'] - elseif ($_POST['StockCode']) { + } elseif ($_POST['StockCode']) { + $SQL = "SELECT stockmaster.stockid, - stockmaster.description, -... [truncated message content] |