- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / CustWhereAlloc.php
blob10a475f3c29b2f98abae9ffcef24edebf05abea8
1 <?php
2 /* $Revision: 1.7 $ */
3 $PageSecurity = 2;
5 include('includes/session.inc');
6 $title = _('Customer How Paid Inquiry');
7 include('includes/header.inc');
9 echo "<FORM ACTION='" . $_SERVER['PHP_SELF'] . "' METHOD=POST>";
11 echo '<CENTER><TABLE CELLPADDING=2><TR>';
13 echo '<TD>' . _('Type') . ":</TD><TD><SELECT name='TransType'> ";
15 $sql = 'SELECT typeid, typename FROM systypes WHERE typeid = 10 OR typeid=12';
16 $resultTypes = DB_query($sql,$db);
17 while ($myrow=DB_fetch_array($resultTypes)){
18 if (isset($_POST['TransType'])){
19 if ($myrow['typeid'] == $_POST['TransType']){
20 echo "<OPTION SELECTED Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
21 } else {
22 echo "<OPTION Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
24 } else {
25 echo "<OPTION Value='" . $myrow['typeid'] . "'>" . $myrow['typename'];
28 echo '</SELECT></TD>';
30 echo '<TD>'._('Transaction Number').":</TD>
31 <TD><INPUT TYPE=TEXT NAME='TransNo' MAXLENGTH=10 SIZE=10 VALUE=". $_POST['TransNo'] . '></TD>';
33 echo "</TR></TABLE>
34 <INPUT TYPE=SUBMIT NAME='ShowResults' VALUE="._('Show How Allocated').'>';
35 echo '<HR>';
37 if (isset($_POST['ShowResults']) AND $_POST['TransNo']==''){
38 prnMsg(_('The transaction number to be queried must be entered first'),'warn');
41 if (isset($_POST['ShowResults']) AND $_POST['TransNo']!=''){
44 /*First off get the DebtorTransID of the transaction (invoice normally) selected */
45 $sql = 'SELECT id,
46 ovamount+ovgst AS totamt
47 FROM debtortrans
48 WHERE type=' . $_POST['TransType'] . ' AND transno = ' . $_POST['TransNo'];
50 $result = DB_query($sql , $db);
52 if (DB_num_rows($result)==1){
53 $myrow = DB_fetch_array($result);
54 $AllocToID = $myrow['id'];
56 echo '<CENTER><FONT SIZE=3><B><BR>'._('Allocations made against invoice number') . ' ' . $_POST['TransNo'] . ' '._('Transaction Total').': '. number_format($myrow['totamt'],2) . '</FONT></B>';
58 $sql = "SELECT type,
59 transno,
60 trandate,
61 debtortrans.debtorno,
62 reference,
63 rate,
64 ovamount+ovgst+ovfreight+ovdiscount as totalamt,
65 custallocns.amt
66 FROM debtortrans
67 INNER JOIN custallocns ON debtortrans.id=custallocns.transid_allocfrom
68 WHERE custallocns.transid_allocto=". $AllocToID;
70 $ErrMsg = _('The customer transactions for the selected criteria could not be retrieved because');
72 $TransResult = DB_query($sql, $db, $ErrMsg);
74 if (DB_num_rows($TransResult)==0){
75 prnMsg(_('There are no allocations made against this transaction'),'info');
76 } else {
77 echo '<TABLE CELLPADDING=2 BORDER=2>';
79 $tableheader = "<TR><TD class='tableheader'>"._('Type')."</TD>
80 <TD class='tableheader'>"._('Number')."</TD>
81 <TD class='tableheader'>"._('Reference')."</TD>
82 <TD class='tableheader'>"._('Ex Rate')."</TD>
83 <TD class='tableheader'>"._('Amount')."</TD>
84 <TD class='tableheader'>"._('Alloc').'</TD>
85 </TR>';
86 echo $tableheader;
88 $RowCounter = 1;
89 $k = 0; //row colour counter
90 $AllocsTotal = 0;
92 while ($myrow=DB_fetch_array($TransResult)) {
94 if ($k==1){
95 echo "<tr bgcolor='#CCCCCC'>";
96 $k=0;
97 } else {
98 echo "<tr bgcolor='#EEEEEE'>";
99 $k++;
102 if ($myrow['type']==11){
103 $TransType = _('Credit Note');
104 } else {
105 $TransType = _('Receipt');
107 printf( "<td>%s</td>
108 <td>%s</td>
109 <td>%s</td>
110 <td>%s</td>
111 <td ALIGN=RIGHT>%s</td>
112 <td ALIGN=RIGHT>%s</td>
113 </tr>",
114 $TransType,
115 $myrow['transno'],
116 $myrow['reference'],
117 $myrow['rate'],
118 $myrow['totalamt'],
119 $myrow['amt']);
121 $RowCounter++;
122 If ($RowCounter == 12){
123 $RowCounter=1;
124 echo $tableheader;
126 //end of page full new headings if
127 $AllocsTotal +=$myrow['amt'];
129 //end of while loop
130 echo '<TR><TD COLSPAN = 6 ALIGN=RIGHT>' . number_format($AllocsTotal,2) . '</TD></TR>';
131 echo '</TABLE>';
136 echo '</FORM></CENTER>';
137 include('includes/footer.inc');