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 #======================================================================
41 $lxdebug->enter_sub();
43 # $locale->text('Sales Invoices')
44 # $locale->text('Packing Lists')
45 # $locale->text('Sales Orders')
46 # $locale->text('Purchase Orders')
47 # $locale->text('Quotations')
48 # $locale->text('RFQs')
49 # $locale->text('Checks')
50 # $locale->text('Receipts')
52 # setup customer/vendor selection
53 BP->get_vc(\%myconfig, \%$form);
55 if (@{ $form->{"all_$form->{vc}"} }) {
56 map { $name .= "<option>$_->{name}--$_->{id}\n" }
57 @{ $form->{"all_$form->{vc}"} };
58 $name = qq|<select name=$form->{vc}><option>\n$name</select>|;
60 $name = qq|<input name=$form->{vc} size=35>|;
63 # $locale->text('Customer')
64 # $locale->text('Vendor')
68 { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' },
70 { title => 'Packing Lists', name => 'Customer', l_invnumber => 'Y' },
72 { title => 'Sales Orders', name => 'Customer', l_ordnumber => 'Y' },
74 { title => 'Purchase Orders', name => 'Vendor', l_ordnumber => 'Y' },
76 { title => 'Quotations', name => 'Customer', l_quonumber => 'Y' },
78 { title => 'RFQs', name => 'Vendor', l_quonumber => 'Y' },
79 check => { title => 'Checks', name => 'Vendor' },
80 receipt => { title => 'Receipts', name => 'Customer' });
82 $label{invoice}{invnumber} = qq|
84 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
85 <td colspan=3><input name=invnumber size=20></td>
88 $label{invoice}{ordnumber} = qq|
90 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
91 <td colspan=3><input name=ordnumber size=20></td>
94 $label{sales_quotation}{quonumber} = qq|
96 <th align=right nowrap>| . $locale->text('Quotation Number') . qq|</th>
97 <td colspan=3><input name=quonumber size=20></td>
101 $label{check}{chknumber} = qq|
103 <th align=right nowrap>| . $locale->text('Reference') . qq|</th>
104 <td colspan=3><input name=chknumber size=20></td>
108 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
109 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
110 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
111 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
112 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
113 $label{receipt}{rctnumber} = $label{check}{chknumber};
115 # do one call to text
117 $locale->text('Print') . " "
118 . $locale->text($label{ $form->{type} }{title});
120 if ($form->{type} =~ /(check|receipt)/) {
121 if (BP->payment_accounts(\%myconfig, \%$form)) {
124 <th align=right>| . $locale->text('Account') . qq|</th>
127 if ($form->{accounts}) {
129 <td colspan=3><select name=account>
131 foreach $ref (@{ $form->{accounts} }) {
133 <option>$ref->{accno}--$ref->{description}
142 <td colspan=3><input name=account></td>
154 # use JavaScript Calendar or not
155 $form->{jsscript} = $jscalendar;
157 if ($form->{jsscript}) {
159 # with JavaScript Calendar
161 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
162 <input type=button name=transdatefrom id="trigger1" value=|
163 . $locale->text('button')
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')
175 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
176 "transdateto", "BL", "trigger2");
179 # without JavaScript Calendar
181 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
183 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
191 <form method=post action=$form->{script}>
193 <input type=hidden name=vc value=$form->{vc}>
194 <input type=hidden name=type value=$form->{type}>
195 <input type=hidden name=title value="$form->{title}">
198 <tr><th class=listtop>$form->{title}</th></tr>
204 <th align=right>Kunde</th>
205 <td colspan=3>$name</td>
208 $label{$form->{type}}{invnumber}
209 $label{$form->{type}}{ordnumber}
210 $label{$form->{type}}{quonumber}
211 $label{$form->{type}}{chknumber}
212 $label{$form->{type}}{rctnumber}
214 <th align=right nowrap>| . $locale->text('From') . qq|</th>
216 <th align=right>| . $locale->text('Bis') . qq|</th>
219 <input type=hidden name=sort value=transdate>
224 <td><hr size=3 noshade></td>
228 <input type=hidden name=nextsub value=list_spool>
230 <input type=hidden name=path value=$form->{path}>
231 <input type=hidden name=login value=$form->{login}>
232 <input type=hidden name=password value=$form->{password}>
235 <input class=submit type=submit name=action value="|
236 . $locale->text('Continue') . qq|">
247 $lxdebug->leave_sub();
251 $lxdebug->enter_sub();
255 for $i (1 .. $form->{rowcount}) {
256 if ($form->{"checked_$i"}) {
262 $form->error('Nothing selected!') unless $selected;
264 $form->{title} = $locale->text('Confirm!');
271 <form method=post action=$form->{script}>
274 map { delete $form->{$_} } qw(action header);
276 foreach $key (keys %$form) {
277 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
281 <h2 class=confirm>$form->{title}</h2>
285 'Are you sure you want to remove the marked entries from the queue?')
288 <input name=action class=submit type=submit value="|
289 . $locale->text('Yes') . qq|">
296 $lxdebug->leave_sub();
300 $lxdebug->enter_sub();
302 $form->info($locale->text('Removing marked entries from queue ...'));
303 $form->{callback} .= "&header=1" if $form->{callback};
305 $form->redirect($locale->text('Removed spoolfiles!'))
306 if (BP->delete_spool(\%myconfig, \%$form, $spool));
307 $form->error($locale->text('Cannot remove files!'));
309 $lxdebug->leave_sub();
313 $lxdebug->enter_sub();
315 if ($form->{callback}) {
316 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
317 (1 .. $form->{rowcount});
318 $form->{callback} .= "&header=1";
321 for $i (1 .. $form->{rowcount}) {
322 if ($form->{"checked_$i"}) {
323 $form->{OUT} = "| $myconfig{printer}";
324 $form->info($locale->text('Printing ... '));
326 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
327 print $locale->text('done');
328 $form->redirect($locale->text('Marked entries printed!'));
334 $form->error('Nothing selected!');
336 $lxdebug->leave_sub();
340 $lxdebug->enter_sub();
342 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
343 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
344 split(/--/, $form->{ $form->{vc} });
346 BP->get_spoolfiles(\%myconfig, \%$form);
348 $title = $form->escape($form->{title});
350 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
352 $title = $form->escape($form->{title}, 1);
354 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
356 if ($form->{ $form->{vc} }) {
357 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
358 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
360 ($form->{vc} eq 'customer')
361 ? $locale->text('Customer')
362 : $locale->text('Vendor');
363 $option .= " : $form->{$form->{vc}}";
365 if ($form->{account}) {
366 $callback .= "&account=" . $form->escape($form->{account}, 1);
367 $href .= "&account=" . $form->escape($form->{account});
368 $option .= "\n<br>" if ($option);
369 $option .= $locale->text('Account') . " : $form->{account}";
371 if ($form->{invnumber}) {
372 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
373 $href .= "&invnumber=" . $form->escape($form->{invnumber});
374 $option .= "\n<br>" if ($option);
375 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
377 if ($form->{ordnumber}) {
378 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
379 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
380 $option .= "\n<br>" if ($option);
381 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
383 if ($form->{quonumber}) {
384 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
385 $href .= "&quonumber=" . $form->escape($form->{quonumber});
386 $option .= "\n<br>" if ($option);
387 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
390 if ($form->{transdatefrom}) {
391 $callback .= "&transdatefrom=$form->{transdatefrom}";
392 $href .= "&transdatefrom=$form->{transdatefrom}";
393 $option .= "\n<br>" if ($option);
395 $locale->text('From') . " "
396 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
398 if ($form->{transdateto}) {
399 $callback .= "&transdateto=$form->{transdateto}";
400 $href .= "&transdateto=$form->{transdateto}";
401 $option .= "\n<br>" if ($option);
403 $locale->text('To') . " "
404 . $locale->date(\%myconfig, $form->{transdateto}, 1);
407 $name = ucfirst $form->{vc};
409 @columns = (transdate);
410 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
411 push @columns, "invnumber";
413 if ($form->{type} =~ /_order$/) {
414 push @columns, "ordnumber";
416 if ($form->{type} =~ /_quotation$/) {
417 push @columns, "quonumber";
420 push @columns, (name, spoolfile);
421 @column_index = $form->sort_columns(@columns);
422 unshift @column_index, "checked";
424 $column_header{checked} = "<th class=listheading> </th>";
425 $column_header{transdate} =
426 "<th><a class=listheading href=$href&sort=transdate>"
427 . $locale->text('Date')
429 $column_header{invnumber} =
430 "<th><a class=listheading href=$href&sort=invnumber>"
431 . $locale->text('Invoice')
433 $column_header{ordnumber} =
434 "<th><a class=listheading href=$href&sort=ordnumber>"
435 . $locale->text('Order')
437 $column_header{quonumber} =
438 "<th><a class=listheading href=$href&sort=quonumber>"
439 . $locale->text('Quotation')
441 $column_header{name} =
442 "<th><a class=listheading href=$href&sort=name>"
443 . $locale->text($name)
445 $column_header{spoolfile} =
446 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
453 <form method=post action=$form->{script}>
457 <th class=listtop>$form->{title}</th>
466 <tr class=listheading>
469 map { print "\n$column_header{$_}" } @column_index;
475 # add sort and escape callback, this one we use for the add sub
476 $form->{callback} = $callback .= "&sort=$form->{sort}";
478 # escape callback for href
479 $callback = $form->escape($callback);
483 foreach $ref (@{ $form->{SPOOL} }) {
487 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
489 if ($ref->{invoice}) {
490 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
492 $module = "$ref->{module}.pl";
494 $column_data{transdate} = "<td>$ref->{transdate} </td>";
496 if ($spoolfile eq $ref->{spoolfile}) {
497 $column_data{checked} = qq|<td></td>|;
499 $column_data{checked} =
500 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
503 $column_data{invnumber} =
504 "<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>";
505 $column_data{ordnumber} =
506 "<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>";
507 $column_data{quonumber} =
508 "<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>";
509 $column_data{name} = "<td>$ref->{name}</td>";
510 $column_data{spoolfile} =
511 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
512 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
515 $spoolfile = $ref->{spoolfile};
523 map { print "\n$column_data{$_}" } @column_index;
532 <input type=hidden name=rowcount value=$i>
538 <td><hr size=3 noshade></td>
544 <input name=callback type=hidden value="$form->{callback}">
546 <input type=hidden name=title value="$form->{title}">
547 <input type=hidden name=vc value="$form->{vc}">
548 <input type=hidden name=type value="$form->{type}">
549 <input type=hidden name=sort value="$form->{sort}">
551 <input type=hidden name=account value="$form->{account}">
553 <input type=hidden name=path value=$form->{path}>
554 <input type=hidden name=login value=$form->{login}>
555 <input type=hidden name=password value=$form->{password}>
558 if ($myconfig{printer}) {
560 <input class=submit type=submit name=action value="|
561 . $locale->text('Select all') . qq|">
562 <input class=submit type=submit name=action value="|
563 . $locale->text('Print') . qq|">
564 <input class=submit type=submit name=action value="|
565 . $locale->text('Remove') . qq|">
569 if ($form->{menubar}) {
570 require "$form->{path}/menu.pl";
581 $lxdebug->leave_sub();
585 $lxdebug->enter_sub();
587 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
590 $lxdebug->leave_sub();
593 sub continue { &{ $form->{nextsub} } }