From: <dai...@us...> - 2010-12-19 09:19:37
|
Revision: 4188 http://web-erp.svn.sourceforge.net/web-erp/?rev=4188&view=rev Author: daintree Date: 2010-12-19 09:19:30 +0000 (Sun, 19 Dec 2010) Log Message: ----------- PO stuff Modified Paths: -------------- trunk/PO_Header.php trunk/doc/Manual/ManualShipments.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/PO_Header.php 2010-12-19 09:19:30 UTC (rev 4188) @@ -99,21 +99,62 @@ if ($_POST['Status'] == 'Rejected' AND $OKToUpdateStatus==1) { - - //need to copy the lines to purchorderdetails_deleted - - if ($AuthorityLevel>$OrderTotal) { - $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Rejected by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; - $_SESSION['PO'.$identifier]->Status=$_POST['Status']; - } 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'); + $OKToReject = 1; //to start with + 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){ + $OKToReject =0; //its not ok to reject + prnMsg( _('This order cannot be cancelled 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'); + } } + if ($OKToReject==1){ + if ($AuthorityLevel>$OrderTotal) { + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Rejected by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; + } 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'); + } + } } + if ($_POST['Status'] == 'Cancelled') { + $OKToCancel =1; //to start with + 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){ + $OKToCancel =0; + prnMsg( _('This order cannot be cancelled 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'); + } + } + + if ($OKToCancel==1){ + + if ($AuthorityLevel>$OrderTotal) { + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Cancelled by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; + } else { + $OKToUpdateStatus=0; + prnMsg( _('You do not have permission to cancel 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'); + } + } //end if OKToCancel + } + if ($_POST['Status'] == 'Pending' and $OKToUpdateStatus==1) { if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Returned to Pending status by') . ' <a href="mailto:'. $EmailRow['email'] . '">'.$_SESSION['UserID']. @@ -245,177 +286,7 @@ include ('includes/PO_ReadInOrder.inc'); } -if (isset($_POST['CancelOrder']) AND $_POST['CancelOrder']!='') { -/*The cancel button on the header screen - to delete order */ - $OK_to_delete = 1; //alway assume the best to start with ... until we find out otherwise ... - 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){ - $OK_to_delete =0; - prnMsg( _('This order cannot be cancelled 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'); - } - - } - - if ($OK_to_delete==1){ - - if($_SESSION['ExistingOrder']!=0){ - $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; - $EmailResult=DB_query($EmailSQL, $db); - $EmailRow=DB_fetch_array($EmailResult); - $StatusComment=date($_SESSION['DefaultDateFormat']). ' - ' . _('Order Cancelled by:') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['StatusCommentsComplete']; - - /* Copy the deleted orders to the purchorder_deleted table so there is an audit trail of who ordered what */ - $sql = "INSERT INTO purchorders_deleted ( orderno, - supplierno, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms) - SELECT orderno, - supplierno, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - '" . PurchOrder::STATUS_CANCELLED . "', - '" . $StatusComment . "', - deliverydate, - paymentterms - FROM purchorders - WHERE orderno ='" . $_SESSION['ExistingOrder'] . "'"; - - $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 */ - $sql = "INSERT INTO purchorderdetails_deleted ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount, - assetid ) - SELECT orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount, - assetid - FROM purchorderdetails - WHERE orderno='" . $_SESSION['ExistingOrder'] . "'"; - - $ErrMsg =_('The deleted purchase order detail records could not be inserted into the database because'); - $DbgMsg =_('The SQL statement used to insert the deleted purchase order detail records and failed was'); - $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Now we have a copy to record the trail - we can delete this order from the database */ - - $sql = "DELETE FROM purchorderdetails - WHERE purchorderdetails.orderno ='" . $_SESSION['ExistingOrder'] ."'"; - $ErrMsg = _('The order detail lines could not be deleted because'); - $DelResult=DB_query($sql,$db,$ErrMsg); - - $sql="DELETE FROM purchorders - WHERE orderno='".$_SESSION['ExistingOrder']."'"; - $ErrMsg = _('The order header could not be deleted because'); - $DelResult=DB_query($sql,$db,$ErrMsg); - prnMsg( _('Order number').' '.$_SESSION['ExistingOrder'].' '._('has been deleted'), 'success'); - unset($_SESSION['ExistingOrder']); - unset($_SESSION['PO'.$identifier]->LineItems); - unset($_SESSION['PO'.$identifier]); - $_SESSION['PO'.$identifier] = new PurchOrder; - $_SESSION['RequireSupplierSelection'] = 1; - } else { //it's not an existing order currently so just clear the session variable to delete it - // Re-Direct to right place - unset($_SESSION['PO'.$identifier]); - prnMsg( _('The creation of the new order has been cancelled'), 'success'); - } - } -} - if (!isset($_SESSION['PO'.$identifier])){ /* It must be a new order being created * $_SESSION['PO'.$identifier] would be set up from the order modification Modified: trunk/doc/Manual/ManualShipments.html =================================================================== --- trunk/doc/Manual/ManualShipments.html 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/doc/Manual/ManualShipments.html 2010-12-19 09:19:30 UTC (rev 4188) @@ -6,7 +6,7 @@ <br><br> The shipment costing system is meant for use in situations where there are substantial freight costs on purchased products and the business wishes to keep track of the actual cost of these items. Many smaller businesses do these calculations on spreadsheets outside the integrated system. The advantage of bringing them inside the system is that the possibility for updating standards and calculation of variances from standard at the time the costing is completed. <br><br> -Having selected a supplier the system allows outstanding purchase order items to be collated into a shipment of goods arriving altogether, the shipment is allocated a shipment number. By changing the expected time of arrival of the shipment (ETA) the delivery date of all purchase order lines on the shipment will be updated. The costs associated with landing and clearing this bundle of products can be entered against it from purchase invoice entry. Freight charges and cartage from the wharf, airfreight, unpacking, demurrage etc can be entered as costs of the shipment. The shipment costing inquiry will show these costs allocated against all of the items on the shipment, using the invoiced value of the items as the basis for apportionment. The actual shipment cost will show together with the existing standard cost and the variance. +Having selected a supplier the system allows outstanding purchase order items to be collated into a shipment of goods arriving altogether, the shipment is allocated a shipment number. By changing the expected time of arrival of the shipment (ETA) the delivery date of all purchase order lines on the shipment will be updated. The costs associated with landing and clearing this bundle of products can be entered against it from purchase invoice entry. Most likely there will be many different supplier/vendor providing services to get the goods from the supplier's warehouse to the business's warehouse. Any number of different supplier's/vendor's charges can be entered against the shipment costing. Freight charges and cartage from the wharf, airfreight, unpacking, demurrage etc can be entered as costs of the shipment. These charges are entered by clicking the shipment charges button on the supplier invoice entry screen. Where a supplier provides freight services, it is possible that the supplier invoice has charges for many different shipments, the supplier invoice entry allows for the invoice to be split between any number of shipments. The shipment costing inquiry will show these costs allocated against all of the items on the shipment, using the invoiced value of the items as the basis for apportionment. The actual shipment cost will show together with the existing standard cost and the variance. <br><br> <font size="+1"><b>Shipment General Ledger Posting</b></font> <br><br> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 09:19:30 UTC (rev 4188) @@ -475,86 +475,4 @@ INSERT INTO `systypes` (`typeid` ,`typename` ,`typeno`) VALUES ('49', 'Import Fixed Assets', '1'); -CREATE TABLE `purchorderdetails_deleted` ( -`podetailitem` int(11) NOT NULL, -`orderno` int(11) NOT NULL DEFAULT '0', -`itemcode` varchar(20) NOT NULL DEFAULT '', -`deliverydate` date NOT NULL DEFAULT '0000-00-00', -`itemdescription` varchar(100) NOT NULL DEFAULT '', -`glcode` int(11) NOT NULL DEFAULT '0', -`qtyinvoiced` double NOT NULL DEFAULT '0', -`unitprice` double NOT NULL DEFAULT '0', -`actprice` double NOT NULL DEFAULT '0', -`stdcostunit` double NOT NULL DEFAULT '0', -`quantityord` double NOT NULL DEFAULT '0', -`quantityrecd` double NOT NULL DEFAULT '0', -`shiptref` int(11) NOT NULL DEFAULT '0', -`jobref` varchar(20) NOT NULL DEFAULT '', -`completed` tinyint(4) NOT NULL DEFAULT '0', -`itemno` varchar(50) NOT NULL DEFAULT '', -`uom` varchar(50) NOT NULL DEFAULT '', -`subtotal_amount` varchar(50) NOT NULL DEFAULT '', -`package` varchar(100) NOT NULL DEFAULT '', -`pcunit` varchar(50) NOT NULL DEFAULT '', -`nw` varchar(50) NOT NULL DEFAULT '', -`suppliers_partno` varchar(50) NOT NULL DEFAULT '', -`gw` varchar(50) NOT NULL DEFAULT '', -`cuft` varchar(50) NOT NULL DEFAULT '', -`total_quantity` varchar(50) NOT NULL DEFAULT '', -`total_amount` varchar(50) NOT NULL DEFAULT '', -`assetid` int NOT NULL DEFAULT 0, -PRIMARY KEY (`podetailitem`), -KEY `DeliveryDate` (`deliverydate`), -KEY `GLCode` (`glcode`), -KEY `ItemCode` (`itemcode`), -KEY `JobRef` (`jobref`), -KEY `OrderNo` (`orderno`), -KEY `ShiptRef` (`shiptref`), -KEY `Completed` (`completed`) -) ENGINE=InnoDB; - - -CREATE TABLE `purchorders_deleted` ( -`orderno` int(11) NOT NULL, -`supplierno` varchar(10) NOT NULL DEFAULT '', -`comments` longblob, -`orddate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`rate` double NOT NULL DEFAULT '1', -`dateprinted` datetime DEFAULT NULL, -`allowprint` tinyint(4) NOT NULL DEFAULT '1', -`initiator` varchar(10) DEFAULT NULL, -`requisitionno` varchar(15) DEFAULT NULL, -`intostocklocation` varchar(5) NOT NULL DEFAULT '', -`deladd1` varchar(40) NOT NULL DEFAULT '', -`deladd2` varchar(40) NOT NULL DEFAULT '', -`deladd3` varchar(40) NOT NULL DEFAULT '', -`deladd4` varchar(40) NOT NULL DEFAULT '', -`deladd5` varchar(20) NOT NULL DEFAULT '', -`deladd6` varchar(15) NOT NULL DEFAULT '', -`tel` varchar(15) NOT NULL DEFAULT '', -`suppdeladdress1` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress2` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress3` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress4` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress5` varchar(20) NOT NULL DEFAULT '', -`suppdeladdress6` varchar(15) NOT NULL DEFAULT '', -`suppliercontact` varchar(30) NOT NULL DEFAULT '', -`supptel` varchar(30) NOT NULL DEFAULT '', -`contact` varchar(30) NOT NULL DEFAULT '', -`version` decimal(3,2) NOT NULL DEFAULT '1.00', -`revised` date NOT NULL DEFAULT '0000-00-00', -`realorderno` varchar(16) NOT NULL DEFAULT '', -`deliveryby` varchar(100) NOT NULL DEFAULT '', -`deliverydate` date NOT NULL DEFAULT '0000-00-00', -`status` varchar(12) NOT NULL DEFAULT '', -`stat_comment` text NOT NULL, -`paymentterms` char(2) NOT NULL DEFAULT '', -`port` varchar(40) NOT NULL DEFAULT '', -PRIMARY KEY (`orderno`), -KEY `OrdDate` (`orddate`), -KEY `SupplierNo` (`supplierno`), -KEY `IntoStockLocation` (`intostocklocation`), -KEY `AllowPrintPO` (`allowprint`) -) ENGINE=InnoDB; - UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |