From: <dai...@us...> - 2010-12-05 09:32:09
|
Revision: 4179 http://web-erp.svn.sourceforge.net/web-erp/?rev=4179&view=rev Author: daintree Date: 2010-12-05 09:32:02 +0000 (Sun, 05 Dec 2010) Log Message: ----------- 5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required. Modified Paths: -------------- trunk/PO_Header.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/PO_Header.php 2010-12-05 09:32:02 UTC (rev 4179) @@ -69,7 +69,6 @@ } if (isset($_POST['UpdateStat']) AND $_POST['UpdateStat']!='') { - /*The cancel button on the header screen - to delete order */ $OK_to_updstat = 1; $OldStatus=$_SESSION['PO'.$identifier]->Stat; $NewStatus=$_POST['Stat']; @@ -277,7 +276,7 @@ if (isset($_POST['CancelOrder']) AND $_POST['CancelOrder']!='') { /*The cancel button on the header screen - to delete order */ - $OK_to_delete = 1; //assume this in the first instance + $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 @@ -294,35 +293,151 @@ } if ($OK_to_delete==1){ - $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['statcommentscomplete']; - unset($_SESSION['PO'.$identifier]->LineItems); - unset($_SESSION['PO'.$identifier]); - $_SESSION['PO'.$identifier] = new PurchOrder; - $_SESSION['RequireSupplierSelection'] = 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['statcommentscomplete']; + + /* 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); - $sql = "UPDATE purchorderdetails - SET completed=1 - WHERE purchorderdetails.orderno ='" . $_SESSION['ExistingOrder'] ."'"; + /*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="UPDATE purchorders - SET status='".PurchOrder::STATUS_CANCELLED."', - stat_comment='".$StatusComment."' - WHERE orderno='".$_SESSION['ExistingOrder']."'"; - + $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 cancelled'), 'success'); + prnMsg( _('Order number').' '.$_SESSION['ExistingOrder'].' '._('has been deleted'), 'success'); + unset($_SESSION['ExistingOrder']); + unset($_SESSION['PO'.$identifier]->LineItems); unset($_SESSION['PO'.$identifier]); - unset($_SESSION['ExistingOrder']); - } else { + $_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'); @@ -541,20 +656,20 @@ } else { $_POST['Select'] = $_SESSION['PO'.$identifier]->SupplierID; $sql = "SELECT suppliers.suppname, - suppliers.currcode, - suppliers.paymentterms, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.phn, - suppliers.port - FROM suppliers INNER JOIN currencies - ON suppliers.currcode=currencies.currabrev - WHERE supplierid='" . $_POST['Select'] . "'"; - + suppliers.currcode, + suppliers.paymentterms, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.phn, + suppliers.port + FROM suppliers INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE supplierid='" . $_POST['Select'] . "'"; + $ErrMsg = _('The supplier record of the supplier selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/doc/Change.log.html 2010-12-05 09:32:02 UTC (rev 4179) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required. <p>3/12/10 Matt Elbrecht : Estonian translation <p>30/11/10 Phil: Changed table structure of new fixedassettrans and modified upgrade script - those who already ran that bit will need to change the table again. Modified fixed asset scripts again. New fixed assets manual</p> <p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-05 09:32:02 UTC (rev 4179) @@ -510,4 +510,86 @@ 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. |