From: <dai...@us...> - 2011-03-13 04:55:40
|
Revision: 4508 http://web-erp.svn.sourceforge.net/web-erp/?rev=4508&view=rev Author: daintree Date: 2011-03-13 04:55:32 +0000 (Sun, 13 Mar 2011) Log Message: ----------- various Modified Paths: -------------- trunk/SelectSalesOrder.php trunk/Stocks.php trunk/SuppPriceList.php trunk/doc/Change.log.html trunk/includes/ConnectDB.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SelectSalesOrder.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -8,10 +8,11 @@ if (isset($_POST['PlacePO'])){ /*user hit button to place PO for selected orders */ + /*Note the button would not have been displayed if the user had no authority to create purchase orders */ $OrdersToPlacePOFor = ''; for ($i=1;$i<count($_POST);$i++){ - if ($_POST['PlacePO_' . $i]== 'on') { + if (isset($_POST['PlacePO_' . $i])) { //checkboxes only set if they are checked if ($OrdersToPlacePOFor==''){ $OrdersToPlacePOFor .= ' orderno=' . $_POST['OrderNo_PO_'.$i]; } else { @@ -30,13 +31,17 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft - SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS OrderQty + stockmaster.volume, + stockcategory.stockact, + SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS orderqty FROM purchdata INNER JOIN salesorderdetails ON purchdata.stockid = salesorderdetails.stkcode INNER JOIN stockmaster ON purchdata.stockid = stockmaster.stockid + INNER JOIN stockcategory ON + stockmaster.categoryid = stockcategory.categoryid WHERE purchdata.preferred=1 AND purchdata.effectivefrom <='" . Date('Y-m-d') . "' AND (" . $OrdersToPlacePOFor . ") @@ -47,223 +52,213 @@ purchdata.supplierdescription, purchdata.conversionfactor, purchdata.leadtime, + purchdata.suppliersuom, stockmaster.kgs, - stockmaster.cuft + stockmaster.volume, + stockcategory.stockact ORDER BY purchdata.supplierno, purchdata.stockid"; $ErrMsg = _('Unable to retrieve the items on the selected orders for creating purchase orders for'); $ItemResult = DB_query($sql,$db,$ErrMsg); - /*Now get the default delivery address details from the users default stock location */ - $sql = "SELECT locationame, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - contact - FROM locations - WHERE loccode = '" .$_SESSION['UserStockLocation'] . "'"; - $ErrMsg = _('The delivery address for the order could not be obtained from the user default stock location'); - $DelAddResult = DB_query($sql, $db,$ErrMsg); - $DelAddRow = DB_fetch_array($DelAddResult); - $SupplierID = ''; - if (IsEmailAddress($_SESSION['UserEmail'])){ - $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; + if (DB_num_rows($ItemResult)==0){ + prnMsg(_('There might be no supplier purchasing data set up for any items on the selected sales order(s). No purchase orders have been created'),'warn'); } else { - $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; - } - - while ($ItemRow = DB_fetch_array($ItemResult)){ + /*Now get the default delivery address details from the users default stock location */ + $sql = "SELECT locationname, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + contact + FROM locations + WHERE loccode = '" .$_SESSION['UserStockLocation'] . "'"; + $ErrMsg = _('The delivery address for the order could not be obtained from the user default stock location'); + $DelAddResult = DB_query($sql, $db,$ErrMsg); + $DelAddRow = DB_fetch_array($DelAddResult); - if ($SupplierID != $ItemRow['supplierno']){ - /* This order item is purchased from a different supplier so need to finish off the authorisation of the previous order and start a new order */ + $SupplierID = ''; + if (IsEmailAddress($_SESSION['UserEmail'])){ + $UserDetails = ' <a href="mailto:' . $_SESSION['UserEmail'] . '">' . $_SESSION['UsersRealName']. '</a>'; + } else { + $UserDetails = ' ' . $_SESSION['UsersRealName'] . ' '; + } + + while ($ItemRow = DB_fetch_array($ItemResult)){ - if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) { - //if the user has authority to authorise the PO then it should be created as authorised - $AuthSQL ="SELECT authlevel - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$SuppRow['currcode']."'"; - - $AuthResult=DB_query($AuthSQL,$db); - $AuthRow=DB_fetch_array($AuthResult); - - if (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $Order_Value) { //user has authority to authrorise as well as create the order - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '._('Auto created from sales orders') .'<br />'; - $result = DB_query("UPDATE purchorders SET allowprint=1, - status='Authorised', - statuscomment='" . $StatusComment . "' - WHERE orderno='" . $OrderNo . "'", - $db); - } else { // no authority to authorise this order - if (DB_num_rows($AuthResult) ==0){ - $AuthMessage = _('Your authority to approve purchase orders in') . ' ' .$SuppRow['currcode'] . ' ' . _('has not yet been set up') . '<br />'; - } else { - $AuthMessage = _('You can only authorise up to').' '.$SuppRow['currcode'].' '.$AuthRow['authlevel'].'.<br />'; + if ($SupplierID != $ItemRow['supplierno']){ + /* This order item is purchased from a different supplier so need to finish off the authorisation of the previous order and start a new order */ + + if ($SupplierID !='' AND $_SESSION['AutoAuthorisePO']==1) { + //if the user has authority to authorise the PO then it should be created as authorised + $AuthSQL ="SELECT authlevel + FROM purchorderauth + WHERE userid='".$_SESSION['UserID']."' + AND currabrev='".$SuppRow['currcode']."'"; + + $AuthResult=DB_query($AuthSQL,$db); + $AuthRow=DB_fetch_array($AuthResult); + + if (DB_num_rows($AuthResult) > 0 AND $AuthRow['authlevel'] > $Order_Value) { //user has authority to authrorise as well as create the order + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created and Authorised by') . $UserDetails . ' - '._('Auto created from sales orders') .'<br />'; + $result = DB_query("UPDATE purchorders SET allowprint=1, + status='Authorised', + statuscomment='" . $StatusComment . "' + WHERE orderno='" . $OrderNo . "'", + $db); + } else { // no authority to authorise this order + if (DB_num_rows($AuthResult) ==0){ + $AuthMessage = _('Your authority to approve purchase orders in') . ' ' .$SuppRow['currcode'] . ' ' . _('has not yet been set up') . '<br />'; + } else { + $AuthMessage = _('You can only authorise up to').' '.$SuppRow['currcode'].' '.$AuthRow['authlevel'].'.<br />'; + } + + prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. + $SuppRow['currcode'] . ' '. $Order_Value .'. '. + $AuthMessage . _('If you think this is a mistake please contact the systems administrator') . '<br />'. + _('The order has been created with a status of pending and will require authorisation'), 'warn'); } + } //end of authorisation status settings - prnMsg( _('You do not have permission to authorise this purchase order').'.<br />'. _('This order is for').' '. - $SuppRow['currcode'] . ' '. $Order_Value .'. '. - $AuthMessage . _('If you think this is a mistake please contact the systems administrator') . '<br />'. - _('The order has been created with a status of pending and will require authorisation'), 'warn'); + if ($SupplierID !=''){ //then we have just added a purchase order + echo '<p>'; + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); } - } //end of authorisation status settings + /*Starting a new purchase order with a different supplier */ + $result = DB_Txn_Begin($db); + include('includes/SQL_CommonFunctions.inc'); + $PO_OrderNo = GetNextTransNo(18, $db); //get the next PO number + + $SupplierID = $ItemRow['supplierno']; + $Order_Value =0; + /*Now get all the required details for the supplier */ + $sql = "SELECT address1, + address2, + address3, + address4, + address5, + address6, + telephone, + paymentterms, + currcode, + rate + FROM suppliers INNER JOIN currencies + ON suppliers.currcode = currencies.currabrev + WHERE supplierid='" . $SupplierID . "'"; + + $ErrMsg = _('Could not get the supplier information for the order'); + $SuppResult = DB_query($sql, $db, $ErrMsg); + $SuppRow = DB_fetch_array($SuppResult); + + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . ' ' . $UserDetails . ' - '._('Auto created from sales orders') .'<br />'; + /*Insert to purchase order header record */ + $sql = "INSERT INTO purchorders ( orderno, + supplierno, + orddate, + rate, + initiator, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + supptel, + version, + revised, + deliveryby, + status, + stat_comment, + deliverydate, + paymentterms, + allowprint) + VALUES( '" . $PO_OrderNo . "', + '" . $SupplierID . "', + '" . Date('Y-m-d') . "', + '" . $SuppRow['rate'] . "', + '" . $_SESSION['UsersRealName'] . "', + '" . $_SESSION['UserStockLocation'] . "', + '" . $DelAddRow['locationname'] . "', + '" . $DelAddRow['deladd1'] . "', + '" . $DelAddRow['deladd2'] . "', + '" . $DelAddRow['deladd3'] . "', + '" . $DelAddRow['deladd4'] . "', + '" . $DelAddRow['deladd5'] . ' ' . $DelAddRow['deladd6'] . "', + '" . $DelAddRow['tel'] . "', + '" . $SuppRow['address1'] . "', + '" . $SuppRow['address2'] . "', + '" . $SuppRow['address3'] . "', + '" . $SuppRow['address4'] . "', + '" . $SuppRow['address5'] . "', + '" . $SuppRow['address6'] . "', + '" . $SuppRow['telephone'] . "', + '1.0', + '" . Date('Y-m-d') . "', + '" . $_SESSION['Default_Shipper'] . "', + 'Pending', + '" . $StatusComment . "', + '" . Date('Y-m-d') . "', + '" . $SuppRow['paymentterms'] . "', + 0)"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + } //end if it's a new supplier and PO to create - if ($SupplierID !=''){ //then we have just added a purchase order - DB_Txn_Commit($db); - } - /*Starting a new purchase order with a different supplier */ - $result = DB_Txn_Begin($db); - $OrderNo = GetNextTransNo(18, $db); //get the next PO number + /*reminder we are in a loop of the total of each item to place a purchase order for based on a selection of sales orders */ + $DeliveryDate = DateAdd(Date($_SESSION['DefaultDateFormat']),'d',$ItemRow['leadtime']); + $sql = "INSERT INTO purchorderdetails ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + suppliersunit, + suppliers_partno, + kgs, + cuft, + conversionfactor ) + VALUES ( + '" . $PO_OrderNo . "', + '" . $ItemRow['stockid'] . "', + '" . FormatDateForSQL($DeliveryDate) . "', + '" . $ItemRow['suppliers_partno'] . ' ' . $ItemRow['supplierdescription'] . "', + '" . $ItemRow['stockact'] . "', + '" . $ItemRow['price'] . "', + '" . $ItemRow['orderqty'] . "', + '" . $ItemRow['suppliersuom'] . "', + '" . $ItemRow['suppliers_partno'] . "', + '" . $ItemRow['kgs'] . "', + '" . $ItemRow['volume'] . "', + '" . $ItemRow['conversionfactor'] . "')"; + $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - $SupplierID = $ItemRow['supplierno']; - $Order_Value =0; - /*Now get all the required details for the supplier */ - $sql = "SELECT address1, - address2, - address3, - address4, - address5, - address6, - suppliercontact, - telephone, - paymentterms, - currcode, - rate - FROM suppliers INNER JOIN currencies - ON suppliers.currcode = currencies.currabrev - WHERE supplierno='" . $SupplierID . "'"; - - $ErrMsg = _('Could not get the supplier information for the order'); - $SuppResult = DB_query($sql, $db, $ErrMsg); - $SuppRow = DB_fetch_array($SuppResult); - - $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . $UserDetails . ' - '._('Auto created from sales orders') .'<br />'; - /*Insert to purchase order header record */ - $sql = "INSERT INTO purchorders ( orderno, - supplierno, - orddate, - rate, - initiator, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - supptel, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms, - allowprint) - VALUES( '" . $OrderNo . "', - '" . $SupplierID . "', - '" . Date('Y-m-d') . "', - '" . $SuppRow['rate'] . "', - '" . $_SESSION['UsersRealName'] . "', - '" . $_SESSION['UserStockLocation'] . "', - '" . $DelAddRow['locationname'] . "', - '" . $DelAddRow['deladd1'] . "', - '" . $DelAddRow['deladd2'] . "', - '" . $DelAddRow['deladd3'] . "', - '" . $DelAddRow['deladd4'] . "', - '" . $DelAddRow['deladd5'] . "', - '" . $DelAddRow['deladd6'] . "', - '" . $DelAddRow['tel'] . "', - '" . $SuppRow['address1'] . "', - '" . $SuppRow['address2'] . "', - '" . $SuppRow['address3'] . "', - '" . $SuppRow['address4'] . "', - '" . $SuppRow['address5'] . "', - '" . $SuppRow['address6'] . "', - '" . $SuppRow['telephone'] . "', - '1.0', - '" . Date('Y-m-d') . "', - '" . $_SESSION['Default_Shipper'] . "', - 'Pending', - '" . $StatusComment . "', - '" . Date('Y-m-d') . "', - '" . $SuppRow['paymentterms'] . "', - 0)"; - - $ErrMsg = _('The purchase order header record could not be inserted into the database because'); - $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Insert the purchase order detail records */ - foreach ($_SESSION['PO'.$identifier]->LineItems as $POLine) { - if ($POLine->Deleted==False) { - $sql = "INSERT INTO purchorderdetails ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - suppliersunit, - suppliers_partno, - subtotal_amount, - package, - pcunit, - netweight, - kgs, - cuft, - total_quantity, - total_amount, - assetid, - conversionfactor ) - VALUES ( - '" . $_SESSION['PO'.$identifier]->OrderNo . "', - '" . $POLine->StockID . "', - '" . FormatDateForSQL($POLine->ReqDelDate) . "', - '" . $POLine->ItemDescription . "', - '" . $POLine->GLCode . "', - '" . $POLine->Price . "', - '" . $POLine->Quantity . "', - '" . $POLine->ShiptRef . "', - '" . $POLine->JobRef . "', - '" . $POLine->ItemNo . "', - '" . $POLine->SuppliersUnit . "', - '" . $POLine->Suppliers_PartNo . "', - '" . $POLine->SubTotal_Amount . "', - '" . $POLine->Package . "', - '" . $POLine->PcUnit . "', - '" . $POLine->NetWeight . "', - '" . $POLine->KGs . "', - '" . $POLine->CuFt . "', - '" . $POLine->Total_Quantity . "', - '" . $POLine->Total_Amount . "', - '" . $POLine->AssetID . "', - '" . $POLine->ConversionFactor . "')"; - $ErrMsg =_('One of the purchase order detail records could not be inserted into the database because'); - $DbgMsg =_('The SQL statement used to insert the purchase order detail record and failed was'); - - $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - } - } /* end of the loop round the detail line items on the order */ + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $Order_Value += ($ItemRow['price']*$ItemRow['orderqty']); + } /* end of the loop round the items on the sales order that we wish to place purchase orders for */ + if ($SupplierID !=''){ //then we have just added a purchase order echo '<p>'; - prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . _('on') . ' ' . - $_SESSION['PO'.$identifier]->SupplierName . ' ' . _('has been created'),'success'); - } - } + prnMsg(_('Purchase Order') . ' ' . $PO_OrderNo . ' ' . _('on') . ' ' . $ItemRow['supplierno'] . ' ' . _('has been created'),'success'); + DB_Txn_Commit($db); + } + $result = DB_query("UPDATE salesorders SET poplaced=1 WHERE " . $OrdersToPlacePOFor,$db); + }/*There were items that had purchasing data set up to create POs for */ + } /* there were sales orders checked to place POs for */ }/*end of purchase order creation code */ /* ******************************************************************************************* */ @@ -389,14 +384,14 @@ while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockLocation'])){ if ($myrow['loccode'] == $_POST['StockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo "<option selected Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option selected Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } else { - echo "<option Value='" . $myrow['loccode'] . "'>" . $myrow['locationname']; + echo '<option Value="' . $myrow['loccode'] . '">' . $myrow['locationname']. '</option>'; } } @@ -416,7 +411,7 @@ } echo '</select> </td><td>'; - echo "<input type=submit name='SearchOrders' VALUE='" . _('Search') . "'></td>"; + echo '<input type=submit name="SearchOrders" VALUE="' . _('Search') . '"></td>'; echo ' <td><a href="' . $rootpath . '/SelectOrderItems.php?' . SID . '&NewOrder=Yes">' . _('Add Sales Order') . '</a></td></tr></table>'; } @@ -428,16 +423,15 @@ $result1 = DB_query($SQL,$db); - echo "</font>"; - echo "<br /><table class=selection>"; + echo '<br /><table class="selection">'; echo '<tr><th colspan=6><font size=3 color=navy>' . _('To search for sales orders for a specific part use the part selection facilities below'); echo '</th></tr>'; - echo "<tr> - <td><font size=1>" . _('Select a stock category') . ":</font> - <select name='StockCat'>"; + echo '<tr> + <td><font size="1">' . _('Select a stock category') . ':</font> + <select name="StockCat">'; while ($myrow1 = DB_fetch_array($result1)) { - echo "<option VALUE='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo '<option value="'. $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; } echo '</select> @@ -455,12 +449,12 @@ if (isset($StockItemsResult) and DB_num_rows($StockItemsResult)>0) { echo '<table cellpadding=2 colspan=7 class=selection>'; - $TableHeader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('On Hand') . "</th> - <th>" . _('Units') . "</th> - </tr>"; + $TableHeader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('On Hand') . '</th> + <th>' . _('Units') . '</th> + </tr>'; echo $TableHeader; $j = 1; @@ -502,7 +496,7 @@ else { //figure out the SQL required from the inputs available - if (isset($_POST['Quotations']) and $_POST['Quotations']=='Orders_Only'){ + if (isset($_POST['Quotations']) AND $_POST['Quotations']=='Orders_Only'){ $Quotations = 0; } else { $Quotations =1; @@ -519,6 +513,7 @@ salesorders.deliverydate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -553,7 +548,8 @@ salesorders.orddate, salesorders.deliverydate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent) AS ordervalue FROM salesorders, salesorderdetails, @@ -578,7 +574,8 @@ salesorders.customerref, salesorders.orddate, salesorders.deliverto, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -612,6 +609,7 @@ salesorders.orddate, salesorders.deliverto, salesorders.printedpackingslip, + salesorders.poplaced, salesorders.deliverydate, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -642,7 +640,8 @@ salesorders.orddate, salesorders.deliverto, salesorders.deliverydate, - salesorders.printedpackingslip, + salesorders.printedpackingslip, + salesorders.poplaced, SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)) AS ordervalue FROM salesorders, salesorderdetails, @@ -676,9 +675,9 @@ if (DB_num_rows($SalesOrdersResult)>0) { /* Get users authority to place POs */ - $AuthSql="SELECT cancreate - FROM purchorderauth - WHERE userid='". $_SESSION['UserID'] . "'"; + $AuthSQL="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "'"; /*we don't know what currency these orders might be in but if no authority at all then don't show option*/ $AuthResult=DB_query($AuthSQL,$db); @@ -718,7 +717,7 @@ } echo $tableheader; - } + $i = 1; $j = 1; $k=0; //row colour counter @@ -733,120 +732,120 @@ $k++; } - $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; - - if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - } else { /*pre-printed stationery default */ - $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + $ModifyPage = $rootpath . "/SelectOrderItems.php?" . SID . '&ModifyOrderNumber=' . $myrow['orderno']; + $Confirm_Invoice = $rootpath . '/ConfirmDispatch_Invoice.php?' . SID . '&OrderNumber=' .$myrow['orderno']; + + if ($_SESSION['PackNoteFormat']==1){ /*Laser printed A4 default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + } else { /*pre-printed stationery default */ + $PrintDispatchNote = $rootpath . '/PrintCustOrder.php?' . SID . '&TransNo=' . $myrow['orderno']; + } + $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; + $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; + $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); + $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); + $FormatedOrderValue = number_format($myrow['ordervalue'],2); + + if ($myrow['printedpackingslip']==0) { + $PrintText = _('Print'); + } else { + $PrintText = _('Reprint'); + } + + if ($_POST['Quotations']=='Orders_Only'){ + + /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ + if ($AuthRow['cancreate']==0 AND $myrow['poplaced']==0){ //cancreate==0 if the user can create POs and not already placed + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td><input type=checkbox name=PlacePO_%s value><input type=hidden name=OrderNo_PO_%s value=%s></td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue, + $i, + $i, + $myrow['orderno']); + } else { /*User is not authorised to create POs so don't even show the option */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . _('Invoice') . "</a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $Confirm_Invoice, + $PrintDispatchNote, + $PrintSalesOrder, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + + } else { /*must be quotes only */ + printf("<td><a href='%s'>%s</a></td> + <td><a href='%s'>" . $PrintText . "</a></td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + </tr>", + $ModifyPage, + $myrow['orderno'], + $PrintQuotation, + $myrow['name'], + $myrow['brname'], + $myrow['customerref'], + $FormatedOrderDate, + $FormatedDelDate, + $myrow['deliverto'], + $FormatedOrderValue); + } + $i++; + $j++; + if ($j == 12){ + $j=1; + echo $tableheader; + } + //end of page full new headings if + }//end while loop through orders to display + if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs + echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; } - $PrintSalesOrder = $rootpath . '/PrintSalesOrder_generic.php?' . SID . '&TransNo=' . $myrow['orderno']; - $PrintQuotation = $rootpath . '/PDFQuotation.php?' . SID . '&QuotationNo=' . $myrow['orderno']; - $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); - $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); - $FormatedOrderValue = number_format($myrow['ordervalue'],2); - - if ($myrow['printedpackingslip']==0) { - $PrintText = _('Print'); - } else { - $PrintText = _('Reprint'); - } - - if ($_POST['Quotations']=='Orders_Only'){ - - /*Check authority to create POs if user has authority then show the check boxes to select sales orders to place POs for otherwise don't provide this option */ - if ($AuthRow['cancreate']==0){ //cancreate==0 if the user can create POs - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td><input type=checkbox name=PlacePO_%s><input type=hidden name=OrderNo_PO_%s value=%s></td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue, - $i, - $i, - $myrow['orderno']); - } else { /*User is not authorised to create POs so don't even show the option */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . _('Invoice') . "</a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td><a target='_blank' href='%s'>" . $PrintText . " <IMG SRC='" .$rootpath."/css/".$theme."/images/pdf.png' title='" . _('Click for PDF') . "'></a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $Confirm_Invoice, - $PrintDispatchNote, - $PrintSalesOrder, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - - } else { /*must be quotes only */ - printf("<td><a href='%s'>%s</a></td> - <td><a href='%s'>" . $PrintText . "</a></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - </tr>", - $ModifyPage, - $myrow['orderno'], - $PrintQuotation, - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $FormatedOrderDate, - $FormatedDelDate, - $myrow['deliverto'], - $FormatedOrderValue); - } - $i++; - $j++; - if ($j == 12){ - $j=1; - echo $tableheader; - } - //end of page full new headings if - } - //end of while loop - if ($_POST['Quotations']=='Orders_Only' AND $AuthRow['cancreate']==0){ //cancreate==0 means can create POs - echo '<tr><td colspan="10"><td><td colspan="2"><input type="submit" name="PlacePO" value="' . _('Place PO') . '" onclick="return confirm(\'' . _('This will create purchase orders for all the items on the checked sales orders above, based on the preferred supplier purchasing data held in the system. Are You Absolutely Sure?') . '\');"></td</tr>'; - } - echo '</table>'; + echo '</table>'; + } //end if there are some orders to show } ?> Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/Stocks.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -477,7 +477,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stkcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -493,7 +493,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY stockid"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY itemcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { Modified: trunk/SuppPriceList.php =================================================================== --- trunk/SuppPriceList.php 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/SuppPriceList.php 2011-03-13 04:55:32 UTC (rev 4508) @@ -21,10 +21,11 @@ $line_height=12; //get supplier - $sqlsup = "SELECT suppname FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; + $sqlsup = "SELECT suppname, currcode FROM suppliers where supplierid='" . $_POST['supplier'] . "'"; $resultsup = db_query($sqlsup,$db); - $RowSup = db_fetch_row($resultsup); - $Supp=$RowSup['0']; + $RowSup = db_fetch_array($resultsup); + $SupplierName=$RowSup['suppname']; + $CurrCode =$RowSup['currcode']; //get category if ($_POST['category']!="all"){ @@ -36,26 +37,22 @@ $Categoryname="ALL"; } - //get currency - $sqlcur="SELECT currcode FROM `suppliers` where supplierid='" . $_POST['supplier'] . "'"; - $resultcur = db_query($sqlcur,$db); - $RowCur = db_fetch_row($resultcur); - $Currency=$RowCur['0']; - + //get date price - if ($_POST['price']=="all"){ - $DatePrice=_('All Price'); + if ($_POST['price']=='all'){ + $DatePrice=_('All Prices'); } else { $DatePrice=_('Current Price'); } //price and category = all - if (($_POST['price']=="all")and($_POST['category']=="all")){ + if (($_POST['price']=='all')and($_POST['category']=='all')){ $sql = "SELECT purchdata.stockid, stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -72,7 +69,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata, stockmaster WHERE supplierno = '" . $_POST['supplier'] . "' AND stockmaster.stockid = purchdata.stockid @@ -86,7 +84,8 @@ stockmaster.description, purchdata.price, (purchdata.effectivefrom)as dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -102,7 +101,8 @@ WHERE purchdata.stockid = stockmaster.stockid ORDER BY effectivefrom DESC LIMIT 0,1) AS dateprice, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.suppliers_partno FROM purchdata,stockmaster WHERE supplierno='" . $_POST['supplier'] . "' AND stockmaster.stockid=purchdata.stockid @@ -127,7 +127,7 @@ } PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); $FontSize=8; $code=''; @@ -148,26 +148,26 @@ $dateprice=date($_SESSION['DefaultDateFormat'], mktime(0,0,0,$DateArray[1],$DateArray[2],$DateArray[0])); //if item has more than 1 price, write only price, date and supplier code for the old ones - if ($code==$myrow[0]){ + if ($code==$myrow['stockid']){ - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); - $code=$myrow[0]; + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); + $code=$myrow['stockid']; } else { - $code=$myrow[0]; - $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow[0],'left'); - $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow[1],'left'); - $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow[2],2),'right'); + $code=$myrow['stockid']; + $pdf->addTextWrap(50,$YPos,90,$FontSize,$myrow['stockid'],'left'); + $pdf->addTextWrap(145,$YPos,215,$FontSize,$myrow['description'],'left'); + $pdf->addTextWrap(350,$YPos,50,$FontSize,number_format($myrow['price'],2),'right'); $pdf->addTextWrap(430,$YPos,50,$FontSize,$dateprice,'left'); - $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow[4],'left'); + $pdf->addTextWrap(510,$YPos,40,$FontSize,$myrow['suppliers_partno'],'left'); } if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } @@ -176,22 +176,13 @@ if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice); + $Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice); } + + $pdf->OutputD( $_SESSION['DatabaseName'] . '_SupplierPriceList_' . Date('Y-m-d') . '.pdf'); + - $pdfcode = $pdf->output(); - - header('Content-type: application/pdf'); - header("Content-Length: " . $len); - header('Content-Disposition: inline; filename=Supplier Price List.pdf'); - header('Expires: 0'); - header('Cache-Control: private, post-check=0, pre-check=0'); - header('Pragma: public'); - $pdf->Output('SuppPriceList.pdf', 'I'); - - - } else { /*The option to print PDF was not hit so display form */ $title=_('Supplier Price List'); @@ -229,8 +220,8 @@ echo '</select></td></tr>'; echo '<tr><td>' . _('Price List') . ':</td><td><select name="price"> '; - echo '<option Value="all">' ._('All Prices').''; - echo '<option Value="current">' ._('Only Current Price').''; + echo '<option Value="all">' ._('All Prices').'</option>'; + echo '<option Value="current">' ._('Only Current Price').'</option>'; echo '</select></td></tr>'; @@ -243,7 +234,7 @@ function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$Supp,$Categoryname,$Currency,$DatePrice) { + $Page_Width,$Right_Margin,$SupplierName,$Categoryname,$CurrCode,$DatePrice) { /*PDF page header for Supplier price list */ @@ -264,7 +255,7 @@ Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber,'left'); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Supplier').' '); - $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Supp); + $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$SupplierName); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Category').' '); @@ -272,7 +263,7 @@ $pdf->addTextWrap(95,$YPos,150,$FontSize,_(': ').$Categoryname); $YPos -= $line_height; $pdf->addTextWrap($Left_Margin,$YPos,50,$FontSize,_('Currency').' '); - $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$Currency); + $pdf->addTextWrap(95,$YPos,50,$FontSize,_(': ').$CurrCode); $YPos -=(2*$line_height); /*set up the headings */ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/doc/Change.log.html 2011-03-13 04:55:32 UTC (rev 4508) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>12/3/11: SelectSalesOrder.php now allows any number of sales orders to be selected and purchase orders placed for the aggregate of items on the selected sales orders</p> +<p>12/3/11: SuppPriceList.php removed a round trip to DB to get currency - fixed function to get pdf to new TCPDF Output </p> <p>12/3/11: Exson fix all htmlentities to use ENTQUOTES, 'UTF-8' option so other character sets work with it</p> <p>10/3/11: Phil fix pagination of PrintCustOrder_generic.php - second copy was not restarting page numbers</p> <p>10/3/11: Tims launchpad fixes brought in MRP.php fix for table charset utf8 so joins work correctly; typeo in PO_Header preventing purchasing data being retrieved ($result not $Result); correct sql on searching for customer in SelectCreditItems.php; StockStatus.php pricing history bug resolved (4450); StockQuantityByDate.php now allowed to show for all categories - enclosed 'All' in gettext</p> Modified: trunk/includes/ConnectDB.inc =================================================================== --- trunk/includes/ConnectDB.inc 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/includes/ConnectDB.inc 2011-03-13 04:55:32 UTC (rev 4508) @@ -4,7 +4,7 @@ * this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run * if VersionNumber is < $Version then the DB update script is run */ -$Version='4.03'; //must update manually every time there is a DB change +$Version='4.03.2'; //must update manually every time there is a DB change require_once ($PathPrefix .'includes/MiscFunctions.php'); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-11 20:24:03 UTC (rev 4507) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2011-03-13 04:55:32 UTC (rev 4508) @@ -816,4 +816,18 @@ UPDATE config SET confvalue='3.12.31' WHERE confname='VersionNumber'; INSERT INTO config (`confname`, `confvalue`) VALUES ('AutoAuthorisePO', '1'); UPDATE config SET confvalue='4.03' WHERE confname='VersionNumber'; +ALTER TABLE `salesorders` ADD `poplaced` TINYINT NOT NULL DEFAULT '0', +ADD INDEX ( `poplaced` ); +UPDATE config SET confvalue='4.03.1' WHERE confname='VersionNumber'; +CREATE TABLE IF NOT EXISTS `fixedassetlocations` ( + `locationid` char(6) NOT NULL DEFAULT '', + `locationdescription` char(20) NOT NULL DEFAULT '', + `parentlocationid` char(6) DEFAULT '', + PRIMARY KEY (`locationid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +INSERT INTO `fixedassetlocations` (`locationid`, `locationdescription`, `parentlocationid`) VALUES +('HEADOF', 'Head Office', ''); +UPDATE config SET confvalue='4.03.2' WHERE confname='VersionNumber'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |