-
Notifications
You must be signed in to change notification settings - Fork 1
/
showdocs.php
264 lines (253 loc) · 9.79 KB
/
showdocs.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?PHP
/*
| ShowDocs
| Show documents list and allow viewing and printing.
| Written for Drorit accounting system
| by Ori Idan August 2009
| Modifed By adam BH 10/2010
*/
global $prefix;
global $docstbl;
global $DocType;
global $paymentarr;
global $creditarr;
global $banksarr;
$text='';
$step = isset($_GET['step']) ? $_GET['step'] : 0;
/* Get begin and end dates */
$d = date("m-Y");
list($m, $y) = explode('-', $d);
if($m < 4)
$y--;
$begindate = "1-1-$y";
$enddate = date("d-m-Y");
function PrintDocTypeSelect($def) {
global $DocType;
$text= "<select name=\"doctype\">\n";
$l = _("Select document type");
$text.= "<option value=\"0\">-- $l --</option>\n";
foreach($DocType as $key => $val) {
$s = ($key == $def) ? " selected" : "";
$text.= "<option value=\"$key\"$s>$val</option>\n";
}
$text.= "</select>\n";
return $text;
}
/*
function PrintCustomerSelect($def) {
global $accountstbl;
global $prefix;
$t = CUSTOMER;
$query = "SELECT num,company FROM $accountstbl WHERE type='$t' AND prefix='$prefix' ORDER BY company ASC";
$line = __LINE__;
$file = __FILE__;
$result = DoQuery($query, "$file: $line");
print "<select name=\"account\">\n";
$l = _("Select all");
print "<option value=\"0\">-- $l --</option>\n";
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$num = $line['num'];
$company = $line['company'];
$s = ($num == $def) ? " selected" : "";
print "<option value=\"$num\"$s>$company</option>\n";
}
print "</select>\n";
}*/
$doctype = $_REQUEST['doctype'];
$doctypestr = $DocType[$doctype];
//print "<h2>$doctypestr</h2>\n";
$haeder=$doctypestr;
if($step == 1) {
if($doctype == 0) {
$l = _("Document type must be chosen");
$text.= "<h1>$l</h1><br>\n";
$step = 0;
}
else {
$customer = (int)$_POST['account'];
if(!empty($_POST['begindate'])) {
$begindate = $_POST['begindate'];
$enddate = $_POST['enddate'];
}
$begindate = FormatDate($begindate, "dmy", "mysql");
$enddate = FormatDate($enddate, "dmy", "mysql");
//if($doctype != DOC_RECEIPT) {
//if($doctype > DOC_RECEIPT)
// $dt = DOC_INVOICE;
//else
$dt = $doctype;
if(empty($customer))
$query = "SELECT * FROM $docstbl WHERE ";
else
$query = "SELECT * FROM $docstbl WHERE account='$customer' AND ";
$query .= "doctype='$dt' AND issue_date>='$begindate' AND issue_date<='$enddate'";
$query .= " AND prefix='$prefix' ORDER BY docnum DESC";
//}
/*else {
if(empty($customer))
$query = "SELECT * FROM $docstbl WHERE ";
else
$query = "SELECT * FROM $docstbl WHERE account='$customer' AND ";
$query .= "issue_date>='$begindate' AND issue_date<='$enddate'";
$query .= " AND prefix='$prefix' ORDER BY docnum DESC";
}*/
// print "Query: $query<br>\n";
$result = DoQuery($query, "showdocs.php");
//print "<br />\n";
//print "<table width=\"100%\" class=\"tablesorter\" border=\"0\"><tr><td>\n";
$text.= "<table class=\"tablesorter\" id=\"accadmintbl\"><thead><tr>\n";
//$l = _("Doc. type");
//$text.= "<th class=\"header\" style=\"width:6em\">$l</th>\n";
$l = _("Num");
$text.= "<th class=\"header\" style=\"width:3em\">$l</th>\n";
$l = _("Date");
$text.= "<th class=\"header\" style=\"width:7em\">$l</th>\n";
$l = _("Customer");
$text.= "<th class=\"header\" style=\"width:10em\">$l</th>\n";
if($doctype != DOC_RECEIPT) {
$l = _("No VAT sum");
$text.= "<th class=\"header\" style=\"width:8em\">$l</th>\n";
}
$l = _("Total sum");
$text.= "<th class=\"header\" style=\"width:5em\">$l</th>\n";
$l = _("Actions");
$text.= "<th class=\"header\">$l</th>\n";
$text.= "</thead></tr>\n";
$novatsum = 0.0;
$totalsum = 0.0;
$e = 0;
$tbody.="<tbody>";
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$docnum = $line['docnum'];
$issue_date = $line['issue_date'];
$accountstr = $line['company'];
$account = $line['account'];
//if($doctype != DOC_RECEIPT) {
$sub_total = $line['sub_total'];
$novat_total = $line['novat_total'];
$sub_total += $novat_total;
$total = $line['total'];
//}
//else
// $total = $line['sum'];
//NewRow();
$doctypestr = $DocType[$doctype];
/*if($doctype == DOC_INVRCPT)
$doctypestr = _("Invoice receipt");*/
$tbody.= "<tr>";//<td>$doctypestr</td>\n";
$tbody.= "<td>$docnum</td>\n";
$issue_date = FormatDate($issue_date, "mysql", "dmy");
$tbody.= "<td>$issue_date</td>\n";
$tbody.= "<td>$accountstr</td>\n";
if($doctype != DOC_RECEIPT) {
$tbody.= "<td>$sub_total</td>\n";
$novatsum += $sub_total;
}
$tstr = number_format($total);
$tbody.= "<td>$tstr</td>\n";
$totalsum += $total;
$tbody.= "<td>";
if($step == 1) {
$url = "?module=$module&step=2&doctype=$doctype&docnum=$docnum&prefix=$prefix";
$target = "docswin";
$l = _("Display");
}
else {
$targetdoc = $_POST['targetdoc'];
$url = "?module=docsadmin&step=4&targetdoc=$targetdoc&doctype=$doctype&docnum=$docnum";
$target = "window";
$l = _("Copy");
}
if($target == 'docswin')
$tbody.= "<a href=\"$url\">$l</a>";
else{
$tbody.= "<input type=\"button\" onclick=\"window.location.href='$url'\"";
$tbody.= "value=\"$l\">";
}
//$tbody.= "</a> ";
$url = "?module=emaildoc&account=$account&doctype=$doctype&docnum=$docnum";
// print "<input type=\"button\" onclick=\"window.location.href='$url'\"";
// print "value=\"׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ²׳²ֲ²ײ²ֲ©׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳�ֲ¿ֲ½׳²ֲ²ײ²ֲ¿׳²ֲ²ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג‚¬ן¿½ײ²ֲ¬׳³ג€™׳’ג€�ֲ¬׳�ֲ¿ֲ½ ׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג‚¬ן¿½ײ²ֲ¬׳²ֲ»׳�ֲ¿ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג‚¬ן¿½ײ²ֲ¬׳³ן¿½ײ²ֲ¿ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג‚¬ן¿½ײ²ֲ¬׳²ֲ²ײ²ֲ¢׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳�ֲ¿ֲ½׳²ֲ²ײ²ֲ¿׳²ֲ²ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ²׳²ֲ²ײ²ֲ¨ ׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳�ֲ¿ֲ½׳²ֲ²ײ²ֲ¿׳²ֲ²ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳�ֲ¿ֲ½׳²ֲ²ײ²ֲ¿׳²ֲ²ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ²׳²ֲ²ײ²ֲ§׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ»׳³ן¿½ײ²ֲ¿ײ²ֲ½׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ²׳²ֲ²ײ²ֲ¨׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג‚¬ן¿½ײ²ֲ¬׳²ֲ²ײ²ֲ¢׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ²ײ²ֲ²׳²ֲ²ײ²ֲ ׳³ֲ³ײ²ֲ³׳²ֲ²ײ²ֲ³׳³ֲ³׳’ג‚¬ג„¢׳³ג€™׳’ג€�ֲ¬׳�ֲ¿ֲ½׳²ֲ²ײ²ֲ¢\">\n";
$tbody.= "</td></tr>\n";
}
$tbody.="</tbody>";
$text.= "<tfoot><tr class=\"sumline\">\n";
//if($doctype != DOC_RECEIPT)
$text.= "<td colspan=\"3\" align=\"left\">\n";
//else
// print "<td colspan=\"4\" align=\"left\">\n";
$l = _("Total");
$text.= "<b>$l: </b></td>\n";
if($doctype != DOC_RECEIPT)
$text.= "<td>$novatsum</td>\n";
$text.= "<td>$totalsum</td>\n";
$text.= "<td> </td>\n";
$text.= "</tr></tfoot>\n";
$text.= "$tbody</table>\n";
global $ismobile;
if($ismobile)
print $text;
else
createForm($text, $haeder,'',750,'','img/icon_showdocs1.png',1,getHelp());
/* print "</td><td width=\"48%\" valign=\"top\">\n"; */
//print "</td></tr></table>\n";
}
}
if($step == 0) {
//print "<br>\n";
//print "<div class=\"form righthalf1\">\n";
$haeder = _("Search business document");
//print "<h3>$l</h3>\n";
$text.= "<form name=\"form1\" action=\"?module=showdocs&step=1\" method=\"post\">\n";
$text.= "<table border=\"0\" class=\"formtbl\" width=\"100%\"><tr>\n";
$l = _("Doc. type");
$text.= "<td>$l: </td>\n";
$text.= "<td>\n";
$text.=PrintDocTypeSelect(0);
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$l = _("Select customer");
$text.= "<td>$l: </td>\n";
$text.= "<td>\n";
$text.=PrintCustomerSelect("");
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$l = _("From date");
$text.= "<td>$l: </td>\n";
$text.= "<td><input class=\"date\" type=\"text\" id=\"begindate\" name=\"begindate\" value=\"$begindate\" size=\"8\">\n";
//$text.='<script type="text/javascript">addDatePicker("#begindate","'.$begindate.'");</script>';
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$l = _("To date");
$text.= "<td>$l: </td>\n";
$text.= "<td><input class=\"date\" type=\"text\" id=\"enddate\" name=\"enddate\" value=\"$enddate\" size=\"8\">\n";
//$text.='<script type="text/javascript">addDatePicker("#enddate","'.$enddate.'");</script>';
$text.= "</td>\n";
$text.= "</tr><tr>\n";
$l = _("Search");
$text.= "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$l\" class='btnaction' />\n";
$text.= "</td></tr>\n";
$text.= "</table>\n";
$text.= "</form>\n";
//print "</div>\n";
global $ismobile;
if($ismobile)
print $text;
else
createForm($text,$haeder,'',750,'','img/icon_showdocs.png',1,getHelp());
}
$haeder=$doctypestr;
if($step==2){
$l=_("Your browser does not support iframes.");
$doctype = isset($_GET['doctype']) ? $_GET['doctype'] : DOC_INVOICE;
$docnum = isset($_GET['docnum']) ? $_GET['docnum'] : 0;
$url="printdoc.php?doctype=$doctype&docnum=$docnum&prefix=$prefix";
$texty="<iframe src=\"$url\" width=\"100%\" height=\"500\"><p>$l</p></iframe> ";
//?doctype=3&docnum=980&prefix=0
global $ismobile;
if($ismobile)
print $texty;
else
createForm($texty,$haeder,'',750,'','img/icon_showdocs1.png',1,getHelp());
}
?>