- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / CustomerTransInquiry.php
blobdf06b3aecb3af9ec4da682534969e2fab960a108
1 <?php
3 /* $Revision: 1.12 $ */
5 $PageSecurity = 2;
7 include('includes/session.inc');
8 $title = _('Customer Transactions Inquiry');
9 include('includes/header.inc');
12 echo "<FORM ACTION='" . $_SERVER['PHP_SELF'] . "' METHOD=POST>";
14 echo '<CENTER><TABLE CELLPADDING=2><TR>';
16 echo '<TD>' . _('Type') . ":</TD><TD><SELECT name='TransType'> ";
18 $sql = 'SELECT typeid, typename FROM systypes WHERE typeid >= 10 AND typeid <= 14';
19 $resultTypes = DB_query($sql,$db);
21 echo "<OPTION Value='All'> All";
22 while ($myrow=DB_fetch_array($resultTypes)){
23 if (isset($_POST['TransType'])){
24 if ($myrow['typeid'] == $_POST['TransType']){
25 echo "<OPTION SELECTED Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
26 } else {
27 echo "<OPTION Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
29 } else {
30 echo "<OPTION Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
33 echo '</SELECT></TD>';
35 if (!isset($_POST['FromDate'])){
36 $_POST['FromDate']=Date($_SESSION['DefaultDateFormat'], mktime(0,0,0,Date('m'),1,Date('Y')));
38 if (!isset($_POST['ToDate'])){
39 $_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']);
41 echo '<TD>' . _('From') . ":</TD><TD><INPUT TYPE=TEXT NAME='FromDate' MAXLENGTH=10 SIZE=11 VALUE=" . $_POST['FromDate'] . '></TD>';
42 echo '<TD>' . _('To') . ":</TD><TD><INPUT TYPE=TEXT NAME='ToDate' MAXLENGTH=10 SIZE=11 VALUE=" . $_POST['ToDate'] . '></TD>';
44 echo "</TR></TABLE><INPUT TYPE=SUBMIT NAME='ShowResults' VALUE='" . _('Show Transactions') . "'>";
45 echo '<HR>';
47 echo '</FORM></CENTER>';
49 if (isset($_POST['ShowResults']) && $_POST['TransType'] != ''){
50 $SQL_FromDate = FormatDateForSQL($_POST['FromDate']);
51 $SQL_ToDate = FormatDateForSQL($_POST['ToDate']);
52 $sql = "SELECT transno,
53 trandate,
54 debtortrans.debtorno,
55 branchcode,
56 reference,
57 invtext,
58 order_,
59 rate,
60 ovamount+ovgst+ovfreight+ovdiscount as totalamt,
61 currcode,
62 typename
63 FROM debtortrans
64 INNER JOIN debtorsmaster ON debtortrans.debtorno=debtorsmaster.debtorno
65 INNER JOIN systypes ON debtortrans.type = systypes.typeid
66 WHERE ";
68 $sql = $sql . "trandate >='" . $SQL_FromDate . "' AND trandate <= '" . $SQL_ToDate . "'";
69 if ($_POST['TransType']!='All') {
70 $sql .= " AND type = " . $_POST['TransType'];
72 $sql .= " ORDER BY id";
74 $TransResult = DB_query($sql, $db,$ErrMsg,$DbgMsg);
75 $ErrMsg = _('The customer transactions for the selected criteria could not be retrieved because') . ' - ' . DB_error_msg($db);
76 $DbgMsg = _('The SQL that failed was');
78 echo '<TABLE CELLPADDING=2 BORDER=2>';
80 $tableheader = "<TR>
81 <TD class='tableheader'>" . _('Type') . "</TD>
82 <TD class='tableheader'>" . _('Number') . "</TD>
83 <TD class='tableheader'>" . _('Date') . "</TD>
84 <TD class='tableheader'>" . _('Customer') . "</TD>
85 <TD class='tableheader'>" . _('Branch') . "</TD>
86 <TD class='tableheader'>" . _('Reference') . "</TD>
87 <TD class='tableheader'>" . _('Comments') . "</TD>
88 <TD class='tableheader'>" . _('Order') . "</TD>
89 <TD class='tableheader'>" . _('Ex Rate') . "</TD>
90 <TD class='tableheader'>" . _('Amount') . "</TD>
91 <TD class='tableheader'>" . _('Currency') . '</TD></TR>';
92 echo $tableheader;
94 $RowCounter = 1;
95 $k = 0; //row colour counter
97 while ($myrow=DB_fetch_array($TransResult)) {
99 if ($k==1){
100 echo "<tr bgcolor='#CCCCCC'>";
101 $k=0;
102 } else {
103 echo "<tr bgcolor='#EEEEEE'>";
104 $k++;
107 $format_base = "<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 width='200'>%s</td>
114 <td>%s</td>
115 <td ALIGN=RIGHT>%s</td>
116 <td ALIGN=RIGHT>%s</td>
117 <td>%s</td>";
119 if ($_POST['TransType']==10){ /* invoices */
121 printf("$format_base
122 <td><a target='_blank' href='%s/PrintCustTrans.php?%&FromTransNo=%s&InvOrCredit=Invoice'><IMG SRC='%s' TITLE='" . _('Click to preview the invoice') . "'></a></td>
123 </tr>",
124 $myrow['typename'],
125 $myrow['transno'],
126 ConvertSQLDate($myrow['trandate']),
127 $myrow['debtorno'],
128 $myrow['branchcode'],
129 $myrow['reference'],
130 $myrow['invtext'],
131 $myrow['order_'],
132 $myrow['rate'],
133 number_format($myrow['totalamt'],2),
134 $myrow['currcode'],
135 $rootpath,
136 SID,
137 $myrow['transno'],
138 $rootpath.'/css/'.$theme.'/images/preview.gif');
139 } elseif ($_POST['TransType']==11){ /* credit notes */
140 printf("$format_base
141 <td><a target='_blank' href='%s/PrintCustTrans.php?%s&FromTransNo=%s&InvOrCredit=Credit'><IMG SRC='%s' TITLE='" . _('Click to preview the credit') . "'></a></td>
142 </tr>",
143 $myrow['typename'],
144 $myrow['transno'],
145 ConvertSQLDate($myrow['trandate']),
146 $myrow['debtorno'],
147 $myrow['branchcode'],
148 $myrow['reference'],
149 $myrow['invtext'],
150 $myrow['order_'],
151 $myrow['rate'],
152 number_format($myrow['totalamt'],2),
153 $myrow['currcode'],
154 $rootpath,
155 SID,
156 $myrow['transno'],
157 $rootpath.'/css/'.$theme.'/images/preview.gif');
158 } else { /* otherwise */
159 printf("$format_base</tr>",
160 $myrow['typename'],
161 $myrow['transno'],
162 ConvertSQLDate($myrow['trandate']),
163 $myrow['debtorno'],
164 $myrow['branchcode'],
165 $myrow['reference'],
166 $myrow['invtext'],
167 $myrow['order_'],
168 $myrow['rate'],
169 number_format($myrow['totalamt'],2),
170 $myrow['currcode']);
173 $RowCounter++;
174 If ($RowCounter == 12){
175 $RowCounter=1;
176 echo $tableheader;
178 //end of page full new headings if
180 //end of while loop
182 echo '</TABLE>';
185 include('includes/footer.inc');