From: <dai...@us...> - 2014-08-29 22:33:44
|
Revision: 6856 http://sourceforge.net/p/web-erp/reponame/6856 Author: daintree Date: 2014-08-29 22:33:40 +0000 (Fri, 29 Aug 2014) Log Message: ----------- handle zero count of records returned from search Modified Paths: -------------- trunk/Dashboard.php trunk/WorkOrderEntry.php trunk/doc/Change.log Modified: trunk/Dashboard.php =================================================================== --- trunk/Dashboard.php 2014-08-29 20:41:58 UTC (rev 6855) +++ trunk/Dashboard.php 2014-08-29 22:33:40 UTC (rev 6856) @@ -1,5 +1,5 @@ <?php -/* $Id: Dashboard.php 6338 2013-09-28 05:10:46Z daintree $*/ +/* $Id: Dashboard.php 6843 2014-08-20 06:04:47Z daintree $*/ include('includes/session.inc'); Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2014-08-29 20:41:58 UTC (rev 6855) +++ trunk/WorkOrderEntry.php 2014-08-29 22:33:40 UTC (rev 6856) @@ -66,7 +66,7 @@ } else { // new $_POST['WO'] = GetNextTransNo(40,$db); - $sql = "INSERT INTO workorders (wo, + $SQL = "INSERT INTO workorders (wo, loccode, requiredby, startdate) @@ -75,7 +75,7 @@ '" . $LocCode . "', '" . $ReqDate . "', '" . $StartDate. "')"; - $InsWOResult = DB_query($sql,$db); + $InsWOResult = DB_query($SQL,$db); } @@ -190,23 +190,28 @@ ORDER BY stockmaster.stockid"; } } - $sql=$SQL; - $sqlcount = substr($sql,strpos($sql, "FROM")); - $sqlcount = substr($sqlcount,0, strpos($sqlcount, "ORDER")); - $sqlcount = 'SELECT COUNT(*) '.$sqlcount; - $SearchResult = DB_query($sqlcount,$db,$ErrMsg,$DbgMsg); + $SQLCount = substr($SQL,strpos($SQL, "FROM")); + $SQLCount = substr($SQLCount,0, strpos($SQLCount, "ORDER")); + $SQLCount = 'SELECT COUNT(*) '.$SQLCount; + $SearchResult = DB_query($SQLCount,$db,$ErrMsg); + $myrow=DB_fetch_array($SearchResult); DB_free_result($SearchResult); unset($SearchResult); $ListCount = $myrow[0]; - $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax'])-1; + if ($ListCount>0){ + $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax'])-1; + } else { + $ListPageMax =1; + } + if (isset($_POST['Next'])) { - $Offset = $_POST['currpage']+1; + $Offset = $_POST['CurrPage']+1; } if (isset($_POST['Prev'])) { - $Offset = $_POST['currpage']-1; + $Offset = $_POST['CurrPage']-1; } if (!isset($Offset)) { $Offset=0; @@ -217,12 +222,9 @@ if($Offset>$ListPageMax){ $Offset=$ListPageMax; } - $sql = $sql . ' LIMIT ' . $_SESSION['DisplayRecordsMax'].' OFFSET ' . strval($_SESSION['DisplayRecordsMax']*$Offset); + $SQL = $SQL . ' LIMIT ' . $_SESSION['DisplayRecordsMax'].' OFFSET ' . strval($_SESSION['DisplayRecordsMax']*$Offset); - $SQL=$sql; - - $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL used to get the part selection was'); $SearchResult = DB_query($SQL,$db,$ErrMsg, $DbgMsg); @@ -303,7 +305,7 @@ $Result = DB_Txn_Begin($db); // insert parent item info - $sql = "INSERT INTO woitems (wo, + $SQL = "INSERT INTO woitems (wo, stockid, qtyreqd, stdcost) @@ -314,7 +316,7 @@ '" . $Cost . "' )"; $ErrMsg = _('The work order item could not be added'); - $result = DB_query($sql,$db,$ErrMsg); + $result = DB_query($SQL,$db,$ErrMsg); //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements WoRealRequirements($db, $_POST['WO'], $_POST['StockLocation'], $NewItem); @@ -355,16 +357,16 @@ for ($i=1;$i<=$_POST['NumberOfOutputs'];$i++){ $QtyRecd+=$_POST['RecdQty'.$i]; } - unset($sql); + unset($SQL); if ($QtyRecd==0){ //can only change factory location if Qty Recd is 0 - $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', + $SQL[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "', loccode='" . $_POST['StockLocation'] . "' WHERE wo='" . $_POST['WO'] . "'"; } else { prnMsg(_('The factory where this work order is made can only be updated if the quantity received on all output items is 0'),'warn'); - $sql[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', + $SQL[] = "UPDATE workorders SET requiredby='" . $SQL_ReqDate . "', startdate='" . FormatDateForSQL($_POST['StartDate']) . "' WHERE wo='" . $_POST['WO'] . "'"; } @@ -376,7 +378,7 @@ if (!isset($_POST['WOComments'.$i])) { $_POST['WOComments'.$i]=''; } - $sql[] = "UPDATE woitems SET comments = '". $_POST['WOComments'.$i] ."' + $SQL[] = "UPDATE woitems SET comments = '". $_POST['WOComments'.$i] ."' WHERE wo='" . $_POST['WO'] . "' AND stockid='" . $_POST['OutputItem'.$i] . "'"; if (isset($_POST['QtyRecd'.$i]) AND $_POST['QtyRecd'.$i]>$_POST['OutputQty'.$i]){ @@ -399,13 +401,13 @@ } else { $Cost = $CostRow['cost']; } - $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + $SQL[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."', stdcost ='" . $Cost . "' WHERE wo='" . $_POST['WO'] . "' AND stockid='" . $_POST['OutputItem'.$i] . "'"; } elseif (isset($_POST['HasWOSerialNos'.$i]) AND $_POST['HasWOSerialNos'.$i]==false) { - $sql[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', + $SQL[] = "UPDATE woitems SET qtyreqd = '". $_POST['OutputQty' . $i] . "', nextlotsnref = '". $_POST['NextLotSNRef'.$i] ."' WHERE wo='" . $_POST['WO'] . "' AND stockid='" . $_POST['OutputItem'.$i] . "'"; @@ -414,9 +416,9 @@ //run the SQL from either of the above possibilites $ErrMsg = _('The work order could not be added/updated'); - foreach ($sql as $sql_stmt){ - // echo '<br />' . $sql_stmt; - $result = DB_query($sql_stmt,$db,$ErrMsg); + foreach ($SQL as $SQL_stmt){ + // echo '<br />' . $SQL_stmt; + $result = DB_query($SQL_stmt,$db,$ErrMsg); } if (!isset($_POST['Search'])) { @@ -452,19 +454,19 @@ $ErrMsg = _('The work order could not be deleted'); $DbgMsg = _('The SQL used to delete the work order was'); //delete the worequirements - $sql = "DELETE FROM worequirements WHERE wo='" . $_POST['WO'] . "'"; - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $SQL = "DELETE FROM worequirements WHERE wo='" . $_POST['WO'] . "'"; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); //delete the items on the work order - $sql = "DELETE FROM woitems WHERE wo='" . $_POST['WO'] . "'"; - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $SQL = "DELETE FROM woitems WHERE wo='" . $_POST['WO'] . "'"; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); //delete the controlled items defined in wip - $sql="DELETE FROM woserialnos WHERE wo='" . $_POST['WO'] . "'"; + $SQL="DELETE FROM woserialnos WHERE wo='" . $_POST['WO'] . "'"; $ErrMsg=_('The work order serial numbers could not be deleted'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); // delete the actual work order - $sql="DELETE FROM workorders WHERE wo='" . $_POST['WO'] . "'"; + $SQL="DELETE FROM workorders WHERE wo='" . $_POST['WO'] . "'"; $ErrMsg=_('The work order could not be deleted'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); DB_Txn_Commit($db); prnMsg(_('The work order has been cancelled'),'success'); @@ -490,7 +492,7 @@ echo '<br /><table class="selection">'; -$sql="SELECT workorders.loccode, +$SQL="SELECT workorders.loccode, requiredby, startdate, costissued, @@ -500,7 +502,7 @@ INNER JOIN locationusers ON locationusers.loccode=workorders.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 WHERE workorders.wo='" . $_POST['WO'] . "'"; -$WOResult = DB_query($sql,$db); +$WOResult = DB_query($SQL,$db); if (DB_num_rows($WOResult)==1){ $myrow = DB_fetch_array($WOResult); @@ -714,7 +716,7 @@ if (DB_num_rows($SearchResult)>1){ - $PageBar = '<tr><td><input type="hidden" name="currpage" value="'.$Offset.'">'; + $PageBar = '<tr><td><input type="hidden" name="CurrPage" value="'.$Offset.'">'; if($Offset>0) $PageBar .= '<input type="submit" name="Prev" value="'._('Prev').'" />'; else Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2014-08-29 20:41:58 UTC (rev 6855) +++ trunk/doc/Change.log 2014-08-29 22:33:40 UTC (rev 6856) @@ -1,42 +1,43 @@ webERP Change Log -29/08/14 RChacon: In TaxAuthorityRates.php and TaxCategories.php: adds $ViewTopic and $BookMark; Uses gettext() to translate 'Exempt', 'Freight' and 'Handling'. -29/08/14 Exson: Fixed the StockLocStatus Serial Number link column shift problem. -28/08/14 RChacon: In Tax.php: Fixes SQL select order-by from transaction-date to record-number (primary key). Minor improvements. -28/08/14 Exson: Fixed the csv file aligned abnormal when there are commas in fields strings. -28/08/14 RChacon: In Tax.php: Adds code comments, clean-up unneeded variables, simplies and reorder SQL select, reduces if() calls, replaces addTextWarp-left-align with addText, replaces line-drawing a box with Rectangle(), fixes start-date for 'Y/m/d' format, adds start-date for 'Y-m-d' format, adds a summary section for the report, adds ViewTopic and BookMark, adds more NoOfPeriods. -26/08/14 RChacon: In PDFPriceList.php: Adds code comments, adds PageHeader() print for currabrev and categoryid, replaces addTextWarp-left-align with addText, replaces line-drawing a box with Rectangle(), adds 'Prices excluding tax' warning. -15/08/14 RChacon: Fixes double line feed in PDFQuotationPortrait.php reported by Arwan Galaya. Uniforms code between PDFQuotation.php and PDFQuotationPortrait.php. -14/08/14 RChacon: In CustomerInquiry.php and SupplierInquiry.php makes translatable the systypes.typename. -14/08/14 RChacon: In SupplierInquiry.php: Reorganizes columns Date, Type, Number, Reference and Comments, and regroups table-datacel format-strings as in CustomerInquiry.php code. -13/08/14 kelo: SupplierBalsAtPeriodEnd.php fix calculation to take into account fx differences on after date transactions -13/08/14 RChacon: includes/DatabaseTranslations.php used to store the fields of tables that are used from the database so that they can be translated in particular systypes for the types of transactions invoice credit note payment receipt etc. Can be extended for scripts and other tables where the data from the table is static and used to display -13/08/14 RChacon: In CustomerInquiry.php: Adds class ascending and reorganizes columns Date, Type, Number and Reference; Regroups table-datacel format-strings, completes the datacel quantity by table-row; makes translatable the systypes.typename. -12/08/14 RChacon: In SupplierInquiry.php: makes the field systypes.typename be translatable. -12/08/14 RChacon: In Z_poRebuildDefault.php: extends title, improves comments, sets file to pot, updates $FilesToInclude, renames old pot file to bak extension. Minor improvements. -08/08/14 Andrew Galuski: Add SQL and maintenance screens for Location based security. added new report aged controlled stock. additional scripts to follow as time allows +30/8/14 Phil: WorkOrderEntry.php didn't handle no item returned from search correctly - fixed. +29/8/14 RChacon: In TaxAuthorityRates.php and TaxCategories.php: adds $ViewTopic and $BookMark; Uses gettext() to translate 'Exempt', 'Freight' and 'Handling'. +29/8/14 Exson: Fixed the StockLocStatus Serial Number link column shift problem. +28/8/14 RChacon: In Tax.php: Fixes SQL select order-by from transaction-date to record-number (primary key). Minor improvements. +28/8/14 Exson: Fixed the csv file aligned abnormal when there are commas in fields strings. +28/8/14 RChacon: In Tax.php: Adds code comments, clean-up unneeded variables, simplies and reorder SQL select, reduces if() calls, replaces addTextWarp-left-align with addText, replaces line-drawing a box with Rectangle(), fixes start-date for 'Y/m/d' format, adds start-date for 'Y-m-d' format, adds a summary section for the report, adds ViewTopic and BookMark, adds more NoOfPeriods. +26/8/14 RChacon: In PDFPriceList.php: Adds code comments, adds PageHeader() print for currabrev and categoryid, replaces addTextWarp-left-align with addText, replaces line-drawing a box with Rectangle(), adds 'Prices excluding tax' warning. +15/8/14 RChacon: Fixes double line feed in PDFQuotationPortrait.php reported by Arwan Galaya. Uniforms code between PDFQuotation.php and PDFQuotationPortrait.php. +14/8/14 RChacon: In CustomerInquiry.php and SupplierInquiry.php makes translatable the systypes.typename. +14/8/14 RChacon: In SupplierInquiry.php: Reorganizes columns Date, Type, Number, Reference and Comments, and regroups table-datacel format-strings as in CustomerInquiry.php code. +13/8/14 kelo: SupplierBalsAtPeriodEnd.php fix calculation to take into account fx differences on after date transactions +13/8/14 RChacon: includes/DatabaseTranslations.php used to store the fields of tables that are used from the database so that they can be translated in particular systypes for the types of transactions invoice credit note payment receipt etc. Can be extended for scripts and other tables where the data from the table is static and used to display +13/8/14 RChacon: In CustomerInquiry.php: Adds class ascending and reorganizes columns Date, Type, Number and Reference; Regroups table-datacel format-strings, completes the datacel quantity by table-row; makes translatable the systypes.typename. +12/8/14 RChacon: In SupplierInquiry.php: makes the field systypes.typename be translatable. +12/8/14 RChacon: In Z_poRebuildDefault.php: extends title, improves comments, sets file to pot, updates $FilesToInclude, renames old pot file to bak extension. Minor improvements. +08/8/14 Andrew Galuski: Add SQL and maintenance screens for Location based security. added new report aged controlled stock. additional scripts to follow as time allows 2/1/14 Tim: Change columns around on SelectWorkOrder.php -31/07/14 RChacon: Corrects the bottom line of the rectangle. Adds comments (info for developers). -29/07/14 RChacon: In PDFPriceList.php: Adds comments (info for developers), ViewTopic and BookMark, and currency name in locale language; deletes unused lines; reformats for legibility; adjusts column sizes to field sizes; improves printing of stockmaster.longdescription; improves code to reduce execution time (calculation out of loops); links right column positions to right margin; corrects IF for CustomerSpecials (deletes translation). In ManualSalesTypes.html: Adds help info about Print a price list by inventory category. +31/7/14 RChacon: Corrects the bottom line of the rectangle. Adds comments (info for developers). +29/7/14 RChacon: In PDFPriceList.php: Adds comments (info for developers), ViewTopic and BookMark, and currency name in locale language; deletes unused lines; reformats for legibility; adjusts column sizes to field sizes; improves printing of stockmaster.longdescription; improves code to reduce execution time (calculation out of loops); links right column positions to right margin; corrects IF for CustomerSpecials (deletes translation). In ManualSalesTypes.html: Adds help info about Print a price list by inventory category. 27/7/14 Exson: Fixed the PO header lost initiator bugs when locations changed. Report by Akits from www.minghao.hk/bbs/. 25/7/14 Phil: Allow dummy - labour stock type items to be added to purchase orders. 17/7/14 RChacon: Adds ViewTopic and BookMark, adds bullet for class ascending columns, repositions columns Type and Trans, add class number to Trans, completes printf. 16/7/14 Andrew Galuski: Add standard cost to stock movement record for stock adjustments 03/07/14 Exson: Make status comments available in PO_OrderDetails.php to ensure that some important data such as grn reversing can be viewed. And add a return previous page link. 27/06/14 RChacon: Add code-comments, $ViewTopic, $BookMark, page_title_text and code to update NewStockID if OldStockID and SelectedStockItem are the same in Z_ChangeStockCode.php. Add id to the "Change An Inventory Item Code" topic anchor in ManualSpecialUtilities.html. -27/06/14 Exson: Make tel length in PO_Header.php is as same as field definition in sql. -26/06/14 Exson: Fixed the bug that Select Customers search result inconsistence with Customer receipt search result in SelectCustomer.php. -24/06/14 RChacon: Add $ViewTopic, $BookMark to Prices.php and minor improvements. -23/06/14 Tim: Fixed the GL account validation pop up error in MiscFunctions.js. -23/06/14 Exson: Fixed the bug that the sales order line's quantity will be update to zero but it show no change in appearance in SelectOrderItems.php. -22/06/14 Tim: Replace now() with CURRENT_TIMESTAMP in MRP.php to get time stamp to meet ANSI standard. -22/06/14 Exson: Fixed the mrp parameters runtime to datetime instead of date format since MRP running records need more precision. -22/06/14 Benjamin (bpiltz2302) from web-ERP-users mail list report and provide the solution for MRP LevelNetting unusual exit bug. The details can be found here: http://weberp-accounting.1478800.n4.nabble.com/MRP-Error-LevelNetting-td4657425.html -21/06/14 Exson: Add location check in StockAdjustments.php to prevent from users selecting controlled items based on one location but changed the location before submit it to server which make serial not exist check absolutely failed. -17/06/14 Exson: Add Z_ImportDebtors.php into Utilities menu and scripts table. -15/06/14 Akits from minghao.hk/bbs/ fixed the bugs that www_Users.php allowed modules does not matched the one displayed in index.php. -11/06/2014 Exson: Fixed the exported csv files with wrong aligned fields due to comma as part of fields content. -09/06/2014 Exson: Fixed the Delivery Date lossing bugs when change Warehouse. Reported by akits from minghao.hk(weberp) bbs. +27/6/14 Exson: Make tel length in PO_Header.php is as same as field definition in sql. +26/6/14 Exson: Fixed the bug that Select Customers search result inconsistence with Customer receipt search result in SelectCustomer.php. +24/6/14 RChacon: Add $ViewTopic, $BookMark to Prices.php and minor improvements. +23/6/14 Tim: Fixed the GL account validation pop up error in MiscFunctions.js. +23/6/14 Exson: Fixed the bug that the sales order line's quantity will be update to zero but it show no change in appearance in SelectOrderItems.php. +22/6/14 Tim: Replace now() with CURRENT_TIMESTAMP in MRP.php to get time stamp to meet ANSI standard. +22/6/14 Exson: Fixed the mrp parameters runtime to datetime instead of date format since MRP running records need more precision. +22/6/14 Benjamin (bpiltz2302) from web-ERP-users mail list report and provide the solution for MRP LevelNetting unusual exit bug. The details can be found here: http://weberp-accounting.1478800.n4.nabble.com/MRP-Error-LevelNetting-td4657425.html +21/6/14 Exson: Add location check in StockAdjustments.php to prevent from users selecting controlled items based on one location but changed the location before submit it to server which make serial not exist check absolutely failed. +17/6/14 Exson: Add Z_ImportDebtors.php into Utilities menu and scripts table. +15/6/14 Akits from minghao.hk/bbs/ fixed the bugs that www_Users.php allowed modules does not matched the one displayed in index.php. +11/6/2014 Exson: Fixed the exported csv files with wrong aligned fields due to comma as part of fields content. +09/6/2014 Exson: Fixed the Delivery Date lossing bugs when change Warehouse. Reported by akits from minghao.hk(weberp) bbs. 2/6/14 Phil: Added bom effectivity dates into work order creation cost calculations - as spotted by Andrew Galuski 1/6/14 Phil: Fixed bug in POItems.php that resulted in an SQL error when the number of items from the search was zero after previous searches had returned records 27/05/14 RChacon: Add page title text and icon to import scripts. Page title text = menu option. |