-
Notifications
You must be signed in to change notification settings - Fork 1
/
igraph.php
92 lines (77 loc) · 2.45 KB
/
igraph.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
ן»¿<?PHP
/*
| Income graph for freelnace accounting.
| Written by Ori Idan, September 2009
*/
global $prefix, $accountstbl, $transactionstbl, $tranreptbl;
global $label, $data;
$label = array();
$data = array();
if(!isset($prefix) || ($prefix == '')) {
print "<h1>׳�׳� ׳ ׳™׳×׳� ׳�׳‘׳¦׳¢ ׳₪׳¢׳•׳�׳” ׳–׳• ׳�׳�׳� ׳‘׳—׳™׳¨׳× ׳¢׳¡׳§</h1>\n";
return;
}
if(!isset($begindmy)) {
$begindmy = isset($_GET['begin']) ? $_GET['begin'] : date("1-1-Y");
$enddmy = isset($_GET['end']) ? $_GET['end'] : date("d-m-Y");
}
if(!isset($type))
$type = INCOME;
if($type == INCOME)
$fname = "income.png";
else if($type == CUSTOMER)
$fname = "customers.png";
else if($type == OUTCOME)
$fname = "outcome.png";
else if($type == SUPPLIER)
$fname = "suppliers.png";
if(!function_exists('GetAcctTotal')) {
function GetAcctTotal($acct, $begin, $end) {
global $transactionstbl, $prefix;
if($begin != 0)
$query = "SELECT sum FROM $transactionstbl WHERE account='$acct' AND date>='$begin' AND date<='$end' AND prefix='$prefix'";
else
$query = "SELECT sum FROM $transactionstbl WHERE account='$acct' AND date<='$end' AND prefix='$prefix'";
// print "query: $query<br>\n";
$result = DoQuery($query, "igraph.php");
$total = 0.0;
while($line = mysql_fetch_array($result, MYSQL_NUM)) {
$total += $line[0];
}
return $total;
}
}
if(!function_exists('GetGroupData')) {
function GetGroupData($grp, $begin, $end) {
global $accountstbl, $prefix;
global $label, $data;
$query = "SELECT num,company FROM $accountstbl WHERE prefix='$prefix' AND type='$grp'";
$result = DoQuery($query, "compass.php");
$total = 0.0;
$i = 0;
while($line = mysql_fetch_array($result, MYSQL_NUM)) {
$num = $line[0];
$acct = $line[1];
// print "Get total for: $num, ";
$sub_total = GetAcctTotal($num, $begin, $end);
if($sub_total) {
if($sub_total < 0)
$sub_total *= -1.0;
$label[$i] = html_entity_decode($acct, ENT_QUOTES, "utf-8");
$data[$i] = $sub_total;
$i++;
}
// print "$sub_total<br>\n";
$total += $sub_total;
}
return $total;
}
}
$begin = FormatDate($begindmy, "dmy", "mysql");
$end = FormatDate($enddmy, "dmy", "mysql");
GetGroupData($type, $begin, $end);
// print_r($data);
// print "Creating graph...<br>\n";
include('chart.php');
// print "<img src=\"tmp/$fname\">\n";
?>