/
list_advance.php
48 lines (38 loc) · 1.39 KB
/
list_advance.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
<?
# Show Profile shows all the Customer Info, Invoices, Payments, Tickets,
# and a balance.
require("accrp.php");
session_start();
require("security/secure.php");
beginDocument($lCustomerProfile, $sess_user);
$db = getDBConnection();
$desig_array = get_designation_array();
if (!isset($orderby)) $orderby="EMP_ID3";
# calculate received money by Employees
$result = mysql_query("select SUM(AMOUNT),AC_ID5 from TRANS WHERE AC_ID3=30 AND DR_CR='C' GROUP BY AC_ID5 order by PARTY", $db);
checkMySQLError();
$receive_array=array();
while($row = mysql_fetch_array($result)) {
$receive_array[$row["AC_ID5"]] = $row["SUM(AMOUNT)"];
}
# calculate paid_back money
$result = mysql_query("select SUM(AMOUNT),PARTY, AC_ID5 from TRANS WHERE AC_ID3=30 AND DR_CR='D' GROUP BY PARTY order by PARTY", $db);
checkMySQLError();
while($row = mysql_fetch_array($result)) {
if(array_key_exists($row["AC_ID5"],$receive_array))
$receive_array[$row["AC_ID5"]] -= $row["SUM(AMOUNT)"];
}
beginPrettyTable("1", "Schedule of Advance as on ". get_today_hrd_string());
if (isSet($receive_array)) {
printRow(array("Code","Employer's name", "Amount"));
foreach ($receive_array as $key => $value) {
if ($value!=0)
printRow(array("$key", get_ac5_desc_of($key), 0-$value),"fluct");
$sum += 0-$value;
}
printRow(array("","Sum",$sum));
} else
printRow(array("No Advance-money at anybody!"),"");
endPrettyTable();
endDocument();
?>