From: <dai...@us...> - 2011-05-11 09:59:52
|
Revision: 4563 http://web-erp.svn.sourceforge.net/web-erp/?rev=4563&view=rev Author: daintree Date: 2011-05-11 09:59:44 +0000 (Wed, 11 May 2011) Log Message: ----------- various Modified Paths: -------------- trunk/AccountSections.php trunk/Areas.php trunk/AuditTrail.php trunk/CustomerTypes.php trunk/FixedAssetItems.php trunk/FormDesigner.php trunk/GLJournal.php trunk/GLTags.php trunk/PDFBankingSummary.php trunk/PDFOrderStatus.php trunk/PO_AuthorisationLevels.php trunk/SecurityTokens.php trunk/Shipt_Select.php trunk/Stocks.php trunk/SupplierAllocations.php trunk/UpgradeDatabase.php trunk/Z_ImportStocks.php trunk/Z_MakeNewCompany.php trunk/doc/Change.log trunk/includes/session.inc Modified: trunk/AccountSections.php =================================================================== --- trunk/AccountSections.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/AccountSections.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -28,7 +28,7 @@ $myrow = DB_fetch_row($result); if( $myrow[0] == 0 ) { $sql = "INSERT INTO accountsection ( - sectionid, + sectionid,21 sectionname ) VALUES ( 2, @@ -68,9 +68,9 @@ $i++; } } - if (strpos($_POST['SectionName'],'&')>0 OR strpos($_POST['SectionName'],"'")>0) { + if (ContainsIllegalCharacters($_POST['SectionName'])>0) { $InputError = 1; - prnMsg( _('The account section name cannot contain the character') . " '&' " . _('or the character') ." '",'error'); + prnMsg( _('The account section name cannot contain any of the illegal characters') ." '",'error'); $Errors[$i] = 'SectionName'; $i++; } @@ -274,4 +274,4 @@ } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/Areas.php =================================================================== --- trunk/Areas.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/Areas.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -138,16 +138,17 @@ if (!isset($SelectedArea)) { - $sql = 'SELECT * FROM areas'; + $sql = "SELECT * FROM areas"; $result = DB_query($sql,$db); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p><br />'; - echo '<table>'; - echo "<tr> - <th>" . _('Area Code') . "</th> - <th>" . _('Area Name') . '</th>'; + echo '<table> + <tr> + <th>' . _('Area Code') . '</th> + <th>' . _('Area Name') . '</th> + </tr>'; $k=0; //row colour counter @@ -159,13 +160,11 @@ echo '<tr class="OddTableRows">'; $k++; } - - echo '<td>' . $myrow[0] . '</td>'; - echo '<td>' . $myrow[1] . '</td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedArea=' . $myrow[0] . '">' . _('Edit') . '</a></td>'; - echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&SelectedArea=' . $myrow[0] . '&delete=yes">' . _('Delete') . '</a></td>'; - echo '<td><a href="SelectCustomer.php'. '?' . SID . '&Area=' . $myrow[0] . '">' . _('View Customers from this Area') . '</a></td>'; - + echo '<td>' . $myrow[0] . '</td> + <td>' . $myrow[1] . '</td>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?SelectedArea=' . $myrow[0] . '">' . _('Edit') . '</a></td>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?SelectedArea=' . $myrow[0] . '&delete=yes">' . _('Delete') . '</a></td>'; + echo '<td><a href="SelectCustomer.php'. '?Area=' . $myrow[0] . '">' . _('View Customers from this Area') . '</a></td>'; } //END WHILE LIST LOOP echo '</table>'; Modified: trunk/AuditTrail.php =================================================================== --- trunk/AuditTrail.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/AuditTrail.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -101,7 +101,8 @@ $SQLString = str_replace('SET','',$SQLString); $SQLString = str_replace('WHERE',',',$SQLString); $SQLString = str_replace('AND',',',$SQLString); - $FieldArray = preg_split("/[[:space:]]*([[:alnum:].]+[[:space:]]*=[[:space:]]*(?:'[^']*'|[[:digit:].]+))[[:space:]]*,/", $SQLString, 0, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); for ($i=0; $i<sizeof($FieldArray); $i++) { + $FieldArray = preg_split("/[[:space:]]*([[:alnum:].]+[[:space:]]*=[[:space:]]*(?:'[^']*'|[[:digit:].]+))[[:space:]]*,/", $SQLString, 0, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); + for ($i=0; $i<sizeof($FieldArray); $i++) { $Assigment = explode('=', $FieldArray[$i]); $_SESSION['SQLString']['fields'][$i] = $Assigment[0]; if (sizeof($Assigment)>1) { @@ -176,7 +177,7 @@ if (isset($_SESSION['SQLString']['values'][$i]) and (trim(str_replace("'","",$_SESSION['SQLString']['values'][$i])) != "") & (trim($_SESSION['SQLString']['fields'][$i]) != 'password') & (trim($_SESSION['SQLString']['fields'][$i]) != "www_users.password")) { - echo '<tr bgcolor='.$RowColour.'>'; + echo '<tr bgcolor="' . $RowColour . '">'; echo '<td></td> <td></td> <td></td> @@ -186,7 +187,7 @@ echo '</tr>'; } } - echo '<tr bgcolor=black><td></td><td></td><td></td><td></td><td></td><td></td></tr>'; + echo '<tr bgcolor=black> <td colspan="6"></td> </tr>'; } unset($_SESSION['SQLString']); } Modified: trunk/CustomerTypes.php =================================================================== --- trunk/CustomerTypes.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/CustomerTypes.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -177,7 +177,7 @@ links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ - $sql = 'SELECT typeid, typename FROM debtortype'; + $sql = "SELECT typeid, typename FROM debtortype"; $result = DB_query($sql,$db); echo '<br /><table class=selection>'; @@ -255,9 +255,11 @@ if (!isset($_POST['typename'])) { $_POST['typename']=''; } - echo '<tr><td>' . _('Type Name') . ':</td><td><input type="Text" name="typename" value="' . $_POST['typename'] . '"></td></tr>'; + echo '<tr><td>' . _('Type Name') . ':</td> + <td><input type="Text" name="typename" value="' . $_POST['typename'] . '"></td></tr>'; - echo '</td></tr></table>'; // close main table + echo '</td></tr> + </table>'; // close main table echo '<p><div class="centre"><input type=submit name=submit value="' . _('Accept') . '"></div>'; @@ -265,6 +267,5 @@ } // end if user wish to delete - include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/FixedAssetItems.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -130,9 +130,9 @@ $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); /* Get the new account codes for the new asset category */ $result = DB_query("SELECT costact, - accumdepnact - FROM fixedassetcategories - WHERE categoryid='" . $_POST['AssetCategoryID'] . "'",$db); + accumdepnact + FROM fixedassetcategories + WHERE categoryid='" . $_POST['AssetCategoryID'] . "'",$db); $NewAccounts = DB_fetch_array($result); $TransNo = GetNextTransNo( 42, $db); /* transaction type is asset category change */ @@ -145,7 +145,7 @@ account, narrative, amount) - VALUES ('42', + VALUES ('42', '" . $TransNo . "', '" . Date('Y-m-d') . "', '" . $PeriodNo . "', @@ -159,75 +159,75 @@ //debit cost for the new category $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) + typeno, + trandate, + periodno, + account, + narrative, + amount) VALUES ('42', - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $NewAccounts['costact'] . "', - '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', - '" . $OldDetails['cost']. "' - )"; + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $NewAccounts['costact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['cost']. "' + )"; $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); if ($OldDetails['accumdepn']!=0) { //debit accumdepn for the old category $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('42', - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $OldDetails['accumdepnact'] . "', - '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', - '" . $OldDetails['accumdepn']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('42', + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $OldDetails['accumdepnact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['accumdepn']. "' + )"; $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); //credit accum depn for the new category $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('42', - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $NewAccounts['accumdepnact'] . "', - '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', - '" . $OldDetails['accumdepn']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('42', + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $NewAccounts['accumdepnact'] . "', + '" . $AssetID . ' ' . _('change category') . ' ' . $OldDetails['assetcategoryid'] . ' - ' . $_POST['AssetCategoryID'] . "', + '" . $OldDetails['accumdepn']. "' + )"; $ErrMsg = _('Cannot insert a GL entry for the change of asset category because'); $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } /*end if there was accumulated depreciation for the asset */ } /* end if there is a change in asset category */ $sql = "UPDATE fixedassets - SET longdescription='" . $_POST['LongDescription'] . "', - description='" . $_POST['Description'] . "', - assetcategoryid='" . $_POST['AssetCategoryID'] . "', - assetlocation='" . $_POST['AssetLocation'] . "', - depntype='" . $_POST['DepnType'] . "', - depnrate='" . $_POST['DepnRate'] . "', - barcode='" . $_POST['BarCode'] . "', - serialno='" . $_POST['SerialNo'] . "' - WHERE assetid='" . $AssetID . "'"; + SET longdescription='" . $_POST['LongDescription'] . "', + description='" . $_POST['Description'] . "', + assetcategoryid='" . $_POST['AssetCategoryID'] . "', + assetlocation='" . $_POST['AssetLocation'] . "', + depntype='" . $_POST['DepnType'] . "', + depnrate='" . $_POST['DepnRate'] . "', + barcode='" . $_POST['BarCode'] . "', + serialno='" . $_POST['SerialNo'] . "' + WHERE assetid='" . $AssetID . "'"; $ErrMsg = _('The asset could not be updated because'); $DbgMsg = _('The SQL that was used to update the asset and failed was'); @@ -237,22 +237,22 @@ echo '<br />'; } else { //it is a NEW part $sql = "INSERT INTO fixedassets (description, - longdescription, - assetcategoryid, - assetlocation, - depntype, - depnrate, - barcode, - serialno) - VALUES ( - '" . $_POST['Description'] . "', - '" . $_POST['LongDescription'] . "', - '" . $_POST['AssetCategoryID'] . "', - '" . $_POST['AssetLocation'] . "', - '" . $_POST['DepnType'] . "', - '" . $_POST['DepnRate']. "', - '" . $_POST['BarCode'] . "', - '" . $_POST['SerialNo'] . "' )"; + longdescription, + assetcategoryid, + assetlocation, + depntype, + depnrate, + barcode, + serialno) + VALUES ( + '" . $_POST['Description'] . "', + '" . $_POST['LongDescription'] . "', + '" . $_POST['AssetCategoryID'] . "', + '" . $_POST['AssetLocation'] . "', + '" . $_POST['DepnType'] . "', + '" . $_POST['DepnRate']. "', + '" . $_POST['BarCode'] . "', + '" . $_POST['SerialNo'] . "' )"; $ErrMsg = _('The asset could not be added because'); $DbgMsg = _('The SQL that was used to add the asset failed was'); $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); @@ -278,12 +278,12 @@ $CancelDelete = 0; //what validation is required before allowing deletion of assets .... maybe there should be no deletion option? $result = DB_query("SELECT cost, - accumdepn, - accumdepnact, - costact - FROM fixedassets INNER JOIN fixedassetcategories - ON fixedassets.assetcategoryid=fixedassetcategories.categoryid - WHERE assetid='" . $AssetID . "'", $db); + accumdepn, + accumdepnact, + costact + FROM fixedassets INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + WHERE assetid='" . $AssetID . "'", $db); $AssetRow = DB_fetch_array($result); $NBV = $AssetRow['cost'] -$AssetRow['accumdepn']; if ($NBV!=0) { @@ -309,40 +309,40 @@ if ($AssetRow['cost'] > 0){ //credit cost for the asset deleted $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('43', - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $AssetRow['costact'] . "', - '" . _('Delete asset') . ' ' . $AssetID . "', - '" . -$AssetRow['cost']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('43', + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $AssetRow['costact'] . "', + '" . _('Delete asset') . ' ' . $AssetID . "', + '" . -$AssetRow['cost']. "' + )"; $ErrMsg = _('Cannot insert a GL entry for the deletion of the asset because'); $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); //debit accumdepn for the depreciation removed on deletion of this asset $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ('43', - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $AssetRow['accumdepnact'] . "', - '" . _('Delete asset') . ' ' . $AssetID . "', - '" . $Asset['accumdepn']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ('43', + '" . $TransNo . "', + '" . Date('Y-m-d') . "', + '" . $PeriodNo . "', + '" . $AssetRow['accumdepnact'] . "', + '" . _('Delete asset') . ' ' . $AssetID . "', + '" . $Asset['accumdepn']. "' + )"; $ErrMsg = _('Cannot insert a GL entry for the reversal of accumulated depreciation on deletion of the asset because'); $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -394,17 +394,17 @@ } elseif ($InputError!=1) { // Must be modifying an existing item and no changes made yet - need to lookup the details $sql = "SELECT assetid, - description, - longdescription, - assetcategoryid, - serialno, - assetlocation, - datepurchased, - depntype, - depnrate, - cost, - accumdepn, - barcode + description, + longdescription, + assetcategoryid, + serialno, + assetlocation, + datepurchased, + depntype, + depnrate, + cost, + accumdepn, + barcode FROM fixedassets WHERE assetid ='" . $AssetID . "'"; @@ -421,11 +421,11 @@ $_POST['DepnRate'] = $AssetRow['depnrate']; echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; - echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; + echo '<input type="Hidden" name="AssetID" value="'.$AssetID.'"/>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above echo '<tr><td>' . _('Asset Code') . ':</td><td>' . $AssetID . '</td></tr>'; - echo '<input type="Hidden" name="AssetID" value="' . $AssetID . '">'; + echo '<input type="Hidden" name="AssetID" value="' . $AssetID . '"/>'; } if (isset($_POST['Description'])) { @@ -434,7 +434,7 @@ $Description =''; } echo '<tr><td>' . _('Asset Description') . ' (' . _('short') . '):</td> - <td><input ' . (in_array('Description',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Description" size=52 maxlength=50 value="' . $Description . '"></td></tr>'."\n"; + <td><input ' . (in_array('Description',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Description" size=52 maxlength=50 value="' . $Description . '"></td></tr>'."\n"; if (isset($_POST['LongDescription'])) { $LongDescription = AddCarriageReturns($_POST['LongDescription']); Modified: trunk/FormDesigner.php =================================================================== --- trunk/FormDesigner.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/FormDesigner.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -1,6 +1,6 @@ <?php /* $Id$ */ -//$PageSecurity = 14; + include('includes/session.inc'); $title = _('Form Designer'); include('includes/header.inc'); @@ -108,9 +108,6 @@ case 'GoodsReceived.xml': echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/PDFGrn.php?' . SID .'GRNNo=Preview&PONo=1">'; break; - case 'SalesInvoice.xml': - echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/PrintCustTrans.php?' . SID .'FromTransNo=Preview&InvOrCredit=Invoice&PrintPDF=True">'; - break; case 'PickingList.xml': echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/PDFPickingList.php?' . SID .'TransNo=Preview">'; break; Modified: trunk/GLJournal.php =================================================================== --- trunk/GLJournal.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/GLJournal.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -22,7 +22,7 @@ Journals cannot be entered against bank accounts GL postings involving bank accounts must be done using a receipt or a payment transaction to ensure a bank trans is available for matching off vs statements */ - $SQL = 'SELECT accountcode FROM bankaccounts'; + $SQL = "SELECT accountcode FROM bankaccounts"; $result = DB_query($SQL,$db); $i=0; while ($Act = DB_fetch_row($result)){ @@ -158,8 +158,8 @@ if ($AllowThisPosting) { $SQL = "SELECT accountname - FROM chartmaster - WHERE accountcode='" . $_POST['GLManualCode'] . "'"; + FROM chartmaster + WHERE accountcode='" . $_POST['GLManualCode'] . "'"; $Result=DB_query($SQL,$db); if (DB_num_rows($Result)==0){ @@ -270,13 +270,13 @@ //Select the tag echo '<tr><td><select name="tag">'; -$SQL = 'SELECT tagref, - tagdescription +$SQL = "SELECT tagref, + tagdescription FROM tags - ORDER BY tagref'; + ORDER BY tagref"; $result=DB_query($SQL,$db); -echo '<option value="0">0 - None</option>'; +echo '<option value="0">0 - ' . _('None') . '</option>'; while ($myrow=DB_fetch_array($result)){ if (isset($_POST['tag']) and $_POST['tag']==$myrow['tagref']){ echo '<option selected value="' . $myrow['tagref'] . '">' . $myrow['tagref'].' - ' .$myrow['tagdescription'].'</option>'; @@ -294,10 +294,10 @@ "'".'The account code '."'".'+ this.value+ '."'".' doesnt exist'."'".')"' . ' value="'. $_POST['GLManualCode'] .'" /></td>'; -$sql='SELECT accountcode, - accountname - FROM chartmaster - ORDER BY accountcode'; +$sql="SELECT accountcode, + accountname + FROM chartmaster + ORDER BY accountcode"; $result=DB_query($sql, $db); echo '<td><select name="GLCode" onChange="return assignComboToInput(this,'.'GLManualCode'.')">'; @@ -321,7 +321,7 @@ $_POST['Debit'] = ''; } -echo '</tr><tr><th>' . _('Debit') . '</th>'.'<td><input type="text" class="number" Name = "Debit" ' . +echo '</tr><tr><th>' . _('Debit') . '</th><td><input type="text" class="number" name = "Debit" ' . 'onChange="eitherOr(this, '.'Credit'.')"'. ' Maxlength="12" size="10" value="' . $_POST['Debit'] . '" /></td>'; echo '</tr><tr><th>' . _('Credit') . '</th><td><input type="text" class="number" Name = "Credit" ' . @@ -333,21 +333,22 @@ echo '<td><input type="text" name="GLNarrative" maxlength="100" size="100" value="' . $_POST['GLNarrative'] . '" /></td>'; echo '</tr></table><br />'; /*Close the main table */ -echo "<div class='centre'><input type='submit' name='Process' value='" . _('Accept') . "' /></div><br /><br />"; +echo '<div class="centre"><input type="submi2t" name="Process" value="' . _('Accept') . '" /></div><br /><br />'; echo '<table class="selection" width="85%">'; echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>' . _('Journal Summary') . '</b></font></div></th></tr>'; echo '<tr> - <th>'._('GL Tag').'</th> - <th>'._('GL Account').'</th> - <th>'._('Debit').'</th> - <th>'._('Credit').'</th> - <th>'._('Narrative').'</th></tr>'; + <th>'._('GL Tag').'</th> + <th>'._('GL Account').'</th> + <th>'._('Debit').'</th> + <th>'._('Credit').'</th> + <th>'._('Narrative').'</th> + </tr>'; -$debittotal=0; -$credittotal=0; +$DebitTotal=0; +$CreditTotal=0; $j=0; foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { @@ -364,39 +365,38 @@ $result=DB_query($sql, $db); $myrow=DB_fetch_row($result); if ($JournalItem->tag==0) { - $tagdescription='None'; + $TagDescription=_('None'); } else { - $tagdescription=$myrow[0]; + $TagDescription=$myrow[0]; } - echo '<td>' . $JournalItem->tag . ' - ' . $tagdescription . '</td>'; + echo '<td>' . $JournalItem->tag . ' - ' . $TagDescription . '</td>'; echo '<td>' . $JournalItem->GLCode . ' - ' . $JournalItem->GLActName . '</td>'; if ($JournalItem->Amount>0) { - echo '<td class="number">' . number_format($JournalItem->Amount,2) . '</td><td></td>'; - $debittotal=$debittotal+$JournalItem->Amount; - + echo '<td class="number">' . number_format($JournalItem->Amount,$_SESSION['CompanyRecord']['decimalplaces']) . '</td><td></td>'; + $DebitTotal=$DebitTotal+$JournalItem->Amount; } elseif($JournalItem->Amount<0) { - $credit=(-1 * $JournalItem->Amount); + $Credit=(-1 * $JournalItem->Amount); echo '<td></td> - <td class="number">' . number_format($credit,2) . '</td>'; - $credittotal=$credittotal+$credit; + <td class="number">' . number_format($Credit,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>'; + $CreditTotal=$CreditTotal+$Credit; } - echo '<td>' . $JournalItem->Narrative . "</td> - <td><a href='" . $_SERVER['PHP_SELF'] . '?Delete=' . $JournalItem->ID . "'>"._('Delete').'</a></td> + echo '<td>' . $JournalItem->Narrative . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?Delete=' . $JournalItem->ID . '">' . _('Delete').'</a></td> </tr>'; } echo '<tr class="EvenTableRows"><td></td> - <td class="number"><b>' . _('Total') . '</b></td> - <td class="number"><b>' . number_format($debittotal,2) . '</b></td> - <td class="number"><b>' . number_format($credittotal,2) . '</b></td></tr>'; -if ($debittotal!=$credittotal) { + <td class="number"><b>' . _('Total') . '</b></td> + <td class="number"><b>' . number_format($DebitTotal,$_SESSION['CompanyRecord']['decimalplaces']) . '</b></td> + <td class="number"><b>' . number_format($CreditTotal,$_SESSION['CompanyRecord']['decimalplaces']) . '</b></td></tr>'; +if ($DebitTotal!=$CreditTotal) { echo '<td align="center" style="background-color: #fddbdb"><b>' . _('Required to balance') .' - </b>' . - number_format(abs($debittotal-$credittotal),2); + number_format(abs($DebitTotal-$CreditTotal),$_SESSION['CompanyRecord']['decimalplaces']); } -if ($debittotal>$credittotal) { +if ($DebitTotal>$CreditTotal) { echo ' ' . _('Credit') . '</td></tr>'; -} else if ($debittotal<$credittotal) { +} else if ($DebitTotal<$CreditTotal) { echo ' ' . _('Debit') . '</td></tr>'; } echo '</table>'; @@ -409,9 +409,9 @@ } if (!isset($_GET['NewJournal']) or $_GET['NewJournal']=='') { - echo "<script>defaultControl(document.form.GLManualCode);</script>"; + echo '<script>defaultControl(document.form.GLManualCode);</script>'; } else { - echo "<script>defaultControl(document.form.JournalProcessDate);</script>"; + echo '<script>defaultControl(document.form.JournalProcessDate);</script>'; } echo '</form>'; Modified: trunk/GLTags.php =================================================================== --- trunk/GLTags.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/GLTags.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -8,39 +8,57 @@ include('includes/header.inc'); if (isset($_GET['SelectedTag'])) { - $sql="SELECT tagref, tagdescription FROM tags where tagref='".$_GET['SelectedTag']."'"; - $result= DB_query($sql,$db); - $myrow = DB_fetch_array($result,$db); - $ref=$myrow[0]; - $description=$myrow[1]; + if($_GET['Action']=='delete'){ + //first off test there are no transactions created with this tag + $Result = DB_query("SELECT counterindex + FROM gltrans + WHERE tag='" . $_GET['SelectedTag'] . "'",$db); + if (DB_num_rows($Result)>0){ + prnMsg(_('This tag cannot be deleted since there are already general ledger transactions created using it.'),'error'); + } else { + $Result = DB_query("DELETE FROM tags WHERE tagref='" . $_GET['SelectedTag'] . "'",$db); + prnMsg(_('The selected tag has been deleted'),'success'); + } + } else { + $sql="SELECT tagref, + tagdescription + FROM tags + WHERE tagref='".$_GET['SelectedTag']."'"; + + $result= DB_query($sql,$db); + $myrow = DB_fetch_array($result,$db); + $ref=$myrow['tagref']; + $Description=$myrow['tagdescription']; + } } else { - $description=''; + $Description=''; $_GET['SelectedTag']=''; } if (isset($_POST['submit'])) { - $sql = "INSERT INTO tags values(NULL, '".$_POST['description']."')"; + $sql = "INSERT INTO tags values(NULL, '".$_POST['Description']."')"; $result= DB_query($sql,$db); } if (isset($_POST['update'])) { - $sql = "UPDATE tags SET tagdescription='".$_POST['description']. - "' WHERE tagref='".$_POST['reference']."'"; + $sql = "UPDATE tags SET tagdescription='".$_POST['Description']. "' + WHERE tagref='".$_POST['reference']."'"; $result= DB_query($sql,$db); } echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Print') . '" alt="" />' . ' ' . $title . '</p>'; -echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . ' name="form">'; +echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="form">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<br><table><tr>'; +echo '<br /> + <table><tr>'; echo '<td>'. _('Description') . '</td> - <td><input type="text" size=30 maxlength=30 name="description" value="'.$description.'"></td><td> - <input type="hidden" name="reference" value="'.$_GET['SelectedTag'].'">'; + <td><input type="text" size=30 maxlength=30 name="Description" value="'.$Description.'"></td><td> + <input type="hidden" name="reference" value="'.$_GET['SelectedTag'].'">'; -if (isset($_GET['Action']) and $_GET['Action']=='edit') { +if (isset($_GET['Action']) AND $_GET['Action']=='edit') { echo '<input type="submit" name=update value=' . _('Update') . '>'; } else { echo '<input type="submit" name=submit value=' . _('Insert') . '>'; @@ -50,21 +68,25 @@ echo '</form>'; -echo '<table class=selection>'; -echo '<tr><th>'. _('Tag ID') .'</th>'; -echo '<th>'. _('Description'). '</th>'; +echo '<table class="selection">'; +echo '<tr><th>'. _('Tag ID') .'</th> + <th>'. _('Description'). '</th> + </tr>'; $sql="SELECT tagref, tagdescription FROM tags order by tagref"; $result= DB_query($sql,$db); while ($myrow = DB_fetch_array($result,$db)){ - echo '<tr><td>'.$myrow[0].'</td><td>'.$myrow[1].'</td> - <td><a href="' . $_SERVER['PHP_SELF'] . '?SelectedTag=' . $myrow[0] . '&Action=edit">' . _('Edit') . '</a></td></tr>'; + echo '<tr><td>' . $myrow['tagref'].'</td> + <td>' . $myrow['tagdescription'].'</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?SelectedTag=' . $myrow['tagref'] . '&Action=edit">' . _('Edit') . '</a></td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?SelectedTag=' . $myrow['tagref'] . '&Action=delete">' . _('Delete') . '</a></td> + </tr>'; } echo '</table><p></p>'; -echo '<script>defaultControl(document.form.description);</script>'; +echo '<script>defaultControl(document.form.Description);</script>'; include('includes/footer.inc'); Modified: trunk/PDFBankingSummary.php =================================================================== --- trunk/PDFBankingSummary.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/PDFBankingSummary.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -25,7 +25,7 @@ $result=DB_query($sql, $db); echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"> - <table class=selection>'; + <table class="selection">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<tr><td>' . _('Select the batch number of receipts to be printed') . ':</td>'; echo '<td><select name="BatchNo">'; @@ -41,19 +41,19 @@ if (isset($_POST['BatchNo']) and $_POST['BatchNo']!='') { $SQL= "SELECT bankaccountname, - bankaccountnumber, - ref, - transdate, - banktranstype, - bankact, - banktrans.exrate, - banktrans.functionalexrate, - banktrans.currcode - FROM bankaccounts, - banktrans - WHERE bankaccounts.accountcode=banktrans.bankact - AND banktrans.transno='" . $_POST['BatchNo'] . "' - AND banktrans.type=12"; + bankaccountnumber, + ref, + transdate, + banktranstype, + bankact, + banktrans.exrate, + banktrans.functionalexrate, + banktrans.currcode + FROM bankaccounts, + banktrans + WHERE bankaccounts.accountcode=banktrans.bankact + AND banktrans.transno='" . $_POST['BatchNo'] . "' + AND banktrans.type=12"; $ErrMsg = _('An error occurred getting the header information about the receipt batch number') . ' ' . $_POST['BatchNo']; $DbgMsg = _('The SQL used to get the receipt header information that failed was'); @@ -79,14 +79,14 @@ $SQL = "SELECT debtorsmaster.name, - ovamount, - invtext, - reference - FROM debtorsmaster INNER JOIN debtortrans - ON debtorsmaster.debtorno=debtortrans.debtorno - WHERE debtortrans.transno='" . $_POST['BatchNo'] . "' - AND debtortrans.type=12"; - + ovamount, + invtext, + reference + FROM debtorsmaster INNER JOIN debtortrans + ON debtorsmaster.debtorno=debtortrans.debtorno + WHERE debtortrans.transno='" . $_POST['BatchNo'] . "' + AND debtortrans.type=12"; + $CustRecs=DB_query($SQL,$db,'','',false,false); if (DB_error_no($db)!=0){ $title = _('Create PDF Print-out For A Batch Of Receipts'); @@ -99,13 +99,13 @@ exit; } $SQL = "SELECT narrative, - amount - FROM gltrans - WHERE gltrans.typeno='" . $_POST['BatchNo'] . "' - AND gltrans.type=12 and gltrans.amount <0 - AND gltrans.account !='" . $myrow['bankact'] . "' - AND gltrans.account !='" . $_SESSION['CompanyRecord']['debtorsact'] . "'"; - + amount + FROM gltrans + WHERE gltrans.typeno='" . $_POST['BatchNo'] . "' + AND gltrans.type=12 and gltrans.amount <0 + AND gltrans.account !='" . $myrow['bankact'] . "' + AND gltrans.account !='" . $_SESSION['CompanyRecord']['debtorsact'] . "'"; + $GLRecs=DB_query($SQL,$db,'','',false,false); if (DB_error_no($db)!=0){ $title = _('Create PDF Print-out For A Batch Of Receipts'); Modified: trunk/PDFOrderStatus.php =================================================================== --- trunk/PDFOrderStatus.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/PDFOrderStatus.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -48,7 +48,7 @@ echo '<option selected value="All">' . _('Over All Categories') . '</option>'; while ($myrow=DB_fetch_array($result)){ - echo '<option value=' . $myrow['categoryid'] . '>' . $myrow['categorydescription'] . '</option>'; + echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription'] . '</option>'; } echo '</select></td></tr>'; Modified: trunk/PO_AuthorisationLevels.php =================================================================== --- trunk/PO_AuthorisationLevels.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/PO_AuthorisationLevels.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -28,28 +28,27 @@ $_POST['AuthLevel']=0; } $sql="SELECT COUNT(*) - FROM purchorderauth - WHERE userid='" . $_POST['UserID'] . "' - AND currabrev='" . $_POST['CurrCode'] . "'"; + FROM purchorderauth + WHERE userid='" . $_POST['UserID'] . "' + AND currabrev='" . $_POST['CurrCode'] . "'"; $result=DB_query($sql, $db); $myrow=DB_fetch_array($result); if ($myrow[0]==0) { $sql="INSERT INTO purchorderauth ( userid, - currabrev, - cancreate, - offhold, - authlevel) - VALUES( - '".$_POST['UserID']."', - '".$_POST['CurrCode']."', - '".$CanCreate."', - '".$OffHold."', - '".$_POST['AuthLevel']."')"; - $ErrMsg = _('The authentication details cannot be inserted because'); - $Result=DB_query($sql,$db,$ErrMsg); + currabrev, + cancreate, + offhold, + authlevel) + VALUES( '".$_POST['UserID']."', + '".$_POST['CurrCode']."', + '".$CanCreate."', + '".$OffHold."', + '".$_POST['AuthLevel']."')"; + $ErrMsg = _('The authentication details cannot be inserted because'); + $Result=DB_query($sql,$db,$ErrMsg); } else { prnMsg(_('There already exists an entry for this user/currency combination'), 'error'); - echo '<br />'; + echo '<br />'; } } @@ -136,16 +135,16 @@ $OffHold=_('No'); } echo '<tr><td>' . $myrow['userid'] . '</td> - <td>' . $myrow['realname'] . '</td> - <td>' . $myrow['currency'] . '</td> - <td>' . $CanCreate . '</td> - <td>' . $OffHold . '</td> - <td class="number">'.number_format($myrow['authlevel'],2).'</td> - <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Edit=Yes&UserID=' . $myrow['userid'] . - '&Currency='.$myrow['currabrev'].'">'._('Edit').'</td> - <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Delete=Yes&UserID=' . $myrow['userid'] . - '&Currency='.$myrow['currabrev'].'">'._('Delete').'</td> - </tr>'; + <td>' . $myrow['realname'] . '</td> + <td>' . $myrow['currency'] . '</td> + <td>' . $CanCreate . '</td> + <td>' . $OffHold . '</td> + <td class="number">'.number_format($myrow['authlevel'],2).'</td> + <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Edit=Yes&UserID=' . $myrow['userid'] . +'&Currency='.$myrow['currabrev'].'">'._('Edit').'</td> + <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Delete=Yes&UserID=' . $myrow['userid'] . +'&Currency='.$myrow['currabrev'].'">'._('Delete').'</td> + </tr>'; } echo '</table><br><br>'; @@ -176,7 +175,7 @@ $CurrencyResult=DB_query($CurrencySQL,$db); $myrow=DB_fetch_array($CurrencyResult); echo '<tr><td>'._('Currency').'</td> - <td>' . $myrow['currency'] . '</td></tr>'; + <td>' . $myrow['currency'] . '</td></tr>'; echo '<input type=hidden name="currabrev" value="'.$Currency.'"'; } else { echo '<tr><td>'._('Currency').'</td><td><select name="CurrCode">'; Modified: trunk/SecurityTokens.php =================================================================== --- trunk/SecurityTokens.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/SecurityTokens.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -80,7 +80,7 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="form">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<br><table><tr>'; +echo '<br /><table><tr>'; if (isset($_GET['Action']) and $_GET['Action']=='edit') { echo '<td>'. _('Description') . '</td> @@ -99,7 +99,7 @@ echo '<table class="selection">'; echo '<tr><th>'. _('Token ID') .'</th> - <th>'. _('Description'). '</th>'; + <th>'. _('Description'). '</th>'; $sql="SELECT tokenid, tokenname FROM securitytokens ORDER BY tokenid"; $Result= DB_query($sql,$db); Modified: trunk/Shipt_Select.php =================================================================== --- trunk/Shipt_Select.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/Shipt_Select.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -223,7 +223,7 @@ //figure out the SQL required from the inputs available - if (isset($ShiptRef) AND $ShiptRef !='') { + if (isset($ShiptRef) && $ShiptRef !="") { $SQL = "SELECT shipments.shiptref, vessel, voyageref, @@ -231,7 +231,7 @@ shipments.eta, shipments.closed FROM shipments INNER JOIN suppliers - ON shipments.supplierid = suppliers.supplierid + ON shipments.supplierid = suppliers.supplierid WHERE shipments.shiptref='". $ShiptRef . "'"; } else { $SQL = "SELECT DISTINCT shipments.shiptref, vessel, voyageref, suppliers.suppname, shipments.eta, shipments.closed @@ -250,17 +250,17 @@ AND purchorders.intostocklocation = '". $_POST['StockLocation'] . "' AND shipments.closed='" . $_POST['OpenOrClosed'] . "'"; } else { - $SQL .= " WHERE shipments.supplierid='" . $SelectedSupplier ."' + $SQL .= "WHERE shipments.supplierid='" . $SelectedSupplier ."' AND purchorders.intostocklocation = '". $_POST['StockLocation'] . "' AND shipments.closed='" . $_POST['OpenOrClosed'] ."'"; } } else { //no supplier selected if (isset($SelectedStockItem)) { - $SQL .= " WHERE purchorderdetails.itemcode='". $SelectedStockItem ."' + $SQL .= "WHERE purchorderdetails.itemcode='". $SelectedStockItem ."' AND purchorders.intostocklocation = '". $_POST['StockLocation'] . "' AND shipments.closed='" . $_POST['OpenOrClosed'] . "'"; } else { - $SQL .= " WHERE purchorders.intostocklocation = '". $_POST['StockLocation'] . "' + $SQL .= "WHERE purchorders.intostocklocation = '". $_POST['StockLocation'] . "' AND shipments.closed='" . $_POST['OpenOrClosed'] . "'"; } Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/Stocks.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -466,7 +466,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -475,7 +475,7 @@ echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM bom WHERE component='".$StockID."' GROUP BY component"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -483,7 +483,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='".$StockID."' GROUP BY stkcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -491,7 +491,7 @@ prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -499,7 +499,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."'"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='".$StockID."' GROUP BY itemcode"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -507,7 +507,7 @@ prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); echo '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."'"; + $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='".$StockID."' GROUP BY stockid"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]!=0) { Modified: trunk/SupplierAllocations.php =================================================================== --- trunk/SupplierAllocations.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/SupplierAllocations.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -294,21 +294,21 @@ $SQL= "SELECT systypes.typename, - supptrans.type, - supptrans.transno, - supptrans.trandate, - supptrans.supplierno, - suppliers.suppname, - rate, - (supptrans.ovamount+supptrans.ovgst) AS total, - supptrans.diffonexch, - supptrans.alloc - FROM supptrans, - systypes, - suppliers - WHERE supptrans.type = systypes.typeid - AND supptrans.supplierno = suppliers.supplierid - AND supptrans.id='" . $_SESSION['AllocTrans'] . "'"; + supptrans.type, + supptrans.transno, + supptrans.trandate, + supptrans.supplierno, + suppliers.suppname, + rate, + (supptrans.ovamount+supptrans.ovgst) AS total, + supptrans.diffonexch, + supptrans.alloc + FROM supptrans, + systypes, + suppliers + WHERE supptrans.type = systypes.typeid + AND supptrans.supplierno = suppliers.supplierid + AND supptrans.id='" . $_SESSION['AllocTrans'] . "'"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result) != 1){ @@ -336,21 +336,21 @@ /*First get the transactions that have outstanding balances ie Total-Alloc >0 */ $SQL= "SELECT supptrans.id, - typename, - transno, - trandate, - suppreference, - rate, - ovamount+ovgst AS total, - diffonexch, - alloc - FROM supptrans, - systypes - WHERE supptrans.type = systypes.typeid - AND supptrans.settled=0 - AND abs(ovamount+ovgst-alloc)>0.009 - AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; - + typename, + transno, + trandate, + suppreference, + rate, + ovamount+ovgst AS total, + diffonexch, + alloc + FROM supptrans, + systypes + WHERE supptrans.type = systypes.typeid + AND supptrans.settled=0 + AND abs(ovamount+ovgst-alloc)>0.009 + AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; + $ErrMsg = _('There was a problem retrieving the transactions available to allocate to'); $DbgMsg = _('The SQL that was used to retrieve the transaction information was'); @@ -359,41 +359,41 @@ while ($myrow=DB_fetch_array($Result)){ $_SESSION['Alloc']->add_to_AllocsAllocn ($myrow['id'], - $myrow['typename'], - $myrow['transno'], - ConvertSQLDate($myrow['trandate']), - $myrow['suppreference'], - 0, - $myrow['total'], - $myrow['rate'], - $myrow['diffonexch'], - $myrow['diffonexch'], - $myrow['alloc'], - 'NA'); - } + $myrow['typename'], + $myrow['transno'], + ConvertSQLDate($myrow['trandate']), + $myrow['suppreference'], + 0, + $myrow['total'], + $myrow['rate'], + $myrow['diffonexch'], + $myrow['diffonexch'], + $myrow['alloc'], + 'NA'); +} /* Now get trans that might have previously been allocated to by this trans NB existing entries where still some of the trans outstanding entered from above logic will be overwritten with the prev alloc detail below */ $SQL = "SELECT supptrans.id, - typename, - transno, - trandate, - suppreference, - rate, - ovamount+ovgst AS total, - diffonexch, - supptrans.alloc-suppallocs.amt AS prevallocs, - amt, - suppallocs.id AS allocid - FROM supptrans, - systypes, - suppallocs - WHERE supptrans.type = systypes.typeid - AND supptrans.id=suppallocs.transid_allocto - AND suppallocs.transid_allocfrom='" . $_SESSION['AllocTrans'] . - "' AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; + typename, + transno, + trandate, + suppreference, + rate, + ovamount+ovgst AS total, + diffonexch, + supptrans.alloc-suppallocs.amt AS prevallocs, + amt, + suppallocs.id AS allocid + FROM supptrans, + systypes, + suppallocs + WHERE supptrans.type = systypes.typeid + AND supptrans.id=suppallocs.transid_allocto + AND suppallocs.transid_allocfrom='" . $_SESSION['AllocTrans'] . + "' AND supplierno='" . $_SESSION['Alloc']->SupplierID . "'"; $ErrMsg = _('There was a problem retrieving the previously allocated transactions for modification'); @@ -405,14 +405,16 @@ $DiffOnExchThisOne = ($myrow['amt']/$myrow['rate']) - ($myrow['amt']/$_SESSION['Alloc']->TransExRate); - $_SESSION['Alloc']->add_to_AllocsAllocn ($myrow['id'], $myrow['typename'], $myrow['transno'], - ConvertSQLDate($myrow['trandate']), $myrow['suppreference'], $myrow['amt'], - $myrow['total'], - $myrow['rate'], - $DiffOnExchThisOne, - ($myrow['diffonexch'] - $DiffOnExchThisOne), - $myrow['prevallocs'], - $myrow['allocid']); + $_SESSION['Alloc']->add_to_AllocsAllocn ($myrow['id'], + $myrow['typename'], + $myrow['transno'], + ConvertSQLDate($myrow['trandate']), $myrow['suppreference'], $myrow['amt'], + $myrow['total'], + $myrow['rate'], + $DiffOnExchThisOne, + ($myrow['diffonexch'] - $DiffOnExchThisOne), + $myrow['prevallocs'], + $myrow['allocid']); } } @@ -444,12 +446,12 @@ echo '<table cellpadding=2 colspan=7 class=selection>'; $TableHeader = '<tr><th>' . _('Type') . '</th> - <th>' . _('Trans') . '<br />' . _('Number') . '</th> - <th>' . _('Trans') .'<br />' . _('Date') . '</th> - <th>' . _('Supp') . '<br />' . _('Ref') . '</th> - <th>' . _('Total') . '<br />' . _('Amount') .'</th> - <th>' . _('Yet to') . '<br />' . _('Allocate') . '</th> - <th>' . _('This') . '<br />' . _('Allocation') . '</th></tr>'; + <th>' . _('Trans') . '<br />' . _('Number') . '</th> + <th>' . _('Trans') .'<br />' . _('Date') . '</th> + <th>' . _('Supp') . '<br />' . _('Ref') . '</th> + <th>' . _('Total') . '<br />' . _('Amount') .'</th> + <th>' . _('Yet to') . '<br />' . _('Allocate') . '</th> + <th>' . _('This') . '<br />' . _('Allocation') . '</th></tr>'; $k = 0; $Counter = 0; $RowCounter = 0; @@ -481,11 +483,11 @@ $YetToAlloc = ($AllocnItem->TransAmount - $AllocnItem->PrevAlloc); echo '<td>' . $AllocnItem->TransType . '</td> - <td>' . $AllocnItem->TypeNo . '</td> - <td>' . $AllocnItem->TransDate . '</td> - <td>' . $AllocnItem->SuppRef . '</td> - <td class="number">' . number_format($AllocnItem->TransAmount,2) . '</td> - <td class="number">' . number_format($YetToAlloc,2) . '<input type="hidden" name="YetToAlloc' . + <td>' . $AllocnItem->TypeNo . '</td> + <td>' . $AllocnItem->TransDate . '</td> + <td>' . $AllocnItem->SuppRef . '</td> + <td class="number">' . number_format($AllocnItem->TransAmount,2) . '</td> + <td class="number">' . number_format($YetToAlloc,2) . '<input type="hidden" name="YetToAlloc' . $Counter . '" VALUE=' . $YetToAlloc . '></td>'; echo '<td class="number"><input type="checkbox" name="All' . $Counter . '"'; @@ -551,12 +553,12 @@ echo '<table class=selection>'; $TableHeader = '<tr><th>' . _('Trans Type') .'</th> - <th>' . _('Supplier') . '</th> - <th>' . _('Number') . '</th> - <th>' . _('Date') . '</th> - <th>' . _('Total') . '</th> - <th>' . _('To Alloc') . '</th> - </tr>\n'; + <th>' . _('Supplier') . '</th> + <th>' . _('Number') . '</th> + <th>' . _('Date') . '</th> + <th>' . _('Total') . '</th> + <th>' . _('To Alloc') . '</th> + </tr>\n'; echo $TableHeader; @@ -587,7 +589,7 @@ ConvertSQLDate($myrow['trandate']), $myrow['total'], $myrow['total']-$myrow['alloc'], - $_SERVER['PHP_SELF'] . "?" . SID, + $_SERVER['PHP_SELF'] . '?', $myrow['id']); } @@ -600,35 +602,35 @@ unset($_SESSION['Alloc']); $sql = "SELECT id, - transno, - typename, - type, - suppliers.supplierid, - suppname, - trandate, - suppreference, - rate, - ovamount+ovgst AS total, - alloc - FROM supptrans, - suppliers, - systypes - WHERE supptrans.type=systypes.typeid - AND supptrans.supplierno=suppliers.supplierid - AND (type=21 or type=22) - AND settled=0 ORDER BY id"; + transno, + typename, + type, + suppliers.supplierid, + suppname, + trandate, + suppreference, + rate, + ovamount+ovgst AS total, + alloc + FROM supptrans, + suppliers, + systypes + WHERE supptrans.type=systypes.typeid + AND supptrans.supplierno=suppliers.supplierid + AND (type=21 or type=22) + AND settled=0 ORDER BY id"; $result = DB_query($sql, $db); echo '<table class=selection>'; $TableHeader = '<tr><th>' . _('Trans Type') . '</th> - <th>' . _('Supplier') . '</th> - <th>' . _('Number') . '</th> - <th>' . _('Date') . '</th> - <th>' . _('Total') . '</th> - <th>' . _('To Alloc') . '</th> - <th>' . _('More Info') . '</th> - </tr>' ; + <th>' . _('Supplier') . '</th> + <th>' . _('Number') . '</th> + <th>' . _('Date') . '</th> + <th>' . _('Total') . '</th> + <th>' . _('To Alloc') . '</th> + <th>' . _('More Info') . '</th> + </tr>' ; echo $TableHeader; Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/UpgradeDatabase.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -98,6 +98,7 @@ case '3.10': $SQLScripts[] = './sql/mysql/upgrade3.10-3.11.sql'; case '3.11': + case '3.12.32': case '4.0RC1': case '4.01': case '4.02': @@ -195,4 +196,4 @@ } /*Dont do upgrade */ include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/Z_ImportStocks.php =================================================================== --- trunk/Z_ImportStocks.php 2011-05-07 00:24:37 UTC (rev 4562) +++ trunk/Z_ImportStocks.php 2011-05-11 09:59:44 UTC (rev 4563) @@ -1,308 +1,308 @@ -<?php -/* $Id: Z_ImportStocks.php 4043 2010-09-30 16:17:53Z tim_schofield $*/ -/* Script to make stock locations for all parts that do not have stock location records set up*/ - -//$PageSecurity = 15; -include('includes/session.inc'); -$title = _('Import Items'); -include('includes/header.inc'); - -// If this script is called with a file object, then the file contents are imported -// If this script is called with the gettemplate flag, then a template file is served -// Otherwise, a file upload form is displayed - -$headers = array( - 'StockID', // 0 'STOCKID', - 'Description', // 1 'DESCRIPTION', - 'LongDescription', // 2 'LONGDESCRIPTION', - 'CategoryID', // 3 'CATEGORYID', - 'Units', // 4 'UNITS', - 'MBFlag', // 5 'MBFLAG', - 'EOQ', // 6 'EOQ', - 'Discontinued', // 7 'DISCONTINUED', - 'Controlled', // 8 'CONTROLLED', - 'Serialised', // 9 'SERIALISED', - 'Perishable', // 10 'PERISHABLE', - 'Volume', // 11 'VOLUME', - 'KGS', // 12 'KGS', - 'BarCode', // 13 'BARCODE', - 'DiscountCategory', // 14 'DISCOUNTCATEGORY', - 'TaxCat', // 15 'TAXCAT', - 'DecimalPlaces', // 16 'DECIMALPLACES', - 'ItemPDF' // 17 'ITEMPDF' -); - -if ($_FILES['userfile']['name']) { //start file processing - - //initialize - $allowType='text/csv'; - $fieldTarget = 18; - $InputError = 0; - - //check file info - $fileName = $_FILES['userfile']['name']; - $tmpName = $_FILES['userfile']['tmp_name']; - $fileSize = $_FILES['userfile']['size']; - $fileType = $_FILES['userfile']['type']; - if ($fileType != $allowType) { - prnMsg (_('File has type '. $fileType. ', but only '. $allowType. ' is allowed.'),'error'); - include('includes/footer.inc'); - exit; - } - - //get file handle - $handle = fopen($tmpName, 'r'); - - //get the header row - $headRow = fgetcsv($handle, 10000, ","); - - //check for correct number of fields - if ( count($headRow) != count($headers) ) { - prnMsg (_('File contains '. count($headRow). ' columns, expected '. count($headers). '. Try downloading a new template.'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - - //test header row field name and sequence - $head = 0; - foreach ($headRow as $headField) { - if ( strtoupper($headField) != strtoupper($headers[$head]) ) { - prnMsg (_('File contains incorrect headers ('. strtoupper($headField). ' != '. strtoupper($header[$head]). '. Try downloading a new template.'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - $head++; - } - - //start database transaction - DB_Txn_Begin($db); - - //loop through file rows - $row = 1; - while ( ($myrow = fgetcsv($handle, 10000, ",")) !== FALSE ) { - - //check for correct number of fields - $fieldCount = count($myrow); - if ($fieldCount != $fieldTarget){ - prnMsg (_($fieldTarget. ' fields required, '. $fieldCount. ' fields received'),'error'); - fclose($handle); - include('includes/footer.inc'); - exit; - } - - // cleanup the data (csv files often import with empty strings and such) - $StockID = strtoupper($myrow[0]); - foreach ($myrow as &$value) { - $value = trim($value); - } - - //first off check if the item already exists - $sql = "SELECT COUNT(stockid) FROM stockmaster WHERE stockid='".$StockID."'"; - $result = DB_query($sql,$db); - $testrow = DB_fetch_row($result); - if ($testrow[0] != 0) { - $InputError = 1; - prnMsg (_('Stock item "'. $StockID. '" already exists'),'error'); - } - - //next validate inputs are sensible - if (!$myrow[1] or strlen($myrow[1]) > 50 OR strlen($myrow[1])==0) { - $InputError = 1; - prnMsg (_('The stock item description must be entered and be fifty characters or less long') . '. ' . _('It cannot be a zero length string either') . ' - ' . _('a description is required'). ' ("'. implode('","',$myrow). $stockid. '") ','error'); - } - if (strlen($myrow[2])==0) { - $InputError = 1; - prnMsg (_('The stock item description cannot be a zero length string') . ' - ' . _('a long description is required'),'error'); - } - if (strlen($StockID) ==0) { - $InputError = 1; - prnMsg (_('The Stock Item code cannot be empty'),'error'); - } - if (strstr($StockID,' ') OR strstr($StockID,"'") OR strstr($StockID,'+') OR strstr($StockID,"\\") OR strstr($StockID,"\"") OR strstr($StockID,'&') OR strstr($StockID,'"')) { - $InputError = 1; - prnMsg(_('The stock item code cannot contain any of the following characters') . " ' & + \" \\ " . _('or a space'). " (". $StockID. ")",'error'); - $StockID=''; - } - if (strlen($myrow[4]) >20) { - $InputError = 1; - prnMsg(_('The unit of measure must be 20 characters or less long'),'error'); - } - if (strlen($myrow[13]) >20) { - $InputError = 1; - prnMsg(_('The barcode must be 20 characters or less long'),'error'); - } - if ($myrow[10]!=0 AND $myrow[10]!=1) { - $InputError = 1; - prnMsg (_('Values in the Perishable field must be either 0 (No) or 1 (Yes)') ,'error'); - } - if (!is_numeric($myrow[11])) { - $InputError = 1; - prnMsg (_('The volume of the packaged item in cubic metres must be numeric') ,'error'); - } - if ($myrow[11] <0) { - $InputError = 1; - prnMsg(_('The volume of the packaged item must be a positive number'),'error'); - } - if (!is_numeric($myrow[12])) { - $InputError = 1; - prnMsg(_('The weight of the packaged item in KGs must be numeric'),'error'); - } - if ($myrow[12]<0) { - $InputError = 1; - prnMsg(_('The weight of the packaged item must be a positive number'),'error'); - } - if (!is_numeric($myrow[6])) { - $InputError = 1; - prnMsg(_('The economic order quantity must be numeric'),'error'); - } - if ($$myrow[6] <0) { - $InputError = 1; - prnMsg (_('The economic order quantity must be a positive number'),'error'); - } - if ($myrow[8]==0 AND $myrow[9]==1){ - $InputError = 1; - prnMsg(_('The item can only be serialised if there is lot control enabled already') . '. ' . _('Batch control') . ' - ' . _('with any number of items in a lot/bundle/roll is enabled when controlled is enabled') . '. ' . _('Serialised control requires that only one item is in the batch') . '. ' . _('For serialised control') . ', ' . _('both controlled and serialised must be enabled'),'error'); - } - - $mbflag = $myrow[5]; - if ($mbflag!='M' and $mbflag!='K' and $mbflag!='A' and $mbflag!='B' and $mbflag!='D' and $mbflag!='G') { - $InputError = 1; - prnMsg(_('Items must be of MBFlag type Manufactured(M), Assembly(A), Kit-Set(K), Purchased(B), Dummy(D) or Phantom(G)'),'error'); - } - if (($mbflag=='A' OR $mbflag=='K' OR $mbflag=='D' OR $mbflag=='G') AND $myrow[8]==1){ - $InputError = 1; - prnMsg(_('Assembly/Kitset/Phantom/Service items cannot also be controlled items') . '. ' . _('Assemblies, Dummies and Kitsets are not physical items and batch/serial control is therefore not appropriate'),'error'); - } - if ($myrow[3]==''){ - $InputError = 1; - prnMsg(_('There are no inventory categories defined. All inventory items must belong to a valid inventory category,'),'error'); - } - if ($myrow[17]==''){ - $InputError = 1; - prnMsg(_('ItemPDF must contain either a filename, or the keyword `none`'),'error'); - } - - if ($InputError !=1){ - if ($myrow[9]==1){ /*Not appropriate to have several dp on serial items */ - $myrow[16]=0; - } - - //attempt ... [truncated message content] |