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. |