1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
39 require "bin/mozilla/common.pl";
44 $lxdebug->enter_sub();
46 # $locale->text('Sales Invoices')
47 # $locale->text('Packing Lists')
48 # $locale->text('Sales Orders')
49 # $locale->text('Purchase Orders')
50 # $locale->text('Quotations')
51 # $locale->text('RFQs')
52 # $locale->text('Checks')
53 # $locale->text('Receipts')
55 # setup customer/vendor selection
56 BP->get_vc(\%myconfig, \%$form);
58 if (@{ $form->{"all_$form->{vc}"} }) {
59 map { $name .= "<option>$_->{name}--$_->{id}\n" }
60 @{ $form->{"all_$form->{vc}"} };
61 $name = qq|<select name=$form->{vc}><option>\n$name</select>|;
63 $name = qq|<input name=$form->{vc} size=35>|;
66 # $locale->text('Customer')
67 # $locale->text('Vendor')
71 { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' },
73 { title => 'Packing Lists', name => 'Customer', l_invnumber => 'Y' },
75 { title => 'Sales Orders', name => 'Customer', l_ordnumber => 'Y' },
77 { title => 'Purchase Orders', name => 'Vendor', l_ordnumber => 'Y' },
79 { title => 'Quotations', name => 'Customer', l_quonumber => 'Y' },
81 { title => 'RFQs', name => 'Vendor', l_quonumber => 'Y' },
82 check => { title => 'Checks', name => 'Vendor' },
83 receipt => { title => 'Receipts', name => 'Customer' });
85 $label{invoice}{invnumber} = qq|
87 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
88 <td colspan=3><input name=invnumber size=20></td>
91 $label{invoice}{ordnumber} = qq|
93 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
94 <td colspan=3><input name=ordnumber size=20></td>
97 $label{sales_quotation}{quonumber} = qq|
99 <th align=right nowrap>| . $locale->text('Quotation Number') . qq|</th>
100 <td colspan=3><input name=quonumber size=20></td>
104 $label{check}{chknumber} = qq|
106 <th align=right nowrap>| . $locale->text('Reference') . qq|</th>
107 <td colspan=3><input name=chknumber size=20></td>
111 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
112 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
113 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
114 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
115 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
116 $label{receipt}{rctnumber} = $label{check}{chknumber};
118 # do one call to text
120 $locale->text('Print') . " "
121 . $locale->text($label{ $form->{type} }{title});
123 if ($form->{type} =~ /(check|receipt)/) {
124 if (BP->payment_accounts(\%myconfig, \%$form)) {
127 <th align=right>| . $locale->text('Account') . qq|</th>
130 if ($form->{accounts}) {
132 <td colspan=3><select name=account>
134 foreach $ref (@{ $form->{accounts} }) {
136 <option>$ref->{accno}--$ref->{description}
145 <td colspan=3><input name=account></td>
157 # use JavaScript Calendar or not
158 $form->{jsscript} = $jscalendar;
160 if ($form->{jsscript}) {
162 # with JavaScript Calendar
164 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
165 <input type=button name=transdatefrom id="trigger1" value=|
166 . $locale->text('button') . qq|></td>
169 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
170 <input type=button name=transdateto name=transdateto id="trigger2" value=|
171 . $locale->text('button') . qq|></td>
176 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
177 "transdateto", "BL", "trigger2");
180 # without JavaScript Calendar
182 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
184 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
186 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
188 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
189 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
191 <body onLoad="$onload">
193 <form method=post action=$form->{script}>
195 <input type=hidden name=vc value=$form->{vc}>
196 <input type=hidden name=type value=$form->{type}>
197 <input type=hidden name=title value="$form->{title}">
200 <tr><th class=listtop>$form->{title}</th></tr>
206 <th align=right>Kunde</th>
207 <td colspan=3>$name</td>
210 $label{$form->{type}}{invnumber}
211 $label{$form->{type}}{ordnumber}
212 $label{$form->{type}}{quonumber}
213 $label{$form->{type}}{chknumber}
214 $label{$form->{type}}{rctnumber}
216 <th align=right nowrap>| . $locale->text('From') . qq|</th>
218 <th align=right>| . $locale->text('Bis') . qq|</th>
221 <input type=hidden name=sort value=transdate>
226 <td><hr size=3 noshade></td>
230 <input type=hidden name=nextsub value=list_spool>
232 <input type=hidden name=path value=$form->{path}>
233 <input type=hidden name=login value=$form->{login}>
234 <input type=hidden name=password value=$form->{password}>
237 <input class=submit type=submit name=action value="|
238 . $locale->text('Continue') . qq|">
249 $lxdebug->leave_sub();
253 $lxdebug->enter_sub();
257 for $i (1 .. $form->{rowcount}) {
258 if ($form->{"checked_$i"}) {
264 $form->error('Nothing selected!') unless $selected;
266 $form->{title} = $locale->text('Confirm!');
273 <form method=post action=$form->{script}>
276 map { delete $form->{$_} } qw(action header);
278 foreach $key (keys %$form) {
279 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
283 <h2 class=confirm>$form->{title}</h2>
287 'Are you sure you want to remove the marked entries from the queue?')
290 <input name=action class=submit type=submit value="|
291 . $locale->text('Yes') . qq|">
298 $lxdebug->leave_sub();
302 $lxdebug->enter_sub();
304 $form->info($locale->text('Removing marked entries from queue ...'));
305 $form->{callback} .= "&header=1" if $form->{callback};
307 $form->redirect($locale->text('Removed spoolfiles!'))
308 if (BP->delete_spool(\%myconfig, \%$form, $spool));
309 $form->error($locale->text('Cannot remove files!'));
311 $lxdebug->leave_sub();
315 $lxdebug->enter_sub();
317 $form->get_lists(printers => 'ALL_PRINTERS');
318 # use the command stored in the databse or fall back to $myconfig{printer}
319 my $selected_printer = (grep { $_->{id} eq $form->{printer} } @{ $form->{ALL_PRINTERS} })[0]->{'printer_command'} || $myconfig{printer};
321 if ($form->{callback}) {
322 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
323 (1 .. $form->{rowcount});
324 $form->{callback} .= "&header=1";
327 for $i (1 .. $form->{rowcount}) {
328 if ($form->{"checked_$i"}) {
329 $form->{OUT} = "| $selected_printer";
330 $form->info($locale->text('Printing ... '));
332 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
333 print $locale->text('done');
334 $form->redirect($locale->text('Marked entries printed!'));
340 $form->error('Nothing selected!');
342 $lxdebug->leave_sub();
346 $lxdebug->enter_sub();
348 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
349 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
350 split(/--/, $form->{ $form->{vc} });
352 BP->get_spoolfiles(\%myconfig, \%$form);
354 $title = $form->escape($form->{title});
356 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
358 $title = $form->escape($form->{title}, 1);
360 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
362 if ($form->{ $form->{vc} }) {
363 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
364 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
366 ($form->{vc} eq 'customer')
367 ? $locale->text('Customer')
368 : $locale->text('Vendor');
369 $option .= " : $form->{$form->{vc}}";
371 if ($form->{account}) {
372 $callback .= "&account=" . $form->escape($form->{account}, 1);
373 $href .= "&account=" . $form->escape($form->{account});
374 $option .= "\n<br>" if ($option);
375 $option .= $locale->text('Account') . " : $form->{account}";
377 if ($form->{invnumber}) {
378 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
379 $href .= "&invnumber=" . $form->escape($form->{invnumber});
380 $option .= "\n<br>" if ($option);
381 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
383 if ($form->{ordnumber}) {
384 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
385 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
386 $option .= "\n<br>" if ($option);
387 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
389 if ($form->{quonumber}) {
390 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
391 $href .= "&quonumber=" . $form->escape($form->{quonumber});
392 $option .= "\n<br>" if ($option);
393 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
396 if ($form->{transdatefrom}) {
397 $callback .= "&transdatefrom=$form->{transdatefrom}";
398 $href .= "&transdatefrom=$form->{transdatefrom}";
399 $option .= "\n<br>" if ($option);
401 $locale->text('From') . " "
402 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
404 if ($form->{transdateto}) {
405 $callback .= "&transdateto=$form->{transdateto}";
406 $href .= "&transdateto=$form->{transdateto}";
407 $option .= "\n<br>" if ($option);
409 $locale->text('To') . " "
410 . $locale->date(\%myconfig, $form->{transdateto}, 1);
413 $name = ucfirst $form->{vc};
415 @columns = (transdate);
416 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
417 push @columns, "invnumber";
419 if ($form->{type} =~ /_order$/) {
420 push @columns, "ordnumber";
422 if ($form->{type} =~ /_quotation$/) {
423 push @columns, "quonumber";
426 push @columns, (name, spoolfile);
427 @column_index = $form->sort_columns(@columns);
428 unshift @column_index, "checked";
430 $column_header{checked} = "<th class=listheading> </th>";
431 $column_header{transdate} =
432 "<th><a class=listheading href=$href&sort=transdate>"
433 . $locale->text('Date')
435 $column_header{invnumber} =
436 "<th><a class=listheading href=$href&sort=invnumber>"
437 . $locale->text('Invoice')
439 $column_header{ordnumber} =
440 "<th><a class=listheading href=$href&sort=ordnumber>"
441 . $locale->text('Order')
443 $column_header{quonumber} =
444 "<th><a class=listheading href=$href&sort=quonumber>"
445 . $locale->text('Quotation')
447 $column_header{name} =
448 "<th><a class=listheading href=$href&sort=name>"
449 . $locale->text($name)
451 $column_header{spoolfile} =
452 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
459 <form method=post action=$form->{script}>
463 <th class=listtop>$form->{title}</th>
472 <tr class=listheading>
475 map { print "\n$column_header{$_}" } @column_index;
481 # add sort and escape callback, this one we use for the add sub
482 $form->{callback} = $callback .= "&sort=$form->{sort}";
484 # escape callback for href
485 $callback = $form->escape($callback);
489 foreach $ref (@{ $form->{SPOOL} }) {
493 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
495 if ($ref->{invoice}) {
496 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
498 $module = "$ref->{module}.pl";
500 $column_data{transdate} = "<td>$ref->{transdate} </td>";
502 if ($spoolfile eq $ref->{spoolfile}) {
503 $column_data{checked} = qq|<td></td>|;
505 $column_data{checked} =
506 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
509 $column_data{invnumber} =
510 "<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>";
511 $column_data{ordnumber} =
512 "<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>";
513 $column_data{quonumber} =
514 "<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>";
515 $column_data{name} = "<td>$ref->{name}</td>";
516 $column_data{spoolfile} =
517 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
518 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
521 $spoolfile = $ref->{spoolfile};
529 map { print "\n$column_data{$_}" } @column_index;
538 <input type=hidden name=rowcount value=$i>
544 <td><hr size=3 noshade></td>
550 <input name=callback type=hidden value="$form->{callback}">
552 <input type=hidden name=title value="$form->{title}">
553 <input type=hidden name=vc value="$form->{vc}">
554 <input type=hidden name=type value="$form->{type}">
555 <input type=hidden name=sort value="$form->{sort}">
557 <input type=hidden name=account value="$form->{account}">
559 <input type=hidden name=path value=$form->{path}>
560 <input type=hidden name=login value=$form->{login}>
561 <input type=hidden name=password value=$form->{password}>
564 # if ($myconfig{printer}) {
566 <input type=hidden name=transdateto value=$form->{transdateto}>
567 <input type=hidden name=transdatefrom value=$form->{transdatefrom}>
568 <input type=hidden name=invnumber value=$form->{invnumber}>
569 <input type=hidden name=ordnumber value=$form->{ordnumber}>
570 <input type=hidden name=quonumber value=$form->{quonumber}>
571 <input type=hidden name=customer value=$form->{customer}>
572 <input type=hidden name=vendor value=$form->{vendor}>
573 <input class=submit type=submit name=action value="|
574 . $locale->text('Select all') . qq|">
575 <input class=submit type=submit name=action value="|
576 . $locale->text('Remove') . qq|">
577 <input class=submit type=submit name=action value="|
578 . $locale->text('Print') . qq|">
581 $form->get_lists(printers=>"ALL_PRINTERS");
582 print qq|<select name="printer">|;
583 print map(qq|<option value="$_->{id}">| . $form->quote_html($_->{printer_description}) . qq|</option>|, @{ $form->{ALL_PRINTERS} });
595 $main::lxdebug->leave_sub();
599 $lxdebug->enter_sub();
601 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
604 $lxdebug->leave_sub();
607 sub continue { call_sub($form->{"nextsub"}); }