-
Notifications
You must be signed in to change notification settings - Fork 1
/
receipts.php
234 lines (208 loc) · 7.09 KB
/
receipts.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?PHP
/*
| Receipts
| This module is part of Freelance accounting system
| Written for Shay Harel by Ori Idan helicon technologies Ltd.
*/
global $prefix, $accountstbl, $companiestbl, $supdocstbl;
global $paymenttype;
global $creditcompanies;
if(!isset($prefix) || ($prefix == '')) {
$text.= "<h1>לא ניתן לבצע פעולה זו ללא בחירת עסק</h1>\n";
return;
}
$query = "SELECT vat FROM $companiestbl WHERE prefix='$prefix'";
$result = DoQuery($query, "income.php");
$line = mysql_fetch_array($result, MYSQL_NUM);
$vat = $line[0];
$text='';
?>
<script type="text/javascript">
function TypeSelChange() {
var i = document.receipt.payment.selectedIndex;
if(i == 3) {
document.getElementById('crd').style.display = 'block';
}
else {
document.getElementById('crd').style.display = 'none';
}
}
function calcTotal() {
var notaxsum = document.receipt.notaxsum.value;
var tax = document.receipt.src_tax.value;
document.receipt.total.value = parseFloat(notaxsum) - parseFloat(tax);
}
</script>
<?PHP
/*
function PrintCustomerSelect($def) {
global $accountstbl;
global $prefix;
$t = CUSTOMER;
$query = "SELECT num,company FROM $accountstbl WHERE prefix='$prefix' AND type='$t' ORDER BY company ASC";
$result = DoQuery($query, "income.php");
$text.= "<select name=\"customer\">\n";
$text.= "<option value=\"__NULL__\">-- בחר לקוח --</option>\n";
while($line = mysql_fetch_array($result, MYSQL_NUM)) {
$n = $line[0];
$company = $line[1];
if($n == $def)
$text.= "<option value=\"$n\" selected>$company</option>\n";
else
$text.= "<option value=\"$n\">$company</option>\n";
}
$text.= "</select>\n";
}*/
function PrintPaymentSelect($def) {
global $paymenttype;
$str= "<select name=\"payment\" onchange=\"TypeSelChange()\">\n";
foreach($paymenttype as $n => $v) {
if($n == $def)
$str.= "<option value=\"$n\" selected>$v</option>\n";
else
$str.= "<option value=\"$n\">$v</option>\n";
}
$str.= "</select>\n";
return $str;
}
function PrintCreditSelect($def, $payment) {
global $creditcompanies;
if($payment == 3)
$str= "<select name=\"creditcomp\" id=\"crd\" style=\"display:block\">\n";
else
$str= "<select name=\"creditcomp\" id=\"crd\" style=\"display:none\">\n";
foreach($creditcompanies as $n => $v) {
if($n == $def)
$str.= "<option value=\"$n\" selected>$v</option>\n";
else
$str.= "<option value=\"$n\">$v</option>\n";
}
$str.= "</select>\n";
return $str;
}
$step = isset($_GET['step']) ? $_GET['step'] : 0;
if($step > 0) {
$customer = $_POST['customer'];
if($customer == "__NULL__") {
ErrorReport("לא נבחר לקוח");
return;
}
$refnum = $_POST['refnum'];
$details = $_POST['details'];
if(isset($_POST['date'])) {
$dtmysql = FormatDate($_POST['date'], "dmy", "mysql");
$dt = FormatDate($dtmysql, "mysql", "dmy");
}
else {
$dtmysel = date("Y-m-d");
$dt = FormatDate($dtmysql, "mysql", "dmy");
}
$payment = $_POST['payment'];
$creditcomp = $_POST['creditcomp'];
$ref2 = $_POST['refnum2'];
$notaxsum = $_POST['notaxsum'];
$tax = $_POST['tax'];
$sum = $notaxsum - $tax;
}
if($step == 2) {
if($name == 'demo') {
ErrorReport("<h1>משתמש דוגמה אינו רשאי לעדכן נתונים</h1>\n");
return;
}
/* This is the actual data handling */
if($sum > 0.01) { /* Write transactions of receipt */
if($payment == 0) {
ErrorReport("לא נבחר אמצאי תשלום");
return;
}
// Transaction 1 זכות הלקוח בסכום לפני ניכוי במקור
$tnum = Transaction(0, MANRECEIPT, $customer, $refnum, '', $dt, $details, $notaxsum);
// Transaction 2 חובת ניכוי במקור מלקוחות
$t2 = $tax * -1.0;
$tnum = Transaction($tnum, MANRECEIPT, CUSTTAX, $refnum, '', $dt, $details, $t2);
// Transaction 3 חובת קופה
$t3 = $sum * -1.0;
switch($payment) {
case 1:
$tnum = Transaction($tnum, MANRECEIPT, CHEQUE, $ref2, '', $dt, $details, $t3);
break;
case 2:
$tnum = Transaction($tnum, MANRECEIPT, ACCTCASH, $refnum, '', $dt, $details, $t3);
break;
case 3:
$tnum = Transaction($tnum, MANRECEIPT, CREDIT, $ref2, $creditcomp, $dt, $details, $t3);
break;
}
$total = $sum + $t2 + $t3;
$tnum = Transaction($tnum, MANRECEIPT, ROUNDING, $refnum, '', $dt, $details, $total);
}
$step = 0;
$text.= "<h1>התשלום נרשם בהצלחה</h1>\n";
$step = 0;
$refnum = '';
$details = '';
$payment = 0;
$creditcomp = 0;
$ref2 = '';
$notaxsum = 0;
$tax = 0;
$sum = 0;
}
//$text.= "<div class=\"righthalf\">\n";
if($step == 1) {
//$text.= "<div class=\"caption_out\"><div class=\"caption\">";
$header= "אישור רישום קבלה";
//$text.= "</div></div>\n";
$text.= "<h2>יש לבדוק את הפרטים וללחוץ עדכן בשנית על מנת לבצע את הרישום</h2>\n";
$nextstep = 2;
}
else if($step == 0) {
//$text.= "<div class=\"caption_out\"><div class=\"caption\">";
$header= "קבלה";
//$text.= "</div></div>\n";
$customer == "__NULL__";
$nextstep = 1;
$tax = 0;
}
$text.= "<form name=\"receipt\" action=\"?module=docsadmin&targetdoc=8&step=$nextstep\" method=\"post\"><input type=\"hidden\" name=\"type\" value=\"8\" />\n";
$text.= "<table border=\"0\" class=\"formtbl\" width=\"100%\"><tr>\n";
$text.= "<td>\n";
$text.= "לקוח: </td><td>\n";
$text.= PrintCustomerSelect($customer);
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>סכום לפני ניכוי מס: </td>\n";
$text.= "<td><input type=\"text\" name=\"notaxsum\" value=\"$notaxsum\" size=\"10\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>ניכוי במקור: </td>\n";
$text.= "<td><input type=\"text\" name=\"src_tax\" size=\"10\" value=\"$tax\" onblur=\"calcTotal()\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>סכום לאחר ניכוי מס: </td>\n";
$text.= "<td><input type=\"text\" name=\"total\" size=\"10\" value=\"$sum\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>מספר קבלה: </td>\n";
$text.= "<td><input type=\"text\" name=\"refnum\" size=\"10\" value=\"$refnum\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>תאריך: </td>\n";
$text.= "<td><input class=\"date\" type=\"text\" name=\"idate\" id=\"idate\" size=\"7\" value=\"$dt\">\n";
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>פרטים: </td>\n";
$text.= "<td><input type=\"text\" name=\"comments\" value=\"$details\" size=\"25\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td>אמצאי תשלום: </td>\n";
$text.= "<td>\n";
$text.= PrintPaymentSelect($payment);
$text.= PrintCreditSelect($creditcomp, $payment);
// $text.= "</div>\n";
$text.= "</tr><tr>\n";
$text.= "<td>אסמכתא: </td>\n";
$text.= "<td><input type=\"text\" name=\"refnum2\" value=\"$ref2\" size=\"15\"></td>\n";
$text.= "</tr><tr>\n";
$text.= "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"עדכן\">\n";
$text.= "</td></tr>\n";
$text.= "</table>\n";
$text.= "</form>\n";
//$text.= "</div>\n";
createForm($text, $header,'',750,'','icon',1,getHelp());
?>