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