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 #======================================================================
42 $lxdebug->enter_sub();
44 # $locale->text('Sales Invoices')
45 # $locale->text('Packing Lists')
46 # $locale->text('Sales Orders')
47 # $locale->text('Purchase Orders')
48 # $locale->text('Quotations')
49 # $locale->text('RFQs')
50 # $locale->text('Checks')
51 # $locale->text('Receipts')
53 # setup customer/vendor selection
54 BP->get_vc(\%myconfig, \%$form);
56 if (@{ $form->{"all_$form->{vc}"} }) {
57 map { $name .= "<option>$_->{name}--$_->{id}\n" }
58 @{ $form->{"all_$form->{vc}"} };
59 $name = qq|<select name=$form->{vc}><option>\n$name</select>|;
61 $name = qq|<input name=$form->{vc} size=35>|;
64 # $locale->text('Customer')
65 # $locale->text('Vendor')
69 { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' },
71 { title => 'Packing Lists', name => 'Customer', l_invnumber => 'Y' },
73 { title => 'Sales Orders', name => 'Customer', l_ordnumber => 'Y' },
75 { title => 'Purchase Orders', name => 'Vendor', l_ordnumber => 'Y' },
77 { title => 'Quotations', name => 'Customer', l_quonumber => 'Y' },
79 { title => 'RFQs', name => 'Vendor', l_quonumber => 'Y' },
80 check => { title => 'Checks', name => 'Vendor' },
81 receipt => { title => 'Receipts', name => 'Customer' });
83 $label{invoice}{invnumber} = qq|
85 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
86 <td colspan=3><input name=invnumber size=20></td>
89 $label{invoice}{ordnumber} = qq|
91 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
92 <td colspan=3><input name=ordnumber size=20></td>
95 $label{sales_quotation}{quonumber} = qq|
97 <th align=right nowrap>| . $locale->text('Quotation Number') . qq|</th>
98 <td colspan=3><input name=quonumber size=20></td>
102 $label{check}{chknumber} = qq|
104 <th align=right nowrap>| . $locale->text('Reference') . qq|</th>
105 <td colspan=3><input name=chknumber size=20></td>
109 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
110 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
111 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
112 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
113 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
114 $label{receipt}{rctnumber} = $label{check}{chknumber};
116 # do one call to text
118 $locale->text('Print') . " "
119 . $locale->text($label{ $form->{type} }{title});
121 if ($form->{type} =~ /(check|receipt)/) {
122 if (BP->payment_accounts(\%myconfig, \%$form)) {
125 <th align=right>| . $locale->text('Account') . qq|</th>
128 if ($form->{accounts}) {
130 <td colspan=3><select name=account>
132 foreach $ref (@{ $form->{accounts} }) {
134 <option>$ref->{accno}--$ref->{description}
143 <td colspan=3><input name=account></td>
155 # use JavaScript Calendar or not
156 $form->{jsscript} = $jscalendar;
158 if ($form->{jsscript}) {
160 # with JavaScript Calendar
162 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
163 <input type=button name=transdatefrom id="trigger1" value=|
164 . $locale->text('button') . qq|></td>
167 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
168 <input type=button name=transdateto name=transdateto id="trigger2" value=|
169 . $locale->text('button') . qq|></td>
174 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
175 "transdateto", "BL", "trigger2");
178 # without JavaScript Calendar
180 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
182 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
190 <form method=post action=$form->{script}>
192 <input type=hidden name=vc value=$form->{vc}>
193 <input type=hidden name=type value=$form->{type}>
194 <input type=hidden name=title value="$form->{title}">
197 <tr><th class=listtop>$form->{title}</th></tr>
203 <th align=right>Kunde</th>
204 <td colspan=3>$name</td>
207 $label{$form->{type}}{invnumber}
208 $label{$form->{type}}{ordnumber}
209 $label{$form->{type}}{quonumber}
210 $label{$form->{type}}{chknumber}
211 $label{$form->{type}}{rctnumber}
213 <th align=right nowrap>| . $locale->text('From') . qq|</th>
215 <th align=right>| . $locale->text('Bis') . qq|</th>
218 <input type=hidden name=sort value=transdate>
223 <td><hr size=3 noshade></td>
227 <input type=hidden name=nextsub value=list_spool>
229 <input type=hidden name=path value=$form->{path}>
230 <input type=hidden name=login value=$form->{login}>
231 <input type=hidden name=password value=$form->{password}>
234 <input class=submit type=submit name=action value="|
235 . $locale->text('Continue') . qq|">
246 $lxdebug->leave_sub();
250 $lxdebug->enter_sub();
254 for $i (1 .. $form->{rowcount}) {
255 if ($form->{"checked_$i"}) {
261 $form->error('Nothing selected!') unless $selected;
263 $form->{title} = $locale->text('Confirm!');
270 <form method=post action=$form->{script}>
273 map { delete $form->{$_} } qw(action header);
275 foreach $key (keys %$form) {
276 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
280 <h2 class=confirm>$form->{title}</h2>
284 'Are you sure you want to remove the marked entries from the queue?')
287 <input name=action class=submit type=submit value="|
288 . $locale->text('Yes') . qq|">
295 $lxdebug->leave_sub();
299 $lxdebug->enter_sub();
301 $form->info($locale->text('Removing marked entries from queue ...'));
302 $form->{callback} .= "&header=1" if $form->{callback};
304 $form->redirect($locale->text('Removed spoolfiles!'))
305 if (BP->delete_spool(\%myconfig, \%$form, $spool));
306 $form->error($locale->text('Cannot remove files!'));
308 $lxdebug->leave_sub();
312 $lxdebug->enter_sub();
314 $form->get_lists(printers => 'ALL_PRINTERS');
315 # use the command stored in the databse or fall back to $myconfig{printer}
316 my $selected_printer = (grep { $_->{id} eq $form->{printer} } @{ $form->{ALL_PRINTERS} })[0]->{'printer_command'} || $myconfig{printer};
318 if ($form->{callback}) {
319 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
320 (1 .. $form->{rowcount});
321 $form->{callback} .= "&header=1";
324 for $i (1 .. $form->{rowcount}) {
325 if ($form->{"checked_$i"}) {
326 $form->{OUT} = "| $selected_printer";
327 $form->info($locale->text('Printing ... '));
329 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
330 print $locale->text('done');
331 $form->redirect($locale->text('Marked entries printed!'));
337 $form->error('Nothing selected!');
339 $lxdebug->leave_sub();
343 $lxdebug->enter_sub();
345 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
346 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
347 split(/--/, $form->{ $form->{vc} });
349 BP->get_spoolfiles(\%myconfig, \%$form);
351 $title = $form->escape($form->{title});
353 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
355 $title = $form->escape($form->{title}, 1);
357 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
359 if ($form->{ $form->{vc} }) {
360 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
361 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
363 ($form->{vc} eq 'customer')
364 ? $locale->text('Customer')
365 : $locale->text('Vendor');
366 $option .= " : $form->{$form->{vc}}";
368 if ($form->{account}) {
369 $callback .= "&account=" . $form->escape($form->{account}, 1);
370 $href .= "&account=" . $form->escape($form->{account});
371 $option .= "\n<br>" if ($option);
372 $option .= $locale->text('Account') . " : $form->{account}";
374 if ($form->{invnumber}) {
375 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
376 $href .= "&invnumber=" . $form->escape($form->{invnumber});
377 $option .= "\n<br>" if ($option);
378 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
380 if ($form->{ordnumber}) {
381 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
382 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
383 $option .= "\n<br>" if ($option);
384 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
386 if ($form->{quonumber}) {
387 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
388 $href .= "&quonumber=" . $form->escape($form->{quonumber});
389 $option .= "\n<br>" if ($option);
390 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
393 if ($form->{transdatefrom}) {
394 $callback .= "&transdatefrom=$form->{transdatefrom}";
395 $href .= "&transdatefrom=$form->{transdatefrom}";
396 $option .= "\n<br>" if ($option);
398 $locale->text('From') . " "
399 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
401 if ($form->{transdateto}) {
402 $callback .= "&transdateto=$form->{transdateto}";
403 $href .= "&transdateto=$form->{transdateto}";
404 $option .= "\n<br>" if ($option);
406 $locale->text('To') . " "
407 . $locale->date(\%myconfig, $form->{transdateto}, 1);
410 $name = ucfirst $form->{vc};
412 @columns = (transdate);
413 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
414 push @columns, "invnumber";
416 if ($form->{type} =~ /_order$/) {
417 push @columns, "ordnumber";
419 if ($form->{type} =~ /_quotation$/) {
420 push @columns, "quonumber";
423 push @columns, (name, spoolfile);
424 @column_index = $form->sort_columns(@columns);
425 unshift @column_index, "checked";
427 $column_header{checked} = "<th class=listheading> </th>";
428 $column_header{transdate} =
429 "<th><a class=listheading href=$href&sort=transdate>"
430 . $locale->text('Date')
432 $column_header{invnumber} =
433 "<th><a class=listheading href=$href&sort=invnumber>"
434 . $locale->text('Invoice')
436 $column_header{ordnumber} =
437 "<th><a class=listheading href=$href&sort=ordnumber>"
438 . $locale->text('Order')
440 $column_header{quonumber} =
441 "<th><a class=listheading href=$href&sort=quonumber>"
442 . $locale->text('Quotation')
444 $column_header{name} =
445 "<th><a class=listheading href=$href&sort=name>"
446 . $locale->text($name)
448 $column_header{spoolfile} =
449 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
456 <form method=post action=$form->{script}>
460 <th class=listtop>$form->{title}</th>
469 <tr class=listheading>
472 map { print "\n$column_header{$_}" } @column_index;
478 # add sort and escape callback, this one we use for the add sub
479 $form->{callback} = $callback .= "&sort=$form->{sort}";
481 # escape callback for href
482 $callback = $form->escape($callback);
486 foreach $ref (@{ $form->{SPOOL} }) {
490 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
492 if ($ref->{invoice}) {
493 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
495 $module = "$ref->{module}.pl";
497 $column_data{transdate} = "<td>$ref->{transdate} </td>";
499 if ($spoolfile eq $ref->{spoolfile}) {
500 $column_data{checked} = qq|<td></td>|;
502 $column_data{checked} =
503 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
506 $column_data{invnumber} =
507 "<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>";
508 $column_data{ordnumber} =
509 "<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>";
510 $column_data{quonumber} =
511 "<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>";
512 $column_data{name} = "<td>$ref->{name}</td>";
513 $column_data{spoolfile} =
514 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
515 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
518 $spoolfile = $ref->{spoolfile};
526 map { print "\n$column_data{$_}" } @column_index;
535 <input type=hidden name=rowcount value=$i>
541 <td><hr size=3 noshade></td>
547 <input name=callback type=hidden value="$form->{callback}">
549 <input type=hidden name=title value="$form->{title}">
550 <input type=hidden name=vc value="$form->{vc}">
551 <input type=hidden name=type value="$form->{type}">
552 <input type=hidden name=sort value="$form->{sort}">
554 <input type=hidden name=account value="$form->{account}">
556 <input type=hidden name=path value=$form->{path}>
557 <input type=hidden name=login value=$form->{login}>
558 <input type=hidden name=password value=$form->{password}>
561 # if ($myconfig{printer}) {
563 <input type=hidden name=transdateto value=$form->{transdateto}>
564 <input type=hidden name=transdatefrom value=$form->{transdatefrom}>
565 <input type=hidden name=invnumber value=$form->{invnumber}>
566 <input type=hidden name=ordnumber value=$form->{ordnumber}>
567 <input type=hidden name=quonumber value=$form->{quonumber}>
568 <input type=hidden name=customer value=$form->{customer}>
569 <input type=hidden name=vendor value=$form->{vendor}>
570 <input class=submit type=submit name=action value="|
571 . $locale->text('Select all') . qq|">
572 <input class=submit type=submit name=action value="|
573 . $locale->text('Remove') . qq|">
574 <input class=submit type=submit name=action value="|
575 . $locale->text('Print') . qq|">
578 $form->get_lists(printers=>"ALL_PRINTERS");
579 print qq|<select name="printer">|;
580 print map(qq|<option value="$_->{id}">| . $form->quote_html($_->{printer_description}) . qq|</option>|, @{ $form->{ALL_PRINTERS} });
592 $main::lxdebug->leave_sub();
596 $lxdebug->enter_sub();
598 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
601 $lxdebug->leave_sub();
604 sub continue { &{ $form->{nextsub} } }