From: <tim...@us...> - 2010-03-01 08:28:36
|
Revision: 3363 http://web-erp.svn.sourceforge.net/web-erp/?rev=3363&view=rev Author: tim_schofield Date: 2010-03-01 08:28:30 +0000 (Mon, 01 Mar 2010) Log Message: ----------- Pak Ricard: PDFPriceList.php - Updated price list report Modified Paths: -------------- trunk/PDFPriceList.php trunk/doc/Change.log.html Modified: trunk/PDFPriceList.php =================================================================== --- trunk/PDFPriceList.php 2010-03-01 07:57:03 UTC (rev 3362) +++ trunk/PDFPriceList.php 2010-03-01 08:28:30 UTC (rev 3363) @@ -1,21 +1,22 @@ <?php +/* $Revision: 1.14 $ */ -/* $Id$*/ -/* $Revision: 1.15 $ */ - $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){ +If (isset($_POST['PrintPDF']) + AND isset($_POST['FromCriteria']) + AND strlen($_POST['FromCriteria'])>=1 + AND isset($_POST['ToCriteria']) + AND strlen($_POST['ToCriteria'])>=1){ include('includes/PDFStarter.php'); - $pdf->addInfo('Title', _('Price Listing Report') ); - $pdf->addInfo('Subject', _('Price List') ); + $FontSize=10; + $pdf->addinfo('Title', _('Price Listing Report') ); + $pdf->addinfo('Subject', _('Price List') ); + + $PageNumber=1; $line_height=12; @@ -43,6 +44,7 @@ $SQL = "SELECT prices.typeabbrev, prices.stockid, stockmaster.description, + stockmaster.longdescription, prices.currabrev, prices.price, stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standardcost, @@ -77,6 +79,7 @@ $SQL = "SELECT prices.typeabbrev, prices.stockid, stockmaster.description, + stockmaster.longdescription, prices.currabrev, prices.price, stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost as standardcost, @@ -97,8 +100,6 @@ } $PricesResult = DB_query($SQL,$db,'','',false,false); - $ListSize = count ($PricesResult); //Javier - if (DB_error_no($db) !=0) { $title = _('Price List') . ' - ' . _('Problem Report....'); include('includes/header.inc'); @@ -115,20 +116,22 @@ $CurrCode =''; $Category = ''; $CatTot_Val=0; - while ($PriceList = DB_fetch_array($PricesResult,$db)){ + $Pos=$Page_Height-$Top_Margin-$YPos+20; + While ($PriceList = DB_fetch_array($PricesResult,$db)){ + if ($CurrCode != $PriceList['currabrev']){ $FontSize=10; - $YPos -=(2*$line_height); + $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,300-$Left_Margin,$FontSize, $PriceList['currabrev'] . ' ' . _('Prices')); $CurrCode = $PriceList['currabrev']; $FontSize = 8; $YPos -= $line_height; } - if ($Category!= $PriceList['categoryid']){ + if ($Category!=$PriceList['categoryid']){ $FontSize=10; - $YPos -=(2*$line_height); + $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,300-$Left_Margin,$FontSize,$PriceList['categoryid'] . ' - ' . $PriceList['categorydescription']); $Category = $PriceList['categoryid']; $CategoryName = $PriceList['categorydescription']; @@ -137,10 +140,20 @@ } $YPos -=$line_height; + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$PriceList['stockid']); + $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize,$PriceList['description']); + $DisplayUnitPrice = number_format($PriceList['price'],2); + $LeftOvers = $pdf->addTextWrap(440,$YPos,60,$FontSize,$DisplayUnitPrice, 'right'); + if ($PriceList['price']!=0){ + $DisplayGPPercent = (int)(($PriceList['price']-$PriceList['standardcost'])*100/$PriceList['price']) . '%'; + } else { + $DisplayGPPercent = 0; + } - $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$PriceList['stockid']); - $LeftOvers = $pdf->addTextWrap(120,$YPos,260,$FontSize,$PriceList['description']); + if ($_POST['ShowGPPercentages']=='Yes'){ + $LeftOvers = $pdf->addTextWrap(530,$YPos,20,$FontSize,$DisplayGPPercent, 'right'); + } if ($_POST['CustomerSpecials']=='Customer Special Prices Only'){ /*Need to show to which branch the price relates */ @@ -150,60 +163,73 @@ $LeftOvers = $pdf->addTextWrap(320,$YPos,130,$FontSize,_('All'),'left'); } - } + }else If ($_POST['CustomerSpecials']=='Full Description'){ - $DisplayUnitPrice = number_format($PriceList['price'],2); + if(file_exists($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg') ) { + $img = imagecreatefromjpeg($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg'); + $width = imagesx( $img ); + $height = imagesy( $img ); + if($width>$height){ + $LeftOvers = $pdf->Image($_SESSION['part_pics_dir'] . '/'.$PriceList['stockid'].'.jpg',120,$Page_Height-$Top_Margin-$YPos+20,50,0); + }else{ + $LeftOvers = $pdf->Image($_SESSION['part_pics_dir'] . '/'.$PriceList['stockid'].'.jpg',120,$Page_Height-$Top_Margin-$YPos+20,0,40); + } + }/*end checked file exist*/ - if ($PriceList['price']!=0){ - $DisplayGPPercent = (int)(($PriceList['price']-$PriceList['standardcost'])*100/$PriceList['price']) . '%'; - } else { - $DisplayGPPercent = 0; - } + $Split = explode("\r\n", $PriceList['longdescription']); + $FontSize2=6; + for ($i=0; $i<=count($Split); $i++) + { + if(count($Split)==1){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,''); + }elseif(count($Split)==2){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); + }elseif(count($Split)>=3){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); + } - $LeftOvers = $pdf->addTextWrap(440,$YPos,60,$FontSize,$DisplayUnitPrice, 'right'); - if ($_POST['ShowGPPercentages']=='Yes'){ - $LeftOvers = $pdf->addTextWrap(530,$YPos,20,$FontSize,$DisplayGPPercent, 'right'); - } + }/*end for*/ + }/*end if*/ + + + if ($YPos < $Bottom_Margin + $line_height){ include('includes/PDFPriceListPageHeader.inc'); + } } /*end inventory valn while loop */ + $FontSize =10; /*Print out the category totals */ -// Javier: this was actually the Price List that was PDF-Created but it seems it was intended to be only the check that I named ListSize. -/* $FontSize =10; - $FileName= $_SESSION['DatabaseName'] . '_' .'PriceList_' . date('Y-m-d').'.pdf'; -// $pdfcode = $pdf->output(); - $pdfcode = $pdf->OutputD($Filename); - $len = strlen($pdfcode); */ -// if ($len<=20){ - if ($ListSize == 0) { + $pdfcode = $pdf->output(); + $len = strlen($pdfcode); + + if ($len<=20){ $title = _('Print Price List Error'); include('includes/header.inc'); prnMsg(_('There were no price details to print out for the customer or category specified'),'warn'); echo '<br><a href="'.$rootpath.'/index.php?' . SID . '">'. _('Back to the menu').'</a>'; include('includes/footer.inc'); exit; - } else { - -// Javier: TCPDF sends its own http header, it's an error to send it twice. - /* header('Content-type: application/pdf'); + } else { + header('Content-type: application/pdf'); header('Content-Length: ' . $len); header('Content-Disposition: inline; filename=PriceList.pdf'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); */ -// $FontSize =10; - $FileName= $_SESSION['DatabaseName'] . '_' .'PriceList_' . date('Y-m-d').'.pdf'; -// $pdf->Output($FileName,'I'); -// Javier: This is a recursive script, so it needs to be downloaded. - $pdf->OutputD($FileName); - $pdf-> __destruct(); + header('Pragma: public'); + $FileName=$_SESSION['DatabaseName'].'_'.date('Y-m-d').'.pdf'; + $pdf->Output($FileName,'I'); } } else { /*The option to print PDF was not hit */ @@ -220,7 +246,7 @@ $sql='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categoryid'; $CatResult= DB_query($sql,$db); - while ($myrow = DB_fetch_array($CatResult)){ + While ($myrow = DB_fetch_array($CatResult)){ echo "<option VALUE='" . $myrow['categoryid'] . "'>" . $myrow['categoryid'] . ' - ' . $myrow['categorydescription']; } echo '</select></td></tr>'; @@ -230,7 +256,7 @@ /*Set the index for the categories result set back to 0 */ DB_data_seek($CatResult,0); - while ($myrow = DB_fetch_array($CatResult)){ + While ($myrow = DB_fetch_array($CatResult)){ echo '<option VALUE="' . $myrow['categoryid'] . '">' . $myrow['categoryid'] . ' - ' . $myrow['categorydescription']; } echo '</select></td></tr>'; @@ -250,14 +276,14 @@ echo '</select></td></tr>'; echo '<tr><td>' . _('Price Listing Type'). ':</td><td><select name="CustomerSpecials">'; - echo '<option Value="Customer Special Prices Only">'. _('Customer Special Prices Only'); echo '<option selected Value="Sales Type Prices">'. _('Default Sales Type Prices'); + echo '<option Value="Customer Special Prices Only">'. _('Customer Special Prices Only'); + echo '<option Value="Full Description">'. _('Full Description'); echo '</select></td></tr>'; - /*echo '</table><div class="centre"><input type=Submit Name="PrintPDF" Value="'. _('Print PDF'). '"></div>';*/ - echo '</table><div class="centre"><input type=Submit Name="PrintPDF" Value="'. _('Print PDF'). '"></div></form>'; + echo '</table><div class="centre"><input type=Submit Name="PrintPDF" Value="'. _('Print PDF'). '"></div>'; } include('includes/footer.inc'); } /*end of else not PrintPDF */ -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-03-01 07:57:03 UTC (rev 3362) +++ trunk/doc/Change.log.html 2010-03-01 08:28:30 UTC (rev 3363) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>01/03/10 Pak Ricard: PDFPriceList.php - Updated price list report</p> <p>01/03/10 Harald: PcExpensesTypeTabv.php - Correct message on deletion of tab</p> <p>01/03/10 Harald: PcExpensesTypeTabv.php - Missing space</p> <p>01/03/10 Harald: PcExpensesTypeTabv.php - Missing space, and bad end tag</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |