1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
   9 # Copyright (c) 1998-2002
 
  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 #======================================================================
 
  30 # project administration
 
  31 # partsgroup administration
 
  33 #======================================================================
 
  42   $lxdebug->enter_sub();
 
  44   $form->{title} = "Add";
 
  48     "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  49     unless $form->{callback};
 
  51   &{"form_$form->{type}_header"};
 
  52   &{"form_$form->{type}_footer"};
 
  54   $lxdebug->leave_sub();
 
  58   $lxdebug->enter_sub();
 
  60   $form->{title} = "Edit";
 
  62   if ($form->{type} eq 'project') {
 
  63     PE->get_project(\%myconfig, \%$form);
 
  65   if ($form->{type} eq 'partsgroup') {
 
  66     PE->get_partsgroup(\%myconfig, \%$form);
 
  68   if ($form->{type} eq 'pricegroup') {
 
  69     PE->get_pricegroup(\%myconfig, \%$form);
 
  71   &{"form_$form->{type}_header"};
 
  72   &{"form_$form->{type}_footer"};
 
  74   $lxdebug->leave_sub();
 
  78   $lxdebug->enter_sub();
 
  80   if ($form->{type} eq 'project') {
 
  81     $report        = "project_report";
 
  82     $sort          = 'projectnumber';
 
  83     $form->{title} = $locale->text('Projects');
 
  87           <th align=right width=1%>| . $locale->text('Number') . qq|</th>
 
  88           <td><input name=projectnumber size=20></td>
 
  91           <th align=right>| . $locale->text('Description') . qq|</th>
 
  92           <td><input name=description size=60></td>
 
  97   if ($form->{type} eq 'partsgroup') {
 
  98     $report        = "partsgroup_report";
 
 100     $form->{title} = $locale->text('Groups');
 
 104           <th align=right width=1%>| . $locale->text('Group') . qq|</th>
 
 105           <td><input name=partsgroup size=20></td>
 
 112   if ($form->{type} eq 'pricegroup') {
 
 113     $report        = "pricegroup_report";
 
 114     $sort          = 'pricegroup';
 
 115     $form->{title} = $locale->text('Pricegroup');
 
 119           <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
 
 120           <td><input name=pricegroup size=20></td>
 
 131 <form method=post action=$form->{script}>
 
 133 <input type=hidden name=sort value=$sort>
 
 134 <input type=hidden name=type value=$form->{type}>
 
 138     <th class=listtop>$form->{title}</th>
 
 147           <td><input name=status class=radio type=radio value=all checked> |
 
 148     . $locale->text('All') . qq|
 
 149           <input name=status class=radio type=radio value=orphaned> |
 
 150     . $locale->text('Orphaned') . qq|</td>
 
 156     <td><hr size=3 noshade></td>
 
 160 <input type=hidden name=nextsub value=$report>
 
 162 <input type=hidden name=path value=$form->{path}>
 
 163 <input type=hidden name=login value=$form->{login}>
 
 164 <input type=hidden name=password value=$form->{password}>
 
 167 <input class=submit type=submit name=action value="|
 
 168     . $locale->text('Continue') . qq|">
 
 175   $lxdebug->leave_sub();
 
 179   $lxdebug->enter_sub();
 
 181   map { $form->{$_} = $form->unescape($form->{$_}) }
 
 182     (projectnumber, description);
 
 183   PE->projects(\%myconfig, \%$form);
 
 186     "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 189   if ($form->{status} eq 'all') {
 
 190     $option = $locale->text('All');
 
 192   if ($form->{status} eq 'orphaned') {
 
 193     $option .= $locale->text('Orphaned');
 
 195   if ($form->{projectnumber}) {
 
 196     $href     .= "&projectnumber=" . $form->escape($form->{projectnumber});
 
 197     $callback .= "&projectnumber=$form->{projectnumber}";
 
 199       "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
 
 201   if ($form->{description}) {
 
 202     $href     .= "&description=" . $form->escape($form->{description});
 
 203     $callback .= "&description=$form->{description}";
 
 205       "\n<br>" . $locale->text('Description') . " : $form->{description}";
 
 208   @column_index = $form->sort_columns(qw(projectnumber description));
 
 210   $column_header{projectnumber} =
 
 211       qq|<th><a class=listheading href=$href&sort=projectnumber>|
 
 212     . $locale->text('Number')
 
 214   $column_header{description} =
 
 215       qq|<th><a class=listheading href=$href&sort=description>|
 
 216     . $locale->text('Description')
 
 219   $form->{title} = $locale->text('Projects');
 
 228     <th class=listtop>$form->{title}</th>
 
 237         <tr class=listheading>
 
 240   map { print "$column_header{$_}\n" } @column_index;
 
 247   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
 249   # escape callback for href
 
 250   $callback = $form->escape($callback);
 
 252   foreach $ref (@{ $form->{project_list} }) {
 
 258         <tr valign=top class=listrow$i>
 
 261     $column_data{projectnumber} =
 
 262       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{projectnumber}</td>|;
 
 263     $column_data{description} = qq|<td>$ref->{description} </td>|;
 
 265     map { print "$column_data{$_}\n" } @column_index;
 
 277     <td><hr size=3 noshade></td>
 
 282 <form method=post action=$form->{script}>
 
 284 <input name=callback type=hidden value="$form->{callback}">
 
 286 <input type=hidden name=type value=$form->{type}>
 
 288 <input type=hidden name=path value=$form->{path}>
 
 289 <input type=hidden name=login value=$form->{login}>
 
 290 <input type=hidden name=password value=$form->{password}>
 
 292 <input class=submit type=submit name=action value="|
 
 293     . $locale->text('Add') . qq|">
 
 301   $lxdebug->leave_sub();
 
 304 sub form_project_header {
 
 305   $lxdebug->enter_sub();
 
 307   $form->{title} = $locale->text("$form->{title} Project");
 
 309   # $locale->text('Add Project')
 
 310   # $locale->text('Edit Project')
 
 312   $form->{description} =~ s/\"/"/g;
 
 314   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
 316       qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
 
 319       qq|<input name=description size=60 value="$form->{description}">|;
 
 327 <form method=post action=$form->{script}>
 
 329 <input type=hidden name=id value=$form->{id}>
 
 330 <input type=hidden name=type value=project>
 
 334     <th class=listtop>$form->{title}</th>
 
 341           <th align=right>| . $locale->text('Number') . qq|</th>
 
 342           <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
 
 345           <th align=right>| . $locale->text('Description') . qq|</th>
 
 346           <td>$description</td>
 
 352     <td colspan=2><hr size=3 noshade></td>
 
 357   $lxdebug->leave_sub();
 
 360 sub form_project_footer {
 
 361   $lxdebug->enter_sub();
 
 365 <input name=callback type=hidden value="$form->{callback}">
 
 367 <input type=hidden name=path value=$form->{path}>
 
 368 <input type=hidden name=login value=$form->{login}>
 
 369 <input type=hidden name=password value=$form->{password}>
 
 371 <br><input type=submit class=submit name=action value="|
 
 372     . $locale->text('Save') . qq|">
 
 375   if ($form->{id} && $form->{orphaned}) {
 
 377 <input type=submit class=submit name=action value="|
 
 378       . $locale->text('Delete') . qq|">|;
 
 388   $lxdebug->leave_sub();
 
 392   $lxdebug->enter_sub();
 
 394   if ($form->{type} eq 'project') {
 
 395     $form->isblank("projectnumber", $locale->text('Project Number missing!'));
 
 396     PE->save_project(\%myconfig, \%$form);
 
 397     $form->redirect($locale->text('Project saved!'));
 
 399   if ($form->{type} eq 'partsgroup') {
 
 400     $form->isblank("partsgroup", $locale->text('Group missing!'));
 
 401     PE->save_partsgroup(\%myconfig, \%$form);
 
 402     $form->redirect($locale->text('Group saved!'));
 
 405   # choice pricegroup and save
 
 406   if ($form->{type} eq 'pricegroup') {
 
 407     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
 
 408     PE->save_pricegroup(\%myconfig, \%$form);
 
 409     $form->redirect($locale->text('Pricegroup saved!'));
 
 412   $lxdebug->leave_sub();
 
 416   $lxdebug->enter_sub();
 
 418   PE->delete_tuple(\%myconfig, \%$form);
 
 420   if ($form->{type} eq 'project') {
 
 421     $form->redirect($locale->text('Project deleted!'));
 
 423   if ($form->{type} eq 'partsgroup') {
 
 424     $form->redirect($locale->text('Group deleted!'));
 
 426   if ($form->{type} eq 'pricegroup') {
 
 427     $form->redirect($locale->text('Pricegroup deleted!'));
 
 430   $lxdebug->leave_sub();
 
 433 sub continue { &{ $form->{nextsub} } }
 
 435 sub partsgroup_report {
 
 436   $lxdebug->enter_sub();
 
 438   map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
 
 439   PE->partsgroups(\%myconfig, \%$form);
 
 442     "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 444   if ($form->{status} eq 'all') {
 
 445     $option = $locale->text('All');
 
 447   if ($form->{status} eq 'orphaned') {
 
 448     $option .= $locale->text('Orphaned');
 
 450   if ($form->{partsgroup}) {
 
 451     $callback .= "&partsgroup=$form->{partsgroup}";
 
 452     $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
 
 455   @column_index = $form->sort_columns(qw(partsgroup));
 
 457   $column_header{partsgroup} =
 
 458     qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
 
 460   $form->{title} = $locale->text('Groups');
 
 469     <th class=listtop>$form->{title}</th>
 
 478         <tr class=listheading>
 
 481   map { print "$column_header{$_}\n" } @column_index;
 
 488   $form->{callback} = $callback;
 
 490   # escape callback for href
 
 491   $callback = $form->escape($callback);
 
 493   foreach $ref (@{ $form->{item_list} }) {
 
 499         <tr valign=top class=listrow$i>
 
 502     $column_data{partsgroup} =
 
 503       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partsgroup}</td>|;
 
 504     map { print "$column_data{$_}\n" } @column_index;
 
 516     <td><hr size=3 noshade></td>
 
 521 <form method=post action=$form->{script}>
 
 523 <input name=callback type=hidden value="$form->{callback}">
 
 525 <input type=hidden name=type value=$form->{type}>
 
 527 <input type=hidden name=path value=$form->{path}>
 
 528 <input type=hidden name=login value=$form->{login}>
 
 529 <input type=hidden name=password value=$form->{password}>
 
 531 <input class=submit type=submit name=action value="|
 
 532     . $locale->text('Add') . qq|">
 
 540   $lxdebug->leave_sub();
 
 543 sub form_partsgroup_header {
 
 544   $lxdebug->enter_sub();
 
 546   $form->{title} = $locale->text("$form->{title} Group");
 
 548   # $locale->text('Add Group')
 
 549   # $locale->text('Edit Group')
 
 551   $form->{partsgroup} =~ s/\"/"/g;
 
 558 <form method=post action=$form->{script}>
 
 560 <input type=hidden name=id value=$form->{id}>
 
 561 <input type=hidden name=type value=$form->{type}>
 
 565     <th class=listtop>$form->{title}</th>
 
 572           <th align=right>| . $locale->text('Group') . qq|</th>
 
 574           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
 
 580     <td colspan=2><hr size=3 noshade></td>
 
 585   $lxdebug->leave_sub();
 
 588 sub form_partsgroup_footer {
 
 589   $lxdebug->enter_sub();
 
 593 <input name=callback type=hidden value="$form->{callback}">
 
 595 <input type=hidden name=path value=$form->{path}>
 
 596 <input type=hidden name=login value=$form->{login}>
 
 597 <input type=hidden name=password value=$form->{password}>
 
 599 <br><input type=submit class=submit name=action value="|
 
 600     . $locale->text('Save') . qq|">
 
 603   if ($form->{id} && $form->{orphaned}) {
 
 605 <input type=submit class=submit name=action value="|
 
 606       . $locale->text('Delete') . qq|">|;
 
 616   $lxdebug->leave_sub();
 
 619 #################################
 
 620 # get pricesgroups and build up html-code
 
 622 sub pricegroup_report {
 
 623   $lxdebug->enter_sub();
 
 625   map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
 
 626   PE->pricegroups(\%myconfig, \%$form);
 
 629     "$form->{script}?action=pricegroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 631   if ($form->{status} eq 'all') {
 
 632     $option = $locale->text('All');
 
 634   if ($form->{status} eq 'orphaned') {
 
 635     $option .= $locale->text('Orphaned');
 
 637   if ($form->{pricegroup}) {
 
 638     $callback .= "&pricegroup=$form->{pricegroup}";
 
 640       "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
 
 643   @column_index = $form->sort_columns(qw(pricegroup));
 
 645   $column_header{pricegroup} =
 
 646       qq|<th class=listheading width=90%>|
 
 647     . $locale->text('Pricegroup')
 
 650   $form->{title} = $locale->text('Pricegroup');
 
 659     <th class=listtop>$form->{title}</th>
 
 668         <tr class=listheading>
 
 671   map { print "$column_header{$_}\n" } @column_index;
 
 678   $form->{callback} = $callback;
 
 680   # escape callback for href
 
 681   $callback = $form->escape($callback);
 
 683   foreach $ref (@{ $form->{item_list} }) {
 
 689         <tr valign=top class=listrow$i>
 
 691     $column_data{pricegroup} =
 
 692       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{pricegroup}</td>|;
 
 694     map { print "$column_data{$_}\n" } @column_index;
 
 706     <td><hr size=3 noshade></td>
 
 711 <form method=post action=$form->{script}>
 
 713 <input name=callback type=hidden value="$form->{callback}">
 
 715 <input type=hidden name=type value=$form->{type}>
 
 717 <input type=hidden name=path value=$form->{path}>
 
 718 <input type=hidden name=login value=$form->{login}>
 
 719 <input type=hidden name=password value=$form->{password}>
 
 721 <input class=submit type=submit name=action value="|
 
 722     . $locale->text('Add') . qq|">
 
 730   $lxdebug->leave_sub();
 
 733 #######################
 
 734 #build up pricegroup_header
 
 736 sub form_pricegroup_header {
 
 737   $lxdebug->enter_sub();
 
 739   # $locale->text('Add Pricegroup')
 
 740   # $locale->text('Edit Pricegroup')
 
 742   $form->{title} = $locale->text("$form->{title} Pricegroup");
 
 744   $form->{pricegroup} =~ s/\"/"/g;
 
 751 <form method=post action=$form->{script}>
 
 753 <input type=hidden name=id value=$form->{id}>
 
 754 <input type=hidden name=type value=$form->{type}>
 
 758     <th class=listtop>$form->{title}</th>
 
 765           <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
 
 766           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
 
 772     <td colspan=2><hr size=3 noshade></td>
 
 777   $lxdebug->leave_sub();
 
 779 ######################
 
 780 #build up pricegroup_footer
 
 782 sub form_pricegroup_footer {
 
 783   $lxdebug->enter_sub();
 
 787 <input name=callback type=hidden value="$form->{callback}">
 
 789 <input type=hidden name=path value=$form->{path}>
 
 790 <input type=hidden name=login value=$form->{login}>
 
 791 <input type=hidden name=password value=$form->{password}>
 
 793 <br><input type=submit class=submit name=action value="|
 
 794     . $locale->text('Save') . qq|">
 
 797   if ($form->{id} && $form->{orphaned}) {
 
 799 <input type=submit class=submit name=action value="|
 
 800       . $locale->text('Delete') . qq|">|;
 
 810   $lxdebug->leave_sub();