|
From: <dai...@us...> - 2011-08-10 10:21:32
|
Revision: 4655
http://web-erp.svn.sourceforge.net/web-erp/?rev=4655&view=rev
Author: daintree
Date: 2011-08-10 10:21:25 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
POReport.php added link to detail purchase order inquiry
10/8/11 Phil: PO_SelectPurchOrder.php and outstanding purchase order searches now show the delivery date (from the purchase order header) line items may have different delivery dates.
10/8/11 Phil: Stocks.php changing the stock category to one with a different stock account now creates a journal (if stock is linked to GL) to move the cost of the stock from the old GL account to the new GL account
Modified Paths:
--------------
trunk/POReport.php
trunk/PO_SelectOSPurchOrder.php
trunk/PO_SelectPurchOrder.php
trunk/Stocks.php
trunk/doc/Change.log
trunk/includes/DateFunctions.inc
Modified: trunk/POReport.php
===================================================================
--- trunk/POReport.php 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/POReport.php 2011-08-10 10:21:25 UTC (rev 4655)
@@ -72,9 +72,9 @@
//####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT####
-function submit(&$db,$PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType)
-{
+function submit(&$db,$PartNumber,$PartNumberOp,$SupplierId,$SupplierIdOp,$SupplierName,$SupplierNameOp,$SaveSummaryType) {
+ global $rootpath;
//initialize no input errors
$InputError = 0;
@@ -502,7 +502,7 @@
$Detail_Array['suppliers.suppname,suppliers.supplierid,purchorderdetails.orderno'] = _('Supplier Name');
// Display Header info
- echo '<table class=selection>';
+ echo '<table class="selection">';
if ($_POST['ReportType'] == 'Summary') {
$SortBy_Display = $Summary_Array[$SaveSummaryType];
} else {
@@ -533,7 +533,7 @@
<td>' . $_POST['Category'] . '</td></tr></table>';
if ($_POST['ReportType'] == 'Detail') {
- echo '<br /><table class=selection width=98%>';
+ echo '<br /><table class="selection" width=98%>';
if ($_POST['DateType'] == 'Order') {
echo '<tr><th>' . _('Order No') . '</th>
<th>' . _('Part Number') . '</th>
@@ -561,7 +561,7 @@
}
$linectr++;
// Detail for both DateType of Order
- printf('<td>%s</td>
+ printf('<td><a href="'. $rootpath . '/PO_OrderDetails.php?OrderNo=%s">%s</a></td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
@@ -575,6 +575,7 @@
<td>%s</td>
</tr>',
$myrow['orderno'],
+ $myrow['orderno'],
$myrow['itemcode'],
ConvertSQLDate($myrow['orddate']),
$myrow['supplierno'],
Modified: trunk/PO_SelectOSPurchOrder.php
===================================================================
--- trunk/PO_SelectOSPurchOrder.php 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/PO_SelectOSPurchOrder.php 2011-08-10 10:21:25 UTC (rev 4655)
@@ -282,6 +282,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.status,
purchorders.requisitionno,
@@ -317,6 +318,7 @@
purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.status,
purchorders.initiator,
purchorders.requisitionno,
@@ -346,6 +348,7 @@
purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.status,
purchorders.initiator,
purchorders.requisitionno,
@@ -377,6 +380,7 @@
purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.status,
purchorders.initiator,
purchorders.requisitionno,
@@ -405,6 +409,7 @@
purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.status,
purchorders.initiator,
purchorders.requisitionno,
@@ -437,13 +442,13 @@
/*show a table of the orders returned by the SQL */
- echo '<table cellpadding=2 colspan=7 width=97% class=selection>';
+ echo '<table cellpadding="2" colspan="7 width="97%" class="selection">';
-// '</td><td class="tableheader">' . _('Receive') .
echo '<tr>
<th>' . _('Order #') . '</th>
<th>' . _('Order Date') . '</th>
+ <th>' . _('Delivery Date') . '</th>
<th>' . _('Initiated by') . '</th>
<th>' . _('Supplier') . '</th>
<th>' . _('Currency') . '</th>';
@@ -469,8 +474,7 @@
$ModifyPage = $rootpath . '/PO_Header.php?ModifyOrderNumber=' . $myrow['orderno'];
if ($myrow['status'] == 'Printed') {
- $ReceiveOrder = '<a href="'.$rootpath . '/GoodsReceived.php?PONumber=' . $myrow['orderno'].'">'.
- _('Receive').'</a>';
+ $ReceiveOrder = '<a href="'.$rootpath . '/GoodsReceived.php?PONumber=' . $myrow['orderno'].'">'. _('Receive') . '</a>';
} else {
$ReceiveOrder = '';
}
@@ -487,15 +491,17 @@
$FormatedOrderDate = ConvertSQLDate($myrow['orddate']);
+ $FormatedDeliveryDate = ConvertSQLDate($myrow['deliverydate']);
$FormatedOrderValue = number_format($myrow['ordervalue'],2);
echo '<td><a href="'.$ModifyPage.'">' . $myrow['orderno'] . '</a></td>
<td>' . $FormatedOrderDate . '</td>
+ <td>' . $FormatedDeliveryDate . '</td>
<td>' . $myrow['initiator'] . '</td>
<td>' . $myrow['suppname'] . '</td>
<td>' . $myrow['currcode'] . '</td>';
if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) {
- echo '<td class=number>'.$FormatedOrderValue . '</td>';
+ echo '<td class="number">'.$FormatedOrderValue . '</td>';
}
echo '<td>' . _($myrow['status']) . '</td>
<td>' . $PrintPurchOrder . '</td>
Modified: trunk/PO_SelectPurchOrder.php
===================================================================
--- trunk/PO_SelectPurchOrder.php 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/PO_SelectPurchOrder.php 2011-08-10 10:21:25 UTC (rev 4655)
@@ -193,8 +193,8 @@
}
echo '<td><input type="submit" name="SelectedStockItem" value="' . $myrow['stockid'] . '"</td>
<td>' . $myrow['description'] . '</td>
- <td class=number>' . $myrow['qoh'] . '</td>
- <td class=number>' . $myrow['qord'] . '</td>
+ <td class="number">' . $myrow['qoh'] . '</td>
+ <td class="number">' . $myrow['qord'] . '</td>
<td>' . $myrow['units'] . '</td>
</tr>';
$j++;
@@ -229,6 +229,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.requisitionno,
purchorders.allowprint,
@@ -263,6 +264,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.requisitionno,
purchorders.allowprint,
@@ -293,6 +295,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.requisitionno,
purchorders.allowprint,
@@ -324,6 +327,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.requisitionno,
purchorders.allowprint,
@@ -353,6 +357,7 @@
$SQL = "SELECT purchorders.orderno,
suppliers.suppname,
purchorders.orddate,
+ purchorders.deliverydate,
purchorders.initiator,
purchorders.requisitionno,
purchorders.allowprint,
@@ -386,13 +391,14 @@
if (DB_num_rows($PurchOrdersResult) > 0) {
/*show a table of the orders returned by the SQL */
- echo '<table cellpadding=2 colspan=7 width=90% class=selection>';
+ echo '<table cellpadding="2" colspan="7" width="90%" class="selection">';
$TableHeader = '<tr>
<th>' . _('View') . '</th>
<th>' . _('Supplier') . '</th>
<th>' . _('Currency') . '</th>
<th>' . _('Requisition') . '</th>
<th>' . _('Order Date') . '</th>
+ <th>' . _('Delivery Date') . '</th>
<th>' . _('Initiator') . '</th>
<th>' . _('Order Total') . '</th>
<th>' . _('Status') . '</th>
@@ -410,6 +416,7 @@
}
$ViewPurchOrder = $rootpath . '/PO_OrderDetails.php?OrderNo=' . $myrow['orderno'];
$FormatedOrderDate = ConvertSQLDate($myrow['orddate']);
+ $FormatedDeliveryDate = ConvertSQLDate($myrow['deliverydate']);
$FormatedOrderValue = number_format($myrow['ordervalue'], $myrow['decimalplaces']);
/* View Supplier Currency Requisition Order Date Initiator Order Total
ModifyPage, $myrow["orderno"], $myrow["suppname"], $myrow["currcode"], $myrow["requisitionno"] $FormatedOrderDate, $myrow["initiator"] $FormatedOrderValue Order Status*/
@@ -418,8 +425,9 @@
<td>' . $myrow['currcode'] . '</td>
<td>' . $myrow['requisitionno'] . '</td>
<td>' . $FormatedOrderDate . '</td>
+ <td>' . $FormatedDeliveryDate . '</td>
<td>' . $myrow['initiator'] . '</td>
- <td class=number>' . $FormatedOrderValue . '</td>
+ <td class="number">' . $FormatedOrderValue . '</td>
<td>' . _($myrow['status']) . '</td>
</tr>';
//$myrow['status'] is a string which has gettext translations from PO_Header.php script
Modified: trunk/Stocks.php
===================================================================
--- trunk/Stocks.php 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/Stocks.php 2011-08-10 10:21:25 UTC (rev 4655)
@@ -211,27 +211,43 @@
*/
$sql = "SELECT mbflag,
controlled,
- serialised
- FROM stockmaster WHERE stockid = '".$StockID."'";
+ serialised,
+ materialcost+labourcost+overheadcost AS itemcost,
+ stockcategory.stockact
+ FROM stockmaster
+ INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockid = '".$StockID."'";
$MBFlagResult = DB_query($sql,$db);
$myrow = DB_fetch_row($MBFlagResult);
$OldMBFlag = $myrow[0];
$OldControlled = $myrow[1];
$OldSerialised = $myrow[2];
+ $UnitCost = $myrow[3];
+ $OldStockAccount = $myrow[4];
$sql = "SELECT SUM(locstock.quantity)
FROM locstock
WHERE stockid='".$StockID."'
GROUP BY stockid";
$result = DB_query($sql,$db);
- $stkqtychk = DB_fetch_row($result);
+ $StockQtyRow = DB_fetch_row($result);
+ /*Now check the GL account of the new category to see if it is different to the old stock gl account */
+
+ $result = DB_query("SELECT stockact
+ FROM stockcategory
+ WHERE categoryid='" . $_POST['CategoryID'] . "'",
+ $db);
+ $NewStockActRow = DB_fetch_array($result);
+ $NewStockAct = $NewStockActRow['stockact'];
+
if ($OldMBFlag != $_POST['MBFlag']){
if (($OldMBFlag == 'M' OR $OldMBFlag=='B') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K' OR $_POST['MBFlag']=='D' OR $_POST['MBFlag']=='G')){ /*then need to check that there is no stock holding first */
/* stock holding OK for phantom (ghost) items */
- if ($stkqtychk[0]!=0 AND $OldMBFlag!='G'){
+ if ($StockQtyRow[0]!=0 AND $OldMBFlag!='G'){
$InputError=1;
- prnMsg( _('The make or buy flag cannot be changed from') . ' ' . $OldMBFlag . ' ' . _('to') . ' ' . $_POST['MBFlag'] . ' ' . _('where there is a quantity of stock on hand at any location') . '. ' . _('Currently there are') . ' ' . $stkqtychk[0] . ' ' . _('on hand') , 'errror');
+ prnMsg( _('The make or buy flag cannot be changed from') . ' ' . $OldMBFlag . ' ' . _('to') . ' ' . $_POST['MBFlag'] . ' ' . _('where there is a quantity of stock on hand at any location') . '. ' . _('Currently there are') . ' ' . $StockQtyRow[0] . ' ' . _('on hand') , 'errror');
}
/* don't allow controlled/serialized */
if ($_POST['Controlled']==1){
@@ -296,18 +312,21 @@
}
/* Do some checks for changes in the Serial & Controlled setups */
- if ($OldControlled != $_POST['Controlled'] AND $stkqtychk[0]!=0){
+ if ($OldControlled != $_POST['Controlled'] AND $StockQtyRow[0]!=0){
$InputError=1;
prnMsg( _('You can not change a Non-Controlled Item to Controlled (or back from Controlled to non-controlled when there is currently stock on hand for the item') , 'error');
}
- if ($OldSerialised != $_POST['Serialised'] AND $stkqtychk[0]!=0){
+ if ($OldSerialised != $_POST['Serialised'] AND $StockQtyRow[0]!=0){
$InputError=1;
prnMsg( _('You can not change a Serialised Item to Non-Serialised (or vice-versa) when there is a quantity on hand for the item') , 'error');
}
if ($InputError == 0){
+
+ DB_Txn_Begin($db);
+
$sql = "UPDATE stockmaster
SET longdescription='" . $_POST['LongDescription'] . "',
description='" . $_POST['Description'] . "',
@@ -333,12 +352,12 @@
$ErrMsg = _('The stock item could not be updated because');
$DbgMsg = _('The SQL that was used to update the stock item and failed was');
- $result = DB_query($sql,$db,$ErrMsg,$DbgMsg);
+ $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
//delete any properties for the item no longer relevant with the change of category
$result = DB_query("DELETE FROM stockitemproperties
WHERE stockid ='" . $StockID . "'",
- $db);
+ $db,$ErrMsg,$DbgMsg,true);
//now insert any item properties
for ($i=0;$i<$_POST['PropertyCounter'];$i++){
@@ -356,8 +375,47 @@
VALUES ('" . $StockID . "',
'" . $_POST['PropID' . $i] . "',
'" . $_POST['PropValue' . $i] . "')",
- $db);
+ $db,$ErrMsg,$DbgMsg,true);
} //end of loop around properties defined for the category
+
+ if ($OldStockAccount != $NewStockAct AND $_SESSION['CompanyRecord']['gllinkstock']==1) {
+ /*Then we need to make a journal to transfer the cost to the new stock account */
+ $JournalNo = GetNextTransNo(0,$db); //enter as a journal
+ $SQL = "INSERT INTO gltrans (type,
+ typeno,
+ trandate,
+ periodno,
+ account,
+ narrative,
+ amount)
+ VALUES ( 0,
+ '" . $JournalNo . "',
+ '" . Date('Y-m-d') . "',
+ '" . GetPeriodNo(Date('Y-m-d'),true) . "',
+ '" . $NewStockAccount . "',
+ '" . $StockID . ' ' . _('Change stock category') . "',
+ '" . ($UnitCost* $StockQtyRow[0]) . "'";
+ $ErrMsg = _('The stock cost journal could not be inserted because');
+ $DbgMsg = _('The SQL that was used to create the stock cost journal and failed was');
+ $result = DB_query($sql,$db, $ErrMsg, $DbgMsg,true);
+ $SQL = "INSERT INTO gltrans (type,
+ typeno,
+ trandate,
+ periodno,
+ account,
+ narrative,
+ amount)
+ VALUES ( 0,
+ '" . $JournalNo . "',
+ '" . Date('Y-m-d') . "',
+ '" . GetPeriodNo(Date('Y-m-d'),true) . "',
+ '" . $OldStockAccount . "',
+ '" . $StockID . ' ' . _('Change stock category') . "',
+ '" . (-$UnitCost* $StockQtyRow[0]) . "'";
+ $result = DB_query($sql,$db, $ErrMsg, $DbgMsg,true);
+
+ } /* end if the stock category changed and forced a change in stock cost account */
+ DB_Txn_Commit($db);
prnMsg( _('Stock Item') . ' ' . $StockID . ' ' . _('has been updated'), 'success');
echo '<br />';
}
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/doc/Change.log 2011-08-10 10:21:25 UTC (rev 4655)
@@ -1,5 +1,8 @@
webERP Change Log
+10/8/11 Phil: POReport.php added link to detail purchase order inquiry
+10/8/11 Phil: PO_SelectPurchOrder.php and outstanding purchase order searches now show the delivery date (from the purchase order header) line items may have different delivery dates.
+10/8/11 Phil: Stocks.php changing the stock category to one with a different stock account now creates a journal (if stock is linked to GL) to move the cost of the stock from the old GL account to the new GL account
7/8/11 Phil: SelectProduct.php now disables transactions on items flagged as obsolete (discontinued). Also obsolete items are shown as such in the selection list - suggested by Klaus (opto)
7/8/11 Ricard: Corrected INNER JOIN ON clause in sql used in InventoryQuantities.php script
7/8/11 Klaus: Added docuwiki links to WikiLinks function in MiscFunctions.php and allow Docuwiki option in SystemParameters.php
Modified: trunk/includes/DateFunctions.inc
===================================================================
--- trunk/includes/DateFunctions.inc 2011-08-08 10:32:39 UTC (rev 4654)
+++ trunk/includes/DateFunctions.inc 2011-08-10 10:21:25 UTC (rev 4655)
@@ -875,7 +875,7 @@
}
}
/* Find the unix timestamp of the last period end date in periods table */
- $sql = 'SELECT MAX(lastdate_in_period), MAX(periodno) from periods';
+ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods";
$result = DB_query($sql, $db);
$myrow=DB_fetch_row($result);
if (is_null($myrow[0])){
@@ -889,7 +889,7 @@
$LastPeriod = $myrow[1];
}
/* Find the unix timestamp of the first period end date in periods table */
- $sql = 'SELECT MIN(lastdate_in_period), MIN(periodno) from periods';
+ $sql = "SELECT MIN(lastdate_in_period), MIN(periodno) from periods";
$result = DB_query($sql, $db);
$myrow=DB_fetch_row($result);
$Date_Array = explode('-', $myrow[0]);
@@ -929,7 +929,7 @@
}
} else if (!PeriodExists(mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)), $db)) {
/* Make sure the following months period exists */
- $sql = 'SELECT MAX(lastdate_in_period), MAX(periodno) from periods';
+ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods";
$result = DB_query($sql, $db);
$myrow=DB_fetch_row($result);
$Date_Array = explode('-', $myrow[0]);
@@ -941,8 +941,10 @@
/* Now return the period number of the transaction */
$MonthAfterTransDate = Mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate));
- $GetPrdSQL = "SELECT periodno FROM periods WHERE lastdate_in_period < '" .
- Date('Y-m-d', $MonthAfterTransDate) . "' AND lastdate_in_period >= '" . Date('Y-m-d', $TransDate) . "'";
+ $GetPrdSQL = "SELECT periodno
+ FROM periods
+ WHERE lastdate_in_period < '" . Date('Y-m-d', $MonthAfterTransDate) . "'
+ AND lastdate_in_period >= '" . Date('Y-m-d', $TransDate) . "'";
$ErrMsg = _('An error occurred in retrieving the period number');
$GetPrdResult = DB_query($GetPrdSQL,$db,$ErrMsg);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|