3 /* $Revision: 1.12 $ */
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'];
27 echo "<OPTION Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
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') . "'>";
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,
60 ovamount+ovgst+ovfreight+ovdiscount as totalamt,
64 INNER JOIN debtorsmaster ON debtortrans.debtorno=debtorsmaster.debtorno
65 INNER JOIN systypes ON debtortrans.type = systypes.typeid
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>';
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>';
95 $k = 0; //row colour counter
97 while ($myrow=DB_fetch_array($TransResult)) {
100 echo "<tr bgcolor='#CCCCCC'>";
103 echo "<tr bgcolor='#EEEEEE'>";
107 $format_base = "<td>%s</td>
113 <td width='200'>%s</td>
115 <td ALIGN=RIGHT>%s</td>
116 <td ALIGN=RIGHT>%s</td>
119 if ($_POST['TransType']==10){ /* invoices */
122 <td><a target='_blank' href='%s/PrintCustTrans.php?%&FromTransNo=%s&InvOrCredit=Invoice'><IMG SRC='%s' TITLE='" . _('Click to preview the invoice') . "'></a></td>
126 ConvertSQLDate($myrow['trandate']),
128 $myrow['branchcode'],
133 number_format($myrow['totalamt'],2),
138 $rootpath.'/css/'.$theme.'/images/preview.gif');
139 } elseif ($_POST['TransType']==11){ /* credit notes */
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>
145 ConvertSQLDate($myrow['trandate']),
147 $myrow['branchcode'],
152 number_format($myrow['totalamt'],2),
157 $rootpath.'/css/'.$theme.'/images/preview.gif');
158 } else { /* otherwise */
159 printf("$format_base</tr>",
162 ConvertSQLDate($myrow['trandate']),
164 $myrow['branchcode'],
169 number_format($myrow['totalamt'],2),
174 If ($RowCounter == 12){
178 //end of page full new headings if
185 include('includes/footer.inc');