-
Notifications
You must be signed in to change notification settings - Fork 3
/
CustWhereAlloc.php
149 lines (121 loc) · 4.61 KB
/
CustWhereAlloc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/* $Revision: 1.10 $ */
/* $Id$*/
include('includes/session.inc');
$title = _('Customer How Paid Inquiry');
include('includes/header.inc');
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Customer Where Allocated'). '" alt="" />' . $title . '</p>';
echo '<table class="selection" cellpadding="2"><tr>';
echo '<td>' . _('Type') . ':</td>
<td><select tabindex="1" name="TransType"> ';
$sql = "SELECT typeid, typename FROM systypes WHERE typeid = 10 OR typeid=12";
$resultTypes = DB_query($sql,$db);
while ($myrow=DB_fetch_array($resultTypes)){
if (isset($_POST['TransType'])){
if ($myrow['typeid'] == $_POST['TransType']){
echo '<option selected="True" value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
} else {
echo '<option value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
}
} else {
echo '<option value="' . $myrow['typeid'] . '">' . $myrow['typename'] . '</option>';
}
}
echo '</select></td>';
if (!isset($_POST['TransNo'])) {$_POST['TransNo']='';}
echo '<td>'._('Transaction Number') . ':</td>
<td><input tabindex="2" type="text" name="TransNo" maxlength="10" size="10" value="'. $_POST['TransNo'] . '" /></td>';
echo '</tr></table><br />
<div class="centre"><button tabindex="3" type="submit" name="ShowResults">'._('Show How Allocated').'</button></div><br />';
if (isset($_POST['ShowResults']) AND $_POST['TransNo']==''){
echo '<br />';
prnMsg(_('The transaction number to be queried must be entered first'),'warn');
}
if (isset($_POST['ShowResults']) AND $_POST['TransNo']!=''){
/*First off get the DebtorTransID of the transaction (invoice normally) selected */
$sql = "SELECT id,
debtorsmaster.currcode,
ovamount+ovgst AS totamt
FROM debtortrans
LEFT JOIN debtorsmaster
ON debtortrans.debtorno=debtorsmaster.debtorno
WHERE type='" . $_POST['TransType'] . "' AND transno = '" . $_POST['TransNo']."'";
$result = DB_query($sql , $db);
if (DB_num_rows($result)==1){
$myrow = DB_fetch_array($result);
$AllocToID = $myrow['id'];
$sql = "SELECT type,
transno,
trandate,
debtortrans.debtorno,
debtorsmaster.currcode,
reference,
rate,
ovamount+ovgst+ovfreight+ovdiscount as totalamt,
custallocns.amt
FROM debtortrans
INNER JOIN custallocns
ON debtortrans.id=custallocns.transid_allocfrom
LEFT JOIN debtorsmaster
ON debtortrans.debtorno=debtorsmaster.debtorno
WHERE custallocns.transid_allocto='". $AllocToID."'";
$ErrMsg = _('The customer transactions for the selected criteria could not be retrieved because');
$TransResult = DB_query($sql, $db, $ErrMsg);
if (DB_num_rows($TransResult)==0){
prnMsg(_('There are no allocations made against this transaction'),'info');
} else {
echo '<br /><table cellpadding="2" class="selection">';
echo '<tr><th colspan="6"><div class="centre"><font size="3" color="blue"><b>'._('Allocations made against invoice number') . ' ' . $_POST['TransNo']
. '<br />'._('Transaction Total').': '. locale_money_format($myrow['totamt'],$myrow['currcode']) . '</font></b></div></th></tr>';
$tableheader = '<tr>
<th>'._('Type').'</th>
<th>'._('Number').'</th>
<th>'._('Reference').'</th>
<th>'._('Ex Rate').'</th>
<th>'._('Amount').'</th>
<th>'._('Alloc').'</th>
</tr>';
echo $tableheader;
$RowCounter = 1;
$k = 0; //row colour counter
$AllocsTotal = 0;
while ($myrow=DB_fetch_array($TransResult)) {
if ($k==1){
echo '<tr class="EvenTableRows">';
$k=0;
} else {
echo '<tr class="OddTableRows">';
$k++;
}
if ($myrow['type']==11){
$TransType = _('Credit Note');
} else {
$TransType = _('Receipt');
}
echo '<td>'.$TransType.'</td>
<td>'.$myrow['transno'].'</td>
<td>'.$myrow['reference'].'</td>
<td>'.$myrow['rate'].'</td>
<td class="number">'.locale_money_format($myrow['totalamt'],$myrow['currcode']).'</td>
<td class="number">'.locale_money_format($myrow['amt'],$myrow['currcode']).'</td>
</tr>';
$RowCounter++;
if ($RowCounter == 12){
$RowCounter=1;
echo $tableheader;
}
//end of page full new headings if
$AllocsTotal +=$myrow['amt'];
}
//end of while loop
echo '<tr><td colspan="5" class="number">'._('Total allocated').'</td>
<td class="number">' . locale_money_format($AllocsTotal,$_SESSION['CompanyRecord']['currencydefault']) . '</td></tr>';
echo '</table>';
}
}
}
echo '</form>';
include('includes/footer.inc');
?>