- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / SelectRecurringSalesOrder.php
blobac9afbac08fa4bff48be25d0975143d65b8abce4
1 <?php
2 /* $Revision: 1.3 $ */
3 $PageSecurity = 2;
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'];
21 } else {
22 echo "<OPTION Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
24 } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){
25 echo "<OPTION SELECTED Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
26 } else {
27 echo "<OPTION Value='" . $myrow['loccode'] . "'>" . $myrow['locationname'];
31 echo '</SELECT>&nbsp&nbsp';
33 echo "<INPUT TYPE=SUBMIT NAME='SearchRecurringOrders' VALUE='" . _('Search Recurring Orders') . "'>";
35 echo '<HR>';
37 if (isset($_POST['SearchRecurringOrders'])){
39 $SQL = "SELECT recurringsalesorders.recurrorderno,
40 debtorsmaster.name,
41 custbranch.brname,
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,
51 debtorsmaster,
52 custbranch
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,
59 debtorsmaster.name,
60 custbranch.brname,
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%>';
75 $tableheader = "<TR>
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>
84 </TR>";
86 echo $tableheader;
88 $j = 1;
89 $k=0; //row colour counter
90 while ($myrow=DB_fetch_array($SalesOrdersResult)) {
93 if ($k==1){
94 echo "<tr bgcolor='#CCCCCC'>";
95 $k=0;
96 } else {
97 echo "<tr bgcolor='#EEEEEE'>";
98 $k++;
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>
107 <td>%s</td>
108 <td>%s</td>
109 <td>%s</td>
110 <td>%s</td>
111 <td>%s</td>
112 <td>%s</td>
113 <td ALIGN=RIGHT>%s</td>
114 </tr>",
115 $ModifyPage,
116 $myrow['recurrorderno'],
117 $myrow['name'],
118 $myrow['brname'],
119 $myrow['customerref'],
120 $FormatedLastRecurrence,
121 $FormatedStopDate,
122 $myrow['frequency'],
123 $FormatedOrderValue);
125 $j++;
126 If ($j == 12){
127 $j=1;
128 echo $tableheader;
130 //end of page full new headings if
132 //end of while loop
134 echo '</TABLE></FORM>';
137 include('includes/footer.inc');