5 include('includes/session.inc');
6 $title = _('Search Recurring Sales Orders');
7 include('includes/header.inc');
9 echo '<FORM ACTION=' . $_SERVER['PHP_SELF'] .'?' .SID
. ' METHOD=POST>';
11 echo _('Select recurring order templates for delivery from:') . ' ' . '<SELECT NAME="StockLocation">';
13 $sql = 'SELECT loccode, locationname FROM locations';
15 $resultStkLocs = DB_query($sql,$db);
17 while ($myrow=DB_fetch_array($resultStkLocs)){
18 if (isset($_POST['StockLocation'])){
19 if ($myrow['loccode'] == $_POST['StockLocation']){
20 echo "<OPTION SELECTED Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
22 echo "<OPTION Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
24 } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){
25 echo "<OPTION SELECTED Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
27 echo "<OPTION Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
31 echo '</SELECT>  ';
33 echo "<INPUT TYPE=SUBMIT NAME='SearchRecurringOrders' VALUE='" . _('Search Recurring Orders') . "'>";
37 if (isset($_POST['SearchRecurringOrders'])){
39 $SQL = "SELECT recurringsalesorders.recurrorderno,
42 recurringsalesorders.customerref,
43 recurringsalesorders.orddate,
44 recurringsalesorders.deliverto,
45 recurringsalesorders.lastrecurrence,
46 recurringsalesorders.stopdate,
47 recurringsalesorders.frequency,
48 SUM(recurrsalesorderdetails.unitprice*recurrsalesorderdetails.quantity*(1-recurrsalesorderdetails.discountpercent)) AS ordervalue
49 FROM recurringsalesorders,
50 recurrsalesorderdetails,
53 WHERE recurringsalesorders.recurrorderno = recurrsalesorderdetails.recurrorderno
54 AND recurringsalesorders.debtorno = debtorsmaster.debtorno
55 AND debtorsmaster.debtorno = custbranch.debtorno
56 AND recurringsalesorders.branchcode = custbranch.branchcode
57 AND recurringsalesorders.fromstkloc = '". $_POST['StockLocation'] . "'
58 GROUP BY recurringsalesorders.recurrorderno,
61 recurringsalesorders.customerref,
62 recurringsalesorders.orddate,
63 recurringsalesorders.deliverto,
64 recurringsalesorders.lastrecurrence,
65 recurringsalesorders.stopdate,
66 recurringsalesorders.frequency";
68 $ErrMsg = _('No recurring orders were returned by the SQL because');
69 $SalesOrdersResult = DB_query($SQL,$db,$ErrMsg);
71 /*show a table of the orders returned by the SQL */
73 echo '<TABLE CELLPADDING=2 COLSPAN=7 WIDTH=100%>';
76 <TD class='tableheader'>" . _('Modify') . "</TD>
77 <TD class='tableheader'>" . _('Customer') . "</TD>
78 <TD class='tableheader'>" . _('Branch') . "</TD>
79 <TD class='tableheader'>" . _('Cust Order') . " #</TD>
80 <TD class='tableheader'>" . _('Last Recurrence') . "</TD>
81 <TD class='tableheader'>" . _('End Date') . "</TD>
82 <TD class='tableheader'>" . _('Times p.a.') . "</TD>
83 <TD class='tableheader'>" . _('Order Total') . "</TD>
89 $k=0; //row colour counter
90 while ($myrow=DB_fetch_array($SalesOrdersResult)) {
94 echo "<tr bgcolor='#CCCCCC'>";
97 echo "<tr bgcolor='#EEEEEE'>";
101 $ModifyPage = $rootpath . "/RecurringSalesOrders.php?" . SID
. '&ModifyRecurringSalesOrder=' . $myrow['recurrorderno'];
102 $FormatedLastRecurrence = ConvertSQLDate($myrow['lastrecurrence']);
103 $FormatedStopDate = ConvertSQLDate($myrow['stopdate']);
104 $FormatedOrderValue = number_format($myrow['ordervalue'],2);
106 printf("<td><A HREF='%s'>%s</A></td>
113 <td ALIGN=RIGHT>%s</td>
116 $myrow['recurrorderno'],
119 $myrow['customerref'],
120 $FormatedLastRecurrence,
123 $FormatedOrderValue);
130 //end of page full new headings if
134 echo '</TABLE></FORM>';
137 include('includes/footer.inc');