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";
43 sub assert_bp_access {
45 'invoice' => 'invoice_edit',
46 'sales_order' => 'sales_order_edit',
47 'sales_quotation' => 'sales_quotation_edit',
48 'purchase_order' => 'purchase_order_edit',
49 'request_quotation' => 'request_quotation_edit',
54 if ($form->{type} && $access_map{$form->{type}}) {
55 $auth->assert($access_map{$form->{type}});
57 } elsif ($form->{type} eq 'packing_list') {
58 $lxdebug->message(0, "1");
59 if (!$auth->assert('sales_order_edit', 1)) {
60 $lxdebug->message(0, "2");
61 $auth->assert('invoice_edit') ;
63 $lxdebug->message(0, "3");
66 $auth->assert('DOES_NOT_EXIST');
71 $lxdebug->enter_sub();
75 # $locale->text('Sales Invoices')
76 # $locale->text('Packing Lists')
77 # $locale->text('Sales Orders')
78 # $locale->text('Purchase Orders')
79 # $locale->text('Quotations')
80 # $locale->text('RFQs')
81 # $locale->text('Checks')
82 # $locale->text('Receipts')
84 # setup customer/vendor selection
85 BP->get_vc(\%myconfig, \%$form);
87 if (@{ $form->{"all_$form->{vc}"} }) {
88 map { $name .= "<option>$_->{name}--$_->{id}\n" }
89 @{ $form->{"all_$form->{vc}"} };
90 $name = qq|<select name=$form->{vc}><option>\n$name</select>|;
92 $name = qq|<input name=$form->{vc} size=35>|;
95 # $locale->text('Customer')
96 # $locale->text('Vendor')
100 { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' },
102 { title => 'Packing Lists', name => 'Customer', l_invnumber => 'Y' },
104 { title => 'Sales Orders', name => 'Customer', l_ordnumber => 'Y' },
106 { title => 'Purchase Orders', name => 'Vendor', l_ordnumber => 'Y' },
108 { title => 'Quotations', name => 'Customer', l_quonumber => 'Y' },
110 { title => 'RFQs', name => 'Vendor', l_quonumber => 'Y' },
111 check => { title => 'Checks', name => 'Vendor' },
112 receipt => { title => 'Receipts', name => 'Customer' });
114 $label{invoice}{invnumber} = qq|
116 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
117 <td colspan=3><input name=invnumber size=20></td>
120 $label{invoice}{ordnumber} = qq|
122 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
123 <td colspan=3><input name=ordnumber size=20></td>
126 $label{sales_quotation}{quonumber} = qq|
128 <th align=right nowrap>| . $locale->text('Quotation Number') . qq|</th>
129 <td colspan=3><input name=quonumber size=20></td>
133 $label{check}{chknumber} = qq|
135 <th align=right nowrap>| . $locale->text('Reference') . qq|</th>
136 <td colspan=3><input name=chknumber size=20></td>
140 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
141 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
142 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
143 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
144 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
145 $label{receipt}{rctnumber} = $label{check}{chknumber};
147 # do one call to text
149 $locale->text('Print') . " "
150 . $locale->text($label{ $form->{type} }{title});
152 if ($form->{type} =~ /(check|receipt)/) {
153 if (BP->payment_accounts(\%myconfig, \%$form)) {
156 <th align=right>| . $locale->text('Account') . qq|</th>
159 if ($form->{accounts}) {
161 <td colspan=3><select name=account>
163 foreach $ref (@{ $form->{accounts} }) {
165 <option>$ref->{accno}--$ref->{description}
174 <td colspan=3><input name=account></td>
186 # use JavaScript Calendar or not
187 $form->{jsscript} = 1;
189 if ($form->{jsscript}) {
191 # with JavaScript Calendar
193 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
194 <input type=button name=transdatefrom id="trigger1" value=|
195 . $locale->text('button') . qq|></td>
198 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
199 <input type=button name=transdateto name=transdateto id="trigger2" value=|
200 . $locale->text('button') . qq|></td>
205 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
206 "transdateto", "BL", "trigger2");
209 # without JavaScript Calendar
211 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
213 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
215 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
217 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
218 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
220 <body onLoad="$onload">
222 <form method=post action=bp.pl>
224 <input type=hidden name=vc value=$form->{vc}>
225 <input type=hidden name=type value=$form->{type}>
226 <input type=hidden name=title value="$form->{title}">
229 <tr><th class=listtop>$form->{title}</th></tr>
235 <th align=right>Kunde</th>
236 <td colspan=3>$name</td>
239 $label{$form->{type}}{invnumber}
240 $label{$form->{type}}{ordnumber}
241 $label{$form->{type}}{quonumber}
242 $label{$form->{type}}{chknumber}
243 $label{$form->{type}}{rctnumber}
245 <th align=right nowrap>| . $locale->text('From') . qq|</th>
247 <th align=right>| . $locale->text('Bis') . qq|</th>
250 <input type=hidden name=sort value=transdate>
255 <td><hr size=3 noshade></td>
259 <input type=hidden name=nextsub value=list_spool>
262 <input class=submit type=submit name=action value="|
263 . $locale->text('Continue') . qq|">
274 $lxdebug->leave_sub();
278 $lxdebug->enter_sub();
284 for $i (1 .. $form->{rowcount}) {
285 if ($form->{"checked_$i"}) {
291 $form->error('Nothing selected!') unless $selected;
293 $form->{title} = $locale->text('Confirm!');
300 <form method=post action=bp.pl>
303 map { delete $form->{$_} } qw(action header);
305 foreach $key (keys %$form) {
306 next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
307 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
311 <h2 class=confirm>$form->{title}</h2>
315 'Are you sure you want to remove the marked entries from the queue?')
318 <input name=action class=submit type=submit value="|
319 . $locale->text('Yes') . qq|">
326 $lxdebug->leave_sub();
330 $lxdebug->enter_sub();
334 $form->info($locale->text('Removing marked entries from queue ...'));
335 $form->{callback} .= "&header=1" if $form->{callback};
337 $form->redirect($locale->text('Removed spoolfiles!'))
338 if (BP->delete_spool(\%myconfig, \%$form, $spool));
339 $form->error($locale->text('Cannot remove files!'));
341 $lxdebug->leave_sub();
345 $lxdebug->enter_sub();
349 $form->get_lists(printers => 'ALL_PRINTERS');
350 # use the command stored in the databse or fall back to $myconfig{printer}
351 my $selected_printer = (grep { $_->{id} eq $form->{printer} } @{ $form->{ALL_PRINTERS} })[0]->{'printer_command'} || $myconfig{printer};
353 if ($form->{callback}) {
354 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
355 (1 .. $form->{rowcount});
356 $form->{callback} .= "&header=1";
359 for $i (1 .. $form->{rowcount}) {
360 if ($form->{"checked_$i"}) {
361 $form->info($locale->text('Printing ... '));
363 if (BP->print_spool(\%myconfig, \%$form, $spool, "| $selected_printer")) {
364 print $locale->text('done');
365 $form->redirect($locale->text('Marked entries printed!'));
371 $form->error('Nothing selected!');
373 $lxdebug->leave_sub();
377 $lxdebug->enter_sub();
381 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
382 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
383 split(/--/, $form->{ $form->{vc} });
385 BP->get_spoolfiles(\%myconfig, \%$form);
387 $title = $form->escape($form->{title});
388 $href = "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title";
390 $title = $form->escape($form->{title}, 1);
392 "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title";
394 if ($form->{ $form->{vc} }) {
395 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
396 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
398 ($form->{vc} eq 'customer')
399 ? $locale->text('Customer')
400 : $locale->text('Vendor');
401 $option .= " : $form->{$form->{vc}}";
403 if ($form->{account}) {
404 $callback .= "&account=" . $form->escape($form->{account}, 1);
405 $href .= "&account=" . $form->escape($form->{account});
406 $option .= "\n<br>" if ($option);
407 $option .= $locale->text('Account') . " : $form->{account}";
409 if ($form->{invnumber}) {
410 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
411 $href .= "&invnumber=" . $form->escape($form->{invnumber});
412 $option .= "\n<br>" if ($option);
413 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
415 if ($form->{ordnumber}) {
416 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
417 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
418 $option .= "\n<br>" if ($option);
419 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
421 if ($form->{quonumber}) {
422 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
423 $href .= "&quonumber=" . $form->escape($form->{quonumber});
424 $option .= "\n<br>" if ($option);
425 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
428 if ($form->{transdatefrom}) {
429 $callback .= "&transdatefrom=$form->{transdatefrom}";
430 $href .= "&transdatefrom=$form->{transdatefrom}";
431 $option .= "\n<br>" if ($option);
433 $locale->text('From') . " "
434 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
436 if ($form->{transdateto}) {
437 $callback .= "&transdateto=$form->{transdateto}";
438 $href .= "&transdateto=$form->{transdateto}";
439 $option .= "\n<br>" if ($option);
441 $locale->text('To') . " "
442 . $locale->date(\%myconfig, $form->{transdateto}, 1);
445 $name = ucfirst $form->{vc};
447 @columns = (transdate);
448 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
449 push @columns, "invnumber";
451 if ($form->{type} =~ /_order$/) {
452 push @columns, "ordnumber";
454 if ($form->{type} =~ /_quotation$/) {
455 push @columns, "quonumber";
458 push @columns, (name, spoolfile);
459 @column_index = $form->sort_columns(@columns);
460 unshift @column_index, "checked";
462 $column_header{checked} = "<th class=listheading> </th>";
463 $column_header{transdate} =
464 "<th><a class=listheading href=$href&sort=transdate>"
465 . $locale->text('Date')
467 $column_header{invnumber} =
468 "<th><a class=listheading href=$href&sort=invnumber>"
469 . $locale->text('Invoice')
471 $column_header{ordnumber} =
472 "<th><a class=listheading href=$href&sort=ordnumber>"
473 . $locale->text('Order')
475 $column_header{quonumber} =
476 "<th><a class=listheading href=$href&sort=quonumber>"
477 . $locale->text('Quotation')
479 $column_header{name} =
480 "<th><a class=listheading href=$href&sort=name>"
481 . $locale->text($name)
483 $column_header{spoolfile} =
484 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
491 <form method=post action=bp.pl>
495 <th class=listtop>$form->{title}</th>
504 <tr class=listheading>
507 map { print "\n$column_header{$_}" } @column_index;
513 # add sort and escape callback, this one we use for the add sub
514 $form->{callback} = $callback .= "&sort=$form->{sort}";
516 # escape callback for href
517 $callback = $form->escape($callback);
521 foreach $ref (@{ $form->{SPOOL} }) {
525 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
527 if ($ref->{invoice}) {
528 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
530 $module = "$ref->{module}.pl";
532 $column_data{transdate} = "<td>$ref->{transdate} </td>";
534 if ($spoolfile eq $ref->{spoolfile}) {
535 $column_data{checked} = qq|<td></td>|;
537 $column_data{checked} =
538 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
541 $column_data{invnumber} =
542 "<td><a href=$module?action=edit&id=$ref->{id}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>";
543 $column_data{ordnumber} =
544 "<td><a href=$module?action=edit&id=$ref->{id}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>";
545 $column_data{quonumber} =
546 "<td><a href=$module?action=edit&id=$ref->{id}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>";
547 $column_data{name} = "<td>$ref->{name}</td>";
548 $column_data{spoolfile} =
549 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
550 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
553 $spoolfile = $ref->{spoolfile};
561 map { print "\n$column_data{$_}" } @column_index;
570 <input type=hidden name=rowcount value=$i>
576 <td><hr size=3 noshade></td>
582 <input name=callback type=hidden value="$form->{callback}">
584 <input type=hidden name=title value="$form->{title}">
585 <input type=hidden name=vc value="$form->{vc}">
586 <input type=hidden name=type value="$form->{type}">
587 <input type=hidden name=sort value="$form->{sort}">
589 <input type=hidden name=account value="$form->{account}">
592 # if ($myconfig{printer}) {
594 <input type=hidden name=transdateto value=$form->{transdateto}>
595 <input type=hidden name=transdatefrom value=$form->{transdatefrom}>
596 <input type=hidden name=invnumber value=$form->{invnumber}>
597 <input type=hidden name=ordnumber value=$form->{ordnumber}>
598 <input type=hidden name=quonumber value=$form->{quonumber}>
599 <input type=hidden name=customer value=$form->{customer}>
600 <input type=hidden name=vendor value=$form->{vendor}>
601 <input class=submit type=submit name=action value="|
602 . $locale->text('Select all') . qq|">
603 <input class=submit type=submit name=action value="|
604 . $locale->text('Remove') . qq|">
605 <input class=submit type=submit name=action value="|
606 . $locale->text('Print') . qq|">
609 $form->get_lists(printers=>"ALL_PRINTERS");
610 print qq|<select name="printer">|;
611 print map(qq|<option value="$_->{id}">| . H($_->{printer_description}) . qq|</option>|, @{ $form->{ALL_PRINTERS} });
623 $main::lxdebug->leave_sub();
627 $lxdebug->enter_sub();
631 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
634 $lxdebug->leave_sub();
637 sub continue { call_sub($form->{"nextsub"}); }