-
Notifications
You must be signed in to change notification settings - Fork 3
/
PaymentAllocations.php
109 lines (88 loc) · 3.19 KB
/
PaymentAllocations.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
<?php
/* $Id$*/
/* $Revision: 1.6 $ */
/*
This page is called from SupplierInquiry.php when the 'view payments' button is selected
*/
include('includes/session.inc');
$title = _('Payment Allocations');
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
if (!isset($_GET['SuppID'])){
prnMsg( _('Supplier ID Number is not Set, can not display result'),'warn');
include('includes/footer.inc');
exit;
}
if (!isset($_GET['InvID'])){
prnMsg( _('Invoice Number is not Set, can not display result'),'warn');
include('includes/footer.inc');
exit;
}
$SuppID = $_GET['SuppID'];
$InvID = $_GET['InvID'];
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Payments') . '" alt="" />' . ' ' . _('Payment Allocation for Supplier') . ': ' . $SuppID . _(' and') . ' ' . _('Invoice') . ': ' . $InvID . '</p>';
echo '<div class="page_help_text">' . _('This shows how the payment to the supplier was allocated') . '<a href="SupplierInquiry.php?&SupplierID=' . $SuppID . '"><br /> ' . _('Back to supplier inquiry') . '</a></div><br />';
//echo "<br /><font size="4" color=BLUE>Payment Allocation for Supplier: '$SuppID' and Invoice: '$InvID'</font>";
// $_SESSION['SuppID'] = new SupplierID;
// $_SESSION['InvID'] = new InvoiceID;
$SQL= "SELECT supptrans.supplierno,
supptrans.suppreference,
supptrans.trandate,
supptrans.alloc,
suppliers.currcode
FROM supptrans
LEFT JOIN suppliers
ON supptrans.supplierno=suppliers.supplierid
WHERE supptrans.id IN (SELECT suppallocs.transid_allocfrom
FROM supptrans, suppallocs
WHERE supptrans.supplierno = '".$SuppID."'
AND supptrans.suppreference = '".$InvID."'
AND supptrans.id = suppallocs.transid_allocto)";
/*
Might be a way of doing this query without a subquery
$SQL= "SELECT supptrans.supplierno,
supptrans.suppreference,
supptrans.trandate,
supptrans.alloc
FROM supptrans INNER JOIN suppallocs ON supptrans.id=suppallocs.transid_allocfrom
WHERE supptrans.supplierno = '$SuppID'
AND supptrans.suppreference = '$InvID'
*/
$Result = DB_query($SQL, $db);
if (DB_num_rows($Result) == 0){
prnMsg(_('There may be a problem retrieving the information. No data is returned'),'warn');
echo '<br /><a HREF ="javascript:history.back()">' . _('Go back') . '</a>';
include('includes/foooter.inc');
exit;
}
echo '<table cellpadding="2" width="80%" class="selection">';
$TableHeader = '<tr>
<th>' . _('Supplier Number') . '<br />' . _('Reference') . '</th>
<th>' . _('Payment') .'<br />' . _('Reference') . '</th>
<th>' . _('Payment') . '<br />' . _('Date') . '</th>
<th>' . _('Total Payment') . '<br />' . _('Amount') . '</th></tr>';
echo $TableHeader;
$j=1;
$k=0; //row colour counter
while ($myrow = DB_fetch_array($Result)) {
if ($k == 1){
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
echo '<tr class="OddTableRows">';
$k++;
}
echo '<td>'.$myrow['supplierno'].'</td>
<td>'.$myrow['suppreference'].'</td>
<td>'.ConvertSQLDate($myrow['trandate']).'</td>
<td class="number">'.locale_money_format($myrow['alloc'],$myrow['currcode']).'</td>
</tr>';
$j++;
if ($j == 18){
$j=1;
echo $TableHeader;
}
}
echo '</table>';
include('includes/footer.inc');
?>