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->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
 
  63   #/show hhistory button
 
  64   $form->{title} = "Edit";
 
  66   if ($form->{type} eq 'project') {
 
  67     PE->get_project(\%myconfig, \%$form);
 
  69   if ($form->{type} eq 'partsgroup') {
 
  70     PE->get_partsgroup(\%myconfig, \%$form);
 
  72   if ($form->{type} eq 'pricegroup') {
 
  73     PE->get_pricegroup(\%myconfig, \%$form);
 
  75   &{"form_$form->{type}_header"};
 
  76   &{"form_$form->{type}_footer"};
 
  78   $lxdebug->leave_sub();
 
  82   $lxdebug->enter_sub();
 
  84   if ($form->{type} eq 'project') {
 
  85     $report        = "project_report";
 
  86     $sort          = 'projectnumber';
 
  87     $form->{title} = $locale->text('Projects');
 
  91           <th align=right width=1%>| . $locale->text('Number') . qq|</th>
 
  92           <td>| . $cgi->textfield('-name' => 'projectnumber', '-size' => 20) . qq|</td>
 
  95           <th align=right>| . $locale->text('Description') . qq|</th>
 
  96           <td>| . $cgi->textfield('-name' => 'description', '-size' => 60) . qq|</td>
 
 101     $cgi->radio_group('-name' => 'active', '-default' => 'active',
 
 102                       '-values' => ['active', 'inactive', 'both'],
 
 103                       '-labels' => { 'active' => ' ' . $locale->text("Active"),
 
 104                                      'inactive' => ' ' . $locale->text("Inactive"),
 
 105                                      'both' => ' ' . $locale->text("Both") })
 
 111   if ($form->{type} eq 'partsgroup') {
 
 112     $report        = "partsgroup_report";
 
 113     $sort          = 'partsgroup';
 
 114     $form->{title} = $locale->text('Groups');
 
 118           <th align=right width=1%>| . $locale->text('Group') . qq|</th>
 
 119           <td><input name=partsgroup size=20></td>
 
 126   if ($form->{type} eq 'pricegroup') {
 
 127     $report        = "pricegroup_report";
 
 128     $sort          = 'pricegroup';
 
 129     $form->{title} = $locale->text('Pricegroup');
 
 133           <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
 
 134           <td><input name=pricegroup size=20></td>
 
 145 <form method=post action=$form->{script}>
 
 147 <input type=hidden name=sort value=$sort>
 
 148 <input type=hidden name=type value=$form->{type}>
 
 152     <th class=listtop>$form->{title}</th>
 
 161           <td><input name=status class=radio type=radio value=all checked> |
 
 162     . $locale->text('All') . qq|
 
 163           <input name=status class=radio type=radio value=orphaned> |
 
 164     . $locale->text('Orphaned') . qq|</td>
 
 170     <td><hr size=3 noshade></td>
 
 174 <input type=hidden name=nextsub value=$report>
 
 176 <input type=hidden name=path value=$form->{path}>
 
 177 <input type=hidden name=login value=$form->{login}>
 
 178 <input type=hidden name=password value=$form->{password}>
 
 181 <input class=submit type=submit name=action value="|
 
 182     . $locale->text('Continue') . qq|">
 
 189   $lxdebug->leave_sub();
 
 193   $lxdebug->enter_sub();
 
 195   map { $form->{$_} = $form->unescape($form->{$_}) }
 
 196     (projectnumber, description);
 
 197   PE->projects(\%myconfig, \%$form);
 
 200     "$form->{script}?action=project_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}&active=" .
 
 204   if ($form->{status} eq 'all') {
 
 205     $option = $locale->text('All');
 
 207   if ($form->{status} eq 'orphaned') {
 
 208     $option .= $locale->text('Orphaned');
 
 210   if ($form->{projectnumber}) {
 
 211     $href     .= "&projectnumber=" . $form->escape($form->{projectnumber});
 
 212     $callback .= "&projectnumber=$form->{projectnumber}";
 
 214       "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
 
 216   if ($form->{description}) {
 
 217     $href     .= "&description=" . $form->escape($form->{description});
 
 218     $callback .= "&description=$form->{description}";
 
 220       "\n<br>" . $locale->text('Description') . " : $form->{description}";
 
 223   @column_index = qw(projectnumber description);
 
 225   push(@column_index, "active") if ("both" eq $form->{active});
 
 227   $column_header{projectnumber} =
 
 228       qq|<th><a class=listheading href=$href&sort=projectnumber>|
 
 229     . $locale->text('Number')
 
 231   $column_header{description} =
 
 232       qq|<th><a class=listheading href=$href&sort=description>|
 
 233     . $locale->text('Description')
 
 235   $column_header{active} =
 
 236       qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
 
 238   $form->{title} = $locale->text('Projects');
 
 247     <th class=listtop>$form->{title}</th>
 
 256         <tr class=listheading>
 
 259   map { print "$column_header{$_}\n" } @column_index;
 
 266   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
 268   # escape callback for href
 
 269   $callback = $form->escape($callback);
 
 271   foreach $ref (@{ $form->{project_list} }) {
 
 277         <tr valign=top class=listrow$i>
 
 280     $column_data{projectnumber} =
 
 281       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>|;
 
 282     $column_data{description} = qq|<td>$ref->{description} </td>|;
 
 283     $column_data{active} =
 
 285       ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
 
 288     map { print "$column_data{$_}\n" } @column_index;
 
 300     <td><hr size=3 noshade></td>
 
 305 <form method=post action=$form->{script}>
 
 307 <input name=callback type=hidden value="$form->{callback}">
 
 309 <input type=hidden name=type value=$form->{type}>
 
 311 <input type=hidden name=path value=$form->{path}>
 
 312 <input type=hidden name=login value=$form->{login}>
 
 313 <input type=hidden name=password value=$form->{password}>
 
 315 <input class=submit type=submit name=action value="|
 
 316     . $locale->text('Add') . qq|">
 
 324   $lxdebug->leave_sub();
 
 327 sub form_project_header {
 
 328   $lxdebug->enter_sub();
 
 330   $form->{title} = $locale->text("$form->{title} Project");
 
 332   # $locale->text('Add Project')
 
 333   # $locale->text('Edit Project')
 
 335   $form->{description} =~ s/\"/"/g;
 
 338     $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
 
 339                     '-default' => $form->{projectnumber});
 
 342   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
 344       $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
 
 345                      '-style' => 'width: 100%', '-wrap' => 'soft',
 
 346                      '-default' => $form->{description});
 
 349       $cgi->textfield('-name' => 'description', '-size' => 60,
 
 350                       '-default' => $form->{description});
 
 360       $cgi->radio_group('-name' => 'active',
 
 362                         '-default' => $form->{active} * 1,
 
 363                         '-labels' => { 1 => $locale->text("Active"),
 
 364                                        0 => $locale->text("Inactive") })
 
 375 <form method=post action=$form->{script}>
 
 377 <input type=hidden name=id value=$form->{id}>
 
 378 <input type=hidden name=type value=project>
 
 382     <th class=listtop>$form->{title}</th>
 
 389           <th align=right>| . $locale->text('Number') . qq|</th>
 
 390           <td>$projectnumber</td>
 
 393           <th align=right>| . $locale->text('Description') . qq|</th>
 
 394           <td>$description</td>
 
 401     <td colspan=2><hr size=3 noshade></td>
 
 406   $lxdebug->leave_sub();
 
 409 sub form_project_footer {
 
 410   $lxdebug->enter_sub();
 
 414 <input name=callback type=hidden value="$form->{callback}">
 
 416 <input type=hidden name=path value=$form->{path}>
 
 417 <input type=hidden name=login value=$form->{login}>
 
 418 <input type=hidden name=password value=$form->{password}>
 
 420 <br><input type=submit class=submit name=action value="|
 
 421     . $locale->text('Save') . qq|">
 
 424   if ($form->{id} && $form->{orphaned}) {
 
 426 <input type=submit class=submit name=action value="|
 
 427       . $locale->text('Delete') . qq|">|;
 
 430 # button for saving history
 
 432         <input type=button onclick=set_history_window(|
 
 434         . qq|); name=history id=history value=|
 
 435         . $locale->text('history') 
 
 437 # /button for saving history
 
 445   $lxdebug->leave_sub();
 
 449   $lxdebug->enter_sub();
 
 451   if ($form->{type} eq 'project') {
 
 452     $form->isblank("projectnumber", $locale->text('Project Number missing!'));
 
 453     PE->save_project(\%myconfig, \%$form);
 
 454     $form->redirect($locale->text('Project saved!'));
 
 456   if ($form->{type} eq 'partsgroup') {
 
 457     $form->isblank("partsgroup", $locale->text('Group missing!'));
 
 458     PE->save_partsgroup(\%myconfig, \%$form);
 
 459     $form->redirect($locale->text('Group saved!'));
 
 462   # choice pricegroup and save
 
 463   if ($form->{type} eq 'pricegroup') {
 
 464     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
 
 465     PE->save_pricegroup(\%myconfig, \%$form);
 
 466     $form->redirect($locale->text('Pricegroup saved!'));
 
 469   if(!exists $form->{addition} && $form->{id} ne "") {
 
 470         $form->{addition} = "SAVED";
 
 471         $form->save_history($form->dbconnect(\%myconfig));
 
 473   # /saving the history 
 
 475   $lxdebug->leave_sub();
 
 479   $lxdebug->enter_sub();
 
 481   PE->delete_tuple(\%myconfig, \%$form);
 
 483   if ($form->{type} eq 'project') {
 
 484     $form->redirect($locale->text('Project deleted!'));
 
 486   if ($form->{type} eq 'partsgroup') {
 
 487     $form->redirect($locale->text('Group deleted!'));
 
 489   if ($form->{type} eq 'pricegroup') {
 
 490     $form->redirect($locale->text('Pricegroup deleted!'));
 
 493   if(!exists $form->{addition}) {
 
 494         $form->{addition} = "DELETED";
 
 495         $form->save_history($form->dbconnect(\%myconfig));
 
 497   # /saving the history
 
 498   $lxdebug->leave_sub();
 
 501 sub continue { &{ $form->{nextsub} } }
 
 503 sub partsgroup_report {
 
 504   $lxdebug->enter_sub();
 
 506   map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
 
 507   PE->partsgroups(\%myconfig, \%$form);
 
 510     "$form->{script}?action=partsgroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 512   if ($form->{status} eq 'all') {
 
 513     $option = $locale->text('All');
 
 515   if ($form->{status} eq 'orphaned') {
 
 516     $option .= $locale->text('Orphaned');
 
 518   if ($form->{partsgroup}) {
 
 519     $callback .= "&partsgroup=$form->{partsgroup}";
 
 520     $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
 
 523   @column_index = $form->sort_columns(qw(partsgroup));
 
 525   $column_header{partsgroup} =
 
 526     qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
 
 528   $form->{title} = $locale->text('Groups');
 
 537     <th class=listtop>$form->{title}</th>
 
 546         <tr class=listheading>
 
 549   map { print "$column_header{$_}\n" } @column_index;
 
 556   $form->{callback} = $callback;
 
 558   # escape callback for href
 
 559   $callback = $form->escape($callback);
 
 561   foreach $ref (@{ $form->{item_list} }) {
 
 567         <tr valign=top class=listrow$i>
 
 570     $column_data{partsgroup} =
 
 571       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>|;
 
 572     map { print "$column_data{$_}\n" } @column_index;
 
 584     <td><hr size=3 noshade></td>
 
 589 <form method=post action=$form->{script}>
 
 591 <input name=callback type=hidden value="$form->{callback}">
 
 593 <input type=hidden name=type value=$form->{type}>
 
 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 <input class=submit type=submit name=action value="|
 
 600     . $locale->text('Add') . qq|">
 
 608   $lxdebug->leave_sub();
 
 611 sub form_partsgroup_header {
 
 612   $lxdebug->enter_sub();
 
 614   $form->{title} = $locale->text("$form->{title} Group");
 
 616   # $locale->text('Add Group')
 
 617   # $locale->text('Edit Group')
 
 619   $form->{partsgroup} =~ s/\"/"/g;
 
 626 <form method=post action=$form->{script}>
 
 628 <input type=hidden name=id value=$form->{id}>
 
 629 <input type=hidden name=type value=$form->{type}>
 
 633     <th class=listtop>$form->{title}</th>
 
 640           <th align=right>| . $locale->text('Group') . qq|</th>
 
 642           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
 
 648     <td colspan=2><hr size=3 noshade></td>
 
 653   $lxdebug->leave_sub();
 
 656 sub form_partsgroup_footer {
 
 657   $lxdebug->enter_sub();
 
 661 <input name=callback type=hidden value="$form->{callback}">
 
 663 <input type=hidden name=path value=$form->{path}>
 
 664 <input type=hidden name=login value=$form->{login}>
 
 665 <input type=hidden name=password value=$form->{password}>
 
 667 <br><input type=submit class=submit name=action value="|
 
 668     . $locale->text('Save') . qq|">
 
 671   if ($form->{id} && $form->{orphaned}) {
 
 673 <input type=submit class=submit name=action value="|
 
 674       . $locale->text('Delete') . qq|">|;
 
 677 # button for saving history
 
 679         <input type=button onclick=set_history_window(|
 
 681         . qq|); name=history id=history value=|
 
 682         . $locale->text('history') 
 
 684 # /button for saving history
 
 692   $lxdebug->leave_sub();
 
 695 #################################
 
 696 # get pricesgroups and build up html-code
 
 698 sub pricegroup_report {
 
 699   $lxdebug->enter_sub();
 
 701   map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
 
 702   PE->pricegroups(\%myconfig, \%$form);
 
 705     "$form->{script}?action=pricegroup_report&type=$form->{type}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 707   if ($form->{status} eq 'all') {
 
 708     $option = $locale->text('All');
 
 710   if ($form->{status} eq 'orphaned') {
 
 711     $option .= $locale->text('Orphaned');
 
 713   if ($form->{pricegroup}) {
 
 714     $callback .= "&pricegroup=$form->{pricegroup}";
 
 716       "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
 
 719   @column_index = $form->sort_columns(qw(pricegroup));
 
 721   $column_header{pricegroup} =
 
 722       qq|<th class=listheading width=90%>|
 
 723     . $locale->text('Pricegroup')
 
 726   $form->{title} = $locale->text('Pricegroup');
 
 735     <th class=listtop>$form->{title}</th>
 
 744         <tr class=listheading>
 
 747   map { print "$column_header{$_}\n" } @column_index;
 
 754   $form->{callback} = $callback;
 
 756   # escape callback for href
 
 757   $callback = $form->escape($callback);
 
 759   foreach $ref (@{ $form->{item_list} }) {
 
 765         <tr valign=top class=listrow$i>
 
 767     $column_data{pricegroup} =
 
 768       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>|;
 
 770     map { print "$column_data{$_}\n" } @column_index;
 
 782     <td><hr size=3 noshade></td>
 
 787 <form method=post action=$form->{script}>
 
 789 <input name=callback type=hidden value="$form->{callback}">
 
 791 <input type=hidden name=type value=$form->{type}>
 
 793 <input type=hidden name=path value=$form->{path}>
 
 794 <input type=hidden name=login value=$form->{login}>
 
 795 <input type=hidden name=password value=$form->{password}>
 
 797 <input class=submit type=submit name=action value="|
 
 798     . $locale->text('Add') . qq|">
 
 806   $lxdebug->leave_sub();
 
 809 #######################
 
 810 #build up pricegroup_header
 
 812 sub form_pricegroup_header {
 
 813   $lxdebug->enter_sub();
 
 815   # $locale->text('Add Pricegroup')
 
 816   # $locale->text('Edit Pricegroup')
 
 818   $form->{title} = $locale->text("$form->{title} Pricegroup");
 
 820   $form->{pricegroup} =~ s/\"/"/g;
 
 827 <form method=post action=$form->{script}>
 
 829 <input type=hidden name=id value=$form->{id}>
 
 830 <input type=hidden name=type value=$form->{type}>
 
 834     <th class=listtop>$form->{title}</th>
 
 841           <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
 
 842           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
 
 848     <td colspan=2><hr size=3 noshade></td>
 
 853   $lxdebug->leave_sub();
 
 855 ######################
 
 856 #build up pricegroup_footer
 
 858 sub form_pricegroup_footer {
 
 859   $lxdebug->enter_sub();
 
 863 <input name=callback type=hidden value="$form->{callback}">
 
 865 <input type=hidden name=path value=$form->{path}>
 
 866 <input type=hidden name=login value=$form->{login}>
 
 867 <input type=hidden name=password value=$form->{password}>
 
 869 <br><input type=submit class=submit name=action value="|
 
 870     . $locale->text('Save') . qq|">
 
 873   if ($form->{id} && $form->{orphaned}) {
 
 875 <input type=submit class=submit name=action value="|
 
 876       . $locale->text('Delete') . qq|">|;
 
 879 # button for saving history
 
 881         <input type=button onclick=set_history_window(|
 
 883         . qq|); name=history id=history value=|
 
 884         . $locale->text('history') 
 
 886 # /button for saving history
 
 894   $lxdebug->leave_sub();