[Weberp-svn] SF.net SVN: weberp:[7760] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-08-14 10:31:00
|
Revision: 7760 http://weberp.svn.sourceforge.net/weberp/?rev=7760&view=rev Author: tim_schofield Date: 2011-08-14 10:30:53 +0000 (Sun, 14 Aug 2011) Log Message: ----------- Add in facility to print a GL journal Modified Paths: -------------- trunk/GLJournal.php Added Paths: ----------- trunk/PDFGLJournal.php trunk/companies/weberpdemo/FormDesigns/Journal.xml trunk/includes/PDFGLJournalHeader.inc Modified: trunk/GLJournal.php =================================================================== --- trunk/GLJournal.php 2011-08-14 10:30:30 UTC (rev 7759) +++ trunk/GLJournal.php 2011-08-14 10:30:53 UTC (rev 7760) @@ -111,13 +111,15 @@ prnMsg(_('Journal').' ' . $TransNo . ' '._('has been successfully entered'),'success'); + echo '<br /><div class="centre"><a href="PDFGLJournal.php?JournalNo='.$TransNo.'">'._('Print this Journal').'</a>'; + unset($_POST['JournalProcessDate']); unset($_POST['JournalType']); unset($_SESSION['JournalDetail']->GLEntries); unset($_SESSION['JournalDetail']); /*Set up a newy in case user wishes to enter another */ - echo '<br /><a href="' . $_SERVER['PHP_SELF'] . '?NewJournal=Yes">'._('Enter Another General Ledger Journal').'</a>'; + echo '<br /><a href="' . $_SERVER['PHP_SELF'] . '?NewJournal=Yes">'._('Enter Another General Ledger Journal').'</a></div>'; /*And post the journal too */ include ('includes/GLPostings.inc'); include ('includes/footer.inc'); Added: trunk/PDFGLJournal.php =================================================================== --- trunk/PDFGLJournal.php (rev 0) +++ trunk/PDFGLJournal.php 2011-08-14 10:30:53 UTC (rev 7760) @@ -0,0 +1,111 @@ +<?php +$PageSecurity=1; +/* $Id$*/ + +/* $Revision: 1.5 $ */ + +include('includes/session.inc'); + +if (isset($_POST['JournalNo'])) { + $JournalNo=$_POST['JournalNo']; +} else if (isset($_GET['JournalNo'])) { + $JournalNo=$_GET['JournalNo']; +} else { + $JournalNo=''; +} + +if ($JournalNo=='Preview') { + $FormDesign = simplexml_load_file(sys_get_temp_dir().'/Journal.xml'); +} else { + $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/Journal.xml'); +} + +// Set the paper size/orintation +$PaperSize = $FormDesign->PaperSize; +$PageNumber=1; +$line_height=$FormDesign->LineHeight; +include('includes/PDFStarter.php'); +$pdf->addInfo('Title', _('General Ledger Journal') ); + +if ($JournalNo=='Preview') { + $LineCount = 2; // UldisN +} else { + $sql="SELECT gltrans.typeno, + gltrans.trandate, + gltrans.account, + chartmaster.accountname, + gltrans.narrative, + gltrans.amount, + gltrans.tag, + tags.tagdescription, + gltrans.jobref + FROM gltrans + INNER JOIN chartmaster + ON gltrans.account=chartmaster.accountcode + LEFT JOIN tags + ON gltrans.tag=tags.tagref + WHERE gltrans.type='0' + AND gltrans.typeno='" . $JournalNo . "'"; + $result=DB_query($sql, $db); + $LineCount = DB_num_rows($result); // UldisN + $myrow=DB_fetch_array($result); + $JournalDate=$myrow['trandate']; + DB_data_seek($result, 0); + include('includes/PDFGLJournalHeader.inc'); +} +$counter=1; +$YPos=$FormDesign->Data->y; +while ($counter<=$LineCount) { + if ($JournalNo=='Preview') { + $AccountCode=str_pad('',10,'x'); + $Date='1/1/1900'; + $Description=str_pad('',30,'x'); + $Narrative=str_pad('',30,'x'); + $Amount='XXXX.XX'; + $Tag=str_pad('',25,'x'); + $JobRef=str_pad('',25,'x'); + } else { + $myrow=DB_fetch_array($result); + if ($myrow['tag']==0) { + $myrow['tagdescription']='None'; + } + $AccountCode = $myrow['account']; + $Description = $myrow['accountname']; + $Date = $myrow['trandate']; + $Narrative = $myrow['narrative']; + $Amount = $myrow['amount']; + $Tag = $myrow['tag'].' - '.$myrow['tagdescription']; + $JobRef = $myrow['jobref']; + } + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$Page_Height-$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $AccountCode); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$Page_Height-$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $Description); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$Page_Height-$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $Narrative); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$Page_Height-$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize, number_format($Amount,$_SESSION['Currencies'][$_SESSION['CompanyRecord']['currencydefault']]['DecimalPlaces']), 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$Page_Height-$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize, $Tag); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column6->x,$Page_Height-$YPos,$FormDesign->Data->Column6->Length,$FormDesign->Data->Column6->FontSize, $JobRef, 'left'); + $YPos += $line_height; + $counter++; + if ($YPos >= $FormDesign->LineAboveFooter->starty){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + $YPos=$FormDesign->Data->y; + include ('includes/PDFGrnHeader.inc'); + } //end if need a new page headed up +} + +$LeftOvers = $pdf->addText($FormDesign->ReceiptDate->x,$Page_Height-$FormDesign->ReceiptDate->y,$FormDesign->ReceiptDate->FontSize, _('Date of Receipt: ').$Date); + +$LeftOvers = $pdf->addText($FormDesign->SignedFor->x,$Page_Height-$FormDesign->SignedFor->y,$FormDesign->SignedFor->FontSize, _('Signed for ').'______________________'); + +if ($LineCount == 0) { //UldisN + $title = _('GRN Error'); + include('includes/header.inc'); + prnMsg(_('There were no GRN to print'),'warn'); + echo '<br /><a href="'.$rootpath.'/index.php">'. _('Back to the menu').'</a>'; + include('includes/footer.inc'); + exit; +} else { + $pdf->OutputD($_SESSION['DatabaseName'] . '_GRN_' . date('Y-m-d').'.pdf');//UldisN + $pdf->__destruct(); //UldisN +} +?> \ No newline at end of file Added: trunk/companies/weberpdemo/FormDesigns/Journal.xml =================================================================== --- trunk/companies/weberpdemo/FormDesigns/Journal.xml (rev 0) +++ trunk/companies/weberpdemo/FormDesigns/Journal.xml 2011-08-14 10:30:53 UTC (rev 7760) @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form name="Goods Received Note"> + <PaperSize name="Paper size">A4_Landscape</PaperSize> + <LineHeight name="Line height">12</LineHeight> + <logo type="image" name="Logo" id="Logo"> + <x>20</x> + <y>80</y> + <width>0</width> + <height>60</height> + </logo> + <CompanyName type="SimpleText" name="Company name" id="CompanyName"> + <FontSize>10</FontSize> + <x>625</x> + <y>30</y> + </CompanyName> + <GRNNumber type="SimpleText" name="GRN Number" id="GRNNumber"> + <FontSize>10</FontSize> + <x>625</x> + <y>48</y> + </GRNNumber> + <OrderNumber type="SimpleText" name="Order Number" id="OrderNumber"> + <FontSize>10</FontSize> + <x>625</x> + <y>66</y> + </OrderNumber> + <PrintDate type="SimpleText" name="Date Printed" id="PrintDate"> + <FontSize>10</FontSize> + <x>625</x> + <y>84</y> + </PrintDate> + <HeaderRectangle type="Rectangle" name="Header rectangle" id="HeaderRectangle"> + <x>40</x> + <y>114</y> + <width>772</width> + <height>24</height> + </HeaderRectangle> + <Headings type="ElementArray" name="Column headings"> + <Column1 type="SimpleText" name="Heading 1" id="Heading1"> + <FontSize>10</FontSize> + <x>41</x> + <y>126</y> + </Column1> + <Column2 type="SimpleText" name="Heading 2" id="Heading2"> + <FontSize>10</FontSize> + <x>116</x> + <y>126</y> + </Column2> + <Column3 type="SimpleText" name="Heading 3" id="Heading3"> + <FontSize>10</FontSize> + <x>256</x> + <y>126</y> + </Column3> + <Column4 type="MultiLineText" name="Heading 4" id="Heading4"> + <FontSize>10</FontSize> + <x>486</x> + <y>136</y> + <Length>100</Length> + </Column4> + <Column5 type="MultiLineText" name="Heading 5" id="Heading5"> + <FontSize>10</FontSize> + <x>616</x> + <y>136</y> + <Length>100</Length> + </Column5> + </Headings> + <DataRectangle type="Rectangle" name="Data rectangle" id="DataRectangle"> + <x>40</x> + <y>138</y> + <width>772</width> + <height>430</height> + </DataRectangle> + <LineAboveFooter type="Line" name="Line Above Footer" id="LineAboveFooter"> + <startx>40</startx> + <starty>530</starty> + <endx>812</endx> + <endy>530</endy> + </LineAboveFooter> + <Column1 type="Line" name="Column 1" id="Column1"> + <startx>114</startx> + <starty>114</starty> + <endx>114</endx> + <endy>530</endy> + </Column1> + <Column3 type="Line" name="Column 3" id="Column3"> + <startx>254</startx> + <starty>114</starty> + <endx>254</endx> + <endy>530</endy> + </Column3> + <Column4 type="Line" name="Column 4" id="Column4"> + <startx>489</startx> + <starty>114</starty> + <endx>489</endx> + <endy>530</endy> + </Column4> + <Column5 type="Line" name="Column 5" id="Column5"> + <startx>616</startx> + <starty>114</starty> + <endx>616</endx> + <endy>530</endy> + </Column5> + <Data type="ElementArray" name="Column Data"> + <y type="StartLine" name="Y co-ordinate of first data line" id="DataStartLine">156</y> + <Column1 type="DataText" name="Column 1" id="Data1"> + <FontSize>10</FontSize> + <x>41</x> + <Length>94</Length> + </Column1> + <Column2 type="DataText" name="Column 2" id="Data2"> + <FontSize>10</FontSize> + <x>116</x> + <Length>270</Length> + </Column2> + <Column3 type="DataText" name="Column 3" id="Data3"> + <FontSize>10</FontSize> + <x>256</x> + <Length>85</Length> + </Column3> + <Column4 type="DataText" name="Column 5" id="Data5"> + <FontSize>10</FontSize> + <x>568</x> + <Length>30</Length> + </Column4> + <Column5 type="DataText" name="Column 6" id="Data6"> + <FontSize>10</FontSize> + <x>638</x> + <Length>60</Length> + </Column5> + <Column6 type="DataText" name="Column 7" id="Data7"> + <FontSize>10</FontSize> + <x>700</x> + <Length>30</Length> + </Column6> + </Data> + <ReceiptDate type="SimpleText" name="Date Received" id="ReceiptDate"> + <FontSize>10</FontSize> + <x>300</x> + <y>550</y> + </ReceiptDate> + <SignedFor type="SimpleText" name="Signed Fror" id="SignedFor"> + <FontSize>10</FontSize> + <x>50</x> + <y>550</y> + </SignedFor> +</form> Added: trunk/includes/PDFGLJournalHeader.inc =================================================================== --- trunk/includes/PDFGLJournalHeader.inc (rev 0) +++ trunk/includes/PDFGLJournalHeader.inc 2011-08-14 10:30:53 UTC (rev 7760) @@ -0,0 +1,36 @@ +<?php +/* $Id$*/ +/*PDF page header for price list report */ +if ($PageNumber>1){ + $pdf->newPage(); +} + +$pdf->addJpegFromFile($_SESSION['LogoFile'] ,$FormDesign->logo->x,$Page_Height-$FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height); + +$LeftOvers = $pdf->addText($FormDesign->CompanyName->x,$Page_Height-$FormDesign->CompanyName->y,$FormDesign->CompanyName->FontSize,$_SESSION['CompanyRecord']['coyname']); +$LeftOvers = $pdf->addText($FormDesign->GRNNumber->x,$Page_Height-$FormDesign->GRNNumber->y,$FormDesign->GRNNumber->FontSize, _('Journal number ').' ' . $JournalNo ); +$LeftOvers = $pdf->addText($FormDesign->OrderNumber->x,$Page_Height-$FormDesign->OrderNumber->y,$FormDesign->OrderNumber->FontSize, _('Journal Date ').' ' . ConvertSQLDate($JournalDate) ); +$LeftOvers = $pdf->addText($FormDesign->PrintDate->x,$Page_Height-$FormDesign->PrintDate->y,$FormDesign->PrintDate->FontSize, _('Printed').': ' . Date($_SESSION['DefaultDateFormat']) . ' '. _('Page'). ' ' . $PageNumber); + +/*Draw a rectangle to put the headings in */ +$pdf->Rectangle($FormDesign->HeaderRectangle->x, $Page_Height - $FormDesign->HeaderRectangle->y, $FormDesign->HeaderRectangle->width,$FormDesign->HeaderRectangle->height); + +/*set up the headings */ +$LeftOvers = $pdf->addText($FormDesign->Headings->Column1->x,$Page_Height - $FormDesign->Headings->Column1->y, $FormDesign->Headings->Column1->FontSize, _('Account Code')); +$LeftOvers = $pdf->addText($FormDesign->Headings->Column2->x,$Page_Height - $FormDesign->Headings->Column2->y, $FormDesign->Headings->Column2->FontSize, _('Account Description')); +$LeftOvers = $pdf->addText($FormDesign->Headings->Column3->x,$Page_Height - $FormDesign->Headings->Column3->y, $FormDesign->Headings->Column3->FontSize, _('Narrative')); +$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column4->x,$Page_Height - $FormDesign->Headings->Column4->y, $FormDesign->Headings->Column4->Length, $FormDesign->Headings->Column4->FontSize, _('Amount'), 'right'); +$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column5->x,$Page_Height - $FormDesign->Headings->Column5->y, $FormDesign->Headings->Column5->Length, $FormDesign->Headings->Column5->FontSize, _('Tag Details'), 'right'); + +/*Draw a rectangle to put the data in */ +$pdf->Rectangle($FormDesign->DataRectangle->x, $Page_Height - $FormDesign->DataRectangle->y, $FormDesign->DataRectangle->width,$FormDesign->DataRectangle->height); + +$pdf->Line($FormDesign->LineAboveFooter->startx, $Page_Height - $FormDesign->LineAboveFooter->starty, $FormDesign->LineAboveFooter->endx,$Page_Height - $FormDesign->LineAboveFooter->endy); + +$pdf->Line($FormDesign->Column1->startx, $Page_Height - $FormDesign->Column1->starty, $FormDesign->Column1->endx,$Page_Height - $FormDesign->Column1->endy); +$pdf->Line($FormDesign->Column3->startx, $Page_Height - $FormDesign->Column3->starty, $FormDesign->Column3->endx,$Page_Height - $FormDesign->Column3->endy); +$pdf->Line($FormDesign->Column4->startx, $Page_Height - $FormDesign->Column4->starty, $FormDesign->Column4->endx,$Page_Height - $FormDesign->Column4->endy); +$pdf->Line($FormDesign->Column5->startx, $Page_Height - $FormDesign->Column5->starty, $FormDesign->Column5->endx,$Page_Height - $FormDesign->Column5->endy); + +$PageNumber++; +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |