-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtedit.php
More file actions
154 lines (147 loc) · 4.91 KB
/
tedit.php
File metadata and controls
154 lines (147 loc) · 4.91 KB
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
150
151
152
153
154
<?PHP
/*
| Edit trnasaction for Freelance accounting.
| Written by Ori Idan September 2009
*/
global $prefix, $accountstbl, $transactionstbl, $tranreptbl;
global $TranType;
$text='';
if(!isset($prefix) || ($prefix == '')) {
$l = _("This operation can not be executed without choosing a business first");
print "<h1>$l</h1>\n";
return;
}
function StoreNo($tnum) {
global $transactionstbl;
global $prefix;
$query = "SELECT * FROM $transactionstbl WHERE num='$tnum' AND prefix='$prefix'";
$result = DoQuery($query, 'storeno');
$tnum = 0;
print "<table dir=\"rtl\"><tr class=tblhead>\n";
$l = _("Account");
print "<td style=\"width:10em\">$l</td>\n";
$l = _("Debit");
print "<td style=\"width:4em\">$l</td>\n";
$l = _("Credit");
print "<td style=\"width:4em\">$l</td>\n";
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$account = $line['account'];
$refnum1 = $line['refnum1'];
$refnum2 = $line['refnum2'];
$sum = $line['sum'];
$details = $line['details'];
$account_str = GetAccountName($account);
print "<tr>\n";
print "<td>$account_str</td>\n";
$date = FormatDate($line['date'], "mysql", "dmy");
if($sum < 0) {
$sum *= -1.0;
$sumstr = number_format($sum);
print "<td> </td><td dir=\"ltr\" align=\"right\">$sumstr</td>\n";
}
else {
$sum *= -1.0;
$sumstr = number_format($sum);
print "<td>$sumstr</td><td> </td>\n";
}
print "</tr>\n";
$tnum = Transaction($tnum, STORENO, $account, $refnum1, $refnum2, $date, $details, $sum);
}
print "</table>\n";
$l = _("Storeno transaction registered");
print "<h1>$l</h1>\n";
// print "<h1>׳³ֳ—׳³ֲ ׳³ג€¢׳³ֲ¢׳³ֳ— ׳³ג€˜׳³ג„¢׳³ֻ�׳³ג€¢׳³ן¿½ ׳³ֲ ׳³ֲ¨׳³ֲ©׳³ן¿½׳³ג€� </h1>\n";
}
$dt = '';
$refnum1 = '';
$tnum = $_GET['num'];
$acct = $_GET['account'];
$begin = $_GET['begin'];
$end = $_GET['end'];
$step = isset($_GET['step']) ? $_GET['step'] : 0;
if($step == 1) {
if($_POST['storeno'])
StoreNo($tnum);
else {
$dtdmy = $_POST['date'];
$dt = FormatDate($dtdmy, "dmy", "mysql");
$refnum1 = $_POST['refnum1'];
$details = $_POST['details'];
$query = "UPDATE $transactionstbl SET date='$dt', refnum1='$refnum1', details='$details' ";
$query .= "WHERE num='$tnum' AND prefix='$prefix'";
DoQuery($query, 'tedit');
$l = _("Transaction updated");
$text.= "<br><h1>$l</h1>\n";
}
$url = "?module=acctdisp&account=$acct&begin=$begin&end=$end";
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=$url\">\n";
}
$query = "SELECT * FROM $transactionstbl WHERE num='$tnum' AND prefix='$prefix'";
$result = DoQuery($query, "tedit");
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if($dt == '') {
$dt = $line['date'];
$dtdmy = FormatDate($dt, "mysql", "dmy");
}
if($refnum1 == '')
$refnum1 = $line['refnum1'];
if($details == '')
$details == $line['details'];
$type = $line['type'];
$sum = $line['sum'];
$account = $line['account'];
if(($sum > 0) && ($account > 100))
$cacct = $account;
else if(($sum < 0) && ($account > 100))
$dacct = $account;
}
//print "<br>\n";
//print "<div class=\"righthalf1\">\n";
$l = _("Edit transaction");
$haeder=$l;
//print "<h3>$l</h3>\n";
$text.= "<table width=\"100%\">\n";
$text.= "<form name=\"tedit\" action=\"?module=tedit&num=$tnum&account=$acct&begin=$begin&end=$end&step=1\" method=\"post\">\n";
$text.= "<tr>\n";
$l = _("Transaction number");
$text.= "<td>$l: </td>\n";
$text.= "<td><b>$tnum</b></td>\n";
$text.= "</tr><tr>\n";
$l = _("Tran. type");
$text.= "<td>$l</td>\n";
$tstr = $TranType[$type];
$text.= "<td>$tstr</td>\n";
$text.= "</tr><tr>\n";
$l = _("Debit account");
$text.= "<td>$l: </td>\n";
$acctname = GetAccountName($dacct);
$text.= "<td>$acctname</td>\n";
$text.= "</tr><tr>\n";
$l = _("Credit account");
$text.= "<td>$l: </td>\n";
$acctname = GetAccountName($cacct);
$text.= "<td>$acctname</td>\n";
$text.= "</tr><tr>\n";
$l = _("Date");
$text.= "<td>$l: </td>\n";
$text.= "<td><input type=\"hidden\" name=\"date\" size=\"7\" value=\"$dtdmy\" readonly />\n";
$text.= "$dtdmy</td>\n";
$text.= "</tr><tr>\n";
$l = _("Ref. num");
$text.= "<td>$l: </td>\n";
$text.= "<td><input type=\"hidden\" name=\"refnum1\" value=\"$refnum1\" readonly />$refnum1</td>\n";
$text.= "</tr><tr>\n";
$l = _("Details");
$text.= "<td>$l: </td>\n";
$text.= "<td><input type=\"hidden\" name=\"details\" value=\"$details\" readonly />$details</td>\n";
$text.= "</tr><tr>\n";
$l = _("Storeno transaction");
$text.= "<td colspan=\"2\"><input type=\"checkbox\" name=\"storeno\">$l</td>\n";
$text.= "</tr><tr>\n";
$l = _("Submit");
$text.= "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$l\" class='btnaction' /></td>\n";
$text.= "</tr></table>\n";
$text.= "</form>\n";
//$text.= "</div>\n";
createForm($text, $haeder,'',600,'','',1,getHelp());
?>