[Weberp-svn] SF.net SVN: weberp:[4839] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-03-24 11:15:48
|
Revision: 4839 http://weberp.svn.sourceforge.net/weberp/?rev=4839&view=rev Author: tim_schofield Date: 2011-03-24 11:15:41 +0000 (Thu, 24 Mar 2011) Log Message: ----------- Phil: Corrections to Top Items report Modified Paths: -------------- trunk/PDFTopItems.php trunk/TopItems.php Modified: trunk/PDFTopItems.php =================================================================== --- trunk/PDFTopItems.php 2011-03-24 11:13:03 UTC (rev 4838) +++ trunk/PDFTopItems.php 2011-03-24 11:15:41 UTC (rev 4839) @@ -1,7 +1,7 @@ <?php /* $Revision: 1.2 $ */ -/* $Id$*/ -//$PageSecurity = 2; +/* $Id: PDFTopItems.php 4495 2011-02-22 09:45:01Z daintree $*/ + include ('includes/session.inc'); include ('includes/PDFStarter.php'); $FontSize = 10; @@ -10,79 +10,78 @@ $line_height = 12; include ('includes/PDFTopItemsHeader.inc'); $FontSize = 10; -$FromDate = FormatDateForSQL(DateAdd(Date($_SESSION['DefaultDateFormat']),'d', -$_POST['NumberOfDays'])); +$FromDate = FormatDateForSQL(DateAdd(Date($_SESSION['DefaultDateFormat']),'d', -$_GET['NumberOfDays'])); //the situation if the location and customer type selected "All" -if (($_GET["location"] == "All") and ($_GET["customers"] == "All")) { +if (($_GET['Location'] == 'All') and ($_GET['Customers'] == 'All')) { $SQL = "SELECT salesorderdetails.stkcode, - SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, - SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, + SUM(salesorderdetails.qtyinvoiced) totalinvoiced, + SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS valuesales, stockmaster.description, stockmaster.units FROM salesorderdetails, salesorders, debtorsmaster,stockmaster WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno - AND salesorderdetails.ActualDispatchDate >='" . $FromDate . "' + AND salesorderdetails.actualdispatchdate >='" . $FromDate . "' GROUP BY salesorderdetails.stkcode - ORDER BY '" . $_GET['order'] . "' DESC - LIMIT 0," . $_GET['NumberOfTopItems'] . ""; + ORDER BY '" . $_GET['Sequence'] . "' DESC + LIMIT " . $_GET['NumberOfTopItems'] ; } else { //the situation if only location type selected "All" - if ($_GET["location"] == "All") { + if ($_GET['Location'] == 'All') { $SQL = "SELECT salesorderdetails.stkcode, - SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, - SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, + SUM(salesorderdetails.qtyinvoiced) totalinvoiced, + SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS valuesales, stockmaster.description, stockmaster.units FROM salesorderdetails, salesorders, debtorsmaster,stockmaster WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno - AND debtorsmaster.typeid = '" . $_GET["customers"] . "' - AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' + AND debtorsmaster.typeid = '" . $_GET['Customers'] . "' + AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' GROUP BY salesorderdetails.stkcode - ORDER BY '" . $_GET['order'] . "' DESC - LIMIT 0," . $_GET['NumberOfTopItems'] . ""; + ORDER BY '" . $_GET['Sequence'] . "' DESC + LIMIT " . $_GET['NumberOfTopItems']; } else { //the situation if the customer type selected "All" - if ($_GET["customers"] == "All") { - $SQL = " - SELECT salesorderdetails.stkcode, - SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, - SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, + if ($_GET['Customers'] == 'All') { + $SQL = "SELECT salesorderdetails.stkcode, + SUM(salesorderdetails.qtyinvoiced) totalinvoiced, + SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS valuesales, stockmaster.description, stockmaster.units FROM salesorderdetails, salesorders, debtorsmaster,stockmaster WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno - AND salesorders.fromstkloc = '" . $_GET['location'] . "' - AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' + AND salesorders.fromstkloc = '" . $_GET['Location'] . "' + AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' GROUP BY salesorderdetails.stkcode - ORDER BY '" . $_GET['order'] . "' DESC - LIMIT 0," . $_GET['NumberOfTopItems'] . ""; + ORDER BY '" . $_GET['Sequence'] . "' DESC + LIMIT 0," . $_GET['NumberOfTopItems']; } else { //the situation if the location and customer type not selected "All" - $SQL = " - SELECT salesorderdetails.stkcode, - SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, - SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, + $SQL = "SELECT salesorderdetails.stkcode, + SUM(salesorderdetails.qtyinvoiced) totalinvoiced, + SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS valuesales, stockmaster.description, stockmaster.units FROM salesorderdetails, salesorders, debtorsmaster,stockmaster WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno - AND salesorders.fromstkloc = '" . $_GET['location'] . "' - AND debtorsmaster.typeid = '" . $_GET['customers'] . "' - AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' + AND salesorders.fromstkloc = '" . $_GET['Location'] . "' + AND debtorsmaster.typeid = '" . $_GET['Customers'] . "' + AND salesorderdetails.actualdispatchdate >= '" . $FromDate . "' GROUP BY salesorderdetails.stkcode - ORDER BY '" . $_GET['order'] . "' DESC - LIMIT 0," . $_GET['NumberOfTopItems'] . ""; + ORDER BY '" . $_GET['Sequence'] . "' DESC + LIMIT " . $_GET['NumberOfTopItems']; } } } $result = DB_query($SQL, $db); + $YPos = $YPos - 6; while ($myrow = DB_fetch_array($result)) { //find the quantity onhand item @@ -91,18 +90,12 @@ WHERE stockid='" . $myrow['0'] . "'"; $oh = db_query($sqloh, $db); $ohRow = db_fetch_row($oh); - $OnHand = $ohRow[0]; - $ValueSales = number_format($myrow['2'], 2); - $Code = $myrow['0']; //stkcode - $Desc = $myrow['3']; //desc - $TotalInvoice = $myrow['1']; //total invoice here - $Unit = $myrow['4']; //unit - $LeftOvers = $pdf->addTextWrap($Left_Margin + 1, $YPos, 300 - $Left_Margin, $FontSize, $Code); - $LeftOvers = $pdf->addTextWrap($Left_Margin + 100, $YPos, 270 - $Left_Margin, $FontSize, $Desc); - $LeftOvers = $pdf->addTextWrap($Left_Margin + 330, $YPos, 30, $FontSize, $TotalInvoice, 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin + 370, $YPos, 300 - $Left_Margin, $FontSize, $Unit, 'left'); - $LeftOvers = $pdf->addTextWrap($Left_Margin + 400, $YPos, 70, $FontSize, $ValueSales, 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin + 490, $YPos, 30, $FontSize, $OnHand, 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 1, $YPos, 300 - $Left_Margin, $FontSize, $myrow['stkcode']); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 100, $YPos, 270 - $Left_Margin, $FontSize, $myrow['description']); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 330, $YPos, 30, $FontSize, $myrow['totalinvoiced'], 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 370, $YPos, 300 - $Left_Margin, $FontSize, $myrow['units'], 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 400, $YPos, 70, $FontSize, number_format($myrow['valuesales'], 2), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin + 490, $YPos, 30, $FontSize, $ohRow[0], 'right'); if (strlen($LeftOvers) > 1) { $LeftOvers = $pdf->addTextWrap($Left_Margin + 1 + 94, $YPos - $line_height, 270, $FontSize, $LeftOvers, 'left'); $YPos-= $line_height; @@ -122,7 +115,7 @@ $title = _('Print Price List Error'); include ('includes/header.inc'); prnMsg(_('There were no records returned '), 'warn'); - echo '<br><a href="' . $rootpath . '/index.php?' . SID . '">' . _('Back to the menu') . '</a>'; + echo '<br><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; include ('includes/footer.inc'); exit; } else { Modified: trunk/TopItems.php =================================================================== --- trunk/TopItems.php 2011-03-24 11:13:03 UTC (rev 4838) +++ trunk/TopItems.php 2011-03-24 11:15:41 UTC (rev 4839) @@ -7,41 +7,41 @@ $title = _('Top Items Searching'); include ('includes/header.inc'); //check if input already -if (!isset($_POST['search'])) { - +if (!(isset($_POST['Search']))) { + echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Top Sales Order Search') . '" alt="" />' . ' ' . _('Top Sales Order Search') . '</p>'; echo "<form action=" . $_SERVER['PHP_SELF'] . '?' . SID . ' name="SelectCustomer" method=POST>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table cellpadding=3 colspan=4 class=selection>'; //to view store location echo '<tr><td width="150">' . _('Select Location') . ' </td><td>:</td><td><select name=Location>'; - $sql = "SELECT loccode, + $sql = 'SELECT loccode, locationname - FROM `locations`"; + FROM `locations`'; $result = DB_query($sql, $db); - echo "<option value='All'>" . _('All'); + echo '<option value="All">' . _('All') . '</option>'; while ($myrow = DB_fetch_array($result)) { - echo "<option VALUE='" . $myrow['loccode'] . "'>" . $myrow['loccode'] . " - " . $myrow['locationname']; + echo "<option VALUE='" . $myrow['loccode'] . "'>" . $myrow['loccode'] . " - " . $myrow['locationname'] . '</option>'; } - echo "</select></td></tr>"; + echo '</select></td></tr>'; //to view list of customer echo '<tr><td width="150">' . _('Select Customer Type') . ' </td><td>:</td><td><select name=Customers>'; - $sql = "SELECT typename, + $sql = 'SELECT typename, typeid - FROM debtortype"; + FROM debtortype'; $result = DB_query($sql, $db); - echo "<option value='All'>" . _('All'); + echo "<option value='All'>" . _('All') . '</option>'; while ($myrow = DB_fetch_array($result)) { - echo "<option VALUE='" . $myrow['typeid'] . "'>" . $myrow['typename']; + echo "<option VALUE='" . $myrow['typeid'] . "'>" . $myrow['typename'] . '</option>'; } - echo "</select></td> - </tr>"; + echo '</select></td> + </tr>'; //view order by list to display echo '<tr> <td width="150">' . _('Select Order By ') . ' </td> <td>:</td> - <td><select name=Sequence>'; - echo ' <option value=TotalInvoiced>' . _('Total Pieces') . ''; - echo ' <option value=ValueSales>' . _('Value of Sales') . ''; + <td><select name="Sequence">'; + echo ' <option value="TotalInvoiced">' . _('Total Pieces') . ''; + echo ' <option value="ValueSales">' . _('Value of Sales') . ''; echo ' </select></td> </tr>'; //View number of days @@ -57,14 +57,16 @@ <td></td> <td></td> </tr> - </form></table>'; - echo '<br /><div class=centre><input tabindex=5 name="search" type=submit value="' . _('Search') . '"></div>'; + </table> + <br /><div class=centre> + <input tabindex=5 type=submit name="Search" value="' . _('Search') . '"> + </div></form>'; } else { // everything below here to view NumberOfTopItems items sale on selected location $FromDate = FormatDateForSQL(DateAdd(Date($_SESSION['DefaultDateFormat']),'d', -$_POST['NumberOfDays'])); //the situation if the location and customer type selected "All" if (($_POST['Location'] == 'All') and ($_POST['Customers'] == 'All')) { - + $SQL = "SELECT salesorderdetails.stkcode, SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, @@ -78,7 +80,7 @@ AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno AND debtorsmaster.currcode = currencies.currabrev - AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' + AND salesorderdetails.ActualDispatchDate >= '" . $FromDate . "' GROUP BY salesorderdetails.stkcode ORDER BY " . $_POST['Sequence'] . " DESC LIMIT " . $_POST['NumberOfTopItems'] . ""; @@ -149,31 +151,32 @@ } } $result = DB_query($SQL, $db); + echo '<p class="page_title_text" align="center"><strong>' . _('Top Sales Items List') . '</strong></p>'; - echo "<form action=PDFTopItems.php method='GET'><table class='selection'>"; + echo '<form action="PDFTopItems.php" method="GET"><table class="selection">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - $TableHeader = '<tr><th><strong>' . _('#') . '</strong></th> - <th><strong>' . _('Code') . '</strong></th> - <th><strong>' . _('Description') . '</strong></th> - <th><strong>' . _('Total Invoiced') . '</strong></th> - <th><strong>' . _('Units') . '</strong></th> - <th><strong>' . _('Value Sales') . '</strong></th> - <th><strong>' . _('On Hand') . '</strong></th>'; + $TableHeader = '<tr><th>' . _('#') . '</th> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Total Invoiced') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Value Sales') . '</th> + <th>' . _('On Hand') . '</th>'; echo $TableHeader; echo ' - <input type="hidden" value=' . $_POST['Location'] . ' name=location /> - <input type="hidden" value=' . $_POST['Sequence'] . ' name=Sequence /> - <input type="hidden" value=' . $_POST['NumberOfDays'] . ' name=numberofdays /> - <input type="hidden" value=' . $_POST['Customers'] . ' name=customers /> - <input type="hidden" value=' . $_POST['NumberOfTopItems'] . ' name=NumberOfTopItems /> + <input type="hidden" value=' . $_POST['Location'] . ' name="Location" /> + <input type="hidden" value=' . $_POST['Sequence'] . ' name="Sequence" /> + <input type="hidden" value=' . $_POST['NumberOfDays'] . ' name="NumberOfDays" /> + <input type="hidden" value=' . $_POST['Customers'] . ' name="Customers" /> + <input type="hidden" value=' . $_POST['NumberOfTopItems'] . ' name="NumberOfTopItems" /> '; $k = 0; //row colour counter $i = 1; while ($myrow = DB_fetch_array($result)) { //find the quantity onhand item $sqloh = "SELECT sum(quantity)as qty - FROM `locstock` - WHERE stockid='" . $myrow['0'] . "'"; + FROM `locstock` + WHERE stockid='" . $myrow['0'] . "'"; $oh = db_query($sqloh, $db); $ohRow = db_fetch_row($oh); if ($k == 1) { @@ -190,19 +193,20 @@ <td>%s</td> <td class="number">%s</td> <td class="number">%s</td> - </tr>', $i, $myrow['0'], $myrow['3'], $myrow['1'], //total invoice here - $myrow['4'], //unit - number_format($myrow['2']/$myrow['5'],2), //value sales here - number_format($ohRow[0], $myrow['7']) //on hand - ); - $i+= 1; + </tr>', + $i, + $myrow['0'], + $myrow['3'], + $myrow['1'], //total invoice here + $myrow['4'], //unit + number_format($myrow['2']/$myrow['5'],2), //value sales here + number_format($ohRow[0], $myrow['7']) //on hand + ); + $i++; } echo '</table>'; - // echo '<td style="text-align:center" colspan=6><a href="javascript:history.go(-1)" title="Return to previous page"><input type=Button Name="Back" Value="' . _('Back') . '"></a></font>   '; echo '<br /><div class="centre"><input type=Submit Name="PrintPDF" Value="' . _('Print To PDF') . '"></div>'; echo '</form>'; - //end of the else statement - } include ('includes/footer.inc'); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |