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 #======================================================================
 
  37 require "bin/mozilla/common.pl";
 
  44   $lxdebug->enter_sub();
 
  46   $form->{title} = "Add";
 
  50     "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  51     unless $form->{callback};
 
  53   &{"form_$form->{type}_header"};
 
  54   &{"form_$form->{type}_footer"};
 
  56   $lxdebug->leave_sub();
 
  60   $lxdebug->enter_sub();
 
  62   $form->{title} = "Edit";
 
  64   if ($form->{type} eq 'project') {
 
  65     PE->get_project(\%myconfig, \%$form);
 
  67   if ($form->{type} eq 'partsgroup') {
 
  68     PE->get_partsgroup(\%myconfig, \%$form);
 
  70   if ($form->{type} eq 'pricegroup') {
 
  71     PE->get_pricegroup(\%myconfig, \%$form);
 
  73   &{"form_$form->{type}_header"};
 
  74   &{"form_$form->{type}_footer"};
 
  76   $lxdebug->leave_sub();
 
  80   $lxdebug->enter_sub();
 
  82   if ($form->{type} eq 'project') {
 
  83     $report        = "project_report";
 
  84     $sort          = 'projectnumber';
 
  85     $form->{title} = $locale->text('Projects');
 
  89           <th align=right width=1%>| . $locale->text('Number') . qq|</th>
 
  90           <td>| . $cgi->textfield('-name' => 'projectnumber', '-size' => 20) . qq|</td>
 
  93           <th align=right>| . $locale->text('Description') . qq|</th>
 
  94           <td>| . $cgi->textfield('-name' => 'description', '-size' => 60) . qq|</td>
 
  99     $cgi->radio_group('-name' => 'active', '-default' => 'active',
 
 100                       '-values' => ['active', 'inactive', 'both'],
 
 101                       '-labels' => { 'active' => ' ' . $locale->text("Active"),
 
 102                                      'inactive' => ' ' . $locale->text("Inactive"),
 
 103                                      'both' => ' ' . $locale->text("Both") })
 
 109   if ($form->{type} eq 'partsgroup') {
 
 110     $report        = "partsgroup_report";
 
 111     $sort          = 'partsgroup';
 
 112     $form->{title} = $locale->text('Groups');
 
 116           <th align=right width=1%>| . $locale->text('Group') . qq|</th>
 
 117           <td><input name=partsgroup size=20></td>
 
 124   if ($form->{type} eq 'pricegroup') {
 
 125     $report        = "pricegroup_report";
 
 126     $sort          = 'pricegroup';
 
 127     $form->{title} = $locale->text('Pricegroup');
 
 131           <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
 
 132           <td><input name=pricegroup size=20></td>
 
 143 <form method=post action=$form->{script}>
 
 145 <input type=hidden name=sort value=$sort>
 
 146 <input type=hidden name=type value=$form->{type}>
 
 150     <th class=listtop>$form->{title}</th>
 
 159           <td><input name=status class=radio type=radio value=all checked> |
 
 160     . $locale->text('All') . qq|
 
 161           <input name=status class=radio type=radio value=orphaned> |
 
 162     . $locale->text('Orphaned') . qq|</td>
 
 168     <td><hr size=3 noshade></td>
 
 172 <input type=hidden name=nextsub value=$report>
 
 174 <input type=hidden name=path value=$form->{path}>
 
 175 <input type=hidden name=login value=$form->{login}>
 
 176 <input type=hidden name=password value=$form->{password}>
 
 179 <input class=submit type=submit name=action value="|
 
 180     . $locale->text('Continue') . qq|">
 
 187   $lxdebug->leave_sub();
 
 191   $lxdebug->enter_sub();
 
 193   map { $form->{$_} = $form->unescape($form->{$_}) }
 
 194     (projectnumber, description);
 
 195   PE->projects(\%myconfig, \%$form);
 
 198     "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}&active=" .
 
 202   if ($form->{status} eq 'all') {
 
 203     $option = $locale->text('All');
 
 205   if ($form->{status} eq 'orphaned') {
 
 206     $option .= $locale->text('Orphaned');
 
 208   if ($form->{projectnumber}) {
 
 209     $href     .= "&projectnumber=" . $form->escape($form->{projectnumber});
 
 210     $callback .= "&projectnumber=$form->{projectnumber}";
 
 212       "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
 
 214   if ($form->{description}) {
 
 215     $href     .= "&description=" . $form->escape($form->{description});
 
 216     $callback .= "&description=$form->{description}";
 
 218       "\n<br>" . $locale->text('Description') . " : $form->{description}";
 
 221   @column_index = qw(projectnumber description);
 
 223   push(@column_index, "active") if ("both" eq $form->{active});
 
 225   $column_header{projectnumber} =
 
 226       qq|<th><a class=listheading href=$href&sort=projectnumber>|
 
 227     . $locale->text('Number')
 
 229   $column_header{description} =
 
 230       qq|<th><a class=listheading href=$href&sort=description>|
 
 231     . $locale->text('Description')
 
 233   $column_header{active} =
 
 234       qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
 
 236   $form->{title} = $locale->text('Projects');
 
 245     <th class=listtop>$form->{title}</th>
 
 254         <tr class=listheading>
 
 257   map { print "$column_header{$_}\n" } @column_index;
 
 264   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
 266   # escape callback for href
 
 267   $callback = $form->escape($callback);
 
 269   foreach $ref (@{ $form->{project_list} }) {
 
 275         <tr valign=top class=listrow$i>
 
 278     $column_data{projectnumber} =
 
 279       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>|;
 
 280     $column_data{description} = qq|<td>$ref->{description} </td>|;
 
 281     $column_data{active} =
 
 283       ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
 
 286     map { print "$column_data{$_}\n" } @column_index;
 
 298     <td><hr size=3 noshade></td>
 
 303 <form method=post action=$form->{script}>
 
 305 <input name=callback type=hidden value="$form->{callback}">
 
 307 <input type=hidden name=type value=$form->{type}>
 
 309 <input type=hidden name=path value=$form->{path}>
 
 310 <input type=hidden name=login value=$form->{login}>
 
 311 <input type=hidden name=password value=$form->{password}>
 
 313 <input class=submit type=submit name=action value="|
 
 314     . $locale->text('Add') . qq|">
 
 322   $lxdebug->leave_sub();
 
 325 sub form_project_header {
 
 326   $lxdebug->enter_sub();
 
 328   $form->{title} = $locale->text("$form->{title} Project");
 
 330   # $locale->text('Add Project')
 
 331   # $locale->text('Edit Project')
 
 333   $form->{description} =~ s/\"/"/g;
 
 336     $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
 
 337                     '-default' => $form->{projectnumber});
 
 340   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
 342       $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
 
 343                      '-style' => 'width: 100%', '-wrap' => 'soft',
 
 344                      '-default' => $form->{description});
 
 347       $cgi->textfield('-name' => 'description', '-size' => 60,
 
 348                       '-default' => $form->{description});
 
 358       $cgi->radio_group('-name' => 'active',
 
 360                         '-default' => $form->{active} * 1,
 
 361                         '-labels' => { 1 => $locale->text("Active"),
 
 362                                        0 => $locale->text("Inactive") })
 
 373 <form method=post action=$form->{script}>
 
 375 <input type=hidden name=id value=$form->{id}>
 
 376 <input type=hidden name=type value=project>
 
 380     <th class=listtop>$form->{title}</th>
 
 387           <th align=right>| . $locale->text('Number') . qq|</th>
 
 388           <td>$projectnumber</td>
 
 391           <th align=right>| . $locale->text('Description') . qq|</th>
 
 392           <td>$description</td>
 
 399     <td colspan=2><hr size=3 noshade></td>
 
 404   $lxdebug->leave_sub();
 
 407 sub form_project_footer {
 
 408   $lxdebug->enter_sub();
 
 412 <input name=callback type=hidden value="$form->{callback}">
 
 414 <input type=hidden name=path value=$form->{path}>
 
 415 <input type=hidden name=login value=$form->{login}>
 
 416 <input type=hidden name=password value=$form->{password}>
 
 418 <br><input type=submit class=submit name=action value="|
 
 419     . $locale->text('Save') . qq|">
 
 422   if ($form->{id} && $form->{orphaned}) {
 
 424 <input type=submit class=submit name=action value="|
 
 425       . $locale->text('Delete') . qq|">|;
 
 435   $lxdebug->leave_sub();
 
 439   $lxdebug->enter_sub();
 
 441   if ($form->{type} eq 'project') {
 
 442     $form->isblank("projectnumber", $locale->text('Project Number missing!'));
 
 443     PE->save_project(\%myconfig, \%$form);
 
 444     $form->redirect($locale->text('Project saved!'));
 
 446   if ($form->{type} eq 'partsgroup') {
 
 447     $form->isblank("partsgroup", $locale->text('Group missing!'));
 
 448     PE->save_partsgroup(\%myconfig, \%$form);
 
 449     $form->redirect($locale->text('Group saved!'));
 
 452   # choice pricegroup and save
 
 453   if ($form->{type} eq 'pricegroup') {
 
 454     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
 
 455     PE->save_pricegroup(\%myconfig, \%$form);
 
 456     $form->redirect($locale->text('Pricegroup saved!'));
 
 459   $lxdebug->leave_sub();
 
 463   $lxdebug->enter_sub();
 
 465   PE->delete_tuple(\%myconfig, \%$form);
 
 467   if ($form->{type} eq 'project') {
 
 468     $form->redirect($locale->text('Project deleted!'));
 
 470   if ($form->{type} eq 'partsgroup') {
 
 471     $form->redirect($locale->text('Group deleted!'));
 
 473   if ($form->{type} eq 'pricegroup') {
 
 474     $form->redirect($locale->text('Pricegroup deleted!'));
 
 477   $lxdebug->leave_sub();
 
 480 sub continue { &{ $form->{nextsub} } }
 
 482 sub partsgroup_report {
 
 483   $lxdebug->enter_sub();
 
 485   map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
 
 486   PE->partsgroups(\%myconfig, \%$form);
 
 489     "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 491   if ($form->{status} eq 'all') {
 
 492     $option = $locale->text('All');
 
 494   if ($form->{status} eq 'orphaned') {
 
 495     $option .= $locale->text('Orphaned');
 
 497   if ($form->{partsgroup}) {
 
 498     $callback .= "&partsgroup=$form->{partsgroup}";
 
 499     $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
 
 502   @column_index = $form->sort_columns(qw(partsgroup));
 
 504   $column_header{partsgroup} =
 
 505     qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
 
 507   $form->{title} = $locale->text('Groups');
 
 516     <th class=listtop>$form->{title}</th>
 
 525         <tr class=listheading>
 
 528   map { print "$column_header{$_}\n" } @column_index;
 
 535   $form->{callback} = $callback;
 
 537   # escape callback for href
 
 538   $callback = $form->escape($callback);
 
 540   foreach $ref (@{ $form->{item_list} }) {
 
 546         <tr valign=top class=listrow$i>
 
 549     $column_data{partsgroup} =
 
 550       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>|;
 
 551     map { print "$column_data{$_}\n" } @column_index;
 
 563     <td><hr size=3 noshade></td>
 
 568 <form method=post action=$form->{script}>
 
 570 <input name=callback type=hidden value="$form->{callback}">
 
 572 <input type=hidden name=type value=$form->{type}>
 
 574 <input type=hidden name=path value=$form->{path}>
 
 575 <input type=hidden name=login value=$form->{login}>
 
 576 <input type=hidden name=password value=$form->{password}>
 
 578 <input class=submit type=submit name=action value="|
 
 579     . $locale->text('Add') . qq|">
 
 587   $lxdebug->leave_sub();
 
 590 sub form_partsgroup_header {
 
 591   $lxdebug->enter_sub();
 
 593   $form->{title} = $locale->text("$form->{title} Group");
 
 595   # $locale->text('Add Group')
 
 596   # $locale->text('Edit Group')
 
 598   $form->{partsgroup} =~ s/\"/"/g;
 
 605 <form method=post action=$form->{script}>
 
 607 <input type=hidden name=id value=$form->{id}>
 
 608 <input type=hidden name=type value=$form->{type}>
 
 612     <th class=listtop>$form->{title}</th>
 
 619           <th align=right>| . $locale->text('Group') . qq|</th>
 
 621           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
 
 627     <td colspan=2><hr size=3 noshade></td>
 
 632   $lxdebug->leave_sub();
 
 635 sub form_partsgroup_footer {
 
 636   $lxdebug->enter_sub();
 
 640 <input name=callback type=hidden value="$form->{callback}">
 
 642 <input type=hidden name=path value=$form->{path}>
 
 643 <input type=hidden name=login value=$form->{login}>
 
 644 <input type=hidden name=password value=$form->{password}>
 
 646 <br><input type=submit class=submit name=action value="|
 
 647     . $locale->text('Save') . qq|">
 
 650   if ($form->{id} && $form->{orphaned}) {
 
 652 <input type=submit class=submit name=action value="|
 
 653       . $locale->text('Delete') . qq|">|;
 
 663   $lxdebug->leave_sub();
 
 666 #################################
 
 667 # get pricesgroups and build up html-code
 
 669 sub pricegroup_report {
 
 670   $lxdebug->enter_sub();
 
 672   map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
 
 673   PE->pricegroups(\%myconfig, \%$form);
 
 676     "$form->{script}?action=pricegroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 678   if ($form->{status} eq 'all') {
 
 679     $option = $locale->text('All');
 
 681   if ($form->{status} eq 'orphaned') {
 
 682     $option .= $locale->text('Orphaned');
 
 684   if ($form->{pricegroup}) {
 
 685     $callback .= "&pricegroup=$form->{pricegroup}";
 
 687       "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
 
 690   @column_index = $form->sort_columns(qw(pricegroup));
 
 692   $column_header{pricegroup} =
 
 693       qq|<th class=listheading width=90%>|
 
 694     . $locale->text('Pricegroup')
 
 697   $form->{title} = $locale->text('Pricegroup');
 
 706     <th class=listtop>$form->{title}</th>
 
 715         <tr class=listheading>
 
 718   map { print "$column_header{$_}\n" } @column_index;
 
 725   $form->{callback} = $callback;
 
 727   # escape callback for href
 
 728   $callback = $form->escape($callback);
 
 730   foreach $ref (@{ $form->{item_list} }) {
 
 736         <tr valign=top class=listrow$i>
 
 738     $column_data{pricegroup} =
 
 739       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>|;
 
 741     map { print "$column_data{$_}\n" } @column_index;
 
 753     <td><hr size=3 noshade></td>
 
 758 <form method=post action=$form->{script}>
 
 760 <input name=callback type=hidden value="$form->{callback}">
 
 762 <input type=hidden name=type value=$form->{type}>
 
 764 <input type=hidden name=path value=$form->{path}>
 
 765 <input type=hidden name=login value=$form->{login}>
 
 766 <input type=hidden name=password value=$form->{password}>
 
 768 <input class=submit type=submit name=action value="|
 
 769     . $locale->text('Add') . qq|">
 
 777   $lxdebug->leave_sub();
 
 780 #######################
 
 781 #build up pricegroup_header
 
 783 sub form_pricegroup_header {
 
 784   $lxdebug->enter_sub();
 
 786   # $locale->text('Add Pricegroup')
 
 787   # $locale->text('Edit Pricegroup')
 
 789   $form->{title} = $locale->text("$form->{title} Pricegroup");
 
 791   $form->{pricegroup} =~ s/\"/"/g;
 
 798 <form method=post action=$form->{script}>
 
 800 <input type=hidden name=id value=$form->{id}>
 
 801 <input type=hidden name=type value=$form->{type}>
 
 805     <th class=listtop>$form->{title}</th>
 
 812           <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
 
 813           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
 
 819     <td colspan=2><hr size=3 noshade></td>
 
 824   $lxdebug->leave_sub();
 
 826 ######################
 
 827 #build up pricegroup_footer
 
 829 sub form_pricegroup_footer {
 
 830   $lxdebug->enter_sub();
 
 834 <input name=callback type=hidden value="$form->{callback}">
 
 836 <input type=hidden name=path value=$form->{path}>
 
 837 <input type=hidden name=login value=$form->{login}>
 
 838 <input type=hidden name=password value=$form->{password}>
 
 840 <br><input type=submit class=submit name=action value="|
 
 841     . $locale->text('Save') . qq|">
 
 844   if ($form->{id} && $form->{orphaned}) {
 
 846 <input type=submit class=submit name=action value="|
 
 847       . $locale->text('Delete') . qq|">|;
 
 857   $lxdebug->leave_sub();