-
Notifications
You must be signed in to change notification settings - Fork 1
/
moutcome.php
114 lines (94 loc) · 3.56 KB
/
moutcome.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
<?PHP
/*
| monthly Supplier report for Freelance accounting system
| Written by Ori Idan August 2009
*/
if(!isset($module)) {
header('Content-type: text/html;charset=UTF-8');
include('config.inc.php');
include('func.inc.php');
$link = mysql_connect($host, $user, $pswd) or die("Could not connect to host $host");
mysql_select_db($database) or die("Could not select database: $database");
$prefix = isset($_GET['prefix']) ? $_GET['prefix'] : $_COOKIE['prefix'];
$reptitle = "׳”׳•׳¦׳�׳•׳× ׳�׳₪׳™ ׳¡׳₪׳§ ׳•׳—׳•׳“׳©";
include('printhead.inc.php');
print $header;
}
else {
/* open window script */
print "<script type=\"text/javascript\">\n";
print "function PrintWin(url) {\n";
print "\twindow.open(url, 'width=800,height=600,scrollbar=yes');\n";
print "}\n";
print "</script>\n";
}
global $prefix, $accountstbl, $companiestbl, $transactionstbl, $tranreptbl;
$montharr = array('׳™׳ ׳•׳�׳¨', '׳₪׳‘׳¨׳•׳�׳¨', '׳�׳¨׳¥', '׳�׳₪׳¨׳™׳�', '׳�׳�׳™', '׳™׳•׳ ׳™', '׳™׳•׳�׳™', '׳�׳•׳’׳•׳¡׳˜',
'׳¡׳₪׳˜׳�׳‘׳¨', '׳�׳•׳§׳˜׳•׳‘׳¨', '׳ ׳•׳‘׳�׳‘׳¨', '׳“׳¦׳�׳‘׳¨');
if(!isset($prefix) || ($prefix == '')) {
print "<h1>׳�׳� ׳ ׳™׳×׳� ׳�׳‘׳¦׳¢ ׳₪׳¢׳•׳�׳” ׳–׳• ׳�׳�׳� ׳‘׳—׳™׳¨׳× ׳¢׳¡׳§</h1>\n";
return;
}
$filerep = isset($_GET['file']) ? $_GET['file'] : 0;
function GetLastDayOfMonth($month, $year) {
$last = 31;
if($month == 0)
return $last;
while(!checkdate($month, $last, $year)) {
// print "$last-$month-$year<br>\n";
$last--;
}
return $last;
}
function GetAcctType($acct) {
global $prefix, $accountstbl;
$query = "SELECT type FROM $accountstbl WHERE num='$acct' AND prefix='$prefix'";
$result = DoQuery($query, "GetAcctType");
$line = mysql_fetch_array($result, MYSQL_NUM);
return $line[0];
}
function GetAccountSum($account, $begin, $end) {
global $transactionstbl, $prefix;
$query = "SELECT sum FROM $transactionstbl WHERE account='$acct' AND date>='$begin' AND date<='$end' AND prefix='$prefix'";
// print "query: $query<br>\n";
$result = DoQuery($query, "compass.php");
$total = 0.0;
while($line = mysql_fetch_array($result, MYSQL_NUM)) {
$t = $line[0];
if($t > 0)
$total += $t;
}
return $total;
}
$y = date("Y");
if(!isset($module)) {
$query = "SELECT companyname FROM $companiestbl WHERE prefix='$prefix'";
$result = DoQuery($query, "GetAccountName");
$line = mysql_fetch_array($result, MYSQL_NUM);
$str = $line[0];
print "<h1>$str</h1>\n";
}
print "<br><h1>׳”׳•׳¦׳�׳•׳× ׳�׳₪׳™ ׳—׳•׳“׳©</h1>\n";
if($filerep) {
$filename = "tmp/moutcome.cvs";
$fd = fopen($filename, "w");
foreach($montharr as $m)
fwrite($fd, ",\"$m\"");
fwrite($fd, ",׳¡׳”׳›\n");
}
else {
print "<table border=\"0\" style=\"margin-right:8px\"><tr class=\"tblhead\">\n";
print "<td style=\"width:8em\">׳¡׳¢׳™׳£ ׳”׳•׳¦׳�׳” </td>\n";
foreach($montharr as $m)
print "<td style=\"width:4em\">$m</td>\n";
print "<td>׳¡׳”\"׳›</td>\n";
print "</tr>\n";
}
$t = SUPPLIER;
$query = "SELECT num,company FROM $accountstbl WHERE prefix='$prefix' AND type='$t'";
$result = DoQuery($query, "moutcome.php");
$tp = 0;
$e = 0;
$sumarr = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {}
?>