From: <dai...@us...> - 2009-11-29 06:52:55
|
Revision: 3134 http://web-erp.svn.sourceforge.net/web-erp/?rev=3134&view=rev Author: daintree Date: 2009-11-29 06:52:46 +0000 (Sun, 29 Nov 2009) Log Message: ----------- New remittance advice script Modified Paths: -------------- branches/utf-8/includes/header.inc trunk/doc/Change.log.html trunk/includes/PDFPaymentRunPageHeader.inc trunk/includes/PDFStarter.php trunk/index.php Added Paths: ----------- trunk/PDFRemittanceAdvice.php Modified: branches/utf-8/includes/header.inc =================================================================== --- branches/utf-8/includes/header.inc 2009-11-29 06:08:47 UTC (rev 3133) +++ branches/utf-8/includes/header.inc 2009-11-29 06:52:46 UTC (rev 3134) @@ -8,7 +8,7 @@ // $title - should be defined in the page this file is included with if (!headers_sent()){ - header('Content-type: text/html; charset=' . _('ISO-8859-1')); + header('Content-type: text/html; charset=' . _('UTF-8')); } echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; @@ -17,7 +17,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>' . $title . '</title>'; echo '<link rel="shortcut icon" href="'. $rootpath.'/favicon.ico" />'; echo '<link rel="icon" href="' . $rootpath.'/favicon.ico" />'; - echo '<meta http-equiv="Content-Type" content="text/html; charset=' . _('ISO-8859-1') . '" />'; + echo '<meta http-equiv="Content-Type" content="text/html; charset=' . _('UTF-8') . '" />'; echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />'; echo '<script type="text/javascript" src = "'.$rootpath.'/javascripts/MiscFunctions.js"></script>'; echo '</head>'; Added: trunk/PDFRemittanceAdvice.php =================================================================== --- trunk/PDFRemittanceAdvice.php (rev 0) +++ trunk/PDFRemittanceAdvice.php 2009-11-29 06:52:46 UTC (rev 3134) @@ -0,0 +1,322 @@ +<?php +/* $Id $ */ + +$PageSecurity = 2; + +include('includes/session.inc'); + +If ((isset($_POST['PrintPDF'])) + AND isset($_POST['FromCriteria']) + AND strlen($_POST['FromCriteria'])>=1 + AND isset($_POST['ToCriteria']) + AND strlen($_POST['ToCriteria'])>=1) { + +/*then print the report */ + + include('includes/PDFStarter.php'); + $pdf->addInfo('Title',_('Remmitance Advice')); + $pdf->addInfo('Subject',_('Remittance Advice') . ' - ' . _('suppliers from') . ' ' . $_POST['FromCriteria'] . ' to ' . $_POST['ToCriteria'] . ' ' . _('and Paid On') . ' ' . $_POST['PaymentDate']); + + $line_height=12; + + /*Now figure out the invoice less credits due for the Supplier range under review */ + + $sql = "SELECT suppliers.supplierid, + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode, + supptrans.id + FROM supptrans INNER JOIN suppliers ON supptrans.supplierno = suppliers.supplierid + INNER JOIN paymentterms ON suppliers.paymentterms = paymentterms.termsindicator + WHERE supptrans.type=22 + AND trandate ='" . FormatDateForSQL($_POST['PaymentDate']) . "' + AND supplierno >= '" . $_POST['FromCriteria'] . "' + AND supplierno <= '" . $_POST['ToCriteria'] . "' + AND suppliers.remittance=1 + ORDER BY supplierno"; + + $SuppliersResult = DB_query($sql,$db); + + $SupplierID =''; + $RemittanceAdviceCounter =0; + while ($SuppliersPaid = DB_fetch_array($SuppliersResult)){ + + $PageNumber=1; + PageHeader(); + $RemittanceAdviceCounter++; + $SupplierID = $SuppliersPaid['supplierid']; + $SupplierName = $SuppliersPaid['suppname']; + $AccumBalance = 0; + + /* Now get the transactions and amounts that the payment was allocated to */ + $sql = "SELECT systypes.typename, + supptrans.suppreference, + supptrans.trandate, + supptrans.transno, + suppallocs.amt, + (supptrans.ovamount + supptrans.ovgst ) AS trantotal + FROM supptrans + INNER JOIN systypes ON systypes.typeid = supptrans.type + INNER JOIN suppallocs ON suppallocs.transid_allocto=supptrans.id + WHERE suppallocs.transid_allocfrom=" . $SuppliersPaid['id'] . " + ORDER BY supptrans.type, + supptrans.transno"; + + + $TransResult = DB_query($sql,$db,'','',false,false); + if (DB_error_no($db) !=0) { + $title = _('Remittance Advice Problem Report'); + include('includes/header.inc'); + prnMsg(_('The details of the payment to the supplier could not be retrieved because') . ' - ' . DB_error_msg($db),'error'); + echo '<br><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; + if ($debug==1){ + echo '<br>' . _('The SQL that failed was') . ' ' . $sql; + } + include('includes/footer.inc'); + exit; + } + + + while ($DetailTrans = DB_fetch_array($TransResult)){ + + $DisplayTranDate = ConvertSQLDate($DetailTrans['trandate']); + + $LeftOvers = $pdf->addTextWrap($Left_Margin+5, $YPos, 80,$FontSize,$DetailTrans['typename'], 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+95, $YPos, 80,$FontSize,$DisplayTranDate, 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+175, $YPos, 80,$FontSize,$DetailTrans['suppreference'], 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+255, $YPos, 80,$FontSize,number_format($DetailTrans['trantotal'],2), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+355, $YPos,80,$FontSize,number_format($DetailTrans['amt'],2), 'right'); + $AccumBalance += $DetailTrans['amt']; + + $YPos -=$line_height; + if ($YPos < $Bottom_Margin + $line_height){ + $PageNumber++; + PageHeader(); + } + } /*end while there are detail transactions to show */ + PaymentFooter(); + } /* end while there are supplier payments to retrieve allocations for */ + + $pdfcode = $pdf->output(); + $len = strlen($pdfcode); + header('Content-type: application/pdf'); + header('Content-Length: ' . $len); + header('Content-Disposition: inline; filename=RemittanceAdvice.pdf'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + + $pdf->stream(); + + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + +} else { /*The option to print PDF was not hit */ + + $title=_('Remittance Advices'); + include('includes/header.inc'); + + /* show form to allow input */ + + echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method="POST"><table>'; + + if (!isset($_POST['FromCriteria']) or strlen($_POST['FromCriteria'])<1){ + $DefaultFromCriteria = '1'; + } else { + $DefaultFromCriteria = $_POST['FromCriteria']; + } + if (!isset($_POST['ToCriteria']) or strlen($_POST['ToCriteria'])<1){ + $DefaultToCriteria = 'zzzzzzz'; + } else { + $DefaultToCriteria = $_POST['ToCriteria']; + } + echo '<tr><td>' . _('From Supplier Code') . ':</font></td> + <td><input Type=text maxlength=6 size=7 name=FromCriteria value="' . $DefaultFromCriteria . '"></td></tr>'; + echo '<tr><td>' . _('To Supplier Code') . ':</td> + <td><input Type=text maxlength=6 size=7 name=ToCriteria value="' . $DefaultToCriteria . '"></td></tr>'; + + if (!isset($_POST['PaymentDate'])){ + $DefaultDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m')+1,0 ,Date('y'))); + } else { + $DefaultDate = $_POST['PaymentDate']; + } + + echo '<tr><td>' . _('Date Of Payment') . ':</td> + <td><input type=text class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="PaymentDate" maxlength=11 size=12 VALUE=' . $DefaultDate . '></td></tr>'; + + echo '</table><div class="centre"><input type=Submit Name="PrintPDF" Value="' . _('Print PDF') . '"></div>'; + + include ('includes/footer.inc'); +} /*end of else not PrintPDF */ + + +function PaymentFooter (){ + global $pdf; + global $YPos; + global $line_height; + global $Page_Width; + global $Right_Margin; + global $Left_Margin; + global $Bottom_Margin; + global $FontSize; + global $SupplierName; + global $AccumBalance; + global $TotalPayments; + + $YPos -= (0.5*$line_height); + $pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); + + $LeftOvers = $pdf->addTextWrap($Left_Margin+280,$YPos,75,$FontSize,_('Total Payment:'), 'right'); + + $TotalPayments += $AccumBalance; + + $LeftOvers = $pdf->addTextWrap($Left_Margin+355,$YPos,80,$FontSize,number_format($AccumBalance,2), 'right'); + + $YPos -= (1.5*$line_height); + $pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); +} + +function PageHeader(){ + global $pdf; + global $PageNumber; + global $YPos; + global $Xpos; + global $line_height; + global $Page_Height; + global $Top_Margin; + global $Page_Width; + global $Right_Margin; + global $Left_Margin; + global $Bottom_Margin; + global $FontSize; + global $SupplierName; + global $AccumBalance; + global $RemittanceAdviceCounter; + global $SuppliersPaid; + + if ($RemittanceAdviceCounter>0){ + $pdf->newPage(); + } + + $YPos = $Page_Height - $Top_Margin; + + $pdf->addJpegFromFile($_SESSION['LogoFile'],$Page_Width/2 -50,$YPos-50,0,30); + + // Title + $FontSize =15; + $XPos = $Page_Width/2 - 110; + $pdf->addText($XPos, $YPos,$FontSize, _('Remittance Advice') ); + + $FontSize = 10; + $pdf->addText($XPos + 150, $YPos,$FontSize, ' '. _('printed:').' ' . Date($_SESSION['DefaultDateFormat'])); + + $pdf->addText($XPos + 280, $YPos,$FontSize, _('Page').': ' . $PageNumber); + + /*Now print out company info at the top left */ + + $XPos = $Left_Margin; + $YPos = $Page_Height - $Top_Margin - 20; + + $FontSize = 10; + $LineHeight = 13; + $LineCount = 0; + + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, $_SESSION['CompanyRecord']['coyname']); + + $FontSize = 8; + $LineHeight = 10; + + if ($_SESSION['CompanyRecord']['regoffice1'] <> '') { + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight,$FontSize, $_SESSION['CompanyRecord']['regoffice1']); + } + if ($_SESSION['CompanyRecord']['regoffice2'] <> '') { + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight,$FontSize, $_SESSION['CompanyRecord']['regoffice2']); + } + if (($_SESSION['CompanyRecord']['regoffice3'] <> '') OR ($_SESSION['CompanyRecord']['regoffice4'] <> '') OR ($_SESSION['CompanyRecord']['regoffice5'] <> '')) { + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight,$FontSize, $_SESSION['CompanyRecord']['regoffice3'] . ' ' . $_SESSION['CompanyRecord']['regoffice4'] . ' ' . $_SESSION['CompanyRecord']['regoffice5']); // country in 6 not printed + } + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, _('Phone') . ':' . $_SESSION['CompanyRecord']['telephone']); + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight,$FontSize, _('Fax') . ': ' . $_SESSION['CompanyRecord']['fax']); + $LineCount += 1; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, _('Email') . ': ' . $_SESSION['CompanyRecord']['email']); + + + /*Now the supplier details and remittance advice address */ + + $XPos = $Left_Margin+20; + $YPos = $Page_Height - $Top_Margin - 120; + + $LineCount = 0; + $FontSize = 10; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, $SuppliersPaid['suppname']); + $LineCount ++; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, $SuppliersPaid['address1']); + $LineCount ++; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, $SuppliersPaid['address2']); + $LineCount ++; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, $SuppliersPaid['address3'] . ' ' . $SuppliersPaid['address4'] . ' ' . $SuppliersPaid['address5'] . ' ' . $SuppliersPaid['address6']); + $LineCount += 2; + $pdf->addText($XPos, $YPos-$LineCount*$LineHeight, $FontSize, _('Our Code:') . ' ' .$SuppliersPaid['supplierid']); + + $YPos = $Page_Height - $Top_Margin - 120; + + $FontSize=8; + $XPos = $Page_Width/2 - 60; + $pdf->addText($XPos, $YPos,$FontSize, _('All amounts stated in') . ' - ' . $SuppliersPaid['currcode']); + $YPos -= $line_height; + $pdf->addText($XPos, $YPos,$FontSize, $SuppliersPaid['terms']); + + $YPos = $Page_Height - $Top_Margin - 180; + //$YPos -= $line_height; + $XPos = $Left_Margin; + + /*draw a nice curved corner box around the statement details */ + /*from the top right */ + $pdf->partEllipse($Page_Width-$Right_Margin-10,$YPos-10,0,90,10,10); + /*line to the top left */ + $pdf->line($Page_Width-$Right_Margin-10, $YPos,$Left_Margin+10, $YPos); + /*Do top left corner */ + $pdf->partEllipse($Left_Margin+10, $YPos-10,90,180,10,10); + /*Do a line to the bottom left corner */ + $pdf->line($Left_Margin, $YPos-10,$Left_Margin, $Bottom_Margin+10); + /*Now do the bottom left corner 180 - 270 coming back west*/ + $pdf->partEllipse($Left_Margin+10, $Bottom_Margin+10,180,270,10,10); + /*Now a line to the bottom right */ + $pdf->line($Left_Margin+10, $Bottom_Margin,$Page_Width-$Right_Margin-10, $Bottom_Margin); + /*Now do the bottom right corner */ + $pdf->partEllipse($Page_Width-$Right_Margin-10, $Bottom_Margin+10,270,360,10,10); + /*Finally join up to the top right corner where started */ + $pdf->line($Page_Width-$Right_Margin, $Bottom_Margin+10,$Page_Width-$Right_Margin, $YPos-10); + + /*Finally join up to the top right corner where started */ + $pdf->line($Page_Width-$Right_Margin, $Bottom_Margin+10,$Page_Width-$Right_Margin, $YPos-10); + + $YPos -= $line_height; + $FontSize =10; + /*Set up headings */ + $pdf->addText($Left_Margin+10, $YPos,$FontSize, _('Trans Type') ); + $pdf->addText($Left_Margin+100, $YPos,$FontSize, _('Date') ); + $pdf->addText($Left_Margin+180, $YPos,$FontSize, _('Reference') ); + $pdf->addText($Left_Margin+310, $YPos,$FontSize, _('Total') ); + $pdf->addText($Left_Margin+390, $YPos,$FontSize, _('This Payment') ); + + $YPos -= $line_height; + /*draw a line */ + $pdf->line($Page_Width-$Right_Margin, $YPos,$XPos, $YPos); + + $YPos -= $line_height; + $XPos = $Left_Margin; + +} +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2009-11-29 06:08:47 UTC (rev 3133) +++ trunk/doc/Change.log.html 2009-11-29 06:52:46 UTC (rev 3134) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>29/11/09 Phil: New Remittance Advice script <p>24/11/09 Tim: WWW_Users.php - Allow for case where Last visited date isn'nt set, and set it. <p>24/11/09 Tim: SystemParameters.php - Remove .svn from the theme list, and minor layout changes for currencies where large numbers are common. <p>23/11/09 Tim: PrintCustTrans.php and PrintCustTransPortrait.php - Correctly print the invoice lines, and add the invoice number to the file name Modified: trunk/includes/PDFPaymentRunPageHeader.inc =================================================================== --- trunk/includes/PDFPaymentRunPageHeader.inc 2009-11-29 06:08:47 UTC (rev 3133) +++ trunk/includes/PDFPaymentRunPageHeader.inc 2009-11-29 06:52:46 UTC (rev 3134) @@ -1,5 +1,5 @@ <?php -/* $Revision: 1.5 $ */ +/* $Id $ */ /*PDF page header for aged analysis reports */ if ($PageNumber >1){ $pdf->newPage(); Modified: trunk/includes/PDFStarter.php =================================================================== --- trunk/includes/PDFStarter.php 2009-11-29 06:08:47 UTC (rev 3133) +++ trunk/includes/PDFStarter.php 2009-11-29 06:52:46 UTC (rev 3134) @@ -1,5 +1,5 @@ <?php -/* $Revision: 1.5 $ */ +/* $Id $ */ /*this class is an extension to the fpdf class using a syntax that the original reports were written in (the R &OS pdf.php class) - due to limitation of this class for foreign character support this wrapper class Modified: trunk/index.php =================================================================== --- trunk/index.php 2009-11-29 06:08:47 UTC (rev 3133) +++ trunk/index.php 2009-11-29 06:52:46 UTC (rev 3134) @@ -383,6 +383,11 @@ </tr> <tr> <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/PDFRemittanceAdvice.php?' . SID . '">' . _('Remittance Advices') . '</a></p>'; ?> + </td> + </tr> + <tr> + <td class="menu_group_item"> <?php echo '<p>• <a href="' . $rootpath . '/OutstandingGRNs.php?' . SID . '">' . _('Outstanding GRNs Report') . '</a></p>'; ?> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |