From: <dai...@us...> - 2012-04-26 10:48:06
|
Revision: 5287 http://web-erp.svn.sourceforge.net/web-erp/?rev=5287&view=rev Author: daintree Date: 2012-04-26 10:48:00 +0000 (Thu, 26 Apr 2012) Log Message: ----------- label priting changes Modified Paths: -------------- trunk/PDFPrintLabel.php trunk/UpgradeDatabase.php Modified: trunk/PDFPrintLabel.php =================================================================== --- trunk/PDFPrintLabel.php 2012-04-26 09:23:58 UTC (rev 5286) +++ trunk/PDFPrintLabel.php 2012-04-26 10:48:00 UTC (rev 5287) @@ -5,12 +5,95 @@ $PtsPerMM = 2.83465; //pdf millimetres to points -if (isset($_POST['PrintPDF']) + +if (isset($_POST['ShowLabels']) AND isset($_POST['FromCriteria']) AND mb_strlen($_POST['FromCriteria'])>=1 AND isset($_POST['ToCriteria']) AND mb_strlen($_POST['ToCriteria'])>=1){ + + $title = _('Print Labels'); + include('includes/header.inc'); + + $SQL = "SELECT prices.stockid, + stockmaster.description, + stockmaster.barcode, + prices.price, + currencies.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN prices + ON stockmaster.stockid=prices.stockid + INNER JOIN currencies + ON prices.currabrev=currencies.currabrev + WHERE stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' + AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' + AND prices.typeabbrev='" . $_POST['SalesType'] . "' + AND prices.currabrev='" . $_POST['Currency'] . "' + AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' + AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') + AND prices.debtorno='' + ORDER BY prices.currabrev, + stockmaster.categoryid, + stockmaster.stockid, + prices.startdate"; + $LabelsResult = DB_query($SQL,$db,'','',false,false); + + if (DB_error_no($db) !=0) { + prnMsg( _('The Price Labels could not be retrieved by the SQL because'). ' - ' . DB_error_msg($db), 'error'); + echo '<br /><a href="' .$rootpath .'/index.php">'. _('Back to the menu'). '</a>'; + if ($debug==1){ + prnMsg(_('For debugging purposes the SQL used was:') . $SQL,'error'); + } + include('includes/footer.inc'); + exit; + } + if (DB_num_rows($LabelsResult)==0){ + prnMsg(_('There were no price labels to print out for the category specified'),'warn'); + echo '<br /><a href="'.htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'. _('Back').'</a>'; + include('includes/footer.inc'); + exit; + } + + + echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<table class="selection"> + <tr> + <th>' . _('Item Code') . '</th> + <th>' . _('Item Description') . '</th> + <th>' . _('Price') . '</th> + <th>' . _('Print') . ' ?</th> + </tr>'; + $i=0; + while ($LabelRow = DB_fetch_array($LabelsResult)){ + echo '<tr> + <td>' . $LabelRow['stockid'] . '</td> + <td>' . $LabelRow['description'] . '</td> + <td class="number">' . locale_number_format($LabelRow['price'],$LabelRow['decimalplaces']) . '</td> + <td><input type="checkbox" checked="checked" name="PrintLabel' . $i .'" /></td> + </tr>'; + echo '<input type="hidden" name="StockID' . $i . '" value="' . $LabelRow['stockid'] . '" /> + <input type="hidden" name="Description' . $i . '" value="' . $LabelRow['description'] . '" /> + <input type="hidden" name="Barcode' . $i . '" value="' . $LabelRow['barcode'] . '" /> + <input type="hidden" name="Price' . $i . '" value="' . locale_number_format($LabelRow['price'],$LabelRow['decimalplaces']) . '" />'; + $i++; + } + $i--; + echo '</table> + <input type="hidden" name="NoOfLabels" value="' . $i . '" /> + <input type="hidden" name="LabelID" value="' . $_POST['LabelID'] . '" /> + <br /> + <div class="centre"> + <input type="submit" name="PrintLabels" value="'. _('Print Labels'). '" /> + </div> + </form>'; + exit; +} +if (isset($_POST['PrintLabels']) + AND isset($_POST['NoOfLabels'])) { + $result = DB_query("SELECT papersize, description, width*" . $PtsPerMM . " as label_width, @@ -56,51 +139,6 @@ $i++; } - $SQL = "SELECT prices.stockid, - stockmaster.description, - stockmaster.barcode, - prices.price, - currencies.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - INNER JOIN prices - ON stockmaster.stockid=prices.stockid - INNER JOIN currencies - ON prices.currabrev=currencies.currabrev - WHERE stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' - AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' - AND prices.typeabbrev='" . $_POST['SalesType'] . "' - AND prices.currabrev='" . $_POST['Currency'] . "' - AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' - AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') - AND prices.debtorno='' - ORDER BY prices.currabrev, - stockmaster.categoryid, - stockmaster.stockid, - prices.startdate"; - - $LabelsResult = DB_query($SQL,$db,'','',false,false); - - if (DB_error_no($db) !=0) { - $title = _('Price Label') . ' - ' . _('Problem Report....'); - include('includes/header.inc'); - prnMsg( _('The Price Labels could not be retrieved by the SQL because'). ' - ' . DB_error_msg($db), 'error'); - echo '<br /><a href="' .$rootpath .'/index.php">'. _('Back to the menu'). '</a>'; - if ($debug==1){ - prnMsg(_('For debugging purposes the SQL used was:') . $SQL,'error'); - } - include('includes/footer.inc'); - exit; - } - if (DB_num_rows($LabelsResult)==0){ - $title = _('Print Price Labels Error'); - include('includes/header.inc'); - prnMsg(_('There were no price labels to print out for the category specified'),'warn'); - echo '<br /><a href="'.htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'. _('Back').'</a>'; - include('includes/footer.inc'); - exit; - } - $style = array( 'position' => '', 'align' => 'C', @@ -121,46 +159,59 @@ //go down first then accross $YPos = $Page_Height - $Top_Margin; //top of current label $XPos = $Left_Margin; // left of current label - - while ($PriceLabels = DB_fetch_array($LabelsResult,$db)){ - foreach ($LabelFields as $Field){ - if ($Field['FieldValue'] == 'price'){ //need to format for the number of decimal places - $LeftOvers = $pdf->addTextWrap($XPos+$Field['HPos'],$YPos-$LabelDimensions['label_height']+$Field['VPos'],$LabelDimensions['label_width']-$Field['HPos'],$Field['FontSize'],locale_number_format($PriceLabels['price'],$PriceLabels['decimalplaces']),'right'); - } elseif($Field['Barcode']==1) { + + for ($i=0;$i <= $_POST['NoOfLabels'];$i++){ + if ($_POST['PrintLabel'.$i]=='on'){ + + if ($Field['FieldValue']== 'price'){ + $Value = $_POST['Price' . $i]; + } elseif ($Field['FieldValue']== 'stockid'){ + $Value = $_POST['StockID' . $i]; + } elseif ($Field['FieldValue']== 'description'){ + $Value = $_POST['Description' . $i]; + } elseif ($Field['FieldValue']== 'barcode'){ + $Value = $_POST['Barcode' . $i]; + } + foreach ($LabelFields as $Field){ - /* write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style='', $align='') - * Note that the YPos for this function is based on the opposite origin for the Y axis i.e from the bottom not from the top! + if ($Field['FieldValue'] == 'price'){ //need to format for the number of decimal places + $LeftOvers = $pdf->addTextWrap($XPos+$Field['HPos'],$YPos-$LabelDimensions['label_height']+$Field['VPos'],$LabelDimensions['label_width']-$Field['HPos'],$Field['FontSize'],$_POST['Price' . $i],'center'); + } elseif($Field['Barcode']==1) { + + /* write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style='', $align='') + * Note that the YPos for this function is based on the opposite origin for the Y axis i.e from the bottom not from the top! + */ + + $pdf->write1DBarcode(str_replace('_','',$Value), 'C128',$XPos+$Field['HPos'],$Page_Height - $YPos+$LabelDimensions['label_height']-$Field['VPos']-$Field['FontSize'],$LabelDimensions['label_width']-$Field['HPos'], $Field['FontSize'], 0.4, $style, 'N'); + } else { + $LeftOvers = $pdf->addTextWrap($XPos+$Field['HPos'],$YPos-$LabelDimensions['label_height']+$Field['VPos'],$LabelDimensions['label_width']-$Field['HPos']-20,$Field['FontSize'],$Value); + } + } // end loop through label fields + //setup $YPos and $XPos for the next label + if (($YPos - $LabelDimensions['label_rowheight']) < $LabelDimensions['label_height']){ + /* not enough space below the above label to print a new label + * so the above was the last label in the column + * need to start either a new column or new page */ - - $pdf->write1DBarcode(str_replace('_','',$PriceLabels[$Field['FieldValue']]), 'C128',$XPos+$Field['HPos'],$Page_Height - $YPos+$LabelDimensions['label_height']-$Field['VPos']-$Field['FontSize'],$LabelDimensions['label_width']-$Field['HPos'], $Field['FontSize'], 0.4, $style, 'N'); + if (($Page_Width - $XPos - $LabelDimensions['label_columnwidth']) < $LabelDimensions['label_width']) { + /* Not enough space to start a new column so we are into a new page + */ + $pdf->newPage(); + $PageNumber++; + $YPos = $Page_Height - $Top_Margin; //top of next label + $XPos = $Left_Margin; // left of next label + } else { + /* There is enough space for another column */ + $YPos = $Page_Height - $Top_Margin; //back to the top of next label column + $XPos += $LabelDimensions['label_columnwidth']; // left of next label + } } else { - $LeftOvers = $pdf->addTextWrap($XPos+$Field['HPos'],$YPos-$LabelDimensions['label_height']+$Field['VPos'],$LabelDimensions['label_width']-$Field['HPos'],$Field['FontSize'],$PriceLabels[$Field['FieldValue']]); - } - } // end loop through label fields - //setup $YPos and $XPos for the next label - if (($YPos - $LabelDimensions['label_rowheight']) < $LabelDimensions['label_height']){ - /* not enough space below the above label to print a new label - * so the above was the last label in the column - * need to start either a new column or new page - */ - if (($Page_Width - $XPos - $LabelDimensions['label_columnwidth']) < $LabelDimensions['label_width']) { - /* Not enough space to start a new column so we are into a new page + /* There is space below to print a label */ - $pdf->newPage(); - $PageNumber++; - $YPos = $Page_Height - $Top_Margin; //top of next label - $XPos = $Left_Margin; // left of next label - } else { - /* There is enough space for another column */ - $YPos = $Page_Height - $Top_Margin; //back to the top of next label column - $XPos += $LabelDimensions['label_columnwidth']; // left of next label - } - } else { - /* There is space below to print a label - */ - $YPos -= $LabelDimensions['label_rowheight']; //Top of next label - } - } + $YPos -= $LabelDimensions['label_rowheight']; //Top of next label + } + } //this label is set to print + } //loop through labels selected to print $FileName=$_SESSION['DatabaseName']. '_' . _('Price_Labels') . '_' . date('Y-m-d').'.pdf'; @@ -249,12 +300,13 @@ echo '</table> <br /> <div class="centre"> - <input type="submit" name="PrintPDF" value="'. _('Print PDF'). '" /> + <input type="submit" name="ShowLabels" value="'. _('Show Labels'). '" /> </div> - </form>'; + </form>'; + } include('includes/footer.inc'); } /*end of else not PrintPDF */ -?> +?> \ No newline at end of file Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2012-04-26 09:23:58 UTC (rev 5286) +++ trunk/UpgradeDatabase.php 2012-04-26 10:48:00 UTC (rev 5287) @@ -136,6 +136,11 @@ case '4.07': case '4.07.0': case '4.07.1': + case '4.07.2': + case '4.07.3': + case '4.07.4': + case '4.07.5': + case '4.07.6': $SQLScripts[] = './sql/mysql/upgrade4.07-4.08.sql'; case '4.08.0': break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |