1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
26 #======================================================================
37 # $locale->text('Sales Invoices')
38 # $locale->text('Packing Lists')
39 # $locale->text('Pick Lists')
40 # $locale->text('Sales Orders')
41 # $locale->text('Work Orders')
42 # $locale->text('Purchase Orders')
43 # $locale->text('Bin Lists')
44 # $locale->text('Quotations')
45 # $locale->text('RFQs')
46 # $locale->text('Checks')
47 # $locale->text('Receipts')
49 # setup customer/vendor selection
50 BP->get_vc(\%myconfig, \%$form);
52 if (@{ $form->{"all_$form->{vc}"} }) {
53 map { $name .= "<option>$_->{name}--$_->{id}\n" } @{ $form->{"all_$form->{vc}"} };
54 $name = qq|<select name=$form->{vc}><option>\n$name</select>|;
56 $name = qq|<input name=$form->{vc} size=35>|;
59 # $locale->text('Customer')
60 # $locale->text('Vendor')
62 %label = ( invoice => { title => 'Sales Invoices', name => 'Customer' },
63 packing_list => { title => 'Packing Lists', name => 'Customer' },
64 pick_list => { title => 'Pick Lists', name => 'Customer' },
65 sales_order => { title => 'Sales Orders', name => 'Customer' },
66 work_order => { title => 'Work Orders', name => 'Customer' },
67 purchase_order => { title => 'Purchase Orders', name => 'Vendor' },
68 bin_list => { title => 'Bin Lists', name => 'Vendor' },
69 sales_quotation => { title => 'Quotations', name => 'Customer' },
70 request_quotation => { title => 'RFQs', name => 'Vendor' },
71 check => { title => 'Checks', name => 'Vendor' },
72 receipt => { title => 'Receipts', name => 'Customer' }
75 $label{invoice}{invnumber} = qq|
77 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
78 <td colspan=3><input name=invnumber size=20></td>
81 $label{invoice}{ordnumber} = qq|
83 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
84 <td colspan=3><input name=ordnumber size=20></td>
87 $label{sales_quotation}{quonumber} = qq|
89 <th align=right nowrap>|.$locale->text('Quotation Number').qq|</th>
90 <td colspan=3><input name=quonumber size=20></td>
94 $label{check}{chknumber} = qq|
96 <th align=right nowrap>|.$locale->text('Reference').qq|</th>
97 <td colspan=3><input name=chknumber size=20></td>
101 $label{packing_list}{invnumber} = $label{invoice}{invnumber};
102 $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
103 $label{pick_list}{invnumber} = $label{invoice}{invnumber};
104 $label{pick_list}{ordnumber} = $label{invoice}{ordnumber};
105 $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
106 $label{work_order}{ordnumber} = $label{invoice}{ordnumber};
107 $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
108 $label{bin_list}{ordnumber} = $label{invoice}{ordnumber};
109 $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
110 $label{receipt}{rctnumber} = $label{check}{chknumber};
112 # do one call to text
113 $form->{title} = $locale->text('Print')." ".$locale->text($label{$form->{type}}{title});
115 if ($form->{type} =~ /(check|receipt)/) {
116 if (BP->payment_accounts(\%myconfig, \%$form)) {
119 <th align=right>|.$locale->text('Account').qq|</th>
122 if ($form->{accounts}) {
124 <td colspan=3><select name=account>
126 foreach $ref (@{ $form->{accounts} }) {
128 <option>$ref->{accno}--$ref->{description}
137 <td colspan=3><input name=account></td>
151 $form->{selectaccountingyear} = "<option>\n";
152 map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
153 $form->{selectaccountingmonth} = "<option>\n";
154 map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
158 <th align=right>|.$locale->text('Period').qq|</th>
160 <select name=month>$form->{selectaccountingmonth}</select>
161 <select name=year>$form->{selectaccountingyear}</select>
162 <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
163 <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
164 <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
165 <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
176 <form method=post action=$form->{script}>
178 <input type=hidden name=vc value=$form->{vc}>
179 <input type=hidden name=type value=$form->{type}>
180 <input type=hidden name=title value="$form->{title}">
183 <tr><th class=listtop>$form->{title}</th></tr>
189 <th align=right>|.$locale->text($label{$form->{type}}{name}).qq|</th>
190 <td colspan=3>$name</td>
193 $label{$form->{type}}{invnumber}
194 $label{$form->{type}}{ordnumber}
195 $label{$form->{type}}{quonumber}
196 $label{$form->{type}}{chknumber}
197 $label{$form->{type}}{rctnumber}
199 <th align=right nowrap>|.$locale->text('From').qq|</th>
200 <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
201 <th align=right>|.$locale->text('To').qq|</th>
202 <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
204 <input type=hidden name=sort value=transdate>
210 <td><hr size=3 noshade></td>
214 <input type=hidden name=nextsub value=list_spool>
216 <input type=hidden name=path value=$form->{path}>
217 <input type=hidden name=login value=$form->{login}>
218 <input type=hidden name=sessionid value=$form->{sessionid}>
221 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
237 for $i (1 .. $form->{rowcount}) {
238 if ($form->{"checked_$i"}) {
244 $form->error('Nothing selected!') unless $selected;
246 $form->{title} = $locale->text('Confirm!');
253 <form method=post action=$form->{script}>
256 map { delete $form->{$_} } qw(action header);
258 foreach $key (keys %$form) {
259 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
263 <h2 class=confirm>$form->{title}</h2>
265 <h4>|.$locale->text('Are you sure you want to remove the marked entries from the queue?').qq|</h4>
267 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
280 $form->info($locale->text('Removing marked entries from queue ...'));
281 $form->{callback} .= "&header=1" if $form->{callback};
283 $form->redirect($locale->text('Removed spoolfiles!')) if (BP->delete_spool(\%myconfig, \%$form, $spool));
284 $form->error($locale->text('Cannot remove files!'));
291 if ($form->{callback}) {
292 map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} } (1 .. $form->{rowcount});
293 $form->{callback} .= "&header=1";
296 for $i (1 .. $form->{rowcount}) {
297 if ($form->{"checked_$i"}) {
298 $form->{OUT} = "| $printer{$form->{media}}";
299 $form->info($locale->text('Printing ... '));
301 if (BP->print_spool(\%myconfig, \%$form, $spool)) {
302 print $locale->text('done');
303 $form->redirect($locale->text('Marked entries printed!'));
309 $form->error('Nothing selected!');
316 $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
317 ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
319 BP->get_spoolfiles(\%myconfig, \%$form);
321 $title = $form->escape($form->{title});
322 $href = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
326 $title = $form->escape($form->{title},1);
327 $callback = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
329 if ($form->{$form->{vc}}) {
330 $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1);
331 $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}});
332 $option = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
333 $option .= " : $form->{$form->{vc}}";
335 if ($form->{account}) {
336 $callback .= "&account=".$form->escape($form->{account},1);
337 $href .= "&account=".$form->escape($form->{account});
338 $option .= "\n<br>" if ($option);
339 $option .= $locale->text('Account')." : $form->{account}";
341 if ($form->{invnumber}) {
342 $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
343 $href .= "&invnumber=".$form->escape($form->{invnumber});
344 $option .= "\n<br>" if ($option);
345 $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
347 if ($form->{ordnumber}) {
348 $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
349 $href .= "&ordnumber=".$form->escape($form->{ordnumber});
350 $option .= "\n<br>" if ($option);
351 $option .= $locale->text('Order Number')." : $form->{ordnumber}";
353 if ($form->{quonumber}) {
354 $callback .= "&quonumber=".$form->escape($form->{quonumber},1);
355 $href .= "&quonumber=".$form->escape($form->{quonumber});
356 $option .= "\n<br>" if ($option);
357 $option .= $locale->text('Quotation Number')." : $form->{quonumber}";
360 if ($form->{transdatefrom}) {
361 $callback .= "&transdatefrom=$form->{transdatefrom}";
362 $href .= "&transdatefrom=$form->{transdatefrom}";
363 $option .= "\n<br>" if ($option);
364 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
366 if ($form->{transdateto}) {
367 $callback .= "&transdateto=$form->{transdateto}";
368 $href .= "&transdateto=$form->{transdateto}";
369 $option .= "\n<br>" if ($option);
370 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
373 $name = ucfirst $form->{vc};
375 @columns = qw(transdate);
376 if ($form->{type} =~ /(invoice|check|receipt)/) {
377 push @columns, "invnumber";
379 if ($form->{type} =~ /(packing|pick)_list/) {
380 push @columns, "invnumber";
382 if ($form->{type} =~ /_(order|list)$/) {
383 push @columns, "ordnumber";
385 if ($form->{type} =~ /_quotation$/) {
386 push @columns, "quonumber";
389 push @columns, (name, spoolfile);
390 @column_index = $form->sort_columns(@columns);
391 unshift @column_index, "checked";
393 $column_header{checked} = "<th class=listheading> </th>";
394 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
395 $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
396 $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
397 $column_header{quonumber} = "<th><a class=listheading href=$href&sort=quonumber>".$locale->text('Quotation')."</a></th>";
398 $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text($name)."</a></th>";
399 $column_header{spoolfile} = "<th class=listheading>".$locale->text('Spoolfile')."</th>";
407 <form method=post action=$form->{script}>
411 <th class=listtop>$form->{title}</th>
420 <tr class=listheading>
423 map { print "\n$column_header{$_}" } @column_index;
430 # add sort and escape callback, this one we use for the add sub
431 $form->{callback} = $callback .= "&sort=$form->{sort}";
433 # escape callback for href
434 $callback = $form->escape($callback);
438 foreach $ref (@{ $form->{SPOOL} }) {
442 $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
444 # this is for audittrail
445 $form->{module} = $ref->{module};
447 if ($ref->{invoice}) {
448 $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
450 $module = "$ref->{module}.pl";
452 $column_data{transdate} = "<td>$ref->{transdate} </td>";
454 if ($spoolfile eq $ref->{spoolfile}) {
455 $column_data{checked} = qq|<td></td>|;
457 $column_data{checked} = qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
460 if ($ref->{module} eq 'oe') {
461 $column_data{invnumber} = qq|<td> </td>|;
462 $column_data{ordnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>
463 <input type=hidden name="reference_$i" value="$ref->{ordnumber}">|;
465 $column_data{quonumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>
466 <input type=hidden name="reference_$i" value="$ref->{quonumber}">|;
469 $column_data{ordnumber} = qq|<td>$ref->{ordnumber}</td>|;
470 $column_data{quonumber} = qq|<td>$ref->{quonumber}</td>|;
471 $column_data{invnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>
472 <input type=hidden name="reference_$i" value="$ref->{invnumber}">|;
476 $column_data{name} = "<td>$ref->{name}</td>";
477 $column_data{spoolfile} = qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
481 $spoolfile = $ref->{spoolfile};
488 map { print "\n$column_data{$_}" } @column_index;
491 <input type=hidden name="id_$i" value=$ref->{id}>
492 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
500 <input type=hidden name=rowcount value=$i>
506 <td><hr size=3 noshade></td>
512 <input name=callback type=hidden value="$form->{callback}">
514 <input type=hidden name=title value="$form->{title}">
515 <input type=hidden name=vc value="$form->{vc}">
516 <input type=hidden name=type value="$form->{type}">
517 <input type=hidden name=sort value="$form->{sort}">
518 <input type=hidden name=module value=$form->{module}>
520 <input type=hidden name=account value="$form->{account}">
522 <input type=hidden name=path value=$form->{path}>
523 <input type=hidden name=login value=$form->{login}>
524 <input type=hidden name=sessionid value=$form->{sessionid}>
527 if (%printer && $latex) {
528 foreach $key (sort keys %printer) {
530 <input name=media type=radio class=radio value="$key" |;
531 print qq|checked| if $key eq $myconfig{printer};
537 <input class=submit type=submit name=action value="|.$locale->text('Select all').qq|">
538 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
539 <input class=submit type=submit name=action value="|.$locale->text('Remove').qq|">
543 if ($form->{menubar}) {
544 require "$form->{path}/menu.pl";
560 map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
566 sub continue { &{ $form->{nextsub} } };