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>
 
 284     . $locale->text('Are you sure you want to remove the marked entries from the queue?')
 
 287 <input name=action class=submit type=submit value="|
 
 288     . $locale->text('Yes') . qq|">
 
 295   $lxdebug->leave_sub();
 
 299   $lxdebug->enter_sub();
 
 301   $form->info($locale->text('Removing marked entries from queue ...'));
 
 302   $form->{callback} .= "&header=1" if $form->{callback};
 
 304   $form->redirect($locale->text('Removed spoolfiles!'))
 
 305     if (BP->delete_spool(\%myconfig, \%$form, $spool));
 
 306   $form->error($locale->text('Cannot remove files!'));
 
 308   $lxdebug->leave_sub();
 
 312   $lxdebug->enter_sub();
 
 314   if ($form->{callback}) {
 
 315     map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
 
 316       (1 .. $form->{rowcount});
 
 317     $form->{callback} .= "&header=1";
 
 320   for $i (1 .. $form->{rowcount}) {
 
 321     if ($form->{"checked_$i"}) {
 
 322       $form->{OUT} = "| $myconfig{printer}";
 
 323       $form->info($locale->text('Printing ... '));
 
 325       if (BP->print_spool(\%myconfig, \%$form, $spool)) {
 
 326         print $locale->text('done');
 
 327         $form->redirect($locale->text('Marked entries printed!'));
 
 333   $form->error('Nothing selected!');
 
 335   $lxdebug->leave_sub();
 
 339   $lxdebug->enter_sub();
 
 341   $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} });
 
 342   ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
 
 343     split(/--/, $form->{ $form->{vc} });
 
 345   BP->get_spoolfiles(\%myconfig, \%$form);
 
 347   $title = $form->escape($form->{title});
 
 349     "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
 
 351   $title = $form->escape($form->{title}, 1);
 
 353     "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title";
 
 355   if ($form->{ $form->{vc} }) {
 
 356     $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1);
 
 357     $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} });
 
 359       ($form->{vc} eq 'customer')
 
 360       ? $locale->text('Customer')
 
 361       : $locale->text('Vendor');
 
 362     $option .= " : $form->{$form->{vc}}";
 
 364   if ($form->{account}) {
 
 365     $callback .= "&account=" . $form->escape($form->{account}, 1);
 
 366     $href .= "&account=" . $form->escape($form->{account});
 
 367     $option .= "\n<br>" if ($option);
 
 368     $option .= $locale->text('Account') . " : $form->{account}";
 
 370   if ($form->{invnumber}) {
 
 371     $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
 
 372     $href .= "&invnumber=" . $form->escape($form->{invnumber});
 
 373     $option .= "\n<br>" if ($option);
 
 374     $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
 
 376   if ($form->{ordnumber}) {
 
 377     $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
 
 378     $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
 
 379     $option .= "\n<br>" if ($option);
 
 380     $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
 
 382   if ($form->{quonumber}) {
 
 383     $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1);
 
 384     $href .= "&quonumber=" . $form->escape($form->{quonumber});
 
 385     $option .= "\n<br>" if ($option);
 
 386     $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
 
 389   if ($form->{transdatefrom}) {
 
 390     $callback .= "&transdatefrom=$form->{transdatefrom}";
 
 391     $href     .= "&transdatefrom=$form->{transdatefrom}";
 
 392     $option   .= "\n<br>" if ($option);
 
 394         $locale->text('From') . " "
 
 395       . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
 397   if ($form->{transdateto}) {
 
 398     $callback .= "&transdateto=$form->{transdateto}";
 
 399     $href     .= "&transdateto=$form->{transdateto}";
 
 400     $option   .= "\n<br>" if ($option);
 
 402         $locale->text('To') . " "
 
 403       . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
 406   $name = ucfirst $form->{vc};
 
 408   @columns = (transdate);
 
 409   if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) {
 
 410     push @columns, "invnumber";
 
 412   if ($form->{type} =~ /_order$/) {
 
 413     push @columns, "ordnumber";
 
 415   if ($form->{type} =~ /_quotation$/) {
 
 416     push @columns, "quonumber";
 
 419   push @columns, (name, spoolfile);
 
 420   @column_index = $form->sort_columns(@columns);
 
 421   unshift @column_index, "checked";
 
 423   $column_header{checked}   = "<th class=listheading> </th>";
 
 424   $column_header{transdate} =
 
 425       "<th><a class=listheading href=$href&sort=transdate>"
 
 426     . $locale->text('Date')
 
 428   $column_header{invnumber} =
 
 429       "<th><a class=listheading href=$href&sort=invnumber>"
 
 430     . $locale->text('Invoice')
 
 432   $column_header{ordnumber} =
 
 433       "<th><a class=listheading href=$href&sort=ordnumber>"
 
 434     . $locale->text('Order')
 
 436   $column_header{quonumber} =
 
 437       "<th><a class=listheading href=$href&sort=quonumber>"
 
 438     . $locale->text('Quotation')
 
 440   $column_header{name} =
 
 441       "<th><a class=listheading href=$href&sort=name>"
 
 442     . $locale->text($name)
 
 444   $column_header{spoolfile} =
 
 445     "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
 
 452 <form method=post action=$form->{script}>
 
 456     <th class=listtop>$form->{title}</th>
 
 465         <tr class=listheading>
 
 468   map { print "\n$column_header{$_}" } @column_index;
 
 474   # add sort and escape callback, this one we use for the add sub
 
 475   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
 477   # escape callback for href
 
 478   $callback = $form->escape($callback);
 
 482   foreach $ref (@{ $form->{SPOOL} }) {
 
 486     $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
 
 488     if ($ref->{invoice}) {
 
 489       $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
 
 491     $module = "$ref->{module}.pl";
 
 493     $column_data{transdate} = "<td>$ref->{transdate} </td>";
 
 495     if ($spoolfile eq $ref->{spoolfile}) {
 
 496       $column_data{checked} = qq|<td></td>|;
 
 498       $column_data{checked} =
 
 499         qq|<td><input name=checked_$i type=checkbox style=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
 
 502     $column_data{invnumber} =
 
 503       "<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>";
 
 504     $column_data{ordnumber} =
 
 505       "<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>";
 
 506     $column_data{quonumber} =
 
 507       "<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>";
 
 508     $column_data{name}      = "<td>$ref->{name}</td>";
 
 509     $column_data{spoolfile} =
 
 510       qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
 
 511 <input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
 
 514     $spoolfile = $ref->{spoolfile};
 
 522     map { print "\n$column_data{$_}" } @column_index;
 
 531 <input type=hidden name=rowcount value=$i>
 
 537     <td><hr size=3 noshade></td>
 
 543 <input name=callback type=hidden value="$form->{callback}">
 
 545 <input type=hidden name=title value="$form->{title}">
 
 546 <input type=hidden name=vc value="$form->{vc}">
 
 547 <input type=hidden name=type value="$form->{type}">
 
 548 <input type=hidden name=sort value="$form->{sort}">
 
 550 <input type=hidden name=account value="$form->{account}">
 
 552 <input type=hidden name=path value=$form->{path}>
 
 553 <input type=hidden name=login value=$form->{login}>
 
 554 <input type=hidden name=password value=$form->{password}>
 
 557   if ($myconfig{printer}) {
 
 559 <input class=submit type=submit name=action value="|
 
 560       . $locale->text('Select all') . qq|">
 
 561 <input class=submit type=submit name=action value="|
 
 562       . $locale->text('Print') . qq|">
 
 563 <input class=submit type=submit name=action value="|
 
 564       . $locale->text('Remove') . qq|">
 
 568   if ($form->{menubar}) {
 
 569     require "$form->{path}/menu.pl";
 
 580   $lxdebug->leave_sub();
 
 584   $lxdebug->enter_sub();
 
 586   map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount});
 
 589   $lxdebug->leave_sub();
 
 592 sub continue { &{ $form->{nextsub} } }