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();
45 # $locale->text('Sales Invoices')
46 # $locale->text('Packing Lists')
47 # $locale->text('Sales Orders')
48 # $locale->text('Purchase Orders')
49 # $locale->text('Quotations')
50 # $locale->text('RFQs')
51 # $locale->text('Checks')
52 # $locale->text('Receipts')
54 # setup customer/vendor selection
55 BP->get_vc(\%myconfig, \%$form);
57 if (@{ $form->{"all_$form->{vc}"} }) {
58 map { $name .= "<option>$_->{name}--$_->{id}\n" } @{ $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')
67 %label = ( invoice => { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' },
68 packing_list => { title => 'Packing Lists', name => 'Customer', l_invnumber => 'Y' },
69 sales_order => { title => 'Sales Orders', name => 'Customer', l_ordnumber => 'Y' },
70 purchase_order => { title => 'Purchase Orders', name => 'Vendor', l_ordnumber => 'Y' },
71 sales_quotation => { title => 'Quotations', name => 'Customer', l_quonumber => 'Y' },
72 request_quotation => { title => 'RFQs', name => 'Vendor', l_quonumber => 'Y' },
73 check => { title => 'Checks', name => 'Vendor' },
74 receipt => { title => 'Receipts', name => 'Customer' }
77 $label{invoice}{invnumber} = qq|
79 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
80 <td colspan=3><input name=invnumber size=20></td>
83 $label{invoice}{ordnumber} = qq|
85 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
86 <td colspan=3><input name=ordnumber size=20></td>
89 $label{sales_quotation}{quonumber} = qq|
91 <th align=right nowrap>|.$locale->text('Quotation Number').qq|</th>
92 <td colspan=3><input name=quonumber size=20></td>
96 $label{check}{chknumber} = qq|
98 <th align=right nowrap>|.$locale->text('Reference').qq|</th>
99 <td colspan=3><input name=chknumber size=20></td>
103 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
104 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
105 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
106 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
107 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
108 $label{receipt}{rctnumber} = $label{check}{chknumber};
110 # do one call to text
111 $form->{title} = $locale->text('Print')." ".$locale->text($label{$form->{type}}{title});
113 if ($form->{type} =~ /(check|receipt)/) {
114 if (BP->payment_accounts(\%myconfig, \%$form)) {
117 <th align=right>|.$locale->text('Account').qq|</th>
120 if ($form->{accounts}) {
122 <td colspan=3><select name=account>
124 foreach $ref (@{ $form->{accounts} }) {
126 <option>$ref->{accno}--$ref->{description}
135 <td colspan=3><input name=account></td>
147 # use JavaScript Calendar or not
148 $form->{jsscript} = $jscalendar;
150 if ($form->{jsscript})
152 # with JavaScript Calendar
154 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
155 <input type=button name=transdatefrom id="trigger1" value=|.$locale->text('button').qq|></td>
158 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
159 <input type=button name=transdateto name=transdateto id="trigger2" value=|.$locale->text('button').qq|></td>
162 $jsscript = Form->write_trigger(\%myconfig,"2","transdatefrom","BR","trigger1","transdateto","BL","trigger2");
166 # without JavaScript Calendar
168 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
170 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
178 <form method=post action=$form->{script}>
180 <input type=hidden name=vc value=$form->{vc}>
181 <input type=hidden name=type value=$form->{type}>
182 <input type=hidden name=title value="$form->{title}">
185 <tr><th class=listtop>$form->{title}</th></tr>
191 <th align=right>Kunde</th>
192 <td colspan=3>$name</td>
195 $label{$form->{type}}{invnumber}
196 $label{$form->{type}}{ordnumber}
197 $label{$form->{type}}{quonumber}
198 $label{$form->{type}}{chknumber}
199 $label{$form->{type}}{rctnumber}
201 <th align=right nowrap>|.$locale->text('From').qq|</th>
203 <th align=right>|.$locale->text('Bis').qq|</th>
206 <input type=hidden name=sort value=transdate>
211 <td><hr size=3 noshade></td>
215 <input type=hidden name=nextsub value=list_spool>
217 <input type=hidden name=path value=$form->{path}>
218 <input type=hidden name=login value=$form->{login}>
219 <input type=hidden name=password value=$form->{password}>
222 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
233 $lxdebug->leave_sub();
239 $lxdebug->enter_sub();
244 for $i (1 .. $form->{rowcount}) {
245 if ($form->{"checked_$i"}) {
251 $form->error('Nothing selected!') unless $selected;
253 $form->{title} = $locale->text('Confirm!');
260 <form method=post action=$form->{script}>
263 map { delete $form->{$_} } qw(action header);
265 foreach $key (keys %$form) {
266 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
270 <h2 class=confirm>$form->{title}</h2>
272 <h4>|.$locale->text('Are you sure you want to remove the marked entries from the queue?').qq|</h4>
274 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
281 $lxdebug->leave_sub();
287 $lxdebug->enter_sub();
290 $form->info($locale->text('Removing marked entries from queue ...'));
291 $form->{callback} .= "&header=1" if $form->{callback};
293 $form->redirect($locale->text('Removed spoolfiles!')) if (BP->delete_spool(\%myconfig, \%$form, $spool));
294 $form->error($locale->text('Cannot remove files!'));
296 $lxdebug->leave_sub();
301 $lxdebug->enter_sub();
304 if ($form->{callback}) {
305 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} } (1 .. $form->{rowcount});
306 $form->{callback} .= "&header=1";
309 for $i (1 .. $form->{rowcount}) {
310 if ($form->{"checked_$i"}) {
311 $form->{OUT} = "| $myconfig{printer}";
312 $form->info($locale->text('Printing ... '));
314 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
315 print $locale->text('done');
316 $form->redirect($locale->text('Marked entries printed!'));
322 $form->error('Nothing selected!');
324 $lxdebug->leave_sub();
329 $lxdebug->enter_sub();
332 $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
333 ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
335 BP->get_spoolfiles(\%myconfig, \%$form);
337 $title = $form->escape($form->{title});
338 $href = "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
340 $title = $form->escape($form->{title},1);
341 $callback = "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
343 if ($form->{$form->{vc}}) {
344 $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1);
345 $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}});
346 $option = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
347 $option .= " : $form->{$form->{vc}}";
349 if ($form->{account}) {
350 $callback .= "&account=".$form->escape($form->{account},1);
351 $href .= "&account=".$form->escape($form->{account});
352 $option .= "\n<br>" if ($option);
353 $option .= $locale->text('Account')." : $form->{account}";
355 if ($form->{invnumber}) {
356 $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
357 $href .= "&invnumber=".$form->escape($form->{invnumber});
358 $option .= "\n<br>" if ($option);
359 $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
361 if ($form->{ordnumber}) {
362 $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
363 $href .= "&ordnumber=".$form->escape($form->{ordnumber});
364 $option .= "\n<br>" if ($option);
365 $option .= $locale->text('Order Number')." : $form->{ordnumber}";
367 if ($form->{quonumber}) {
368 $callback .= "&quonumber=".$form->escape($form->{quonumber},1);
369 $href .= "&quonumber=".$form->escape($form->{quonumber});
370 $option .= "\n<br>" if ($option);
371 $option .= $locale->text('Quotation Number')." : $form->{quonumber}";
374 if ($form->{transdatefrom}) {
375 $callback .= "&transdatefrom=$form->{transdatefrom}";
376 $href .= "&transdatefrom=$form->{transdatefrom}";
377 $option .= "\n<br>" if ($option);
378 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
380 if ($form->{transdateto}) {
381 $callback .= "&transdateto=$form->{transdateto}";
382 $href .= "&transdateto=$form->{transdateto}";
383 $option .= "\n<br>" if ($option);
384 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
387 $name = ucfirst $form->{vc};
389 @columns = (transdate);
390 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
391 push @columns, "invnumber";
393 if ($form->{type} =~ /_order$/) {
394 push @columns, "ordnumber";
396 if ($form->{type} =~ /_quotation$/) {
397 push @columns, "quonumber";
400 push @columns, (name, spoolfile);
401 @column_index = $form->sort_columns(@columns);
402 unshift @column_index, "checked";
404 $column_header{checked} = "<th class=listheading> </th>";
405 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
406 $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
407 $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
408 $column_header{quonumber} = "<th><a class=listheading href=$href&sort=quonumber>".$locale->text('Quotation')."</a></th>";
409 $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text($name)."</a></th>";
410 $column_header{spoolfile} = "<th class=listheading>".$locale->text('Spoolfile')."</th>";
418 <form method=post action=$form->{script}>
422 <th class=listtop>$form->{title}</th>
431 <tr class=listheading>
434 map { print "\n$column_header{$_}" } @column_index;
441 # add sort and escape callback, this one we use for the add sub
442 $form->{callback} = $callback .= "&sort=$form->{sort}";
444 # escape callback for href
445 $callback = $form->escape($callback);
449 foreach $ref (@{ $form->{SPOOL} }) {
453 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
455 if ($ref->{invoice}) {
456 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
458 $module = "$ref->{module}.pl";
460 $column_data{transdate} = "<td>$ref->{transdate} </td>";
462 if ($spoolfile eq $ref->{spoolfile}) {
463 $column_data{checked} = qq|<td></td>|;
465 $column_data{checked} = qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
468 $column_data{invnumber} = "<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>";
469 $column_data{ordnumber} = "<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>";
470 $column_data{quonumber} = "<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>";
471 $column_data{name} = "<td>$ref->{name}</td>";
472 $column_data{spoolfile} = qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
473 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
476 $spoolfile = $ref->{spoolfile};
483 map { print "\n$column_data{$_}" } @column_index;
492 <input type=hidden name=rowcount value=$i>
498 <td><hr size=3 noshade></td>
504 <input name=callback type=hidden value="$form->{callback}">
506 <input type=hidden name=title value="$form->{title}">
507 <input type=hidden name=vc value="$form->{vc}">
508 <input type=hidden name=type value="$form->{type}">
509 <input type=hidden name=sort value="$form->{sort}">
511 <input type=hidden name=account value="$form->{account}">
513 <input type=hidden name=path value=$form->{path}>
514 <input type=hidden name=login value=$form->{login}>
515 <input type=hidden name=password value=$form->{password}>
518 if ($myconfig{printer}) {
520 <input class=submit type=submit name=action value="|.$locale->text('Select all').qq|">
521 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
522 <input class=submit type=submit name=action value="|.$locale->text('Remove').qq|">
526 if ($form->{menubar}) {
527 require "$form->{path}/menu.pl";
538 $lxdebug->leave_sub();
543 $lxdebug->enter_sub();
546 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
549 $lxdebug->leave_sub();
553 sub continue { &{ $form->{nextsub} } };