From: <dai...@us...> - 2013-04-14 05:07:48
|
Revision: 5841 http://sourceforge.net/p/web-erp/reponame/5841 Author: daintree Date: 2013-04-14 05:07:45 +0000 (Sun, 14 Apr 2013) Log Message: ----------- Tims fix for utility payment run reversal script Modified Paths: -------------- trunk/Stocks.php trunk/SupplierTenderCreate.php trunk/Z_ChangeStockCode.php trunk/Z_ReverseSuppPaymentRun.php Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2013-04-09 09:36:06 UTC (rev 5840) +++ trunk/Stocks.php 2013-04-14 05:07:45 UTC (rev 5841) @@ -711,6 +711,15 @@ $CancelDelete = 1; prnMsg( _('Cannot delete this item because there is currently some stock on hand'),'warn'); echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('on hand for this part'); + } else { + $sql = "SELECT COUNT(*) FROM offers WHERE stockid='".$StockID."' GROUP BY stockid"; + $result = DB_query($sql,$db); + $myrow = DB_fetch_row($result); + if ($myrow[0]!=0) { + $CancelDelete = 1; + prnMsg( _('Cannot delete this item because there are offers for this item'),'warn'); + echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('offers from suppliers for this part'); + } } } } Modified: trunk/SupplierTenderCreate.php =================================================================== --- trunk/SupplierTenderCreate.php 2013-04-09 09:36:06 UTC (rev 5840) +++ trunk/SupplierTenderCreate.php 2013-04-14 05:07:45 UTC (rev 5841) @@ -127,7 +127,7 @@ telephone FROM tenders WHERE closed=0 - AND requiredbydate > CURRENT_DATE"; + AND requiredbydate > '" . Date('Y-m-d') . "'"; $result=DB_query($sql, $db); echo '<table class="selection">'; echo '<tr> Modified: trunk/Z_ChangeStockCode.php =================================================================== --- trunk/Z_ChangeStockCode.php 2013-04-09 09:36:06 UTC (rev 5840) +++ trunk/Z_ChangeStockCode.php 2013-04-14 05:07:45 UTC (rev 5841) @@ -248,15 +248,12 @@ echo ' ... ' . _('completed'); echo '<br />' . _('Changing any image files'); - if (file_exists($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg')) { - if (rename($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg', - $_SESSION['part_pics_dir'] . '/' .$_POST['NewStockID'].'.jpg')) { - echo ' ... ' . _('completed'); - } else { - echo ' ... ' . _('failed'); - } + + if (rename($_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg', + $_SESSION['part_pics_dir'] . '/' .$_POST['NewStockID'].'.jpg')) { + echo ' ... ' . _('completed'); } else { - echo ' ... ' . _('completed'); + echo ' ... ' . _('failed'); } echo '<br />' . _('Changing the item properties table records') . ' - ' . _('parents'); @@ -303,8 +300,12 @@ $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); echo ' ... ' . _('completed'); - - + echo '<br />' . _('Changing offers table'); + $sql = "UPDATE offers SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'"; + $ErrMsg = _('The SQL to update the offer records failed'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + echo ' ... ' . _('completed'); + DB_ReinstateForeignKeys($db); $result = DB_Txn_Commit($db); Modified: trunk/Z_ReverseSuppPaymentRun.php =================================================================== --- trunk/Z_ReverseSuppPaymentRun.php 2013-04-09 09:36:06 UTC (rev 5840) +++ trunk/Z_ReverseSuppPaymentRun.php 2013-04-14 05:07:45 UTC (rev 5841) @@ -31,15 +31,6 @@ while ($Payment = DB_fetch_array($Result)){ prnMsg(_('Deleting payment number') . ' ' . $Payment['transno'] . ' ' . _('to supplier code') . ' ' . $Payment['supplierno'] . ' ' . _('for an amount of') . ' ' . $Payment['ovamount'],'info'); - $SQL = "DELETE FROM supptrans - WHERE type=22 - AND transno='" . $Payment['transno'] . "' - AND trandate='" . $SQLTranDate . "'"; - - $DelResult = DB_query($SQL,$db); - prnMsg(_('Deleted the SuppTran record'),'success'); - - $SQL = "SELECT supptrans.transno, supptrans.type, suppallocs.amt @@ -52,9 +43,9 @@ $SQL= "UPDATE supptrans SET settled=0, alloc=alloc-" . $Alloc['amt'] . ", - diffonexch = diffonexch - ((" . $Alloc['Amt'] . "/rate ) - " . $Alloc['amt']/$Payment['rate'] . ") - WHERE supptrans.type='" . $Alloc['type'] . "' - AND transno='" . $Alloc['transno'] . "'"; + diffonexch = diffonexch - ((" . $Alloc['amt'] . "/rate ) - " . $Alloc['amt']/$Payment['rate'] . ") + WHERE supptrans.type='" . $Alloc['type'] . "' + AND transno='" . $Alloc['transno'] . "'"; $ErrMsg =_('The update to the suppliers charges that were settled by the payment failed because'); $UpdResult = DB_query($SQL,$db,$ErrMsg); @@ -66,6 +57,15 @@ $DelResult = DB_query($SQL,$db); prnMsg(' ... ' . _('deleted the SuppAllocs records'),'info'); + $SQL = "DELETE FROM supptrans + WHERE type=22 + AND transno='" . $Payment['transno'] . "' + AND trandate='" . $SQLTranDate . "'"; + + $DelResult = DB_query($SQL,$db); + prnMsg(_('Deleted the SuppTran record'),'success'); + + $SQL= "DELETE FROM gltrans WHERE typeno='" . $Payment['transno'] . "' AND type=22"; $DelResult = DB_query($SQL,$db); prnMsg(' .... ' . _('the GLTrans records (if any)'),'info'); @@ -78,8 +78,6 @@ prnMsg(' .... ' . _('and the BankTrans record'),'info'); } - - } |