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} = 1;
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=login value=$form->{login}>
233 <input type=hidden name=password value=$form->{password}>
236 <input class=submit type=submit name=action value="|
237 . $locale->text('Continue') . qq|">
248 $lxdebug->leave_sub();
252 $lxdebug->enter_sub();
256 for $i (1 .. $form->{rowcount}) {
257 if ($form->{"checked_$i"}) {
263 $form->error('Nothing selected!') unless $selected;
265 $form->{title} = $locale->text('Confirm!');
272 <form method=post action=$form->{script}>
275 map { delete $form->{$_} } qw(action header);
277 foreach $key (keys %$form) {
278 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
282 <h2 class=confirm>$form->{title}</h2>
286 'Are you sure you want to remove the marked entries from the queue?')
289 <input name=action class=submit type=submit value="|
290 . $locale->text('Yes') . qq|">
297 $lxdebug->leave_sub();
301 $lxdebug->enter_sub();
303 $form->info($locale->text('Removing marked entries from queue ...'));
304 $form->{callback} .= "&header=1" if $form->{callback};
306 $form->redirect($locale->text('Removed spoolfiles!'))
307 if (BP->delete_spool(\%myconfig, \%$form, $spool));
308 $form->error($locale->text('Cannot remove files!'));
310 $lxdebug->leave_sub();
314 $lxdebug->enter_sub();
316 $form->get_lists(printers => 'ALL_PRINTERS');
317 # use the command stored in the databse or fall back to $myconfig{printer}
318 my $selected_printer = (grep { $_->{id} eq $form->{printer} } @{ $form->{ALL_PRINTERS} })[0]->{'printer_command'} || $myconfig{printer};
320 if ($form->{callback}) {
321 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
322 (1 .. $form->{rowcount});
323 $form->{callback} .= "&header=1";
326 for $i (1 .. $form->{rowcount}) {
327 if ($form->{"checked_$i"}) {
328 $form->info($locale->text('Printing ... '));
330 if (BP->print_spool(\%myconfig, \%$form, $spool, "| $selected_printer")) {
331 print $locale->text('done');
332 $form->redirect($locale->text('Marked entries printed!'));
338 $form->error('Nothing selected!');
340 $lxdebug->leave_sub();
344 $lxdebug->enter_sub();
346 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
347 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
348 split(/--/, $form->{ $form->{vc} });
350 BP->get_spoolfiles(\%myconfig, \%$form);
352 $title = $form->escape($form->{title});
354 "$form->{script}?action=list_spool&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
356 $title = $form->escape($form->{title}, 1);
358 "$form->{script}?action=list_spool&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
360 if ($form->{ $form->{vc} }) {
361 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
362 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
364 ($form->{vc} eq 'customer')
365 ? $locale->text('Customer')
366 : $locale->text('Vendor');
367 $option .= " : $form->{$form->{vc}}";
369 if ($form->{account}) {
370 $callback .= "&account=" . $form->escape($form->{account}, 1);
371 $href .= "&account=" . $form->escape($form->{account});
372 $option .= "\n<br>" if ($option);
373 $option .= $locale->text('Account') . " : $form->{account}";
375 if ($form->{invnumber}) {
376 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
377 $href .= "&invnumber=" . $form->escape($form->{invnumber});
378 $option .= "\n<br>" if ($option);
379 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
381 if ($form->{ordnumber}) {
382 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
383 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
384 $option .= "\n<br>" if ($option);
385 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
387 if ($form->{quonumber}) {
388 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
389 $href .= "&quonumber=" . $form->escape($form->{quonumber});
390 $option .= "\n<br>" if ($option);
391 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
394 if ($form->{transdatefrom}) {
395 $callback .= "&transdatefrom=$form->{transdatefrom}";
396 $href .= "&transdatefrom=$form->{transdatefrom}";
397 $option .= "\n<br>" if ($option);
399 $locale->text('From') . " "
400 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
402 if ($form->{transdateto}) {
403 $callback .= "&transdateto=$form->{transdateto}";
404 $href .= "&transdateto=$form->{transdateto}";
405 $option .= "\n<br>" if ($option);
407 $locale->text('To') . " "
408 . $locale->date(\%myconfig, $form->{transdateto}, 1);
411 $name = ucfirst $form->{vc};
413 @columns = (transdate);
414 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
415 push @columns, "invnumber";
417 if ($form->{type} =~ /_order$/) {
418 push @columns, "ordnumber";
420 if ($form->{type} =~ /_quotation$/) {
421 push @columns, "quonumber";
424 push @columns, (name, spoolfile);
425 @column_index = $form->sort_columns(@columns);
426 unshift @column_index, "checked";
428 $column_header{checked} = "<th class=listheading> </th>";
429 $column_header{transdate} =
430 "<th><a class=listheading href=$href&sort=transdate>"
431 . $locale->text('Date')
433 $column_header{invnumber} =
434 "<th><a class=listheading href=$href&sort=invnumber>"
435 . $locale->text('Invoice')
437 $column_header{ordnumber} =
438 "<th><a class=listheading href=$href&sort=ordnumber>"
439 . $locale->text('Order')
441 $column_header{quonumber} =
442 "<th><a class=listheading href=$href&sort=quonumber>"
443 . $locale->text('Quotation')
445 $column_header{name} =
446 "<th><a class=listheading href=$href&sort=name>"
447 . $locale->text($name)
449 $column_header{spoolfile} =
450 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
457 <form method=post action=$form->{script}>
461 <th class=listtop>$form->{title}</th>
470 <tr class=listheading>
473 map { print "\n$column_header{$_}" } @column_index;
479 # add sort and escape callback, this one we use for the add sub
480 $form->{callback} = $callback .= "&sort=$form->{sort}";
482 # escape callback for href
483 $callback = $form->escape($callback);
487 foreach $ref (@{ $form->{SPOOL} }) {
491 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
493 if ($ref->{invoice}) {
494 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
496 $module = "$ref->{module}.pl";
498 $column_data{transdate} = "<td>$ref->{transdate} </td>";
500 if ($spoolfile eq $ref->{spoolfile}) {
501 $column_data{checked} = qq|<td></td>|;
503 $column_data{checked} =
504 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
507 $column_data{invnumber} =
508 "<td><a href=$module?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>";
509 $column_data{ordnumber} =
510 "<td><a href=$module?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>";
511 $column_data{quonumber} =
512 "<td><a href=$module?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>";
513 $column_data{name} = "<td>$ref->{name}</td>";
514 $column_data{spoolfile} =
515 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
516 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
519 $spoolfile = $ref->{spoolfile};
527 map { print "\n$column_data{$_}" } @column_index;
536 <input type=hidden name=rowcount value=$i>
542 <td><hr size=3 noshade></td>
548 <input name=callback type=hidden value="$form->{callback}">
550 <input type=hidden name=title value="$form->{title}">
551 <input type=hidden name=vc value="$form->{vc}">
552 <input type=hidden name=type value="$form->{type}">
553 <input type=hidden name=sort value="$form->{sort}">
555 <input type=hidden name=account value="$form->{account}">
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 { call_sub($form->{"nextsub"}); }