From: <tim...@us...> - 2009-11-18 10:18:11
|
Revision: 3042 http://web-erp.svn.sourceforge.net/web-erp/?rev=3042&view=rev Author: tim_schofield Date: 2009-11-18 10:17:55 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Provide option to print a customer receipt Modified Paths: -------------- trunk/CustomerReceipt.php trunk/doc/Change.log.html Added Paths: ----------- trunk/PDFReceipt.php Modified: trunk/CustomerReceipt.php =================================================================== --- trunk/CustomerReceipt.php 2009-11-18 07:47:54 UTC (rev 3041) +++ trunk/CustomerReceipt.php 2009-11-18 10:17:55 UTC (rev 3042) @@ -210,9 +210,38 @@ $BatchReceiptsTotal = 0; //in functional currency $BatchDiscount = 0; //in functional currency $BatchDebtorTotal = 0; //in functional currency + $k=0; //Table row counter for row styles + $CustomerReceiptCounter=1; //Count lines of customer receipts in this batch + echo '<br /><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Allocate') . '" alt="">' . ' ' . _('Summary of Receipt Batch').'</p><br />'; + + echo '<table><tr><th>'._('Batch Number').'</th> + <th>'._('Date Banked').'</th> + <th>'._('Customer Name').'</th + <th>'._('GL Code').'</th + <th>'._('Amount of Receipt').'</th></tr>'; + foreach ($_SESSION['ReceiptBatch']->Items as $ReceiptItem) { + + if ($k==1){ + echo '<tr class="OddTableRows">'; + $k=0; + } else { + echo '<tr class="EvenTableRows">'; + $k=1; + } + echo '<td>'.$_SESSION['ReceiptBatch']->BatchNo.'</td> + <td>'.$_SESSION['ReceiptBatch']->DateBanked.'</td> + <td>'.$ReceiptItem->CustomerName.'</td> + <td>'.$ReceiptItem->GLCode.'</td> + <td class=number>'.number_format($ReceiptItem->Amount/$_SESSION['ReceiptBatch']->ExRate/$_SESSION['ReceiptBatch']->FunctionalExRate,2) .'</td>'; + + if ($ReceiptItem->GLCode ==''){ + echo '<td><a target="_blank" href="' . $rootpath . '/PDFReceipt.php?BatchNumber=' . $_SESSION['ReceiptBatch']->BatchNo. '&ReceiptNumber='.$CustomerReceiptCounter.'">'._('Print a Customer Receipt').'</a></td></tr>'; + $CustomerReceiptCounter += 1; + } + if ($ReceiptItem->GLCode !=''){ if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ /* then enter a GLTrans record */ $SQL = 'INSERT INTO gltrans (type, @@ -337,12 +366,12 @@ '', '" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "', " . $PeriodNo . ", - '" . $_SESSION['ReceiptBatch']->ReceiptType . ' ' . $ReceiptItem->Narrative . "', + '" . $_SESSION['ReceiptBatch']->ReceiptType . ' ' . $ReceiptItem->PayeeBankDetail . "', '', " . ($_SESSION['ReceiptBatch']->ExRate/$_SESSION['ReceiptBatch']->FunctionalExRate) . ", " . -$ReceiptItem->Amount . ", " . -$ReceiptItem->Discount . ", - '" . $ReceiptItem->PayeeBankDetail . "' + '" . $ReceiptItem->Narrative. "' )"; $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); $ErrMsg = _('Cannot insert a receipt transaction against the customer because') ; @@ -361,6 +390,7 @@ $BatchReceiptsTotal += ($ReceiptItem->Amount/$_SESSION['ReceiptBatch']->ExRate/$_SESSION['ReceiptBatch']->FunctionalExRate); } /*end foreach $ReceiptItem */ + echo '</table>'; if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ /* then enter GLTrans records for discount, bank and debtors */ @@ -496,7 +526,7 @@ $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name FROM debtorsmaster - WHERE debtorsmaster.name " . LIKE . " '$SearchString' + WHERE debtorsmaster.name LIKE '". $SearchString."' AND debtorsmaster.currcode= '" . $_SESSION['ReceiptBatch']->Currency . "'"; } elseif (strlen($_POST['CustCode'])>0){ @@ -513,6 +543,7 @@ WHERE debtortrans.transno " . LIKE . " '%" . $_POST['CustInvNo'] . "%' AND debtorsmaster.currcode= '" . $_SESSION['ReceiptBatch']->Currency . "'"; } + $CustomerSearchResult = DB_query($SQL,$db,'','',false,false); if (DB_error_no($db) !=0) { prnMsg(_('The searched customer records requested cannot be retrieved because') . ' - ' . DB_error_msg($db),'error'); @@ -941,8 +972,10 @@ echo '<tr><td>' . _('Payee Bank Details') . ':</td> <td><input tabindex=12 type="text" name="PayeeBankDetail" maxlength=22 size=20 value="' . $_POST['PayeeBankDetail'] . '"></td></tr>'; - echo '<tr><td>' . _('Narrative') . ':</td> - <td><input tabindex=13 type="text" name="Narrative" maxlength=30 size=32 value="' . $_POST['Narrative'] . '"></td></tr>'; +// echo '<tr><td>' . _('Narrative') . ':</td> +// <td><input tabindex=13 type="text" name="Narrative" maxlength=30 size=32 value="' . $_POST['Narrative'] . '"></td></tr>'; + echo '<td>' . _('Narrative') . ':</td>'; + echo '<td><textarea name="Narrative" cols=40 rows=1></textarea></td>'; echo '</table>'; echo '<div class="centre"><input tabindex=14 type="submit" name="Process" value="' . _('Accept') . '">'; echo '<input tabindex=14 type="submit" name="Cancel" value="' . _('Cancel') . '"></div>'; Added: trunk/PDFReceipt.php =================================================================== --- trunk/PDFReceipt.php (rev 0) +++ trunk/PDFReceipt.php 2009-11-18 10:17:55 UTC (rev 3042) @@ -0,0 +1,121 @@ +<?php +/* $Id $ */ + +$PageSecurity = 2; +include('includes/session.inc'); + +include('includes/PDFStarter.php'); + +$FontSize=10; +$pdf->addinfo('Title', _('Sales Receipt') ); + +$PageNumber=1; +$line_height=12; +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(50,$YPos-($line_height*6),300,$FontSize,$_SESSION['CompanyRecord']['coyname']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*7),300,$FontSize,$_SESSION['CompanyRecord']['regoffice1']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*8),300,$FontSize,$_SESSION['CompanyRecord']['regoffice2']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*9),300,$FontSize,$_SESSION['CompanyRecord']['regoffice3']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*10),300,$FontSize,$_SESSION['CompanyRecord']['regoffice4']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*11),300,$FontSize,$_SESSION['CompanyRecord']['regoffice5']); +$LeftOvers = $pdf->addTextWrap(50,$YPos-($line_height*12),300,$FontSize,$_SESSION['CompanyRecord']['regoffice6']); +$LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-180,$YPos-($line_height*3),550,$FontSize, _('Customer Receipt Number ').' : ' . $_GET['BatchNumber'] .'/'.$_GET['ReceiptNumber'] ); +$LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-180,$YPos-($line_height*4.5),140,$FontSize, _('Printed').': ' . Date($_SESSION['DefaultDateFormat']) . ' '. _('Page'). ' ' . $PageNumber); + +$YPos -= 150; + +$YPos -=$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 */ + +$pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); + +$FontSize=10; +$YPos -= (1.5 * $line_height); + +$PageNumber++; + +$sql='SELECT MIN(id) as start FROM debtortrans WHERE type=12 AND transno='.$_GET['BatchNumber']; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$StartReceiptNumber=$myrow['start']; + +$sql='SELECT debtorno, + ovamount, + invtext + FROM debtortrans + WHERE type=12 + AND transno='.$_GET['BatchNumber'].' + AND id='.($StartReceiptNumber-1+$_GET['ReceiptNumber']); +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$DebtorNo=$myrow['debtorno']; +$Amount=$myrow['ovamount']; +$Narrative=$myrow['invtext']; + +$sql='SELECT currency, + decimalplaces + FROM currencies + WHERE currabrev=(SELECT currcode + FROM banktrans + WHERE type=12 + AND transno='.$_GET['BatchNumber'].')'; +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); +$Currency=$myrow['currency']; +$DecimalPlaces=$myrow['decimalplaces']; + +$sql='SELECT name, + address1, + address2, + address3, + address4, + address5, + address6 + FROM debtorsmaster + WHERE debtorno="'.$DebtorNo.'"'; + +$result=DB_query($sql, $db); +$myrow=DB_fetch_array($result); + +$LeftOvers = $pdf->addTextWrap(50,$YPos,300,$FontSize,_('Received From').' : '); + +$LeftOvers = $pdf->addTextWrap(150,$YPos,300,$FontSize, htmlspecialchars_decode($myrow['name'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*1),300,$FontSize, htmlspecialchars_decode($myrow['address1'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*2),300,$FontSize, htmlspecialchars_decode($myrow['address2'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*3),300,$FontSize, htmlspecialchars_decode($myrow['address3'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*4),300,$FontSize, htmlspecialchars_decode($myrow['address4'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*5),300,$FontSize, htmlspecialchars_decode($myrow['address5'])); +$LeftOvers = $pdf->addTextWrap(150,$YPos-($line_height*6),300,$FontSize, htmlspecialchars_decode($myrow['address6'])); + +$YPos=$YPos-($line_height*8); + +$LeftOvers = $pdf->addTextWrap(50,$YPos,300,$FontSize,_('The Sum Of').' : '); +$LeftOvers = $pdf->addTextWrap(150,$YPos,300,$FontSize,number_format(-$Amount,$DecimalPlaces).' '.$Currency); + +$YPos=$YPos-($line_height*2); + +$LeftOvers = $pdf->addTextWrap(50,$YPos,500,$FontSize,_('Details').' : '.$Narrative); + +$YPos=$YPos-($line_height*8); + +$LeftOvers = $pdf->addTextWrap(50,$YPos,500,$FontSize,_('Signed On Behalf Of').' : '.$_SESSION['CompanyRecord']['coyname']); + +$YPos=$YPos-($line_height*10); + +$LeftOvers = $pdf->addTextWrap(50,$YPos,300,$FontSize,'______________________________________________________________________________'); + +$pdf->Output('Receipt-'.$_GET['ReceiptNumber'], 'I'); +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2009-11-18 07:47:54 UTC (rev 3041) +++ trunk/doc/Change.log.html 2009-11-18 10:17:55 UTC (rev 3042) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>18/11/09 Tim: PDFReceipt.php - Provide option to print a customer receipt <p>17/11/09 Bryan Nielsen: Factors.php - Correction first factor does not show in amend list <p>17/11/09 Tim: WWW_Users.php - Alter directory listing for svn directory <p>17/11/09 Tim: UserSettings.php - Alter directory listing for svn directory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |