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}&login=$form->{login}&password=$form->{password}"
 
  51     unless $form->{callback};
 
  53   call_sub("form_$form->{type}_header");
 
  54   call_sub("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   call_sub("form_$form->{type}_header");
 
  76   call_sub("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=login value=$form->{login}>
 
 177 <input type=hidden name=password value=$form->{password}>
 
 180 <input class=submit type=submit name=action value="|
 
 181     . $locale->text('Continue') . qq|">
 
 188   $lxdebug->leave_sub();
 
 192   $lxdebug->enter_sub();
 
 194   map { $form->{$_} = $form->unescape($form->{$_}) }
 
 195     (projectnumber, description);
 
 196   PE->projects(\%myconfig, \%$form);
 
 199     "$form->{script}?action=project_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}&active=" .
 
 203   if ($form->{status} eq 'all') {
 
 204     $option = $locale->text('All');
 
 206   if ($form->{status} eq 'orphaned') {
 
 207     $option .= $locale->text('Orphaned');
 
 209   if ($form->{projectnumber}) {
 
 210     $href     .= "&projectnumber=" . $form->escape($form->{projectnumber});
 
 211     $callback .= "&projectnumber=$form->{projectnumber}";
 
 213       "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
 
 215   if ($form->{description}) {
 
 216     $href     .= "&description=" . $form->escape($form->{description});
 
 217     $callback .= "&description=$form->{description}";
 
 219       "\n<br>" . $locale->text('Description') . " : $form->{description}";
 
 222   @column_index = qw(projectnumber description);
 
 224   push(@column_index, "active") if ("both" eq $form->{active});
 
 226   $column_header{projectnumber} =
 
 227       qq|<th><a class=listheading href=$href&sort=projectnumber>|
 
 228     . $locale->text('Number')
 
 230   $column_header{description} =
 
 231       qq|<th><a class=listheading href=$href&sort=description>|
 
 232     . $locale->text('Description')
 
 234   $column_header{active} =
 
 235       qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
 
 237   $form->{title} = $locale->text('Projects');
 
 246     <th class=listtop>$form->{title}</th>
 
 255         <tr class=listheading>
 
 258   map { print "$column_header{$_}\n" } @column_index;
 
 265   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
 267   # escape callback for href
 
 268   $callback = $form->escape($callback);
 
 270   foreach $ref (@{ $form->{project_list} }) {
 
 276         <tr valign=top class=listrow$i>
 
 279     $column_data{projectnumber} =
 
 280       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{projectnumber}</td>|;
 
 281     $column_data{description} = qq|<td>$ref->{description} </td>|;
 
 282     $column_data{active} =
 
 284       ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
 
 287     map { print "$column_data{$_}\n" } @column_index;
 
 299     <td><hr size=3 noshade></td>
 
 304 <form method=post action=$form->{script}>
 
 306 <input name=callback type=hidden value="$form->{callback}">
 
 308 <input type=hidden name=type value=$form->{type}>
 
 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=login value=$form->{login}>
 
 415 <input type=hidden name=password value=$form->{password}>
 
 417 <br><input type=submit class=submit name=action value="|
 
 418     . $locale->text('Save') . qq|">
 
 421   if ($form->{id} && $form->{orphaned}) {
 
 423 <input type=submit class=submit name=action value="|
 
 424       . $locale->text('Delete') . qq|">|;
 
 427 # button for saving history
 
 429         <input type=button onclick=set_history_window(|
 
 431         . qq|); name=history id=history value=|
 
 432         . $locale->text('history') 
 
 434 # /button for saving history
 
 442   $lxdebug->leave_sub();
 
 446   $lxdebug->enter_sub();
 
 448   if ($form->{type} eq 'project') {
 
 449     $form->isblank("projectnumber", $locale->text('Project Number missing!'));
 
 450     PE->save_project(\%myconfig, \%$form);
 
 451     $form->redirect($locale->text('Project saved!'));
 
 453   if ($form->{type} eq 'partsgroup') {
 
 454     $form->isblank("partsgroup", $locale->text('Group missing!'));
 
 455     PE->save_partsgroup(\%myconfig, \%$form);
 
 456     $form->redirect($locale->text('Group saved!'));
 
 459   # choice pricegroup and save
 
 460   if ($form->{type} eq 'pricegroup') {
 
 461     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
 
 462     PE->save_pricegroup(\%myconfig, \%$form);
 
 463     $form->redirect($locale->text('Pricegroup saved!'));
 
 466   if(!exists $form->{addition} && $form->{id} ne "") {
 
 467     $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
 
 468         $form->{addition} = "SAVED";
 
 469         $form->save_history($form->dbconnect(\%myconfig));
 
 471   # /saving the history 
 
 473   $lxdebug->leave_sub();
 
 477   $lxdebug->enter_sub();
 
 479   PE->delete_tuple(\%myconfig, \%$form);
 
 481   if ($form->{type} eq 'project') {
 
 482     $form->redirect($locale->text('Project deleted!'));
 
 484   if ($form->{type} eq 'partsgroup') {
 
 485     $form->redirect($locale->text('Group deleted!'));
 
 487   if ($form->{type} eq 'pricegroup') {
 
 488     $form->redirect($locale->text('Pricegroup deleted!'));
 
 491   if(!exists $form->{addition}) {
 
 492     $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
 
 493         $form->{addition} = "DELETED";
 
 494         $form->save_history($form->dbconnect(\%myconfig));
 
 496   # /saving the history
 
 497   $lxdebug->leave_sub();
 
 500 sub continue { call_sub($form->{"nextsub"}); }
 
 502 sub partsgroup_report {
 
 503   $lxdebug->enter_sub();
 
 505   map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
 
 506   PE->partsgroups(\%myconfig, \%$form);
 
 509     "$form->{script}?action=partsgroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 511   if ($form->{status} eq 'all') {
 
 512     $option = $locale->text('All');
 
 514   if ($form->{status} eq 'orphaned') {
 
 515     $option .= $locale->text('Orphaned');
 
 517   if ($form->{partsgroup}) {
 
 518     $callback .= "&partsgroup=$form->{partsgroup}";
 
 519     $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
 
 522   @column_index = $form->sort_columns(qw(partsgroup));
 
 524   $column_header{partsgroup} =
 
 525     qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
 
 527   $form->{title} = $locale->text('Groups');
 
 536     <th class=listtop>$form->{title}</th>
 
 545         <tr class=listheading>
 
 548   map { print "$column_header{$_}\n" } @column_index;
 
 555   $form->{callback} = $callback;
 
 557   # escape callback for href
 
 558   $callback = $form->escape($callback);
 
 560   foreach $ref (@{ $form->{item_list} }) {
 
 566         <tr valign=top class=listrow$i>
 
 569     $column_data{partsgroup} =
 
 570       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partsgroup}</td>|;
 
 571     map { print "$column_data{$_}\n" } @column_index;
 
 583     <td><hr size=3 noshade></td>
 
 588 <form method=post action=$form->{script}>
 
 590 <input name=callback type=hidden value="$form->{callback}">
 
 592 <input type=hidden name=type value=$form->{type}>
 
 594 <input type=hidden name=login value=$form->{login}>
 
 595 <input type=hidden name=password value=$form->{password}>
 
 597 <input class=submit type=submit name=action value="|
 
 598     . $locale->text('Add') . qq|">
 
 606   $lxdebug->leave_sub();
 
 609 sub form_partsgroup_header {
 
 610   $lxdebug->enter_sub();
 
 612   $form->{title} = $locale->text("$form->{title} Group");
 
 614   # $locale->text('Add Group')
 
 615   # $locale->text('Edit Group')
 
 617   $form->{partsgroup} =~ s/\"/"/g;
 
 624 <form method=post action=$form->{script}>
 
 626 <input type=hidden name=id value=$form->{id}>
 
 627 <input type=hidden name=type value=$form->{type}>
 
 631     <th class=listtop>$form->{title}</th>
 
 638           <th align=right>| . $locale->text('Group') . qq|</th>
 
 640           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
 
 646     <td colspan=2><hr size=3 noshade></td>
 
 651   $lxdebug->leave_sub();
 
 654 sub form_partsgroup_footer {
 
 655   $lxdebug->enter_sub();
 
 659 <input name=callback type=hidden value="$form->{callback}">
 
 661 <input type=hidden name=login value=$form->{login}>
 
 662 <input type=hidden name=password value=$form->{password}>
 
 664 <br><input type=submit class=submit name=action value="|
 
 665     . $locale->text('Save') . qq|">
 
 668   if ($form->{id} && $form->{orphaned}) {
 
 670 <input type=submit class=submit name=action value="|
 
 671       . $locale->text('Delete') . qq|">|;
 
 674 # button for saving history
 
 676         <input type=button onclick=set_history_window(|
 
 678         . qq|); name=history id=history value=|
 
 679         . $locale->text('history') 
 
 681 # /button for saving history
 
 689   $lxdebug->leave_sub();
 
 692 #################################
 
 693 # get pricesgroups and build up html-code
 
 695 sub pricegroup_report {
 
 696   $lxdebug->enter_sub();
 
 698   map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
 
 699   PE->pricegroups(\%myconfig, \%$form);
 
 702     "$form->{script}?action=pricegroup_report&type=$form->{type}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 704   if ($form->{status} eq 'all') {
 
 705     $option = $locale->text('All');
 
 707   if ($form->{status} eq 'orphaned') {
 
 708     $option .= $locale->text('Orphaned');
 
 710   if ($form->{pricegroup}) {
 
 711     $callback .= "&pricegroup=$form->{pricegroup}";
 
 713       "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
 
 716   @column_index = $form->sort_columns(qw(pricegroup));
 
 718   $column_header{pricegroup} =
 
 719       qq|<th class=listheading width=90%>|
 
 720     . $locale->text('Pricegroup')
 
 723   $form->{title} = $locale->text('Pricegroup');
 
 732     <th class=listtop>$form->{title}</th>
 
 741         <tr class=listheading>
 
 744   map { print "$column_header{$_}\n" } @column_index;
 
 751   $form->{callback} = $callback;
 
 753   # escape callback for href
 
 754   $callback = $form->escape($callback);
 
 756   foreach $ref (@{ $form->{item_list} }) {
 
 762         <tr valign=top class=listrow$i>
 
 764     $column_data{pricegroup} =
 
 765       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{pricegroup}</td>|;
 
 767     map { print "$column_data{$_}\n" } @column_index;
 
 779     <td><hr size=3 noshade></td>
 
 784 <form method=post action=$form->{script}>
 
 786 <input name=callback type=hidden value="$form->{callback}">
 
 788 <input type=hidden name=type value=$form->{type}>
 
 790 <input type=hidden name=login value=$form->{login}>
 
 791 <input type=hidden name=password value=$form->{password}>
 
 793 <input class=submit type=submit name=action value="|
 
 794     . $locale->text('Add') . qq|">
 
 802   $lxdebug->leave_sub();
 
 805 #######################
 
 806 #build up pricegroup_header
 
 808 sub form_pricegroup_header {
 
 809   $lxdebug->enter_sub();
 
 811   # $locale->text('Add Pricegroup')
 
 812   # $locale->text('Edit Pricegroup')
 
 814   $form->{title} = $locale->text("$form->{title} Pricegroup");
 
 816   $form->{pricegroup} =~ s/\"/"/g;
 
 823 <form method=post action=$form->{script}>
 
 825 <input type=hidden name=id value=$form->{id}>
 
 826 <input type=hidden name=type value=$form->{type}>
 
 830     <th class=listtop>$form->{title}</th>
 
 837           <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
 
 838           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
 
 844     <td colspan=2><hr size=3 noshade></td>
 
 849   $lxdebug->leave_sub();
 
 851 ######################
 
 852 #build up pricegroup_footer
 
 854 sub form_pricegroup_footer {
 
 855   $lxdebug->enter_sub();
 
 859 <input name=callback type=hidden value="$form->{callback}">
 
 861 <input type=hidden name=login value=$form->{login}>
 
 862 <input type=hidden name=password value=$form->{password}>
 
 864 <br><input type=submit class=submit name=action value="|
 
 865     . $locale->text('Save') . qq|">
 
 868   if ($form->{id} && $form->{orphaned}) {
 
 870 <input type=submit class=submit name=action value="|
 
 871       . $locale->text('Delete') . qq|">|;
 
 874 # button for saving history
 
 876         <input type=button onclick=set_history_window(|
 
 878         . qq|); name=history id=history value=|
 
 879         . $locale->text('history') 
 
 881 # /button for saving history
 
 889   $lxdebug->leave_sub();