From: <dai...@us...> - 2010-11-27 10:13:20
|
Revision: 4169 http://web-erp.svn.sourceforge.net/web-erp/?rev=4169&view=rev Author: daintree Date: 2010-11-27 10:13:11 +0000 (Sat, 27 Nov 2010) Log Message: ----------- fixed asset work Modified Paths: -------------- trunk/FixedAssetDepreciation.php trunk/FixedAssetItems.php trunk/GoodsReceived.php trunk/PO_Header.php trunk/PO_Items.php trunk/PO_SelectOSPurchOrder.php trunk/PurchData.php trunk/ReverseGRN.php trunk/SelectAsset.php trunk/StockCheck.php trunk/StockCostUpdate.php trunk/SuppCreditGRNs.php trunk/SuppInvGRNs.php trunk/SupplierCredit.php trunk/SupplierInvoice.php trunk/doc/Change.log.html trunk/includes/DateFunctions.inc trunk/includes/DefinePOClass.php trunk/includes/DefineSuppTransClass.php trunk/includes/PO_ReadInOrder.inc trunk/includes/SQL_CommonFunctions.inc trunk/install/index.php trunk/install/save.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php 2010-11-26 11:23:53 UTC (rev 4168) +++ trunk/FixedAssetDepreciation.php 2010-11-27 10:13:11 UTC (rev 4169) @@ -32,7 +32,6 @@ $AllowUserEnteredProcessDate = false; $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); } -$PeriodNo = GetPeriod($_POST['ProcessDate'],$db); /* Get list of assets for journal */ $sql='SELECT fixedassets.assetid, @@ -41,19 +40,20 @@ fixedassets.accumdepn, fixedassets.depntype, fixedassets.depnrate, - fixedassetcategories.accumdepnact AS bsdepn, - fixedassetcategories.depnact AS pldepn, + fixedassets.datepurchased, + fixedassetcategories.accumdepnact, + fixedassetcategories.depnact, fixedassetcategories.categorydescription FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid ORDER BY assetcategoryid, assetid'; -$result=DB_query($sql, $db); +$AssetsResult=DB_query($sql, $db); if (isset($_POST['CommitDepreciation'])){ $result = DB_Txn_Begin($db); $TransNo = GetNextTransNo(44, $db); - + $PeriodNo = GetPeriod($_POST['ProcessDate'],$db); } echo '<p></p><table>'; @@ -76,8 +76,8 @@ $RowCounter = 0; $k=0; -while ($myrow=DB_fetch_array($result)) { - if ($AssetCategoryDescription != $myrow['categorydescription'] OR $AssetCategoryDescription =='0'){ +while ($AssetRow=DB_fetch_array($AssetsResult)) { + if ($AssetCategoryDescription != $AssetRow['categorydescription'] OR $AssetCategoryDescription =='0'){ if ($AssetCategoryDescription !='0'){ //then print totals echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> <th class="number">' . number_format($TotalCategoryCost,2) . '</th> @@ -87,23 +87,27 @@ <th class="number">' . number_format($TotalCategoryDepn,2) . '</th> </tr>'; } - echo '<tr><th colspan=8 align="left">' . $myrow['categorydescription'] . '</th></tr>'; - $AssetCategoryDescription = $myrow['categorydescription']; + echo '<tr><th colspan=8 align="left">' . $AssetRow['categorydescription'] . '</th></tr>'; + $AssetCategoryDescription = $AssetRow['categorydescription']; $TotalCategoryCost = 0; $TotalCategoryAccumDepn =0; $TotalCategoryDepn = 0; } - $BookValueBfwd = $myrow['cost'] - $myrow['accumdepn']; - if ($myrow['depntype']==0){ //striaght line depreciation + $BookValueBfwd = $AssetRow['cost'] - $AssetRow['accumdepn']; + if ($AssetRow['depntype']==0){ //striaght line depreciation $DepreciationType = _('SL'); - $NewDepreciation = $myrow['cost'] * $myrow['depnrate']/100/12; + $NewDepreciation = $AssetRow['cost'] * $AssetRow['depnrate']/100/12; if ($NewDepreciation > $BookValueBfwd){ $NewDepreciation = $BookValueBfwd; } } else { //Diminishing value depreciation $DepreciationType = _('DV'); - $NewDepreciation = $BookValueBfwd * $myrow['depnrate']/100/12; + $NewDepreciation = $BookValueBfwd * $AssetRow['depnrate']/100/12; } + if (Date1GreaterThanDate2($AssetRow['datepurchased'],$_POST['ProcessDate'])){ + /*Over-ride calculations as the asset was not purchased at the date of the calculation!! */ + $NewDepreciation =0; + } $RowCounter++; if ($RowCounter ==15){ echo $Heading; @@ -116,23 +120,24 @@ echo '<tr class="OddTableRows">'; $k++; } - echo '<td>' . $myrow['assetid'] . '</td> - <td>' . $myrow['description'] . '</td> - <td class="number">' . number_format($myrow['cost'],2) . '</td> - <td class="number">' . number_format($myrow['accumdepn'],2) . '</td> - <td class="number">' . number_format($myrow['cost']-$myrow['accumdepn'],2) . '</td> + echo '<td>' . $AssetRow['assetid'] . '</td> + <td>' . $AssetRow['description'] . '</td> + <td class="number">' . number_format($AssetRow['cost'],2) . '</td> + <td class="number">' . number_format($AssetRow['accumdepn'],2) . '</td> + <td class="number">' . number_format($AssetRow['cost']-$AssetRow['accumdepn'],2) . '</td> <td align="center">' . $DepreciationType . '</td> - <td class="number">' . $myrow['depnrate'] . '</td> - <td class="number">' . $NewDepreciation . '</td> + <td class="number">' . $AssetRow['depnrate'] . '</td> + <td class="number">' . number_format($NewDepreciation ,2) . '</td> </tr>'; - $TotalCategoryCost +=$myrow['cost']; - $TotalCategoryAccumDepn +=$myrow['accumdepn']; + $TotalCategoryCost +=$AssetRow['cost']; + $TotalCategoryAccumDepn +=$AssetRow['accumdepn']; $TotalCategoryDepn +=$NewDepreciation; - $TotalCost +=$myrow['cost']; - $TotalAccumDepn +=$myrow['accumdepn']; + $TotalCost +=$AssetRow['cost']; + $TotalAccumDepn +=$AssetRow['accumdepn']; $TotalDepn +=$NewDepreciation; if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0){ + //debit depreciation expense $SQL = "INSERT INTO gltrans (type, typeno, @@ -145,8 +150,8 @@ '" . $TransNo . "', '" . FormatDateForSQL($_POST['ProcessDate']) . "', '" . $PeriodNo . "', - '" . $myrow['depnact'] . "', - '" . $myrow['assetid'] . "', + '" . $AssetRow['depnact'] . "', + '" . $AssetRow['assetid'] . "', '" . $NewDepreciation ."')"; $ErrMsg = _('Cannot insert a depreciation GL entry for the depreciation because'); $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); @@ -162,8 +167,8 @@ '" . $TransNo . "', '" . FormatDateForSQL($_POST['ProcessDate']) . "', '" . $PeriodNo . "', - '" . $myrow['accumdepnact'] . "', - '" . $myrow['assetid'] . "', + '" . $AssetRow['accumdepnact'] . "', + '" . $AssetRow['assetid'] . "', '" . -$NewDepreciation ."')"; $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -176,7 +181,7 @@ inputdate, cost, depn) - VALUES ('" . $myrow['assetid'] . "', + VALUES ('" . $AssetRow['assetid'] . "', '44', '" . $TransNo . "', '" . FormatDateForSQL($_POST['ProcessDate']) . "', @@ -187,6 +192,13 @@ $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + /*now update the accum depn in fixedassets */ + $SQL = "UPDATE fixedassets SET accumdepn = accumdepn + " . $NewDepreciation . " + WHERE assetid = '" . $AssetRow['assetid'] . "'"; + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset accumulated depreciation could not be updated:'); + $DbgMsg = _('The following SQL was used to attempt the update the accumulated depreciation of the asset was:'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); } //end if Committing the depreciation to DB } //end loop around the assets to calculate depreciation for echo '<tr><th colspan=2 align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th> Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-26 11:23:53 UTC (rev 4168) +++ trunk/FixedAssetItems.php 2010-11-27 10:13:11 UTC (rev 4169) @@ -107,13 +107,8 @@ $Errors[$i] = 'DepnRate'; $i++; } - if (!Is_Date($_POST['DatePurchased'])){ - $InputError = 1; - prnMsg(_('The date that the asset was purchased must be entered in the format') . ' ' . $SESSION['DefaultDateFormat'],'error'); - $Errors[$i] = 'DatePurchased'; - $i++; - } + if ($InputError !=1){ if ($_POST['submit']==_('Update')) { /*so its an existing one */ @@ -219,7 +214,6 @@ description='" . $_POST['Description'] . "', assetcategoryid='" . $_POST['AssetCategoryID'] . "', assetlocation='" . $_POST['AssetLocation'] . "', - datepurchased='" . FormatDateForSQL($_POST['DatePurchased']) . "', depntype='" . $_POST['DepnType'] . "', depnrate='" . $_POST['DepnRate'] . "', barcode='" . $_POST['BarCode'] . "', @@ -238,7 +232,6 @@ longdescription, assetcategoryid, assetlocation, - datepurchased, depntype, depnrate, barcode, @@ -248,7 +241,6 @@ '" . $_POST['LongDescription'] . "', '" . $_POST['AssetCategoryID'] . "', '" . $_POST['AssetLocation'] . "', - '" . FormatDateForSQL($_POST['DatePurchased']) . "', '" . $_POST['DepnType'] . "', '" . $_POST['DepnRate']. "', '" . $_POST['BarCode'] . "', @@ -264,7 +256,6 @@ unset($_POST['Description']); // unset($_POST['AssetCategoryID']); // unset($_POST['AssetLocation']); - unset($_POST['DatePurchased']); // unset($_POST['DepnType']); // unset($_POST['DepnRate']); unset($_POST['BarCode']); @@ -282,17 +273,29 @@ $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); + $result = DB_query('SELECT cost, + 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) { $CancelDelete =1; //cannot delete assets where NBV is not 0 + prnMsg(_('The asset still has a net book value - only assets with a zero net book value can be deleted'),'error'); } $result = DB_query('SELECT * FROM fixedassettrans WHERE assetid="' . $AssetID . '"',$db); if (DB_num_rows($result) > 0){ $CancelDelete =1; /*cannot delete assets with transactions */ + prnMsg(_('The asset has transactions associated with it. The asset can only be deleted when the fixed asset transactions are purged, otherwise the integrity of fixed asset reports may be compromised'),'error'); } - + $result = DB_query('SELECT * FROM purchorderdetails WHERE assetid="' . $AssetID . '"',$db); + if (DB_num_rows($result) > 0){ + $CancelDelete =1; /*cannot delete assets where there is a purchase order set up for it */ + prnMsg(_('There is a purchase order set up for this asset. The purchase order line must be deleted first'),'error'); + } if ($CancelDelete==0) { $result = DB_Txn_Begin($db); @@ -302,40 +305,40 @@ if ($AssetRow['cost'] > 0){ //credit cost for the asset deleted $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) "; - $SQL= $SQL . "VALUES (43, - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $AssetRow['costact'] . "', - '" . _('Delete asset') . ' ' . $AssetID . "', - '" . -$AssetRow['cost']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "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) "; - $SQL= $SQL . "VALUES (43, - '" . $TransNo . "', - '" . Date('Y-m-d') . "', - '" . $PeriodNo . "', - '" . $AssetRow['accumdepnact'] . "', - '" . _('Delete asset') . ' ' . $AssetID . "', - '" . $Asset['accumdepn']. "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) "; + $SQL= $SQL . "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); @@ -353,7 +356,6 @@ unset($_POST['Description']); unset($_POST['AssetCategoryID']); unset($_POST['AssetLocation']); - unset($_POST['DatePurchased']); unset($_POST['DepnType']); unset($_POST['DepnRate']); unset($_POST['BarCode']); @@ -386,22 +388,23 @@ assetlocation, datepurchased, depntype, - depnrate + depnrate, + cost, + accumdepn FROM fixedassets WHERE assetid ='" . $AssetID . "'"; $result = DB_query($sql, $db); - $myrow = DB_fetch_array($result); + $AssetRow = DB_fetch_array($result); - $_POST['LongDescription'] = $myrow['longdescription']; - $_POST['Description'] = $myrow['description']; - $_POST['AssetCategoryID'] = $myrow['assetcategoryid']; - $_POST['SerialNo'] = $myrow['serialno']; - $_POST['AssetLocation'] = $myrow['assetlocation']; - $_POST['DatePurchased'] = ConvertSQLDate($myrow['DatePurchased']); - $_POST['DepnType'] = $myrow['depntype']; - $_POST['BarCode'] = $myrow['barcode']; - $_POST['DepnRate'] = $myrow['depnrate']; + $_POST['LongDescription'] = $AssetRow['longdescription']; + $_POST['Description'] = $AssetRow['description']; + $_POST['AssetCategoryID'] = $AssetRow['assetcategoryid']; + $_POST['SerialNo'] = $AssetRow['serialno']; + $_POST['AssetLocation'] = $AssetRow['assetlocation']; + $_POST['DepnType'] = $AssetRow['depntype']; + $_POST['BarCode'] = $AssetRow['barcode']; + $_POST['DepnRate'] = $AssetRow['depnrate']; echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; @@ -475,13 +478,10 @@ $_POST['AssetCategoryID']=$category; } -if ($_POST['DatePurchased']==''){ - $_POST['DatePurchased'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); +if ($AssetRow['datepurchased']!='0000-00-00'){ + echo '<tr><td>' . _('Date Purchased') . ':</td><td>' . ConvertSQLDate($AssetRow['datepurchased']) . '</td></tr>'; } -echo '<tr><td>' . _('Date Purchased') . ':</td><td><input ' . (in_array('DatePurchased',$Errors) ? 'class="inputerror"' : 'class="date"' ) . ' alt="' .$_SESSION['DefaultDateFormat'] . '" type="Text" name="DatePurchased" size=12 maxlength=10 value="' . $_POST['DatePurchased '] . '"></td></tr>'; - - $sql = 'SELECT locationid, locationdescription FROM fixedassetlocations'; $ErrMsg = _('The asset locations could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve asset locations and failed was'); @@ -518,9 +518,26 @@ echo '</select></td></tr>'; echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=3 maxlength=3 value="' . $_POST['DepnRate'] . '"></td></tr>'; - echo '</table>'; +/*Get the last period depreciation (depn is transtype =44) was posted for */ +echo '<table><tr><th colspan=2>' . _('Asset Financial Summary') . '</th></tr>'; + +echo '<tr><td>' . _('Accumulated Costs') . ':</td><td class="number">' . number_format($AssetRow['cost'],2) . '</td></tr>'; +echo '<tr><td>' . _('Accumulated Depreciation') . ':</td><td class="number">' . number_format($AssetRow['accumdepn'],2) . '</td></tr>'; +echo '<tr><td>' . _('Net Book Value') . ':</td><td class="number">' . number_format($AssetRow['cost']-$AssetRow['accumdepn'],2) . '</td></tr>'; + +$result = DB_query('SELECT periods.lastdate_in_period, max(fixedassettrans.periodno) FROM fixedassettrans INNER JOIN periods ON fixedassettrans.periodno=periods.periodno WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); +$LastDepnRun = DB_fetch_row($result); +if(DB_num_rows($result)==0){ + $LastRunDate = _('Not Yet Run'); +} else { + $LastRunDate = ConvertSQLDate($LastDepnRun[0]); +} +echo '<tr><td>' . _('Depreciation last run') . ':</td><td>' . $LastRunDate . '</td></tr> + </table>'; + + if ($New==1) { echo '<div class=centre><br><input type="Submit" name="submit" value="' . _('Insert New Fixed Asset') . '">'; Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-26 11:23:53 UTC (rev 4168) +++ trunk/GoodsReceived.php 2010-11-27 10:13:11 UTC (rev 4169) @@ -93,7 +93,7 @@ </tr>'; /*show the line items on the order with the quantity being received for modification */ - $_SESSION['PO']->total = 0; + $_SESSION['PO']->Total = 0; } $k=0; //row colour counter @@ -120,33 +120,33 @@ //Setup & Format values for LineItem display $LineTotal = ($LnItm->ReceiveQty * $LnItm->Price ); - $_SESSION['PO']->total = $_SESSION['PO']->total + $LineTotal; + $_SESSION['PO']->Total = $_SESSION['PO']->Total + $LineTotal; $DisplayQtyOrd = number_format($LnItm->Quantity,$LnItm->DecimalPlaces); $DisplayQtyRec = number_format($LnItm->QtyReceived,$LnItm->DecimalPlaces); $DisplayLineTotal = number_format($LineTotal,2); $DisplayPrice = number_format($LnItm->Price,2); - $UomSQL="SELECT unitsofmeasure.unitname, - conversionfactor, - suppliersuom, - max(effectivefrom) - FROM purchdata - LEFT JOIN unitsofmeasure - ON purchdata.suppliersuom=unitsofmeasure.unitid - WHERE supplierno='".$_SESSION['PO']->SupplierID."' - AND stockid='".$LnItm->StockID."' - GROUP BY unitsofmeasure.unitname"; - - $UomResult=DB_query($UomSQL, $db); - if (DB_num_rows($UomResult)>0) { - $UomRow=DB_fetch_array($UomResult); - if (strlen($UomRow['unitname'])>0) { - $Uom=$UomRow['unitname']; + $SupplierUomSQL="SELECT unitsofmeasure.unitname, + conversionfactor, + suppliersuom, + max(effectivefrom) + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno='".$_SESSION['PO']->SupplierID."' + AND stockid='".$LnItm->StockID."' + GROUP BY unitsofmeasure.unitname"; + + $SupplierUOMResult=DB_query($SupplierUomSQL, $db); + if (DB_num_rows($SupplierUOMResult)>0) { + $SupplierUOMRow=DB_fetch_array($SupplierUOMResult); + if (strlen($SupplierUOMRow['unitname'])>0) { + $Uom=$SupplierUOMRow['unitname']; } else { $Uom=$LnItm->Units; } - $ConversionFactor=$UomRow['conversionfactor']; - } else { + $ConversionFactor=$SupplierUOMRow['conversionfactor']; + } else { //using our units throughout $Uom=$LnItm->Units; $ConversionFactor=1; } @@ -185,7 +185,7 @@ echo '</tr>'; }//foreach(LineItem) echo "<script>defaultControl(document.forms[0].RecvQty_$LnItm->LineNo);</script>"; -$DisplayTotal = number_format($_SESSION['PO']->total,2); +$DisplayTotal = number_format($_SESSION['PO']->Total,2); if ($_SESSION['ShowValueOnGRN']==1) { echo '<tr><td colspan=7 class=number><b>' . _('Total value of goods received'). '</b></td> <td class=number><b>'. $DisplayTotal. '</b></td> @@ -342,9 +342,8 @@ DB_free_result($Result); +/* *********************** BEGIN SQL TRANSACTIONS *********************** */ -/************************ BEGIN SQL TRANSACTIONS ************************/ - $Result = DB_Txn_Begin($db); /*Now Get the next GRN - function in SQL_CommonFunctions*/ $GRN = GetNextTransNo(25, $db); @@ -357,7 +356,6 @@ if ($OrderLine->ReceiveQty !=0 AND $OrderLine->ReceiveQty!='' AND isset($OrderLine->ReceiveQty)) { $LocalCurrencyPrice = ($OrderLine->Price / $_SESSION['PO']->ExRate); -/*Update SalesOrderDetails for the new quantity received and the standard cost used for postings to GL and recorded in the stock movements for FIFO/LIFO stocks valuations*/ if ($OrderLine->StockID!='') { /*Its a stock item line */ /*Need to get the current standard cost as it is now so we can process GL jorunals later*/ @@ -380,7 +378,7 @@ costs received = the total of standard cost posted to GRN suspense*/ $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost = (($CurrentStandardCost * $OrderLine->ReceiveQty) + ($_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost *$OrderLine->QtyReceived)) / ($OrderLine->ReceiveQty + $OrderLine->QtyReceived); - } elseif ($OrderLine->QtyReceived==0 AND $OrderLine->StockID=="") { + } elseif ($OrderLine->QtyReceived==0 AND $OrderLine->StockID=='') { /*Its a nominal item being received */ /*Need to record the value of the order per unit in the standard cost field to ensure GRN account entries clear */ $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost = $LocalCurrencyPrice; @@ -394,16 +392,16 @@ if ($OrderLine->ReceiveQty >= ($OrderLine->Quantity - $OrderLine->QtyReceived)){ $SQL = "UPDATE purchorderdetails SET - quantityrecd = quantityrecd + '" . $OrderLine->ReceiveQty . "', - stdcostunit='" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', - completed=1 - WHERE podetailitem = '" . $OrderLine->PODetailRec . "'"; + quantityrecd = quantityrecd + '" . $OrderLine->ReceiveQty . "', + stdcostunit='" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', + completed=1 + WHERE podetailitem = '" . $OrderLine->PODetailRec . "'"; } else { $SQL = "UPDATE purchorderdetails SET - quantityrecd = quantityrecd + '" . $OrderLine->ReceiveQty . "', - stdcostunit='" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', - completed=0 - WHERE podetailitem = '" . $OrderLine->PODetailRec . "'"; + quantityrecd = quantityrecd + '" . $OrderLine->ReceiveQty . "', + stdcostunit='" . $_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost . "', + completed=0 + WHERE podetailitem = '" . $OrderLine->PODetailRec . "'"; } $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase order detail record could not be updated with the quantity received because'); @@ -434,7 +432,7 @@ '" . $_POST['DefaultReceivedDate'] . "', '" . $OrderLine->ReceiveQty . "', '" . $_SESSION['PO']->SupplierID . "', - '" . $CurrentStandardCost *$OrderLine->ConversionFactor. "')"; + '" . $CurrentStandardCost . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('A GRN record could not be inserted') . '. ' . _('This receipt of goods has not been processed because'); $DbgMsg = _('The following SQL to insert the GRN record was used'); @@ -459,19 +457,6 @@ $QtyOnHandPrior = 0; } - $sql="SELECT conversionfactor - FROM purchdata - WHERE supplierno='".$_SESSION['PO']->SupplierID."' - AND stockid='".$OrderLine->StockID."'"; - $result=DB_query($sql, $db); - if (DB_num_rows($result)>0) { - $myrow=DB_fetch_array($result); - $ConversionFactor=$myrow['conversionfactor']; - } else { - $ConversionFactor=1; - } - $OrderLine->ReceiveQty=$OrderLine->ReceiveQty*$ConversionFactor; - $SQL = "UPDATE locstock SET quantity = locstock.quantity + '" . $OrderLine->ReceiveQty . "' WHERE locstock.stockid = '" . $OrderLine->StockID . "' @@ -481,9 +466,8 @@ $DbgMsg = _('The following SQL to update the location stock record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); + /* Insert stock movements - with unit cost */ - /* ... Insert stock movements - with unit cost */ - $SQL = "INSERT INTO stockmoves (stockid, type, transno, @@ -501,7 +485,7 @@ '" . $GRN . "', '" . $_SESSION['PO']->Location . "', '" . $_POST['DefaultReceivedDate'] . "', - '" . $LocalCurrencyPrice / $ConversionFactor . "', + '" . $LocalCurrencyPrice . "', '" . $PeriodNo . "', '" . $_SESSION['PO']->SupplierID . " (" . $_SESSION['PO']->SupplierName . ") - " .$_SESSION['PO']->OrderNo . "', '" . $OrderLine->ReceiveQty . "', @@ -562,15 +546,15 @@ /** now insert the serial stock movement **/ $SQL = "INSERT INTO stockserialmoves (stockmoveno, - stockid, - serialno, - moveqty) - VALUES ( - '" . $StkMoveNo . "', - '" . $OrderLine->StockID . "', - '" . $Item->BundleRef . "', - '" . $Item->BundleQty . "' - )"; + stockid, + serialno, + moveqty) + VALUES ( + '" . $StkMoveNo . "', + '" . $OrderLine->StockID . "', + '" . $Item->BundleRef . "', + '" . $Item->BundleQty . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -580,10 +564,12 @@ } /*end of its a stock item - updates to locations and insert movements*/ /* Check to see if the line item was flagged as the purchase of an asset */ - if ($OrderLine->AssetID !=''){ //then it is an asset + if ($OrderLine->AssetID !='' AND $OrderLine->AssetID !='0'){ //then it is an asset /*first validate the AssetID and if it doesn't exist treat it like a normal nominal item */ - $CheckAssetExistsResult = DB_query("SELECT assetid, costact + $CheckAssetExistsResult = DB_query("SELECT assetid, + datepurchased, + costact FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid WHERE assetid='" . $OrderLine->AssetID . "'",$db); @@ -592,12 +578,13 @@ /*Need to add a fixedassettrans for the cost of the asset being received */ $SQL = "INSERT INTO fixedassettrans (assetid, transtype, - typeno, + transno, transdate, periodno, inputdate, cost) - VALUES (25, + VALUES ('" . $OrderLine->AssetID . "', + 25, '" . $GRN . "', '" . $_POST['DefaultReceivedDate'] . "', '" . $PeriodNo . "', @@ -611,6 +598,19 @@ $AssetRow = DB_fetch_array($CheckAssetExistsResult); /*Over-ride any GL account specified in the order with the asset category cost account */ $_SESSION['PO']->LineItems[$OrderLine->LineNo]->GLCode = $AssetRow['costact']; + /*Now if there are no previous additions to this asset update the date purchased */ + if ($AssetRow['datepurchased']=='0000-00-00'){ + $SQL = "UPDATE fixedassets SET datepurchased='" . $_POST['DefaultReceivedDate'] . "', + cost = cost + " . ($CurrentStandardCost * $OrderLine->ReceiveQty) . " + WHERE assetid = '" . $OrderLine->AssetID . "'"; + } else { + $SQL = "UPDATE fixedassets SET cost = cost + " . ($CurrentStandardCost * $OrderLine->ReceiveQty) . " + WHERE assetid = '" . $OrderLine->AssetID . "'"; + } + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost and date purchased was not able to be updated because:'); + $DbgMsg = _('The following SQL was used to attempt the update of the cost and the date the asset was purchased'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + } //assetid provided doesn't exist so ignore it and treat as a normal nominal item } //assetid is set so the nominal item is an asset /* If GLLink_Stock then insert GLTrans to debit the GL Code and credit GRN Suspense account at standard cost*/ Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-11-26 11:23:53 UTC (rev 4168) +++ trunk/PO_Header.php 2010-11-27 10:13:11 UTC (rev 4169) @@ -73,10 +73,10 @@ $OK_to_updstat = 1; $OldStatus=$_SESSION['PO'.$identifier]->Stat; $NewStatus=$_POST['Stat']; - $emailsql='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; - $emailresult=DB_query($emailsql, $db); - $emailrow=DB_fetch_array($emailresult); - $date = date($_SESSION['DefaultDateFormat']); + $EmailSQL='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; + $EmailResult=DB_query($EmailSQL, $db); + $EmailRow=DB_fetch_array($EmailResult); + if ($OldStatus!=$NewStatus) { /* assume this in the first instance */ $authsql="SELECT authlevel @@ -94,7 +94,7 @@ if ($NewStatus == PurchOrder::STATUS_AUTHORISED) { if ($AuthorityLevel>$OrderTotal) { - $StatusComment=$date.' - Authorised by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + $StatusComment= date($_SESSION['DefaultDateFormat']).' - Authorised by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; $_SESSION['PO'.$identifier]->StatComments=$StatusComment; $_SESSION['PO'.$identifier]->Stat=$NewStatus; @@ -110,7 +110,7 @@ if ($NewStatus == PurchOrder::STATUS_CANCELLED and $OK_to_updstat==1) { if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { - $StatusComment=$date.' - Cancelled by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + $StatusComment=date($_SESSION['DefaultDateFormat']).' - Cancelled by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; $_SESSION['PO'.$identifier]->StatComments=$StatusComment; $_SESSION['PO'.$identifier]->Stat=$NewStatus; @@ -125,7 +125,7 @@ if ($NewStatus == PurchOrder::STATUS_REJECTED and $OK_to_updstat==1) { if ($AuthorityLevel>$OrderTotal) { - $StatusComment=$date.' - Rejected by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + $StatusComment=date($_SESSION['DefaultDateFormat']).' - Rejected by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; $_SESSION['PO'.$identifier]->StatComments=$StatusComment; $_SESSION['PO'.$identifier]->Stat=$NewStatus; @@ -140,7 +140,7 @@ if ($NewStatus == PurchOrder::STATUS_PENDING and $OK_to_updstat==1) { if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { - $StatusComment=$date.' - Returned to Pending status by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + $StatusComment=date($_SESSION['DefaultDateFormat']).' - Returned to Pending status by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; $_SESSION['PO'.$identifier]->StatComments=$StatusComment; $_SESSION['PO'.$identifier]->Stat=$NewStatus; @@ -166,18 +166,14 @@ } else { $AllowPrint=0; } - $SQL = "UPDATE purchorders SET - status='" . $_POST['Stat']. "', - stat_comment='" . $StatusComment ."', - allowprint='".$AllowPrint."' - WHERE purchorders.orderno ='" . $_SESSION['ExistingOrder'] ."'"; + $SQL = "UPDATE purchorders SET status='" . $_POST['Stat']. "', + stat_comment='" . $StatusComment ."', + allowprint='".$AllowPrint."' + WHERE purchorders.orderno ='" . $_SESSION['ExistingOrder'] ."'"; $ErrMsg = _('The order status could not be updated because'); - $DelResult=DB_query($SQL,$db,$ErrMsg); + $UpdateResult=DB_query($SQL,$db,$ErrMsg); -// $SQL = 'DELETE FROM purchorders WHERE purchorders.orderno=' . $_SESSION['ExistingOrder']; -// $ErrMsg = _('The order header could not be deleted because'); -// $DelResult=DB_query($SQL,$db,$ErrMsg); } else { // Re-Direct to right place prnMsg( _('This is a new order. It must be created before you can change the status'), 'warn'); @@ -186,20 +182,14 @@ } } -/** -* 2008-08-19 ToPu at WAT -* add extra functionality: -* enter a purchase order with the item's stockid and maintained -* suppliers (in purchdata) form the screen "Search Inventory Items" -* of SelectProduct.php -*/ + if (isset($_GET['NewOrder']) and isset($_GET['StockID']) and isset($_GET['SelectedSupplier'])) { /* - * initialize a new order + * initialise a new order */ $_SESSION['ExistingOrder']=0; unset($_SESSION['PO'.$identifier]); - /* initialize new class object */ + /* initialise new class object */ $_SESSION['PO'.$identifier] = new PurchOrder; /** * and fill it with essential data @@ -209,15 +199,13 @@ $_SESSION['PO'.$identifier]->GLLink = $_SESSION['CompanyRecord']['gllink_stock']; /* set the SupplierID we got */ $_SESSION['PO'.$identifier]->SupplierID = $_GET['SelectedSupplier']; - /**/ $_SESSION['RequireSupplierSelection'] = 0; - /**/ $_POST['Select'] = $_GET['SelectedSupplier']; - /** - * the item (its item code) that should be purchased + /* + * the item (it's item code) that should be purchased */ - $purch_item = $_GET['StockID']; + $Purch_Item = $_GET['StockID']; } @@ -233,33 +221,33 @@ $_SESSION['PO'.$identifier]->DelAdd4 = $_POST['DelAdd4']; $_SESSION['PO'.$identifier]->DelAdd5 = $_POST['DelAdd5']; $_SESSION['PO'.$identifier]->DelAdd6 = $_POST['DelAdd6']; - $_SESSION['PO'.$identifier]->suppDelAdd1 = $_POST['suppDelAdd1']; - $_SESSION['PO'.$identifier]->suppDelAdd2 = $_POST['suppDelAdd2']; - $_SESSION['PO'.$identifier]->suppDelAdd3 = $_POST['suppDelAdd3']; - $_SESSION['PO'.$identifier]->suppDelAdd4 = $_POST['suppDelAdd4']; - $_SESSION['PO'.$identifier]->suppDelAdd5 = $_POST['suppDelAdd5']; - $_SESSION['PO'.$identifier]->supptel= $_POST['supptel']; + $_SESSION['PO'.$identifier]->SuppDelAdd1 = $_POST['SuppDelAdd1']; + $_SESSION['PO'.$identifier]->SuppDelAdd2 = $_POST['SuppDelAdd2']; + $_SESSION['PO'.$identifier]->SuppDelAdd3 = $_POST['SuppDelAdd3']; + $_SESSION['PO'.$identifier]->SuppDelAdd4 = $_POST['SuppDelAdd4']; + $_SESSION['PO'.$identifier]->SuppDelAdd5 = $_POST['SuppDelAdd5']; + $_SESSION['PO'.$identifier]->SuppTel= $_POST['SuppTel']; $_SESSION['PO'.$identifier]->Initiator = $_POST['Initiator']; $_SESSION['PO'.$identifier]->RequisitionNo = $_POST['Requisition']; - $_SESSION['PO'.$identifier]->version = $_POST['version']; - $_SESSION['PO'.$identifier]->deliverydate = $_POST['deliverydate']; - $_SESSION['PO'.$identifier]->revised = $_POST['revised']; + $_SESSION['PO'.$identifier]->Version = $_POST['Version']; + $_SESSION['PO'.$identifier]->DeliveryDate = $_POST['DeliveryDate']; + $_SESSION['PO'.$identifier]->Revised = $_POST['Revised']; $_SESSION['PO'.$identifier]->ExRate = $_POST['ExRate']; $_SESSION['PO'.$identifier]->Comments = $_POST['Comments']; - $_SESSION['PO'.$identifier]->deliveryby = $_POST['deliveryby']; + $_SESSION['PO'.$identifier]->DeliveryBy = $_POST['DeliveryBy']; $_SESSION['PO'.$identifier]->StatusMessage = $_POST['StatComments']; - $_SESSION['PO'.$identifier]->paymentterms = $_POST['paymentterms']; - $_SESSION['PO'.$identifier]->contact = $_POST['Contact']; - $_SESSION['PO'.$identifier]->tel = $_POST['tel']; - $_SESSION['PO'.$identifier]->port = $_POST['port']; + $_SESSION['PO'.$identifier]->PaymentTerms = $_POST['PaymentTerms']; + $_SESSION['PO'.$identifier]->Contact = $_POST['Contact']; + $_SESSION['PO'.$identifier]->Tel = $_POST['Tel']; + $_SESSION['PO'.$identifier]->Port = $_POST['Port']; if (isset($_POST['RePrint']) and $_POST['RePrint']==1){ $_SESSION['PO'.$identifier]->AllowPrintPO=1; $sql = "UPDATE purchorders - SET purchorders.allowprint=1 - WHERE purchorders.orderno='" . $_SESSION['PO'.$identifier]->OrderNo ."'"; + SET purchorders.allowprint=1 + WHERE purchorders.orderno='" . $_SESSION['PO'.$identifier]->OrderNo ."'"; $ErrMsg = _('An error occurred updating the purchase order to allow reprints') . '. ' . _('The error says'); $updateResult = DB_query($sql,$db,$ErrMsg); @@ -306,11 +294,11 @@ } if ($OK_to_delete==1){ - $emailsql="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; - $emailresult=DB_query($emailsql, $db); - $emailrow=DB_fetch_array($emailresult); + $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; + $EmailResult=DB_query($EmailSQL, $db); + $EmailRow=DB_fetch_array($EmailResult); $StatusComment=date($_SESSION['DefaultDateFormat']). - ' - Order Cancelled by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['statcommentscomplete']; + ' - Order Cancelled by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['statcommentscomplete']; unset($_SESSION['PO'.$identifier]->LineItems); unset($_SESSION['PO'.$identifier]); $_SESSION['PO'.$identifier] = new PurchOrder; @@ -375,13 +363,12 @@ * (see below)*/ if ($_SESSION['PO'.$identifier]->Stat == PurchOrder::STATUS_PENDING and $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator) { if ($_SESSION['PO'.$identifier]->Any_Already_Received()==0){ - $emailsql='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; - $emailresult=DB_query($emailsql, $db); - $emailrow=DB_fetch_array($emailresult); - $date = date($_SESSION['DefaultDateFormat']); + $EmailSQL='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; + $EmailResult=DB_query($EmailSQL, $db); + $EmailRow=DB_fetch_array($EmailResult); $_SESSION['RequireSupplierSelection']=1; $_SESSION['PO'.$identifier]->Stat = PurchOrder::STATUS_PENDING; - $StatusComment=$date.' - Supplier changed by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + $StatusComment=date($_SESSION['DefaultDateFormat']).' - Supplier changed by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. '</a> - '.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; $_SESSION['PO'.$identifier]->StatComments=$StatusComment; } else { @@ -456,19 +443,19 @@ $_POST['SupplierName']=$_SESSION['PO'.$identifier]->SupplierName; $_POST['CurrCode'] = $_SESSION['PO'.$identifier]->CurrCode; $_POST['ExRate'] = $_SESSION['PO'.$identifier]->ExRate; - $_POST['paymentterms'] = $_SESSION['PO'.$identifier]->paymentterms; + $_POST['PaymentTerms'] = $_SESSION['PO'.$identifier]->PaymentTerms; $_POST['DelAdd1']=$_SESSION['PO'.$identifier]->DelAdd1; $_POST['DelAdd2']=$_SESSION['PO'.$identifier]->DelAdd2; $_POST['DelAdd3']=$_SESSION['PO'.$identifier]->DelAdd3; $_POST['DelAdd4']=$_SESSION['PO'.$identifier]->DelAdd4; $_POST['DelAdd5']=$_SESSION['PO'.$identifier]->DelAdd5; $_POST['DelAdd6']=$_SESSION['PO'.$identifier]->DelAdd6; - $_POST['suppDelAdd1']=$_SESSION['PO'.$identifier]->suppDelAdd1; - $_POST['suppDelAdd2']=$_SESSION['PO'.$identifier]->suppDelAdd2; - $_POST['suppDelAdd3']=$_SESSION['PO'.$identifier]->suppDelAdd3; - $_POST['suppDelAdd4']=$_SESSION['PO'.$identifier]->suppDelAdd4; - $_POST['suppDelAdd5']=$_SESSION['PO'.$identifier]->suppDelAdd5; - $_POST['suppDelAdd6']=$_SESSION['PO'.$identifier]->suppDelAdd6; + $_POST['SuppDelAdd1']=$_SESSION['PO'.$identifier]->SuppDelAdd1; + $_POST['SuppDelAdd2']=$_SESSION['PO'.$identifier]->SuppDelAdd2; + $_POST['SuppDelAdd3']=$_SESSION['PO'.$identifier]->SuppDelAdd3; + $_POST['SuppDelAdd4']=$_SESSION['PO'.$identifier]->SuppDelAdd4; + $_POST['SuppDelAdd5']=$_SESSION['PO'.$identifier]->SuppDelAdd5; + $_POST['SuppDelAdd6']=$_SESSION['PO'.$identifier]->SuppDelAdd6; } @@ -517,30 +504,30 @@ $_POST['SupplierName'] = $myrow[0]; $_POST['CurrCode'] = $myrow[1]; $_POST['ExRate'] = $myrow[2]; - $_POST['paymentterms']= $myrow[3]; - $_POST['suppDelAdd1'] = $myrow[4]; - $_POST['suppDelAdd2'] = $myrow[5]; - $_POST['suppDelAdd3'] = $myrow[6]; - $_POST['suppDelAdd4'] = $myrow[7]; - $_POST['suppDelAdd5'] = $myrow[8]; - $_POST['suppDelAdd6'] = $myrow[9]; - $_POST['supptel'] = $myrow[10]; - $_POST['port'] = $myrow[11]; + $_POST['PaymentTerms']= $myrow[3]; + $_POST['SuppDelAdd1'] = $myrow[4]; + $_POST['SuppDelAdd2'] = $myrow[5]; + $_POST['SuppDelAdd3'] = $myrow[6]; + $_POST['SuppDelAdd4'] = $myrow[7]; + $_POST['SuppDelAdd5'] = $myrow[8]; + $_POST['SuppDelAdd6'] = $myrow[9]; + $_POST['SuppTel'] = $myrow[10]; + $_POST['Port'] = $myrow[11]; $_SESSION['PO'.$identifier]->SupplierID = $_POST['Select']; $_SESSION['RequireSupplierSelection'] = 0; $_SESSION['PO'.$identifier]->SupplierName = $_POST['SupplierName']; $_SESSION['PO'.$identifier]->CurrCode = $_POST['CurrCode']; $_SESSION['PO'.$identifier]->ExRate = $_POST['ExRate']; - $_SESSION['PO'.$identifier]->paymentterms = $_POST['paymentterms']; - $_SESSION['PO'.$identifier]->suppDelAdd1 = $_POST['suppDelAdd1']; - $_SESSION['PO'.$identifier]->suppDelAdd2 = $_POST['suppDelAdd2']; - $_SESSION['PO'.$identifier]->suppDelAdd3 = $_POST['suppDelAdd3']; - $_SESSION['PO'.$identifier]->suppDelAdd4 = $_POST['suppDelAdd4']; - $_SESSION['PO'.$identifier]->suppDelAdd5 = $_POST['suppDelAdd5']; - $_SESSION['PO'.$identifier]->suppDelAdd6 = $_POST['suppDelAdd6']; - $_SESSION['PO'.$identifier]->supptel = $_POST['supptel']; - $_SESSION['PO'.$identifier]->port = $_POST['port']; + $_SESSION['PO'.$identifier]->PaymentTerms = $_POST['PaymentTerms']; + $_SESSION['PO'.$identifier]->SuppDelAdd1 = $_POST['SuppDelAdd1']; + $_SESSION['PO'.$identifier]->SuppDelAdd2 = $_POST['SuppDelAdd2']; + $_SESSION['PO'.$identifier]->SuppDelAdd3 = $_POST['SuppDelAdd3']; + $_SESSION['PO'.$identifier]->SuppDelAdd4 = $_POST['SuppDelAdd4']; + $_SESSION['PO'.$identifier]->SuppDelAdd5 = $_POST['SuppDelAdd5']; + $_SESSION['PO'.$identifier]->SuppDelAdd6 = $_POST['SuppDelAdd6']; + $_SESSION['PO'.$identifier]->SuppTel = $_POST['SuppTel']; + $_SESSION['PO'.$identifier]->Port = $_POST['Port']; } else { prnMsg( _('You do not have the authority to raise Purchase Orders for '). $SupplierName.'. '._('Please Consult your system administrator for more information').'. ' @@ -581,30 +568,30 @@ if (!isset($_SESSION['PO'.$identifier])) { $_POST['SupplierName'] = $myrow[0]; $_POST['CurrCode'] = $myrow[1]; - $_POST['paymentterms']= $myrow[2]; - $_POST['suppDelAdd1'] = $myrow[3]; - $_POST['suppDelAdd2'] = $myrow[4]; - $_POST['suppDelAdd3'] = $myrow[5]; - $_POST['suppDelAdd4'] = $myrow[6]; - $_POST['suppDelAdd5'] = $myrow[7]; - $_POST['suppDelAdd6'] = $myrow[8]; - $_POST['supptel'] = $myrow[9]; - $_POST['port'] = $myrow[10]; + $_POST['PaymentTerms']= $myrow[2]; + $_POST['SuppDelAdd1'] = $myrow[3]; + $_POST['SuppDelAdd2'] = $myrow[4]; + $_POST['SuppDelAdd3'] = $myrow[5]; + $_POST['SuppDelAdd4'] = $myrow[6]; + $_POST['SuppDelAdd5'] = $myrow[7]; + $_POST['SuppDelAdd6'] = $myrow[8]; + $_POST['SuppTel'] = $myrow[9]; + $_POST['Port'] = $myrow[10]; $_SESSION['PO'.$identifier]->SupplierID = $_POST['Select']; $_SESSION['RequireSupplierSelection'] = 0; $_SESSION['PO'.$identifier]->SupplierName = $_POST['SupplierName']; $_SESSION['PO'.$identifier]->CurrCode = $_POST['CurrCode']; $_SESSION['PO'.$identifier]->ExRate = $_POST['ExRate']; - $_SESSION['PO'.$identifier]->paymentterms = $_POST['paymentterms']; - $_SESSION['PO'.$identifier]->suppDelAdd1 = $_POST['suppDelAdd1']; - $_SESSION['PO'.$identifier]->suppDelAdd2 = $_POST['suppDelAdd2']; - $_SESSION['PO'.$identifier]->suppDelAdd3 = $_POST['suppDelAdd3']; - $_SESSION['PO'.$identifier]->suppDelAdd4 = $_POST['suppDelAdd4']; - $_SESSION['PO'.$identifier]->suppDelAdd5 = $_POST['suppDelAdd5']; - $_SESSION['PO'.$identifier]->suppDelAdd6 = $_POST['suppDelAdd6']; - $_SESSION['PO'.$identifier]->supptel = $_POST['supptel']; - $_SESSION['PO'.$identifier]->port = $_POST['port']; + $_SESSION['PO'.$identifier]->PaymentTerms = $_POST['PaymentTerms']; + $_SESSION['PO'.$identifier]->SuppDelAdd1 = $_POST['SuppDelAdd1']; + $_SESSION['PO'.$identifier]->SuppDelAdd2 = $_POST['SuppDelAdd2']; + $_SESSION['PO'.$identifier]->SuppDelAdd3 = $_POST['SuppDelAdd3']; + $_SESSION['PO'.$identifier]->SuppDelAdd4 = $_POST['SuppDelAdd4']; + $_SESSION['PO'.$identifier]->SuppDelAdd5 = $_POST['SuppDelAdd5']; + $_SESSION['PO'.$identifier]->SuppDelAdd6 = $_POST['SuppDelAdd6']; + $_SESSION['PO'.$identifier]->SuppTel = $_POST['SuppTel']; + $_SESSION['PO'.$identifier]->Port = $_POST['Port']; // end of added for suppliers lookup fields } } @@ -637,8 +624,6 @@ echo '<script type="text/javascript">defaultControl(document.forms[0].Keywords);</script>'; -// UPDATED BY HUDSON 30/6/2008 - if (isset($result_SuppSelect)) { echo '<br><table cellpadding=3 colspan=7 class=selection>'; @@ -705,21 +690,18 @@ } -/* 2008-08-19 ToPu -- debugging purpose */ - if (isset($purch_item)) { - prnMsg(_('Purchase Item(s) with this code') . ': ' . $purch_item,'info'); + if (isset($Purch_Item)) { + prnMsg(_('Purchase Item(s) with this code') . ': ' . $Purch_Item,'info'); /** - * 2008-08-21 ToPu * Now go ahead to PO_Items.php - * with NewItem=$purch_item + * with NewItem=$Purch_Item */ - /* a somewhat nice outfit for that link */ echo "<div class='centre'>"; echo '<br><table class="table_index"><tr><td class="menu_group_item">'; /* the link */ - echo '<li><a href="'.$rootpath.'/PO_Items.php?' . SID . 'NewItem=' . $purch_item . "&identifier=".$identifier. '">' . + echo '<li><a href="'.$rootpath.'/PO_Items.php?' . SID . 'NewItem=' . $Purch_Item . "&identifier=".$identifier. '">' . _('Enter Line Item to this purchase order') . '</a></li>'; /**/ echo "</td></tr></table></div><br>"; @@ -730,68 +712,58 @@ $Qty=1; } - $sql="SELECT - controlled, - serialised, - description, - units , - decimalplaces - FROM stockmaster - WHERE stockid='".$purch_item."'"; - $result=DB_query($sql, $db); - $stockmasterrow=DB_fetch_array($result); + $sql="SELECT stockmaster.controlled, + stockmaster.serialised, + stockmaster.description, + stockmaster.units , + stockmaster.decimalplaces, + purchdata.price, + purchdata.suppliersuom, + purchdata.suppliers_partno, + purchdata.conversionfactor, + stockcategory.stockact + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + LEFT JOIN purchdata + ON stockmaster.stockid = purchdata.stockid + WHERE stockmaster.stockid='".$Purch_Item. "' + AND purchdata.supplierno ='" . $_GET['SelectedSupplier'] . "'"; + $Result=DB_query($sql, $db); + $PurchItemRow=DB_fetch_array($result); - $sql="SELECT - price, - suppliersuom, - suppliers_partno, - conversionfactor - FROM purchdata - WHERE supplierno='".$_GET['SelectedSupplier'] ."' - AND stockid='".$purch_item ."'"; - $result=DB_query($sql, $db); - $purchdatarow=DB_fetch_array($result); - if (!isset($purchdatarow['conversionfactor'])) { - $purchdatarow['conversionfactor']=1; + if (!isset($PurchItemRow['conversionfactor'])) { + $PurchItemRow['conversionfactor']=1; } - $sql="SELECT - stockact - FROM stockcategory - LEFT JOIN stockmaster ON stockmaster.categoryid=stockcategory.categoryid - WHERE stockid='".$purch_item. "'"; - $result=DB_query($sql, $db); - $categoryrow=DB_fetch_array($result); - - $_SESSION['PO'.$identifier]->add_to_order( - 1, - $purch_item, - $stockmasterrow['serialised'], - $stockmasterrow['controlled'], - $Qty, - $stockmasterrow['description'], - $purchdatarow['price'], - $stockmasterrow['units'], - $categoryrow['stockact'], - date($_SESSION['DefaultDateFormat']), - 0, - 0, - '', - 0, - 0, - '', - $stockmasterrow['decimalplaces'], - $purch_item, - $purchdatarow['suppliersuom'], - $purchdatarow['conversionfactor'], - $purchdatarow['suppliers_partno'], - $Qty*$purchdatarow['price'], - '', - 0, - 0, - 0, - 0, - $Qty, - $Qty*$purchdatarow['price']); + + $_SESSION['PO'.$identifier]->add_to_order( 1, + $Purch_Item, + $PurchItemRow['serialised'], + $PurchItemRow['controlled'], + $Qty, + $PurchItemRow['description'], + $PurchItemRow['price'], + $PurchItemRow['units'], + $PurchItemRow['stockact'], + date($_SESSION['DefaultDateFormat']), + 0, + 0, + '', + 0, + 0, + '', + $PurchItemRow['decimalplaces'], + $Purch_Item, + $PurchItemRow['suppliersuom'], + $PurchItemRow['conversionfactor'], + $PurchItemRow['suppliers_partno'], + $Qty*$PurchItemRow['price'], + '', + 0, + 0, + 0, + 0, + $Qty, + $Qty*$PurchItemRow['price']); echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/PO_Items.php?' . SID . 'identifier='.$identifier. "'>"; } @@ -812,13 +784,13 @@ $_POST['DelAdd6']=$_SESSION['PO'.$identifier]->DelAdd6; $_POST['Initiator']=$_SESSION['PO'.$identifier]->Initiator; $_POST['Requisition']=$_SESSION['PO'.$identifier]->RequisitionNo; - $_POST['version']=$_SESSION['PO'.$identifier]->version; - $_POST['deliverydate']=$_SESSION['PO'.$identifier]->deliverydate; - $_POST['revised']=$_SESSION['PO'.$identifier]->revised; + $_POST['Version']=$_SESSION['PO'.$identifier]->Version; + $_POST['DeliveryDate']=$_SESSION['PO'.$identifier]->DeliveryDate; + $_POST['Revised']=$_SESSION['PO'.$identifier]->Revised; $_POST['ExRate']=$_SESSION['PO'.$identifier]->ExRate; $_POST['Comments']=$_SESSION['PO'.$identifier]->Comments; - $_POST['deliveryby']=$_SESSION['PO'.$identifier]->deliveryby; - $_POST['paymentterms']=$_SESSION['PO'.$identifier]->paymentterms; + $_POST['DeliveryBy']=$_SESSION['PO'.$identifier]->DeliveryBy; + $_POST['PaymentTerms']=$_SESSION['PO'.$identifier]->PaymentTerms; } // move apart by Hudson @@ -839,28 +811,26 @@ } echo '</td></tr>'; - $date = date($_SESSION['DefaultDateFormat']); - if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != '') { - $_SESSION['PO'.$identifier]->version += 1; - $_POST['version'] = $_SESSION['PO'.$identifier]->version; - } elseif (isset($_SESSION['PO'.$identifier]->version) and $_SESSION['PO'.$identifier]->version != '') { - $_POST['version'] = $_SESSION['PO'.$identifier]->version; + $_SESSION['PO'.$identifier]->Version += 1; + $_POST['Version'] = $_SESSION['PO'.$identifier]->Version; + } elseif (isset($_SESSION['PO'.$identifier]->Version) and $_SESSION['PO'.$identifier]->Version != '') { + $_POST['Version'] = $_SESSION['PO'.$identifier]->Version; } else { - $_POST['version']='1'; + $_POST['Version']='1'; } - if (!isset($_POST['deliverydate'])) { - $_POST['deliverydate']= date($_SESSION['DefaultDateFormat']); + if (!isset($_POST['DeliveryDate'])) { + $_POST['DeliveryDate']= date($_SESSION['DefaultDateFormat']); } - echo '<tr><td>' . _('Version'). ' #' . ":</td><td><input type='hidden' name='version' size=16 maxlength=15 - value='" . $_POST['version'] . "'>".$_POST['version']."</td></tr>"; - echo '<tr><td>' . _('Revised') . ":</td><td><input type='hidden' name='revised' size=11 maxlength=15 value=" . - $date . '>'.$date.'</td></tr>'; + echo '<tr><td>' . _('Version'). ' #' . ":</td><td><input type='hidden' name='Version' size=16 maxlength=15 + value='" . $_POST['Version'] . "'>".$_POST['Version']."</td></tr>"; + echo '<tr><td>' . _('Revised') . ":</td><td><input type='hidden' name='Revised' size=11 maxlength=15 value=" . + date($_SESSION['DefaultDateFormat']) . '>'. date($_SESSION['DefaultDateFormat']).'</td></tr>'; echo '<tr><td>' . _('Delivery Date') . ":</td><td><input type='text' class=date alt='".$_SESSION['DefaultDateFormat']. - "' name='deliverydate' size=11 value=" . $_POST['deliverydate'] . '>'."</td></tr>"; + "' name='DeliveryDate' size=11 value=" . $_POST['DeliveryDate'] . '>'."</td></tr>"; if (!isset($_POST['Initiator'])) { $_POST['Initiator'] = $_SESSION['UserID']; @@ -1019,7 +989,7 @@ $_POST['DelAdd4'] = $LocnRow[3]; $_POST['DelAdd5'] = $LocnRow[4]; $_POST['DelAdd6'] = $LocnRow[5]; - $_POST['tel'] = $LocnRow[6]; + $_POST['Tel'] = $LocnRow[6]; $_POST['Contact'] = $LocnRow[7]; $_SESSION['PO'.$identifier]->Location= $_POST['StkLocation']; @@ -1030,8 +1000,8 @@ $_SESSION['PO'.$identifier]->DelAdd4 = $_POST['DelAdd4']; $_SESSION['PO'.$identifier]->DelAdd5 = $_POST['DelAdd5']; $_SESSION['PO'.$identifier]->DelAdd6 = $_POST['DelAdd6']; - $_SESSION['PO'.$identifier]->tel = $_POST['tel']; - $_SESSION['PO'.$identifier]->contact = $_POST['Contact']; + $_SESSION['PO'.$identifier]->Tel = $_POST['Tel']; + $_SESSION['PO'.$identifier]->Contact = $_POST['Contact']; } else { /*The default location of the user is crook */ @@ -1062,7 +1032,7 @@ $_POST['DelAdd4'] = $LocnRow[3]; $_POST['DelAdd5'] = $LocnRow[4]; $_POST['DelAdd6'] = $LocnRow[5]; - $_POST['tel'] = $LocnRow[6]; + $_POST['Tel'] = $LocnRow[6]; $_POST['Contact'] = $LocnRow[7]; $_SESSION['PO'.$identifier]->Location= $_POST['StkLocation']; @@ -1072,14 +1042,14 @@ $_SESSION['PO'.$identifier]->DelAdd4 = $_POST['DelAdd4']; $_SESSION['PO'.$identifier]->DelAdd5 = $_POST['DelAdd5']; $_SESSION['PO'.$identifier]->DelAdd6 = $_POST['DelAdd6']; - $_SESSION['PO'.$identifier]->tel = $_POST['tel']; - $_SESSION['PO'.$identifier]->contact = $_POST['Contact']; + $_SESSION['PO'.$identifier]->Tel = $_POST['Tel']; + $_SESSION['PO'.$identifier]->Contact = $_POST['Contact']; } } echo '<tr><td>' . _('Delivery Contact') . ":</td> - <td><input type='text' name=Contact size=41 value='" . $_SESSION['PO'.$identifier]->contact . "'></td> + <td><input type='text' name=Contact size=41 value='" . $_SESSION['PO'.$identifier]->Contact . "'></td> </tr>"; echo '<tr><td>' . _('Address') . " 1 :</td> <td><input type='text' name=DelAdd1 size=41 maxlength=40 value='" . $_POST['DelAdd1'] . "'></td> @@ -1100,16 +1070,16 @@ <td><input type='text' name=DelAdd6 size=16 maxlength=15 value='" . $_POST['DelAdd6'] . "'></td> </tr>"; echo '<tr><td>' . _('Phone') . ":</td> - <td><input type='text' name=tel size=31 maxlength=30 value='" . $_SESSION['PO'.$identifier]->tel . "'></td> + <td><input type='text' name=Tel size=31 maxlength=30 value='" . $_SESSION['PO'.$identifier]->Tel . "'></td> </tr>"; - echo '<tr><td>' . _('Delivery By') . ':</td><td><select name=deliveryby>'; + echo '<tr><td>' . _('Delivery By') . ':</td><td><select name=DeliveryBy>'; $sql = "SELECT shipper_id, shippername FROM shippers"; $shipperResult = DB_query($sql,$db); while ($shipperRow=DB_fetch_array($shipperResult)){ - if (isset($_POST['deliveryby']) and ($_POST['deliveryby'] == $shipperRow['shipper_id'])) { + if (isset($_POST['DeliveryBy']) and ($_POST['DeliveryBy'] == $shipperRow['shipper_id'])) { echo "<option selected value='" . $shipperRow['shipper_id'] . "'>" . $shipperRow['shippername']; } else { echo "<option value='" . $shipperRow['shipper_id'] . "'>" . $shipperRow['shippername']; @@ -1160,30 +1130,30 @@ echo '</td></tr>'; echo '<tr><td>' . _('Address') . " 1 :</td> - </td><td><input type='text' name=suppDelAdd1 size=41 maxlength=40 value='" . $_POST['suppDelAdd1'] . "'></td> + </td><td><input type='text' name=SuppDelAdd1 size=41 maxlength=40 value='" . $_POST['SuppDelAdd1'] . "'></td> </tr>"; echo '<tr><td>' . _('Address') . " 2 :</td> - </td><td><input type='text' name=suppDelAdd2 size=41 maxlength=40 value='" . $_POST['suppDelAdd2'] . "'></td> + </td><td><input type='text' name=SuppDelAdd2 size=41 maxlength=40 value='" . $_POST['SuppDelAdd2'] . "'></td> </tr>"; echo '<tr><td>' . _('Address') . " 3 :</td> - </td><td><input type='text' name=suppDelAdd3 size=41 maxlength=40 value='" . $_POST['suppDelAdd3'] . "'></td> + </td><td><input type='text' name=SuppDelAdd3 size=41 maxlength=40 value='" . $_POST['SuppDelAdd3'] . "'></td> </tr>"; echo '<tr><td>' . _('Address') . " 4 :</td> - </td><td><input type='text' name=suppDelAdd5 size=21 maxlength=20 value='" . $_POST['suppDelAdd5'] . "'></td> + </td><td><input type='text' name=SuppDelAdd5 size=21 maxlength=20 value='" . $_POST['SuppDelAdd5'] . "'></td> </tr>"; echo '<tr><td>' . _('Address') . " 5 :</td> - </td><td><input type='text' name=suppDelAdd4 size=41 maxlength=40 value='" . $_POST['suppDelAdd4'] . "'></td> + </td><td><input type='text' name=SuppDelAdd4 size=41 maxlength=40 value='" . $_POST['SuppDelAdd4'] . "'></td> </tr>"; echo '<tr><td>' . _('Phone') . ": - </td><td><input type='text' name=supptel size=31 maxlength=30 value='" . $_SESSION['PO'.$identifier]->supptel . "'></td> + </td><td><input type='text' name=SuppTel size=31 maxlength=30 value='" . $_SESSION['PO'.$identifier]->SuppTel . "'></td> </tr>"; $result=DB_query("SELECT terms, termsindicator FROM paymentterms", $db); - echo '<tr><td>' . _('Payment Terms') . ":</td><td><select name='paymentterms'>"; + echo '<tr><td>' . _('Payment Terms') . ":</td><td><select name='PaymentTerms'>"; while ($myr... [truncated message content] |
From: <dai...@us...> - 2010-11-28 06:37:22
|
Revision: 4170 http://web-erp.svn.sourceforge.net/web-erp/?rev=4170&view=rev Author: daintree Date: 2010-11-28 06:37:13 +0000 (Sun, 28 Nov 2010) Log Message: ----------- whole lotta fixed asset stuff Modified Paths: -------------- trunk/FixedAssetDepreciation.php trunk/FixedAssetItems.php trunk/FixedAssetRegister.php trunk/FixedAssetTransfer.php trunk/PO_Items.php trunk/SupplierCredit.php trunk/SupplierInvoice.php trunk/doc/Change.log.html trunk/includes/ConnectDB_mysql.inc trunk/includes/ConnectDB_mysqli.inc trunk/includes/DefineSuppTransClass.php trunk/javascripts/MiscFunctions.js trunk/sql/mysql/upgrade3.11.1-4.00.sql Added Paths: ----------- trunk/SuppFixedAssetChgs.php Modified: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/FixedAssetDepreciation.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -36,17 +36,28 @@ /* Get list of assets for journal */ $sql='SELECT fixedassets.assetid, fixedassets.description, - fixedassets.cost, - fixedassets.accumdepn, fixedassets.depntype, fixedassets.depnrate, fixedassets.datepurchased, fixedassetcategories.accumdepnact, fixedassetcategories.depnact, - fixedassetcategories.categorydescription + fixedassetcategories.categorydescription, + SUM(fixedassettrans.cost) AS costtotal, + SUM(fixedassettrans.depn) AS depnbfwd FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + INNER JOIN fixedassettrans + ON fixedassets.assetid=fixedassettrans.assetid + WHERE fixedassettrans.transdate<="' . FormatDateForSQL($_POST['ProcessDate']) . '" + GROUP BY fixedassets.assetid, + fixedassets.description, + fixedassets.depntype, + fixedassets.depnrate, + fixedassets.datepurchased, + fixedassetcategories.accumdepnact, + fixedassetcategories.depnact, + fixedassetcategories.categorydescription ORDER BY assetcategoryid, assetid'; $AssetsResult=DB_query($sql, $db); @@ -93,10 +104,10 @@ $TotalCategoryAccumDepn =0; $TotalCategoryDepn = 0; } - $BookValueBfwd = $AssetRow['cost'] - $AssetRow['accumdepn']; + $BookValueBfwd = $AssetRow['costtotal'] - $AssetRow['depnbfwd']; if ($AssetRow['depntype']==0){ //striaght line depreciation $DepreciationType = _('SL'); - $NewDepreciation = $AssetRow['cost'] * $AssetRow['depnrate']/100/12; + $NewDepreciation = $AssetRow['costtotal'] * $AssetRow['depnrate']/100/12; if ($NewDepreciation > $BookValueBfwd){ $NewDepreciation = $BookValueBfwd; } Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/FixedAssetItems.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -39,7 +39,7 @@ } elseif ( $_FILES['ItemPicture']['size'] > ($_SESSION['MaxImageSize']*1024)) { //File Size Check prnMsg(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $_SESSION['MaxImageSize'],'warn'); $UploadTheFile ='No'; - } elseif ( $_FILES['ItemPicture']['type'] == "text/plain" ) { //File Type Check + } elseif ( $_FILES['ItemPicture']['type'] == 'text/plain' ) { //File Type Check prnMsg( _('Only graphics files can be uploaded'),'warn'); $UploadTheFile ='No'; } elseif (file_exists($filename)){ @@ -251,7 +251,8 @@ $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); if (DB_error_no($db) ==0) { - prnMsg( _('The new asset has been added to the database'),'success'); + $NewAssetID = DB_Last_Insert_ID($db,'fixedassets', 'assetid'); + prnMsg( _('The new asset has been added to the database with an asset code of:') . ' ' . $NewAssetID,'success'); unset($_POST['LongDescription']); unset($_POST['Description']); // unset($_POST['AssetCategoryID']); @@ -301,7 +302,7 @@ /*Need to remove cost and accumulate depreciation from cost and accumdepn accounts */ $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); - $TransNo = GetNextTransNo( 43, $db); /* transaction type is asset deletion - (and remove cost/accumdepn from GL) */ + $TransNo = GetNextTransNo( 43, $db); /* transaction type is asset deletion - (and remove cost/acc5umdepn from GL) */ if ($AssetRow['cost'] > 0){ //credit cost for the asset deleted $SQL = "INSERT INTO gltrans (type, @@ -478,7 +479,7 @@ $_POST['AssetCategoryID']=$category; } -if ($AssetRow['datepurchased']!='0000-00-00'){ +if ($AssetRow['datepurchased']!='0000-00-00' AND $AssetRow['datepurchased']!=''){ echo '<tr><td>' . _('Date Purchased') . ':</td><td>' . ConvertSQLDate($AssetRow['datepurchased']) . '</td></tr>'; } @@ -517,7 +518,7 @@ echo '</select></td></tr>'; -echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=3 maxlength=3 value="' . $_POST['DepnRate'] . '"></td></tr>'; +echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=4 maxlength=4 value="' . $_POST['DepnRate'] . '"></td></tr>'; echo '</table>'; /*Get the last period depreciation (depn is transtype =44) was posted for */ Modified: trunk/FixedAssetRegister.php =================================================================== --- trunk/FixedAssetRegister.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/FixedAssetRegister.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -2,13 +2,6 @@ $PageSecurity = 11; include ('includes/session.inc'); $title = _('Fixed Asset Register'); -$TotalCost = 0; -$Totaldepn = 0; -$TotaldepnInt = 0; -$Totaldisp = 0; -$TotaldepInt = 0; -$TotalNBV = 0; -$TotalNBVInt = 0; $csv_output = ''; // Reports being generated in HTML, PDF and CSV/EXCEL format if (isset($_POST['submit']) or isset($_POST['pdf']) or isset($_POST['csv'])) { @@ -19,160 +12,203 @@ include ('includes/header.inc'); echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title; } - $dateFrom = FormatDateForSQL($_POST['fromDate']); - $dateTo = FormatDateForSQL($_POST['toDate']); - $sql = 'SELECT assetmanager.id, - assetmanager.stockid, - stockmaster.longdescription, - stockmaster.categoryid, - assetmanager.serialno, - fixedassetlocations.locationdescription, - assetmanager.cost, - assetmanager.datepurchased, - assetmanager.depn, - assetmanager.disposalvalue, - fixedassetlocations.parentlocationid, - assetmanager.location - FROM assetmanager - LEFT JOIN stockmaster ON assetmanager.stockid=stockmaster.stockid - LEFT JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid - LEFT JOIN fixedassetlocations ON assetmanager.location=fixedassetlocations.locationid - WHERE stockmaster.categoryid like "' . $_POST['assetcategory'] . '" - AND stockmaster.stockid like "' . $_POST['assettype'] . '" - AND assetmanager.datepurchased BETWEEN "' . $dateFrom . '" AND "' . $dateTo . '"'; + $DateFrom = FormatDateForSQL($_POST['FromDate']); + $DateTo = FormatDateForSQL($_POST['ToDate']); + $sql = 'SELECT fixedassets.assetid, + fixedassets.description, + fixedassets.longdescription, + fixedassets.assetcategoryid, + fixedassets.serialno, + fixedassetlocations.locationdescription, + fixedassets.datepurchased, + fixedassetlocations.parentlocationid, + fixedassets.assetlocation, + SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom . '") THEN fixedassettrans.cost ELSE 0 END) AS bfwdcost, + SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom .'") THEN fixedassettrans.depn ELSE 0 END) AS bfwddepn, + SUM(CASE WHEN (fixedassettrans.transdate >="' . $DateFrom .'" AND fixedassettrans.transdate <="' . $DateTo . '") THEN fixedassettrans.cost ELSE 0 END) AS periodadditions, + SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" THEN fixedassettrans.depn ELSE 0 END) AS perioddepn + FROM fixedassets + INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + INNER JOIN fixedassetlocations ON fixedassets.assetlocation=fixedassetlocations.locationid + INNER JOIN fixedassettrans ON fixedassets.assetid=fixedassettrans.assetid + WHERE fixedassets.assetcategoryid ' . LIKE . '"' . $_POST['AssetCategory'] . '" + AND fixedassets.assetid ' . LIKE . '"' . $_POST['AssetID'] . '" + GROUP BY fixedassets.assetid, + fixedassets.description, + fixedassets.longdescription, + fixedassets.assetcategoryid, + fixedassets.serialno, + fixedassetlocations.locationdescription, + fixedassets.datepurchased, + fixedassetlocations.parentlocationid, + fixedassets.assetlocation'; $result = DB_query($sql, $db); if (isset($_POST['pdf'])) { $FontSize = 10; $pdf->addinfo('Title', _('Fixed Asset Register')); $PageNumber = 1; $line_height = 12; - include ('includes/PDFAssetRegisterHeader.inc'); + if ($_POST['AssetCategory']=='%') { + $AssetCategory=_('All'); + } else { + $CategorySQL='SELECT categorydescription FROM fixedassetcategories WHERE categoryid="'.$_POST['AssetCategory'].'"'; + $CategoryResult=DB_query($CategorySQL, $db); + $CategoryRow=DB_fetch_array($CategoryResult); + $AssetCategory=$CategoryRow['categorydescription']; + } + + if ($_POST['AssetID']=='%') { + $AssetDescription =_('All'); + } else { + $AssetSQL='SELECT description FROM fixedassets WHERE assetid="'.$_POST['AssetID'].'"'; + $AssetResult=DB_query($AssetSQL, $db); + $AssetRow=DB_fetch_array($AssetResult); + $AssetDescription =$AssetRow['description']; + } + PDFPageHeader(); } elseif (isset($_POST['csv'])) { - $csv_output = "'Asset ID','Stock ID', 'Description','Serial Number','Location','Date Acquired','Cost','Depreciation','NBV','Disposal Value'"; - $csv_output.= "\n"; + $csv_output = "'Asset ID','Description','Serial Number','Location','Date Acquired','Cost B/Fwd','Period Additions','Depn B/Fwd','Period Depreciation','Cost C/Fwd', 'Accum Depn C/Fwd','NBV','Disposal Value'\n"; } else { echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<br><table width=80% cellspacing="1" class=selection><tr>'; echo '<th>' . _('Asset ID') . '</th>'; - echo '<th>' . _('Stock ID') . '</th>'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Serial Number') . '</th>'; echo '<th>' . _('Location') . '</th>'; echo '<th>' . _('Date Acquired') . '</th>'; - echo '<th>' . _('Cost') . '</th>'; - echo '<th>' . _('Depreciation') . '</th>'; + echo '<th>' . _('Cost B/fwd') . '</th>'; + echo '<th>' . _('Depn B/fwd') . '</th>'; + echo '<th>' . _('Additions') . '</th>'; + echo '<th>' . _('Depn') . '</th>'; + echo '<th>' . _('Cost C/fwd') . '</th>'; + echo '<th>' . _('Depn C/fwd') . '</th>'; echo '<th>' . _('NBV') . '</th>'; echo '<th>' . _('Disposal Value') . '</th></tr>'; } + $TotalCostBfwd =0; + $TotalCostCfwd = 0; + $TotalDepnBfwd = 0; + $TotalDepnCfwd = 0; + $TotalAdditions = 0; + $TotalDepn = 0; + $TotalDisposals = 0; + $TotalNBV = 0; + while ($myrow = DB_fetch_array($result)) { - $ancestors = array(); - $ancestors[0] = $myrow['locationdescription']; + /* + * $Ancestors = array(); + $Ancestors[0] = $myrow['locationdescription']; $i = 0; - while ($ancestors[$i] != '') { - $locationsql = 'SELECT parentlocationid from fixedassetlocations where locationdescription="' . $ancestors[$i] . '"'; - $locationresult = DB_query($locationsql, $db); - $locationrow = DB_fetch_array($locationresult); - $parentsql = 'SELECT locationdescription from fixedassetlocations where locationid="' . $locationrow['parentlocationid'] . '"'; - $parentresult = DB_query($parentsql, $db); - $parentrow = DB_fetch_array($parentresult); + while ($Ancestors[$i] != '') { + $LocationSQL = 'SELECT parentlocationid from fixedassetlocations where locationdescription="' . $Ancestors[$i] . '"'; + $LocationResult = DB_query($LocationSQL, $db); + $LocationRow = DB_fetch_array($LocationResult); + $ParentSQL = 'SELECT locationdescription from fixedassetlocations where locationid="' . $LocationRow['parentlocationid'] . '"'; + $ParentResult = DB_query($ParentSQL, $db); + $ParentRow = DB_fetch_array($ParentResult); $i++; - $ancestors[$i] = $parentrow['locationdescription']; + $Ancestors[$i] = $ParentRow['locationdescription']; } - $MonthsOld = DateDiff(date('d/m/Y'), ConvertSQLDate($myrow['datepurchased']), 'm'); - if (in_array($_POST['assetlocation'], $ancestors) or $_POST['assetlocation'] == 'All') { - if (isset($_POST['pdf'])) { - $LeftOvers = $pdf->addTextWrap($Xpos, $YPos, 300 - $Left_Margin, $FontSize, $myrow['id']); - $LeftOvers = $pdf->addTextWrap($Xpos + 40, $YPos, 300 - $Left_Margin, $FontSize, $myrow['stockid']); - $LeftOvers = $pdf->addTextWrap($Xpos + 80, $YPos, 300 - $Left_Margin, $FontSize, $myrow['longdescription']); - $LeftOvers = $pdf->addTextWrap($Xpos + 250, $YPos, 300 - $Left_Margin, $FontSize, $myrow['serialno']); - $LeftOvers = $pdf->addTextWrap($Xpos + 300, $YPos, 300 - $Left_Margin, $FontSize, $myrow['locationdescription']); - $TempYPos = $YPos; - for ($i = 1;$i < sizeOf($ancestors) - 1;$i++) { - for ($j = 0;$j < $i;$j++) { - $TempYPos-= (0.8 * $line_height); - $LeftOvers = $pdf->addTextWrap($Xpos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, ' '); - } - $LeftOvers = $pdf->addTextWrap($Xpos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, '|_' . $ancestors[$i]); + */ + + if (isset($_POST['pdf'])) { + $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 30 - $Left_Margin, $FontSize, $myrow['assetid']); + $LeftOvers = $pdf->addTextWrap($XPos + 30, $YPos, 150 - $Left_Margin, $FontSize, $myrow['description']); + $LeftOvers = $pdf->addTextWrap($XPos + 180, $YPos, 40 - $Left_Margin, $FontSize, $myrow['serialno']); + /* + * $TempYPos = $YPos; + for ($i = 1;$i < sizeof($Ancestors) - 1;$i++) { + for ($j = 0;$j < $i;$j++) { + $TempYPos-= (0.8 * $line_height); + $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, ' '); } - $LeftOvers = $pdf->addTextWrap($Xpos + 380, $YPos, 300 - $Left_Margin, $FontSize, ConvertSQLDate($myrow['datepurchased'])); - $LeftOvers = $pdf->addTextWrap($Xpos + 440, $YPos, 55, $FontSize, number_format($myrow['cost'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 495, $YPos, 55, $FontSize, number_format($myrow['depn'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 550, $YPos, 50, $FontSize, number_format($myrow['cost'] - $myrow['depn'], 0), 'right'); - $YPos = $TempYPos - (0.8 * $line_height); - if ($YPos < $Bottom_Margin + $line_height) { - include ('includes/PDFAssetRegisterHeader.inc'); - } - } elseif (isset($_POST['csv'])) { - $csv_output.= $myrow['id'] . "," . $myrow['stockid'] .",".$myrow['longdescription'].",". - $myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['cost']. - ",".$myrow['depn'].",".($myrow['cost']-$myrow['depn'])."\n"; + $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, '|_' . $Ancestors[$i]); + } + * */ + + $LeftOvers = $pdf->addTextWrap($XPos + 220, $YPos, 50 - $Left_Margin, $FontSize, ConvertSQLDate($myrow['datepurchased'])); + $LeftOvers = $pdf->addTextWrap($XPos + 270, $YPos, 70, $FontSize, number_format($myrow['costbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 340, $YPos, 70, $FontSize, number_format($myrow['depnbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 410, $YPos, 70, $FontSize, number_format($myrow['periodadditions'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 480, $YPos, 70, $FontSize, number_format($myrow['perioddepn'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 550, $YPos, 70, $FontSize, number_format($myrow['periodadditions'] + $myrow['costbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 620, $YPos, 70, $FontSize, number_format($myrow['periodepn'] + $myrow['depnbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 690, $YPos, 70, $FontSize, number_format($myrow['periodadditions'] + $myrow['costbfwd'] - $myrow['periodepn'] - $myrow['depnbfwd'], 0), 'right'); + + $YPos = $TempYPos - (0.8 * $line_height); + if ($YPos < $Bottom_Margin + $line_height) { + PDFPageHeader(); + } + } elseif (isset($_POST['csv'])) { + $csv_output.= $myrow['assetid'] . "," . $myrow['longdescription'] .",".$myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['costbfwd'].",".$myrow['periodadditions']."," . $myrow['depnbfwd'] . "," .$myrow['perioddepn'].",".($myrow['costbfwd']+$myrow['periodadditions']). ", " . ($myrow['depnbfwd']+$myrow['perioddepn']) . ", " . ($myrow['costbfwd']+$myrow['periodadditions']-$myrow['depnbfwd']-$myrow['perioddepn']) . "\n"; - } else { - echo '<tr><td style="vertical-align:top">' . $myrow['id'] . '</td>'; - echo '<td style="vertical-align:top">' . $myrow['stockid'] . '</td>'; - echo '<td style="vertical-align:top">' . $myrow['longdescription'] . '</td>'; - echo '<td style="vertical-align:top">' . $myrow['serialno'] . '</td>'; - echo '<td>' . $myrow['locationdescription'] . '<br>'; - for ($i = 1;$i < sizeOf($ancestors) - 1;$i++) { - for ($j = 0;$j < $i;$j++) { - echo ' '; - } - echo '|_' . $ancestors[$i] . '<br>'; + } else { + echo '<tr><td style="vertical-align:top">' . $myrow['assetid'] . '</td>'; + echo '<td style="vertical-align:top">' . $myrow['longdescription'] . '</td>'; + echo '<td style="vertical-align:top">' . $myrow['serialno'] . '</td>'; + echo '<td>' . $myrow['locationdescription'] . '<br>'; + for ($i = 1;$i < sizeOf($Ancestors) - 1;$i++) { + for ($j = 0;$j < $i;$j++) { + echo ' '; } - echo '</td><td style="vertical-align:top">' . ConvertSQLDate($myrow['datepurchased']) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['depn'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'] - $myrow['depn'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['disposalvalue'], 2) . '</td></tr>'; + echo '|_' . $Ancestors[$i] . '<br>'; } - $TotalCost = $TotalCost + $myrow['cost']; - $Totaldepn = $Totaldepn + $myrow['depn']; - $TotalNBV = $TotalCost - $Totaldepn; - $Totaldisp = $Totaldisp + $myrow['disposalvalue']; + echo '</td><td style="vertical-align:top">' . ConvertSQLDate($myrow['datepurchased']) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['depnbfwd'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['periodadditions'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddepn'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd']+$myrow['periodadditions'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddepn']+$myrow['depnbfwd'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd']+$myrow['periodadditions']-$myrow['perioddepn']-$myrow['depnbfwd'], 2) . '</td>'; + + //echo '<td style="vertical-align:top" class=number>' . number_format($myrow['disposalvalue'], 2) . '</td></tr>'; } + $TotalCostBfwd +=$myrow['costbfwd']; + $TotalCostCfwd += ($myrow['costbfwd']+$myrow['periodadditions']); + $TotalDepnBfwd += $myrow['depnbfwd']; + $TotalDepnCfwd += ($myrow['depnbfwd']+$myrow['perioddepn']); + $TotalAdditions += $myrow['periodadditions']; + $TotalDepn += $myrow['perioddepn']; + $TotalDisposals += 0; + $TotalNBV += ($myrow['costbfwd']+$myrow['periodadditions']- $myrow['depnbfwd']-$myrow['perioddepn']); } + if (isset($_POST['pdf'])) { - $LeftOvers = $pdf->addTextWrap($Xpos, $YPos, 300 - $Left_Margin, $FontSize, "TOTAL"); - $LeftOvers = $pdf->addTextWrap($Xpos + 40, $YPos, 300 - $Left_Margin, $FontSize, ' '); - $LeftOvers = $pdf->addTextWrap($Xpos + 80, $YPos, 300 - $Left_Margin, $FontSize, ' '); - $LeftOvers = $pdf->addTextWrap($Xpos + 250, $YPos, 300 - $Left_Margin, $FontSize, ' '); - $LeftOvers = $pdf->addTextWrap($Xpos + 300, $YPos, 300 - $Left_Margin, $FontSize, ' '); - $LeftOvers = $pdf->addTextWrap($Xpos + 300, $YPos, 300 - $Left_Margin, $FontSize, ' '); - $LeftOvers = $pdf->addTextWrap($Xpos + 380, $YPos, 300 - $Left_Margin, $FontSize, ' '); // number_format($Totaldepn_pdf,2),'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 440, $YPos, 55, $FontSize, number_format($TotalCost, 2), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 495, $YPos, 55, $FontSize, number_format($Totaldepn, 2), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 550, $YPos, 50, $FontSize, number_format($TotalNBV, 2), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 300 - $Left_Margin, $FontSize, _('TOTAL')); + $LeftOvers = $pdf->addTextWrap($XPos + 270, $YPos, 70, $FontSize, number_format($TotalCostBfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 340, $YPos, 70, $FontSize, number_format($TotalDepnBfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 410, $YPos, 70, $FontSize, number_format($TotalAdditions, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 480, $YPos, 70, $FontSize, number_format($TotalDepn, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 550, $YPos, 70, $FontSize, number_format($TotalCostCfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 620, $YPos, 70, $FontSize, number_format($TotalDepnCfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 690, $YPos, 70, $FontSize, number_format($TotalNBV, 0), 'right'); + $pdf->Output($_SESSION['DatabaseName'] . '_Asset Register_' . date('Y-m-d') . '.pdf', 'I'); exit; } elseif (isset($_POST['csv'])) { - // download now. WFT am I waiting for??? Don't use headers, kinda messy - // $filename="/tmp/".date("Y-m-d").".csv"; - $filename = "companies/".$_SESSION['DatabaseName']."/reportwriter/test.csv"; + $filename = $_SESSION['reports_dir'] . '/FixedAssetRegister_' . Date('Y-m-d') .'.csv'; $csvfile = fopen($filename, 'w'); $i = fwrite($csvfile, $csv_output); - header("Location: companies/".$_SESSION['DatabaseName']."/reportwriter/test.csv"); - // echo "Testing successfully done"; - // header("Content-Type: text/csv"); - // header("Content-disposition: attachment; filename= $cvsfile"); + header('Location: ' .$_SESSION['reports_dir'] . '/FixedAssetRegister_' . Date('Y-m-d') .'.csv'); } else { - echo '<input type=hidden name=fromDate value="' . $_POST['fromDate'] . '">'; - echo '<input type=hidden name=toDate value=' . $_POST['toDate'] . '>'; - echo '<input type=hidden name=assetcategory value=' . $_POST['assetcategory'] . '>'; - echo '<input type=hidden name=assettype value=' . $_POST['assettype'] . '>'; - echo '<input type=hidden name=assetlocation value=' . $_POST['assetlocation'] . '>'; + echo '<input type=hidden name=FromDate value="' . $_POST['FromDate'] . '">'; + echo '<input type=hidden name=ToDate value=' . $_POST['ToDate'] . '>'; + echo '<input type=hidden name=AssetCategory value=' . $_POST['AssetCategory'] . '>'; + echo '<input type=hidden name=AssetID value=' . $_POST['AssetID'] . '>'; + echo '<input type=hidden name=AssetLocation value=' . $_POST['AssetLocation'] . '>'; //Total Values - echo '<tr><th style="vertical-align:top">TOTAL</th>'; - echo '<th style="vertical-align:top"></th>'; - echo '<th style="vertical-align:top"></th>'; - echo '<th style="vertical-align:top"></th>'; - echo '<th style="vertical-align:top"></th>'; - echo '<th style="vertical-align:top"></th>'; - echo '<th style="text-align:right">' . number_format($TotalCost, 2) . '</th>'; - echo '<th style="text-align:right">' . number_format($Totaldepn, 2) . '</th>'; + echo '<tr><th style="vertical-align:top" colspan="5">' . _('TOTAL') . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalCostBfwd, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalDepnBfwd, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalAdditions, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalDepn, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalCostCfwd, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalDepnCfwd, 2) . '</th>'; echo '<th style="text-align:right">' . number_format($TotalNBV, 2) . '</th>'; - echo '<th style="text-align:right">' . number_format($Totaldisp, 2) . '</th></tr>'; + echo '<th style="text-align:right">' . number_format($TotalDisposals, 2) . '</th></tr>'; echo '</table>'; echo '<br><div class="centre"><input type="Submit" name="pdf" value="' . _('Print as a pdf') . '"> '; echo '<input type="Submit" name="csv" value="' . _('Print as CSV') . '"></div></form>'; @@ -180,57 +216,57 @@ } else { include ('includes/header.inc'); echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title; - $sql = "SELECT * FROM stockcategory WHERE stocktype='" . 'A' . "'"; - $result = DB_query($sql, $db); + + $result = DB_query('SELECT categoryid,categorydescription FROM fixedassetcategories', $db); echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<tr><th>' . _('Asset Category') . '</th>'; - echo '<td><select name=assetcategory>'; + echo '<td><select name=AssetCategory>'; echo '<option value="%">' . _('ALL') . '</option>'; while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['assetcategory']) and $myrow['categoryid'] == $_POST['assetcategory']) { + if (isset($_POST['AssetCategory']) and $myrow['categoryid'] == $_POST['AssetCategory']) { echo '<option selected value=' . $myrow['categoryid'] . '>' . $myrow['categorydescription'] . '</option>'; } else { echo '<option value=' . $myrow['categoryid'] . '>' . $myrow['categorydescription'] . '</option>'; } } echo '</select></td></tr>'; - $sql = "SELECT locationid, locationdescription FROM fixedassetlocations"; + $sql = 'SELECT locationid, locationdescription FROM fixedassetlocations'; $result = DB_query($sql, $db); echo '<tr><th>' . _('Asset Location') . '</th>'; - echo '<td><select name=assetlocation>'; + echo '<td><select name=AssetLocation>'; echo '<option value="All">' . _('ALL') . '</option>'; while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['assetlocation']) and $myrow['locationdescription'] == $_POST['assetlocation']) { + if (isset($_POST['AssetLocation']) and $myrow['locationdescription'] == $_POST['AssetLocation']) { echo '<option selected value="' . $myrow['locationdescription'] . '">' . $myrow['locationdescription'] . '</option>'; } else { echo '<option value="' . $myrow['locationdescription'] . '">' . $myrow['locationdescription'] . '</option>'; } } echo '</select></td></tr>'; - $sql = "SELECT stockid, description FROM stockmaster LEFT JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stocktype='A'"; + $sql = 'SELECT assetid, description FROM fixedassets'; $result = DB_query($sql, $db); - echo '<tr><th>' . _('Asset Type') . '</th>'; - echo '<td><select name=assettype>'; + echo '<tr><th>' . _('Asset') . '</th>'; + echo '<td><select name="AssetID">'; echo '<option value="%">' . _('ALL') . '</option>'; while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['assettype']) and $myrow['stockid'] == $_POST['assettype']) { - echo '<option selected value=' . $myrow['stockid'] . '>' . $myrow['description'] . '</option>'; + if (isset($_POST['AssetID']) and $myrow['assetid'] == $_POST['AssetID']) { + echo '<option selected value=' . $myrow['assetid'] . '>' . $myrow['assetid'] . ' - ' . $myrow['description'] . '</option>'; } else { - echo '<option value=' . $myrow['stockid'] . '>' . $myrow['description'] . '</option>'; + echo '<option value=' . $myrow['assetid'] . '>' . $myrow['assetid'] . ' - ' . $myrow['description'] . '</option>'; } } echo '</select></td></tr>'; - if (empty($_POST['fromDate'])) { - $_POST['fromDate'] = date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1)); + if (empty($_POST['FromDate'])) { + $_POST['FromDate'] = date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1)); } - if (empty($_POST['toDate'])) { - $_POST['toDate'] = date($_SESSION['DefaultDateFormat']); + if (empty($_POST['ToDate'])) { + $_POST['ToDate'] = date($_SESSION['DefaultDateFormat']); } //FULUSI CHANGE BELOW TO ADD TIME - echo '<tr><th>' . _(' From Date') . "</th><td><input type='text' class='date' alt='" . $_SESSION['DefaultDateFormat'] . "' name='fromDate' maxlength=10 size=11 value='" . $_POST['fromDate'] . "'></td>"; + echo '<tr><th>' . _(' From Date') . "</th><td><input type='text' class='date' alt='" . $_SESSION['DefaultDateFormat'] . "' name='FromDate' maxlength=10 size=11 value='" . $_POST['FromDate'] . "'></td>"; echo '</tr>'; - echo '<tr><th>' . _('To Date ') . "</th><td><input type='text' class='date' alt='" . $_SESSION['DefaultDateFormat'] . "' name='toDate' maxlength=10 size=11 value='" . $_POST['toDate'] . "'></td>"; + echo '<tr><th>' . _('To Date ') . "</th><td><input type='text' class='date' alt='" . $_SESSION['DefaultDateFormat'] . "' name='ToDate' maxlength=10 size=11 value='" . $_POST['ToDate'] . "'></td>"; echo '</tr>'; //end of FULUSI STUFF echo '</table><br>'; @@ -240,4 +276,82 @@ echo '</form>'; } include ('includes/footer.inc'); + + +function PDFPageHeader (){ + global $PageNumber, + $pdf, + $XPos, + $YPos, + $Page_Height, + $Page_Width, + $Top_Margin, + $FontSize, + $Left_Margin, + $Right_Margin, + $line_height; + $AssetDescription; + $AssetCategory; + + if ($PageNumber>1){ + $pdf->newPage(); + } + + $FontSize=10; + $YPos= $Page_Height-$Top_Margin; + $XPos=0; + $pdf->addJpegFromFile($_SESSION['LogoFile'] ,$XPos+20,$YPos-50,0,60); + + + + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos,240,$FontSize,$_SESSION['CompanyRecord']['coyname']); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*1),240,$FontSize, _('Asset Category ').' ' . $AssetCategory ); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*2),240,$FontSize, _('Asset Location ').' ' . $_POST['AssetLocation'] ); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*3),240,$FontSize, _('Asset ID').': ' . $AssetDescription); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*4),240,$FontSize, _('From').': ' . $_POST['FromDate']); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*5),240,$FontSize, _('To').': ' . $_POST['ToDate']); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*7),240,$FontSize, _('Page'). ' ' . $PageNumber); + + $YPos -= 60; + + $YPos -=2*$line_height; + //Note, this is ok for multilang as this is the value of a Select, text in option is different + + $YPos -=(2*$line_height); + + /*Draw a rectangle to put the headings in */ + $YTopLeft=$YPos+$line_height; + $pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); + $pdf->line($Left_Margin, $YPos+$line_height,$Left_Margin, $YPos- $line_height); + $pdf->line($Left_Margin, $YPos- $line_height,$Page_Width-$Right_Margin, $YPos- $line_height); + $pdf->line($Page_Width-$Right_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos- $line_height); + + /*set up the headings */ + $FontSize=10; + $XPos = $Left_Margin+1; + $YPos -=(0.8*$line_height); + $LeftOvers = $pdf->addTextWrap($XPos,$YPos,30,$FontSize, _('Asset'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+30,$YPos,150,$FontSize, _('Description'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+180,$YPos,40,$FontSize, _('Serial No.'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+220,$YPos,50,$FontSize, _('Purchased'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+270,$YPos,70,$FontSize, _('Cost B/Fwd'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+340,$YPos,70,$FontSize, _('Depn B/Fwd'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+410,$YPos,70,$FontSize, _('Additions'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+480,$YPos,70,$FontSize, _('Depreciation'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+550,$YPos,70,$FontSize, _('Cost C/Fwd'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+620,$YPos,70,$FontSize, _('Depn C/Fwd'), 'centre'); + $LeftOvers = $pdf->addTextWrap($XPos+690,$YPos,70,$FontSize, _('Net Book Value'), 'centre'); + //$LeftOvers = $pdf->addTextWrap($XPos+760,$YPos,70,$FontSize, _('Disposal Proceeds'), 'centre'); + + $pdf->line($Left_Margin, $YTopLeft,$Page_Width-$Right_Margin, $YTopLeft); + $pdf->line($Left_Margin, $YTopLeft,$Left_Margin, $Bottom_Margin); + $pdf->line($Left_Margin, $Bottom_Margin,$Page_Width-$Right_Margin, $Bottom_Margin); + $pdf->line($Page_Width-$Right_Margin, $Bottom_Margin,$Page_Width-$Right_Margin, $YTopLeft); + + $FontSize=8; + $YPos -= (1.5 * $line_height); + + $PageNumber++; +} + ?> \ No newline at end of file Modified: trunk/FixedAssetTransfer.php =================================================================== --- trunk/FixedAssetTransfer.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/FixedAssetTransfer.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -10,11 +10,11 @@ foreach ($_POST as $key => $value) { if (substr($key,0,4)=='move') { - $id=substr($key,4); - $location=$_POST['location'.$id]; - $sql='UPDATE assetmanager - SET location="'.$location.'" - WHERE id='.$id; + $AssetID=substr($key,4); + $location=$_POST['location'.$AssetID]; + $sql='UPDATE fixedassets + SET assetlocation="'.$location.'" + WHERE assetid='.$AssetID; $result=DB_query($sql, $db); } } @@ -24,7 +24,7 @@ } else if (isset($_POST['AssetID'])) { $AssetID=$_POST['AssetID']; } else { - $sql='SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype="'.'A'.'"'; + $sql='SELECT categoryid, categorydescription FROM fixedassetcategories'; $result=DB_query($sql, $db); echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -32,14 +32,14 @@ '" alt="">' . ' ' . $title . '</p>'; echo '<table class=selection><tr>'; echo '<td>'. _('In Asset Category') . ': '; - echo '<select name="StockCat">'; + echo '<select name="AssetCat">'; - if (!isset($_POST['StockCat'])) { - $_POST['StockCat'] = ""; + if (!isset($_POST['AssetCat'])) { + $_POST['AssetCat'] = ""; } while ($myrow = DB_fetch_array($result)) { - if ($myrow['categoryid'] == $_POST['StockCat']) { + if ($myrow['categoryid'] == $_POST['AssetCat']) { echo '<option selected VALUE="' . $myrow['categoryid'] . '">' . $myrow['categorydescription']; } else { echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription']; @@ -61,10 +61,10 @@ echo '<td><font size 3><b>' . _('OR').' ' . '</b></font>' . _('Enter partial') .' <b>'. _('Stock Code') . '</b>:</td>'; echo '<td>'; - if (isset($_POST['StockCode'])) { - echo '<input type="text" name="StockCode" value="'. trim($_POST['StockCode'],'%') . '" size=15 maxlength=18>'; + if (isset($_POST['AssetID'])) { + echo '<input type="text" name="AssetID" value="'. trim($_POST['AssetID'],'%') . '" size=15 maxlength=18>'; } else { - echo '<input type="text" name="StockCode" size=15 maxlength=18>'; + echo '<input type="text" name="AssetID" size=15 maxlength=18>'; } echo '<tr><td></td>'; @@ -72,7 +72,7 @@ echo '<td><font size 3><b>' . _('OR').' ' . '</font></b>' . _('Enter partial').' <b>'. _('Serial Number') . '</b>:</td>'; echo '<td>'; - if (isset($_POST['StockCode'])) { + if (isset($_POST['AssetID'])) { echo '<input type="text" name="SerialNumber" value="'. trim($_POST['SerialNumber'],'%') . '" size=15 maxlength=18>'; } else { echo '<input type="text" name="SerialNumber" size=15 maxlength=18>'; @@ -82,79 +82,86 @@ echo '<div class="centre"><input type=submit name="Search" value="'. _('Search Now') . '"></div></form><br>'; } - if (isset($_POST['Search'])) { - if ($_POST['StockCat']=='All') { - $_POST['StockCat']='%'; - } - if (isset($_POST['Keywords'])) { - $_POST['Keywords']='%'.$_POST['Keywords'].'%'; - } else { - $_POST['Keywords']='%'; - } - if (isset($_POST['StockCode'])) { - $_POST['StockCode']='%'.$_POST['StockCode'].'%'; - } else { - $_POST['StockCode']='%'; - } - if (isset($_POST['SerialNumber'])) { - $_POST['SerialNumber']='%'.$_POST['SerialNumber'].'%'; - } else { - $_POST['SerialNumber']='%'; - } - $sql= 'SELECT assetmanager.*,stockmaster.description, fixedassetlocations.locationdescription - FROM assetmanager - LEFT JOIN stockmaster - ON assetmanager.stockid=stockmaster.stockid - LEFT JOIN fixedassetlocations - ON assetmanager.location=fixedassetlocations.locationid - WHERE stockmaster.categoryid like "'.$_POST['StockCat'].'" - AND stockmaster.description like "'.$_POST['Keywords'].'" - AND assetmanager.stockid like "'.$_POST['StockCode'].'" - AND assetmanager.serialno like "'.$_POST['SerialNumber'].'"'; - $result=DB_query($sql, $db); - echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post><table class=selection>'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<tr><th>'._('Asset ID').'</th> - <th>'._('Stock Code').'</th> - <th>'._('Description').'</th> - <th>'._('Serial number').'</th> - <th>'._('Purchase Cost').'</th> - <th>'._('Total Depreciation').'</th> - <th>'._('Current Location').'</th> - <th>'._('Move To :').'</th> - </tr>'; - while ($myrow=DB_fetch_array($result)) { - $locationsql='select * from fixedassetlocations'; - $locationresult=DB_query($locationsql, $db); - echo '<tr><td>'.$myrow['id'].'</td>'; - echo '<td>'.$myrow['stockid'].'</td>'; - echo '<td>'.$myrow['description'].'</td>'; - echo '<td>'.$myrow['serialno'].'</td>'; - echo '<td class=number>'.number_format($myrow['cost'],2).'</td>'; - echo '<td class=number>'.number_format($myrow['depn'],2).'</td>'; - echo '<td>'.$myrow['locationdescription'].'</td>'; - echo '<td><select name="location'.$myrow['id'].'" onChange="ReloadForm(move'.$myrow['id'].')">'; - echo '<option></option>'; - while ($locationrow=DB_fetch_array($locationresult)) { - if ($locationrow['locationid']==$myrow['location']) { - echo '<option selected value="'.$locationrow['locationid'].'">'.$locationrow['locationdescription']. - '</option>'; - } else { - echo '<option value="'.$locationrow['locationid'].'">'.$locationrow['locationdescription'].'</option>'; - } + +if (isset($_POST['Search'])) { + if ($_POST['AssetCat']=='All') { + $_POST['AssetCat']='%'; + } + if (isset($_POST['Keywords'])) { + $_POST['Keywords']='%'.$_POST['Keywords'].'%'; + } else { + $_POST['Keywords']='%'; + } + if (isset($_POST['AssetID'])) { + $_POST['AssetID']='%'.$_POST['AssetID'].'%'; + } else { + $_POST['AssetID']='%'; + } + if (isset($_POST['SerialNumber'])) { + $_POST['SerialNumber']='%'.$_POST['SerialNumber'].'%'; + } else { + $_POST['SerialNumber']='%'; + } + $sql= 'SELECT fixedassets.assetid, + fixedassets.cost, + fixedassets.accumdepn, + fixedassets.description, + fixedassets.depntype, + fixedassets.serialno, + fixedassets.barcode, + fixedassets.assetlocation, + fixedassetlocations.locationdescription + FROM fixedassets + INNER JOIN fixedassetlocations + ON fixedassets.assetlocation=fixedassetlocations.locationid + WHERE fixedassets.assetcategoryid ' . LIKE . '"'.$_POST['AssetCat'].'" + AND fixedassets.description ' . LIKE . '"'.$_POST['Keywords'].'" + AND fixedassets.assetid ' . LIKE . '"'.$_POST['AssetID'].'" + AND fixedassets.serialno ' . LIKE . '"'.$_POST['SerialNumber'].'"'; + $Result=DB_query($sql, $db); + echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post><table class=selection>'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<tr><th>'._('Asset ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Serial number') . '</th> + <th>' . _('Purchase Cost') . '</th> + <th>' . _('Total Depreciation') . '</th> + <th>' . _('Current Location') . '</th> + <th>' . _('Move To :') . '</th> + </tr>'; + + $locationsql='SELECT locationid, locationdescription from fixedassetlocations'; + $LocationResult=DB_query($locationsql, $db); + + while ($myrow=DB_fetch_array($Result)) { + + echo '<tr><td>'.$myrow['assetid'].'</td> + <td>'.$myrow['description'].'</td> + <td>'.$myrow['serialno'].'</td> + <td class=number>'.number_format($myrow['cost'],2).'</td> + <td class=number>'.number_format($myrow['accumdepn'],2).'</td> + <td>'.$myrow['locationdescription'].'</td>'; + echo '<td><select name="location'.$myrow['assetid'].'" onChange="ReloadForm(move'.$myrow['assetid'].')">'; + echo '<option></option>'; + while ($LocationRow=DB_fetch_array($LocationResult)) { + if ($LocationRow['locationid']==$myrow['location']) { + echo '<option selected value="'.$LocationRow['locationid'].'">'.$LocationRow['locationdescription'] . '</option>'; + } else { + echo '<option value="'.$LocationRow['locationid'].'">'.$LocationRow['locationdescription'].'</option>'; } - echo '</select></td>'; - echo '<input type=hidden name=StockCat value="' . $_POST['StockCat'].'"'; - echo '<input type=hidden name=Keywords value="' . $_POST['Keywords'].'"'; - echo '<input type=hidden name=StockCode value="' . $_POST['StockCode'].'"'; - echo '<input type=hidden name=SerialNumber value="' . $_POST['SerialNumber'].'"'; - echo '<input type=hidden name=Search value="' . $_POST['Search'].'"'; - echo '<td><input type=submit name="move'.$myrow['id'].'" value=Move></td>'; - echo '</tr>'; } - echo '</table></form>'; + DB_data_seek($LocationResult,0); + echo '</select></td>'; + echo '<input type=hidden name=AssetCat value="' . $_POST['AssetCat'].'"'; + echo '<input type=hidden name=Keywords value="' . $_POST['Keywords'].'"'; + echo '<input type=hidden name=AssetID value="' . $_POST['AssetID'].'"'; + echo '<input type=hidden name=SerialNumber value="' . $_POST['SerialNumber'].'"'; + echo '<input type=hidden name=Search value="' . $_POST['Search'].'"'; + echo '<td><input type=submit name="move'.$myrow['id'].'" value=Move></td>'; + echo '</tr>'; } -//} + echo '</table></form>'; +} include('includes/footer.inc'); Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/PO_Items.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -29,7 +29,7 @@ $Maximum_Number_Of_Parts_To_Show=50; if (!isset($_POST['Commit'])) { - echo '<a href="'.$rootpath.'/PO_Header.php?' . SID . "identifier=".$identifier. '">' ._('Back To Purchase Order Header') . '</a><br>'; + echo '<a href="'.$rootpath.'/PO_Header.php?' . SID . 'identifier=' . $identifier. '">' ._('Back To Purchase Order Header') . '</a><br>'; } // add new request here 08-09-26 Added: trunk/SuppFixedAssetChgs.php =================================================================== --- trunk/SuppFixedAssetChgs.php (rev 0) +++ trunk/SuppFixedAssetChgs.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -0,0 +1,144 @@ +<?php + +/* $Id: $*/ + +/*The supplier transaction uses the SuppTrans class to hold the information about the invoice +the SuppTrans class contains an array of Asset objects called Assets- containing details of all asset additions on a supplier invoice +Asset additions are posted to the debit of fixed asset category cost account if the creditors GL link is on */ + +include('includes/DefineSuppTransClass.php'); + +$PageSecurity = 5; + +/* Session started here for password checking and authorisation level check */ +include('includes/session.inc'); + +$title = _('Fixed Asset Charges or Credits'); + +include('includes/header.inc'); + +if ($_SESSION['SuppTrans']->InvoiceOrCredit == 'Invoice'){ + echo '<a href="' . $rootpath . '/SupplierInvoice.php?' . SID . '">' . _('Back to Invoice Entry') . '</a>'; +} else { + echo '<a href="' . $rootpath . '/SupplierCredit.php?' . SID . '">' . _('Back to Credit Note Entry') . '</a>'; +} + +if (!isset($_SESSION['SuppTrans'])){ + prnMsg(_('Fixed asset additions or credits are entered against supplier invoices or credit notes respectively') . '. ' . _('To enter supplier transactions the supplier must first be selected from the supplier selection screen') . ', ' . _('then the link to enter a supplier invoice or credit note must be clicked on'),'info'); + echo '<br><a href="' . $rootpath . '/SelectSupplier.php?' . SID .'">' . _('Select A Supplier') . '</a>'; + exit; + /*It all stops here if there aint no supplier selected and invoice/credit initiated ie $_SESSION['SuppTrans'] started off*/ +} + + +if (isset($_POST['AddAssetToInvoice'])){ + + $InputError = False; + if ($_POST['AssetID'] == ''){ + $_POST['AssetID'] = $_POST['AssetSelection']; + } else { + $result = DB_query('SELECT assetid FROM fixedassets WHERE assetid="' . $_POST['AssetID'] . '"',$db); + if (DB_num_rows($result)==0) { + prnMsg(_('The asset ID entered manually is not a valid fixed asset. If you do not know the asset reference, select it from the list'),'error'); + $InputError = True; + unset($_POST['AssetID']); + } + } + + if (!is_numeric($_POST['Amount'])){ + prnMsg(_('The amount entered is not numeric. This fixed asset cannot be added to the invoice'),'error'); + $InputError = True; + unset($_POST['Amount']); + } + + if ($InputError == False){ + $_SESSION['SuppTrans']->Add_Asset_To_Trans($_POST['AssetID'], $_POST['Amount']); + unset($_POST['AssetID']); + unset($_POST['Amount']); + } +} + +if (isset($_GET['Delete'])){ + + $_SESSION['SuppTrans']->Remove_Asset_From_Trans($_GET['Delete']); +} + +/*Show all the selected ShiptRefs so far from the SESSION['SuppInv']->Shipts array */ +if ($_SESSION['SuppTrans']->InvoiceOrCredit=='Invoice'){ + echo '<div class="centre"><p class="page_title_text">'. _('Fixed Assets on Invoice') . ' '; +} else { + echo '<div class="centre"><p class="page_title_text">' . _('Fixed Asset credits on Credit Note') . ' '; +} +echo $_SESSION['SuppTrans']->SuppReference . ' ' ._('From') . ' ' . $_SESSION['SuppTrans']->SupplierName; +echo '</div>'; +echo '<table cellpadding=2 class=selection>'; +$TableHeader = '<tr><th>' . _('Asset ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Amount') . '</th></tr>'; +echo $TableHeader; + +$TotalAssetValue = 0; + +foreach ($_SESSION['SuppTrans']->Assets as $EnteredAsset){ + + echo '<tr><td>' . $EnteredAsset->AssetID . '</td> + <td>' . $EnteredAsset->Description . '</td> + <td class=number>' . number_format($EnteredAsset->Amount,2) . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $EnteredAsset->Counter . '">' . _('Delete') . '</a></td></tr>'; + + $TotalAssetValue += $EnteredAsset->Amount; + +} + +echo '<tr> + <td class="number"><font size="2" color="navy">' . _('Total') . ':</font></td> + <td class="number"><font size="2" color="navy"><U>' . number_format($TotalAssetValue,2) . '</U></font></td> +</tr> +</table><br />'; + +/*Set up a form to allow input of new Shipment charges */ +echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method="post">'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + +if (!isset($_POST['AssetID'])) { + $_POST['AssetID']=''; +} +echo '<table class=selection>'; + +prnMsg(_('If you know the code enter it in the Asset ID input box, otherwise select the asset from the list below. Only assets with no cost will show in the list'),'info'); + +echo '<tr><td>' . _('Asset ID') . ':</td> + <td><input type="text" name="AssetID" size="5" maxlength="6" VALUE="' . $_POST['AssetID'] . '"> <a href="FixedAssetItems.php" target=_blank>'. _('New Fixed Asset') . '</a></td></tr>'; +echo '<tr><td>' . _('Asset Selection') . ':</td><td><select name="AssetSelection">'; + +$sql = 'SELECT assetid, + description + FROM fixedassets + WHERE cost=0 + ORDER BY assetid DESC'; + +$result = DB_query($sql, $db); + +while ($myrow = DB_fetch_array($result)) { + if (isset($_POST['AssetSelection']) AND $myrow['AssetID']==$_POST['AssetSelection']) { + echo '<option selected VALUE="'; + } else { + echo '<option VALUE="'; + } + echo $myrow['assetid'] . '">' . $myrow['assetid'] . ' - ' . $myrow['description'] . '</option>'; +} + +echo '</select></td></tr>'; + +if (!isset($_POST['Amount'])) { + $_POST['Amount']=0; +} +echo '<tr><td>' . _('Amount') . ':</td> + <td><input type="text" name="Amount" size="12" maxlength="11" VALUE="' . $_POST['Amount'] . '"></td></tr>'; +echo '</table>'; + +echo '<br /><div class=centre><input type="submit" name="AddAssetToInvoice" VALUE="' . _('Enter Fixed Asset') . '"></div>'; + +echo '</form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2010-11-27 10:13:11 UTC (rev 4169) +++ trunk/SupplierCredit.php 2010-11-28 06:37:13 UTC (rev 4170) @@ -55,6 +55,7 @@ unset ($_SESSION['SuppTrans']->GRNs); unset ($_SESSION['SuppTrans']->Shipts); unset ($_SESSION['SuppTrans']->GLCodes); + unset($_SESSION['SuppTrans']->Assets); unset ($_SESSION['SuppTrans']); } @@ -129,7 +130,7 @@ $_SESSION['SuppTrans']->GRNAct = $_SESSION['CompanyRecord']['grnact']; $_SESSION['SuppTrans']->CreditorsAct = $_SESSION['CompanyRecord']['creditorsact']; - $_SESSION['SuppTrans']->InvoiceOrCredit = 'Credit Note'; + $_SESSION['SuppTrans']->InvoiceOrCredit = 'Credit Note'; //note no gettext going on here } elseif (!isset($_SESSION['SuppTrans'])){ @@ -186,6 +187,11 @@ $_SESSION['SuppTrans']->OvAmount += $ShiptLine->Amount; } } + if (count($_SESSION['SuppTrans']->Assets) > 0){ + foreach ( $_SESSION['SuppTrans']->Assets as $FixedAsset){ + $_SESSION['SuppTrans']->OvAmount += $FixedAsset->Amount; + } + } /*OvAmount must be entered manually */ $_SESSION['SuppTrans']->OvAmount = round($_POST['OvAmount'],2); @@ -195,7 +201,7 @@ } } -if (isset($_POST['GRNS']) and $_POST['GRNS'] == _('Enter Credit Against Goods Recd')){ +if (isset($_POST['GRNS']) and $_POST['GRNS'] == _('Purchase Orders')){ /*This ensures that any changes in the page are stored in the session before calling the grn page */ @@ -219,7 +225,7 @@ include('includes/footer.inc'); exit; } -if (isset($_POST['GL']) and $_POST['GL'] == _('Enter General Ledger Analysis')){ +if (isset($_POST['GL']) and $_POST['GL'] == _('General Ledger')){ /*This ensures that any changes in the page are stored in the session before calling the shipments page */ @@ -231,14 +237,22 @@ include('includes/footer.inc'); exit; } -if (isset($_POST['Contracts']) and $_POST['Contracts'] == _('Enter Against Contracts')){ +if (isset($_POST['Contracts']) and $_POST['Contracts'] == _('Contracts')){ /*This ensures that any changes in the page are stored in the session before calling the shipments page */ echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/SuppContractChgs.php?' . SID . '">'; - echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of invoices against contracts page') . + echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of supplier credit notes against contracts page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh'). ') ' . '<a href="' . $rootpath . '/SuppContractChgs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; exit; - } +} +if (isset($_POST['FixedAssets']) and $_POST['FixedAssets'] == _('Fixed Assets')){ + /*This ensures that any changes in the page are stored in the session before calling the shipments page */ + echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/SuppFixedAssetChgs.php?' . SID . '">'; + echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of invoices against fixed assets page') . + '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh'). ') ' . + '<a href="' . $rootpath . '/SuppFixedAssetChgs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; + exit; +} /* everything below here only do if a Supplier is selected fisrt add a header to show who we are making an credit note for */ @@ -271,15 +285,13 @@ <td><input type=TEXT class='number' size=11 maxlength=10 name='ExRate' VALUE=" . $_SESSION['SuppTrans']->ExRate . '></td></tr>'; echo '</table>'; -echo '<br><div class="centre"><input type="submit" name="GRNS" VALUE="' . _('Enter Credit Against Goods Recd') . '"> '; -echo '<input type="submit" name="Shipts" value="' . _('Enter Credit Against Shipment') . '"> '; -echo '<input type="submit" name="Contracts" VALUE="' . _('Enter Against Contracts') . '"> '; +echo '<br><div class="centre"><input type="submit" name="GRNS" VALUE="' . _('Purchase Orders') . '"> '; +echo '<input type="submit" name="Shipts" value="' . _('Shipments') . '"> '; +echo '<input type="submit" name="Contracts" VALUE="' . _('Contracts') . '"> '; if ( $_SESSION['SuppTrans']->GLLink_Creditors ==1){ - echo '<input type="submit" name="GL" value="' . _('Enter General Ledger Analysis') . '"></div>'; -} else { - echo '</div>'; -} - + echo '<input type="submit" name="GL" value="' . _('General Ledger') . '"> '; +} +echo '<input type="submit" name="FixedAssets" VALUE="' . _('Fixed Assets') . '"></div>'; echo '<br />'; if (count($_SESSION['SuppTrans']->GRNs)>0){ /*if there are some GRNs selected for crediting then */ @@ -287,7 +299,8 @@ /*Show all the selected GRNs so far from the SESSION['SuppInv']->GRNs array Note that the class for carrying GRNs refers to quantity invoiced read credited in this context*/ - echo '<table cellpadding=2 class=selection>'; + echo '<table cellpadding=2 class=selection> + <tr><th colspan="6">' . _('Purchase Order Credits') . '</th></tr>'; $TableHeader = "<tr><th>" . _('GRN') . "</th> <th>" . _('Item Code') . "</th> <th>" . _('Description') . "</th> @@ -318,7 +331,8 @@ if (count($_SESSION['SuppTrans']->Shipts)>0){ /*if there are any Shipment charges on the credit note*/ - echo '<table cellpadding=2 class=selection>'; + echo '<table cellpadding=2 class=selection> + <tr><th colspan="2">' . _('Shipment Credits') . '</th></tr>'; $TableHeader = "<tr><th>" . _('Shipment') . "</th> <th>" . _('Amount') . '</th></tr>'; echo $TableHeader; @@ -342,9 +356,41 @@ <td class=number><fontcolor=red><U>' . number_format($TotalShiptValue,2) . '</U></font></td></tr></table><br />'; } +if (count( $_SESSION['SuppTrans']->Assets) > 0){ /*if there are any fixed assets on the invoice*/ + + echo '<br /><table cellpadding=2 class=selection> + <tr><th colspan=3>' . _('Fixed Asset Credits') . '</th></tr>'; + $TableHeader = '<tr><th>' . _('Asset ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Amount') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th></tr>'; + echo $TableHeader; + + $TotalAssetValue = 0; + + foreach ($_SESSION['SuppTrans']->Assets as $EnteredAsset){ + + echo '<tr><td>' . $EnteredAsset->AssetID . '</td> + <td>' . $EnteredAsset->Description . '</td> + <td class=number>' . number_format($EnteredAsset->Amount,2) . '</td></tr>'; + + $TotalAssetValue += $EnteredAsset->Amount; + + $i++; + if ($i > 15){ + $i = 0; + echo $TableHeader; + } + } + + echo '<tr><td colspan=2 class=number><font size=4 color=blue>' . _('Total') . ':</font></td> + <td class=number><font size=4 color=BLUE><U>' . number_format($TotalAssetValue,2) . '</U></font></td></tr></table>'; +} //end loop around fixed assets + + if (count( $_SESSION['SuppTrans']->Contracts) > 0){ /*if there are any contract charges on the invoice*/ - echo '<table cellpadding="2" class=selection>'; + echo '<table cellpadding="2" class=selection> + <tr><th colspan="3">' . _('Contract Charges') . '</th></tr>'; $TableHeader = '<tr><th>' . _('Contract') . '</th> <th>' . _('Amount') . '</th> <th>' . _('Narrative') . '</th></tr>'; @@ -377,7 +423,8 @@ if ($_SESSION['SuppTrans']->GLLink_Creditors ==1){ if (count($_SESSION['SuppTrans']->GLCodes)>0){ - echo '<table cellpadding=2 class=selection>'; + echo '<table cellpadding=2 class=selection> + <tr><th colspan="3">' . _('General Ledger Analysis') . '</th></tr>'; $TableHeader = '<tr><th>' . _('Account') . '</th> <th>' . _('Name') . '</th> <th>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th> @@ -419,9 +466,11 @@ if (!isset($TotalContractsValue)){ $TotalContractsValue = 0; } + if (!isset($TotalAssetValue)){ + $TotalAssetValue = 0; + } + $_SESSION['SuppTrans']->OvAmount = round($TotalGRNValue + $TotalGLValue + $TotalAssetValue + $TotalShiptValue + $TotalContractsValue,2); - $_SESSION['SuppTrans']->OvAmount = round($TotalGRNValue + $TotalGLValue + $TotalShiptValue + $TotalContractsValue,2); - echo '<table class=selection><tr><td><font color=red>' . _('Credit Amount in Supplier Currency') . ':</font></td> <td colspan=2 class=number>' . number_format($_SESSION['SuppTrans']->OvAmount,2) . '</td></tr>'; } else { @@ -558,7 +607,7 @@ }elseif ($_SESSION['SuppTrans']->ExRate <= 0){ $InputError = True; prnMsg(_('The credit note as entered cannot be processed because the exchange rate for the credit note has been entered as a negative or zero number') . '. ' . _('The exchange rate is expected to show how many of the suppliers currency there are in 1 of the local currency'),'warn'); - }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalGRNValue,2)){ + }elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalAssetValue + $TotalGRNValue,2)){ prnMsg(_('The credit note total as entered is less than the sum of the shipment charges') . ', ' . _('the general ledger entries (if any) and the charges for goods received') . '. ' . _('There must be a mistake somewhere') . ', ' . _('the credit note as entered will not be processed'),'error'); $InputError = True; } else { @@ -664,7 +713,30 @@ $LocalTotal += round($ShiptChg->Amount/$_SESSION['SuppTrans']->ExRate,2); } - + + foreach ($_SESSION['SuppTrans']->Assets as $AssetAddition){ + /* only the GL entries if the creditors->GL integration is enabled */ + $SQL = 'INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (21, ' . +... [truncated message content] |
From: <dai...@us...> - 2010-11-28 07:10:04
|
Revision: 4172 http://web-erp.svn.sourceforge.net/web-erp/?rev=4172&view=rev Author: daintree Date: 2010-11-28 07:09:57 +0000 (Sun, 28 Nov 2010) Log Message: ----------- fix upgrade script to delete all stock related data for fixed assets .... Modified Paths: -------------- trunk/index.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-11-28 06:40:31 UTC (rev 4171) +++ trunk/index.php 2010-11-28 07:09:57 UTC (rev 4172) @@ -1334,11 +1334,6 @@ </tr> <tr> <td class="menu_group_item"> - <?php echo '<p>• <a href="' . $rootpath . '/FixedAssetList.php?' . SID . '">' . _('List Asset properties') . '</a></p>'; ?> - </td> - </tr> - <tr> - <td class="menu_group_item"> <?php echo GetRptLinks('fa'); ?> </td> </tr> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-28 06:40:31 UTC (rev 4171) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-28 07:09:57 UTC (rev 4172) @@ -468,6 +468,15 @@ DELETE stockitemproperties.* FROM stockitemproperties INNER JOIN stockmaster ON stockitemproperties.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; +DELETE stockserialmoves.* FROM stockserialmoves, stockmoves, +stockmaster,stockcategory WHERE stockserialmoves.stockmoveno=stockmoves.stkmoveno AND +stockmoves.stockid = stockmaster.stockid AND stockmaster.categoryid = stockcategory.categoryid AND stockcategory.stocktype = 'A'; + +DELETE stockserialitems.* FROM stockserialitems, stockmaster, stockcategory +WHERE stockserialitems.stockid = stockmaster.stockid AND stockmaster.categoryid=stockcategory.categoryid AND stocktype='A'; + +DELETE stockmoves . * FROM stockmoves, stockmaster, stockcategory WHERE stockmoves.stockid = stockmaster.stockid AND stockmaster.categoryid = stockcategory.categoryid AND stockcategory.stocktype = 'A'; + DELETE stockmaster.* FROM stockmaster INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; ALTER TABLE `fixedassets` CHANGE `id` `assetid` INT( 11 ) NOT NULL AUTO_INCREMENT ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-28 17:56:48
|
Revision: 4173 http://web-erp.svn.sourceforge.net/web-erp/?rev=4173&view=rev Author: tim_schofield Date: 2010-11-28 17:56:41 +0000 (Sun, 28 Nov 2010) Log Message: ----------- Only show when the invoiced qty is less than the GRN qty Modified Paths: -------------- trunk/OutstandingGRNs.php trunk/doc/Change.log.html Modified: trunk/OutstandingGRNs.php =================================================================== --- trunk/OutstandingGRNs.php 2010-11-28 07:09:57 UTC (rev 4172) +++ trunk/OutstandingGRNs.php 2010-11-28 17:56:41 UTC (rev 4173) @@ -39,7 +39,7 @@ suppliers WHERE grns.supplierid=suppliers.supplierid AND grns.podetailitem = purchorderdetails.podetailitem - AND qtyrecd-quantityinv <>0 + AND qtyrecd-quantityinv>0 AND grns.supplierid >='" . $_POST['FromCriteria'] . "' AND grns.supplierid <='" . $_POST['ToCriteria'] . "' ORDER BY supplierid, Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-28 07:09:57 UTC (rev 4172) +++ trunk/doc/Change.log.html 2010-11-28 17:56:41 UTC (rev 4173) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>28/11/10 Tim: OutstandingGRNs.php - Only show when the invoiced qty is less than the GRN qty</p> <p>28/11/10 Phil: All fixed asset scripts SupplierInvoice.php SupplierCredit.php SuppFixedAssetChgs.php - adding fixed assets directly from invoice charges - and reversing additions with credit notes. Also FixedAssetRegister.php report to print PDF or export CSV of fixed assets now includes date range depreciation and b/fwd cost b/fwd accum depn and c/fwd cost and accum depn - and NBV <p>28/11/10 James Murray: unset session in ConnectDB_mysqli.inc and ConnectDB_mysql.inc when the login fails <p>27/11/10 Phil install/index.php check for critical requirements before allowing install to proceed</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-11-28 18:27:41
|
Revision: 4174 http://web-erp.svn.sourceforge.net/web-erp/?rev=4174&view=rev Author: tim_schofield Date: 2010-11-28 18:27:34 +0000 (Sun, 28 Nov 2010) Log Message: ----------- Exsson: CreditStatus.php - Fix bug in sql statement Modified Paths: -------------- trunk/CreditStatus.php trunk/doc/Change.log.html Modified: trunk/CreditStatus.php =================================================================== --- trunk/CreditStatus.php 2010-11-28 17:56:41 UTC (rev 4173) +++ trunk/CreditStatus.php 2010-11-28 18:27:34 UTC (rev 4174) @@ -1,249 +1,249 @@ -<?php -/* $Revision: 1.16 $ */ -/* $Id$*/ - -$PageSecurity = 3; -include('includes/session.inc'); -$title = _('Credit Status Code Maintenance'); -include('includes/header.inc'); - -if (isset($_GET['SelectedReason'])){ - $SelectedReason = $_GET['SelectedReason']; -} elseif(isset($_POST['SelectedReason'])){ - $SelectedReason = $_POST['SelectedReason']; -} - -if (isset($Errors)) { - unset($Errors); -} -$Errors = array(); -$InputError = 0; -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<br>'; - -if (isset($_POST['submit'])) { - - //initialise no input errors assumed initially before we test - $i=1; - - /* actions to take once the user has clicked the submit button - ie the page has called itself with some user input */ - - //first off validate inputs are sensible - - $sql="SELECT count(reasoncode) - FROM holdreasons WHERE reasoncode='".$_POST['ReasonCode']."'"; - $result=DB_query($sql, $db); - $myrow=DB_fetch_row($result); - - if ($myrow[0]!=0 and !isset($SelectedReason)) { - $InputError = 1; - prnMsg( _('The credit status code already exists in the database'),'error'); - $Errors[$i] = 'ReasonCode'; - $i++; - } - if (!is_numeric($_POST['ReasonCode'])) { - $InputError = 1; - prnMsg(_('The status code name must be an integer'),'error'); - $Errors[$i] = 'ReasonCode'; - $i++; - } - if (strlen($_POST['ReasonDescription']) > 30) { - $InputError = 1; - prnMsg(_('The credit status description must be thirty characters or less long'),'error'); - } - if (strlen($_POST['ReasonDescription']) == 0) { - $InputError = 1; - prnMsg(_('The credit status description must be entered'),'error'); - $Errors[$i] = 'ReasonDescription'; - $i++; - } - - $msg=''; - - if (isset($SelectedReason) AND $InputError !=1) { - - /*SelectedReason could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ - - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ - $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=1 - WHERE reasoncode = '".$SelectedReason."'"; - } else { - $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=0 - WHERE reasoncode = '".$SelectedReason."'"; - } - $msg = _('The credit status record has been updated'); - - } else if ($InputError !=1) { - - /*Selected Reason is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new status code form */ - - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ - - $sql = "INSERT INTO holdreasons ( - reasoncode, - reasondescription, - dissallowinvoices) - VALUES ( - '" .$_POST['ReasonCode'] . ", - '" .$_POST['ReasonDescription'] . "', 1)"; - } else { - $sql = "INSERT INTO holdreasons ( - reasoncode, - reasondescription, - dissallowinvoices) - VALUES ( - '" .$_POST['ReasonCode'] . ", - '" .$_POST['ReasonDescription'] . "', 0)"; - } - - $msg = _('A new credit status record has been inserted'); - unset ($SelectedReason); - unset ($_POST['ReasonDescription']); - } - //run the SQL from either of the above possibilites - $result = DB_query($sql,$db); - if ($msg != '') { - prnMsg($msg,'success'); - } -} elseif (isset($_GET['delete'])) { -//the link to delete a selected record was clicked instead of the submit button - -// PREVENT DELETES IF DEPENDENT RECORDS IN DebtorsMaster - - $sql= "SELECT COUNT(*) - FROM debtorsmaster - WHERE debtorsmaster.holdreason='".$SelectedReason."'"; - - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0] > 0) { - prnMsg( _('Cannot delete this credit status code because customer accounts have been created referring to it'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('customer accounts that refer to this credit status code'); - } else { - //only delete if used in neither customer or supplier accounts - - $sql="DELETE FROM holdreasons WHERE reasoncode=$SelectedReason"; - $result = DB_query($sql,$db); - prnMsg(_('This credit status code has been deleted'),'success'); - } - //end if status code used in customer or supplier accounts - unset ($_GET['delete']); - unset ($SelectedReason); - -} - -if (!isset($SelectedReason)) { - -/* It could still be the second time the page has been run and a record has been selected for modification - SelectedReason will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters -then none of the above are true and the list of status codes will be displayed with -links to delete or edit each. These will call the same page again and allow update/input -or deletion of the records*/ - - $sql = "SELECT reasoncode, reasondescription, dissallowinvoices FROM holdreasons"; - $result = DB_query($sql, $db); - - echo '<table class=selection>'; - echo "<tr> - <th>". _('Status Code') ."</th> - <th>". _('Description') ."</th> - <th>". _('Disallow Invoices') .'</th>'; - - $k=0; //row colour counter - while ($myrow=DB_fetch_row($result)) { - - if ($myrow[2]==0) { - $DissallowText = _('Invoice OK'); - } else { - $DissallowText = '<b>'. _('NO INVOICING') .'</b>'; - } - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k=1; - } - - printf("<td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href=\"%s?SelectedReason=%s\">" . _('Edit') . "</a></td> - <td><a href=\"%s?SelectedReason=%s&delete=1\">". _('Delete') .'</a></td> - </tr>', - $myrow[0], - $myrow[1], - $DissallowText, - $_SERVER['PHP_SELF'], - $myrow[0], - $_SERVER['PHP_SELF'], - $myrow[0]); - - } //END WHILE LIST LOOP - echo '</table>'; - -} //end of ifs and buts! - -if (isset($SelectedReason)) { - echo '<div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Show Defined Credit Status Codes') . '</a></div>'; -} - -if (!isset($_GET['delete'])) { - - echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - - if (isset($SelectedReason) and ($InputError!=1)) { - //editing an existing status code - - $sql = "SELECT reasoncode, - reasondescription, - dissallowinvoices - FROM holdreasons - WHERE reasoncode='".$SelectedReason."'"; - - $result = DB_query($sql, $db); - $myrow = DB_fetch_array($result); - - $_POST['ReasonCode'] = $myrow['reasoncode']; - $_POST['ReasonDescription'] = $myrow['reasondescription']; - $_POST['DisallowInvoices'] = $myrow['dissallowinvoices']; - - echo "<input type=hidden name='SelectedReason' VALUE='" . $SelectedReason . "'>"; - echo "<input type=hidden name='ReasonCode' VALUE='" . $_POST['ReasonCode'] . "'>"; - echo "<table class=selection><tr><td>". _('Status Code') .':</td><td>'; - echo $_POST['ReasonCode'] . '</td></tr>'; - - } else { //end of if $SelectedReason only do the else when a new record is being entered - if (!isset($_POST['ReasonCode'])) { - $_POST['ReasonCode'] = ''; - } - echo '<br><table class=selection> - <tr> - <td>'. _('Status Code') .":</td> - <td><input " . (in_array('ReasonCode',$Errors) ? 'class="inputerror"' : '' ) . - " tabindex=1 type='Text' name='ReasonCode' VALUE='". $_POST['ReasonCode'] ."' size=3 maxlength=2></td> - </tr>"; - } - - if (!isset($_POST['ReasonDescription'])) { - $_POST['ReasonDescription'] = ''; - } - echo '<tr> - <td>'. _('Description') .':</td> - <td><input ' . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . - ' tabindex=2 type="text" name="ReasonDescription" VALUE="'. $_POST['ReasonDescription'] .'" size="28" maxlength="30"> - </td></tr> - <tr><td>'. _('Disallow Invoices') . '</td>'; - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']==1) { - echo '<td><input tabindex=3 type="checkbox" checked name="DisallowInvoices"></td></tr>'; - } else { - echo '<td><input tabindex=3 type="checkbox" name="DisallowInvoices"></td></tr>'; - } - echo '</table><br><div class="centre"><input tabindex=4 type="submit" name="submit" value="' . _('Enter Information') . '"></div></form>'; -} //end if record deleted no point displaying form to add record -include('includes/footer.inc'); -?> \ No newline at end of file +<?php +/* $Revision: 1.16 $ */ +/* $Id: CreditStatus.php 3863 2010-09-30 14:53:09Z tim_schofield $*/ + +$PageSecurity = 3; +include('includes/session.inc'); +$title = _('Credit Status Code Maintenance'); +include('includes/header.inc'); + +if (isset($_GET['SelectedReason'])){ + $SelectedReason = $_GET['SelectedReason']; +} elseif(isset($_POST['SelectedReason'])){ + $SelectedReason = $_POST['SelectedReason']; +} + +if (isset($Errors)) { + unset($Errors); +} +$Errors = array(); +$InputError = 0; +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<br>'; + +if (isset($_POST['submit'])) { + + //initialise no input errors assumed initially before we test + $i=1; + + /* actions to take once the user has clicked the submit button + ie the page has called itself with some user input */ + + //first off validate inputs are sensible + + $sql="SELECT count(reasoncode) + FROM holdreasons WHERE reasoncode='".$_POST['ReasonCode']."'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_row($result); + + if ($myrow[0]!=0 and !isset($SelectedReason)) { + $InputError = 1; + prnMsg( _('The credit status code already exists in the database'),'error'); + $Errors[$i] = 'ReasonCode'; + $i++; + } + if (!is_numeric($_POST['ReasonCode'])) { + $InputError = 1; + prnMsg(_('The status code name must be an integer'),'error'); + $Errors[$i] = 'ReasonCode'; + $i++; + } + if (strlen($_POST['ReasonDescription']) > 30) { + $InputError = 1; + prnMsg(_('The credit status description must be thirty characters or less long'),'error'); + } + if (strlen($_POST['ReasonDescription']) == 0) { + $InputError = 1; + prnMsg(_('The credit status description must be entered'),'error'); + $Errors[$i] = 'ReasonDescription'; + $i++; + } + + $msg=''; + + if (isset($SelectedReason) AND $InputError !=1) { + + /*SelectedReason could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ + + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ + $sql = "UPDATE holdreasons SET + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=1 + WHERE reasoncode = '".$SelectedReason."'"; + } else { + $sql = "UPDATE holdreasons SET + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=0 + WHERE reasoncode = '".$SelectedReason."'"; + } + $msg = _('The credit status record has been updated'); + + } else if ($InputError !=1) { + + /*Selected Reason is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new status code form */ + + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ + + $sql = "INSERT INTO holdreasons ( + reasoncode, + reasondescription, + dissallowinvoices) + VALUES ( + "."'" .$_POST['ReasonCode'] . "'".",'" + .$_POST['ReasonDescription'] . "', 1)"; + } else { + $sql = "INSERT INTO holdreasons ( + reasoncode, + reasondescription, + dissallowinvoices) + VALUES ( + "."'" .$_POST['ReasonCode'] . "'".",'" + .$_POST['ReasonDescription'] . "', 0)"; + } + + $msg = _('A new credit status record has been inserted'); + unset ($SelectedReason); + unset ($_POST['ReasonDescription']); + } + //run the SQL from either of the above possibilites + $result = DB_query($sql,$db); + if ($msg != '') { + prnMsg($msg,'success'); + } +} elseif (isset($_GET['delete'])) { +//the link to delete a selected record was clicked instead of the submit button + +// PREVENT DELETES IF DEPENDENT RECORDS IN DebtorsMaster + + $sql= "SELECT COUNT(*) + FROM debtorsmaster + WHERE debtorsmaster.holdreason='".$SelectedReason."'"; + + $result = DB_query($sql,$db); + $myrow = DB_fetch_row($result); + if ($myrow[0] > 0) { + prnMsg( _('Cannot delete this credit status code because customer accounts have been created referring to it'),'warn'); + echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('customer accounts that refer to this credit status code'); + } else { + //only delete if used in neither customer or supplier accounts + + $sql="DELETE FROM holdreasons WHERE reasoncode=$SelectedReason"; + $result = DB_query($sql,$db); + prnMsg(_('This credit status code has been deleted'),'success'); + } + //end if status code used in customer or supplier accounts + unset ($_GET['delete']); + unset ($SelectedReason); + +} + +if (!isset($SelectedReason)) { + +/* It could still be the second time the page has been run and a record has been selected for modification - SelectedReason will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters +then none of the above are true and the list of status codes will be displayed with +links to delete or edit each. These will call the same page again and allow update/input +or deletion of the records*/ + + $sql = "SELECT reasoncode, reasondescription, dissallowinvoices FROM holdreasons"; + $result = DB_query($sql, $db); + + echo '<table class=selection>'; + echo "<tr> + <th>". _('Status Code') ."</th> + <th>". _('Description') ."</th> + <th>". _('Disallow Invoices') .'</th>'; + + $k=0; //row colour counter + while ($myrow=DB_fetch_row($result)) { + + if ($myrow[2]==0) { + $DissallowText = _('Invoice OK'); + } else { + $DissallowText = '<b>'. _('NO INVOICING') .'</b>'; + } + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + printf("<td>%s</td> + <td>%s</td> + <td>%s</td> + <td><a href=\"%s?SelectedReason=%s\">" . _('Edit') . "</a></td> + <td><a href=\"%s?SelectedReason=%s&delete=1\">". _('Delete') .'</a></td> + </tr>', + $myrow[0], + $myrow[1], + $DissallowText, + $_SERVER['PHP_SELF'], + $myrow[0], + $_SERVER['PHP_SELF'], + $myrow[0]); + + } //END WHILE LIST LOOP + echo '</table>'; + +} //end of ifs and buts! + +if (isset($SelectedReason)) { + echo '<div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Show Defined Credit Status Codes') . '</a></div>'; +} + +if (!isset($_GET['delete'])) { + + echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + + if (isset($SelectedReason) and ($InputError!=1)) { + //editing an existing status code + + $sql = "SELECT reasoncode, + reasondescription, + dissallowinvoices + FROM holdreasons + WHERE reasoncode='".$SelectedReason."'"; + + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); + + $_POST['ReasonCode'] = $myrow['reasoncode']; + $_POST['ReasonDescription'] = $myrow['reasondescription']; + $_POST['DisallowInvoices'] = $myrow['dissallowinvoices']; + + echo "<input type=hidden name='SelectedReason' VALUE='" . $SelectedReason . "'>"; + echo "<input type=hidden name='ReasonCode' VALUE='" . $_POST['ReasonCode'] . "'>"; + echo "<table class=selection><tr><td>". _('Status Code') .':</td><td>'; + echo $_POST['ReasonCode'] . '</td></tr>'; + + } else { //end of if $SelectedReason only do the else when a new record is being entered + if (!isset($_POST['ReasonCode'])) { + $_POST['ReasonCode'] = ''; + } + echo '<br><table class=selection> + <tr> + <td>'. _('Status Code') .":</td> + <td><input " . (in_array('ReasonCode',$Errors) ? 'class="inputerror"' : '' ) . + " tabindex=1 type='Text' name='ReasonCode' VALUE='". $_POST['ReasonCode'] ."' size=3 maxlength=2></td> + </tr>"; + } + + if (!isset($_POST['ReasonDescription'])) { + $_POST['ReasonDescription'] = ''; + } + echo '<tr> + <td>'. _('Description') .':</td> + <td><input ' . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . + ' tabindex=2 type="text" name="ReasonDescription" VALUE="'. $_POST['ReasonDescription'] .'" size="28" maxlength="30"> + </td></tr> + <tr><td>'. _('Disallow Invoices') . '</td>'; + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']==1) { + echo '<td><input tabindex=3 type="checkbox" checked name="DisallowInvoices"></td></tr>'; + } else { + echo '<td><input tabindex=3 type="checkbox" name="DisallowInvoices"></td></tr>'; + } + echo '</table><br><div class="centre"><input tabindex=4 type="submit" name="submit" value="' . _('Enter Information') . '"></div></form>'; +} //end if record deleted no point displaying form to add record +include('includes/footer.inc'); +?> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-28 17:56:41 UTC (rev 4173) +++ trunk/doc/Change.log.html 2010-11-28 18:27:34 UTC (rev 4174) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> <p>28/11/10 Tim: OutstandingGRNs.php - Only show when the invoiced qty is less than the GRN qty</p> <p>28/11/10 Phil: All fixed asset scripts SupplierInvoice.php SupplierCredit.php SuppFixedAssetChgs.php - adding fixed assets directly from invoice charges - and reversing additions with credit notes. Also FixedAssetRegister.php report to print PDF or export CSV of fixed assets now includes date range depreciation and b/fwd cost b/fwd accum depn and c/fwd cost and accum depn - and NBV <p>28/11/10 James Murray: unset session in ConnectDB_mysqli.inc and ConnectDB_mysql.inc when the login fails This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-11-30 08:45:14
|
Revision: 4175 http://web-erp.svn.sourceforge.net/web-erp/?rev=4175&view=rev Author: daintree Date: 2010-11-30 08:45:07 +0000 (Tue, 30 Nov 2010) Log Message: ----------- fixed assets manual ...start thereof Modified Paths: -------------- trunk/CreditStatus.php trunk/FixedAssetDepreciation.php trunk/FixedAssetItems.php trunk/FixedAssetRegister.php trunk/GoodsReceived.php trunk/OutstandingGRNs.php trunk/PO_Items.php trunk/SupplierCredit.php trunk/SupplierInvoice.php trunk/doc/INSTALL.txt trunk/doc/Manual/ManualContents.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Added Paths: ----------- trunk/doc/Manual/ManualFixedAssets.html Modified: trunk/CreditStatus.php =================================================================== --- trunk/CreditStatus.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/CreditStatus.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -1,249 +1,250 @@ -<?php -/* $Revision: 1.16 $ */ -/* $Id: CreditStatus.php 3863 2010-09-30 14:53:09Z tim_schofield $*/ - -$PageSecurity = 3; -include('includes/session.inc'); -$title = _('Credit Status Code Maintenance'); -include('includes/header.inc'); - -if (isset($_GET['SelectedReason'])){ - $SelectedReason = $_GET['SelectedReason']; -} elseif(isset($_POST['SelectedReason'])){ - $SelectedReason = $_POST['SelectedReason']; -} - -if (isset($Errors)) { - unset($Errors); -} -$Errors = array(); -$InputError = 0; -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<br>'; - -if (isset($_POST['submit'])) { - - //initialise no input errors assumed initially before we test - $i=1; - - /* actions to take once the user has clicked the submit button - ie the page has called itself with some user input */ - - //first off validate inputs are sensible - - $sql="SELECT count(reasoncode) - FROM holdreasons WHERE reasoncode='".$_POST['ReasonCode']."'"; - $result=DB_query($sql, $db); - $myrow=DB_fetch_row($result); - - if ($myrow[0]!=0 and !isset($SelectedReason)) { - $InputError = 1; - prnMsg( _('The credit status code already exists in the database'),'error'); - $Errors[$i] = 'ReasonCode'; - $i++; - } - if (!is_numeric($_POST['ReasonCode'])) { - $InputError = 1; - prnMsg(_('The status code name must be an integer'),'error'); - $Errors[$i] = 'ReasonCode'; - $i++; - } - if (strlen($_POST['ReasonDescription']) > 30) { - $InputError = 1; - prnMsg(_('The credit status description must be thirty characters or less long'),'error'); - } - if (strlen($_POST['ReasonDescription']) == 0) { - $InputError = 1; - prnMsg(_('The credit status description must be entered'),'error'); - $Errors[$i] = 'ReasonDescription'; - $i++; - } - - $msg=''; - - if (isset($SelectedReason) AND $InputError !=1) { - - /*SelectedReason could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ - - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ - $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=1 - WHERE reasoncode = '".$SelectedReason."'"; - } else { - $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=0 - WHERE reasoncode = '".$SelectedReason."'"; - } - $msg = _('The credit status record has been updated'); - - } else if ($InputError !=1) { - - /*Selected Reason is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new status code form */ - - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ - - $sql = "INSERT INTO holdreasons ( - reasoncode, - reasondescription, - dissallowinvoices) - VALUES ( - "."'" .$_POST['ReasonCode'] . "'".",'" - .$_POST['ReasonDescription'] . "', 1)"; - } else { - $sql = "INSERT INTO holdreasons ( - reasoncode, - reasondescription, - dissallowinvoices) - VALUES ( - "."'" .$_POST['ReasonCode'] . "'".",'" - .$_POST['ReasonDescription'] . "', 0)"; - } - - $msg = _('A new credit status record has been inserted'); - unset ($SelectedReason); - unset ($_POST['ReasonDescription']); - } - //run the SQL from either of the above possibilites - $result = DB_query($sql,$db); - if ($msg != '') { - prnMsg($msg,'success'); - } -} elseif (isset($_GET['delete'])) { -//the link to delete a selected record was clicked instead of the submit button - -// PREVENT DELETES IF DEPENDENT RECORDS IN DebtorsMaster - - $sql= "SELECT COUNT(*) - FROM debtorsmaster - WHERE debtorsmaster.holdreason='".$SelectedReason."'"; - - $result = DB_query($sql,$db); - $myrow = DB_fetch_row($result); - if ($myrow[0] > 0) { - prnMsg( _('Cannot delete this credit status code because customer accounts have been created referring to it'),'warn'); - echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('customer accounts that refer to this credit status code'); - } else { - //only delete if used in neither customer or supplier accounts - - $sql="DELETE FROM holdreasons WHERE reasoncode=$SelectedReason"; - $result = DB_query($sql,$db); - prnMsg(_('This credit status code has been deleted'),'success'); - } - //end if status code used in customer or supplier accounts - unset ($_GET['delete']); - unset ($SelectedReason); - -} - -if (!isset($SelectedReason)) { - -/* It could still be the second time the page has been run and a record has been selected for modification - SelectedReason will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters -then none of the above are true and the list of status codes will be displayed with -links to delete or edit each. These will call the same page again and allow update/input -or deletion of the records*/ - - $sql = "SELECT reasoncode, reasondescription, dissallowinvoices FROM holdreasons"; - $result = DB_query($sql, $db); - - echo '<table class=selection>'; - echo "<tr> - <th>". _('Status Code') ."</th> - <th>". _('Description') ."</th> - <th>". _('Disallow Invoices') .'</th>'; - - $k=0; //row colour counter - while ($myrow=DB_fetch_row($result)) { - - if ($myrow[2]==0) { - $DissallowText = _('Invoice OK'); - } else { - $DissallowText = '<b>'. _('NO INVOICING') .'</b>'; - } - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k=1; - } - - printf("<td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href=\"%s?SelectedReason=%s\">" . _('Edit') . "</a></td> - <td><a href=\"%s?SelectedReason=%s&delete=1\">". _('Delete') .'</a></td> - </tr>', - $myrow[0], - $myrow[1], - $DissallowText, - $_SERVER['PHP_SELF'], - $myrow[0], - $_SERVER['PHP_SELF'], - $myrow[0]); - - } //END WHILE LIST LOOP - echo '</table>'; - -} //end of ifs and buts! - -if (isset($SelectedReason)) { - echo '<div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Show Defined Credit Status Codes') . '</a></div>'; -} - -if (!isset($_GET['delete'])) { - - echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - - if (isset($SelectedReason) and ($InputError!=1)) { - //editing an existing status code - - $sql = "SELECT reasoncode, - reasondescription, - dissallowinvoices - FROM holdreasons - WHERE reasoncode='".$SelectedReason."'"; - - $result = DB_query($sql, $db); - $myrow = DB_fetch_array($result); - - $_POST['ReasonCode'] = $myrow['reasoncode']; - $_POST['ReasonDescription'] = $myrow['reasondescription']; - $_POST['DisallowInvoices'] = $myrow['dissallowinvoices']; - - echo "<input type=hidden name='SelectedReason' VALUE='" . $SelectedReason . "'>"; - echo "<input type=hidden name='ReasonCode' VALUE='" . $_POST['ReasonCode'] . "'>"; - echo "<table class=selection><tr><td>". _('Status Code') .':</td><td>'; - echo $_POST['ReasonCode'] . '</td></tr>'; - - } else { //end of if $SelectedReason only do the else when a new record is being entered - if (!isset($_POST['ReasonCode'])) { - $_POST['ReasonCode'] = ''; - } - echo '<br><table class=selection> - <tr> - <td>'. _('Status Code') .":</td> - <td><input " . (in_array('ReasonCode',$Errors) ? 'class="inputerror"' : '' ) . - " tabindex=1 type='Text' name='ReasonCode' VALUE='". $_POST['ReasonCode'] ."' size=3 maxlength=2></td> - </tr>"; - } - - if (!isset($_POST['ReasonDescription'])) { - $_POST['ReasonDescription'] = ''; - } - echo '<tr> - <td>'. _('Description') .':</td> - <td><input ' . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . - ' tabindex=2 type="text" name="ReasonDescription" VALUE="'. $_POST['ReasonDescription'] .'" size="28" maxlength="30"> - </td></tr> - <tr><td>'. _('Disallow Invoices') . '</td>'; - if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']==1) { - echo '<td><input tabindex=3 type="checkbox" checked name="DisallowInvoices"></td></tr>'; - } else { - echo '<td><input tabindex=3 type="checkbox" name="DisallowInvoices"></td></tr>'; - } - echo '</table><br><div class="centre"><input tabindex=4 type="submit" name="submit" value="' . _('Enter Information') . '"></div></form>'; -} //end if record deleted no point displaying form to add record -include('includes/footer.inc'); -?> +<?php +/* $Revision: 1.16 $ */ +/* $Id$*/ + +$PageSecurity = 3; +include('includes/session.inc'); +$title = _('Credit Status Code Maintenance'); +include('includes/header.inc'); + +if (isset($_GET['SelectedReason'])){ + $SelectedReason = $_GET['SelectedReason']; +} elseif(isset($_POST['SelectedReason'])){ + $SelectedReason = $_POST['SelectedReason']; +} + +if (isset($Errors)) { + unset($Errors); +} +$Errors = array(); +$InputError = 0; +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<br>'; + +if (isset($_POST['submit'])) { + + //initialise no input errors assumed initially before we test + $i=1; + + /* actions to take once the user has clicked the submit button + ie the page has called itself with some user input */ + + //first off validate inputs are sensible + + $sql="SELECT count(reasoncode) + FROM holdreasons WHERE reasoncode='".$_POST['ReasonCode']."'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_row($result); + + if ($myrow[0]!=0 and !isset($SelectedReason)) { + $InputError = 1; + prnMsg( _('The credit status code already exists in the database'),'error'); + $Errors[$i] = 'ReasonCode'; + $i++; + } + if (!is_numeric($_POST['ReasonCode'])) { + $InputError = 1; + prnMsg(_('The status code name must be an integer'),'error'); + $Errors[$i] = 'ReasonCode'; + $i++; + } + if (strlen($_POST['ReasonDescription']) > 30) { + $InputError = 1; + prnMsg(_('The credit status description must be thirty characters or less long'),'error'); + } + if (strlen($_POST['ReasonDescription']) == 0) { + $InputError = 1; + prnMsg(_('The credit status description must be entered'),'error'); + $Errors[$i] = 'ReasonDescription'; + $i++; + } + + $msg=''; + + if (isset($SelectedReason) AND $InputError !=1) { + + /*SelectedReason could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ + + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ + $sql = "UPDATE holdreasons SET + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=1 + WHERE reasoncode = '".$SelectedReason."'"; + } else { + $sql = "UPDATE holdreasons SET + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=0 + WHERE reasoncode = '".$SelectedReason."'"; + } + $msg = _('The credit status record has been updated'); + + } else if ($InputError !=1) { + + /*Selected Reason is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new status code form */ + + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ + + $sql = "INSERT INTO holdreasons ( + reasoncode, + reasondescription, + dissallowinvoices) + VALUES ( + '" .$_POST['ReasonCode'] . "', + '".$_POST['ReasonDescription'] . "' + , 1)"; + } else { + $sql = "INSERT INTO holdreasons ( + reasoncode, + reasondescription, + dissallowinvoices) + VALUES ( + '" . $_POST['ReasonCode'] . "', + '" . $_POST['ReasonDescription'] ."', 0)"; + } + + $msg = _('A new credit status record has been inserted'); + unset ($SelectedReason); + unset ($_POST['ReasonDescription']); + } + //run the SQL from either of the above possibilites + $result = DB_query($sql,$db); + if ($msg != '') { + prnMsg($msg,'success'); + } +} elseif (isset($_GET['delete'])) { +//the link to delete a selected record was clicked instead of the submit button + +// PREVENT DELETES IF DEPENDENT RECORDS IN DebtorsMaster + + $sql= "SELECT COUNT(*) + FROM debtorsmaster + WHERE debtorsmaster.holdreason='".$SelectedReason."'"; + + $result = DB_query($sql,$db); + $myrow = DB_fetch_row($result); + if ($myrow[0] > 0) { + prnMsg( _('Cannot delete this credit status code because customer accounts have been created referring to it'),'warn'); + echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('customer accounts that refer to this credit status code'); + } else { + //only delete if used in neither customer or supplier accounts + + $sql="DELETE FROM holdreasons WHERE reasoncode=$SelectedReason"; + $result = DB_query($sql,$db); + prnMsg(_('This credit status code has been deleted'),'success'); + } + //end if status code used in customer or supplier accounts + unset ($_GET['delete']); + unset ($SelectedReason); + +} + +if (!isset($SelectedReason)) { + +/* It could still be the second time the page has been run and a record has been selected for modification - SelectedReason will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters +then none of the above are true and the list of status codes will be displayed with +links to delete or edit each. These will call the same page again and allow update/input +or deletion of the records*/ + + $sql = 'SELECT reasoncode, reasondescription, dissallowinvoices FROM holdreasons'; + $result = DB_query($sql, $db); + + echo '<table class=selection>'; + echo '<tr> + <th>'. _('Status Code') .'</th> + <th>'. _('Description') .'</th> + <th>'. _('Disallow Invoices') .'</th>'; + + $k=0; //row colour counter + while ($myrow=DB_fetch_row($result)) { + + if ($myrow[2]==0) { + $DissallowText = _('Invoice OK'); + } else { + $DissallowText = '<b>'. _('NO INVOICING') .'</b>'; + } + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + printf("<td>%s</td> + <td>%s</td> + <td>%s</td> + <td><a href=\"%s?SelectedReason=%s\">" . _('Edit') . "</a></td> + <td><a href=\"%s?SelectedReason=%s&delete=1\">". _('Delete') .'</a></td> + </tr>', + $myrow[0], + $myrow[1], + $DissallowText, + $_SERVER['PHP_SELF'], + $myrow[0], + $_SERVER['PHP_SELF'], + $myrow[0]); + + } //END WHILE LIST LOOP + echo '</table>'; + +} //end of ifs and buts! + +if (isset($SelectedReason)) { + echo '<div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Show Defined Credit Status Codes') . '</a></div>'; +} + +if (!isset($_GET['delete'])) { + + echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + + if (isset($SelectedReason) and ($InputError!=1)) { + //editing an existing status code + + $sql = "SELECT reasoncode, + reasondescription, + dissallowinvoices + FROM holdreasons + WHERE reasoncode='".$SelectedReason."'"; + + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); + + $_POST['ReasonCode'] = $myrow['reasoncode']; + $_POST['ReasonDescription'] = $myrow['reasondescription']; + $_POST['DisallowInvoices'] = $myrow['dissallowinvoices']; + + echo "<input type=hidden name='SelectedReason' VALUE='" . $SelectedReason . "'>"; + echo "<input type=hidden name='ReasonCode' VALUE='" . $_POST['ReasonCode'] . "'>"; + echo "<table class=selection><tr><td>". _('Status Code') .':</td><td>'; + echo $_POST['ReasonCode'] . '</td></tr>'; + + } else { //end of if $SelectedReason only do the else when a new record is being entered + if (!isset($_POST['ReasonCode'])) { + $_POST['ReasonCode'] = ''; + } + echo '<br><table class=selection> + <tr> + <td>'. _('Status Code') .":</td> + <td><input " . (in_array('ReasonCode',$Errors) ? 'class="inputerror"' : '' ) . + " tabindex=1 type='Text' name='ReasonCode' VALUE='". $_POST['ReasonCode'] ."' size=3 maxlength=2></td> + </tr>"; + } + + if (!isset($_POST['ReasonDescription'])) { + $_POST['ReasonDescription'] = ''; + } + echo '<tr> + <td>'. _('Description') .':</td> + <td><input ' . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . + ' tabindex=2 type="text" name="ReasonDescription" VALUE="'. $_POST['ReasonDescription'] .'" size="28" maxlength="30"> + </td></tr> + <tr><td>'. _('Disallow Invoices') . '</td>'; + if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']==1) { + echo '<td><input tabindex=3 type="checkbox" checked name="DisallowInvoices"></td></tr>'; + } else { + echo '<td><input tabindex=3 type="checkbox" name="DisallowInvoices"></td></tr>'; + } + echo '</table><br><div class="centre"><input tabindex=4 type="submit" name="submit" value="' . _('Enter Information') . '"></div></form>'; +} //end if record deleted no point displaying form to add record +include('includes/footer.inc'); +?> Modified: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/FixedAssetDepreciation.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -13,7 +13,12 @@ /*Get the last period depreciation (depn is transtype =44) was posted for */ -$result = DB_query('SELECT periods.lastdate_in_period, max(fixedassettrans.periodno) FROM fixedassettrans INNER JOIN periods ON fixedassettrans.periodno=periods.periodno WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); +$result = DB_query('SELECT periods.lastdate_in_period, + max(fixedassettrans.periodno) + FROM fixedassettrans INNER JOIN periods + ON fixedassettrans.periodno=periods.periodno + WHERE transtype=44 + GROUP BY periods.lastdate_in_period',$db); $LastDepnRun = DB_fetch_row($result); @@ -33,6 +38,7 @@ $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); } + /* Get list of assets for journal */ $sql='SELECT fixedassets.assetid, fixedassets.description, @@ -61,7 +67,12 @@ ORDER BY assetcategoryid, assetid'; $AssetsResult=DB_query($sql, $db); -if (isset($_POST['CommitDepreciation'])){ +$InputError = false; //always hope for the best +if (Date1GreaterThanDate2($_POST['ProcessDate'],Date($_SESSION['DefaultDateFormat']))){ + prnMsg(_('No depreciation will be committed as the processing date is beyond the current date. The depreciation run can only be run for periods prior to today'),'warn'); + $InputError =true; +} +if (isset($_POST['CommitDepreciation']) AND $InputError==false){ $result = DB_Txn_Begin($db); $TransNo = GetNextTransNo(44, $db); $PeriodNo = GetPeriod($_POST['ProcessDate'],$db); @@ -147,7 +158,7 @@ $TotalAccumDepn +=$AssetRow['accumdepn']; $TotalDepn +=$NewDepreciation; - if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0){ + if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0 AND $InputError==false){ //debit depreciation expense $SQL = "INSERT INTO gltrans (type, @@ -190,7 +201,7 @@ transdate, periodno, inputdate, - cost, + fixedassettranstype, depn) VALUES ('" . $AssetRow['assetid'] . "', '44', @@ -198,7 +209,7 @@ '" . FormatDateForSQL($_POST['ProcessDate']) . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', - '0', + 'depn', '" . $NewDepreciation . "')"; $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); @@ -229,7 +240,7 @@ echo '</table><hr><p></p>'; -if (isset($_POST['CommitDepreciation'])){ +if (isset($_POST['CommitDepreciation']) AND $InputError==false){ $result = DB_Txn_Commit($db); prnMsg(_('Depreciation') . ' ' . $TransNo . ' ' . _('has been successfully entered'),'success'); unset($_POST['ProcessDate']); Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/FixedAssetItems.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -101,9 +101,9 @@ $Errors[$i] = 'AssetCategoryID'; $i++; } - if (!is_numeric($_POST['DepnRate']) OR $_POST['DepnRate']>100 OR $_POST['DepnRate']<0){ + if (!is_numeric($_POST['DepnRate']) OR $_POST['DepnRate']>100 OR $_POST['DepnRate']<1){ $InputError = 1; - prnMsg(_('The depreciation rate is expected to be a number between 0 and 100'),'error'); + prnMsg(_('The depreciation rate is expected to be a number between 1 and 100'),'error'); $Errors[$i] = 'DepnRate'; $i++; } @@ -518,7 +518,7 @@ echo '</select></td></tr>'; -echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=4 maxlength=4 value="' . $_POST['DepnRate'] . '"></td></tr>'; +echo '<tr><td>' . _('Depreciation Rate') . ':</td><td><input ' . (in_array('DepnRate',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="Text" name="DepnRate" size=4 maxlength=4 value="' . $_POST['DepnRate'] . '">%</td></tr>'; echo '</table>'; /*Get the last period depreciation (depn is transtype =44) was posted for */ Modified: trunk/FixedAssetRegister.php =================================================================== --- trunk/FixedAssetRegister.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/FixedAssetRegister.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -23,10 +23,10 @@ fixedassets.datepurchased, fixedassetlocations.parentlocationid, fixedassets.assetlocation, - SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom . '") THEN fixedassettrans.cost ELSE 0 END) AS bfwdcost, - SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom .'") THEN fixedassettrans.depn ELSE 0 END) AS bfwddepn, - SUM(CASE WHEN (fixedassettrans.transdate >="' . $DateFrom .'" AND fixedassettrans.transdate <="' . $DateTo . '") THEN fixedassettrans.cost ELSE 0 END) AS periodadditions, - SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" THEN fixedassettrans.depn ELSE 0 END) AS perioddepn + SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom . '" AND fixedassettrans.fixedassettranstype="cost") THEN fixedassettrans.amount ELSE 0 END) AS bfwdcost, + SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom .'" AND fixedassettrans.fixedassettranstype="depn") THEN fixedassettrans.amount ELSE 0 END) AS bfwddepn, + SUM(CASE WHEN (fixedassettrans.transdate >="' . $DateFrom .'" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="cost") THEN fixedassettrans.amount ELSE 0 END) AS periodadditions, + SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="depn" THEN fixedassettrans.amount ELSE 0 END) AS perioddepn FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid INNER JOIN fixedassetlocations ON fixedassets.assetlocation=fixedassetlocations.locationid Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/GoodsReceived.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -582,13 +582,15 @@ transdate, periodno, inputdate, - cost) + fixedassettranstype + amount) VALUES ('" . $OrderLine->AssetID . "', 25, '" . $GRN . "', '" . $_POST['DefaultReceivedDate'] . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', + 'cost', '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "')"; $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); Modified: trunk/OutstandingGRNs.php =================================================================== --- trunk/OutstandingGRNs.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/OutstandingGRNs.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -24,27 +24,27 @@ /*Now figure out the data to report for the criteria under review */ $SQL = "SELECT grnno, - orderno, - grns.supplierid, - suppliers.suppname, - grns.itemcode, - grns.itemdescription, - qtyrecd, - quantityinv, - grns.stdcostunit, - actprice, - unitprice - FROM grns, - purchorderdetails, - suppliers - WHERE grns.supplierid=suppliers.supplierid - AND grns.podetailitem = purchorderdetails.podetailitem - AND qtyrecd-quantityinv>0 - AND grns.supplierid >='" . $_POST['FromCriteria'] . "' - AND grns.supplierid <='" . $_POST['ToCriteria'] . "' - ORDER BY supplierid, - grnno"; - + orderno, + grns.supplierid, + suppliers.suppname, + grns.itemcode, + grns.itemdescription, + qtyrecd, + quantityinv, + grns.stdcostunit, + actprice, + unitprice + FROM grns, + purchorderdetails, + suppliers + WHERE grns.supplierid=suppliers.supplierid + AND grns.podetailitem = purchorderdetails.podetailitem + AND qtyrecd-quantityinv>0 + AND grns.supplierid >='" . $_POST['FromCriteria'] . "' + AND grns.supplierid <='" . $_POST['ToCriteria'] . "' + ORDER BY supplierid, + grnno"; + $GRNsResult = DB_query($SQL,$db,'','',false,false); if (DB_error_no($db) !=0) { Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/PO_Items.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -663,20 +663,28 @@ else { $_POST['GLCode']=0; } - if (strlen($_POST['AssetID'])>0){ - if (!is_numeric($_POST['AssetID'])){ - $AllowUpdate = false; - prnMsg(_('An asset code was entered but it is not numeric. A numeric asset code that exists must be entered when ordering a fixed asset'),'error'); - } - $ValidAssetResult = DB_query('SELECT assetid FROM fixedassets WHERE assetid="' . $_POST['AssetID'] . '"',$db); + if ($_POST['AssetID'] !='Not an Asset'){ + $ValidAssetResult = DB_query('SELECT assetid, + description, + costact + FROM fixedassets + INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + WHERE assetid="' . $_POST['AssetID'] . '"',$db); if (DB_num_rows($ValidAssetResult)==0){ // then the asset id entered doesn't exist $AllowUpdate = false; prnMsg(_('An asset code was entered but it does not yet exist. Only pre-existing asset ids can be entered when ordering a fixed asset'),'error'); + } else { + $AssetRow = DB_fetch_array($ValidAssetResult); + $_POST['GLCode'] = $AssetRow['costact']; + if ($_POST['ItemDescription']==''){ + $_POST['ItemDescription'] = $AssetRow['description']; + } } } //end if an AssetID is entered if (strlen($_POST['ItemDescription'])<=3){ $AllowUpdate = false; - prnMsg(_('Cannot enter this order line') . ':<br>' . _('The description of the item being purchase is required where a non-stock item is being ordered'),'warn'); + prnMsg(_('Cannot enter this order line') . ':<br>' . _('The description of the item being purchased is required where a non-stock item is being ordered'),'warn'); } if ($AllowUpdate == true){ @@ -999,10 +1007,21 @@ while ($myrow=DB_fetch_array($result)) { echo '<option value="'.$myrow['accountcode'].'">'.$myrow['accountcode'].' - '.$myrow['accountname'].'</option>'; } - echo '</td></tr>'; + echo '</select></td></tr>'; echo '<tr><td>'._('OR Asset ID'). '</td> - <td><input type="text" class="number" name="AssetID" size="10" maxlength=12> - <a href="FixedAssetItems.php" target=_blank>'. _('New Fixed Asset') . '</a></td> + <td><select name="AssetID">'; + $AssetsResult = DB_query('SELECT assetid, description, datepurchased FROM fixedassets ORDER BY assetid DESC',$db); + echo '<option selected value="Not an Asset">' . _('Not an Asset') . '</option>'; + while ($AssetRow = DB_fetch_array($AssetsResult)){ + if ($AssetRow['datepurchased']=='0000-00-00'){ + $DatePurchased = _('Not yet purchased'); + } else { + $DatePurchased = ConvertSQLDate($AssetRow['datepurchased']); + } + echo '<option value="' . $AssetRow['assetid'] . '">' . $AssetRow['assetid'] . ' - '. $DatePurchased . ' - ' . $AssetRow['description'] . '</option>'; + } + + echo'</select><a href="FixedAssetItems.php" target=_blank>'. _('New Fixed Asset') . '</a></td> <tr><td>'._('Quantity to purchase').'</td> <td><input type="text" class="number" name="Qty" size=10></td></tr> <tr><td>'._('Price per item').'</td> Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/SupplierCredit.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -1172,13 +1172,15 @@ transdate, periodno, inputdate, - cost) + fixedassettranstype, + amount) VALUES ('" . $EnteredGRN->AssetID . "', 21, '" . $CreditNoteNo . "', '" . $SQLCreditNoteDate . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', + 'cost', '" . -($PurchPriceVar) . "')"; $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); @@ -1257,13 +1259,15 @@ transdate, periodno, inputdate, - cost) + fixedassettranstype, + amount) VALUES ('" . $AssetAddition->AssetID . "', 21, '" . $CreditNoteNo . "', '" . $SQLCreditNoteDate . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', + 'cost', '" . (-$AssetAddition->Amount / $_SESSION['SuppTrans']->ExRate) . "')"; $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); Modified: trunk/SupplierInvoice.php =================================================================== --- trunk/SupplierInvoice.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/SupplierInvoice.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -1168,13 +1168,15 @@ transdate, periodno, inputdate, - cost) + fixedassettranstype, + amount) VALUES ('" . $EnteredGRN->AssetID . "', 20, '" . $InvoiceNo . "', '" . $SQLInvoiceDate . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', + 'cost', '" . ($PurchPriceVar) . "')"; $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); @@ -1250,13 +1252,15 @@ transdate, periodno, inputdate, - cost) + fixedassettranstype, + amount) VALUES ('" . $AssetAddition->AssetID . "', 20, '" . $InvoiceNo . "', '" . $SQLInvoiceDate . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', + 'cost', '" . ($AssetAddition->Amount / $_SESSION['SuppTrans']->ExRate) . "')"; $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); Modified: trunk/doc/INSTALL.txt =================================================================== --- trunk/doc/INSTALL.txt 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/doc/INSTALL.txt 2010-11-30 08:45:07 UTC (rev 4175) @@ -28,6 +28,20 @@ ***************New Installations*************** +Automated Installation + +Extract the webERP archive under your web-root directory (folder). Browse to the + +http://yourhost/webERP/ + +Where "yourhost" is the host web-server. The install should start automatically. It is most important to ensure that the web-server can write to the hosting files and persmissions may need to be altered through cpanel or other means. They should be changed back once the installation is completed. + + + +Manual Installation + +Read on below if you cannot use the installer to set up your installation. + Note: It is worth printing this document off and checking off the steps as you go. Pre-requisites: Modified: trunk/doc/Manual/ManualContents.php =================================================================== --- trunk/doc/Manual/ManualContents.php 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/doc/Manual/ManualContents.php 2010-11-30 08:45:07 UTC (rev 4175) @@ -733,7 +733,29 @@ <BR> </LI> <LI> + <?php + if (!isset($_POST['Submit'])) { +?> + <input type="checkbox" name="SelectFixedAssets"> + <A HREF="<?php echo $_SERVER['PHP_SELF'] . '?ViewTopic=FixedAssets'; ?>">Fixed Assets</A> <?php + } else { +?> + <A HREF="#Fixed Assets">Fixed Assets</A> +<?php + } +?> + <UL> + <LI>Fixed Assets Overview</LI> + <LI>Creating a Fixed Asset</LI> + <LI>Selecting Fixed Assets</LI> + <LI>Depreciation Run</LI> + <LI>Fixed Asset Schedule</LI> + </UL> + <BR> + </LI> + <LI> +<?php if (!isset($_POST['Submit'])) { ?> <input type="checkbox" name="SelectReportBuilder"> @@ -1030,6 +1052,9 @@ if ($_GET['ViewTopic'] == 'GeneralLedger' OR isset($_POST['SelectGeneralLedger'])) { include('ManualGeneralLedger.html'); } +if ($_GET['ViewTopic'] == 'FixedAssets' OR isset($_POST['SelectFixedAssets'])) { + include('ManualFixedAssets.html'); +} if ($_GET['ViewTopic'] == 'Manufacturing' OR isset($_POST['SelectManufacturing'])) { include('ManualManufacturing.html'); } Added: trunk/doc/Manual/ManualFixedAssets.html =================================================================== --- trunk/doc/Manual/ManualFixedAssets.html (rev 0) +++ trunk/doc/Manual/ManualFixedAssets.html 2010-11-30 08:45:07 UTC (rev 4175) @@ -0,0 +1,48 @@ +<!-- Help Begin: Fixed Assets --> +<br><br> +<a name="Fixed Assets"><font size="+3"><b>Fixed Assets</b></font></a> +<br><br> +<font size="+1"><b>Features Overview</b></font> +<br><br> +The Fixed Assets module allows for recording a database of the individual assets with integration back to the webERP general ledger. +<ul> +<li>Assets are assigned a unique id number</li> +<li>Any number of fixed asset categories can be defined eg. Plant, Equipment, Buildings etc.</li> +<li>Assets can be depreciated using either striaght line or diminishing value depreciation methods</li> +<li>Each asset can have it's own depreciation rate</li> +<li>Any number of fixed asset locations can be defined. Assets can only belong to one location. Assets can be listed by category and location so they can be readily identified in a fixed asset audit.</li> +<li>Depreciation calculation and posting run checks if previously run and defaults the run date to avoid duplicated depreciation runs.</li> +<li>A transaction log of depreciation, additions and disposals is maintained</li> +<li>Full fixed asset schedule of any date period range is possible</li> +<li>Fixed asset general ledger posting is performed based on the gl accounts in any number user defined fixed asset categories</li> +</ul> +<br><br> +<font size="+1"><b>Creating a New Fixed Asset</b></font> +<br><br> +The sequence of events in creating a new fixed asset is as follows: +<ul> +<li>Any number of fixed asset categories are defined - from Fixed Asset Module -> Fixed Asset Categories. These are the groupings of like assets e.g. Plant, IT equipment, Buildings, Land etc.</li> +<li>Fixed asset locations must be defined. These can be in a heirarchical manner e.g. "Head Office" may have a sub-location of "Server Room".</li> +<li>A fixed asset is created from the Fixed Assets module -> Add Fixed Asset. This process allows the description and a long description to be recorded, together with the asset's serial number or barcode, the category of fixed asset it belongs to and it's location in the business. The depreciation method and rate is also specified. At this point there is no cost (nor accumulated depreciation)associated with the asset</li> +<li>A purchase order is placed for the asset as a non-stock item. There is provision to enter the asset id of the asset into the purchase order. When the asset is received - the cost is posted to the general ledger account specified by the asset's category. It is also possible to add cost to existing assets in this way. Each cost added is recorded in the fixed asset transaction log so additions over a period can be identified easily.</li> +<li>Instead of entering a purchase order with the asset specified directly it is possible to enter a purchase invoice directly allocating the charges to any number of fixed assets. The supplier invoice form allows entry against fixed assets directly. All assets created - but with no cost will show in a select box - any of these can be selected or if the asset id is known it can be entered manually. In this way it is possible to add to existing assets. Depreciation will calculate on the new total cost of the asset (or book value if DV depreciation is being used).</li> +<li>If the asset is from capitalised stock, then it is possible to do a stock adjustment referencing an asset id - the cost of the stock from the current (standard or weighted average) cost is posted to the cost account of the fixed asset category of the asset selected. Stock general ledger accounts are also updated as usual. The asset addition is logged in much the same way as a purchase ordered fixed asset.</li> +<br><br> +<br><br> +<font size="+1"><b>Selecting A Fixed Asset</b></font> +<br><br> +From the main menu -> Fixed Assets Module tab -> Select Asset. There are options to select the asset category and the asset location and just look at assets for the given category and location. Alternatively the asset id can be entered or any part of the description. +<br><br> +Once and item is selected - the details of the asset shows including the cost and accumulated depreciation with all entered transactions reflected. +The cost and accumulated depreciation cannot be entered or altered manually. The asset cost will always come from the accounts payable module and depreciation will always come from the automatic calculation of depreciation. However, all other details of the asset can be modified when an asset is selected. The description, serial number, barcode, category, location, depreciation type and rate etc can all be modified at will. +<br><br> +<font size="+1"><b>Fixed Asset Depreciation Run</b></font> +<br><br> +The depreciation run must be run monthly to create the general ledger journals for depreciation at the rates and depreciation methods defined for the assets. In addition to the general ledger journals a log of the depreciation transactions is also created. The depreciation run checks the last month it was run and defaults to run for the following month ... in this way every time it is run it is self evident whether it has been run for the month under review. There is no functionality to reverse a depreciation run. +<br><br> +<font size="+1"><b>Fixed Asset Schedule</b></font> +<br><br> +The fixed asset schedule requires the entry of a starting date and an end date. The script can produce a pdf report, comma separated values for importing into a spreadsheet, or just view in html on screen. It shows the cost b/fwd at the start date, the total of any additions subsequent to the start date, the depreciation brought forward and the depreciation charged over the period, together with the carried forward cost, accumulated depreciation and net book value. + + +<!-- Help End: Fixed Assets --> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-28 18:27:34 UTC (rev 4174) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-30 08:45:07 UTC (rev 4175) @@ -496,8 +496,8 @@ transno INT NOT NULL , periodno SMALLINT( 6 ) NOT NULL , inputdate DATE NOT NULL , -cost DOUBLE NOT NULL , -depn DOUBLE NOT NULL , +fixedassettranstype varchar(8) NOT NULL , +amount DOUBLE NOT NULL , PRIMARY KEY ( id ) , INDEX ( assetid, transtype, transno ) , INDEX ( inputdate ), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-01 09:19:34
|
Revision: 4176 http://web-erp.svn.sourceforge.net/web-erp/?rev=4176&view=rev Author: daintree Date: 2010-12-01 09:19:27 +0000 (Wed, 01 Dec 2010) Log Message: ----------- Fixed Assets import script Modified Paths: -------------- trunk/FixedAssetItems.php trunk/Z_index.php trunk/doc/Change.log.html trunk/doc/INSTALL.txt trunk/sql/mysql/upgrade3.11.1-4.00.sql Added Paths: ----------- trunk/Z_ImportFixedAssets.php Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-11-30 08:45:07 UTC (rev 4175) +++ trunk/FixedAssetItems.php 2010-12-01 09:19:27 UTC (rev 4176) @@ -101,12 +101,15 @@ $Errors[$i] = 'AssetCategoryID'; $i++; } - if (!is_numeric($_POST['DepnRate']) OR $_POST['DepnRate']>100 OR $_POST['DepnRate']<1){ + if (!is_numeric($_POST['DepnRate']) OR $_POST['DepnRate']>100 OR $_POST['DepnRate']<0){ $InputError = 1; - prnMsg(_('The depreciation rate is expected to be a number between 1 and 100'),'error'); + prnMsg(_('The depreciation rate is expected to be a number between 0 and 100'),'error'); $Errors[$i] = 'DepnRate'; $i++; } + if ($_POST['DepnRate']>0 AND $_POST['DepnRate']<1){ + prnMsg(_('Numbers less than 1 are interpreted as less than 1%. The depreciation rate should be entered as a number between 0 and 100'),'warn'); + } if ($InputError !=1){ Added: trunk/Z_ImportFixedAssets.php =================================================================== --- trunk/Z_ImportFixedAssets.php (rev 0) +++ trunk/Z_ImportFixedAssets.php 2010-12-01 09:19:27 UTC (rev 4176) @@ -0,0 +1,312 @@ +<?php +/* $Id: $*/ +/* Script to import fixed assets into a specified period*/ + +$PageSecurity = 15; +include('includes/session.inc'); +$title = _('Import Fixed Assets'); +include('includes/header.inc'); +include('includes/SQL_CommonFunctions.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 + +$FieldNames = array( + 'Description', //0 + 'LongDescription', //1 + 'AssetCategoryID', //2 + 'SerialNo', //3 + 'BarCode', //4 + 'AssetLocationCode', //5 + 'Cost', //6 + 'AccumDepn', //7 + 'DepnType', //8 - SL or DV + 'DepnRate', //9 + 'DatePurchased' //10 +); + +if ($_FILES['SelectedAssetFile']['name']) { //start file processing + + //initialize + $InputError = false; + +/* + if ($_FILES['SelectedAssetFile']['type'] != 'text/csv') { + prnMsg (_('File has type') . ' ' . $_FILES['SelectedAssetFile']['type'] . ', ' . _('but only "text/csv" is allowed.'),'error'); + include('includes/footer.inc'); + exit; + } +*/ + //get file handle + $FileHandle = fopen($_FILES['SelectedAssetFile']['tmp_name'], 'r'); + + //get the header row + $HeaderRow = fgetcsv($FileHandle, 10000, ","); + + //check for correct number of fields + if ( count($HeaderRow) != count($FieldNames) ) { + prnMsg (_('File contains') . ' '. count($HeaderRow). ' ' . _('columns, expected') . ' '. count($FieldNames). '. ' . _('Study a downloaded template to see the format for the file'),'error'); + fclose($FileHandle); + include('includes/footer.inc'); + exit; + } + + //test header row field name and sequence + $i = 0; + foreach ($HeaderRow as $FieldName) { + if ( strtoupper($FieldName) != strtoupper($FieldNames[$i]) ) { + prnMsg (_('The selected file contains fields in the incorrect order ('. strtoupper($FieldName). ' != '. strtoupper($FieldNames[$i]). _('. Download a template and ensuer that fields are in the same sequence as the template.')),'error'); + fclose($FileHandle); + include('includes/footer.inc'); + exit; + } + $i++; + } + + //start database transaction + DB_Txn_Begin($db); + + //loop through file rows + $Row = 1; + while ( ($myrow = fgetcsv($FileHandle, 10000, ',')) !== FALSE ) { + + //check for correct number of fields + $FieldCount = count($myrow); + if ($FieldCount != count($FieldNames)){ + prnMsg (count($FieldNames) . ' ' . _('fields are required, but') . ' '. $FieldCount . ' ' . _('fields were received'),'error'); + fclose($FileHandle); + include('includes/footer.inc'); + exit; + } + + // cleanup the data (csv files often import with empty strings and such) + for ($i=0; $i<count($myrow);$i++) { + $myrow[$i] = trim($myrow[$i]); + switch ($i) { + case 0: + $Description = $myrow[$i]; + break; + case 1: + $LongDescription = $myrow[$i]; + break; + case 2: + $AssetCategoryID = $myrow[$i]; + break; + case 3: + $SerialNo = $myrow[$i]; + break; + case 4: + $BarCode = $myrow[$i]; + break; + case 5: + $AssetLocationCode = $myrow[$i]; + break; + case 6: + $Cost = $myrow[$i]; + break; + case 7: + $AccumDepn = $myrow[$i]; + break; + case 8: + $DepnType = strtoupper($myrow[$i]); + break; + case 9: + $DepnRate= $myrow[$i]; + break; + case 10: + $DatePurchased= $myrow[$i]; + break; + } //end switch + } //end loop around fields from import + + if (strlen($Description)==0 OR strlen($Description)>50){ + prnMsg('The description of the asset is expected to be more than 3 characters long and less than 50 characters long','error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Description:') . ' ' . $Description; + $InputError=true; + } + if (!is_numeric($DepnRate)){ + prnMsg(_('The depreciation rate is expected to be numeric'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Depreciation Rate:') . ' ' . $DepnRate; + $InputError=true; + }elseif ($DepnRate<0 OR $DepnRate>100){ + prnMsg(_('The depreciation rate is expected to be a number between 0 and 100'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' ._('Invalid Depreciation Rate:') . ' ' . $DepnRate; + $InputError=true; + } + if (!is_numeric($AccumDepn)){ + prnMsg(_('The accumulated depreciation is expected to be numeric'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Accumulated Depreciation:') . ' ' . $AccumDepn; + $InputError=true; + } elseif ($AccumDepn<0){ + prnMsg(_('The accumulated depreciation is expected to be either zero or a positive number'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Accumulated Depreciation:') . ' ' . $AccumDepn; + $InputError=true; + } + if (!is_numeric($Cost)){ + prnMsg(_('The cost is expected to be numeric'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Cost:') . ' ' . $Cost; + $InputError=true; + } elseif ($Cost<=0){ + prnMsg(_('The cost is expected to be a positive number'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid Cost:') . ' ' . $AccumDepn; + $InputError=true; + } + if ($DepnType !='SL' AND $DepnType!='DV'){ + prnMsg(_('The depreciation type must be either "SL" - Straight Line or "DV" - Diminishing Value'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid depreciation type:') . ' ' . $DepnType; + $InputError = true; + } + $result = DB_query('SELECT categoryid FROM fixedassetcategories WHERE categoryid="' . $AssetCategoryID . '"', $db); + if (DB_num_rows($result)==0){ + $InputError = true; + prnMsg(_('The asset category code entered must be exist in the assetcategories table'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid asset category:') . ' ' . $AssetCategoryID; + } + $result = DB_query('SELECT locationid FROM fixedassetlocations WHERE locationid="' . $AssetLocationCode . '"', $db); + if (DB_num_rows($result)==0){ + $InputError = true; + prnMsg(_('The asset location code entered must be exist in the asset locations table'),'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid asset location code:') . ' ' . $AssetLocationCode; + } + if (!Is_Date($DatePurchased)){ + $InputError = true; + prnMsg(_('The date purchased must be entered in the format:') . ' ' . $_SESSION['DefaultDateFormat'],'error'); + echo '<br>' . _('Row:') . $Row . ' - ' . _('Invalid date format:') . ' ' . $DatePurchased; + } + if ($DepnType=='DV'){ + $DepnType=1; + } else { + $DepnType=0; + } + + if ($InputError == false){ //no errors + + $TransNo = GetNextTransNo(49,$db); + $PeriodNo = GetPeriod(ConvertSQLDate($_POST['DateToEnter']),$db); + + //attempt to insert the stock item + $sql = "INSERT INTO fixedassets (description, + longdescription, + assetcategoryid, + serialno, + barcode, + assetlocation, + cost, + accumdepn, + depntype, + depnrate, + datepurchased) + VALUES ('" . $Description . "', + '" . $LongDescription . "', + '" . $AssetCategoryID . "', + '" . $SerialNo . "', + '" . $BarCode . "', + '" . $AssetLocationCode . "', + '" . $Cost . "', + '" . $AccumDepn . "', + '" . $DepnType . "', + '" . $DepnRate . "', + '" . FormatDateForSQL($DatePurchased) . "')"; + + $ErrMsg = _('The asset could not be added because'); + $DbgMsg = _('The SQL that was used to add the asset and failed was'); + $result = DB_query($sql,$db, $ErrMsg, $DbgMsg); + + if (DB_error_no($db) ==0) { //the insert of the new code worked so bang in the fixedassettrans records too + + + $AssetID = DB_Last_Insert_ID($db, 'fixedassets','assetid'); + $sql = "INSERT INTO fixedassettrans ( assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + fixedassettranstype, + amount) + VALUES ( '" . $AssetID . "', + '49', + '" . $TransNo . "', + '" . $_POST['DateToEnter'] . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + 'cost', + '" . $Cost . "')"; + + $ErrMsg = _('The transaction for the cost of the asset could not be added because'); + $DbgMsg = _('The SQL that was used to add the fixedasset trans record that failed was'); + $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + $sql = "INSERT INTO fixedassettrans ( assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + fixedassettranstype, + amount) + VALUES ( '" . $AssetID . "', + '49', + '" . $TransNo . "', + '" . $_POST['DateToEnter'] . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + 'depn', + '" . $AccumDepn . "')"; + + $ErrMsg = _('The transaction for the cost of the asset could not be added because'); + $DbgMsg = _('The SQL that was used to add the fixedasset trans record that failed was'); + $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if (DB_error_no($db) ==0) { + prnMsg( _('Inserted the new asset:') . ' ' . $Description,'info'); + } + } + } // there were errors checking the row so no inserts + $Row++; + } + + if ($InputError == 1) { //exited loop with errors so rollback + prnMsg(_('Failed on row '. $Row. '. Batch import has been rolled back.'),'error'); + DB_Txn_Rollback($db); + } else { //all good so commit data transaction + DB_Txn_Commit($db); + prnMsg( _('Batch Import of') .' ' . $_FILES['SelectedAssetFile']['name'] . ' '. _('has been completed. All assets in the file have been committed to the database.'),'success'); + } + + fclose($FileHandle); + +} elseif ( isset($_POST['gettemplate']) || isset($_GET['gettemplate']) ) { //download an import template + + echo '<br /><br /><br />"'. implode('","',$FieldNames). '"<br /><br /><br />'; + +} else { //show file upload form + + echo ' + <br /> + <a href="Z_ImportFixedAssets.php?gettemplate=1">Get Import Template</a> + <br /> + <br /> + '; + echo '<form enctype="multipart/form-data" action="Z_ImportFixedAssets.php" method=post>'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '">'; + + echo '<input type="hidden" name="MAX_FILE_SIZE" value="1000000">'; + echo '<table class="selection"> + <tr><td>' . _('Select Date to Upload B/Fwd Assets To:') . '</td> + <td><select name="DateToEnter">'; + $PeriodsResult = DB_query('SELECT lastdate_in_period FROM periods ORDER BY periodno',$db); + while ($PeriodRow = DB_fetch_row($PeriodsResult)){ + echo '<option value="' . $PeriodRow[0] . '">' . ConvertSQLDate($PeriodRow[0]) . '</option>'; + } + echo '</select></td></tr>'; + echo '<tr><td>' . _('Fixed Assets Upload file:') . '</td><td><input name="SelectedAssetFile" type="file"></tr></table> + <input type="submit" VALUE="' . _('Send File') . '"> + </form>'; + +} + + +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/Z_index.php =================================================================== --- trunk/Z_index.php 2010-11-30 08:45:07 UTC (rev 4175) +++ trunk/Z_index.php 2010-12-01 09:19:27 UTC (rev 4176) @@ -24,7 +24,9 @@ echo "<p><a href='$rootpath/Z_DataExport.php?" . SID . "'>" . _('Data Export Options') . '</a>'; echo "<p><a href='$rootpath/Z_GetStockImage.php?" . SID . "'>" . _('Image Manipulation Utility') . '</a>'; echo "<p><a href='$rootpath/Z_ImportStocks.php?" . SID . "'>" . _('Import Stock Items from .csv') . '</a>'; + echo "<p><a href='$rootpath/Z_ImportFixedAssets.php?" . SID . "'>" . _('Import Fixed Assets from .csv file') . '</a>'; echo "<p><a href='$rootpath/Z_CreateCompanyTemplateFile.php?" . SID . "'>" . _('Create new company template SQL file and submit to webERP') . '</a>'; + echo '<br><br><hr><br>' . _('The stuff below is really quite dangerous!'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-30 08:45:07 UTC (rev 4175) +++ trunk/doc/Change.log.html 2010-12-01 09:19:27 UTC (rev 4176) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>30/11/10 Phil: Changed table structure of new fixedassettrans and modified upgrade script - those who already ran that bit will need to change the table again. Modified fixed asset scripts again. New fixed assets manual</p> <p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> <p>28/11/10 Tim: OutstandingGRNs.php - Only show when the invoiced qty is less than the GRN qty</p> <p>28/11/10 Phil: All fixed asset scripts SupplierInvoice.php SupplierCredit.php SuppFixedAssetChgs.php - adding fixed assets directly from invoice charges - and reversing additions with credit notes. Also FixedAssetRegister.php report to print PDF or export CSV of fixed assets now includes date range depreciation and b/fwd cost b/fwd accum depn and c/fwd cost and accum depn - and NBV Modified: trunk/doc/INSTALL.txt =================================================================== --- trunk/doc/INSTALL.txt 2010-11-30 08:45:07 UTC (rev 4175) +++ trunk/doc/INSTALL.txt 2010-12-01 09:19:27 UTC (rev 4176) @@ -6,8 +6,10 @@ A php upgrade script is provided for versions from 3.05 that applies the database changes required to move from the previous version to the newer version - this script also updates any data as required to work with the new version scripts. Simply point your browser to Z_Upgrade3.06-3.07.php (for an upgrade between 3.06 and 3.07 - similar naming convention applies to subsequent releases) and follow the prompts. If you are upgrading through several versions eg. from 3.05 to 3.08 then you must run each successive Z_UpgradeX.XX-X.XY.php script in sequence. -If the database must be updated manually (as it must for versions prior to 3.05), the SQL scripts are included under webERP/sql/mysql/ to update an existing mysql webERP database to the current version. The upgrade script no longer assumes the weberp database is called webERP. If using the mysql command line client then each upgrade SQL script must be edited to enter the name of the database to upgrade by adding a line +If the database must be updated manually (as it must for versions prior to 3.05): +The SQL scripts are included under webERP/sql/mysql/ to update an existing mysql webERP database to the current version. The upgrade script no longer assumes the weberp database is called webERP. If using the mysql command line client then each upgrade SQL script must be edited to enter the name of the database to upgrade by adding a line + USE mydatabase; at the beginning of the script. Where mydatabase is the name of the company database that you are using in your webERP installation. @@ -28,7 +30,7 @@ ***************New Installations*************** -Automated Installation +There is an automated Installation script to Extract the webERP archive under your web-root directory (folder). Browse to the @@ -36,11 +38,13 @@ Where "yourhost" is the host web-server. The install should start automatically. It is most important to ensure that the web-server can write to the hosting files and persmissions may need to be altered through cpanel or other means. They should be changed back once the installation is completed. +The install script checks for the appropriate permissions and will not even attempt to install unless the web-server has the necessary write access to the files. + Manual Installation -Read on below if you cannot use the installer to set up your installation. +Read on below if you cannot use the installer to set up your installation for some reason or you simply wish to understand what is going on when the installer runs. Note: It is worth printing this document off and checking off the steps as you go. Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-30 08:45:07 UTC (rev 4175) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-01 09:19:27 UTC (rev 4176) @@ -508,4 +508,6 @@ ALTER TABLE purchorderdetails ADD COLUMN assetid int NOT NULL DEFAULT 0; +INSERT INTO `systypes` (`typeid` ,`typename` ,`typeno`) VALUES ('49', 'Import Fixed Assets', '1'); + UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-03 06:32:18
|
Revision: 4178 http://web-erp.svn.sourceforge.net/web-erp/?rev=4178&view=rev Author: daintree Date: 2010-12-03 06:32:12 +0000 (Fri, 03 Dec 2010) Log Message: ----------- Depreciation calc sql fix Modified Paths: -------------- trunk/FixedAssetDepreciation.php trunk/doc/Change.log.html trunk/doc/Manual/ManualContributors.html Modified: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php 2010-12-03 06:16:45 UTC (rev 4177) +++ trunk/FixedAssetDepreciation.php 2010-12-03 06:32:12 UTC (rev 4178) @@ -48,8 +48,8 @@ fixedassetcategories.accumdepnact, fixedassetcategories.depnact, fixedassetcategories.categorydescription, - SUM(fixedassettrans.cost) AS costtotal, - SUM(fixedassettrans.depn) AS depnbfwd + SUM(CASE WHEN fixedassettrans.fixedassettranstype="cost" THEN fixedassettrans.amount ELSE 0 END) AS costtotal, + SUM(CASE WHEN fixedassettrans.fixedassettranstype="depn" THEN fixedassettrans.amount ELSE 0 END) AS depnbfwd FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-03 06:16:45 UTC (rev 4177) +++ trunk/doc/Change.log.html 2010-12-03 06:32:12 UTC (rev 4178) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>3/12/10 Matt Elbrecht : Estonian translation <p>30/11/10 Phil: Changed table structure of new fixedassettrans and modified upgrade script - those who already ran that bit will need to change the table again. Modified fixed asset scripts again. New fixed assets manual</p> <p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> <p>28/11/10 Tim: OutstandingGRNs.php - Only show when the invoiced qty is less than the GRN qty</p> Modified: trunk/doc/Manual/ManualContributors.html =================================================================== --- trunk/doc/Manual/ManualContributors.html 2010-12-03 06:16:45 UTC (rev 4177) +++ trunk/doc/Manual/ManualContributors.html 2010-12-03 06:32:12 UTC (rev 4178) @@ -130,6 +130,8 @@ <br><br> Janusz Dobrowolski - Polish <br><br> +Matt Elbrecht - Estonian +<br><br> Igor Felix - Portuguese Brazilian <br><br> Karel van der Esch - Dutch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-05 09:32:09
|
Revision: 4179 http://web-erp.svn.sourceforge.net/web-erp/?rev=4179&view=rev Author: daintree Date: 2010-12-05 09:32:02 +0000 (Sun, 05 Dec 2010) Log Message: ----------- 5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required. Modified Paths: -------------- trunk/PO_Header.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/PO_Header.php 2010-12-05 09:32:02 UTC (rev 4179) @@ -69,7 +69,6 @@ } if (isset($_POST['UpdateStat']) AND $_POST['UpdateStat']!='') { - /*The cancel button on the header screen - to delete order */ $OK_to_updstat = 1; $OldStatus=$_SESSION['PO'.$identifier]->Stat; $NewStatus=$_POST['Stat']; @@ -277,7 +276,7 @@ if (isset($_POST['CancelOrder']) AND $_POST['CancelOrder']!='') { /*The cancel button on the header screen - to delete order */ - $OK_to_delete = 1; //assume this in the first instance + $OK_to_delete = 1; //alway assume the best to start with ... until we find out otherwise ... if(!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder']!=0) { /* need to check that not already dispatched or invoiced @@ -294,35 +293,151 @@ } if ($OK_to_delete==1){ - $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; - $EmailResult=DB_query($EmailSQL, $db); - $EmailRow=DB_fetch_array($EmailResult); - $StatusComment=date($_SESSION['DefaultDateFormat']). - ' - Order Cancelled by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['statcommentscomplete']; - unset($_SESSION['PO'.$identifier]->LineItems); - unset($_SESSION['PO'.$identifier]); - $_SESSION['PO'.$identifier] = new PurchOrder; - $_SESSION['RequireSupplierSelection'] = 1; if($_SESSION['ExistingOrder']!=0){ + $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; + $EmailResult=DB_query($EmailSQL, $db); + $EmailRow=DB_fetch_array($EmailResult); + $StatusComment=date($_SESSION['DefaultDateFormat']). ' - ' . _('Order Cancelled by:') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['statcommentscomplete']; + + /* Copy the deleted orders to the purchorder_deleted table so there is an audit trail of who ordered what */ + $sql = "INSERT INTO purchorders_deleted ( orderno, + supplierno, + comments, + orddate, + rate, + initiator, + requisitionno, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + suppliercontact, + supptel, + contact, + version, + revised, + deliveryby, + status, + stat_comment, + deliverydate, + paymentterms) + SELECT orderno, + supplierno, + comments, + orddate, + rate, + initiator, + requisitionno, + intostocklocation, + deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + suppdeladdress1, + suppdeladdress2, + suppdeladdress3, + suppdeladdress4, + suppdeladdress5, + suppdeladdress6, + suppliercontact, + supptel, + contact, + version, + revised, + deliveryby, + '" . PurchOrder::STATUS_CANCELLED . "', + '" . $StatusComment . "', + deliverydate, + paymentterms + FROM purchorders + WHERE orderno ='" . $_SESSION['ExistingOrder'] . "'"; + + $ErrMsg = _('The purchase order header record could not be inserted into the database because'); + $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - $sql = "UPDATE purchorderdetails - SET completed=1 - WHERE purchorderdetails.orderno ='" . $_SESSION['ExistingOrder'] ."'"; + /*Insert the purchase order detail records */ + $sql = "INSERT INTO purchorderdetails_deleted ( orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + uom, + suppliers_partno, + subtotal_amount, + package, + pcunit, + nw, + gw, + cuft, + total_quantity, + total_amount, + assetid ) + SELECT orderno, + itemcode, + deliverydate, + itemdescription, + glcode, + unitprice, + quantityord, + shiptref, + jobref, + itemno, + uom, + suppliers_partno, + subtotal_amount, + package, + pcunit, + nw, + gw, + cuft, + total_quantity, + total_amount, + assetid + FROM purchorderdetails + WHERE orderno='" . $_SESSION['ExistingOrder'] . "'"; + + $ErrMsg =_('The deleted purchase order detail records could not be inserted into the database because'); + $DbgMsg =_('The SQL statement used to insert the deleted purchase order detail records and failed was'); + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + /*Now we have a copy to record the trail - we can delete this order from the database */ + + $sql = "DELETE FROM purchorderdetails + WHERE purchorderdetails.orderno ='" . $_SESSION['ExistingOrder'] ."'"; $ErrMsg = _('The order detail lines could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); - $sql="UPDATE purchorders - SET status='".PurchOrder::STATUS_CANCELLED."', - stat_comment='".$StatusComment."' - WHERE orderno='".$_SESSION['ExistingOrder']."'"; - + $sql="DELETE FROM purchorders + WHERE orderno='".$_SESSION['ExistingOrder']."'"; $ErrMsg = _('The order header could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); - prnMsg( _('Order number').' '.$_SESSION['ExistingOrder'].' '._('has been cancelled'), 'success'); + prnMsg( _('Order number').' '.$_SESSION['ExistingOrder'].' '._('has been deleted'), 'success'); + unset($_SESSION['ExistingOrder']); + unset($_SESSION['PO'.$identifier]->LineItems); unset($_SESSION['PO'.$identifier]); - unset($_SESSION['ExistingOrder']); - } else { + $_SESSION['PO'.$identifier] = new PurchOrder; + $_SESSION['RequireSupplierSelection'] = 1; + } else { //it's not an existing order currently so just clear the session variable to delete it // Re-Direct to right place unset($_SESSION['PO'.$identifier]); prnMsg( _('The creation of the new order has been cancelled'), 'success'); @@ -541,20 +656,20 @@ } else { $_POST['Select'] = $_SESSION['PO'.$identifier]->SupplierID; $sql = "SELECT suppliers.suppname, - suppliers.currcode, - suppliers.paymentterms, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.phn, - suppliers.port - FROM suppliers INNER JOIN currencies - ON suppliers.currcode=currencies.currabrev - WHERE supplierid='" . $_POST['Select'] . "'"; - + suppliers.currcode, + suppliers.paymentterms, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.phn, + suppliers.port + FROM suppliers INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE supplierid='" . $_POST['Select'] . "'"; + $ErrMsg = _('The supplier record of the supplier selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/doc/Change.log.html 2010-12-05 09:32:02 UTC (rev 4179) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required. <p>3/12/10 Matt Elbrecht : Estonian translation <p>30/11/10 Phil: Changed table structure of new fixedassettrans and modified upgrade script - those who already ran that bit will need to change the table again. Modified fixed asset scripts again. New fixed assets manual</p> <p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-03 06:32:12 UTC (rev 4178) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-05 09:32:02 UTC (rev 4179) @@ -510,4 +510,86 @@ INSERT INTO `systypes` (`typeid` ,`typename` ,`typeno`) VALUES ('49', 'Import Fixed Assets', '1'); +CREATE TABLE `purchorderdetails_deleted` ( +`podetailitem` int(11) NOT NULL, +`orderno` int(11) NOT NULL DEFAULT '0', +`itemcode` varchar(20) NOT NULL DEFAULT '', +`deliverydate` date NOT NULL DEFAULT '0000-00-00', +`itemdescription` varchar(100) NOT NULL DEFAULT '', +`glcode` int(11) NOT NULL DEFAULT '0', +`qtyinvoiced` double NOT NULL DEFAULT '0', +`unitprice` double NOT NULL DEFAULT '0', +`actprice` double NOT NULL DEFAULT '0', +`stdcostunit` double NOT NULL DEFAULT '0', +`quantityord` double NOT NULL DEFAULT '0', +`quantityrecd` double NOT NULL DEFAULT '0', +`shiptref` int(11) NOT NULL DEFAULT '0', +`jobref` varchar(20) NOT NULL DEFAULT '', +`completed` tinyint(4) NOT NULL DEFAULT '0', +`itemno` varchar(50) NOT NULL DEFAULT '', +`uom` varchar(50) NOT NULL DEFAULT '', +`subtotal_amount` varchar(50) NOT NULL DEFAULT '', +`package` varchar(100) NOT NULL DEFAULT '', +`pcunit` varchar(50) NOT NULL DEFAULT '', +`nw` varchar(50) NOT NULL DEFAULT '', +`suppliers_partno` varchar(50) NOT NULL DEFAULT '', +`gw` varchar(50) NOT NULL DEFAULT '', +`cuft` varchar(50) NOT NULL DEFAULT '', +`total_quantity` varchar(50) NOT NULL DEFAULT '', +`total_amount` varchar(50) NOT NULL DEFAULT '', +`assetid` int NOT NULL DEFAULT 0, +PRIMARY KEY (`podetailitem`), +KEY `DeliveryDate` (`deliverydate`), +KEY `GLCode` (`glcode`), +KEY `ItemCode` (`itemcode`), +KEY `JobRef` (`jobref`), +KEY `OrderNo` (`orderno`), +KEY `ShiptRef` (`shiptref`), +KEY `Completed` (`completed`) +) ENGINE=InnoDB; + + +CREATE TABLE `purchorders_deleted` ( +`orderno` int(11) NOT NULL, +`supplierno` varchar(10) NOT NULL DEFAULT '', +`comments` longblob, +`orddate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', +`rate` double NOT NULL DEFAULT '1', +`dateprinted` datetime DEFAULT NULL, +`allowprint` tinyint(4) NOT NULL DEFAULT '1', +`initiator` varchar(10) DEFAULT NULL, +`requisitionno` varchar(15) DEFAULT NULL, +`intostocklocation` varchar(5) NOT NULL DEFAULT '', +`deladd1` varchar(40) NOT NULL DEFAULT '', +`deladd2` varchar(40) NOT NULL DEFAULT '', +`deladd3` varchar(40) NOT NULL DEFAULT '', +`deladd4` varchar(40) NOT NULL DEFAULT '', +`deladd5` varchar(20) NOT NULL DEFAULT '', +`deladd6` varchar(15) NOT NULL DEFAULT '', +`tel` varchar(15) NOT NULL DEFAULT '', +`suppdeladdress1` varchar(40) NOT NULL DEFAULT '', +`suppdeladdress2` varchar(40) NOT NULL DEFAULT '', +`suppdeladdress3` varchar(40) NOT NULL DEFAULT '', +`suppdeladdress4` varchar(40) NOT NULL DEFAULT '', +`suppdeladdress5` varchar(20) NOT NULL DEFAULT '', +`suppdeladdress6` varchar(15) NOT NULL DEFAULT '', +`suppliercontact` varchar(30) NOT NULL DEFAULT '', +`supptel` varchar(30) NOT NULL DEFAULT '', +`contact` varchar(30) NOT NULL DEFAULT '', +`version` decimal(3,2) NOT NULL DEFAULT '1.00', +`revised` date NOT NULL DEFAULT '0000-00-00', +`realorderno` varchar(16) NOT NULL DEFAULT '', +`deliveryby` varchar(100) NOT NULL DEFAULT '', +`deliverydate` date NOT NULL DEFAULT '0000-00-00', +`status` varchar(12) NOT NULL DEFAULT '', +`stat_comment` text NOT NULL, +`paymentterms` char(2) NOT NULL DEFAULT '', +`port` varchar(40) NOT NULL DEFAULT '', +PRIMARY KEY (`orderno`), +KEY `OrdDate` (`orddate`), +KEY `SupplierNo` (`supplierno`), +KEY `IntoStockLocation` (`intostocklocation`), +KEY `AllowPrintPO` (`allowprint`) +) ENGINE=InnoDB; + UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-08 05:35:25
|
Revision: 4180 http://web-erp.svn.sourceforge.net/web-erp/?rev=4180&view=rev Author: daintree Date: 2010-12-08 05:35:19 +0000 (Wed, 08 Dec 2010) Log Message: ----------- James Murray SuppPaymentRun.php fix Modified Paths: -------------- trunk/PO_Header.php trunk/SuppPaymentRun.php trunk/doc/Change.log.html Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-05 09:32:02 UTC (rev 4179) +++ trunk/PO_Header.php 2010-12-08 05:35:19 UTC (rev 4180) @@ -79,9 +79,9 @@ if ($OldStatus!=$NewStatus) { /* assume this in the first instance */ $authsql="SELECT authlevel - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; + FROM purchorderauth + WHERE userid='".$_SESSION['UserID']."' + AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; $authresult=DB_query($authsql,$db); $myrow=DB_fetch_array($authresult); Modified: trunk/SuppPaymentRun.php =================================================================== --- trunk/SuppPaymentRun.php 2010-12-05 09:32:02 UTC (rev 4179) +++ trunk/SuppPaymentRun.php 2010-12-08 05:35:19 UTC (rev 4180) @@ -113,7 +113,7 @@ include('includes/footer.inc'); exit; } - if (DB_num_rows($TranResult)==0) { + if (DB_num_rows($TransResult)==0) { $title = _('Payment Run -Problem Report'); include('includes/header.inc'); prnMsg(_('There are no outstanding supplier invoices to pay'),'info'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-05 09:32:02 UTC (rev 4179) +++ trunk/doc/Change.log.html 2010-12-08 05:35:19 UTC (rev 4180) @@ -1,7 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> -<p></p> -<p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required. -<p>3/12/10 Matt Elbrecht : Estonian translation +<p>/</p> +<p>8/12/10 James Murray: fixed bug in SuppPaymentRun.php - was not showing anything as the test to see if there was anything to see was using a non-existant result set!</p> +<p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required.</p> +<p>3/12/10 Matt Elbrecht : Estonian translation</p> <p>30/11/10 Phil: Changed table structure of new fixedassettrans and modified upgrade script - those who already ran that bit will need to change the table again. Modified fixed asset scripts again. New fixed assets manual</p> <p>28/11/10 Exsson: CreditStatus.php - Fix bug in sql statement</p> <p>28/11/10 Tim: OutstandingGRNs.php - Only show when the invoiced qty is less than the GRN qty</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-09 07:22:57
|
Revision: 4181 http://web-erp.svn.sourceforge.net/web-erp/?rev=4181&view=rev Author: daintree Date: 2010-12-09 06:59:34 +0000 (Thu, 09 Dec 2010) Log Message: ----------- fix supplier invoice and credit due date calculations based on invoice/credit date not todays date Modified Paths: -------------- trunk/SupplierCredit.php trunk/SupplierInvoice.php trunk/doc/Change.log.html Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2010-12-08 05:35:19 UTC (rev 4180) +++ trunk/SupplierCredit.php 2010-12-09 06:59:34 UTC (rev 4181) @@ -150,11 +150,15 @@ $_SESSION['SuppTrans']->TranDate = $_POST['TranDate']; if (substr( $_SESSION['SuppTrans']->Terms,0,1)=='1') { /*Its a day in the following month when due */ - $_SESSION['SuppTrans']->DueDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m')+1, substr( $_SESSION['SuppTrans']->Terms,1),Date('y'))); + $DayInFollowingMonth = (int) substr( $_SESSION['SuppTrans']->Terms,1); + $DaysBeforeDue = 0; } else { /*Use the Days Before Due to add to the invoice date */ - $_SESSION['SuppTrans']->DueDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m'),Date('d') + (int) substr( $_SESSION['SuppTrans']->Terms,1),Date('y'))); + $DayInFollowingMonth = 0; + $DaysBeforeDue = (int) substr( $_SESSION['SuppTrans']->Terms,1); } - + + $_SESSION['SuppTrans']->DueDate = CalcDueDate($_SESSION['SuppTrans']->TranDate, $DayInFollowingMonth, $DaysBeforeDue); + $_SESSION['SuppTrans']->SuppReference = $_POST['SuppReference']; /*if (!isset($_POST['OvAmount'])) { Modified: trunk/SupplierInvoice.php =================================================================== --- trunk/SupplierInvoice.php 2010-12-08 05:35:19 UTC (rev 4180) +++ trunk/SupplierInvoice.php 2010-12-09 06:59:34 UTC (rev 4181) @@ -133,11 +133,15 @@ $_SESSION['SuppTrans']->TranDate = $_POST['TranDate']; if (substr( $_SESSION['SuppTrans']->Terms,0,1)=='1') { /*Its a day in the following month when due */ - $_SESSION['SuppTrans']->DueDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m')+1, substr( $_SESSION['SuppTrans']->Terms,1),Date('y'))); + $DayInFollowingMonth = (int) substr( $_SESSION['SuppTrans']->Terms,1); + $DaysBeforeDue = 0; } else { /*Use the Days Before Due to add to the invoice date */ - $_SESSION['SuppTrans']->DueDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m'),Date('d') + (int) substr( $_SESSION['SuppTrans']->Terms,1),Date('y'))); + $DayInFollowingMonth = 0; + $DaysBeforeDue = (int) substr( $_SESSION['SuppTrans']->Terms,1); } - + + $_SESSION['SuppTrans']->DueDate = CalcDueDate($_SESSION['SuppTrans']->TranDate, $DayInFollowingMonth, $DaysBeforeDue); + $_SESSION['SuppTrans']->SuppReference = $_POST['SuppReference']; if ( $_SESSION['SuppTrans']->GLLink_Creditors == 1){ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-08 05:35:19 UTC (rev 4180) +++ trunk/doc/Change.log.html 2010-12-09 06:59:34 UTC (rev 4181) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>9/12/10 James Murray: highlighted a bug in SupplierInvoice.php (and also in SupplierCredit.php) where the due date of the invoice/credit was not calculated correctly based on the terms - it was picking up the current date rather than the invoice/credit date. Now fixed</p> <p>8/12/10 James Murray: fixed bug in SuppPaymentRun.php - was not showing anything as the test to see if there was anything to see was using a non-existant result set!</p> <p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required.</p> <p>3/12/10 Matt Elbrecht : Estonian translation</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-11 00:03:25
|
Revision: 4182 http://web-erp.svn.sourceforge.net/web-erp/?rev=4182&view=rev Author: daintree Date: 2010-12-11 00:03:18 +0000 (Sat, 11 Dec 2010) Log Message: ----------- Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made Modified Paths: -------------- trunk/GoodsReceived.php trunk/PDFStockCheckComparison.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/GoodsReceived.php 2010-12-11 00:03:18 UTC (rev 4182) @@ -582,7 +582,7 @@ transdate, periodno, inputdate, - fixedassettranstype + fixedassettranstype, amount) VALUES ('" . $OrderLine->AssetID . "', 25, Modified: trunk/PDFStockCheckComparison.php =================================================================== --- trunk/PDFStockCheckComparison.php 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/PDFStockCheckComparison.php 2010-12-11 00:03:18 UTC (rev 4182) @@ -23,12 +23,13 @@ if ($_POST['ReportOrClose']=='ReportAndClose'){ $sql = "SELECT stockcheckfreeze.stockid, - stockcheckfreeze.loccode, - qoh, - materialcost+labourcost+overheadcost AS standardcost - FROM stockmaster INNER JOIN stockcheckfreeze - ON stockcheckfreeze.stockid=stockmaster.stockid - ORDER BY stockcheckfreeze.loccode, stockcheckfreeze.stockid"; + stockcheckfreeze.loccode, + qoh, + materialcost+labourcost+overheadcost AS standardcost, + stockcheckfreeze.stockcheckdate + FROM stockmaster INNER JOIN stockcheckfreeze + ON stockcheckfreeze.stockid=stockmaster.stockid + ORDER BY stockcheckfreeze.loccode, stockcheckfreeze.stockid"; $StockChecks = DB_query($sql, $db,'','',false,false); if (DB_error_no($db) !=0) { @@ -44,18 +45,16 @@ exit; } - $PeriodNo = GetPeriod (Date($_SESSION['DefaultDateFormat']), $db); - $SQLAdjustmentDate = FormatDateForSQL(Date($_SESSION['DefaultDateFormat'])); $AdjustmentNumber = GetNextTransNo(17,$db); while ($myrow = DB_fetch_array($StockChecks)){ $sql = "SELECT SUM(stockcounts.qtycounted) AS totcounted, - COUNT(stockcounts.stockid) AS noofcounts - FROM stockcounts - WHERE stockcounts.stockid='" . $myrow['stockid'] . "' - AND stockcounts.loccode='" . $myrow['loccode'] . "'"; - + COUNT(stockcounts.stockid) AS noofcounts + FROM stockcounts + WHERE stockcounts.stockid='" . $myrow['stockid'] . "' + AND stockcounts.loccode='" . $myrow['loccode'] . "'"; + $StockCounts = DB_query($sql, $db); if (DB_error_no($db) !=0) { $title = _('Stock Count Comparison') . ' - ' . _('Problem Report') . '....'; @@ -81,14 +80,12 @@ if ($StockQtyDifference !=0){ // only adjust stock if there is an adjustment to make!! - $SQL = 'BEGIN'; - $Result = DB_query($SQL,$db); - + DB_Txn_Begin($db); // Need to get the current location quantity will need it later for the stock movement $SQL="SELECT locstock.quantity - FROM locstock - WHERE locstock.stockid='" . $myrow['stockid'] . "' - AND loccode= '" . $myrow['loccode'] . "'"; + FROM locstock + WHERE locstock.stockid='" . $myrow['stockid'] . "' + AND loccode= '" . $myrow['loccode'] . "'"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result)==1){ @@ -98,7 +95,9 @@ // There must actually be some error this should never happen $QtyOnHandPrior = 0; } - + + $PeriodNo = GetPeriod (ConvertSQLDate($myrow['stockcheckdate']), $db); + $SQL = "INSERT INTO stockmoves (stockid, type, transno, @@ -112,9 +111,9 @@ 17, '" . $AdjustmentNumber . "', '" . $myrow['loccode'] . "', - '" . $SQLAdjustmentDate . "', + '" . Date('Y-m-d') . "', '" . $PeriodNo . "', - '" . _('Inventory Check') . "', + '" . _('Inventory Check') . ' - ' . ConvertSQLDate($myrow['stockcheckdate']) . "', '" . $StockQtyDifference . "', '" . ($QtyOnHandPrior + $StockQtyDifference) . "' )"; @@ -124,9 +123,9 @@ $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); $SQL = "UPDATE locstock - SET quantity = quantity + '" . $StockQtyDifference . "' - WHERE stockid='" . $myrow['stockid'] . "' - AND loccode='" . $myrow['loccode'] . "'"; + SET quantity = quantity + '" . $StockQtyDifference . "' + WHERE stockid='" . $myrow['stockid'] . "' + AND loccode='" . $myrow['loccode'] . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because'); $DbgMsg = _('The following SQL to update the stock record was used'); $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); @@ -146,7 +145,7 @@ narrative) VALUES (17, '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', + '" . $myrow['stockcheckdate'] . "', '" . $PeriodNo . "', '" . $StockGLCodes['adjglact'] . "', '" . $myrow['standardcost'] * -($StockQtyDifference) . "', @@ -165,16 +164,15 @@ narrative) VALUES (17, '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', + '" . $myrow['stockcheckdate'] . "', '" . $PeriodNo . "', '" . $StockGLCodes['stockact'] . "', - '" . $myrow['standardcost'] * $StockQtyDifference . ", '" . $myrow['stockid'] . " x " . $StockQtyDifference . " @ " . $myrow['standardcost'] . " - " . _('Inventory Check') . "')"; + '" . $myrow['standardcost'] * $StockQtyDifference . "', + '" . $myrow['stockid'] . " x " . $StockQtyDifference . " @ " . $myrow['standardcost'] . " - " . _('Inventory Check') . "')"; $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); } //END INSERT GL TRANS - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Unable to COMMIT transaction while adjusting stock in StockCheckAdjustmet report'); - $SQL = "COMMIT"; - $Result = DB_query($SQL,$db, $ErrMsg,'',true); + DB_Txn_Commit($db); } // end if $StockQtyDifference !=0 Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/doc/Change.log.html 2010-12-11 00:03:18 UTC (rev 4182) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>11/12/10 Phil: Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made</p> <p>9/12/10 James Murray: highlighted a bug in SupplierInvoice.php (and also in SupplierCredit.php) where the due date of the invoice/credit was not calculated correctly based on the terms - it was picking up the current date rather than the invoice/credit date. Now fixed</p> <p>8/12/10 James Murray: fixed bug in SuppPaymentRun.php - was not showing anything as the test to see if there was anything to see was using a non-existant result set!</p> <p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required.</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-11 00:03:18 UTC (rev 4182) @@ -432,7 +432,7 @@ ALTER TABLE `reports` ADD `col20width` INT( 3 ) NOT NULL DEFAULT '25' AFTER `col19width` ; -ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ''; +ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) NOT NULL DEFAULT ''; ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-14 09:30:27
|
Revision: 4183 http://web-erp.svn.sourceforge.net/web-erp/?rev=4183&view=rev Author: daintree Date: 2010-12-14 09:30:20 +0000 (Tue, 14 Dec 2010) Log Message: ----------- PO stuff Modified Paths: -------------- trunk/PO_Header.php trunk/PO_Items.php trunk/PO_SelectOSPurchOrder.php trunk/doc/Change.log.html trunk/includes/DefinePOClass.php trunk/includes/PO_ReadInOrder.inc Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/PO_Header.php 2010-12-14 09:30:20 UTC (rev 4183) @@ -6,18 +6,7 @@ include('includes/DefinePOClass.php'); include('includes/session.inc'); -/* Dummy for gettext */ -$sDummy = _('New Order') . - _('Pending') . - _('Authorised') . - _('Rejected') . - _('Cancelled') . - _('Printed') . - _('Completed'); - -unset($sDummy); - if (isset($_GET['ModifyOrderNumber'])) { $title = _('Modify Purchase Order') . ' ' . $_GET['ModifyOrderNumber']; } else { @@ -56,9 +45,9 @@ if (isset($_POST['Select']) and empty($_POST['SupplierContact'])) { $sql = "SELECT contact - FROM suppliercontacts - WHERE supplierid='". $_POST['Select'] ."'"; - + FROM suppliercontacts + WHERE supplierid='". $_POST['Select'] ."'"; + $SuppCoResult = DB_query($sql,$db); if (DB_num_rows($SuppCoResult)>0) { $myrow = DB_fetch_row($SuppCoResult); @@ -68,38 +57,39 @@ } } -if (isset($_POST['UpdateStat']) AND $_POST['UpdateStat']!='') { - $OK_to_updstat = 1; - $OldStatus=$_SESSION['PO'.$identifier]->Stat; - $NewStatus=$_POST['Stat']; +if ($_POST['Status']=='NewOrder'){ + $_POST['UpdateStatus']='Yes please'; + $_POST['Status'] = 'Pending'; +} + +if ((isset($_POST['UpdateStatus']) AND $_POST['UpdateStatus']!='') ) { + $OKToUpdateStatus = 1; $EmailSQL='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; $EmailResult=DB_query($EmailSQL, $db); $EmailRow=DB_fetch_array($EmailResult); - if ($OldStatus!=$NewStatus) { - /* assume this in the first instance */ - $authsql="SELECT authlevel + if ($_SESSION['PO'.$identifier]->Status !=$_POST['Status']) { //the old status != new status + + $AuthSQL ="SELECT authlevel FROM purchorderauth WHERE userid='".$_SESSION['UserID']."' AND currabrev='".$_SESSION['PO'.$identifier]->CurrCode."'"; - $authresult=DB_query($authsql,$db); - $myrow=DB_fetch_array($authresult); + $AuthResult=DB_query($AuthSQL,$db); + $myrow=DB_fetch_array($AuthResult); $AuthorityLevel=$myrow['authlevel']; $OrderTotal=$_SESSION['PO'.$identifier]->Order_Value(); - if ($_POST['StatComments']!='') { - $_POST['StatComments']=' - '.$_POST['StatComments']; + if ($_POST['StatusComments']!='') { + $_POST['StatusComments']=' - '.$_POST['StatusComments']; } - if ($NewStatus == PurchOrder::STATUS_AUTHORISED) { - if ($AuthorityLevel>$OrderTotal) { - $StatusComment= date($_SESSION['DefaultDateFormat']).' - Authorised by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. - '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; - $_SESSION['PO'.$identifier]->StatComments=$StatusComment; - $_SESSION['PO'.$identifier]->Stat=$NewStatus; + if ($_POST['Status'] == 'Authorised') { + if ($AuthorityLevel > $OrderTotal) { + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']) . ' - ' . _('Authorised by') . ' <a href="mailto:' . $EmailRow['email'] . '">'. $_SESSION['UserID']. '</a>' . $_POST['StatusComments'] . '<br>' . $_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; $_SESSION['PO'.$identifier]->AllowPrintPO=1; } else { - $OK_to_updstat=0; + $OKToUpdateStatus=0; prnMsg( _('You do not have permission to authorise this purchase order').'.<br>'. _('This order is for').' '. $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. _('You can only authorise up to').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. @@ -107,29 +97,16 @@ } } - if ($NewStatus == PurchOrder::STATUS_CANCELLED and $OK_to_updstat==1) { - if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { - $StatusComment=date($_SESSION['DefaultDateFormat']).' - Cancelled by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. - '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; - $_SESSION['PO'.$identifier]->StatComments=$StatusComment; - $_SESSION['PO'.$identifier]->Stat=$NewStatus; - } else { - $OK_to_updstat=0; - prnMsg( _('You do not have permission to cancel this purchase order').'.<br>'. _('This order is for').' '. - $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. - _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. - _('If you think this is a mistake please contact the systems administrator') , 'warn'); - } - } - if ($NewStatus == PurchOrder::STATUS_REJECTED and $OK_to_updstat==1) { + if ($_POST['Status'] == 'Rejected' AND $OKToUpdateStatus==1) { + + //need to copy the lines to purchorderdetails_deleted + if ($AuthorityLevel>$OrderTotal) { - $StatusComment=date($_SESSION['DefaultDateFormat']).' - Rejected by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. - '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; - $_SESSION['PO'.$identifier]->StatComments=$StatusComment; - $_SESSION['PO'.$identifier]->Stat=$NewStatus; + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Rejected by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; } else { - $OK_to_updstat=0; + $OKToUpdateStatus=0; prnMsg( _('You do not have permission to reject this purchase order').'.<br>'. _('This order is for').' '. $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. @@ -137,14 +114,13 @@ } } - if ($NewStatus == PurchOrder::STATUS_PENDING and $OK_to_updstat==1) { + if ($_POST['Status'] == 'Pending' and $OKToUpdateStatus==1) { if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { - $StatusComment=date($_SESSION['DefaultDateFormat']).' - Returned to Pending status by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. - '</a>'.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; - $_SESSION['PO'.$identifier]->StatComments=$StatusComment; - $_SESSION['PO'.$identifier]->Stat=$NewStatus; + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Returned to Pending status by') . ' <a href="mailto:'. $EmailRow['email'] . '">'.$_SESSION['UserID']. + '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; } else { - $OK_to_updstat=0; + $OKToUpdateStatus=0; prnMsg( _('You do not have permission to change the status of this purchase order').'.<br>'. _('This order is for').' '. $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. @@ -152,20 +128,16 @@ } } - if ($OK_to_updstat==1){ -// unset($_SESSION['PO'.$identifier]->LineItems); -// unset($_SESSION['PO'.$identifier]); -// $_SESSION['PO'.$identifier] = new PurchOrder; -// $_SESSION['RequireSupplierSelection'] = 1; + if ($OKToUpdateStatus==1){ if($_SESSION['ExistingOrder']!=0){ - if ($_SESSION['PO'.$identifier]->Stat==PurchOrder::STATUS_AUTHORISED) { + if ($_SESSION['PO'.$identifier]->Status=='Authorised') { $AllowPrint=1; } else { $AllowPrint=0; } - $SQL = "UPDATE purchorders SET status='" . $_POST['Stat']. "', + $SQL = "UPDATE purchorders SET status='" . $_POST['Status']. "', stat_comment='" . $StatusComment ."', allowprint='".$AllowPrint."' WHERE purchorders.orderno ='" . $_SESSION['ExistingOrder'] ."'"; @@ -234,7 +206,7 @@ $_SESSION['PO'.$identifier]->ExRate = $_POST['ExRate']; $_SESSION['PO'.$identifier]->Comments = $_POST['Comments']; $_SESSION['PO'.$identifier]->DeliveryBy = $_POST['DeliveryBy']; - $_SESSION['PO'.$identifier]->StatusMessage = $_POST['StatComments']; + $_SESSION['PO'.$identifier]->StatusMessage = $_POST['StatusComments']; $_SESSION['PO'.$identifier]->PaymentTerms = $_POST['PaymentTerms']; $_SESSION['PO'.$identifier]->Contact = $_POST['Contact']; $_SESSION['PO'.$identifier]->Tel = $_POST['Tel']; @@ -249,8 +221,7 @@ WHERE purchorders.orderno='" . $_SESSION['PO'.$identifier]->OrderNo ."'"; $ErrMsg = _('An error occurred updating the purchase order to allow reprints') . '. ' . _('The error says'); - $updateResult = DB_query($sql,$db,$ErrMsg); - + $UpdateResult = DB_query($sql,$db,$ErrMsg); } else { $_POST['RePrint'] = 0; } @@ -298,7 +269,7 @@ $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; $EmailResult=DB_query($EmailSQL, $db); $EmailRow=DB_fetch_array($EmailResult); - $StatusComment=date($_SESSION['DefaultDateFormat']). ' - ' . _('Order Cancelled by:') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['statcommentscomplete']; + $StatusComment=date($_SESSION['DefaultDateFormat']). ' - ' . _('Order Cancelled by:') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['StatusCommentsComplete']; /* Copy the deleted orders to the purchorder_deleted table so there is an audit trail of who ordered what */ $sql = "INSERT INTO purchorders_deleted ( orderno, @@ -473,19 +444,16 @@ if (isset($_POST['ChangeSupplier'])) { -/* change supplier only allowed with appropriate permissions - - * button only displayed to modify is AccessLevel >10 - * (see below)*/ - if ($_SESSION['PO'.$identifier]->Stat == PurchOrder::STATUS_PENDING and $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator) { + if ($_SESSION['PO'.$identifier]->Status == PurchOrder::STATUS_PENDING and $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator) { if ($_SESSION['PO'.$identifier]->Any_Already_Received()==0){ $EmailSQL='SELECT email FROM www_users WHERE userid="'.$_SESSION['PO'.$identifier]->Initiator.'"'; $EmailResult=DB_query($EmailSQL, $db); $EmailRow=DB_fetch_array($EmailResult); $_SESSION['RequireSupplierSelection']=1; - $_SESSION['PO'.$identifier]->Stat = PurchOrder::STATUS_PENDING; - $StatusComment=date($_SESSION['DefaultDateFormat']).' - Supplier changed by <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. - '</a> - '.$_POST['StatComments'].'<br>'.$_POST['statcommentscomplete']; - $_SESSION['PO'.$identifier]->StatComments=$StatusComment; + $_SESSION['PO'.$identifier]->Status = PurchOrder::STATUS_PENDING; + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Supplier changed by') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID']. + '</a> - '.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->StatusComments=$StatusComment; } else { echo '<br><br>'; prnMsg(_('Cannot modify the supplier of the order once some of the order has been received'),'warn'); @@ -493,45 +461,44 @@ } } -$msg=''; if (isset($_POST['SearchSuppliers'])){ if (strlen($_POST['Keywords'])>0 AND strlen($_SESSION['PO'.$identifier]->SupplierID)>0) { - $msg=_('Supplier name keywords have been used in preference to the supplier code extract entered'); + prnMsg(_('Supplier name keywords have been used in preference to the supplier code extract entered'),'warn'); } if ($_POST['Keywords']=='' AND $_POST['SuppCode']=='') { - $msg=_('At least one Supplier Name keyword OR an extract of a Supplier Code must be entered for the search'); + prnMsg(_('At least one Supplier Name keyword OR an extract of a Supplier Code must be entered for the search'),'error'); } else { if (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT suppliers.supplierid, - suppliers.suppname, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.currcode - FROM suppliers - WHERE suppliers.suppname LIKE '". $SearchString ."' - ORDER BY suppliers.suppname"; + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + WHERE suppliers.suppname LIKE '". $SearchString ."' + ORDER BY suppliers.suppname"; } elseif (strlen($_POST['SuppCode'])>0){ $SQL = "SELECT suppliers.supplierid, - suppliers.suppname, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.currcode - FROM suppliers - WHERE suppliers.supplierid LIKE '%" . $_POST['SuppCode'] . "%' - ORDER BY suppliers.supplierid"; + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + WHERE suppliers.supplierid LIKE '%" . $_POST['SuppCode'] . "%' + ORDER BY suppliers.supplierid"; } $ErrMsg = _('The searched supplier records requested cannot be retrieved because'); @@ -548,11 +515,10 @@ } /*end of if search for supplier codes/names */ -// added by Hudson if((!isset($_POST['SearchSuppliers']) or $_POST['SearchSuppliers']=='' ) AND (isset($_SESSION['PO'.$identifier]->SupplierID) AND $_SESSION['PO'.$identifier]->SupplierID!='')){ - /*The session variables are set but the form variables have been lost + /*The session variables are set but the form variables could have been lost * need to restore the form variables from the session */ $_POST['SupplierID']=$_SESSION['PO'.$identifier]->SupplierID; $_POST['SupplierName']=$_SESSION['PO'.$identifier]->SupplierName; @@ -578,46 +544,41 @@ /* will only be true if page called from supplier selection form * or set because only one supplier record returned from a search - * so parse the $Select string into supplier code and branch code */ - $sql="SELECT currcode FROM suppliers where supplierid='".$_POST['Select']."'"; - $result=DB_query($sql,$db); - $myrow=DB_fetch_array($result); - $SupplierCurrCode=$myrow['currcode']; + */ - $authsql="SELECT cancreate - FROM purchorderauth - WHERE userid='".$_SESSION['UserID']."' - AND currabrev='".$SupplierCurrCode."'"; - - $authresult=DB_query($authsql,$db); - $sql = "SELECT suppliers.suppname, - suppliers.currcode, - currencies.rate, - suppliers.paymentterms, - suppliers.address1, - suppliers.address2, - suppliers.address3, - suppliers.address4, - suppliers.address5, - suppliers.address6, - suppliers.phn, - suppliers.port - FROM suppliers INNER JOIN currencies - ON suppliers.currcode=currencies.currabrev - WHERE supplierid='" . $_POST['Select'] . "'"; - + suppliers.currcode, + currencies.rate, + suppliers.paymentterms, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.phn, + suppliers.port + FROM suppliers INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE supplierid='" . $_POST['Select'] . "'"; + $ErrMsg = _('The supplier record of the supplier selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); - $myrow = DB_fetch_row($result); - $SupplierName = $myrow[0]; + $myrow = DB_fetch_array($result); // added for suppliers lookup fields - if (($authmyrow=DB_fetch_array($authresult) and $authmyrow[0]==0 ) ) { - $_POST['SupplierName'] = $myrow[0]; - $_POST['CurrCode'] = $myrow[1]; + $AuthSql="SELECT cancreate + FROM purchorderauth + WHERE userid='". $_SESSION['UserID'] . "' + AND currabrev='". $myrow['currcode'] . "'"; + + $AuthResult=DB_query($AuthSql,$db); + + if (($AuthRow=DB_fetch_array($AuthResult) and $AuthRow['cancreate']==0 ) ) { + $_POST['SupplierName'] = $myrow['suppname']; + $_POST['CurrCode'] = $myrow['currcode']; $_POST['ExRate'] = $myrow[2]; $_POST['PaymentTerms']= $myrow[3]; $_POST['SuppDelAdd1'] = $myrow[4]; @@ -644,9 +605,7 @@ $_SESSION['PO'.$identifier]->SuppTel = $_POST['SuppTel']; $_SESSION['PO'.$identifier]->Port = $_POST['Port']; } else { - prnMsg( _('You do not have the authority to raise Purchase Orders for '). - $SupplierName.'. '._('Please Consult your system administrator for more information').'. ' - ._('You can setup authorisations ').'<a href=PO_AuthorisationLevels.php>'._('here').'.</a>', 'warn'); + prnMsg( _('You do not have the authority to raise Purchase Orders for') . ' ' . $myrow['suppname'] .'. ' . _('Please Consult your system administrator for more information.') . '<br>' . _('You can setup authorisations'). ' ' . '<a href="PO_AuthorisationLevels.php">' . _('here') . '</a>', 'warn'); include('includes/footer.inc'); exit; } @@ -675,10 +634,8 @@ $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); - $myrow = DB_fetch_row($result); - // added for suppliers lookup fields if (!isset($_SESSION['PO'.$identifier])) { $_POST['SupplierName'] = $myrow[0]; @@ -711,8 +668,6 @@ } } -// MADE THE SUPPILERS BECOME SELECT MENU NOT BY SEARCHING By Hudson @2008/6/30 - // part of step 1 if ($_SESSION['RequireSupplierSelection'] ==1 OR !isset($_SESSION['PO'.$identifier]->SupplierID) OR $_SESSION['PO'.$identifier]->SupplierID=='' ) { @@ -721,9 +676,6 @@ _('Purchase Order') . '" alt="">' . ' ' . _('Purchase Order: Select Supplier') . ''; echo "<form action='" . $_SERVER['PHP_SELF'] . '?' . SID . "identifier=".$identifier."' method=post name='choosesupplier'>"; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - if (strlen($msg)>1){ - prnMsg($msg,'warn'); - } echo '<table cellpadding=3 colspan=4 class=selection> <tr> @@ -743,12 +695,12 @@ echo '<br><table cellpadding=3 colspan=7 class=selection>'; - $tableheader = "<tr> - <th>" . _('Code') . "</th> - <th>" . _('Supplier Name') . "</th> - <th>" . _('Address') . "</th> - <th>" . _('Currency') . '</th> - </tr>'; + $tableheader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Supplier Name') . '</th> + <th>' . _('Address') . '</th> + <th>' . _('Currency') . '</th> + </tr>'; echo $tableheader; @@ -788,16 +740,14 @@ } else { /* everything below here only do if a supplier is selected */ - echo "<form name='form1' action='" . $_SERVER['PHP_SELF'] . '?' . SID . "identifier=".$identifier. "' method=post>"; + echo '<form name="form1" action="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier=' . $identifier . '" method=post>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -// Be careful not made confused by orderno and realorderno -// $orderno = previous_id("purchorders","orderno"); -// $_SESSION['PO'.$identifier]->OrderNo2 = $orderno; echo '<p class="page_title_text"> - <img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Purchase Order') . '" alt=""> - ' . $_SESSION['PO'.$identifier]->SupplierName . ' - ' . _('All amounts stated in') . ' - ' . $_SESSION['PO'.$identifier]->CurrCode . '<br />'; + <img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Purchase Order') . '" alt=""> + ' . $_SESSION['PO'.$identifier]->SupplierName . ' - ' . _('All amounts stated in') . ' + ' . $_SESSION['PO'.$identifier]->CurrCode . '<br />'; + if ($_SESSION['ExistingOrder']) { echo _(' Modify Purchase Order Number') . ' ' . $_SESSION['PO'.$identifier]->OrderNo; @@ -808,18 +758,14 @@ if (isset($Purch_Item)) { prnMsg(_('Purchase Item(s) with this code') . ': ' . $Purch_Item,'info'); - /** - * Now go ahead to PO_Items.php - * with NewItem=$Purch_Item - */ - echo "<div class='centre'>"; + echo '<div class="centre">'; echo '<br><table class="table_index"><tr><td class="menu_group_item">'; /* the link */ - echo '<li><a href="'.$rootpath.'/PO_Items.php?' . SID . 'NewItem=' . $Purch_Item . "&identifier=".$identifier. '">' . + echo '<li><a href="'.$rootpath.'/PO_Items.php?' . SID . 'NewItem=' . $Purch_Item . '&identifier=' . $identifier . '">' . _('Enter Line Item to this purchase order') . '</a></li>'; /**/ - echo "</td></tr></table></div><br>"; + echo '</td></tr></table></div><br>'; if (isset($_GET['Quantity'])) { $Qty=$_GET['Quantity']; @@ -879,6 +825,7 @@ 0, $Qty, $Qty*$PurchItemRow['price']); + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/PO_Items.php?' . SID . 'identifier='.$identifier. "'>"; } @@ -889,26 +836,25 @@ /* The session variables are set but the form variables have * been lost -- * need to restore the form variables from the session */ - $_POST['StkLocation']=$_SESSION['PO'.$identifier]->Location; + $_POST['StkLocation']=$_SESSION['PO'.$identifier]->Location; $_POST['SupplierContact']=$_SESSION['PO'.$identifier]->SupplierContact; - $_POST['DelAdd1']=$_SESSION['PO'.$identifier]->DelAdd1; - $_POST['DelAdd2']=$_SESSION['PO'.$identifier]->DelAdd2; - $_POST['DelAdd3']=$_SESSION['PO'.$identifier]->DelAdd3; - $_POST['DelAdd4']=$_SESSION['PO'.$identifier]->DelAdd4; - $_POST['DelAdd5']=$_SESSION['PO'.$identifier]->DelAdd5; - $_POST['DelAdd6']=$_SESSION['PO'.$identifier]->DelAdd6; - $_POST['Initiator']=$_SESSION['PO'.$identifier]->Initiator; - $_POST['Requisition']=$_SESSION['PO'.$identifier]->RequisitionNo; - $_POST['Version']=$_SESSION['PO'.$identifier]->Version; - $_POST['DeliveryDate']=$_SESSION['PO'.$identifier]->DeliveryDate; - $_POST['Revised']=$_SESSION['PO'.$identifier]->Revised; - $_POST['ExRate']=$_SESSION['PO'.$identifier]->ExRate; - $_POST['Comments']=$_SESSION['PO'.$identifier]->Comments; - $_POST['DeliveryBy']=$_SESSION['PO'.$identifier]->DeliveryBy; - $_POST['PaymentTerms']=$_SESSION['PO'.$identifier]->PaymentTerms; + $_POST['DelAdd1']=$_SESSION['PO'.$identifier]->DelAdd1; + $_POST['DelAdd2']=$_SESSION['PO'.$identifier]->DelAdd2; + $_POST['DelAdd3']=$_SESSION['PO'.$identifier]->DelAdd3; + $_POST['DelAdd4']=$_SESSION['PO'.$identifier]->DelAdd4; + $_POST['DelAdd5']=$_SESSION['PO'.$identifier]->DelAdd5; + $_POST['DelAdd6']=$_SESSION['PO'.$identifier]->DelAdd6; + $_POST['Initiator']=$_SESSION['PO'.$identifier]->Initiator; + $_POST['Requisition']=$_SESSION['PO'.$identifier]->RequisitionNo; + $_POST['Version']=$_SESSION['PO'.$identifier]->Version; + $_POST['DeliveryDate']=$_SESSION['PO'.$identifier]->DeliveryDate; + $_POST['Revised']=$_SESSION['PO'.$identifier]->Revised; + $_POST['ExRate']=$_SESSION['PO'.$identifier]->ExRate; + $_POST['Comments']=$_SESSION['PO'.$identifier]->Comments; + $_POST['DeliveryBy']=$_SESSION['PO'.$identifier]->DeliveryBy; + $_POST['PaymentTerms']=$_SESSION['PO'.$identifier]->PaymentTerms; } -// move apart by Hudson echo '<br><table colspan=1 width=80%> <tr> <th><font color=blue size=4><b>' . _('Order Initiation Details') . '</b></font></th> @@ -978,75 +924,61 @@ } if ($_SESSION['PO'.$identifier]->AllowPrintPO==0 AND empty($_POST['RePrint'])){ - echo '<tr><td>' . _('Allow Reprint') . ":</td><td><select name='RePrint' onChange='ReloadForm(form1.AllowRePrint)'><option selected value=0>" . - _('No') . "<option value=1>" . _('Yes') . '</select></td>'; + echo '<tr><td>' . _('Allow Reprint') . ':</td> + <td><select name="RePrint" onChange="ReloadForm(form1.AllowRePrint)"> + <option selected value=0>' . _('No') . '</option> + <option value=1>' . _('Yes') . '</option> + </select></td>'; echo '<td><input type=submit name="AllowRePrint" value="Update"></td></tr>'; } elseif ($Printed) { - echo "<tr><td colspan=2><a target='_blank' href='$rootpath/PO_PDFPurchOrder.php?" . - SID . "OrderNo=" . $_SESSION['ExistingOrder'] . "&identifier=".$identifier. "'>" . _('Reprint Now') . '</a></td></tr>'; + echo '<tr><td colspan=2><a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . 'OrderNo=' . $_SESSION['ExistingOrder'] . '&identifier='.$identifier. '">' . _('Reprint Now') . '</a></td></tr>'; } echo '</table>'; echo '<td style="width:50%" valign=top><table class=selection width=100%>'; - if($_SESSION['ExistingOrder'] != 0 and $_SESSION['PO'.$identifier]->Stat == PurchOrder::STATUS_PRINTED){ - echo '<tr><td><a href="' .$rootpath . "/GoodsReceived.php?" . SID . "&PONumber=" . - $_SESSION['PO'.$identifier]->OrderNo . "&identifier=".$identifier.'">'._('Receive this order').'</a></td></tr>'; + + if($_SESSION['ExistingOrder'] != 0 AND $_SESSION['PO'.$identifier]->Status == 'Printed'){ + + echo '<tr><td><a href="' . $rootpath . '/GoodsReceived.php?' . SID . '&PONumber=' . + $_SESSION['PO'.$identifier]->OrderNo . '&identifier=' . $identifier . '">'._('Receive this order').'</a></td></tr>'; } - echo '<td>' . _('Status') . ' : </td><td><select name=Stat onChange="ReloadForm(form1.UpdateStat)">'; - - switch ($_SESSION['PO'.$identifier]->Stat) { - case '': - $StatusList = array(PurchOrder::STATUS_NEW_ORDER); - break; - case PurchOrder::STATUS_PENDING: - $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, - PurchOrder::STATUS_REJECTED, PurchOrder::STATUS_CANCELLED); - break; - case PurchOrder::STATUS_AUTHORISED: - $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, - PurchOrder::STATUS_CANCELLED); - break; - case PurchOrder::STATUS_REJECTED: - $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, - PurchOrder::STATUS_REJECTED, PurchOrder::STATUS_CANCELLED); - break; - case PurchOrder::STATUS_CANCELLED: - $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_CANCELLED); - break; - case PurchOrder::STATUS_PRINTED: - $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_PRINTED, - PurchOrder::STATUS_CANCELLED); - break; - case PurchOrder::STATUS_COMPLITED: - $StatusList = array(PurchOrder::STATUS_COMPLITED); - break; - default: - $StatusList = array(PurchOrder::STATUS_NEW_ORDER, PurchOrder::STATUS_PENDING, - PurchOrder::STATUS_AUTHORISED, PurchOrder::STATUS_REJECTED, - PurchOrder::STATUS_CANCELLED); - break; - } - - foreach ($StatusList as $Status) { - if ($_SESSION['PO'.$identifier]->Stat == $Status){ - echo '<option selected value="' . $Status . '">' . _($Status) . '</option>'; - } else { - echo '<option value="'.$Status.'">' . _($Status) . '</option>'; + if ($_SESSION['PO'.$identifier]->Status==''){ //then its a new order + echo '<input type="hidden" name="Status" value="NewOrder">'; + echo '<tr><td>' . _('New Purchase Order') . '</td></tr>'; + } else { + echo '<tr><td>' . _('Status') . ' : </td><td><select name="Status" onChange="ReloadForm(form1.UpdateStatus)">'; + + switch ($_SESSION['PO'.$identifier]->Status) { + case 'Pending': + echo '<option selected value="Pending">' . _('Pending') . '</option> + <option value="Authorised">' . _('Authorised') . '</option> + <option value="Rejected">' . _('Rejected') . '</option>'; + break; + case 'Authorised': + echo '<option value="Pending">' . _('Pending') . '</option> + <option selected value="Authorised">' . _('Authorised') . '</option>'; + break; + case 'Printed': + echo '<option selected value="Pending">' . _('Pending') . '</option> + <option value="Printed">' . _('Printed') . '</option>'; + break; + case 'Completed': + echo '<option selected value="Completed">' . _('Completed') . '</option>'; + break; } - } - echo '</select></td></tr>'; - echo '<tr><td>' . _('Status Comment'); - echo ":</td><td><input type=text name='StatComments' size=50></td></tr><tr><td colspan=2><b>" . html_entity_decode($_SESSION['PO'.$identifier]->StatComments) .'</b></td></tr>'; - echo "<input type=hidden name='statcommentscomplete' value='".$_SESSION['PO'.$identifier]->StatComments."'>"; - echo '<tr><td><input type="submit" name=UpdateStat value="' . _("Status Update") .'"></td>'; - - echo "<td><input type='submit' name='CancelOrder' value='" . _("Cancel and Delete Order") . "'></td></tr>"; + echo '</select></td></tr>'; + + echo '<tr><td>' . _('Status Comment') . ':</td> + <td><input type=text name="StatusComments" size=50></td></tr> + <tr><td colspan=2><b>' . html_entity_decode($_SESSION['PO'.$identifier]->StatusComments) .'</b></td></tr>'; + echo '<input type=hidden name="StatusCommentsComplete" value="' . $_SESSION['PO'.$identifier]->StatusComments .'">'; + echo '<tr><td><input type="submit" name="UpdateStatus" value="' . _('Status Update') .'"></td>'; + } //end its not a new order + echo '<td><input type="submit" name="CancelOrder" value="' . _('Cancel and Delete Order') . '"></td></tr>'; echo '</table></td>'; -// end of move by Hudson - echo '<table width=80%> <tr> <th><font color=blue size=4><b>' . _('Warehouse Info') . '</b></font></th> @@ -1059,17 +991,17 @@ echo '<table class=selection width=100%><tr><td>' . _('Warehouse') . ':</td> <td><select name=StkLocation onChange="ReloadForm(form1.LookupDeliveryAddress)">'; - $sql = "SELECT loccode, - locationname - FROM locations"; + $sql = 'SELECT loccode, + locationname + FROM locations'; $LocnResult = DB_query($sql,$db); while ($LocnRow=DB_fetch_array($LocnResult)){ if (isset($_POST['StkLocation']) and ($_POST['StkLocation'] == $LocnRow['loccode'] OR ($_POST['StkLocation']=='' AND $LocnRow['loccode']==$_SESSION['UserStockLocation']))){ - echo "<option selected value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname']; + echo '<option selected value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>'; } else { - echo "<option value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname']; + echo '<option value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>'; } } @@ -1085,15 +1017,15 @@ $_POST['StkLocation'] = $_SESSION['UserStockLocation']; $sql = "SELECT deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - contact - FROM locations - WHERE loccode='" . $_POST['StkLocation'] . "'"; + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + contact + FROM locations + WHERE loccode='" . $_POST['StkLocation'] . "'"; $LocnAddrResult = DB_query($sql,$db); if (DB_num_rows($LocnAddrResult)==1){ @@ -1128,15 +1060,15 @@ } elseif (isset($_POST['LookupDeliveryAddress'])){ $sql = "SELECT deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - contact - FROM locations - WHERE loccode='" . $_POST['StkLocation'] . "'"; + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + contact + FROM locations + WHERE loccode='" . $_POST['StkLocation'] . "'"; $LocnAddrResult = DB_query($sql,$db); if (DB_num_rows($LocnAddrResult)==1){ @@ -1307,11 +1239,11 @@ echo '</td></tr></table><br>'; /* end of main table */ // discard change supplier submit buttom - // kept enter line item but remove Delete button by Hudson 11/16,and added status field + echo "<div class='centre'> <input type=submit name='EnterLines' value='" . _('Enter Line Items') . "'></div>"; - // Delete PO when necessrary + } /*end of if supplier selected */ echo '</form>'; Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/PO_Items.php 2010-12-14 09:30:20 UTC (rev 4183) @@ -33,7 +33,7 @@ } // add new request here 08-09-26 -if (isset($_POST['StockID2']) && $_GET['Edit']=='') { +if (isset($_POST['StockID2']) AND $_GET['Edit']=='') { /* If a stock item is selected and a purchdata record * exists for it then find that record. */ @@ -95,15 +95,15 @@ /*If all clear then proceed to update the database */ if ($InputError!=1){ - $emailsql="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; - $emailresult=DB_query($emailsql, $db); - $emailrow=DB_fetch_array($emailresult); + $EmailSql="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; + $EmailResult=DB_query($EmailSql, $db); + $EmailRow=DB_fetch_array($EmailResult); $result = DB_Txn_Begin($db); if ($_SESSION['ExistingOrder']==0){ /*its a new order to be inserted */ - $StatusComment=date($_SESSION['DefaultDateFormat']).' - Order Created by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['PO'.$identifier]->Initiator. + $StatusComment=date($_SESSION['DefaultDateFormat']).' - ' . _('Order Created by') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['PO'.$identifier]->Initiator. '</a> - '.$_SESSION['PO'.$identifier]->StatusMessage.'<br>'; /*Get the order number */ @@ -168,7 +168,7 @@ '" . $_SESSION['PO'.$identifier]->Version . "', '" . Date('Y-m-d') . "', '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', - '" . 'Pending' . "', + 'Pending', '" . $StatusComment . "', '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', '" . $_SESSION['PO'.$identifier]->PaymentTerms. "' @@ -264,7 +264,7 @@ contact='" . $_SESSION['PO'.$identifier]->Contact . "', paymentterms='" . $_SESSION['PO'.$identifier]->PaymentTerms . "', allowprint='" . $_SESSION['PO'.$identifier]->AllowPrintPO . "', - status = '" . PurchOrder::STATUS_PENDING . "' + status = 'Pending' WHERE orderno = '" . $_SESSION['PO'.$identifier]->OrderNo ."'"; $ErrMsg = _('The purchase order could not be updated because'); Modified: trunk/PO_SelectOSPurchOrder.php =================================================================== --- trunk/PO_SelectOSPurchOrder.php 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/PO_SelectOSPurchOrder.php 2010-12-14 09:30:20 UTC (rev 4183) @@ -422,64 +422,54 @@ } $ModifyPage = $rootpath . '/PO_Header.php?' . SID . '&ModifyOrderNumber=' . $myrow['orderno']; - if ($myrow['status'] == PurchOrder::STATUS_PRINTED) { + if ($myrow['status'] == 'Printed') { $ReceiveOrder = '<a href="'.$rootpath . '/GoodsReceived.php?' . SID . '&PONumber=' . $myrow['orderno'].'">'. _('Receive').'</a>'; } else { $ReceiveOrder = _('Receive'); } - if ($myrow["allowprint"] == 1){ + if ($myrow['allowprint'] == 1){ $PrintPurchOrder = '<a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '">' . _('Print Now') . '</a>'; } else { // not open yet // $PrintPurchOrder = '<font color=GREY>' . _('Printed') . '</font>'; } - if ($myrow['status'] == PurchOrder::STATUS_AUTHORISED) { - $PrintPurchOrder = ' - <a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=2"> + if ($myrow['status'] == 'Authorisied') { + $PrintPurchOrder = '<a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=2"> ' . _('Print') . ' </a>'; } else { - $PrintPurchOrder = _(PurchOrder::STATUS_PRINTED); + $PrintPurchOrder = _('Printed'); } - $PrintPurchOrder2 = ' - <a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=1"> - ' . _('Show') . ' - </a>'; + + $PrintPurchOrder2 = '<a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=1">' . _('Show') . '</a>'; + $s2 = '<a target="_blank" href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . '&OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=1">' . $myrow['realorderno']. '</a>'; $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); $FormatedOrderValue = number_format($myrow['ordervalue'],2); -// the tailed two column -// <td>%s</font></td> -// <td class=number>%s</font></td> -// $myrow['requisitionno'], -// $myrow['initiator']); -// '</td><td class="tableheader">' . _('Requisition') . -// '</td><td class="tableheader">' . _('Initiator') . -// <td><a href='%s'>" . _('Receive') . "</a></td> - echo "<td>".$myrow["orderno"]."</font></td> - <td>".$FormatedOrderDate."</td> - <td>".$myrow['initiator']."</td> - <td>".$myrow['suppname']."</td> - <td>".$myrow['currcode']."</td>"; + echo '<td>' . $myrow['orderno'] . '</td> + <td>' . $FormatedOrderDate . '</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>"._($myrow['status'])."</td> - <td><a href='".$ModifyPage."'>Modify</a></td> - <td>".$PrintPurchOrder."</td> - <td>".$ReceiveOrder."</td> - </tr>"; + echo '<td>'._($myrow['status']).'</td> + <td><a href="'.$ModifyPage.'">' . _('Modify') . '</a></td> + <td>'.$PrintPurchOrder.'</td> + <td>'.$ReceiveOrder.'</td> + </tr>'; //end of page full new headings if } //end of while loop echo '</table>'; } -echo "<script>defaultControl(document.forms[0].StockCode);</script>"; +echo '<script>defaultControl(document.forms[0].StockCode);</script>'; echo '</form>'; include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/doc/Change.log.html 2010-12-14 09:30:20 UTC (rev 4183) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>14/12/10 Phil: modify purchasing scripts for coding conventions/readability</p> <p>11/12/10 Phil: Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made</p> <p>9/12/10 James Murray: highlighted a bug in SupplierInvoice.php (and also in SupplierCredit.php) where the due date of the invoice/credit was not calculated correctly based on the terms - it was picking up the current date rather than the invoice/credit date. Now fixed</p> <p>8/12/10 James Murray: fixed bug in SuppPaymentRun.php - was not showing anything as the test to see if there was anything to see was using a non-existant result set!</p> Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/includes/DefinePOClass.php 2010-12-14 09:30:20 UTC (rev 4183) @@ -6,19 +6,11 @@ Class PurchOrder { - const STATUS_NEW_ORDER = 'New Order'; - const STATUS_PENDING = 'Pending'; - const STATUS_AUTHORISED = 'Authorised'; - const STATUS_REJECTED = 'Rejected'; - const STATUS_CANCELLED = 'Cancelled'; - const STATUS_PRINTED = 'Printed'; - const STATUS_COMPLITED = 'Completed'; - var $LineItems; /*array of objects of class LineDetails using the product id as the pointer */ var $CurrCode; var $ExRate; var $Initiator; - var $deliverydate; + var $DeliveryDate; var $RequisitionNo; var $DelAdd1; var $DelAdd2; @@ -48,8 +40,8 @@ var $Total; var $GLLink; /*Is the GL link to stock activated only checked when order initiated or reading in for modification */ var $Version; - var $Stat; - var $StatComments; + var $Status; + var $StatusComments; var $AllowPrintPO; var $Revised; var $DeliveryBy; @@ -82,7 +74,7 @@ $GLActName='', $DecimalPlaces=2, $ItemNo, - $uom, + $SuppUOM, $ConversionFactor=1, $LeadTime=1, $Suppliers_PartNo='', @@ -116,7 +108,7 @@ $GLActName, $DecimalPlaces, $ItemNo, - $uom, + $SuppUOM, $ConversionFactor, $LeadTime, $Suppliers_PartNo, @@ -177,7 +169,6 @@ $this->LineItems[$LineNo]->CuFt = $CuFt; $this->LineItems[$LineNo]->Total_Quantity = $Total_Quantity; $this->LineItems[$LineNo]->Total_Amount = $Total_Amount; - $this->LineItems[$LineNo]->Price = $Price; } function remove_from_order(&$LineNo){ @@ -227,7 +218,7 @@ Var $GLActName; Var $Quantity; Var $Price; - Var $Units; + Var $Units; //errrrr what is uom for then Var $ReqDelDate; Var $QtyInv; Var $QtyReceived; @@ -236,7 +227,7 @@ var $Completed; Var $JobRef; Var $ItemNo; - Var $uom; + Var $SuppUOM; var $ConversionFactor; Var $Suppliers_PartNo; Var $SubTotal_Amount; @@ -273,7 +264,7 @@ $GLActName, $DecimalPlaces, $ItemNo, - $uom, + $SuppUOM, $ConversionFactor, $Suppliers_PartNo, $SubTotal_Amount, @@ -303,7 +294,7 @@ $this->GLCode = $GLCode; $this->JobRef = $JobRef; $this->ItemNo = $ItemNo; - $this->uom = $uom; + $this->SuppUOM = $SuppUOM; $this->ConversionFactor = $ConversionFactor; $this->Suppliers_PartNo = $Suppliers_PartNo; $this->Subtotal_Amount = $SubTotal_Amount; Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-12-11 00:03:18 UTC (rev 4182) +++ trunk/includes/PO_ReadInOrder.inc 2010-12-14 09:30:20 UTC (rev 4183) @@ -80,22 +80,22 @@ $_SESSION['PO'.$identifier]->DelAdd4 = $myrow['deladd4']; $_SESSION['PO'.$identifier]->DelAdd5 = $myrow['deladd5']; $_SESSION['PO'.$identifier]->DelAdd6 = $myrow['deladd6']; - $_SESSION['PO'.$identifier]->tel = $myrow['tel']; - $_SESSION['PO'.$identifier]->suppDelAdd1 = $myrow['suppdeladdress1']; - $_SESSION['PO'.$identifier]->suppDelAdd2 = $myrow['suppdeladdress2']; - $_SESSION['PO'.$identifier]->suppDelAdd3 = $myrow['suppdeladdress3']; - $_SESSION['PO'.$identifier]->suppDelAdd4 = $myrow['suppdeladdress4']; - $_SESSION['PO'.$identifier]->suppDelAdd5 = $myrow['suppdeladdress5']; - $_SESSION['PO'.$identifier]->suppDelAdd6 = $myrow['suppdeladdress6']; + $_SESSION['PO'.$identifier]->Tel = $myrow['tel']; + $_SESSION['PO'.$identifier]->SuppDelAdd1 = $myrow['suppdeladdress1']; + $_SESSION['PO'.$identifier]->SuppDelAdd2 = $myrow['suppdeladdress2']; + $_SESSION['PO'.$identifier]->SuppDelAdd3 = $myrow['suppdeladdress3']; + $_SESSION['PO'.$identifier]->SuppDelAdd4 = $myrow['suppdeladdress4']; + $_SESSION['PO'.$identifier]->SuppDelAdd5 = $myrow['suppdeladdress5']; + $_SESSION['PO'.$identifier]->SuppDelAdd6 = $myrow['suppdeladdress6']; $_SESSION['PO'.$identifier]->SupplierContact = $myrow['suppliercontact']; - $_SESSION['PO'.$identifier]->supptel= $myrow['supptel']; - $_SESSION['PO'.$identifier]->contact = $myrow['contact']; + $_SESSION['PO'.$identifier]->SuppTel= $myrow['supptel']; + $_SESSION['PO'.$identifier]->Contact = $myrow['contact']; $_SESSION['PO'.$identifier]->Managed = $myrow['managed']; - $_SESSION['PO'.$identifier]->version = $myrow['version']; - $_SESSION['PO'.$identifier]->port = $myrow['port']; - $_SESSION['PO'.$identifier]->Stat = $myrow['status']; + $_SESSION['PO'.$identifier]->Version = $myrow['version']; + $_SESSION['PO'.$identifier]->Port = $myrow['port']; + $_SESSION['PO'.$identifier]->Status = $myrow['status']; $_SESSION['PO'.$identifier]->StatComments = $myrow['stat_comment']; - $_SESSION['PO'.$identifier]->deliverydate = ConvertSQLDate($myrow['deliverydate']); + $_SESSION['PO'.$identifier]->DeliveryDate = ConvertSQLDate($myrow['deliverydate']); $_SESSION['ExistingOrder'] = $_SESSION['PO'.$identifier]->OrderNo; $_SESSION['PO'.$identifier]->paymentterms= $myrow['paymentterms']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-17 21:59:06
|
Revision: 4184 http://web-erp.svn.sourceforge.net/web-erp/?rev=4184&view=rev Author: daintree Date: 2010-12-17 21:58:59 +0000 (Fri, 17 Dec 2010) Log Message: ----------- Mods to select fixed asset for disposal Modified Paths: -------------- trunk/SelectOrderItems.php trunk/SupplierInvoice.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-12-14 09:30:20 UTC (rev 4183) +++ trunk/SelectOrderItems.php 2010-12-17 21:58:59 UTC (rev 4184) @@ -982,6 +982,85 @@ unset($NewItem); } /* end of if quick entry */ + if (isset($_POST['AssetDisposalEntered'])){ //its an asset being disposed of + if ($_POST['AssetToDisposeOf'] == 'NoAssetSelected'){ //don't do anything unless an asset is disposed of + prnMsg(_('No asset was selected to dispose of. No assets have been added to this customer order'),'warn'); + } else { //need to add the asset to the order + /*First need to create a stock ID to hold the asset and record the sale - as only stock items can be sold + * and before that we need to add a disposal stock category - if not already created + * first off get the details about the asset being disposed of */ + $AssetDetailsResult = DB_query('SELECT fixedassets.description, + fixedassets.longdescription, + fixedassets.barcode, + fixedassetcategories.costact + FROM fixedassetcategories INNER JOIN fixedassets + ON fixedassetcategories.categoryid=fixedassets.assetcategoryid + WHERE fixedassets.assetid="' . $_POST['AssetToDisposeOf'] . '"',$db); + $AssetRow = DB_fetch_array($AssetCatDetailsResult); + + $AssetCategoryResult = DB_query('SELECT categoryid FROM stockcategory WHERE categoryid="ASSETS"',$db); + if (DB_num_rows($AssetCategoryResult)==0){ + /*Although asset GL posting will come from the asset category - we should set the GL codes to something sensible + * based on the category of the asset under review at the moment - this may well change for any other assets sold subsequentely */ + + /*OK now we can insert the stock category for this asset */ + $InsertAssetStockCatResult = DB_query('INSERT INTO stockcategory ( categoryid, + categorydescription, + stockact) + VALUES ("ASSETS", + "' . _('Asset Disposals') . '", + "' . $AssetRow['costact'] . '")',$db); + } + + /*First check to see that it doesn't exist already assets are of the format "ASSET-" . $AssetID + */ + $TestAssetExistsAlreadyResult = DB_query('SELECT stockid FROM stockmaster WHERE stockid ="ASSET-' . $_POST['AssetToDisposeOf'] . '"',$db); + if (DB_num_rows($TestAssetExistsAlreadyResult)==1){ //then it exists already ... bum + $j=1; + while (DB_num_rows($TestAssetExistsAlreadyResult)==1) { + $TestAssetExistsAlreadyResult = DB_query('SELECT stockid FROM stockmaster WHERE stockid ="ASSET-' . $_POST['AssetToDisposeOf'] . '-' . $j . '"',$db); + $j++; + } + $AssetStockID = 'ASSET-' . $_POST['AssetToDisposeOf'] . '-' . $j; + } else { + $AssetStockID = 'ASSET-' . $_POST['AssetToDisposeOf']; + } + /* Perhaps ought to check that the asset exists already as a stock item first */ + + /*OK now we can insert the item for this asset */ + $InsertAssetAsStockItemResult = DB_query('INSERT INTO stockmaster ( stockid, + description, + categoryid, + longdescription, + mbflag, + controlled, + serialised, + taxcatid) + VALUES ("' . $AssetStockID . '", + "' . $AssetRow['description'] . '", + "' . $AssetRow['longdescription'] . '", + "ASSETS", + "B", + "0", + "0", + "' . $_SESSION['DefaultTaxCategory'] . '")' , $db); + /*not forgetting the location records too */ + $InsertStkLocRecsResult = DB_query('INSERT INTO locstock (loccode, + stockid) + SELECT loccode, "' . $AssetStockID . '" FROM locations',$db); + /*Now the asset has been added to the stock master we can add it to the sales order */ + $NewItemDue = date($_SESSION['DefaultDateFormat']); + if (isset($_POST['POLine']){ + $NewPOLine = $_POST['POLine']; + } else { + $NewPOLine = 0; + } + $NewItem = $AssetStockID; + include('includes/SelectOrderItems_IntoCart.inc'); + } + + + } /*Now do non-quick entry delete/edits/adds */ @@ -1324,7 +1403,10 @@ /* Now show the stock item selection search stuff below */ - if (isset($_POST['PartSearch']) && $_POST['PartSearch']!='' || !isset($_POST['QuickEntry'])){ + if ((isset($_POST['PartSearch']) + AND $_POST['PartSearch']!='' + AND !isset($_POST['QuickEntry']) + AND !isset($_POST['SelectAsset']))){ echo '<input type="hidden" name="PartSearch" value="' . _('Yes Please') . '">'; @@ -1333,12 +1415,18 @@ // Select the most recently ordered items for quick select $SixMonthsAgo = DateAdd (Date($_SESSION['DefaultDateFormat']),'m',-6); - $SQL="SELECT stockmaster.units, stockmaster.description, stockmaster.stockid, salesorderdetails.stkcode, SUM(qtyinvoiced) Sales FROM `salesorderdetails`, `stockmaster` - WHERE ActualDispatchDate >= '" . FormatDateForSQL($SixMonthsAgo) . "' - AND salesorderdetails.stkcode = stockmaster.stockid - GROUP BY stkcode - ORDER BY sales DESC - LIMIT " . $_SESSION['FrequentlyOrderedItems']; + $SQL="SELECT stockmaster.units, + stockmaster.description, + stockmaster.stockid, + salesorderdetails.stkcode, + SUM(qtyinvoiced) salesqty + FROM `salesorderdetails`INNER JOIN `stockmaster` + ON salesorderdetails.stkcode = stockmaster.stockid + WHERE ActualDispatchDate >= '" . FormatDateForSQL($SixMonthsAgo) . "' + GROUP BY stkcode + ORDER BY salesqty DESC + LIMIT " . $_SESSION['FrequentlyOrderedItems']; + $result2 = DB_query($SQL,$db); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' '; echo _('Frequently Ordered Items') . '<br>'; @@ -1370,13 +1458,13 @@ // Find the quantity on outstanding sales orders $sql = "SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem - FROM salesorderdetails, - salesorders - WHERE salesorders.orderno = salesorderdetails.orderno AND - salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' AND - salesorderdetails.completed=0 AND - salesorders.quotation=0 AND - salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; + FROM salesorderdetails, + salesorders + WHERE salesorders.orderno = salesorderdetails.orderno AND + salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' AND + salesorderdetails.completed=0 AND + salesorders.quotation=0 AND + salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; $ErrMsg = _('The demand for this product from') . ' ' . $_SESSION['Items'.$identifier]->Location . ' ' . _('cannot be retrieved because'); @@ -1390,9 +1478,9 @@ } // Find the quantity on purchase orders $sql = "SELECT SUM(purchorderdetails.quantityord-purchorderdetails.quantityrecd) AS dem - FROM purchorderdetails - WHERE purchorderdetails.completed=0 - AND purchorderdetails.itemcode='" . $myrow['stockid'] . "'"; + FROM purchorderdetails + WHERE purchorderdetails.completed=0 + AND purchorderdetails.itemcode='" . $myrow['stockid'] . "'"; $ErrMsg = _('The order details for this product cannot be retrieved because'); $PurchResult = db_query($sql,$db,$ErrMsg); @@ -1406,8 +1494,8 @@ // Find the quantity on works orders $sql = "SELECT SUM(woitems.qtyreqd - woitems.qtyrecd) AS dedm - FROM woitems - WHERE stockid='" . $myrow['stockid'] ."'"; + FROM woitems + WHERE stockid='" . $myrow['stockid'] ."'"; $ErrMsg = _('The order details for this product cannot be retrieved because'); $WoResult = db_query($sql,$db,$ErrMsg); $WoRow = db_fetch_row($WoResult); @@ -1429,26 +1517,26 @@ $Available = $qoh - $DemandQty + $OnOrder; printf('<td>%s</font></td> - <td>%s</td> - <td>%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td><font size=1><input class="number" tabindex='.number_format($j+7).' type="textbox" size=6 name="itm'.$myrow['stockid'].'" value=0> - </td> - </tr>', - $myrow['stockid'], - $myrow['description'], - $myrow['units'], - $qoh, - $DemandQty, - $OnOrder, - $Available, - $ImageSource, - $rootpath, - SID, - $myrow['stockid']); + <td>%s</td> + <td>%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td><font size=1><input class="number" tabindex='.number_format($j+7).' type="textbox" size=6 name="itm'.$myrow['stockid'].'" value=0> + </td> + </tr>', + $myrow['stockid'], + $myrow['description'], + $myrow['units'], + $qoh, + $DemandQty, + $OnOrder, + $Available, + $ImageSource, + $rootpath, + SID, + $myrow['stockid']); if ($j==1) { $jsCall = '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.itm'.$myrow['stockid'].');}</script>'; } @@ -1466,16 +1554,17 @@ echo '<table class="selection"><tr><td><b>' . _('Select a Stock Category') . ': </b><select tabindex=1 name="StockCat">'; if (!isset($_POST['StockCat'])){ - echo "<option selected value='All'>" . _('All'); + echo '<option selected value="All">' . _('All'); $_POST['StockCat'] ='All'; } else { - echo "<option value='All'>" . _('All'); + echo '<option value="All">' . _('All'); } - $SQL="SELECT categoryid, - categorydescription - FROM stockcategory - WHERE stocktype='F' OR stocktype='D' - ORDER BY categorydescription"; + $SQL='SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype="F" OR stocktype="D" + ORDER BY categorydescription'; + $result1 = DB_query($SQL,$db); while ($myrow1 = DB_fetch_array($result1)) { if ($_POST['StockCat']==$myrow1['categoryid']){ @@ -1485,53 +1574,52 @@ } } - ?> + echo '</select></td> + <td><b>' . _('Enter partial Description') . ':</b><input tabindex=2 type="Text" name="Keywords" size=20 maxlength=25 value="' ; + + if (isset($_POST['Keywords'])) { + echo$_POST['Keywords'] ; + } + echo '"></td>'; - </select></td> - <td><b><?php echo _('Enter partial Description'); ?>:</b> - <input tabindex=2 type="Text" name="Keywords" size=20 maxlength=25 value="<?php if (isset($_POST['Keywords'])) echo $_POST['Keywords']; ?>"></td> - - <td align="right"><b><?php echo _('OR'); ?> </b><b><?php echo _('Enter extract of the Stock Code'); ?>:</b> - <input tabindex=3 type="Text" name="StockCode" size=15 maxlength=18 value="<?php if (isset($_POST['StockCode'])) echo $_POST['StockCode']; ?>"></td> - - </tr><tr> - <td style="text-align:center" colspan=1><input tabindex=4 type=submit name="Search" value="<?php echo _('Search Now'); ?>"></td> - <td style="text-align:center" colspan=1><input tabindex=5 type=submit name="QuickEntry" value="<?php echo _('Use Quick Entry'); ?>"></td> - - <?php + echo '<td align="right"><b>' . _('OR') . ' ' . _('Enter extract of the Stock Code') . ':</b><input tabindex=3 type="Text" name="StockCode" size=15 maxlength=18 value="'; + if (isset($_POST['StockCode'])) { + echo $_POST['StockCode']; + } + echo '"></td></tr>'; + + echo '<tr> + <td style="text-align:center" colspan=1><input tabindex=4 type=submit name="Search" value="' . _('Search Now') . '"></td> + <td style="text-align:center" colspan=1><input tabindex=5 type=submit name="QuickEntry" value="' . _('Use Quick Entry') . '"></td>'; + if (!isset($_POST['PartSearch'])) { echo '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.Keywords);}</script>'; } - if (in_array(2,$_SESSION['AllowedPageSecurityTokens'])){ - echo '<td style="text-align:center" colspan=1><input tabindex=6 type=submit name="ChangeCustomer" value="' . _('Change Customer') . '"></td>'; - echo '</tr></table><br>'; - echo '</b>'; -// Add some useful help as the order progresses - if (isset($SearchResult)) { - echo '<br>'; - echo '<div class="page_help_text">' . _('Select an item by entering the quantity required. Click Order when ready.') . '</div>'; - echo '<br>'; - } -// Remove add stock item link, as this should be done through inventory -// echo '<div class="centre"><br><br><a tabindex=7 target="_blank" href="' . $rootpath . '/Stocks.php?' . SID . '"><b>' . _('Add a New Stock Item') . '</b></a></div>'; + if (in_array(2,$_SESSION['AllowedPageSecurityTokens'])){ //not a customer entry of own order + echo '<td style="text-align:center" colspan=1><input tabindex=6 type="submit" name="ChangeCustomer" value="' . _('Change Customer') . '"></td> + <td style="text-align:center" colspan=1><input tabindex=7 type="submit" name="SelectAsset" value="' . _('Fixed Asset Disposal') . '"></td> + </tr></table><br>'; } if (isset($SearchResult)) { + echo '<br>'; + echo '<div class="page_help_text">' . _('Select an item by entering the quantity required. Click Order when ready.') . '</div>'; + echo '<br>'; $j = 1; echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID .'identifier='.$identifier . ' method=post name="orderform">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table class="table1">'; - echo '<tr><td colspan=><input type="hidden" name="previous" value='.number_format($Offset-1).'><input tabindex='.number_format($j+7).' type="submit" name="Prev" value="'._('Prev').'"></td>'; - echo '<td style="text-align:center" colspan=6><input type="hidden" name="order_items" value=1><input tabindex='.number_format($j+8).' type="submit" value="'._('Add to Sales Order').'"></td>'; - echo '<td colspan=><input type="hidden" name="nextlist" value='.number_format($Offset+1).'><input tabindex='.number_format($j+9).' type="submit" name="Next" value="'._('Next').'"></td></tr>'; + echo '<tr><td colspan=><input type="hidden" name="previous" value='.number_format($Offset-1).'><input tabindex='.number_format($j+8).' type="submit" name="Prev" value="'._('Prev').'"></td>'; + echo '<td style="text-align:center" colspan=6><input type="hidden" name="order_items" value=1><input tabindex='.number_format($j+9).' type="submit" value="'._('Add to Sales Order').'"></td>'; + echo '<td colspan=><input type="hidden" name="nextlist" value='.number_format($Offset+1).'><input tabindex='.number_format($j+10).' type="submit" name="Next" value="'._('Next').'"></td></tr>'; $TableHeader = '<tr><th>' . _('Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('On Hand') . '</th> - <th>' . _('On Demand') . '</th> - <th>' . _('On Order') . '</th> - <th>' . _('Available') . '</th> - <th>' . _('Quantity') . '</th></tr>'; + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('On Hand') . '</th> + <th>' . _('On Demand') . '</th> + <th>' . _('On Order') . '</th> + <th>' . _('Available') . '</th> + <th>' . _('Quantity') . '</th></tr>'; echo $TableHeader; $k=0; //row colour counter @@ -1554,25 +1642,24 @@ */ // Find the quantity in stock at location $qohsql = "SELECT sum(quantity) - FROM locstock - WHERE stockid='" .$myrow['stockid'] . "' AND - loccode = '" . $_SESSION['Items'.$identifier]->Location . "'"; + FROM locstock + WHERE stockid='" .$myrow['stockid'] . "' AND + loccode = '" . $_SESSION['Items'.$identifier]->Location . "'"; $qohresult = DB_query($qohsql,$db); $qohrow = DB_fetch_row($qohresult); $qoh = $qohrow[0]; // Find the quantity on outstanding sales orders $sql = "SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem - FROM salesorderdetails, - salesorders - WHERE salesorders.orderno = salesorderdetails.orderno AND - salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' AND - salesorderdetails.completed=0 AND - salesorders.quotation=0 AND - salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; + FROM salesorderdetails, + salesorders + WHERE salesorders.orderno = salesorderdetails.orderno AND + salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' AND + salesorderdetails.completed=0 AND + salesorders.quotation=0 AND + salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; - $ErrMsg = _('The demand for this product from') . ' ' . $_SESSION['Items'.$identifier]->Location . ' ' . - _('cannot be retrieved because'); + $ErrMsg = _('The demand for this product from') . ' ' . $_SESSION['Items'.$identifier]->Location . ' ' . _('cannot be retrieved because'); $DemandResult = DB_query($sql,$db,$ErrMsg); $DemandRow = DB_fetch_row($DemandResult); @@ -1620,30 +1707,29 @@ $k=1; } $OnOrder = $PurchQty + $WoQty; - $Available = $qoh - $DemandQty + $OnOrder; printf('<td>%s</font></td> - <td>%s</td> - <td>%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td style="text-align:center">%s</td> - <td><font size=1><input class="number" tabindex='.number_format($j+7).' type="textbox" size=6 name="itm'.$myrow['stockid'].'" value=0> - </td> - </tr>', - $myrow['stockid'], - $myrow['description'], - $myrow['units'], - $qoh, - $DemandQty, - $OnOrder, - $Available, - $ImageSource, - $rootpath, - SID, - $myrow['stockid']); + <td>%s</td> + <td>%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td style="text-align:center">%s</td> + <td><font size=1><input class="number" tabindex='.number_format($j+7).' type="textbox" size=6 name="itm'.$myrow['stockid'].'" value=0> + </td> + </tr>', + $myrow['stockid'], + $myrow['description'], + $myrow['units'], + $qoh, + $DemandQty, + $OnOrder, + $Available, + $ImageSource, + $rootpath, + SID, + $myrow['stockid']); if ($j==1) { $jsCall = '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.itm'.$myrow['stockid'].');}</script>'; } @@ -1659,9 +1745,8 @@ }#end if SearchResults to show } /*end of PartSearch options to be displayed */ - else { /* show the quick entry form variable */ + elseif( isset($_POST['QuickEntry'])) { /* show the quick entry form variable */ /*FORM VARIABLES TO POST TO THE ORDER WITH PART CODE AND QUANTITY */ -// echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" name="quickentry" method=post>'; echo '<div class="page_help_text"><b>' . _('Use this screen for the '). _('Quick Entry')._(' of products to be ordered') . '</b></div><br> <table border=1> <tr>'; @@ -1691,7 +1776,28 @@ echo '</table><br><div class="centre"><input type="submit" name="QuickEntry" value="' . _('Quick Entry') . '"> <input type="submit" name="PartSearch" value="' . _('Search Parts') . '"></div>'; - } + } elseif (isset($_POST['SelectAsset'])){ + + echo '<div class="page_help_text"><b>' . _('Use this screen to select an asset to dispose of to this customer') . '</b></div><br> + <table border=1>'; + /*do not display colum unless customer requires po line number by sales order line*/ + if($_SESSION['Items'.$identifier]->DefaultPOLine ==1){ + echo '<tr><td>' . _('PO Line') . '</td> + <td><input type="text" name="poline" size=21 maxlength=20></td></tr>'; + } + echo '<tr><td>' . _('Asset to Dispose Of') . ':</td> + <td><select name="AssetToDisposeOf">'; + $AssetsResult = DB_query('SELECT assetid, description FROM fixedassets WHERE disposaldate="0000-00-00"',$db); + echo '<option selected value="NoAssetSelected">' . _('Select Asset To Dispose of From the List Below') . '</option>'; + while ($AssetRow = DB_fetch_array($AssetsResult)){ + echo '<option value="' . $AssetRow['assetid'] . '">' . $AssetRow['assetid'] . ' - ' . $AssetRow['description'] . '</option>'; + } + echo '</select></td></tr></table> + <br><div class="centre"><input type="submit" name="AssetDisposalEntered" value="' . _('Add Asset To Order') . '"> + <input type="submit" name="PartSearch" value="' . _('Search Parts') . '"></div>'; + + } //end of if it is a Quick Entry screen/part search or asset selection form to display + if ($_SESSION['Items'.$identifier]->ItemsOrdered >=1){ echo '<br><div class="centre"><input type=submit name="CancelOrder" value="' . _('Cancel Whole Order') . '" onclick="return confirm(\'' . _('Are you sure you wish to cancel this entire order?') . '\');"></div>'; } Modified: trunk/SupplierInvoice.php =================================================================== --- trunk/SupplierInvoice.php 2010-12-14 09:30:20 UTC (rev 4183) +++ trunk/SupplierInvoice.php 2010-12-17 21:58:59 UTC (rev 4184) @@ -553,12 +553,13 @@ } $InputError = False; - if ( $TaxTotal + $_SESSION['SuppTrans']->OvAmount <= 0){ + if ( $TaxTotal + $_SESSION['SuppTrans']->OvAmount < 0){ $InputError = True; - prnMsg(_('The invoice as entered cannot be processed because the total amount of the invoice is less than or equal to 0') . '. ' . _('Invoices are expected to have a charge'),'error'); + prnMsg(_('The invoice as entered cannot be processed because the total amount of the invoice is less than 0') . '. ' . _('Invoices are expected to have a positive charge'),'error'); echo '<p> The tax total is : ' . $TaxTotal; echo '<p> The ovamount is : ' . $_SESSION['SuppTrans']->OvAmount; - + } elseif ( $TaxTotal + $_SESSION['SuppTrans']->OvAmount == 0){ + prnMsg(_('The invoice as entered will be processed but be warned the amount of the invoice is zero!') . '. ' . _('Invoices are normally expected to have a positive charge'),'warn'); } elseif (strlen( $_SESSION['SuppTrans']->SuppReference)<1){ $InputError = True; prnMsg(_('The invoice as entered cannot be processed because the there is no suppliers invoice number or reference entered') . '. ' . _('The supplier invoice number must be entered'),'error'); Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-14 09:30:20 UTC (rev 4183) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-17 21:58:59 UTC (rev 4184) @@ -445,8 +445,10 @@ ALTER TABLE fixedassets ADD COLUMN `depntype` int NOT NULL DEFAULT 1; ALTER TABLE fixedassets ADD COLUMN `depnrate` double NOT NULL; ALTER TABLE fixedassets ADD COLUMN `barcode` VARCHAR( 30 ) NOT NULL; +ALTER TABLE fixedassets ADD COLUMN `disposaldate` DATE NOT NULL DEFAULT '0000-00-00'; ALTER TABLE `fixedassets` CHANGE `depn` `accumdepn` DOUBLE NOT NULL DEFAULT '0'; ALTER TABLE `fixedassets` CHANGE `location` `assetlocation` VARCHAR( 6 ) NOT NULL DEFAULT ''; +ALTER TABLE `fixedassets` CHANGE `disposalvalue` `disposalproceeds` DOUBLE NOT NULL DEFAULT '0' UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid, fixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-18 05:18:15
|
Revision: 4185 http://web-erp.svn.sourceforge.net/web-erp/?rev=4185&view=rev Author: daintree Date: 2010-12-18 05:18:08 +0000 (Sat, 18 Dec 2010) Log Message: ----------- sql script pricing end dates per Ricard Modified Paths: -------------- trunk/SelectOrderItems.php trunk/includes/MiscFunctions.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-12-17 21:58:59 UTC (rev 4184) +++ trunk/SelectOrderItems.php 2010-12-18 05:18:08 UTC (rev 4185) @@ -307,16 +307,16 @@ $SearchString = '%' . str_replace(' ', '%', $_POST['CustKeywords']) . '%'; $SQL = "SELECT custbranch.brname, - custbranch.contactname, - custbranch.phoneno, - custbranch.faxno, - custbranch.branchcode, - custbranch.debtorno, - debtorsmaster.name - FROM custbranch - LEFT JOIN debtorsmaster - ON custbranch.debtorno=debtorsmaster.debtorno - WHERE custbranch.brname " . LIKE . " '$SearchString'"; + custbranch.contactname, + custbranch.phoneno, + custbranch.faxno, + custbranch.branchcode, + custbranch.debtorno, + debtorsmaster.name + FROM custbranch + LEFT JOIN debtorsmaster + ON custbranch.debtorno=debtorsmaster.debtorno + WHERE custbranch.brname " . LIKE . " '$SearchString'"; if ($_SESSION['SalesmanLogin']!=''){ $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; @@ -329,17 +329,17 @@ $_POST['CustCode'] = strtoupper(trim($_POST['CustCode'])); $SQL = "SELECT custbranch.brname, - custbranch.contactname, - custbranch.phoneno, - custbranch.faxno, - custbranch.branchcode, - custbranch.debtorno, - debtorsmaster.name - FROM custbranch - LEFT JOIN debtorsmaster - ON custbranch.debtorno=debtorsmaster.debtorno - WHERE custbranch.debtorno " . LIKE . " '%" . $_POST['CustCode'] . "%' OR custbranch.branchcode " . LIKE . " '%" . $_POST['CustCode'] . "%'"; - + custbranch.contactname, + custbranch.phoneno, + custbranch.faxno, + custbranch.branchcode, + custbranch.debtorno, + debtorsmaster.name + FROM custbranch + LEFT JOIN debtorsmaster + ON custbranch.debtorno=debtorsmaster.debtorno + WHERE custbranch.debtorno " . LIKE . " '%" . $_POST['CustCode'] . "%' OR custbranch.branchcode " . LIKE . " '%" . $_POST['CustCode'] . "%'"; + if ($_SESSION['SalesmanLogin']!=''){ $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } @@ -347,23 +347,23 @@ ORDER BY custbranch.debtorno'; } elseif (strlen($_POST['CustPhone'])>0){ $SQL = "SELECT custbranch.brname, - custbranch.contactname, - custbranch.phoneno, - custbranch.faxno, - custbranch.branchcode, - custbranch.debtorno, - debtorsmaster.name - FROM custbranch - LEFT JOIN debtorsmaster - ON custbranch.debtorno=debtorsmaster.debtorno - WHERE custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%'"; + custbranch.contactname, + custbranch.phoneno, + custbranch.faxno, + custbranch.branchcode, + custbranch.debtorno, + debtorsmaster.name + FROM custbranch + LEFT JOIN debtorsmaster + ON custbranch.debtorno=debtorsmaster.debtorno + WHERE custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%'"; if ($_SESSION['SalesmanLogin']!=''){ $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } $SQL .= ' AND custbranch.disabletrans=0 - ORDER BY custbranch.debtorno'; + ORDER BY custbranch.debtorno'; } $ErrMsg = _('The searched customer records requested cannot be retrieved because'); @@ -389,20 +389,20 @@ // Now check to ensure this account is not on hold */ $sql = "SELECT debtorsmaster.name, - holdreasons.dissallowinvoices, - debtorsmaster.salestype, - salestypes.sales_type, - debtorsmaster.currcode, - debtorsmaster.customerpoline, - paymentterms.terms - FROM debtorsmaster, - holdreasons, - salestypes, - paymentterms - WHERE debtorsmaster.salestype=salestypes.typeabbrev - AND debtorsmaster.holdreason=holdreasons.reasoncode - AND debtorsmaster.paymentterms=paymentterms.termsindicator - AND debtorsmaster.debtorno = '" . $_POST['Select'] . "'"; + holdreasons.dissallowinvoices, + debtorsmaster.salestype, + salestypes.sales_type, + debtorsmaster.currcode, + debtorsmaster.customerpoline, + paymentterms.terms + FROM debtorsmaster, + holdreasons, + salestypes, + paymentterms + WHERE debtorsmaster.salestype=salestypes.typeabbrev + AND debtorsmaster.holdreason=holdreasons.reasoncode + AND debtorsmaster.paymentterms=paymentterms.termsindicator + AND debtorsmaster.debtorno = '" . $_POST['Select'] . "'"; $ErrMsg = _('The details of the customer selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the customer details and failed was') . ':'; @@ -430,26 +430,26 @@ # the branch was also selected from the customer selection so default the delivery details from the customer branches table CustBranch. The order process will ask for branch details later anyway $sql = "SELECT custbranch.brname, - custbranch.braddress1, - custbranch.braddress2, - custbranch.braddress3, - custbranch.braddress4, - custbranch.braddress5, - custbranch.braddress6, - custbranch.phoneno, - custbranch.email, - custbranch.defaultlocation, - custbranch.defaultshipvia, - custbranch.deliverblind, - custbranch.specialinstructions, - custbranch.estdeliverydays, - locations.locationname, - custbranch.salesman - FROM custbranch - INNER JOIN locations - ON custbranch.defaultlocation=locations.loccode - WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' - AND custbranch.debtorno = '" . $_POST['Select'] . "'"; + custbranch.braddress1, + custbranch.braddress2, + custbranch.braddress3, + custbranch.braddress4, + custbranch.braddress5, + custbranch.braddress6, + custbranch.phoneno, + custbranch.email, + custbranch.defaultlocation, + custbranch.defaultshipvia, + custbranch.deliverblind, + custbranch.specialinstructions, + custbranch.estdeliverydays, + locations.locationname, + custbranch.salesman + FROM custbranch + INNER JOIN locations + ON custbranch.defaultlocation=locations.loccode + WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' + AND custbranch.debtorno = '" . $_POST['Select'] . "'"; $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); $DbgMsg = _('SQL used to retrieve the branch details was') . ':'; @@ -516,13 +516,13 @@ #DefaultSalesType will not have been set as above $sql = "SELECT debtorsmaster.name, - holdreasons.dissallowinvoices, - debtorsmaster.salestype, - debtorsmaster.currcode, - debtorsmaster.customerpoline - FROM debtorsmaster, holdreasons - WHERE debtorsmaster.holdreason=holdreasons.reasoncode - AND debtorsmaster.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + holdreasons.dissallowinvoices, + debtorsmaster.salestype, + debtorsmaster.currcode, + debtorsmaster.customerpoline + FROM debtorsmaster, holdreasons + WHERE debtorsmaster.holdreason=holdreasons.reasoncode + AND debtorsmaster.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; if (isset($_POST['Select'])) { $ErrMsg = _('The details for the customer selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); @@ -550,23 +550,23 @@ // the order process will ask for branch details later anyway $sql = "SELECT custbranch.brname, - custbranch.branchcode, - custbranch.braddress1, - custbranch.braddress2, - custbranch.braddress3, - custbranch.braddress4, - custbranch.braddress5, - custbranch.braddress6, - custbranch.phoneno, - custbranch.email, - custbranch.defaultlocation, - custbranch.deliverblind, - custbranch.estdeliverydays, - locations.locationname - FROM custbranch INNER JOIN locations - ON custbranch.defaultlocation=locations.loccode - WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' - AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + custbranch.branchcode, + custbranch.braddress1, + custbranch.braddress2, + custbranch.braddress3, + custbranch.braddress4, + custbranch.braddress5, + custbranch.braddress6, + custbranch.phoneno, + custbranch.email, + custbranch.defaultlocation, + custbranch.deliverblind, + custbranch.estdeliverydays, + locations.locationname + FROM custbranch INNER JOIN locations + ON custbranch.defaultlocation=locations.loccode + WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' + AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; if (isset($_POST['Select'])) { $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_POST['Select'] . ' ' . _('cannot be retrieved because'); @@ -685,9 +685,9 @@ if($_SESSION['ExistingOrder']!=0) { //need to check that not already dispatched $sql = "SELECT qtyinvoiced - FROM salesorderdetails - WHERE orderno='" . $_SESSION['ExistingOrder'] . "' - AND qtyinvoiced>0"; + FROM salesorderdetails + WHERE orderno='" . $_SESSION['ExistingOrder'] . "' + AND qtyinvoiced>0"; $InvQties = DB_query($sql,$db); @@ -942,8 +942,8 @@ } /*Now figure out if the item is a kit set - the field MBFlag='K'*/ $sql = "SELECT stockmaster.mbflag - FROM stockmaster - WHERE stockmaster.stockid='". $NewItem ."'"; + FROM stockmaster + WHERE stockmaster.stockid='". $NewItem ."'"; $ErrMsg = _('Could not determine if the part being ordered was a kitset or not because'); $DbgMsg = _('The sql that was used to determine if the part being ordered was a kitset or not was '); @@ -1050,17 +1050,15 @@ SELECT loccode, "' . $AssetStockID . '" FROM locations',$db); /*Now the asset has been added to the stock master we can add it to the sales order */ $NewItemDue = date($_SESSION['DefaultDateFormat']); - if (isset($_POST['POLine']){ + if (isset($_POST['POLine'])){ $NewPOLine = $_POST['POLine']; } else { $NewPOLine = 0; } $NewItem = $AssetStockID; include('includes/SelectOrderItems_IntoCart.inc'); - } - - - } + } //end if adding a fixed asset to the order + } //end if the fixed asset selection box was set /*Now do non-quick entry delete/edits/adds */ @@ -1403,9 +1401,7 @@ /* Now show the stock item selection search stuff below */ - if ((isset($_POST['PartSearch']) - AND $_POST['PartSearch']!='' - AND !isset($_POST['QuickEntry']) + if ((!isset($_POST['QuickEntry']) AND !isset($_POST['SelectAsset']))){ echo '<input type="hidden" name="PartSearch" value="' . _('Yes Please') . '">'; Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2010-12-17 21:58:59 UTC (rev 4184) +++ trunk/includes/MiscFunctions.php 2010-12-18 05:18:08 UTC (rev 4185) @@ -12,8 +12,7 @@ }//prnMsg -function reverse_escape($str) -{ +function reverse_escape($str) { $search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $replace=array("\\","\0","\n","\r","\x1a","'",'"'); return str_replace($search,$replace,$str); @@ -57,63 +56,53 @@ return '<DIV class="'.$Class.'"><B>' . $Prefix . '</B> : ' .$Msg . '</DIV>'; }//getMsg -function IsEmailAddress($email){ +function IsEmailAddress($Email){ - $atIndex = strrpos ($email, "@"); - if ($atIndex === false) - { + $AtIndex = strrpos ($Email, "@"); + if ($AtIndex == false) { return false; // No @ sign is not acceptable. } - if (preg_match('/\\.\\./', $email)) + if (preg_match('/\\.\\./', $Email)){ return false; // > 1 consecutive dot is not allowed. - + } // Check component length limits - $domain = substr ($email, $atIndex+1); - $local = substr ($email, 0, $atIndex); - $localLen = strlen ($local); - $domainLen = strlen ($domain); - if ($localLen < 1 || $localLen > 64) - { + $Domain = substr ($Email, $AtIndex+1); + $Local= substr ($Email, 0, $AtIndex); + $LocalLen = strlen ($Local); + $DomainLen = strlen ($Domain); + if ($LocalLen < 1 || $LocalLen > 64){ // local part length exceeded return false; } - if ($domainLen < 1 || $domainLen > 255) - { + if ($DomainLen < 1 || $DomainLen > 255){ // domain part length exceeded return false; } - if ($local[0] == '.' || $local[$localLen-1] == '.') - { + if ($Local[0] == '.' OR $Local[$LocalLen-1] == '.') { // local part starts or ends with '.' return false; } - if (!preg_match ('/^[A-Za-z0-9\\-\\.]+$/', $domain )) - { + if (!preg_match ('/^[A-Za-z0-9\\-\\.]+$/', $Domain )){ // character not valid in domain part return false; } - if (!preg_match ('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', - str_replace ("\\\\", "" ,$local ) )) - { + if (!preg_match ('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace ("\\\\", "" ,$Local) )){ // character not valid in local part unless local part is quoted - if (!preg_match ('/^"(\\\\"|[^"])+"$/', - str_replace("\\\\", "", $local) )) - { - return false; + if (!preg_match ('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $Local) )) { + return false; } } // Check for a DNS 'MX' or 'A' record. // Windows supported from PHP 5.3.0 on - so check. - $ret = true; - if (version_compare(PHP_VERSION, '5.3.0') >= 0 - || strtoupper(substr(PHP_OS, 0, 3) !== 'WIN')) { - $ret = checkdnsrr( $domain, "MX" ) || checkdnsrr( $domain, "A" ); + $Ret = true; + if (version_compare(PHP_VERSION, '5.3.0') >= 0 OR strtoupper(substr(PHP_OS, 0, 3) !== 'WIN')) { + $Ret = checkdnsrr( $Domain, 'MX' ) OR checkdnsrr( $Domain, 'A' ); } - return $ret; + return $Ret; } @@ -135,9 +124,9 @@ function pre_var_dump(&$var){ - echo "<div align=left><pre>"; + echo '<div align=left><pre>'; var_dump($var); - echo "</pre></div>"; + echo '</pre></div>'; } @@ -164,18 +153,18 @@ $stack = array(); foreach ($tags as $tag) { $index = count($elements); - if ($tag['type'] == "complete" || $tag['type'] == "open") { + if ($tag['type'] == 'complete' OR $tag['type'] == 'open') { $elements[$index] = new XmlElement; $elements[$index]->name = $tag['tag']; $elements[$index]->attributes = $tag['attributes']; $elements[$index]->content = $tag['value']; - if ($tag['type'] == "open") { // push + if ($tag['type'] == 'open') { // push $elements[$index]->children = array(); $stack[count($stack)] = &$elements; $elements = &$elements[$index]->children; } } - if ($tag['type'] == "close") { // pop + if ($tag['type'] == 'close') { // pop $elements = &$stack[count($stack) - 1]; unset($stack[count($stack) - 1]); } Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-17 21:58:59 UTC (rev 4184) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-18 05:18:08 UTC (rev 4185) @@ -260,11 +260,11 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `systypes` VALUES(19, 'Picking List', 0); -ALTER TABLE `prices` ADD `startdate` DATE NOT NULL DEFAULT '0000-00-00' , ADD `enddate` DATE NOT NULL DEFAULT '9999-12-31'; +ALTER TABLE `prices` ADD `startdate` DATE NOT NULL DEFAULT '0000-00-00' , ADD `enddate` DATE NOT NULL DEFAULT '0000-00-00'; ALTER TABLE prices DROP PRIMARY KEY , ADD PRIMARY KEY ( `stockid` , `typeabbrev` , `currabrev` , `debtorno` , `branchcode`, `startdate` , `enddate` ) ; ALTER TABLE purchdata ADD column minorderqty int(11) NOT NULL default 1; -UPDATE prices SET startdate='1999-01-01', enddate=''; +UPDATE prices SET startdate='1999-01-01', enddate='0000-00-00'; ALTER TABLE stockcheckfreeze ADD COLUMN stockcheckdate date NOT NULL; @@ -385,7 +385,6 @@ ALTER TABLE `loctransfers` CHANGE COLUMN `shipqty` `shipqty` double NOT NULL DEFAULT 0.0; -INSERT INTO `config` VALUES ('VersionNumber', '4.00-RC1'); UPDATE `securitytokens` SET `tokenname`='Prices Security' WHERE tokenid=12; ALTER TABLE `www_users` CHANGE `supplierid` `supplierid` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-19 01:10:49
|
Revision: 4186 http://web-erp.svn.sourceforge.net/web-erp/?rev=4186&view=rev Author: daintree Date: 2010-12-19 01:10:36 +0000 (Sun, 19 Dec 2010) Log Message: ----------- Fixed asset disposals Modified Paths: -------------- trunk/ConfirmDispatch_Invoice.php trunk/FixedAssetRegister.php trunk/SelectOrderItems.php trunk/includes/GetSalesTransGLCodes.inc Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2010-12-18 05:18:08 UTC (rev 4185) +++ trunk/ConfirmDispatch_Invoice.php 2010-12-19 01:10:36 UTC (rev 4186) @@ -37,44 +37,44 @@ /*read in all the guff from the selected order into the Items cart */ $OrderHeaderSQL = 'SELECT salesorders.orderno, - salesorders.debtorno, - debtorsmaster.name, - salesorders.branchcode, - salesorders.customerref, - salesorders.comments, - salesorders.orddate, - salesorders.ordertype, - salesorders.shipvia, - salesorders.deliverto, - salesorders.deladd1, - salesorders.deladd2, - salesorders.deladd3, - salesorders.deladd4, - salesorders.deladd5, - salesorders.deladd6, - salesorders.contactphone, - salesorders.contactemail, - salesorders.freightcost, - salesorders.deliverydate, - debtorsmaster.currcode, - salesorders.fromstkloc, - locations.taxprovinceid, - custbranch.taxgroupid, - currencies.rate as currency_rate, - custbranch.defaultshipvia, - custbranch.specialinstructions - FROM salesorders, - debtorsmaster, - custbranch, - currencies, - locations - WHERE salesorders.debtorno = debtorsmaster.debtorno - AND salesorders.branchcode = custbranch.branchcode - AND salesorders.debtorno = custbranch.debtorno - AND locations.loccode=salesorders.fromstkloc - AND debtorsmaster.currcode = currencies.currabrev - AND salesorders.orderno = "' . $_GET['OrderNumber'].'"'; - + salesorders.debtorno, + debtorsmaster.name, + salesorders.branchcode, + salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.ordertype, + salesorders.shipvia, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.contactphone, + salesorders.contactemail, + salesorders.freightcost, + salesorders.deliverydate, + debtorsmaster.currcode, + salesorders.fromstkloc, + locations.taxprovinceid, + custbranch.taxgroupid, + currencies.rate as currency_rate, + custbranch.defaultshipvia, + custbranch.specialinstructions + FROM salesorders, + debtorsmaster, + custbranch, + currencies, + locations + WHERE salesorders.debtorno = debtorsmaster.debtorno + AND salesorders.branchcode = custbranch.branchcode + AND salesorders.debtorno = custbranch.debtorno + AND locations.loccode=salesorders.fromstkloc + AND debtorsmaster.currcode = currencies.currabrev + AND salesorders.orderno = "' . $_GET['OrderNumber'].'"'; + $ErrMsg = _('The order cannot be retrieved because'); $DbgMsg = _('The SQL to get the order header was'); $GetOrdHdrResult = DB_query($OrderHeaderSQL,$db,$ErrMsg,$DbgMsg); @@ -160,29 +160,29 @@ while ($myrow=db_fetch_array($LineItemsResult)) { $_SESSION['Items']->add_to_cart($myrow['stkcode'], - $myrow['quantity'], - $myrow['description'], - $myrow['unitprice'], - $myrow['discountpercent'], - $myrow['units'], - $myrow['volume'], - $myrow['kgs'], - 0, - $myrow['mbflag'], - $myrow['actualdispatchdate'], - $myrow['qtyinvoiced'], - $myrow['discountcategory'], - $myrow['controlled'], - $myrow['serialised'], - $myrow['decimalplaces'], - $myrow['narrative'], - 'No', - $myrow['orderlineno'], - $myrow['taxcatid'], - '', - $myrow['itemdue'], - $myrow['poline'], - $myrow['standardcost']); /*NB NO Updates to DB */ + $myrow['quantity'], + $myrow['description'], + $myrow['unitprice'], + $myrow['discountpercent'], + $myrow['units'], + $myrow['volume'], + $myrow['kgs'], + 0, + $myrow['mbflag'], + $myrow['actualdispatchdate'], + $myrow['qtyinvoiced'], + $myrow['discountcategory'], + $myrow['controlled'], + $myrow['serialised'], + $myrow['decimalplaces'], + $myrow['narrative'], + 'No', + $myrow['orderlineno'], + $myrow['taxcatid'], + '', + $myrow['itemdue'], + $myrow['poline'], + $myrow['standardcost']); /*NB NO Updates to DB */ /*Calculate the taxes applicable to this line item from the customer branch Tax Group and Item Tax Category */ @@ -579,7 +579,7 @@ $ErrMsg = _('Could not retrieve the quantity left at the location once this order is invoiced (for the purposes of checking that stock will not go negative because)'); $Result = DB_query($SQL,$db,$ErrMsg); $CheckNegRow = DB_fetch_array($Result); - if ($CheckNegRow['mbflag']=='B' OR $CheckNegRow['mbflag']=='M'){ + if (($CheckNegRow['mbflag']=='B' OR $CheckNegRow['mbflag']=='M') AND substr($OrderLine->StockID,0,4)!='ASSET'){ if ($CheckNegRow['quantity'] < $OrderLine->QtyDispatched){ prnMsg( _('Invoicing the selected order would result in negative stock. The system parameters are set to prohibit negative stocks from occurring. This invoice cannot be created until the stock on hand is corrected.'),'error',$OrderLine->StockID . ' ' . $CheckNegRow['description'] . ' - ' . _('Negative Stock Prohibited')); $NegativesFound = true; @@ -625,10 +625,10 @@ /* Now Get the area where the sale is to from the branches table */ $SQL = "SELECT area, - defaultshipvia - FROM custbranch - WHERE custbranch.debtorno ='". $_SESSION['Items']->DebtorNo . "' - AND custbranch.branchcode = '" . $_SESSION['Items']->Branch . "'"; + defaultshipvia + FROM custbranch + WHERE custbranch.debtorno ='". $_SESSION['Items']->DebtorNo . "' + AND custbranch.branchcode = '" . $_SESSION['Items']->Branch . "'"; $ErrMsg = _('We were unable to load Area where the Sale is to from the BRANCHES table') . '. ' . _('Please remedy this'); $Result = DB_query($SQL,$db, $ErrMsg); @@ -649,12 +649,12 @@ /*Now need to check that the order details are the same as they were when they were read into the Items array. If they've changed then someone else may have invoiced them */ $SQL = "SELECT stkcode, - quantity, - qtyinvoiced, - orderlineno - FROM salesorderdetails - WHERE completed=0 - AND orderno = '" . $_SESSION['ProcessingOrder']."'"; + quantity, + qtyinvoiced, + orderlineno + FROM salesorderdetails + WHERE completed=0 + AND orderno = '" . $_SESSION['ProcessingOrder']."'"; $Result = DB_query($SQL,$db); @@ -730,8 +730,8 @@ /*Update order header for invoice charged on */ $SQL = "UPDATE salesorders - SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "') - WHERE orderno= '" . $_SESSION['ProcessingOrder']."'"; + SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "') + WHERE orderno= '" . $_SESSION['ProcessingOrder']."'"; $ErrMsg = _('CRITICAL ERROR') . ' ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order header could not be updated with the invoice number'); $DbgMsg = _('The following SQL to update the sales order was used'); @@ -739,44 +739,41 @@ /*Now insert the DebtorTrans */ - $SQL = "INSERT INTO debtortrans ( - transno, - type, - debtorno, - branchcode, - trandate, - inputdate, - prd, - reference, - tpe, - order_, - ovamount, - ovgst, - ovfreight, - rate, - invtext, - shipvia, - consignment - ) - VALUES ( - '". $InvoiceNo . "', - 10, - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - '" . $DefaultDispatchDate . "', - '" . date('Y-m-d H-i-s') . "', - '" . $PeriodNo . "', - '', - '" . $_SESSION['Items']->DefaultSalesType . "', - '" . $_SESSION['ProcessingOrder'] . "', - '" . $_SESSION['Items']->total . "', - '" . $TaxTotal . "', - '" . $_POST['ChargeFreightCost'] . "', - '" . $_SESSION['CurrencyRate'] . "', - '" . $_POST['InvoiceText'] . "', - '" . $_SESSION['Items']->ShipVia . "', - '" . $_POST['Consignment'] . "' - )"; + $SQL = "INSERT INTO debtortrans ( transno, + type, + debtorno, + branchcode, + trandate, + inputdate, + prd, + reference, + tpe, + order_, + ovamount, + ovgst, + ovfreight, + rate, + invtext, + shipvia, + consignment ) + VALUES ( + '". $InvoiceNo . "', + 10, + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + '" . $DefaultDispatchDate . "', + '" . date('Y-m-d H-i-s') . "', + '" . $PeriodNo . "', + '', + '" . $_SESSION['Items']->DefaultSalesType . "', + '" . $_SESSION['ProcessingOrder'] . "', + '" . $_SESSION['Items']->total . "', + '" . $TaxTotal . "', + '" . $_POST['ChargeFreightCost'] . "', + '" . $_SESSION['CurrencyRate'] . "', + '" . $_POST['InvoiceText'] . "', + '" . $_SESSION['Items']->ShipVia . "', + '" . $_POST['Consignment'] . "' )"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction record was used'); @@ -788,11 +785,11 @@ foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) { $SQL = "INSERT INTO debtortranstaxes (debtortransid, - taxauthid, - taxamount) - VALUES ('" . $DebtorTransID . "', - '" . $TaxAuthID . "', - '" . $TaxAmount/$_SESSION['CurrencyRate'] . "')"; + taxauthid, + taxamount) + VALUES ('" . $DebtorTransID . "', + '" . $TaxAuthID . "', + '" . $TaxAmount/$_SESSION['CurrencyRate'] . "')"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used'); @@ -804,12 +801,28 @@ foreach ($_SESSION['Items']->LineItems as $OrderLine) { + /*Test to see if the item being sold is an asset */ + if (substr($OrderLine->StockID,0,6)=='ASSET-'){ + $IsAsset = true; + $HyphenOccursAt = strpos($OrderLine->StockID,'-',6); + if ($HyphenOccursAt == false){ + $AssetNumber = intval(substr($OrderLine->StockID,6)); + } else { + $AssetNumber = intval(substr($OrderLine->StockID,6,strlen($OrderLine->StockID)-$HyphenOccursAt-1)); + } + prnMsg (_('The asset number beind disposed of is:') . ' ' . $AssetNumber, 'info'); + } else { + $IsAsset = false; + $AssetNumber = 0; + } + + if ($_POST['BOPolicy']=='CAN'){ $SQL = "UPDATE salesorderdetails - SET quantity = quantity - " . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . " - WHERE orderno = '" . $_SESSION['ProcessingOrder'] . " ' - AND stkcode = '" . $OrderLine->StockID . "'"; + SET quantity = quantity - " . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . " + WHERE orderno = '" . $_SESSION['ProcessingOrder'] . " ' + AND stkcode = '" . $OrderLine->StockID . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order detail record could not be updated because'); $DbgMsg = _('The following SQL to update the sales order detail record was used'); @@ -818,24 +831,21 @@ if (($OrderLine->Quantity - $OrderLine->QtyDispatched)>0){ - $SQL = "INSERT INTO orderdeliverydifferenceslog ( - orderno, - invoiceno, - stockid, - quantitydiff, - debtorno, - branch, - can_or_bo - ) - VALUES ( - '" . $_SESSION['ProcessingOrder'] . "', - '" . $InvoiceNo . "', - '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - 'CAN' - )"; + $SQL = "INSERT INTO orderdeliverydifferenceslog ( orderno, + invoiceno, + stockid, + quantitydiff, + debtorno, + branch, + can_or_bo ) + VALUES ( + '" . $_SESSION['ProcessingOrder'] . "', + '" . $InvoiceNo . "', + '" . $OrderLine->StockID . "', + '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + 'CAN')"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because'); $DbgMsg = _('The following SQL to insert the order delivery differences record was used'); @@ -848,25 +858,24 @@ /*The order is being short delivered after the due date - need to insert a delivery differnce log */ - $SQL = "INSERT INTO orderdeliverydifferenceslog ( - orderno, - invoiceno, - stockid, - quantitydiff, - debtorno, - branch, - can_or_bo - ) - VALUES ( - '" . $_SESSION['ProcessingOrder'] . "', - '" . $InvoiceNo . "', - '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - 'BO' - )"; - + $SQL = "INSERT INTO orderdeliverydifferenceslog ( orderno, + invoiceno, + stockid, + quantitydiff, + debtorno, + branch, + can_or_bo + ) + VALUES ( + '" . $_SESSION['ProcessingOrder'] . "', + '" . $InvoiceNo . "', + '" . $OrderLine->StockID . "', + '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + 'BO' + )"; + $ErrMsg = '<br>' . _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because'); $DbgMsg = _('The following SQL to insert the order delivery differences record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -878,18 +887,16 @@ // Test above to see if the line is completed or not if ($OrderLine->QtyDispatched>=($OrderLine->Quantity - $OrderLine->QtyInv) OR $_POST['BOPolicy']=="CAN"){ - $SQL = "UPDATE salesorderdetails - SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", - actualdispatchdate = '" . $DefaultDispatchDate . "', - completed=1 - WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' - AND orderlineno = '" . $OrderLine->LineNumber . "'"; + $SQL = "UPDATE salesorderdetails SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", + actualdispatchdate = '" . $DefaultDispatchDate . "', + completed=1 + WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' + AND orderlineno = '" . $OrderLine->LineNumber . "'"; } else { - $SQL = "UPDATE salesorderdetails - SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", - actualdispatchdate = '" . $DefaultDispatchDate . "' - WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' - AND orderlineno = '" . $OrderLine->LineNumber . "'"; + $SQL = "UPDATE salesorderdetails SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", + actualdispatchdate = '" . $DefaultDispatchDate . "' + WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' + AND orderlineno = '" . $OrderLine->LineNumber . "'"; } @@ -900,23 +907,23 @@ /* Update location stock records if not a dummy stock item need the MBFlag later too so save it to $MBFlag */ $Result = DB_query("SELECT mbflag - FROM stockmaster - WHERE stockid = '" . $OrderLine->StockID . "'",$db,"<br>Can't retrieve the mbflag"); + FROM stockmaster + WHERE stockid = '" . $OrderLine->StockID . "'",$db, _('Cannot retrieve the mbflag')); $myrow = DB_fetch_row($Result); $MBFlag = $myrow[0]; - if ($MBFlag=="B" OR $MBFlag=="M") { + if ($MBFlag=='B' OR $MBFlag=='M') { $Assembly = False; /* Need to get the current location quantity will need it later for the stock movement */ - $SQL="SELECT locstock.quantity - FROM locstock - WHERE locstock.stockid='" . $OrderLine->StockID . "' - AND loccode= '" . $_SESSION['Items']->Location . "'"; + $SQL="SELECT locstock.quantity + FROM locstock + WHERE locstock.stockid='" . $OrderLine->StockID . "' + AND loccode= '" . $_SESSION['Items']->Location . "'"; $ErrMsg = _('WARNING') . ': ' . _('Could not retrieve current location stock'); - $Result = DB_query($SQL, $db, $ErrMsg); + $Result = DB_query($SQL, $db, $ErrMsg); if (DB_num_rows($Result)==1){ $LocQtyRow = DB_fetch_row($Result); @@ -926,8 +933,7 @@ $QtyOnHandPrior = 0; } - $SQL = "UPDATE locstock - SET quantity = locstock.quantity - " . $OrderLine->QtyDispatched . " + $SQL = "UPDATE locstock SET quantity = locstock.quantity - " . $OrderLine->QtyDispatched . " WHERE locstock.stockid = '" . $OrderLine->StockID . "' AND loccode = '" . $_SESSION['Items']->Location . "'"; @@ -1026,7 +1032,7 @@ $_SESSION['Items']->LineItems[$OrderLine->LineNumber]->StandardCost = $StandardCost; $OrderLine->StandardCost = $StandardCost; } /* end of its an assembly */ - + // Insert stock movements - with unit cost $LocalCurrencyPrice= ($OrderLine->Price / $_SESSION['CurrencyRate']); @@ -1034,71 +1040,69 @@ $OrderLine->StandardCost=0; } if ($MBFlag=='B' OR $MBFlag=='M'){ - $SQL = "INSERT INTO stockmoves ( - stockid, - type, - transno, - loccode, - trandate, - debtorno, - branchcode, - price, - prd, - reference, - qty, - discountpercent, - standardcost, - newqoh, - narrative ) - VALUES ('" . $OrderLine->StockID . "', - 10, - '" . $InvoiceNo . "', - '" . $_SESSION['Items']->Location . "', - '" . $DefaultDispatchDate . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - '" . $LocalCurrencyPrice . "', - '" . $PeriodNo . "', - '" . $_SESSION['ProcessingOrder'] . "', - '" . -$OrderLine->QtyDispatched . "', - '" . $OrderLine->DiscountPercent . "', - '" . $OrderLine->StandardCost . "', - '" . ($QtyOnHandPrior - $OrderLine->QtyDispatched) . "', - '" . DB_escape_string($OrderLine->Narrative) . "' )"; + $SQL = "INSERT INTO stockmoves ( stockid, + type, + transno, + loccode, + trandate, + debtorno, + branchcode, + price, + prd, + reference, + qty, + discountpercent, + standardcost, + newqoh, + narrative ) + VALUES ('" . $OrderLine->StockID . "', + 10, + '" . $InvoiceNo . "', + '" . $_SESSION['Items']->Location . "', + '" . $DefaultDispatchDate . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + '" . $LocalCurrencyPrice . "', + '" . $PeriodNo . "', + '" . $_SESSION['ProcessingOrder'] . "', + '" . -$OrderLine->QtyDispatched . "', + '" . $OrderLine->DiscountPercent . "', + '" . $OrderLine->StandardCost . "', + '" . ($QtyOnHandPrior - $OrderLine->QtyDispatched) . "', + '" . DB_escape_string($OrderLine->Narrative) . "' )"; } else { // its an assembly or dummy and assemblies/dummies always have nil stock (by definition they are made up at the time of dispatch so new qty on hand will be nil if (empty($OrderLine->StandardCost)) { $OrderLine->StandardCost=0; } - $SQL = "INSERT INTO stockmoves ( - stockid, - type, - transno, - loccode, - trandate, - debtorno, - branchcode, - price, - prd, - reference, - qty, - discountpercent, - standardcost, - narrative ) - VALUES ('" . $OrderLine->StockID . "', - 10, - '" . $InvoiceNo . "', - '" . $_SESSION['Items']->Location . "', - '" . $DefaultDispatchDate . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - '" . $LocalCurrencyPrice . "', - '" . $PeriodNo . "', - '" . $_SESSION['ProcessingOrder'] . "', - '" . -$OrderLine->QtyDispatched . "', - '" . $OrderLine->DiscountPercent . "', - '" . $OrderLine->StandardCost . "', - '" . DB_escape_string($OrderLine->Narrative) . "')"; + $SQL = "INSERT INTO stockmoves ( stockid, + type, + transno, + loccode, + trandate, + debtorno, + branchcode, + price, + prd, + reference, + qty, + discountpercent, + standardcost, + narrative ) + VALUES ('" . $OrderLine->StockID . "', + 10, + '" . $InvoiceNo . "', + '" . $_SESSION['Items']->Location . "', + '" . $DefaultDispatchDate . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + '" . $LocalCurrencyPrice . "', + '" . $PeriodNo . "', + '" . $_SESSION['ProcessingOrder'] . "', + '" . -$OrderLine->QtyDispatched . "', + '" . $OrderLine->DiscountPercent . "', + '" . $OrderLine->StandardCost . "', + '" . DB_escape_string($OrderLine->Narrative) . "')"; } @@ -1113,15 +1117,15 @@ foreach ($OrderLine->Taxes as $Tax) { $SQL = "INSERT INTO stockmovestaxes (stkmoveno, - taxauthid, - taxrate, - taxcalculationorder, - taxontax) - VALUES ('" . $StkMoveNo . "', - '" . $Tax->TaxAuthID . "', - '" . $Tax->TaxRate . "', - '" . $Tax->TaxCalculationOrder . "', - '" . $Tax->TaxOnTax . "')"; + taxauthid, + taxrate, + taxcalculationorder, + taxontax) + VALUES ('" . $StkMoveNo . "', + '" . $Tax->TaxAuthID . "', + '" . $Tax->TaxRate . "', + '" . $Tax->TaxCalculationOrder . "', + '" . $Tax->TaxOnTax . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Taxes and rates applicable to this invoice line item could not be inserted because'); $DbgMsg = _('The following SQL to insert the stock movement tax detail records was used'); @@ -1136,11 +1140,10 @@ /*We need to add the StockSerialItem record and The StockSerialMoves as well */ - $SQL = "UPDATE stockserialitems - SET quantity= quantity - " . $Item->BundleQty . " - WHERE stockid='" . $OrderLine->StockID . "' - AND loccode='" . $_SESSION['Items']->Location . "' - AND serialno='" . $Item->BundleRef . "'"; + $SQL = "UPDATE stockserialitems SET quantity= quantity - " . $Item->BundleQty . " + WHERE stockid='" . $OrderLine->StockID . "' + AND loccode='" . $_SESSION['Items']->Location . "' + AND serialno='" . $Item->BundleRef . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -1149,13 +1152,13 @@ /* now insert the serial stock movement */ $SQL = "INSERT INTO stockserialmoves (stockmoveno, - stockid, - serialno, - moveqty) - VALUES ('" . $StkMoveNo . "', - '" . $OrderLine->StockID . "', - '" . $Item->BundleRef . "', - '" . -$Item->BundleQty . "')"; + stockid, + serialno, + moveqty) + VALUES ('" . $StkMoveNo . "', + '" . $OrderLine->StockID . "', + '" . $Item->BundleRef . "', + '" . -$Item->BundleQty . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); @@ -1166,14 +1169,14 @@ /*Insert Sales Analysis records */ $SQL="SELECT COUNT(*), - salesanalysis.stockid, - salesanalysis.stkcategory, - salesanalysis.cust, - salesanalysis.custbranch, - salesanalysis.area, - salesanalysis.periodno, - salesanalysis.typeabbrev, - salesanalysis.salesperson + salesanalysis.stockid, + salesanalysis.stkcategory, + salesanalysis.cust, + salesanalysis.custbranch, + salesanalysis.area, + salesanalysis.periodno, + salesanalysis.typeabbrev, + salesanalysis.salesperson FROM salesanalysis, custbranch, stockmaster @@ -1206,56 +1209,53 @@ if ($myrow[0]>0){ /*Update the existing record that already exists */ - $SQL = "UPDATE salesanalysis - SET amt=amt+" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . ", - cost=cost+" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . ", - qty=qty +" . $OrderLine->QtyDispatched . ", - disc=disc+" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . " - WHERE salesanalysis.area='" . $myrow[5] . "' - AND salesanalysis.salesperson='" . $myrow[8] . "' - AND typeabbrev ='" . $_SESSION['Items']->DefaultSalesType . "' - AND periodno = '" . $PeriodNo . "' - AND cust " . LIKE . " '" . $_SESSION['Items']->DebtorNo . "' - AND custbranch " . LIKE . " '" . $_SESSION['Items']->Branch . "' - AND stockid " . LIKE . " '" . $OrderLine->StockID . "' - AND salesanalysis.stkcategory ='" . $myrow[2] . "' - AND budgetoractual=1"; + $SQL = "UPDATE salesanalysis SET amt=amt+" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . ", + cost=cost+" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . ", + qty=qty +" . $OrderLine->QtyDispatched . ", + disc=disc+" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . " + WHERE salesanalysis.area='" . $myrow[5] . "' + AND salesanalysis.salesperson='" . $myrow[8] . "' + AND typeabbrev ='" . $_SESSION['Items']->DefaultSalesType . "' + AND periodno = '" . $PeriodNo . "' + AND cust " . LIKE . " '" . $_SESSION['Items']->DebtorNo . "' + AND custbranch " . LIKE . " '" . $_SESSION['Items']->Branch . "' + AND stockid " . LIKE . " '" . $OrderLine->StockID . "' + AND salesanalysis.stkcategory ='" . $myrow[2] . "' + AND budgetoractual=1"; } else { /* insert a new sales analysis record */ - $SQL = "INSERT INTO salesanalysis ( - typeabbrev, - periodno, - amt, - cost, - cust, - custbranch, - qty, - disc, - stockid, - area, - budgetoractual, - salesperson, - stkcategory - ) - SELECT '" . $_SESSION['Items']->DefaultSalesType . "', - '" . $PeriodNo . "', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', - '" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . $_SESSION['Items']->Branch . "', - '" . $OrderLine->QtyDispatched . "', - '" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', - '" . $OrderLine->StockID . "', - custbranch.area, - 1, - custbranch.salesman, - stockmaster.categoryid - FROM stockmaster, - custbranch - WHERE stockmaster.stockid = '" . $OrderLine->StockID . "' - AND custbranch.debtorno = '" . $_SESSION['Items']->DebtorNo . "' - AND custbranch.branchcode='" . $_SESSION['Items']->Branch . "'"; + $SQL = "INSERT INTO salesanalysis (typeabbrev, + periodno, + amt, + cost, + cust, + custbranch, + qty, + disc, + stockid, + area, + budgetoractual, + salesperson, + stkcategory ) + SELECT '" . $_SESSION['Items']->DefaultSalesType . "', + '" . $PeriodNo . "', + '" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', + '" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . $_SESSION['Items']->Branch . "', + '" . $OrderLine->QtyDispatched . "', + '" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', + '" . $OrderLine->StockID . "', + custbranch.area, + 1, + custbranch.salesman, + stockmaster.categoryid + FROM stockmaster, + custbranch + WHERE stockmaster.stockid = '" . $OrderLine->StockID . "' + AND custbranch.debtorno = '" . $_SESSION['Items']->DebtorNo . "' + AND custbranch.branchcode='" . $_SESSION['Items']->Branch . "'"; } $ErrMsg = _('Sales analysis record could not be added or updated because'); @@ -1264,107 +1264,251 @@ /* If GLLink_Stock then insert GLTrans to credit stock and debit cost of sales at standard cost*/ - if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND $OrderLine->StandardCost !=0){ + if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND $OrderLine->StandardCost !=0 AND ! $IsAsset){ -/*first the cost of sales entry*/ +/*first the cost of sales entry - GL accounts are retrieved using the function GetCOGSGLAccount from includes/GetSalesTransGLCodes.inc */ - $SQL = "INSERT INTO gltrans ( - type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ( - 10, - '" . $InvoiceNo . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . "', - '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . $OrderLine->StandardCost * $OrderLine->QtyDispatched . "')"; - + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', + '" . $OrderLine->StandardCost * $OrderLine->QtyDispatched . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); -/*now the stock entry*/ +/*now the stock entry - this is set to the cost act in the case of a fixed asset disposal */ $StockGLCode = GetStockGLCode($OrderLine->StockID,$db); - $SQL = "INSERT INTO gltrans ( - type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ( - 10, - '" . $InvoiceNo . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . $StockGLCode['stockact'] . "', - '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; - + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $StockGLCode['stockact'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', + '" . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - } /* end of if GL and stock integrated and standard cost !=0 */ - + } /* end of if GL and stock integrated and standard cost !=0 and not an asset */ + if ($_SESSION['CompanyRecord']['gllink_debtors']==1 AND $OrderLine->Price !=0){ - //Post sales transaction to GL credit sales - $SalesGLAccounts = GetSalesGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db); - - $SQL = "INSERT INTO gltrans ( - type, - typeno, - trandate, - periodno, - account, - narrative, - amount ) - VALUES ( - 10, - '" . $InvoiceNo . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . $SalesGLAccounts['salesglcode'] . "', - '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "', - '" . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . "')"; - - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because'); + if (!$IsAsset){ // its a normal stock item + //Post sales transaction to GL credit sales + $SalesGLAccounts = GetSalesGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db); + + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $SalesGLAccounts['salesglcode'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "', + '" . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because'); + $DbgMsg = '<br>' ._('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + if ($OrderLine->DiscountPercent !=0){ + + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $SalesGLAccounts['discountglcode'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . ($OrderLine->DiscountPercent * 100) . "%', + '" . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because'); + $DbgMsg = _('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } /*end of if discount !=0 */ + + } else { + /* then the item being sold is an asset disposal + * the cost of sales account will be the gain or loss on disposal account + * from the fixed asset categories table */ + $SQL = "SELECT cost, + accumdepn, + costact, + accumdepnact, + disposalact + FROM fixedassetcategories INNER JOIN fixedassets + ON fixedassetcategories.categoryid = fixedassets.assetcategoryid + WHERE assetid ='" . $AssetNumber . "'"; + $ErrMsg = _('The asset disposal GL posting details could not be retrieved because'); + $DbgMsg = _('The following SQL was used to get the asset posting details'); + $DisposalResult = DB_query( $SQL,$db,$ErrMsg,$DbgMsg); + $DisposalRow = DB_fetch_array($DisposalResult); + + /*Need to : + * 1.) debit accum depn account with whole amount of accum depn + * 2.) credit cost account with the whole amount of the cost + * 3.) debit the disposal account with the NBV + * 4.) credit the disposal account with the sale proceeds net of discounts */ + + /* 1 debit accum depn */ + if ($DisposalRow['accumdpen']!=0){ + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $DisposalRow['accumdepnact'] . "', + '" . $_SESSION['Items']->DebtorNo . ' - ' . $OrderLine->StockID . ' ' . _('disposal') . "', + '" . -$DisposalRow['accumdpen'] . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The reversal of accumulated depreciation GL posting on disposal could not be inserted because'); + $DbgMsg = _('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } + /* 2 credit cost */ + if($DisposalRow['cost']!=0){ + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $DisposalRow['costact'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', + '" . -$DisposalRow['cost'] . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The reversal of asset cost on dispoal GL posting could not be inserted because'); + $DbgMsg = _('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } + //3. Debit disposal account with NBV + if($DisposalRow['cost']-$DisposalRow['accumdepn']!=0){ + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $DisposalRow['disposalact'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', + '" . ($DisposalRow['cost']-$DisposalRow['accumdepn']) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal net book value GL posting could not be inserted because'); + $DbgMsg = '<br>' ._('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } + + //4. Credit the disposal account with the proceeds + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $DisposalRow['disposalact'] . "', + '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', + '" . (-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal proceeds GL posting could not be inserted because'); $DbgMsg = '<br>' ._('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - if ($OrderLine->DiscountPercent !=0){ - - $SQL = "INSERT INTO gltrans ( - type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ( - 10, - '" . $InvoiceNo . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . $SalesGLAccounts['discountglcode'] . "', - '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . ($OrderLine->DiscountPercent * 100) . "%', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . "')"; - - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because'); - $DbgMsg = _('The following SQL to insert the GLTrans record was used'); - $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - } /*end of if discount !=0 */ + } // end if the item being sold was an asset } /*end of if sales integrated with debtors */ - + + if ($IsAsset) { + /* then the item being sold is an asset disposal + * need to create fixedassettrans + * set disposal date and proceeds + */ + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + transno, + periodno, + inputdate, + fixedassettranstype, + amount, + transdate) + VALUES ('" . $AssetNumber . "', + 10, + '" . $InvoiceNo . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + 'disposal', + '" . ($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', + '" . $DefaultDispatchDate . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The fixed asset transaction could not be inserted because'); + $DbgMsg = '<br>' ._('The following SQL to insert the fixed asset transaction record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + $SQL = "UPDATE fixedassets SET disposalproceeds ='" . ($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', + disposaldate ='" . $DefaultDispatchDate . "' + WHERE assetid ='" . $AssetNumber . "'"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The fixed asset record could not be updated for the disposal because'); + $DbgMsg = '<br>' ._('The following SQL to update the fixed asset record was used'); + $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + } } /*Quantity dispatched is more than 0 */ } /*end of OrderLine loop */ @@ -1373,22 +1517,21 @@ /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ if (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal) !=0) { - $SQL = "INSERT INTO gltrans ( - type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES ( - 10, - '" . $InvoiceNo . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . $_SESSION['CompanyRecord']['debtorsact'] . "', - '" . $_SESSION['Items']->DebtorNo . "', - '" . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . "')"; + $SQL = "INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES ( + 10, + '" . $InvoiceNo . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['debtorsact'] . "', + '" . $_SESSION['Items']->DebtorNo . "', + '" . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the total debtors control GLTrans record was used'); Modified: trunk/FixedAssetRegister.php =================================================================== --- trunk/FixedAssetRegister.php 2010-12-18 05:18:08 UTC (rev 4185) +++ trunk/FixedAssetRegister.php 2010-12-19 01:10:36 UTC (rev 4186) @@ -23,10 +23,12 @@ fixedassets.datepurchased, fixedassetlocations.parentlocationid, fixedassets.assetlocation, + fixedassets.disposaldate, SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom . '" AND fixedassettrans.fixedassettranstype="cost") THEN fixedassettrans.amount ELSE 0 END) AS bfwdcost, SUM(CASE WHEN (fixedassettrans.transdate <"' . $DateFrom .'" AND fixedassettrans.fixedassettranstype="depn") THEN fixedassettrans.amount ELSE 0 END) AS bfwddepn, SUM(CASE WHEN (fixedassettrans.transdate >="' . $DateFrom .'" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="cost") THEN fixedassettrans.amount ELSE 0 END) AS periodadditions, - SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="depn" THEN fixedassettrans.amount ELSE 0 END) AS perioddepn + SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="depn" THEN fixedassettrans.amount ELSE 0 END) AS perioddepn, + SUM(CASE WHEN fixedassettrans.transdate >="' . $DateFrom . '" AND fixedassettrans.transdate <="' . $DateTo . '" AND fixedassettrans.fixedassettranstype="disposal" THEN fixedassettrans.amount ELSE 0 END) AS perioddisposal FROM fixedassets INNER JOIN fixedassetcategories ON fixedassets.assetcategoryid=fixedassetcategories.categoryid INNER JOIN fixedassetlocations ON fixedassets.assetlocation=fixedassetlocations.locationid @@ -111,68 +113,80 @@ $Ancestors[$i] = $ParentRow['locationdescription']; } */ - - if (isset($_POST['pdf'])) { - $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 30 - $Left_Margin, $FontSize, $myrow['assetid']); - $LeftOvers = $pdf->addTextWrap($XPos + 30, $YPos, 150 - $Left_Margin, $FontSize, $myrow['description']); - $LeftOvers = $pdf->addTextWrap($XPos + 180, $YPos, 40 - $Left_Margin, $FontSize, $myrow['serialno']); - /* - * $TempYPos = $YPos; - for ($i = 1;$i < sizeof($Ancestors) - 1;$i++) { - for ($j = 0;$j < $i;$j++) { - $TempYPos-= (0.8 * $line_height); - $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, ' '); - } - $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, '|_' . $Ancestors[$i]); + if (Date1GreaterThanDate2(ConvertSQLDate($myrow['disposaldate']),$_POST['FromDate']) OR $myrow['disposaldate']='0000-00-00'){ + + if (Date1GreaterThanDate2($_POST['ToDate'], ConvertSQLDate($myrow['disposaldate']))){ + /*The asset was disposed during the period */ + $CostCfwd = 0; + $AccumDepnCfwd = 0; + } else { + $CostCfwd = $myrow['periodadditions'] + $myrow['costbfwd']; + $AccumDepnCfwd = $myrow['periodepn'] + $myrow['depnbfwd']; } - * */ - $LeftOvers = $pdf->addTextWrap($XPos + 220, $YPos, 50 - $Left_Margin, $FontSize, ConvertSQLDate($myrow['datepurchased'])); - $LeftOvers = $pdf->addTextWrap($XPos + 270, $YPos, 70, $FontSize, number_format($myrow['costbfwd'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 340, $YPos, 70, $FontSize, number_format($myrow['depnbfwd'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 410, $YPos, 70, $FontSize, number_format($myrow['periodadditions'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 480, $YPos, 70, $FontSize, number_format($myrow['perioddepn'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 550, $YPos, 70, $FontSize, number_format($myrow['periodadditions'] + $myrow['costbfwd'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 620, $YPos, 70, $FontSize, number_format($myrow['periodepn'] + $myrow['depnbfwd'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($XPos + 690, $YPos, 70, $FontSize, number_format($myrow['periodadditions'] + $myrow['costbfwd'] - $myrow['periodepn'] - $myrow['depnbfwd'], 0), 'right'); - - $YPos = $TempYPos - (0.8 * $line_height); - if ($YPos < $Bottom_Margin + $line_height) { - PDFPageHeader(); - } - } elseif (isset($_POST['csv'])) { - $csv_output.= $myrow['assetid'] . "," . $myrow['longdescription'] .",".$myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['costbfwd'].",".$myrow['periodadditions']."," . $myrow['depnbfwd'] . "," .$myrow['perioddepn'].",".($myrow['costbfwd']+$myrow['periodadditions']). ", " . ($myrow['depnbfwd']+$myrow['perioddepn']) . ", " . ($myrow['costbfwd']+$myrow['periodadditions']-$myrow['depnbfwd']-$myrow['perioddepn']) . "\n"; - - } else { - echo '<tr><td style="vertical-align:top">' . $myrow['assetid'] . '</td>'; - echo '<td style="vertical-align:top">' . $myrow['longdescription'] . '</td>'; - echo '<td style="vertical-align:top">' . $myrow['serialno'] . '</td>'; - echo '<td>' . $myrow['locationdescription'] . '<br>'; - for ($i = 1;$i < sizeOf($Ancestors) - 1;$i++) { - for ($j = 0;$j < $i;$j++) { - echo ' '; + if (isset($_POST['pdf'])) { + + $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 30 - $Left_Margin, $FontSize, $myrow['assetid']); + $LeftOvers = $pdf->addTextWrap($XPos + 30, $YPos, 150 - $Left_Margin, $FontSize, $myrow['description']); + $LeftOvers = $pdf->addTextWrap($XPos + 180, $YPos, 40 - $Left_Margin, $FontSize, $myrow['serialno']); + /* + * $TempYPos = $YPos; + for ($i = 1;$i < sizeof($Ancestors) - 1;$i++) { + for ($j = 0;$j < $i;$j++) { + $TempYPos-= (0.8 * $line_height); + $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, ' '); + } + $LeftOvers = $pdf->addTextWrap($XPos + 300, $TempYPos, 300 - $Left_Margin, $FontSize, '|_' . $Ancestors[$i]); } - echo '|_' . $Ancestors[$i] . '<br>'; + * */ + + $LeftOvers = $pdf->addTextWrap($XPos + 220, $YPos, 50 - $Left_Margin, $FontSize, ConvertSQLDate($myrow['datepurchased'])); + $LeftOvers = $pdf->addTextWrap($XPos + 270, $YPos, 70, $FontSize, number_format($myrow['costbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 340, $YPos, 70, $FontSize, number_format($myrow['depnbfwd'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 410, $YPos, 70, $FontSize, number_format($myrow['periodadditions'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 480, $YPos, 70, $FontSize, number_format($myrow['perioddepn'], 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 550, $YPos, 70, $FontSize, number_format($CostCfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 620, $YPos, 70, $FontSize, number_format($AccumDepnCfwd, 0), 'right'); + $LeftOvers = $pdf->addTextWrap($XPos + 690, $YPos, 70, $FontSize, number_format($CostCfwd - $AccumDepnCfwd, 0), 'right'); + + $YPos = $TempYPos - (0.8 * $line_height); + if ($YPos < $Bottom_Margin + $line_height) { + PDFPageHeader(); + } + } elseif (isset($_POST['csv'])) { + $csv_output.= $myrow['assetid'] . "," . $myrow['longdescription'] .",".$myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['costbfwd'].",".$myrow['periodadditions']."," . $myrow['depnbfwd'] . "," .$myrow['perioddepn'].",". $CostCfwd . ", " . $AccumDepnCfwd . ", " . ($CostCfwd - $AccumDepnCfwd) . "," . $myrow['perioddisposal'] . "\n"; + + } else { + echo '<tr><td style="vertical-align:top">' . $myrow['assetid'] . '</td>'; + echo '<td style="vertical-align:top">' . $myrow['longdescription'] . '</td>'; + echo '<td style="vertical-align:top">' . $myrow['serialno'] . '</td>'; + echo '<td>' . $myrow['locationdescription'] . '<br>'; + for ($i = 1;$i < sizeOf($Ancestors) - 1;$i++) { + for ($j = 0;$j < $i;$j++) { + echo ' '; + } + echo '|_' . $Ancestors[$i] . '<br>'; + } + echo '</td><td style="vertical-align:top">' . ConvertSQLDate($myrow['datepurchased']) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['depnbfwd'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['periodadditions'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddepn'], 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($CostCfwd , 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($AccumDepnCfwd, 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($CostCfwd - $AccumDepnCfwd, 2) . '</td>'; + echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddisposal'], 2) . '</td></tr>'; } - echo '</td><td style="vertical-align:top">' . ConvertSQLDate($myrow['datepurchased']) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['depnbfwd'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['periodadditions'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddepn'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd']+$myrow['periodadditions'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['perioddepn']+$myrow['depnbfwd'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['costbfwd']+$myrow['periodadditions']-$myrow['perioddepn']-$myrow['depnbfwd'], 2) . '</td>'; - - //echo '<td style="vertical-align:top" class=number>' . number_format($myrow['disposalvalue'], 2) . '</td></tr>'; - } + } // end of if the asset was either not disposed yet or disposed af... [truncated message content] |
From: <dai...@us...> - 2010-12-19 03:37:15
|
Revision: 4187 http://web-erp.svn.sourceforge.net/web-erp/?rev=4187&view=rev Author: daintree Date: 2010-12-19 03:37:08 +0000 (Sun, 19 Dec 2010) Log Message: ----------- Fixed asset disposals Modified Paths: -------------- trunk/doc/Change.log.html trunk/doc/Manual/ManualFixedAssets.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-19 01:10:36 UTC (rev 4186) +++ trunk/doc/Change.log.html 2010-12-19 03:37:08 UTC (rev 4187) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>19/12/10 Phil: SelectOrderItems.php ConfirmDispatch_Invoice.php add code to handle asset disposals. <p>14/12/10 Phil: modify purchasing scripts for coding conventions/readability</p> <p>11/12/10 Phil: Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made</p> <p>9/12/10 James Murray: highlighted a bug in SupplierInvoice.php (and also in SupplierCredit.php) where the due date of the invoice/credit was not calculated correctly based on the terms - it was picking up the current date rather than the invoice/credit date. Now fixed</p> Modified: trunk/doc/Manual/ManualFixedAssets.html =================================================================== --- trunk/doc/Manual/ManualFixedAssets.html 2010-12-19 01:10:36 UTC (rev 4186) +++ trunk/doc/Manual/ManualFixedAssets.html 2010-12-19 03:37:08 UTC (rev 4187) @@ -40,6 +40,10 @@ <br><br> The depreciation run must be run monthly to create the general ledger journals for depreciation at the rates and depreciation methods defined for the assets. In addition to the general ledger journals a log of the depreciation transactions is also created. The depreciation run checks the last month it was run and defaults to run for the following month ... in this way every time it is run it is self evident whether it has been run for the month under review. There is no functionality to reverse a depreciation run. <br><br> +<font size="+1"><b>Fixed Asset Disposals</b></font> +<br><br> +To dispose of a fixed - an invoice is raised for a fixed asset in the usual order entry screen. Instead of selecting a stock item, there is a button that allows a fixed asset to be selected. By selecting a fixed asset to be sold, the system creates a stock item for the fixed asset. When the sales order is confirmed for invoicing and if the debtors ledger is integrated into the general ledger then entries to dispose of the asset to the general ledger accounts defined in the fixed asset category of the asset are created. The fixed asset transaction is created for the disposal and the fixed asset updated to show the date it was disposed and the proceeds on the disposal. +<br><br> <font size="+1"><b>Fixed Asset Schedule</b></font> <br><br> The fixed asset schedule requires the entry of a starting date and an end date. The script can produce a pdf report, comma separated values for importing into a spreadsheet, or just view in html on screen. It shows the cost b/fwd at the start date, the total of any additions subsequent to the start date, the depreciation brought forward and the depreciation charged over the period, together with the carried forward cost, accumulated depreciation and net book value. Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 01:10:36 UTC (rev 4186) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 03:37:08 UTC (rev 4187) @@ -103,27 +103,7 @@ ALTER TABLE woserialnos CONVERT TO CHARACTER SET utf8; ALTER TABLE www_users CONVERT TO CHARACTER SET utf8; -CREATE TABLE IF NOT EXISTS `fixedassetlocations` ( - `locationid` char(6) NOT NULL default '', - `locationdescription` char(20) NOT NULL default '', - `parentlocationid` char(6) DEFAULT '', - PRIMARY KEY (`locationid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -DROP TABLE IF EXISTS `assetmanager`; - -CREATE TABLE `assetmanager` ( - `id` int(11) NOT NULL auto_increment, - `stockid` varchar(20) NOT NULL default '', - `serialno` varchar(30) NOT NULL default '', - `location` varchar(15) NOT NULL default '', - `cost` double NOT NULL default '0', - `depn` double NOT NULL default '0', - `datepurchased` date NOT NULL default '0000-00-00', - `disposalvalue` int(11) NOT NULL DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - UPDATE `www_users` SET `modulesallowed`=(SELECT insert(`modulesallowed`, 15,0,"1,")); INSERT INTO `config` (`confname`, `confvalue`) VALUES ('FrequentlyOrderedItems',0); ALTER TABLE `www_users` CHANGE COLUMN `language` `language` varchar(10) NOT NULL DEFAULT 'en_GB.utf8'; @@ -437,20 +417,6 @@ ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, ADD `numericvalue` TINYINT NOT NULL DEFAULT 0 ; -RENAME TABLE assetmanager to fixedassets; -ALTER TABLE fixedassets ADD COLUMN `assetcategoryid` varchar(6) NOT NULL DEFAULT ''; -ALTER TABLE fixedassets ADD COLUMN `description` varchar(50) NOT NULL DEFAULT ''; -ALTER TABLE fixedassets ADD COLUMN `longdescription` text NOT NULL; -ALTER TABLE fixedassets ADD COLUMN `depntype` int NOT NULL DEFAULT 1; -ALTER TABLE fixedassets ADD COLUMN `depnrate` double NOT NULL; -ALTER TABLE fixedassets ADD COLUMN `barcode` VARCHAR( 30 ) NOT NULL; -ALTER TABLE fixedassets ADD COLUMN `disposaldate` DATE NOT NULL DEFAULT '0000-00-00'; -ALTER TABLE `fixedassets` CHANGE `depn` `accumdepn` DOUBLE NOT NULL DEFAULT '0'; -ALTER TABLE `fixedassets` CHANGE `location` `assetlocation` VARCHAR( 6 ) NOT NULL DEFAULT ''; -ALTER TABLE `fixedassets` CHANGE `disposalvalue` `disposalproceeds` DOUBLE NOT NULL DEFAULT '0' - -UPDATE fixedassets INNER JOIN stockmaster ON fixedassets.stockid=stockmaster.stockid SET assetcategoryid=stockmaster.categoryid, fixedassets.description=stockmaster.description, fixedassets.longdescription=stockmaster.longdescription; - CREATE TABLE IF NOT EXISTS `fixedassetcategories` ( `categoryid` char(6) NOT NULL DEFAULT '', `categorydescription` char(20) NOT NULL DEFAULT '', @@ -463,27 +429,25 @@ PRIMARY KEY (`categoryid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO fixedassetcategories (categoryid, categorydescription, costact, depnact, disposalact, accumdepnact) SELECT categoryid, categorydescription, stockact, adjglact, materialuseagevarac, wipact FROM stockcategory WHERE stocktype='A'; +CREATE TABLE IF NOT EXISTS `fixedassets` ( + `assetid` int(11) NOT NULL AUTO_INCREMENT, + `serialno` varchar(30) NOT NULL DEFAULT '', + `barcode` varchar(20) NOT NULL, + `assetlocation` varchar(6) NOT NULL DEFAULT '', + `cost` double NOT NULL DEFAULT '0', + `accumdepn` double NOT NULL DEFAULT '0', + `datepurchased` date NOT NULL DEFAULT '0000-00-00', + `disposalproceeds` double NOT NULL DEFAULT '0', + `assetcategoryid` varchar(6) NOT NULL DEFAULT '', + `description` varchar(50) NOT NULL DEFAULT '', + `longdescription` text NOT NULL, + `depntype` int(11) NOT NULL DEFAULT '1', + `depnrate` double NOT NULL, + `disposaldate` date NOT NULL DEFAULT '0000-00-00' + PRIMARY KEY (`assetid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -DELETE locstock.* FROM locstock INNER JOIN stockmaster ON locstock.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; -DELETE stockitemproperties.* FROM stockitemproperties INNER JOIN stockmaster ON stockitemproperties.stockid=stockmaster.stockid INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; - -DELETE stockserialmoves.* FROM stockserialmoves, stockmoves, -stockmaster,stockcategory WHERE stockserialmoves.stockmoveno=stockmoves.stkmoveno AND -stockmoves.stockid = stockmaster.stockid AND stockmaster.categoryid = stockcategory.categoryid AND stockcategory.stocktype = 'A'; - -DELETE stockserialitems.* FROM stockserialitems, stockmaster, stockcategory -WHERE stockserialitems.stockid = stockmaster.stockid AND stockmaster.categoryid=stockcategory.categoryid AND stocktype='A'; - -DELETE stockmoves . * FROM stockmoves, stockmaster, stockcategory WHERE stockmoves.stockid = stockmaster.stockid AND stockmaster.categoryid = stockcategory.categoryid AND stockcategory.stocktype = 'A'; - -DELETE stockmaster.* FROM stockmaster INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid WHERE stockcategory.stocktype='A'; - -ALTER TABLE `fixedassets` CHANGE `id` `assetid` INT( 11 ) NOT NULL AUTO_INCREMENT ; -DELETE FROM stockcategory WHERE stocktype='A'; -ALTER TABLE `fixedassets` DROP `stockid`; - INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('41', 'Asset Addition', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('42', 'Asset Category Change', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('43', 'Delete w/down asset', '1'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-19 09:19:37
|
Revision: 4188 http://web-erp.svn.sourceforge.net/web-erp/?rev=4188&view=rev Author: daintree Date: 2010-12-19 09:19:30 +0000 (Sun, 19 Dec 2010) Log Message: ----------- PO stuff Modified Paths: -------------- trunk/PO_Header.php trunk/doc/Manual/ManualShipments.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/PO_Header.php 2010-12-19 09:19:30 UTC (rev 4188) @@ -99,21 +99,62 @@ if ($_POST['Status'] == 'Rejected' AND $OKToUpdateStatus==1) { - - //need to copy the lines to purchorderdetails_deleted - - if ($AuthorityLevel>$OrderTotal) { - $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Rejected by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; - $_SESSION['PO'.$identifier]->Status=$_POST['Status']; - } else { - $OKToUpdateStatus=0; - prnMsg( _('You do not have permission to reject this purchase order').'.<br>'. _('This order is for').' '. - $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. - _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. - _('If you think this is a mistake please contact the systems administrator') , 'warn'); + $OKToReject = 1; //to start with + if(!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder']!=0) { + /* need to check that not already dispatched or invoiced + * by the supplier */ + + if($_SESSION['PO'.$identifier]->Any_Already_Received()==1){ + $OKToReject =0; //its not ok to reject + prnMsg( _('This order cannot be cancelled because some of it has already been received') . '. ' . + _('The line item quantities may be modified to quantities more than already received') . '. ' . + _('Prices cannot be altered for lines that have already been received') .' '. + _('and quantities cannot be reduced below the quantity already received'),'warn'); + } } + if ($OKToReject==1){ + if ($AuthorityLevel>$OrderTotal) { + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Rejected by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; + } else { + $OKToUpdateStatus=0; + prnMsg( _('You do not have permission to reject this purchase order').'.<br>'. _('This order is for').' '. + $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. + _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. + _('If you think this is a mistake please contact the systems administrator') , 'warn'); + } + } } + if ($_POST['Status'] == 'Cancelled') { + $OKToCancel =1; //to start with + if(!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder']!=0) { + /* need to check that not already dispatched or invoiced + * by the supplier */ + if($_SESSION['PO'.$identifier]->Any_Already_Received()==1){ + $OKToCancel =0; + prnMsg( _('This order cannot be cancelled because some of it has already been received') . '. ' . + _('The line item quantities may be modified to quantities more than already received') . '. ' . + _('Prices cannot be altered for lines that have already been received') .' '. + _('and quantities cannot be reduced below the quantity already received'),'warn'); + } + } + + if ($OKToCancel==1){ + + if ($AuthorityLevel>$OrderTotal) { + $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Cancelled by') . '<a href="mailto:' . $EmailRow['email'] . '">' . $_SESSION['UserID']. '</a>'.$_POST['StatusComments'].'<br>'.$_POST['StatusCommentsComplete']; + $_SESSION['PO'.$identifier]->Status=$_POST['Status']; + } else { + $OKToUpdateStatus=0; + prnMsg( _('You do not have permission to cancel this purchase order').'.<br>'. _('This order is for').' '. + $_SESSION['PO'.$identifier]->CurrCode.' '.$OrderTotal.'. '. + _('Your authorisation limit is set at').' '.$_SESSION['PO'.$identifier]->CurrCode.' '.$AuthorityLevel.'.<br>'. + _('If you think this is a mistake please contact the systems administrator') , 'warn'); + } + } //end if OKToCancel + } + if ($_POST['Status'] == 'Pending' and $OKToUpdateStatus==1) { if ($AuthorityLevel>$OrderTotal or $_SESSION['UserID']==$_SESSION['PO'.$identifier]->Initiator ) { $_SESSION['PO'.$identifier]->StatusComments = date($_SESSION['DefaultDateFormat']).' - ' . _('Returned to Pending status by') . ' <a href="mailto:'. $EmailRow['email'] . '">'.$_SESSION['UserID']. @@ -245,177 +286,7 @@ include ('includes/PO_ReadInOrder.inc'); } -if (isset($_POST['CancelOrder']) AND $_POST['CancelOrder']!='') { -/*The cancel button on the header screen - to delete order */ - $OK_to_delete = 1; //alway assume the best to start with ... until we find out otherwise ... - if(!isset($_SESSION['ExistingOrder']) OR $_SESSION['ExistingOrder']!=0) { - /* need to check that not already dispatched or invoiced - * by the supplier */ - - if($_SESSION['PO'.$identifier]->Any_Already_Received()==1){ - $OK_to_delete =0; - prnMsg( _('This order cannot be cancelled because some of it has already been received') . '. ' . - _('The line item quantities may be modified to quantities more than already received') . '. ' . - _('Prices cannot be altered for lines that have already been received') .' '. - _('and quantities cannot be reduced below the quantity already received'),'warn'); - } - - } - - if ($OK_to_delete==1){ - - if($_SESSION['ExistingOrder']!=0){ - $EmailSQL="SELECT email FROM www_users WHERE userid='".$_SESSION['PO'.$identifier]->Initiator."'"; - $EmailResult=DB_query($EmailSQL, $db); - $EmailRow=DB_fetch_array($EmailResult); - $StatusComment=date($_SESSION['DefaultDateFormat']). ' - ' . _('Order Cancelled by:') . ' <a href="mailto:'.$EmailRow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_POST['StatusCommentsComplete']; - - /* Copy the deleted orders to the purchorder_deleted table so there is an audit trail of who ordered what */ - $sql = "INSERT INTO purchorders_deleted ( orderno, - supplierno, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - status, - stat_comment, - deliverydate, - paymentterms) - SELECT orderno, - supplierno, - comments, - orddate, - rate, - initiator, - requisitionno, - intostocklocation, - deladd1, - deladd2, - deladd3, - deladd4, - deladd5, - deladd6, - tel, - suppdeladdress1, - suppdeladdress2, - suppdeladdress3, - suppdeladdress4, - suppdeladdress5, - suppdeladdress6, - suppliercontact, - supptel, - contact, - version, - revised, - deliveryby, - '" . PurchOrder::STATUS_CANCELLED . "', - '" . $StatusComment . "', - deliverydate, - paymentterms - FROM purchorders - WHERE orderno ='" . $_SESSION['ExistingOrder'] . "'"; - - $ErrMsg = _('The purchase order header record could not be inserted into the database because'); - $DbgMsg = _('The SQL statement used to insert the purchase order header record and failed was'); - $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Insert the purchase order detail records */ - $sql = "INSERT INTO purchorderdetails_deleted ( orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount, - assetid ) - SELECT orderno, - itemcode, - deliverydate, - itemdescription, - glcode, - unitprice, - quantityord, - shiptref, - jobref, - itemno, - uom, - suppliers_partno, - subtotal_amount, - package, - pcunit, - nw, - gw, - cuft, - total_quantity, - total_amount, - assetid - FROM purchorderdetails - WHERE orderno='" . $_SESSION['ExistingOrder'] . "'"; - - $ErrMsg =_('The deleted purchase order detail records could not be inserted into the database because'); - $DbgMsg =_('The SQL statement used to insert the deleted purchase order detail records and failed was'); - $result =DB_query($sql,$db,$ErrMsg,$DbgMsg,true); - - /*Now we have a copy to record the trail - we can delete this order from the database */ - - $sql = "DELETE FROM purchorderdetails - WHERE purchorderdetails.orderno ='" . $_SESSION['ExistingOrder'] ."'"; - $ErrMsg = _('The order detail lines could not be deleted because'); - $DelResult=DB_query($sql,$db,$ErrMsg); - - $sql="DELETE FROM purchorders - WHERE orderno='".$_SESSION['ExistingOrder']."'"; - $ErrMsg = _('The order header could not be deleted because'); - $DelResult=DB_query($sql,$db,$ErrMsg); - prnMsg( _('Order number').' '.$_SESSION['ExistingOrder'].' '._('has been deleted'), 'success'); - unset($_SESSION['ExistingOrder']); - unset($_SESSION['PO'.$identifier]->LineItems); - unset($_SESSION['PO'.$identifier]); - $_SESSION['PO'.$identifier] = new PurchOrder; - $_SESSION['RequireSupplierSelection'] = 1; - } else { //it's not an existing order currently so just clear the session variable to delete it - // Re-Direct to right place - unset($_SESSION['PO'.$identifier]); - prnMsg( _('The creation of the new order has been cancelled'), 'success'); - } - } -} - if (!isset($_SESSION['PO'.$identifier])){ /* It must be a new order being created * $_SESSION['PO'.$identifier] would be set up from the order modification Modified: trunk/doc/Manual/ManualShipments.html =================================================================== --- trunk/doc/Manual/ManualShipments.html 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/doc/Manual/ManualShipments.html 2010-12-19 09:19:30 UTC (rev 4188) @@ -6,7 +6,7 @@ <br><br> The shipment costing system is meant for use in situations where there are substantial freight costs on purchased products and the business wishes to keep track of the actual cost of these items. Many smaller businesses do these calculations on spreadsheets outside the integrated system. The advantage of bringing them inside the system is that the possibility for updating standards and calculation of variances from standard at the time the costing is completed. <br><br> -Having selected a supplier the system allows outstanding purchase order items to be collated into a shipment of goods arriving altogether, the shipment is allocated a shipment number. By changing the expected time of arrival of the shipment (ETA) the delivery date of all purchase order lines on the shipment will be updated. The costs associated with landing and clearing this bundle of products can be entered against it from purchase invoice entry. Freight charges and cartage from the wharf, airfreight, unpacking, demurrage etc can be entered as costs of the shipment. The shipment costing inquiry will show these costs allocated against all of the items on the shipment, using the invoiced value of the items as the basis for apportionment. The actual shipment cost will show together with the existing standard cost and the variance. +Having selected a supplier the system allows outstanding purchase order items to be collated into a shipment of goods arriving altogether, the shipment is allocated a shipment number. By changing the expected time of arrival of the shipment (ETA) the delivery date of all purchase order lines on the shipment will be updated. The costs associated with landing and clearing this bundle of products can be entered against it from purchase invoice entry. Most likely there will be many different supplier/vendor providing services to get the goods from the supplier's warehouse to the business's warehouse. Any number of different supplier's/vendor's charges can be entered against the shipment costing. Freight charges and cartage from the wharf, airfreight, unpacking, demurrage etc can be entered as costs of the shipment. These charges are entered by clicking the shipment charges button on the supplier invoice entry screen. Where a supplier provides freight services, it is possible that the supplier invoice has charges for many different shipments, the supplier invoice entry allows for the invoice to be split between any number of shipments. The shipment costing inquiry will show these costs allocated against all of the items on the shipment, using the invoiced value of the items as the basis for apportionment. The actual shipment cost will show together with the existing standard cost and the variance. <br><br> <font size="+1"><b>Shipment General Ledger Posting</b></font> <br><br> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 03:37:08 UTC (rev 4187) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-19 09:19:30 UTC (rev 4188) @@ -475,86 +475,4 @@ INSERT INTO `systypes` (`typeid` ,`typename` ,`typeno`) VALUES ('49', 'Import Fixed Assets', '1'); -CREATE TABLE `purchorderdetails_deleted` ( -`podetailitem` int(11) NOT NULL, -`orderno` int(11) NOT NULL DEFAULT '0', -`itemcode` varchar(20) NOT NULL DEFAULT '', -`deliverydate` date NOT NULL DEFAULT '0000-00-00', -`itemdescription` varchar(100) NOT NULL DEFAULT '', -`glcode` int(11) NOT NULL DEFAULT '0', -`qtyinvoiced` double NOT NULL DEFAULT '0', -`unitprice` double NOT NULL DEFAULT '0', -`actprice` double NOT NULL DEFAULT '0', -`stdcostunit` double NOT NULL DEFAULT '0', -`quantityord` double NOT NULL DEFAULT '0', -`quantityrecd` double NOT NULL DEFAULT '0', -`shiptref` int(11) NOT NULL DEFAULT '0', -`jobref` varchar(20) NOT NULL DEFAULT '', -`completed` tinyint(4) NOT NULL DEFAULT '0', -`itemno` varchar(50) NOT NULL DEFAULT '', -`uom` varchar(50) NOT NULL DEFAULT '', -`subtotal_amount` varchar(50) NOT NULL DEFAULT '', -`package` varchar(100) NOT NULL DEFAULT '', -`pcunit` varchar(50) NOT NULL DEFAULT '', -`nw` varchar(50) NOT NULL DEFAULT '', -`suppliers_partno` varchar(50) NOT NULL DEFAULT '', -`gw` varchar(50) NOT NULL DEFAULT '', -`cuft` varchar(50) NOT NULL DEFAULT '', -`total_quantity` varchar(50) NOT NULL DEFAULT '', -`total_amount` varchar(50) NOT NULL DEFAULT '', -`assetid` int NOT NULL DEFAULT 0, -PRIMARY KEY (`podetailitem`), -KEY `DeliveryDate` (`deliverydate`), -KEY `GLCode` (`glcode`), -KEY `ItemCode` (`itemcode`), -KEY `JobRef` (`jobref`), -KEY `OrderNo` (`orderno`), -KEY `ShiptRef` (`shiptref`), -KEY `Completed` (`completed`) -) ENGINE=InnoDB; - - -CREATE TABLE `purchorders_deleted` ( -`orderno` int(11) NOT NULL, -`supplierno` varchar(10) NOT NULL DEFAULT '', -`comments` longblob, -`orddate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`rate` double NOT NULL DEFAULT '1', -`dateprinted` datetime DEFAULT NULL, -`allowprint` tinyint(4) NOT NULL DEFAULT '1', -`initiator` varchar(10) DEFAULT NULL, -`requisitionno` varchar(15) DEFAULT NULL, -`intostocklocation` varchar(5) NOT NULL DEFAULT '', -`deladd1` varchar(40) NOT NULL DEFAULT '', -`deladd2` varchar(40) NOT NULL DEFAULT '', -`deladd3` varchar(40) NOT NULL DEFAULT '', -`deladd4` varchar(40) NOT NULL DEFAULT '', -`deladd5` varchar(20) NOT NULL DEFAULT '', -`deladd6` varchar(15) NOT NULL DEFAULT '', -`tel` varchar(15) NOT NULL DEFAULT '', -`suppdeladdress1` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress2` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress3` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress4` varchar(40) NOT NULL DEFAULT '', -`suppdeladdress5` varchar(20) NOT NULL DEFAULT '', -`suppdeladdress6` varchar(15) NOT NULL DEFAULT '', -`suppliercontact` varchar(30) NOT NULL DEFAULT '', -`supptel` varchar(30) NOT NULL DEFAULT '', -`contact` varchar(30) NOT NULL DEFAULT '', -`version` decimal(3,2) NOT NULL DEFAULT '1.00', -`revised` date NOT NULL DEFAULT '0000-00-00', -`realorderno` varchar(16) NOT NULL DEFAULT '', -`deliveryby` varchar(100) NOT NULL DEFAULT '', -`deliverydate` date NOT NULL DEFAULT '0000-00-00', -`status` varchar(12) NOT NULL DEFAULT '', -`stat_comment` text NOT NULL, -`paymentterms` char(2) NOT NULL DEFAULT '', -`port` varchar(40) NOT NULL DEFAULT '', -PRIMARY KEY (`orderno`), -KEY `OrdDate` (`orddate`), -KEY `SupplierNo` (`supplierno`), -KEY `IntoStockLocation` (`intostocklocation`), -KEY `AllowPrintPO` (`allowprint`) -) ENGINE=InnoDB; - UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-12-21 18:24:01
|
Revision: 4190 http://web-erp.svn.sourceforge.net/web-erp/?rev=4190&view=rev Author: daintree Date: 2010-12-21 18:23:54 +0000 (Tue, 21 Dec 2010) Log Message: ----------- Labels SQL plus coding convention amendments Modified Paths: -------------- trunk/PDFPrintLabel.php trunk/doc/Change.log.html trunk/includes/DefineLabelClass.php Modified: trunk/PDFPrintLabel.php =================================================================== --- trunk/PDFPrintLabel.php 2010-12-19 09:25:36 UTC (rev 4189) +++ trunk/PDFPrintLabel.php 2010-12-21 18:23:54 UTC (rev 4190) @@ -6,19 +6,18 @@ $Version_adds= "1.2"; include('includes/session.inc'); -require_once("includes/DefineLabelClass.php"); +require_once('includes/DefineLabelClass.php'); -$msgErr=null; -$decimalplaces=2; -$today = date('Y-m-d'); +$MsgErr=null; +$DecimalPlaces=2; $pdf= null; - $allLabels = //!< The variable $allLabels is the global variable that contains the list + $AllLabels = //!< The variable $AllLabels is the global variable that contains the list getXMLFile(LABELS_FILE); //!< of all the label objects defined until now. In case of a fresh //!< installation or an empty XML labels file it holds a NULL value. // If there is no label templates, the user could select to set up a new one -if ($allLabels==null) { +if ($AllLabels==null) { echo '<br/><br/>'; abortMsg( _("There isn't any label template to select for printing. Click") . ' <a href="Labels.php"><b>' . _('HERE'). '</b></a> '. _('to set up a new one') ); @@ -30,21 +29,21 @@ */ if (isset($_POST['PrintPDF']) OR isset($_POST['PDFTest']) ) { if (!isset($_POST['QtyByItem']) OR (int)$_POST['QtyByItem']<1) - $msgErr = _('You must specify the number of labels per item required'); + $MsgErr = _('You must specify the number of labels per item required'); else { if (count($_POST['StockID'])<1) - $msgErr = _('You must select the items to be printed'); + $MsgErr = _('You must select the items to be printed'); else { // - $label = $allLabels->getLabel($_POST['labelID']); + $label = $AllLabels->getLabel($_POST['LabelID']); list($dimensions, $lines) = resizeLabel($label); $formatPage = getPageDimensions($dimensions); list($Page_Width, - $Page_Height, - $Top_Margin, - $Bottom_Margin, - $Left_Margin, - $Right_Margin) = $formatPage; + $Page_Height, + $Top_Margin, + $Bottom_Margin, + $Left_Margin, + $Right_Margin) = $formatPage; // Do it! $PaperSize = 'User_special'; // Don't use any of the predefined sizes @@ -64,7 +63,7 @@ if ($ok) exit(); // the print was success else // Has been ocurred an error - $msgErr = _('There were an error. Consult your IT staff'); + $MsgErr = _('There was an error. Consult your IT staff'); } } } @@ -77,8 +76,9 @@ $title = _('Print Price Labels'); include('includes/header.inc'); -if ($msgErr!=null) - prnMsg($msgErr,'warn'); +if ($MsgErr!=null) { + prnMsg($MsgErr,'warn'); +} showLabelOptions(); @@ -86,7 +86,7 @@ exit(); function showLabelOptions() { - global $allLabels, $decimalplaces, $rootpath, $theme; + global $AllLabels, $DecimalPlaces, $rootpath, $theme; $txt = array( _('Label Sticker Printing'), _('Select label type'), @@ -94,27 +94,28 @@ _('Price list'), _('Currency'), _('Category'), _('Update values') ); - if (!isset($_POST['labelID'])) - $_POST['labelID']=(string)$allLabels->label[0]->id; - $optionLabels = selLabels($_POST['labelID']); + if (!isset($_POST['LabelID'])) + $_POST['LabelID']=(string)$AllLabels->label[0]->id; + $OptionLabels = selLabels($_POST['LabelID']); if (!isset($_POST['QtyByItem'])) $_POST['QtyByItem']=1; if (!isset($_POST['SalesType'])) $_POST['SalesType']=$_SESSION['DefaultPriceList']; - $optionSales = selSalesType($_POST['SalesType']); + $OptionSales = selSalesType($_POST['SalesType']); - if (!isset($_POST['Currency'])) + if (!isset($_POST['Currency'])){ $_POST['Currency']=$_SESSION['CompanyRecord']['currencydefault']; - $decimalplaces=getDecimalPlaces($_POST['Currency']); + } + $DecimalPlaces=getDecimalPlaces($_POST['Currency']); - $optionCurrency = selCurrency($_POST['Currency']); + $OptionCurrency = selCurrency($_POST['Currency']); if (!isset($_POST['Category'])) $_POST['Category']=''; - $optionsCategory = selCategory($_POST['Category']); + $OptionsCategory = selCategory($_POST['Category']); - $tableItems = tableItems($_POST['Category'], $okItems); + $TableItems = tableItems($_POST['Category'], $okItems); - $sendButton = '<br /><div class=centre><input type="submit" name="PrintPDF" value="'. _('Print labels') .'"> + $SendButton = '<br /><div class=centre><input type="submit" name="PrintPDF" value="'. _('Print labels') .'"> <input type="submit" name="PDFTest" value="'. _('Print labels with borders') .'"></div>'; $iTxt=0; @@ -135,8 +136,8 @@ echo '<tbody>'; echo '<tr> <td class="number">'.$txt[$iTxt++].':</td> - <td><select name="labelID">'. - $optionLabels + <td><select name="LabelID">'. + $OptionLabels .'</select></td> </tr>'; echo '<tr> @@ -147,18 +148,18 @@ echo '<tr> <td class="number">'.$txt[$iTxt++].':</td> <td><select name="SalesType" onChange="ReloadForm(form1.refresh)"> - '.$optionSales.' + '.$OptionSales.' </select></td> </tr>'; echo '<td class="number">'.$txt[$iTxt++].':</td> <td><select name="Currency" onChange="ReloadForm(form1.refresh)"> - '.$optionCurrency.' + '.$OptionCurrency.' </select></td> </tr>'; echo '<tr> <td class="number">'.$txt[$iTxt++].':</td> <td><select name="Category" onChange="ReloadForm(form1.refresh)"> - '.$optionsCategory.' + '.$OptionsCategory.' </select> </td> </tr>'; echo '<tr> @@ -167,21 +168,21 @@ </th>'; echo '<tr> <td colspan="2"> - '.$tableItems.' + '.$TableItems.' </td> </tr>'; echo '</tbody> </table> - '.$sendButton.' + '.$SendButton.' </form>'; } function selLabels($type) { - global $allLabels; + global $AllLabels; $list=array(); - foreach ($allLabels->label as $label) + foreach ($AllLabels->label as $label) $list[(string)$label->id] = (string)$label->description; return selectOptions($list, $type); @@ -221,14 +222,14 @@ return $html; } -function tableItems($category, &$ok) { - global $db, $decimalplaces; +function tableItems($CategoryID, &$ok) { + global $db, $DecimalPlaces; - if (empty($category)) { + if (empty($CategoryID)) { $ok=false; return noneButton( _('Select a Category') ); } - $result = getStockItems($category, $_POST['Currency'], $_POST['SalesType']); + $result = getStockItems($CategoryID, $_POST['Currency'], $_POST['SalesType']); if (!DB_num_rows($result)) { $ok=false; return noneButton( _('This category has no items to show') ); @@ -256,7 +257,7 @@ $ok=true; $odd=true; while ($myrow=DB_fetch_array($result)) { - $price = number_format($myrow['price'],$decimalplaces); + $price = number_format($myrow['price'],$DecimalPlaces); $oddEven=$odd?"Odd":"Even"; $odd = !$odd; $html .= <<<ZZZ @@ -290,27 +291,33 @@ * The routine works in two contexts: when only the category is given * it looks for all the items */ -function getStockItems($category, $currAbrev, $typeSales, $stockID=false) { - global $db, $today; - if ($stockID!==false) { - $wS= "sm.stockid='$stockID' LIMIT 1"; +function getStockItems($CategoryID, $CurrCode, $SalesType, $StockID=false) { + global $db, $Today; + if ($StockID!==false) { + $WhereClause = "stockmaster.stockid='$StockID' LIMIT 1"; } else { - $wS= "sm.categoryid='$category' ORDER BY sm.stockid"; + $WhereClause = "stockmaster.categoryid='$CategoryID' ORDER BY stockmaster.stockid"; } - $sql="SELECT sm.stockid, sm.description, sm.longdescription, sm.barcode, pr.price ". - "FROM stockmaster AS sm LEFT JOIN prices AS pr ON sm.stockid=pr.stockid ". - "AND pr.currabrev = '$currAbrev' " . - "AND pr.typeabbrev= '$typeSales' " . - "AND ('$today' BETWEEN pr.startdate AND pr.enddate) " . - "AND pr.debtorno='' " . - "WHERE $wS"; + $sql="SELECT stockmaster.stockid, + stockmaster.description, stockmaster.longdescription, stockmaster.barcode, prices.price + FROM stockmaster LEFT JOIN prices ON stockmaster.stockid=prices.stockid + AND prices.currabrev = '" . $CurrCode . "' + AND prices.typeabbrev= '" . $SalesType . "' + AND prices.startdate >= '" . Date('Y-m-d') . "' + AND (prices.enddate <= '" . Date('Y-m-d') . "' OR prices.enddate='0000-00-00') + AND prices.debtorno='' + WHERE " . $WhereClause; +// if current prices are those with enddate = 0000-00-00 the following line was wrong +// "AND ('$Today' BETWEEN pr.startdate AND prices.enddate) " . + + return DB_query($sql, $db); } -function getStockData($stockID, $currency, $salesType) { - $result = getStockItems(null, $currency, $salesType, $stockID); +function getStockData($StockID, $Currency, $salesType) { + $result = getStockItems(null, $Currency, $salesType, $StockID); return DB_fetch_array($result); } @@ -379,17 +386,17 @@ ); } -function printLabels($dimensions, $lines, $qtyByItem, $currency, $salesType, $stockIDList) { - global $pdf, $decimalplaces, $Version; +function printLabels($dimensions, $lines, $qtyByItem, $Currency, $salesType, $StockIDList) { + global $pdf, $DecimalPlaces, $Version; $row = $col = 0; - $decimalplaces=getDecimalPlaces($currency); + $DecimalPlaces=getDecimalPlaces($Currency); - foreach ($stockIDList as $stockID=>$on) { // At least there is one item - $itemData = getStockData($stockID, $currency, $salesType); + foreach ($StockIDList as $StockID=>$on) { // At least there is one item + $itemData = getStockData($StockID, $Currency, $salesType); $num=$qtyByItem; while ($num-- > 0) { // Print $num labels per item - printStockid($itemData, $dimensions, $lines, $currency, $row, $col); + printStockid($itemData, $dimensions, $lines, $Currency, $row, $col); if (++$col>=$dimensions['Cols']) { $col=0; if (++$row>=$dimensions['Rows']) { @@ -433,8 +440,8 @@ * possible that the combination $data valid and $readonly false occurs when * invalid data needs to be recaptured because an error in a new label capture. */ -function printStockid($itemData, $labelDim, $dataParams, $currency, $row, $col) { - global $pdf, $decimalplaces; +function printStockid($itemData, $labelDim, $dataParams, $Currency, $row, $col) { + global $pdf, $DecimalPlaces; //echo $row.':'.$col.'<br>'; // Calculate the bottom left corner position $iX = $labelDim['Lm'] + $col * $labelDim['Cw']; @@ -473,7 +480,7 @@ unset($ldescrip); break; case 'price': - $txt = number_format($itemData['price'], $decimalplaces). ' '. $currency; + $txt = number_format($itemData['price'], $DecimalPlaces). ' '. $Currency; // $adj='left'; break; case 'bcode': break; @@ -486,9 +493,9 @@ } } -function getDecimalPlaces($currency) { +function getDecimalPlaces($Currency) { global $db; - $sql="SELECT decimalplaces FROM currencies WHERE currabrev='$currency'"; + $sql="SELECT decimalplaces FROM currencies WHERE currabrev='$Currency'"; $result = DB_query($sql, $db); if (!DB_num_rows($result)) abortMsg(_('Couldnt get the currency data')); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-19 09:25:36 UTC (rev 4189) +++ trunk/doc/Change.log.html 2010-12-21 18:23:54 UTC (rev 4190) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>21/12/10 Phil : Reworked PDFPrintLabels.php to conform to standards and corrected SQL for prices</p> +<p>21/12/10 Ricard Andreu: PDFPrintLabels.php was not checking for end date of prices - fixed</p> <p>19/12/10 Phil: SelectOrderItems.php ConfirmDispatch_Invoice.php add code to handle asset disposals. <p>14/12/10 Phil: modify purchasing scripts for coding conventions/readability</p> <p>11/12/10 Phil: Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made</p> Modified: trunk/includes/DefineLabelClass.php =================================================================== --- trunk/includes/DefineLabelClass.php 2010-12-19 09:25:36 UTC (rev 4189) +++ trunk/includes/DefineLabelClass.php 2010-12-21 18:23:54 UTC (rev 4190) @@ -1,13 +1,18 @@ <?php -define("MAX_LINES_PER_LABEL", 5); -define("LABELS_FILE", $_SESSION['reports_dir'] . "/labels.xml"); +define('MAX_LINES_PER_LABEL', 5); +define('LABELS_FILE', $_SESSION['reports_dir'] . "/labels.xml"); /** * These tags contains the more general data of the labels */ -$GlobalTags = array( - 'id'=>array('desc'=> _('Label id'), 'type'=>'t', 'sz'=>8, 'maxsz'=>12), // text - 'description'=>array('desc'=>_('Description'),'type'=>'t','sz'=>15,'maxsz'=>30) // text +$GlobalTags = array('id'=>array('desc'=> _('Label id'), + 'type'=>'t', + 'sz'=>8, + 'maxsz'=>12), // text + 'description'=>array('desc'=>_('Description'), + 'type'=>'t', + 'sz'=>15, + 'maxsz'=>30) // text ); /** * These tags specifies the dimension of individual label @@ -60,7 +65,7 @@ if (file_exists($file)) { $list= simplexml_load_file($file, "LabelList"); if (!$list) { - prnMsg(_("Failed loading XML file").' '. $file.':'); + prnMsg(_('Failed loading XML file').' '. $file.':'); foreach(libxml_get_errors() as $error) { echo " <br>", $error->message; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-12-22 14:18:35
|
Revision: 4195 http://web-erp.svn.sourceforge.net/web-erp/?rev=4195&view=rev Author: tim_schofield Date: 2010-12-22 14:18:29 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/index.php trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-12-22 14:18:14 UTC (rev 4194) +++ trunk/index.php 2010-12-22 14:18:29 UTC (rev 4195) @@ -22,14 +22,14 @@ foreach ($_POST as $key => $value) { if (substr($key, 0, 6)=='Update') { - $WidgetID=substr($key, 6, strlen($key)-6); + $ReportletID=substr($key, 6, strlen($key)-6); - $sql="UPDATE widgets SET refresh='".$_POST['RefreshRate'.$WidgetID]."' WHERE userid='".$_SESSION['UserID']."' AND id='".$WidgetID."'"; + $sql="UPDATE reportlets SET refresh='".$_POST['RefreshRate'.$ReportletID]."' WHERE userid='".$_SESSION['UserID']."' AND id='".$ReportletID."'"; $result=DB_query($sql, $db); } } -$sql="SELECT * FROM widgets WHERE userid='".$_SESSION['UserID']."'"; +$sql="SELECT * FROM reportlets WHERE userid='".$_SESSION['UserID']."'"; $result=DB_query($sql, $db); $j=1; @@ -56,7 +56,7 @@ echo '</select>'; echo '<input type="submit" name="Update'.$myrow['id'].'" value="Go">'; echo '</th></tr>'; - echo '<tr><td colspan=2><iframe frameborder="0" height="100%" width="100%" src="dashboard_widgets/WidgetContainer.php?Widget='.$myrow['id'].'&Refresh='.$RefreshRate.'"></iframe>'; + echo '<tr><td colspan=2><iframe frameborder="0" height="100%" width="100%" src="dashboard/ReportletContainer.php?Reportlet='.$myrow['id'].'&Refresh='.$RefreshRate.'"></iframe>'; echo '</td></tr></table></form>'; if (($j % 2) == 0) echo '</tr><tr>'; $j++; Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-22 14:18:14 UTC (rev 4194) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-22 14:18:29 UTC (rev 4195) @@ -411,7 +411,7 @@ ALTER TABLE `reports` ADD `col20width` INT( 3 ) NOT NULL DEFAULT '25' AFTER `col19width` ; -ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) NOT NULL DEFAULT ''; +ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ''; ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-12-22 14:22:41
|
Revision: 4212 http://web-erp.svn.sourceforge.net/web-erp/?rev=4212&view=rev Author: tim_schofield Date: 2010-12-22 14:22:35 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/includes/GetConfig.php trunk/includes/session.inc trunk/index.php Modified: trunk/includes/GetConfig.php =================================================================== --- trunk/includes/GetConfig.php 2010-12-22 14:22:06 UTC (rev 4211) +++ trunk/includes/GetConfig.php 2010-12-22 14:22:35 UTC (rev 4212) @@ -27,6 +27,13 @@ $_SESSION['MenuAccess'][$myrow['menuid']]=$myrow['access']; } + $sql="SELECT script, security FROM pagesecurity"; + $result=DB_query($sql, $db); + + while ($myrow=DB_fetch_array($result)) { + $_SESSION[$myrow['script']]=$myrow['security']; + } + /* Also reads all the company data set up in the company record and returns an array */ $sql= 'SELECT @@ -61,8 +68,8 @@ $ReadCoyResult = DB_query($sql,$db,$ErrMsg); if (DB_num_rows($ReadCoyResult)==0) { - echo '<BR><B>'; - prnMsg( _('The company record has not yet been set up') . '</B><BR>' . _('From the system setup tab select company maintenance to enter the company information and system preferences'),'error',_('CRITICAL PROBLEM')); + echo '<br /><b>'; + prnMsg( _('The company record has not yet been set up') . '</b><br />' . _('From the system setup tab select company maintenance to enter the company information and system preferences'),'error',_('CRITICAL PROBLEM')); exit; } else { $_SESSION['CompanyRecord'] = DB_fetch_array($ReadCoyResult); Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-12-22 14:22:06 UTC (rev 4211) +++ trunk/includes/session.inc 2010-12-22 14:22:35 UTC (rev 4212) @@ -113,6 +113,8 @@ /*User is logged in so get configuration parameters - save in session*/ include($PathPrefix . 'includes/GetConfig.php'); +$PageSecurity = $_SESSION[basename($_SERVER['SCRIPT_NAME'])]; + if(isset($_SESSION['DB_Maintenance'])){ if ($_SESSION['DB_Maintenance']!=0) { if (DateDiff(Date($_SESSION['DefaultDateFormat']), Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-12-22 14:22:06 UTC (rev 4211) +++ trunk/index.php 2010-12-22 14:22:35 UTC (rev 4212) @@ -4,7 +4,7 @@ /* $Revision: 1.91 $ */ -$PageSecurity = 1; +// $PageSecurity = 1; include('includes/session.inc'); $title=_('Main Menu'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-12-22 14:33:31
|
Revision: 4213 http://web-erp.svn.sourceforge.net/web-erp/?rev=4213&view=rev Author: tim_schofield Date: 2010-12-22 14:33:20 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/AccountGroups.php trunk/AccountSections.php trunk/AgedDebtors.php trunk/AgedSuppliers.php trunk/AuditTrail.php trunk/BOMExtendedQty.php trunk/BOMIndented.php trunk/BOMIndentedReverse.php trunk/BOMListing.php trunk/BOMs.php trunk/BankAccounts.php trunk/BankMatching.php trunk/BankReconciliation.php trunk/COGSGLPostings.php trunk/CompanyPreferences.php trunk/ConfirmDispatchControlled_Invoice.php trunk/ConfirmDispatch_Invoice.php trunk/ContractBOM.php trunk/ContractCosting.php trunk/ContractOtherReqts.php trunk/Contracts.php trunk/CounterSales.php trunk/CreditItemsControlled.php trunk/CreditStatus.php trunk/CustEDISetup.php trunk/CustLoginSetup.php trunk/CustomerAllocations.php trunk/CustomerBranches.php trunk/CustomerInquiry.php trunk/CustomerReceipt.php trunk/CustomerTransInquiry.php trunk/CustomerTypes.php trunk/Customers.php trunk/DailyBankTransactions.php trunk/DailySalesInquiry.php trunk/DebtorsAtPeriodEnd.php trunk/DeliveryDetails.php trunk/DiscountCategories.php trunk/DiscountMatrix.php trunk/EDIMessageFormat.php trunk/EDIProcessOrders.php trunk/EDISendInvoices.php trunk/EmailConfirmation.php trunk/EmailCustTrans.php trunk/ExchangeRateTrend.php trunk/FTP_RadioBeacon.php trunk/Factors.php trunk/FixedAssetCategories.php trunk/FixedAssetDepreciation.php trunk/FixedAssetItems.php trunk/FixedAssetList.php trunk/FixedAssetLocations.php trunk/FixedAssetRegister.php trunk/FixedAssetTransfer.php trunk/FreightCosts.php trunk/GLAccountCSV.php trunk/GLAccountInquiry.php trunk/GLAccountReport.php trunk/GLAccounts.php trunk/GLBalanceSheet.php trunk/GLCodesInquiry.php trunk/GLJournal.php trunk/GLProfit_Loss.php trunk/GLTagProfit_Loss.php trunk/GLTransInquiry.php trunk/GLTrialBalance.php trunk/GLTrialBalance_csv.php trunk/GoodsReceived.php trunk/GoodsReceivedControlled.php trunk/InventoryPlanning.php trunk/InventoryPlanningPrefSupplier.php trunk/InventoryQuantities.php trunk/InventoryValuation.php trunk/Labels.php trunk/Locations.php trunk/MRP.php trunk/MRPCalendar.php trunk/MRPCreateDemands.php trunk/MRPDemandTypes.php trunk/MRPDemands.php trunk/MRPPlannedPurchaseOrders.php trunk/MRPPlannedWorkOrders.php trunk/MRPReport.php trunk/MRPReschedules.php trunk/MRPShortages.php trunk/MailInventoryValuation.php trunk/OffersReceived.php trunk/OrderDetails.php trunk/OutstandingGRNs.php trunk/PDFBankingSummary.php trunk/PDFChequeListing.php trunk/PDFCustTransListing.php trunk/PDFCustomerList.php trunk/PDFDIFOT.php trunk/PDFDeliveryDifferences.php trunk/PDFGrn.php trunk/PDFLowGP.php trunk/PDFOrderStatus.php trunk/PDFOrdersInvoiced.php trunk/PDFPickingList.php trunk/PDFPriceList.php trunk/PDFPrintLabel.php trunk/PDFQuotation.php trunk/PDFReceipt.php trunk/PDFRemittanceAdvice.php trunk/PDFStockCheckComparison.php trunk/PDFStockLocTransfer.php trunk/PDFStockNegatives.php trunk/PDFStockTransListing.php trunk/PDFStockTransfer.php trunk/PDFSuppTransListing.php trunk/POReport.php trunk/PO_AuthorisationLevels.php trunk/PO_Header.php trunk/PO_Items.php trunk/PO_OrderDetails.php trunk/PO_SelectOSPurchOrder.php trunk/PaymentAllocations.php trunk/PaymentMethods.php trunk/PaymentTerms.php trunk/Payments.php trunk/PcAssignCashToTab.php trunk/PcAuthorizeExpenses.php trunk/PcClaimExpensesFromTab.php trunk/PcExpenses.php trunk/PcExpensesTypeTab.php trunk/PcReportTab.php trunk/PcTabs.php trunk/PcTypeTabs.php trunk/PeriodsInquiry.php trunk/Prices.php trunk/PricesByCost.php trunk/PrintCheque.php trunk/PrintCustOrder.php trunk/PrintCustOrder_generic.php trunk/PrintCustStatements.php trunk/PrintCustTransPortrait.php trunk/PrintSalesOrder_generic.php trunk/PurchData.php trunk/RecurringSalesOrders.php trunk/ReorderLevel.php trunk/ReorderLevelLocation.php trunk/ReportBug.php trunk/ReverseGRN.php trunk/SMTPServer.php trunk/SalesAnalReptCols.php trunk/SalesAnalRepts.php trunk/SalesAnalysis_UserDefined.php trunk/SalesCategories.php trunk/SalesInquiry.php trunk/SalesPeople.php trunk/SalesTypes.php trunk/SelectAsset.php trunk/SelectCompletedOrder.php trunk/SelectContract.php trunk/SelectCreditItems.php trunk/SelectGLAccount.php trunk/SelectOrderItems.php trunk/SelectSalesOrder.php trunk/SelectWorkOrder.php trunk/ShipmentCosting.php trunk/Shipments.php trunk/Shippers.php trunk/Shipt_Select.php trunk/ShiptsList.php trunk/SpecialOrder.php trunk/StockAdjustments.php trunk/StockAdjustmentsControlled.php trunk/StockCategories.php trunk/StockCostUpdate.php trunk/StockCounts.php trunk/StockDispatch.php trunk/StockLocMovements.php trunk/StockLocStatus.php trunk/StockLocTransfer.php trunk/StockLocTransferReceive.php trunk/StockMovements.php trunk/StockQties_csv.php trunk/StockQuantityByDate.php trunk/StockReorderLevel.php trunk/StockSerialItemResearch.php trunk/StockSerialItems.php trunk/StockStatus.php trunk/StockTransferControlled.php trunk/StockTransfers.php trunk/StockUsage.php trunk/StockUsageGraph.php trunk/Stocks.php trunk/SuppContractChgs.php trunk/SuppCreditGRNs.php trunk/SuppFixedAssetChgs.php trunk/SuppInvGRNs.php trunk/SuppLoginSetup.php trunk/SuppPaymentRun.php trunk/SuppPriceList.php trunk/SuppShiptChgs.php trunk/SuppTransGLAnalysis.php trunk/SupplierAllocations.php trunk/SupplierBalsAtPeriodEnd.php trunk/SupplierContacts.php trunk/SupplierCredit.php trunk/SupplierInquiry.php trunk/SupplierInvoice.php trunk/SupplierTenders.php trunk/SupplierTransInquiry.php trunk/SupplierTypes.php trunk/Suppliers.php trunk/SystemParameters.php trunk/Tax.php trunk/TaxAuthorities.php trunk/TaxAuthorityRates.php trunk/TaxCategories.php trunk/TaxProvinces.php trunk/TopItems.php trunk/UnitsOfMeasure.php trunk/UserSettings.php trunk/WOSerialNos.php trunk/WWW_Access.php trunk/WWW_Users.php trunk/WhereUsedInquiry.php trunk/WorkCentres.php trunk/WorkOrderCosting.php trunk/WorkOrderEntry.php trunk/WorkOrderIssue.php trunk/WorkOrderReceive.php trunk/WorkOrderStatus.php trunk/Z_BottomUpCosts.php trunk/Z_ChangeBranchCode.php trunk/Z_ChangeCustomerCode.php trunk/Z_ChangeStockCode.php trunk/Z_CheckAllocationsFrom.php trunk/Z_CheckAllocs.php trunk/Z_CopyBOM.php trunk/Z_CreateChartDetails.php trunk/Z_CreateCompany.php trunk/Z_CreateCompanyTemplateFile.php trunk/Z_CurrencySuppliersBalances.php trunk/Z_DataExport.php trunk/Z_DeleteCreditNote.php trunk/Z_DeleteInvoice.php trunk/Z_DeleteSalesTransActions.php trunk/Z_DescribeTable.php trunk/Z_ImportChartOfAccounts.php trunk/Z_ImportFixedAssets.php trunk/Z_ImportGLAccountGroups.php trunk/Z_ImportGLAccountSections.php trunk/Z_ImportPartCodes.php trunk/Z_MakeNewCompany.php trunk/Z_MakeStockLocns.php trunk/Z_ReApplyCostToSA.php trunk/Z_RePostGLFromPeriod.php trunk/Z_ReverseSuppPaymentRun.php trunk/Z_SalesIntegrityCheck.php trunk/Z_UpdateChartDetailsBFwd.php trunk/Z_Upgrade_3.01-3.02.php trunk/Z_Upgrade_3.04-3.05.php trunk/Z_Upgrade_3.11-4.00.php trunk/Z_UploadForm.php trunk/Z_UploadResult.php trunk/Z_index.php trunk/Z_poAddLanguage.php trunk/Z_poAdmin.php trunk/Z_poEditLangHeader.php trunk/Z_poEditLangModule.php trunk/Z_poEditLangRemaining.php trunk/Z_poRebuildDefault.php trunk/geo_displaymap_customers.php trunk/geo_displaymap_suppliers.php Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/AccountGroups.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.23 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); Modified: trunk/AccountSections.php =================================================================== --- trunk/AccountSections.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/AccountSections.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.7 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); Modified: trunk/AgedDebtors.php =================================================================== --- trunk/AgedDebtors.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/AgedDebtors.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ /* $Revision: 1.20 $ */ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); if (isset($_POST['PrintPDF']) Modified: trunk/AgedSuppliers.php =================================================================== --- trunk/AgedSuppliers.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/AgedSuppliers.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ /* $Revision: 1.13 $ */ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); If (isset($_POST['PrintPDF']) Modified: trunk/AuditTrail.php =================================================================== --- trunk/AuditTrail.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/AuditTrail.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id$ */ -$PageSecurity=15; +//$PageSecurity=15; include('includes/session.inc'); Modified: trunk/BOMExtendedQty.php =================================================================== --- trunk/BOMExtendedQty.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BOMExtendedQty.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -5,7 +5,7 @@ /* $Revision: 1.8 $ */ // BOMExtendedQty.php - Quantiy Extended Bill of Materials -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); if (isset($_POST['PrintPDF'])) { Modified: trunk/BOMIndented.php =================================================================== --- trunk/BOMIndented.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BOMIndented.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -5,7 +5,7 @@ /* $Revision: 1.5 $ */ // BOMIndented.php - Indented Bill of Materials -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); if (isset($_POST['PrintPDF'])) { Modified: trunk/BOMIndentedReverse.php =================================================================== --- trunk/BOMIndentedReverse.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BOMIndentedReverse.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -6,7 +6,7 @@ // BOMIndented.php - Reverse Indented Bill of Materials - From lowest level component to top level // assembly -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); if (isset($_POST['PrintPDF'])) { Modified: trunk/BOMListing.php =================================================================== --- trunk/BOMListing.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BOMListing.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ /* $Revision: 1.14 $ */ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); Modified: trunk/BOMs.php =================================================================== --- trunk/BOMs.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BOMs.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.37 $ */ /* $Id$*/ -$PageSecurity = 9; +//$PageSecurity = 9; include('includes/session.inc'); Modified: trunk/BankAccounts.php =================================================================== --- trunk/BankAccounts.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BankAccounts.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.21 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); Modified: trunk/BankMatching.php =================================================================== --- trunk/BankMatching.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BankMatching.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.23 $ */ /* $Id$*/ -$PageSecurity = 7; +//$PageSecurity = 7; include("includes/session.inc"); $title = _('Bank Account Matching'); Modified: trunk/BankReconciliation.php =================================================================== --- trunk/BankReconciliation.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/BankReconciliation.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.15 $ */ /* $Id$*/ -$PageSecurity = 7; +//$PageSecurity = 7; include ('includes/session.inc'); Modified: trunk/COGSGLPostings.php =================================================================== --- trunk/COGSGLPostings.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/COGSGLPostings.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.15 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); Modified: trunk/CompanyPreferences.php =================================================================== --- trunk/CompanyPreferences.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CompanyPreferences.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.18 $ */ /* $Id$*/ -$PageSecurity =10; +//$PageSecurity =10; include('includes/session.inc'); Modified: trunk/ConfirmDispatchControlled_Invoice.php =================================================================== --- trunk/ConfirmDispatchControlled_Invoice.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ConfirmDispatchControlled_Invoice.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Specify Dispatched Controlled Items'); Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ConfirmDispatch_Invoice.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -6,7 +6,7 @@ /* Session started in session.inc for password checking and authorisation level check */ include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); $title = _('Confirm Dispatches and Invoice An Order'); Modified: trunk/ContractBOM.php =================================================================== --- trunk/ContractBOM.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ContractBOM.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id: $ */ -$PageSecurity = 6; +//$PageSecurity = 6; include('includes/DefineContractClass.php'); Modified: trunk/ContractCosting.php =================================================================== --- trunk/ContractCosting.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ContractCosting.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id: ContractCosting.php 3692 2010-08-15 09:22:08Z daintree $*/ -$PageSecurity = 6; +//$PageSecurity = 6; include('includes/DefineContractClass.php'); include('includes/session.inc'); $title = _('Contract Costing'); Modified: trunk/ContractOtherReqts.php =================================================================== --- trunk/ContractOtherReqts.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ContractOtherReqts.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id: $ */ -$PageSecurity = 4; +//$PageSecurity = 4; include('includes/DefineContractClass.php'); Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/Contracts.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id: Contracts.php 3692 2010-08-15 09:22:08Z daintree $ */ -$PageSecurity = 6; +//$PageSecurity = 6; include('includes/DefineContractClass.php'); include('includes/session.inc'); Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CounterSales.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id: SelectOrderItems.php 3453 2010-05-06 06:39:52Z lindsayh $*/ include('includes/DefineCartClass.php'); -$PageSecurity = 1; +//$PageSecurity = 1; /* Session started in session.inc for password checking and authorisation level check config.php is in turn included in session.inc*/ @@ -83,7 +83,7 @@ include('includes/footer.inc'); exit; } - + $CashSaleCustomer = explode('-',$myrow['cashsalecustomer']); $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[1]; Modified: trunk/CreditItemsControlled.php =================================================================== --- trunk/CreditItemsControlled.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CreditItemsControlled.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$*/ include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); $title = _('Specify Credited Controlled Items'); @@ -28,7 +28,7 @@ $LineNo = $_GET['LineNo']; } elseif (isset($_POST['LineNo'])){ $LineNo = $_POST['LineNo']; -} else { +} else { echo '<div class="centre"><a href="' . $rootpath . '/' . $CreditLink . '?' . SID . '">'. _('Select Credit Items'). '</a><br><br>'; prnMsg( _('This page can only be opened if a Line Item on a credit note has been selected.') . ' ' . _('Please do that first'), 'error'); echo '</div>'; Modified: trunk/CreditStatus.php =================================================================== --- trunk/CreditStatus.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CreditStatus.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.16 $ */ /* $Id$*/ -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); $title = _('Credit Status Code Maintenance'); include('includes/header.inc'); Modified: trunk/CustEDISetup.php =================================================================== --- trunk/CustEDISetup.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustEDISetup.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.11 $ */ /* $Id$*/ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Customer EDI Set Up'); Modified: trunk/CustLoginSetup.php =================================================================== --- trunk/CustLoginSetup.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustLoginSetup.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.2 $ */ /* $Id$*/ -$PageSecurity = 15; +//$PageSecurity = 15; include('includes/session.inc'); $title = _('Customer Login Configuration'); Modified: trunk/CustomerAllocations.php =================================================================== --- trunk/CustomerAllocations.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerAllocations.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -10,7 +10,7 @@ */ include('includes/DefineCustAllocsClass.php'); -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); $title = _('Customer Receipt') . '/' . _('Credit Note Allocations'); include('includes/header.inc'); Modified: trunk/CustomerBranches.php =================================================================== --- trunk/CustomerBranches.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerBranches.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.53 $ */ /* $Id$*/ -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); $title = _('Customer Branches'); Modified: trunk/CustomerInquiry.php =================================================================== --- trunk/CustomerInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -5,7 +5,7 @@ include('includes/SQL_CommonFunctions.inc'); -$PageSecurity = 1; +//$PageSecurity = 1; include('includes/session.inc'); $title = _('Customer Inquiry'); Modified: trunk/CustomerReceipt.php =================================================================== --- trunk/CustomerReceipt.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerReceipt.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -5,7 +5,7 @@ include('includes/DefineReceiptClass.php'); -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); $title = _('Receipt Entry'); Modified: trunk/CustomerTransInquiry.php =================================================================== --- trunk/CustomerTransInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerTransInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.17 $ */ /* $Id$*/ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); $title = _('Customer Transactions Inquiry'); Modified: trunk/CustomerTypes.php =================================================================== --- trunk/CustomerTypes.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/CustomerTypes.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.6 $ */ /* $Id$*/ -$PageSecurity = 15; +//$PageSecurity = 15; include('includes/session.inc'); $title = _('Customer Types') . ' / ' . _('Maintenance'); Modified: trunk/Customers.php =================================================================== --- trunk/Customers.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/Customers.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$ */ /* $Revision: 1.44 $ */ -$PageSecurity = 3; +//$PageSecurity = 3; include('includes/session.inc'); Modified: trunk/DailyBankTransactions.php =================================================================== --- trunk/DailyBankTransactions.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DailyBankTransactions.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,6 +1,6 @@ <?php -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('Daily Banking Inquiry'); include('includes/header.inc'); Modified: trunk/DailySalesInquiry.php =================================================================== --- trunk/DailySalesInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DailySalesInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.00$ */ /* $Id$*/ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); $title = _('Daily Sales Inquiry'); Modified: trunk/DebtorsAtPeriodEnd.php =================================================================== --- trunk/DebtorsAtPeriodEnd.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DebtorsAtPeriodEnd.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,5 +1,5 @@ <?php -$PageSecurity = 2; +//$PageSecurity = 2; /* $Id$*/ Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DeliveryDetails.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -11,7 +11,7 @@ /* Session started in header.inc for password checking the session will contain the details of the order from the Cart class object. The details of the order come from SelectOrderItems.php */ -$PageSecurity=1; +//$PageSecurity=1; include('includes/session.inc'); $title = _('Order Delivery Details'); include('includes/header.inc'); Modified: trunk/DiscountCategories.php =================================================================== --- trunk/DiscountCategories.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DiscountCategories.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.10 $ */ /* $Id$*/ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); Modified: trunk/DiscountMatrix.php =================================================================== --- trunk/DiscountMatrix.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/DiscountMatrix.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.9 $ */ /* $Id$*/ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Discount Matrix Maintenance'); include('includes/header.inc'); Modified: trunk/EDIMessageFormat.php =================================================================== --- trunk/EDIMessageFormat.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/EDIMessageFormat.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.10 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); $title = _('EDI Message Format'); Modified: trunk/EDIProcessOrders.php =================================================================== --- trunk/EDIProcessOrders.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/EDIProcessOrders.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.20 $ */ /* $Id$*/ -$PageSecurity =11; +//$PageSecurity =11; include ('includes/session.inc'); @@ -459,18 +459,18 @@ break; case 'SN': /*Store Number - get the branch details from the store number - snag here too cos need to ensure got the Customer detail first before try looking up its branches */ - $BranchResult = DB_query("SELECT branchcode, - brname, + $BranchResult = DB_query("SELECT branchcode, + brname, braddress1, - braddress2, - braddress3, - braddress4, - braddress5, - braddress6, - contactname, - defaultlocation, - phoneno, - email + braddress2, + braddress3, + braddress4, + braddress5, + braddress6, + contactname, + defaultlocation, + phoneno, + email FROM custbranch INNER JOIN debtorsmaster ON custbranch.debtorno = custbranch.debtorno WHERE custbranchcode='" . $NAD_C082[0] . "' AND custbranch.debtorno='" . $Order->DebtorNo . "' AND debtorsmaster.ediorders=1",$db); if (DB_num_rows($BranchResult)!=1){ $EmailText .= "\n" . _('The Store number was specified as') . ' ' . $NAD_C082[0] . ' ' . _('Unfortunately there are either no branches of customer code') . ' ' . $Order->DebtorNo . ' ' ._('or several that match this store number') . '. ' . _('This order could not be processed further'); Modified: trunk/EDISendInvoices.php =================================================================== --- trunk/EDISendInvoices.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/EDISendInvoices.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Revision: 1.11 $ */ /* $Id$*/ -$PageSecurity =15; +//$PageSecurity =15; include ('includes/session.inc'); include ('includes/header.inc'); Modified: trunk/EmailConfirmation.php =================================================================== --- trunk/EmailConfirmation.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/EmailConfirmation.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -101,7 +101,7 @@ include('includes/footer.inc'); exit; }//packing slip has been printed. - $MailSubject = "Order Confirmation-Sales Order " . $_GET['TransNo'] . " - Your PO " . + $MailSubject = "Order Confirmation-Sales Order " . $_GET['TransNo'] . " - Your PO " . $myrow['customerref'] ; } @@ -111,39 +111,39 @@ ) LETS GO */ -$MailMessage = "<html><head><title>Email Confirmation</title></head><body>" . - "<Table cellpadding='2' cellspacing='2'><tr>" . +$MailMessage = "<html><head><title>Email Confirmation</title></head><body>" . + "<Table cellpadding='2' cellspacing='2'><tr>" . "<td align='center' colspan='4'><H1>" . $_SESSION['CompanyRecord']['coyname'] . "</H1>" ; $MailMessage = $MailMessage . "</td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . $_SESSION['CompanyRecord']['regoffice1'] . "</td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . $_SESSION['CompanyRecord']['regoffice4'] . ","; -$MailMessage = $MailMessage . "<b>" . +$MailMessage = $MailMessage . "<b>" . $_SESSION['CompanyRecord']['regoffice5'] . "</td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . - $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . + $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' . $_SESSION['CompanyRecord']['fax'] . "</td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . $_SESSION['CompanyRecord']['email'] . "<br><br><br></td></tr>"; -$MailMessage = $MailMessage . "<Table><tr><td align='center' colspan='4'> +$MailMessage = $MailMessage . "<Table><tr><td align='center' colspan='4'> <h2> Order Acknowledgement</h2></td></tr>"; -$MailMessage = $MailMessage . "<tr><td align='center' colspan='4'> <b>Order Number " . +$MailMessage = $MailMessage . "<tr><td align='center' colspan='4'> <b>Order Number " . $_GET['TransNo'] . "</b><br><br><br></td></tr>"; $MailMessage = $MailMessage . "<tr><td colspan='4'> <b>Delivered To:</b></td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . $myrow['deliverto'] . "</td></tr>"; -$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . +$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" . $myrow['deladd1'] . "</td></tr>"; If(strlen(trim($myrow['deladd2']))) { $MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd2'] . "</td></tr>"; - $MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] . + $MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5']. "<br><br><br></td></tr>"; } else { - $MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] . ' ' . + $MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5'] . "<br><br><br></td></tr>"; } $MailMessage = $MailMessage . "</table><table border='1' width='50%'><tr>"; @@ -156,10 +156,10 @@ <td>Due Date</td></tr>"; - $sql = "SELECT salesorderdetails.stkcode, - stockmaster.description, - salesorderdetails.quantity, - salesorderdetails.qtyinvoiced, + $sql = "SELECT salesorderdetails.stkcode, + stockmaster.description, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, salesorderdetails.unitprice, salesorderdetails.narrative, salesorderdetails.poline, @@ -188,15 +188,15 @@ else { $ItemDue[$i] = date('M d, Y',strtotime($myrow2['itemdue'])); - } + } $MailMessage = $MailMessage . "<tr>"; if($_REQUEST['POLine'] == 1){ $MailMessage = $MailMessage . "<td align='right'>" . $POLine[$i] . "</td>"; } $MailMessage = $MailMessage . "<td>" . $myrow2['stkcode'] . - "</td><td>" . - $myrow2['description'] . "</td><td align='right'>" . - $DisplayQty . "</td><td align='center'>" . $ItemDue[$i] . + "</td><td>" . + $myrow2['description'] . "</td><td align='right'>" . + $DisplayQty . "</td><td align='center'>" . $ItemDue[$i] . "</td></tr>"; $i = $i + 1; @@ -236,23 +236,23 @@ <td colspan='2' nowrap width="50%"> <b><?=$myrow['deliverto']?></td> </tr> <tr> - <td colspan='2' nowrap width="50%"> + <td colspan='2' nowrap width="50%"> <b><?=$_SESSION['CompanyRecord']['regoffice4']?>, <?=$_SESSION['CompanyRecord']['regoffice5']?> </b> </td> <td colspan='2' nowrap width="50%"> <b><?=$myrow['deladd1']?></td> </tr> <tr> - <td colspan='2' nowrap width="50%"> - <b><?=$_SESSION['CompanyRecord']['telephone']?> + <td colspan='2' nowrap width="50%"> + <b><?=$_SESSION['CompanyRecord']['telephone']?> Fax:<?=$_SESSION['CompanyRecord']['fax']?></b> </td> <td nowrap width="50%"><b><?=$myrow['deladd2']?></td> </tr> <tr> - <td colspan='2' nowrap width="50%"> + <td colspan='2' nowrap width="50%"> <b><?=$_SESSION['CompanyRecord']['email']?><br><br><br> - </td> + </td> <td nowrap width="50%"> <b><?=$myrow['deladd3']?> <?=$myrow['deladd4'] ?> <?=$myrow['deladd5']?><br><br><br> </td> @@ -262,11 +262,11 @@ <tr> <? if($_REQUEST['POLine'] == 1){ -?> +?> <td align="center">PO Line</td> <? } -?> +?> <td align="center">Stock Code</td> <td align="center">Description</td> <td align="center">Quantity Ordered</td> @@ -279,11 +279,11 @@ <tr> <? if($_REQUEST['POLine']){ -?> +?> <td align='right'><?=$POLine[$j]?></td> <? } -?> +?> <td><?=$StkCode[$j]?></td> <td><?=$DscCode[$j]?></td> <td align="right"><?=$QtyCode[$j]?></td> @@ -291,7 +291,7 @@ </tr> <? } -?> +?> </table> </body> </html> Modified: trunk/EmailCustTrans.php =================================================================== --- trunk/EmailCustTrans.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/EmailCustTrans.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.8 $ */ /* $Id$*/ -$PageSecurity = 2; +//$PageSecurity = 2; include ('includes/session.inc'); include ('includes/SQL_CommonFunctions.inc'); Modified: trunk/ExchangeRateTrend.php =================================================================== --- trunk/ExchangeRateTrend.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/ExchangeRateTrend.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.3 $ */ /* $Id$*/ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); $title = _('View Currency Trends'); Modified: trunk/FTP_RadioBeacon.php =================================================================== --- trunk/FTP_RadioBeacon.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FTP_RadioBeacon.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ /*Variables required to configure this script must be set in config.php */ -$PageSecurity = 2; +//$PageSecurity = 2; include('includes/session.inc'); $title=_('FTP order to Radio Beacon'); include('includes/header.inc'); Modified: trunk/Factors.php =================================================================== --- trunk/Factors.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/Factors.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,6 +1,6 @@ <?php -$PageSecurity = 5; +//$PageSecurity = 5; include('includes/session.inc'); Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetCategories.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,7 +1,7 @@ <?php /* $Revision: 1.1 $ */ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); @@ -108,7 +108,7 @@ $ErrMsg = _('Could not insert the new fixed asset category') . $_POST['CategoryDescription'] . _('because'); $result = DB_query($sql,$db,$ErrMsg); prnMsg(_('A new fixed asset category record has been added for') . ' ' . $_POST['CategoryDescription'],'success'); - + } //run the SQL from either of the above possibilites @@ -226,7 +226,7 @@ $_POST['DepnAct'] = $myrow['depnact']; $_POST['DisposalAct'] = $myrow['disposalact']; $_POST['AccumDepnAct'] = $myrow['accumdepnact']; - + echo '<input type=hidden name="SelectedCategory" value="' . $SelectedCategory . '">'; echo '<input type=hidden name="CategoryID" value="' . $_POST['CategoryID'] . '">'; echo '<table class=selection><tr><td>' . _('Category Code') . ':</td><td>' . $_POST['CategoryID'] . '</td></tr>'; Modified: trunk/FixedAssetDepreciation.php =================================================================== --- trunk/FixedAssetDepreciation.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetDepreciation.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -4,7 +4,7 @@ include('includes/DefineJournalClass.php'); -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); $title = _('Depreciation Journal Entry'); @@ -13,11 +13,11 @@ /*Get the last period depreciation (depn is transtype =44) was posted for */ -$result = DB_query('SELECT periods.lastdate_in_period, - max(fixedassettrans.periodno) - FROM fixedassettrans INNER JOIN periods - ON fixedassettrans.periodno=periods.periodno - WHERE transtype=44 +$result = DB_query('SELECT periods.lastdate_in_period, + max(fixedassettrans.periodno) + FROM fixedassettrans INNER JOIN periods + ON fixedassettrans.periodno=periods.periodno + WHERE transtype=44 GROUP BY periods.lastdate_in_period',$db); $LastDepnRun = DB_fetch_row($result); @@ -27,13 +27,13 @@ $AllowUserEnteredProcessDate = true; if ($LastDepnRun[1]==0 AND $LastDepnRun[0]==NULL) { //then depn has never been run yet? - + /*in this case default depreciation calc to the last day of last month - and allow user to select a period */ if (!isset($_POST['ProcessDate'])) { $_POST['ProcessDate'] = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); } - -} else { //depn calc has been run previously + +} else { //depn calc has been run previously $AllowUserEnteredProcessDate = false; $_POST['ProcessDate'] = DateAdd(ConvertSQLDate($LastDepnRun[0]),'m',1); } @@ -157,9 +157,9 @@ $TotalCost +=$AssetRow['cost']; $TotalAccumDepn +=$AssetRow['accumdepn']; $TotalDepn +=$NewDepreciation; - + if (isset($_POST['CommitDepreciation']) AND $NewDepreciation !=0 AND $InputError==false){ - + //debit depreciation expense $SQL = "INSERT INTO gltrans (type, typeno, @@ -167,7 +167,7 @@ periodno, account, narrative, - amount) + amount) VALUES (44, '" . $TransNo . "', '" . FormatDateForSQL($_POST['ProcessDate']) . "', @@ -184,7 +184,7 @@ periodno, account, narrative, - amount) + amount) VALUES (44, '" . $TransNo . "', '" . FormatDateForSQL($_POST['ProcessDate']) . "', @@ -193,7 +193,7 @@ '" . $AssetRow['assetid'] . "', '" . -$NewDepreciation ."')"; $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - + //insert the fixedassettrans record $SQL = "INSERT INTO fixedassettrans (assetid, transtype, @@ -214,7 +214,7 @@ $ErrMsg = _('Cannot insert a fixed asset transaction entry for the depreciation because'); $DbgMsg = _('The SQL that failed to insert the fixed asset transaction record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - + /*now update the accum depn in fixedassets */ $SQL = "UPDATE fixedassets SET accumdepn = accumdepn + " . $NewDepreciation . " WHERE assetid = '" . $AssetRow['assetid'] . "'"; Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetItems.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$ */ /* $Revision: 1.3 $ */ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Fixed Assets'); @@ -87,14 +87,14 @@ $Errors[$i] = 'LongDescription'; $i++; } - + if (strlen($_POST['BarCode']) >20) { $InputError = 1; prnMsg(_('The barcode must be 20 characters or less long'),'error'); $Errors[$i] = 'BarCode'; $i++; } - + if (trim($_POST['AssetCategoryID'])==''){ $InputError = 1; prnMsg(_('There are no asset categories defined. All assets must belong to a valid category,'),'error'); @@ -110,25 +110,25 @@ if ($_POST['DepnRate']>0 AND $_POST['DepnRate']<1){ prnMsg(_('Numbers less than 1 are interpreted as less than 1%. The depreciation rate should be entered as a number between 0 and 100'),'warn'); } - - + + if ($InputError !=1){ - + if ($_POST['submit']==_('Update')) { /*so its an existing one */ /*Start a transaction to do the whole lot inside */ $result = DB_Txn_Begin($db); - + /*Need to check if changing the balance sheet codes - as will need to do journals for the cost and accum depn of the asset to the new category */ $result = DB_query("SELECT assetcategoryid, cost, accumdepn, costact, accumdepnact FROM fixedassets INNER JOIN fixedassetcategories WHERE assetid='" . $AssetID . "'",$db); $OldDetails = DB_fetch_array($result); if ($OldDetails['assetcategoryid'] !=$_POST['AssetCategoryID'] AND $OldDetails['cost']!=0){ - + $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); $NewAccounts = DB_fetch_array($result); - + $TransNo = GetNextTransNo( 42, $db); /* transaction type is asset category change */ //credit cost for the old category @@ -150,7 +150,7 @@ $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); - + //debit cost for the new category $SQL = "INSERT INTO gltrans (type, typeno, @@ -190,7 +190,7 @@ $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, @@ -252,7 +252,7 @@ $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); - + if (DB_error_no($db) ==0) { $NewAssetID = DB_Last_Insert_ID($db,'fixedassets', 'assetid'); prnMsg( _('The new asset has been added to the database with an asset code of:') . ' ' . $NewAssetID,'success'); @@ -277,12 +277,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 + $result = DB_query('SELECT cost, + 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']; @@ -302,7 +302,7 @@ } if ($CancelDelete==0) { $result = DB_Txn_Begin($db); - + /*Need to remove cost and accumulate depreciation from cost and accumdepn accounts */ $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']),$db); $TransNo = GetNextTransNo( 43, $db); /* transaction type is asset deletion - (and remove cost/acc5umdepn from GL) */ @@ -326,7 +326,7 @@ $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, @@ -346,10 +346,10 @@ $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); - + } //end if cost > 0 - - + + $sql="DELETE FROM fixedassets WHERE assetid='" . $AssetID . "'"; $result=DB_query($sql,$db, _('Could not delete the asset record'),'',true); @@ -381,7 +381,7 @@ $New = 1; echo '<input type="hidden" name="New" value="">'. "\n"; - + } elseif ($InputError!=1) { // Must be modifying an existing item and no changes made yet - need to lookup the details $sql = "SELECT assetid, @@ -409,7 +409,7 @@ $_POST['DepnType'] = $AssetRow['depntype']; $_POST['BarCode'] = $AssetRow['barcode']; $_POST['DepnRate'] = $AssetRow['depnrate']; - + echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$AssetID.'</td></tr>'. "\n"; echo '<input type="Hidden" name="AssetID" value='.$AssetID.'>'. "\n"; @@ -452,13 +452,13 @@ $AssetImgLink = _('No Image'); } } - + if ($AssetImgLink!=_('No Image')) { echo '<td>' . _('Image') . '<br>'.$AssetImgLink . '</td></tr>'; } else { echo '</td></tr>'; } - + // EOR Add Image upload for New Item - by Ori } //only show the add image if the asset already exists - otherwise AssetID will not be set - and the image needs the AssetID to save @@ -546,7 +546,7 @@ echo '<div class=centre><br><input type="Submit" name="submit" value="' . _('Insert New Fixed Asset') . '">'; } else { - + echo '<br><div class=centre><input type="submit" name="submit" value="' . _('Update') . '"></div>'; prnMsg( _('Only click the Delete button if you are sure you wish to delete the asset. Only assets with a zero book value can be deleted'), 'warn', _('WARNING')); echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Asset') . '" onclick="return confirm(\'' . _('Are You Sure? Only assets with a zero book value can be deleted.') . '\');"></div>'; Modified: trunk/FixedAssetList.php =================================================================== --- trunk/FixedAssetList.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetList.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,5 +1,5 @@ <?php -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Fixed Asset Properties List'); Modified: trunk/FixedAssetLocations.php =================================================================== --- trunk/FixedAssetLocations.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetLocations.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,6 +1,6 @@ <?php -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Fixed Asset Locations'); @@ -60,7 +60,7 @@ // if you are not updating then you want to delete but lets be sure first. if (isset($_POST['delete'])) { $InputError=0; - + $sql="SELECT COUNT(locationid) FROM fixedassetlocations WHERE parentlocationid='" . $_POST['LocationID']."'"; $result = DB_query($sql,$db); $myrow=DB_fetch_row($result); @@ -99,7 +99,7 @@ $parentresult=DB_query($parentsql, $db); $parentrow=DB_fetch_array($parentresult); echo '<td>'.$parentrow['locationdescription'].'</td>'; - echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . _('Edit') . '</td>'; + echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . _('Edit') . '</td>'; } echo '</table><br>'; Modified: trunk/FixedAssetRegister.php =================================================================== --- trunk/FixedAssetRegister.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetRegister.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,5 +1,5 @@ <?php -$PageSecurity = 11; +//$PageSecurity = 11; include ('includes/session.inc'); $title = _('Fixed Asset Register'); $csv_output = ''; @@ -58,7 +58,7 @@ $CategoryRow=DB_fetch_array($CategoryResult); $AssetCategory=$CategoryRow['categorydescription']; } - + if ($_POST['AssetID']=='%') { $AssetDescription =_('All'); } else { @@ -96,7 +96,7 @@ $TotalDepn = 0; $TotalDisposals = 0; $TotalNBV = 0; - + while ($myrow = DB_fetch_array($result)) { /* * $Ancestors = array(); @@ -198,7 +198,7 @@ $LeftOvers = $pdf->addTextWrap($XPos + 550, $YPos, 70, $FontSize, number_format($TotalCostCfwd, 0), 'right'); $LeftOvers = $pdf->addTextWrap($XPos + 620, $YPos, 70, $FontSize, number_format($TotalDepnCfwd, 0), 'right'); $LeftOvers = $pdf->addTextWrap($XPos + 690, $YPos, 70, $FontSize, number_format($TotalNBV, 0), 'right'); - + $pdf->Output($_SESSION['DatabaseName'] . '_Asset Register_' . date('Y-m-d') . '.pdf', 'I'); exit; } elseif (isset($_POST['csv'])) { @@ -230,7 +230,7 @@ } else { include ('includes/header.inc'); echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title; - + $result = DB_query('SELECT categoryid,categorydescription FROM fixedassetcategories', $db); echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -306,18 +306,18 @@ $line_height; $AssetDescription; $AssetCategory; - + if ($PageNumber>1){ $pdf->newPage(); } - + $FontSize=10; $YPos= $Page_Height-$Top_Margin; $XPos=0; $pdf->addJpegFromFile($_SESSION['LogoFile'] ,$XPos+20,$YPos-50,0,60); - - - + + + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos,240,$FontSize,$_SESSION['CompanyRecord']['coyname']); $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*1),240,$FontSize, _('Asset Category ').' ' . $AssetCategory ); $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*2),240,$FontSize, _('Asset Location ').' ' . $_POST['AssetLocation'] ); @@ -325,21 +325,21 @@ $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*4),240,$FontSize, _('From').': ' . $_POST['FromDate']); $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*5),240,$FontSize, _('To').': ' . $_POST['ToDate']); $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-240,$YPos-($line_height*7),240,$FontSize, _('Page'). ' ' . $PageNumber); - + $YPos -= 60; - + $YPos -=2*$line_height; //Note, this is ok for multilang as this is the value of a Select, text in option is different - + $YPos -=(2*$line_height); - + /*Draw a rectangle to put the headings in */ $YTopLeft=$YPos+$line_height; $pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); $pdf->line($Left_Margin, $YPos+$line_height,$Left_Margin, $YPos- $line_height); $pdf->line($Left_Margin, $YPos- $line_height,$Page_Width-$Right_Margin, $YPos- $line_height); $pdf->line($Page_Width-$Right_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos- $line_height); - + /*set up the headings */ $FontSize=10; $XPos = $Left_Margin+1; @@ -356,15 +356,15 @@ $LeftOvers = $pdf->addTextWrap($XPos+620,$YPos,70,$FontSize, _('Depn C/Fwd'), 'centre'); $LeftOvers = $pdf->addTextWrap($XPos+690,$YPos,70,$FontSize, _('Net Book Value'), 'centre'); //$LeftOvers = $pdf->addTextWrap($XPos+760,$YPos,70,$FontSize, _('Disposal Proceeds'), 'centre'); - + $pdf->line($Left_Margin, $YTopLeft,$Page_Width-$Right_Margin, $YTopLeft); $pdf->line($Left_Margin, $YTopLeft,$Left_Margin, $Bottom_Margin); $pdf->line($Left_Margin, $Bottom_Margin,$Page_Width-$Right_Margin, $Bottom_Margin); $pdf->line($Page_Width-$Right_Margin, $Bottom_Margin,$Page_Width-$Right_Margin, $YTopLeft); - + $FontSize=8; $YPos -= (1.5 * $line_height); - + $PageNumber++; } Modified: trunk/FixedAssetTransfer.php =================================================================== --- trunk/FixedAssetTransfer.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FixedAssetTransfer.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -1,6 +1,6 @@ <?php -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); @@ -103,9 +103,9 @@ $_POST['SerialNumber']='%'; } $sql= 'SELECT fixedassets.assetid, - fixedassets.cost, - fixedassets.accumdepn, - fixedassets.description, + fixedassets.cost, + fixedassets.accumdepn, + fixedassets.description, fixedassets.depntype, fixedassets.serialno, fixedassets.barcode, @@ -129,12 +129,12 @@ <th>' . _('Current Location') . '</th> <th>' . _('Move To :') . '</th> </tr>'; - + $locationsql='SELECT locationid, locationdescription from fixedassetlocations'; $LocationResult=DB_query($locationsql, $db); - + while ($myrow=DB_fetch_array($Result)) { - + echo '<tr><td>'.$myrow['assetid'].'</td> <td>'.$myrow['description'].'</td> <td>'.$myrow['serialno'].'</td> Modified: trunk/FreightCosts.php =================================================================== --- trunk/FreightCosts.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/FreightCosts.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$*/ /* $Revision: 1.14 $ */ -$PageSecurity = 11; +//$PageSecurity = 11; include('includes/session.inc'); $title = _('Freight Costs Set Up'); include('includes/header.inc'); Modified: trunk/GLAccountCSV.php =================================================================== --- trunk/GLAccountCSV.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLAccountCSV.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id: $*/ /* $Revision: 1.00 $ */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('General Ledger Account Report'); include('includes/header.inc'); Modified: trunk/GLAccountInquiry.php =================================================================== --- trunk/GLAccountInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLAccountInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$*/ /* $Revision: 1.28 $ */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('General Ledger Account Inquiry'); include('includes/header.inc'); Modified: trunk/GLAccountReport.php =================================================================== --- trunk/GLAccountReport.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLAccountReport.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id: $*/ /* $Revision: 1.00 $ */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); if (isset($_POST['Period'])){ Modified: trunk/GLAccounts.php =================================================================== --- trunk/GLAccounts.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLAccounts.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Revision: 1.21 $ */ /* $Id$*/ -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); $title = _('Chart of Accounts Maintenance'); Modified: trunk/GLBalanceSheet.php =================================================================== --- trunk/GLBalanceSheet.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLBalanceSheet.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -6,7 +6,7 @@ /*Through deviousness and cunning, this system allows shows the balance sheets as at the end of any period selected - so first off need to show the input of criteria screen while the user is selecting the period end of the balance date meanwhile the system is posting any unposted transactions */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('Balance Sheet'); Modified: trunk/GLCodesInquiry.php =================================================================== --- trunk/GLCodesInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLCodesInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$*/ /* $Revision: 1.9 $ */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('GL Codes Inquiry'); Modified: trunk/GLJournal.php =================================================================== --- trunk/GLJournal.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLJournal.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -5,7 +5,7 @@ include('includes/DefineJournalClass.php'); -$PageSecurity = 10; +//$PageSecurity = 10; include('includes/session.inc'); $title = _('Journal Entry'); Modified: trunk/GLProfit_Loss.php =================================================================== --- trunk/GLProfit_Loss.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLProfit_Loss.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id$*/ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('Profit and Loss'); Modified: trunk/GLTagProfit_Loss.php =================================================================== --- trunk/GLTagProfit_Loss.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLTagProfit_Loss.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -2,7 +2,7 @@ /* $Id$*/ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('Income and Expenditure by Tag'); Modified: trunk/GLTransInquiry.php =================================================================== --- trunk/GLTransInquiry.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLTransInquiry.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -3,7 +3,7 @@ /* $Id$*/ /* $Revision: 1.16 $ */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('General Ledger Transaction Inquiry'); Modified: trunk/GLTrialBalance.php =================================================================== --- trunk/GLTrialBalance.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLTrialBalance.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -8,7 +8,7 @@ while the user is selecting the criteria the system is posting any unposted transactions */ -$PageSecurity = 8; +//$PageSecurity = 8; include ('includes/session.inc'); $title = _('Trial Balance'); Modified: trunk/GLTrialBalance_csv.php =================================================================== --- trunk/GLTrialBalance_csv.php 2010-12-22 14:22:35 UTC (rev 4212) +++ trunk/GLTrialBalance_csv.php 2010-12-22 14:33:20 UTC (rev 4213) @@ -6,10 +6,10 @@ and shows the balance sheets as at the end of the period selected - so first off need to show the input of criteria screen while the user is selecting the criteria the system is posting any unposted transactions */ -/*Needs to have FromPeriod and ToPeriod sent with URL +/*Needs to have FromPeriod and ToPeriod sent with URL * also need to work on authentication with username and password sent too*/ -$PageSecurity = 8; +//$PageSecurity = 8; $AllowAnyone =true; //$_POST['UserNameEntryField'] = $_GET['Identifier']; //$_POST['Password'] = $_GET['Identifier... [truncated message content] |
From: <tim...@us...> - 2010-12-22 14:34:40
|
Revision: 4217 http://web-erp.svn.sourceforge.net/web-erp/?rev=4217&view=rev Author: tim_schofield Date: 2010-12-22 14:34:34 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/doc/Manual/ManualContents.php trunk/includes/session.inc Modified: trunk/doc/Manual/ManualContents.php =================================================================== --- trunk/doc/Manual/ManualContents.php 2010-12-22 14:34:24 UTC (rev 4216) +++ trunk/doc/Manual/ManualContents.php 2010-12-22 14:34:34 UTC (rev 4217) @@ -19,7 +19,7 @@ Comments beginning with Help Begin and Help End denote the beginning and end of a section that goes into the online help. What section is named after Help Begin: and there can be multiple sections separated with a comma. -->';*/ -$PageSecurity=1; +// $PageSecurity=1; $PathPrefix='../../'; include($PathPrefix.'includes/session.inc'); Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-12-22 14:34:24 UTC (rev 4216) +++ trunk/includes/session.inc 2010-12-22 14:34:34 UTC (rev 4217) @@ -12,7 +12,7 @@ header('Location:' . $rootpath . '/install/index.php'); } include($PathPrefix . 'config.php'); -$DBVersion=46; +$DBVersion=47; if (isset($SessionSavePath)){ session_save_path($SessionSavePath); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-12-22 14:34:54
|
Revision: 4218 http://web-erp.svn.sourceforge.net/web-erp/?rev=4218&view=rev Author: tim_schofield Date: 2010-12-22 14:34:48 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/css/default/default.css trunk/index.php Modified: trunk/css/default/default.css =================================================================== --- trunk/css/default/default.css 2010-12-22 14:34:34 UTC (rev 4217) +++ trunk/css/default/default.css 2010-12-22 14:34:48 UTC (rev 4218) @@ -19,7 +19,7 @@ body { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 14px; + font-size: 10px; background-color: #CCCCDD; margin-left: 5px; margin-top: 5px; @@ -35,7 +35,7 @@ /*links before selection */ a { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; text-decoration: none; color: black; @@ -65,7 +65,7 @@ /*table detail items default format */ td { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; text-align: left; } @@ -154,7 +154,7 @@ input { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } input.number{ @@ -171,7 +171,7 @@ select { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } font.good { @@ -202,7 +202,7 @@ #page { width: 100%; color: black; - font-size: 12px; + font-size: 10px; white-space: nowrap; border: none; } @@ -239,7 +239,7 @@ textarea{ font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } textarea:hover{ @@ -297,7 +297,7 @@ width: 100%; margin: 0px; padding: 0px; - font-size: 12px; + font-size: 10px; } /* Main page heading with quick menu within */ @@ -323,7 +323,7 @@ /*The main page heading left part before quick menu */ .quick_menu_left { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; border: 0px; white-space: nowrap; @@ -391,12 +391,12 @@ } .system_menu_tabs a { - font-size: 12px; + font-size: 10px; color: black; } .system_menu_tabs a:hover { - font-size: 12px; + font-size: 10px; color: black; } @@ -408,7 +408,7 @@ .main_menu { background-color: #40FC40; - font-size: 14px; + font-size: 10px; border-top: 1px #AAAAAA solid; border-bottom: 1px #AAAAAA solid; font-weight: normal; @@ -471,7 +471,7 @@ span.main_menu_nolink { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; color: #777777; text-decoration: none; @@ -505,7 +505,7 @@ .menu_group_area { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 14px; + font-size: 10px; border: 2px inset white; color: #cc6600; background-color: #CCCCCC; @@ -527,7 +527,7 @@ .menu_group_headers_text { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; color: white; } @@ -559,7 +559,7 @@ padding-top: 2px; padding-bottom: 2px; font-weight: bold; - font-size: 12px; + font-size: 10px; color: black; TEXT-ALIGN:center; } @@ -604,7 +604,7 @@ span.menu_group_nolink { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: normal; color: #777777; text-decoration: none; Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-12-22 14:34:34 UTC (rev 4217) +++ trunk/index.php 2010-12-22 14:34:48 UTC (rev 4218) @@ -63,7 +63,7 @@ } echo '</tr></table>'; -echo "<div style='margin-left: 10px; position: absolute; top:50px; z-index:99;'><ul class='makeMenu'>"; +echo "<div style='margin-left: 10px; position: absolute; top:60px; z-index:99;'><ul class='makeMenu'>"; $ModuleID=0; for ($i=0; $i<sizeOf($MenuStructure); $i++) { if ($MenuStructure[$i]['parent']==-1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-12-22 14:35:49
|
Revision: 4219 http://web-erp.svn.sourceforge.net/web-erp/?rev=4219&view=rev Author: tim_schofield Date: 2010-12-22 14:35:42 +0000 (Wed, 22 Dec 2010) Log Message: ----------- $Message Modified Paths: -------------- trunk/SelectOrderItems.php trunk/css/jelly/default.css trunk/includes/session.inc Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-12-22 14:34:48 UTC (rev 4218) +++ trunk/SelectOrderItems.php 2010-12-22 14:35:42 UTC (rev 4219) @@ -949,6 +949,85 @@ $DbgMsg = _('The sql that was used to determine if the part being ordered was a kitset or not was '); $KitResult = DB_query($sql, $db,$ErrMsg,$DbgMsg); + if (isset($_POST['AssetDisposalEntered'])){ //its an asset being disposed of + if ($_POST['AssetToDisposeOf'] == 'NoAssetSelected'){ //don't do anything unless an asset is disposed of + prnMsg(_('No asset was selected to dispose of. No assets have been added to this customer order'),'warn'); + } else { //need to add the asset to the order + /*First need to create a stock ID to hold the asset and record the sale - as only stock items can be sold + * and before that we need to add a disposal stock category - if not already created + * first off get the details about the asset being disposed of */ + $AssetDetailsResult = DB_query('SELECT fixedassets.description, + fixedassets.longdescription, + fixedassets.barcode, + fixedassetcategories.costact + FROM fixedassetcategories INNER JOIN fixedassets + ON fixedassetcategories.categoryid=fixedassets.assetcategoryid + WHERE fixedassets.assetid="' . $_POST['AssetToDisposeOf'] . '"',$db); + $AssetRow = DB_fetch_array($AssetCatDetailsResult); + + $AssetCategoryResult = DB_query('SELECT categoryid FROM stockcategory WHERE categoryid="ASSETS"',$db); + if (DB_num_rows($AssetCategoryResult)==0){ + /*Although asset GL posting will come from the asset category - we should set the GL codes to something sensible + * based on the category of the asset under review at the moment - this may well change for any other assets sold subsequentely */ + + /*OK now we can insert the stock category for this asset */ + $InsertAssetStockCatResult = DB_query('INSERT INTO stockcategory ( categoryid, + categorydescription, + stockact) + VALUES ("ASSETS", + "' . _('Asset Disposals') . '", + "' . $AssetRow['costact'] . '")',$db); + } + + /*First check to see that it doesn't exist already assets are of the format "ASSET-" . $AssetID + */ + $TestAssetExistsAlreadyResult = DB_query('SELECT stockid FROM stockmaster WHERE stockid ="ASSET-' . $_POST['AssetToDisposeOf'] . '"',$db); + if (DB_num_rows($TestAssetExistsAlreadyResult)==1){ //then it exists already ... bum + $j=1; + while (DB_num_rows($TestAssetExistsAlreadyResult)==1) { + $TestAssetExistsAlreadyResult = DB_query('SELECT stockid FROM stockmaster WHERE stockid ="ASSET-' . $_POST['AssetToDisposeOf'] . '-' . $j . '"',$db); + $j++; + } + $AssetStockID = 'ASSET-' . $_POST['AssetToDisposeOf'] . '-' . $j; + } else { + $AssetStockID = 'ASSET-' . $_POST['AssetToDisposeOf']; + } + /* Perhaps ought to check that the asset exists already as a stock item first */ + + /*OK now we can insert the item for this asset */ + $InsertAssetAsStockItemResult = DB_query('INSERT INTO stockmaster ( stockid, + description, + categoryid, + longdescription, + mbflag, + controlled, + serialised, + taxcatid) + VALUES ("' . $AssetStockID . '", + "' . $AssetRow['description'] . '", + "' . $AssetRow['longdescription'] . '", + "ASSETS", + "B", + "0", + "0", + "' . $_SESSION['DefaultTaxCategory'] . '")' , $db); + /*not forgetting the location records too */ + $InsertStkLocRecsResult = DB_query('INSERT INTO locstock (loccode, + stockid) + SELECT loccode, "' . $AssetStockID . '" FROM locations',$db); + /*Now the asset has been added to the stock master we can add it to the sales order */ + $NewItemDue = date($_SESSION['DefaultDateFormat']); + if (isset($_POST['POLine']){ + $NewPOLine = $_POST['POLine']; + } else { + $NewPOLine = 0; + } + $NewItem = $AssetStockID; + include('includes/SelectOrderItems_IntoCart.inc'); + } + + + } if (DB_num_rows($KitResult)==0){ prnMsg( _('The item code') . ' ' . $NewItem . ' ' . _('could not be retrieved from the database and has not been added to the order'),'warn'); @@ -1692,8 +1771,8 @@ // Find the quantity on works orders $sql = "SELECT SUM(woitems.qtyreqd - woitems.qtyrecd) AS dedm - FROM woitems - WHERE stockid='" . $myrow['stockid'] ."'"; + FROM woitems + WHERE stockid='" . $myrow['stockid'] ."'"; $ErrMsg = _('The order details for this product cannot be retrieved because'); $WoResult = db_query($sql,$db,$ErrMsg); Modified: trunk/css/jelly/default.css =================================================================== --- trunk/css/jelly/default.css 2010-12-22 14:34:48 UTC (rev 4218) +++ trunk/css/jelly/default.css 2010-12-22 14:35:42 UTC (rev 4219) @@ -34,7 +34,7 @@ /*links before selection */ a { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: normal; text-decoration: none; color: #0000FF; @@ -66,7 +66,7 @@ /*table detail items default format */ td { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; text-align:left; } @@ -119,7 +119,7 @@ th { font-weight: normal; background: #ccc; - font-size: 12px; + font-size: 10px; color: #330000; text-align: center; } @@ -127,7 +127,7 @@ th.number { font-weight: normal; background: #ccc; - font-size: 12px; + font-size: 10px; color: #330000; text-align: right; } @@ -147,7 +147,7 @@ font-family: Verdana, Arial, Helvetica; padding-top: 1px; padding-bottom: 1px; - font-size: 12px; + font-size: 10px; TEXT-ALIGN:center; } @@ -213,7 +213,7 @@ color:#000; border: 0px 0px 1px 1px #000 dashed; font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } input.number{ @@ -234,7 +234,7 @@ select {background:#eee; color:#111; font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } font.good { @@ -305,7 +305,7 @@ color:#000; border: 0px 0px 1px 1px #000 dashed; font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; } textarea:hover{ background: url(images/inputhtxt.png) #eee; @@ -367,7 +367,7 @@ width: 100%; margin: 0px; padding: 0px; - font-size: 12px; + font-size: 10px; } /* Main page heading with quick menu within */ @@ -394,7 +394,7 @@ .quick_menu_left { background: none; font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; border: none; white-space: nowrap; @@ -464,12 +464,12 @@ } .system_menu_tabs a { - font-size: 12px; + font-size: 10px; color: black; } .system_menu_tabs a:hover { - font-size: 12px; + font-size: 10px; color: black; } @@ -536,7 +536,7 @@ span.main_menu_nolink { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; color: #fff; text-decoration: none; @@ -582,7 +582,7 @@ .menu_group_headers_text { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: bold; color: black; } @@ -610,7 +610,7 @@ padding-top: 2px; padding-bottom: 2px; font-weight: bold; - font-size: 12px; + font-size: 10px; color: black; TEXT-ALIGN:center; } @@ -655,7 +655,7 @@ span.menu_group_nolink { font-family: Arial, Verdana, Helvetica, sans-serif; - font-size: 12px; + font-size: 10px; font-weight: normal; color: #777777; text-decoration: none; Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-12-22 14:34:48 UTC (rev 4218) +++ trunk/includes/session.inc 2010-12-22 14:35:42 UTC (rev 4219) @@ -12,7 +12,7 @@ header('Location:' . $rootpath . '/install/index.php'); } include($PathPrefix . 'config.php'); -$DBVersion=47; +$DBVersion=48; if (isset($SessionSavePath)){ session_save_path($SessionSavePath); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |