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') . qq|></td>
166 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
167 <input type=button name=transdateto name=transdateto id="trigger2" value=|
168 . $locale->text('button') . qq|></td>
173 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
174 "transdateto", "BL", "trigger2");
177 # without JavaScript Calendar
179 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
181 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
189 <form method=post action=$form->{script}>
191 <input type=hidden name=vc value=$form->{vc}>
192 <input type=hidden name=type value=$form->{type}>
193 <input type=hidden name=title value="$form->{title}">
196 <tr><th class=listtop>$form->{title}</th></tr>
202 <th align=right>Kunde</th>
203 <td colspan=3>$name</td>
206 $label{$form->{type}}{invnumber}
207 $label{$form->{type}}{ordnumber}
208 $label{$form->{type}}{quonumber}
209 $label{$form->{type}}{chknumber}
210 $label{$form->{type}}{rctnumber}
212 <th align=right nowrap>| . $locale->text('From') . qq|</th>
214 <th align=right>| . $locale->text('Bis') . qq|</th>
217 <input type=hidden name=sort value=transdate>
222 <td><hr size=3 noshade></td>
226 <input type=hidden name=nextsub value=list_spool>
228 <input type=hidden name=path value=$form->{path}>
229 <input type=hidden name=login value=$form->{login}>
230 <input type=hidden name=password value=$form->{password}>
233 <input class=submit type=submit name=action value="|
234 . $locale->text('Continue') . qq|">
245 $lxdebug->leave_sub();
249 $lxdebug->enter_sub();
253 for $i (1 .. $form->{rowcount}) {
254 if ($form->{"checked_$i"}) {
260 $form->error('Nothing selected!') unless $selected;
262 $form->{title} = $locale->text('Confirm!');
269 <form method=post action=$form->{script}>
272 map { delete $form->{$_} } qw(action header);
274 foreach $key (keys %$form) {
275 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
279 <h2 class=confirm>$form->{title}</h2>
283 'Are you sure you want to remove the marked entries from the queue?')
286 <input name=action class=submit type=submit value="|
287 . $locale->text('Yes') . qq|">
294 $lxdebug->leave_sub();
298 $lxdebug->enter_sub();
300 $form->info($locale->text('Removing marked entries from queue ...'));
301 $form->{callback} .= "&header=1" if $form->{callback};
303 $form->redirect($locale->text('Removed spoolfiles!'))
304 if (BP->delete_spool(\%myconfig, \%$form, $spool));
305 $form->error($locale->text('Cannot remove files!'));
307 $lxdebug->leave_sub();
311 $lxdebug->enter_sub();
313 if ($form->{callback}) {
314 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
315 (1 .. $form->{rowcount});
316 $form->{callback} .= "&header=1";
319 for $i (1 .. $form->{rowcount}) {
320 if ($form->{"checked_$i"}) {
321 $form->{OUT} = "| $myconfig{printer}";
322 $form->info($locale->text('Printing ... '));
324 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
325 print $locale->text('done');
326 $form->redirect($locale->text('Marked entries printed!'));
332 $form->error('Nothing selected!');
334 $lxdebug->leave_sub();
338 $lxdebug->enter_sub();
340 $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
341 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
342 split(/--/, $form->{ $form->{vc} });
344 BP->get_spoolfiles(\%myconfig, \%$form);
346 $title = $form->escape($form->{title});
348 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
350 $title = $form->escape($form->{title}, 1);
352 "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
354 if ($form->{ $form->{vc} }) {
355 $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
356 $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
358 ($form->{vc} eq 'customer')
359 ? $locale->text('Customer')
360 : $locale->text('Vendor');
361 $option .= " : $form->{$form->{vc}}";
363 if ($form->{account}) {
364 $callback .= "&account=" . $form->escape($form->{account}, 1);
365 $href .= "&account=" . $form->escape($form->{account});
366 $option .= "\n<br>" if ($option);
367 $option .= $locale->text('Account') . " : $form->{account}";
369 if ($form->{invnumber}) {
370 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
371 $href .= "&invnumber=" . $form->escape($form->{invnumber});
372 $option .= "\n<br>" if ($option);
373 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
375 if ($form->{ordnumber}) {
376 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
377 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
378 $option .= "\n<br>" if ($option);
379 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
381 if ($form->{quonumber}) {
382 $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
383 $href .= "&quonumber=" . $form->escape($form->{quonumber});
384 $option .= "\n<br>" if ($option);
385 $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
388 if ($form->{transdatefrom}) {
389 $callback .= "&transdatefrom=$form->{transdatefrom}";
390 $href .= "&transdatefrom=$form->{transdatefrom}";
391 $option .= "\n<br>" if ($option);
393 $locale->text('From') . " "
394 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
396 if ($form->{transdateto}) {
397 $callback .= "&transdateto=$form->{transdateto}";
398 $href .= "&transdateto=$form->{transdateto}";
399 $option .= "\n<br>" if ($option);
401 $locale->text('To') . " "
402 . $locale->date(\%myconfig, $form->{transdateto}, 1);
405 $name = ucfirst $form->{vc};
407 @columns = (transdate);
408 if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
409 push @columns, "invnumber";
411 if ($form->{type} =~ /_order$/) {
412 push @columns, "ordnumber";
414 if ($form->{type} =~ /_quotation$/) {
415 push @columns, "quonumber";
418 push @columns, (name, spoolfile);
419 @column_index = $form->sort_columns(@columns);
420 unshift @column_index, "checked";
422 $column_header{checked} = "<th class=listheading> </th>";
423 $column_header{transdate} =
424 "<th><a class=listheading href=$href&sort=transdate>"
425 . $locale->text('Date')
427 $column_header{invnumber} =
428 "<th><a class=listheading href=$href&sort=invnumber>"
429 . $locale->text('Invoice')
431 $column_header{ordnumber} =
432 "<th><a class=listheading href=$href&sort=ordnumber>"
433 . $locale->text('Order')
435 $column_header{quonumber} =
436 "<th><a class=listheading href=$href&sort=quonumber>"
437 . $locale->text('Quotation')
439 $column_header{name} =
440 "<th><a class=listheading href=$href&sort=name>"
441 . $locale->text($name)
443 $column_header{spoolfile} =
444 "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
451 <form method=post action=$form->{script}>
455 <th class=listtop>$form->{title}</th>
464 <tr class=listheading>
467 map { print "\n$column_header{$_}" } @column_index;
473 # add sort and escape callback, this one we use for the add sub
474 $form->{callback} = $callback .= "&sort=$form->{sort}";
476 # escape callback for href
477 $callback = $form->escape($callback);
481 foreach $ref (@{ $form->{SPOOL} }) {
485 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
487 if ($ref->{invoice}) {
488 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
490 $module = "$ref->{module}.pl";
492 $column_data{transdate} = "<td>$ref->{transdate} </td>";
494 if ($spoolfile eq $ref->{spoolfile}) {
495 $column_data{checked} = qq|<td></td>|;
497 $column_data{checked} =
498 qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
501 $column_data{invnumber} =
502 "<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>";
503 $column_data{ordnumber} =
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->{ordnumber}</a></td>";
505 $column_data{quonumber} =
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->{quonumber}</a></td>";
507 $column_data{name} = "<td>$ref->{name}</td>";
508 $column_data{spoolfile} =
509 qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
510 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
513 $spoolfile = $ref->{spoolfile};
521 map { print "\n$column_data{$_}" } @column_index;
530 <input type=hidden name=rowcount value=$i>
536 <td><hr size=3 noshade></td>
542 <input name=callback type=hidden value="$form->{callback}">
544 <input type=hidden name=title value="$form->{title}">
545 <input type=hidden name=vc value="$form->{vc}">
546 <input type=hidden name=type value="$form->{type}">
547 <input type=hidden name=sort value="$form->{sort}">
549 <input type=hidden name=account value="$form->{account}">
551 <input type=hidden name=path value=$form->{path}>
552 <input type=hidden name=login value=$form->{login}>
553 <input type=hidden name=password value=$form->{password}>
556 if ($myconfig{printer}) {
558 <input type=hidden name=transdateto value=$form->{transdateto}>
559 <input type=hidden name=transdatefrom value=$form->{transdatefrom}>
560 <input type=hidden name=invnumber value=$form->{invnumber}>
561 <input type=hidden name=ordnumber value=$form->{ordnumber}>
562 <input type=hidden name=quonumber value=$form->{quonumber}>
563 <input type=hidden name=customer value=$form->{customer}>
564 <input type=hidden name=vendor value=$form->{vendor}>
565 <input class=submit type=submit name=action value="|
566 . $locale->text('Select all') . qq|">
567 <input class=submit type=submit name=action value="|
568 . $locale->text('Print') . qq|">
569 <input class=submit type=submit name=action value="|
570 . $locale->text('Remove') . qq|">
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} } }