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 # partsgroup, pricegroup administration
 
  32 #======================================================================
 
  36 require "bin/mozilla/common.pl";
 
  45   $main::lxdebug->enter_sub();
 
  47   $main::auth->assert('config');
 
  49   my $form     = $main::form;
 
  51   $form->{title} = "Add";
 
  55     "$form->{script}?action=add&type=$form->{type}"
 
  56     unless $form->{callback};
 
  58   call_sub("form_$form->{type}_header");
 
  59   call_sub("form_$form->{type}_footer");
 
  61   $main::lxdebug->leave_sub();
 
  65   $main::lxdebug->enter_sub();
 
  67   $main::auth->assert('config');
 
  69   my $form     = $main::form;
 
  70   my %myconfig = %main::myconfig;
 
  73   $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
 
  74   #/show hhistory button
 
  75   $form->{title} = "Edit";
 
  77   if ($form->{type} eq 'partsgroup') {
 
  78     PE->get_partsgroup(\%myconfig, \%$form);
 
  80   if ($form->{type} eq 'pricegroup') {
 
  81     PE->get_pricegroup(\%myconfig, \%$form);
 
  83   call_sub("form_$form->{type}_header");
 
  84   call_sub("form_$form->{type}_footer");
 
  86   $main::lxdebug->leave_sub();
 
  90   $main::lxdebug->enter_sub();
 
  92   $main::auth->assert('config');
 
  94   my $form     = $main::form;
 
  95   my $locale   = $main::locale;
 
  97   my ($report, $sort, $number);
 
  98   if ($form->{type} eq 'partsgroup') {
 
  99     $report        = "partsgroup_report";
 
 100     $sort          = 'partsgroup';
 
 101     $form->{title} = $locale->text('Groups');
 
 105     <th align=right width=1%>| . $locale->text('Group') . qq|</th>
 
 106     <td><input name=partsgroup size=20></td>
 
 113   if ($form->{type} eq 'pricegroup') {
 
 114     $report        = "pricegroup_report";
 
 115     $sort          = 'pricegroup';
 
 116     $form->{title} = $locale->text('Pricegroup');
 
 120     <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
 
 121     <td><input name=pricegroup size=20></td>
 
 132 <form method=post action=$form->{script}>
 
 134 <input type=hidden name=sort value=$sort>
 
 135 <input type=hidden name=type value=$form->{type}>
 
 139     <th class=listtop>$form->{title}</th>
 
 148           <td><input name=status class=radio type=radio value=all checked> | . $locale->text('All') . qq|
 
 149           <input name=status class=radio type=radio value=orphaned> | . $locale->text('Orphaned') . qq|</td>
 
 155     <td><hr size=3 noshade></td>
 
 159 <input type=hidden name=nextsub value=$report>
 
 162 <input class=submit type=submit name=action value="|
 
 163     . $locale->text('Continue') . qq|">
 
 170   $main::lxdebug->leave_sub();
 
 174   $main::lxdebug->enter_sub();
 
 176   $main::auth->assert('config');
 
 178   my $form     = $main::form;
 
 179   my %myconfig = %main::myconfig;
 
 180   my $locale   = $main::locale;
 
 182   if ($form->{type} eq 'partsgroup') {
 
 183     $form->isblank("partsgroup", $locale->text('Group missing!'));
 
 184     PE->save_partsgroup(\%myconfig, \%$form);
 
 185     $form->redirect($locale->text('Group saved!'));
 
 188   # choice pricegroup and save
 
 189   if ($form->{type} eq 'pricegroup') {
 
 190     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
 
 191     PE->save_pricegroup(\%myconfig, \%$form);
 
 192     $form->redirect($locale->text('Pricegroup saved!'));
 
 195   if(!exists $form->{addition} && $form->{id} ne "") {
 
 196     $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
 
 197     $form->{addition} = "SAVED";
 
 200   # /saving the history
 
 202   $main::lxdebug->leave_sub();
 
 206   $main::lxdebug->enter_sub();
 
 208   $main::auth->assert('config');
 
 210   my $form     = $main::form;
 
 211   my %myconfig = %main::myconfig;
 
 212   my $locale   = $main::locale;
 
 214   PE->delete_tuple(\%myconfig, \%$form);
 
 216   if ($form->{type} eq 'partsgroup') {
 
 217     $form->redirect($locale->text('Group deleted!'));
 
 219   if ($form->{type} eq 'pricegroup') {
 
 220     $form->redirect($locale->text('Pricegroup deleted!'));
 
 223   if(!exists $form->{addition}) {
 
 224     $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
 
 225     $form->{addition} = "DELETED";
 
 228   # /saving the history
 
 229   $main::lxdebug->leave_sub();
 
 232 sub continue { call_sub($main::form->{"nextsub"}); }
 
 234 sub partsgroup_report {
 
 235   $main::lxdebug->enter_sub();
 
 237   $main::auth->assert('config');
 
 239   my $form     = $main::form;
 
 240   my %myconfig = %main::myconfig;
 
 241   my $locale   = $main::locale;
 
 243   map { $form->{$_} = $form->unescape($form->{$_}) } qw(partsgroup);
 
 244   PE->partsgroups(\%myconfig, \%$form);
 
 247     "$form->{script}?action=partsgroup_report&type=$form->{type}&status=$form->{status}";
 
 250   if ($form->{status} eq 'all') {
 
 251     $option = $locale->text('All');
 
 253   if ($form->{status} eq 'orphaned') {
 
 254     $option .= $locale->text('Orphaned');
 
 256   if ($form->{partsgroup}) {
 
 257     $callback .= "&partsgroup=$form->{partsgroup}";
 
 258     $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
 
 261   my @column_index = $form->sort_columns(qw(partsgroup));
 
 263   $column_header{partsgroup} =
 
 264     qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
 
 266   $form->{title} = $locale->text('Groups');
 
 275     <th class=listtop>$form->{title}</th>
 
 284         <tr class=listheading>
 
 287   map { print "$column_header{$_}\n" } @column_index;
 
 294   $form->{callback} = $callback;
 
 296   # escape callback for href
 
 297   $callback = $form->escape($callback);
 
 299   my ($i, %column_data);
 
 300   foreach my $ref (@{ $form->{item_list} }) {
 
 306         <tr valign=top class=listrow$i>
 
 309     $column_data{partsgroup} =
 
 310       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{partsgroup}</td>|;
 
 311     map { print "$column_data{$_}\n" } @column_index;
 
 323     <td><hr size=3 noshade></td>
 
 328 <form method=post action=$form->{script}>
 
 330 <input name=callback type=hidden value="$form->{callback}">
 
 332 <input type=hidden name=type value=$form->{type}>
 
 334 <input class=submit type=submit name=action value="|
 
 335     . $locale->text('Add') . qq|">
 
 343   $main::lxdebug->leave_sub();
 
 346 sub form_partsgroup_header {
 
 347   $main::lxdebug->enter_sub();
 
 349   $main::auth->assert('config');
 
 351   my $form     = $main::form;
 
 352   my $locale   = $main::locale;
 
 354   $form->{title} = $locale->text("$form->{title} Group");
 
 356   # $locale->text('Add Group')
 
 357   # $locale->text('Edit Group')
 
 359   $form->{partsgroup} =~ s/\"/"/g;
 
 366 <form method=post action=$form->{script}>
 
 368 <input type=hidden name=id value=$form->{id}>
 
 369 <input type=hidden name=type value=$form->{type}>
 
 373     <th class=listtop>$form->{title}</th>
 
 380           <th align=right>| . $locale->text('Group') . qq|</th>
 
 381           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
 
 387     <td colspan=2><hr size=3 noshade></td>
 
 392   $main::lxdebug->leave_sub();
 
 395 sub form_partsgroup_footer {
 
 396   $main::lxdebug->enter_sub();
 
 398   $main::auth->assert('config');
 
 400   my $form     = $main::form;
 
 401   my $locale   = $main::locale;
 
 405 <input name=callback type=hidden value="$form->{callback}">
 
 407 <br><input type=submit class=submit name=action value="|
 
 408     . $locale->text('Save') . qq|">
 
 411   if ($form->{id} && $form->{orphaned}) {
 
 413 <input type=submit class=submit name=action value="|
 
 414       . $locale->text('Delete') . qq|">|;
 
 417 # button for saving history
 
 419     <input type=button onclick=set_history_window(|
 
 421     . qq|); name=history id=history value=|
 
 422     . $locale->text('history')
 
 424 # /button for saving history
 
 432   $main::lxdebug->leave_sub();
 
 435 #################################
 
 436 # get pricesgroups and build up html-code
 
 438 sub pricegroup_report {
 
 439   $main::lxdebug->enter_sub();
 
 441   $main::auth->assert('config');
 
 443   my $form     = $main::form;
 
 444   my %myconfig = %main::myconfig;
 
 445   my $locale   = $main::locale;
 
 447   map { $form->{$_} = $form->unescape($form->{$_}) } qw(pricegroup);
 
 448   PE->pricegroups(\%myconfig, \%$form);
 
 451     "$form->{script}?action=pricegroup_report&type=$form->{type}&status=$form->{status}";
 
 454   if ($form->{status} eq 'all') {
 
 455     $option = $locale->text('All');
 
 457   if ($form->{status} eq 'orphaned') {
 
 458     $option .= $locale->text('Orphaned');
 
 460   if ($form->{pricegroup}) {
 
 461     $callback .= "&pricegroup=$form->{pricegroup}";
 
 463       "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
 
 466   my @column_index = $form->sort_columns(qw(pricegroup));
 
 468   $column_header{pricegroup} =
 
 469       qq|<th class=listheading width=90%>|
 
 470     . $locale->text('Pricegroup')
 
 473   $form->{title} = $locale->text('Pricegroup');
 
 482     <th class=listtop>$form->{title}</th>
 
 491         <tr class=listheading>
 
 494   map { print "$column_header{$_}\n" } @column_index;
 
 501   $form->{callback} = $callback;
 
 503   # escape callback for href
 
 504   $callback = $form->escape($callback);
 
 506   my ($i, %column_data);
 
 507   foreach my $ref (@{ $form->{item_list} }) {
 
 513         <tr valign=top class=listrow$i>
 
 515     $column_data{pricegroup} =
 
 516       qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{pricegroup}</td>|;
 
 518     map { print "$column_data{$_}\n" } @column_index;
 
 530     <td><hr size=3 noshade></td>
 
 535 <form method=post action=$form->{script}>
 
 537 <input name=callback type=hidden value="$form->{callback}">
 
 539 <input type=hidden name=type value=$form->{type}>
 
 541 <input class=submit type=submit name=action value="|
 
 542     . $locale->text('Add') . qq|">
 
 550   $main::lxdebug->leave_sub();
 
 553 #######################
 
 554 #build up pricegroup_header
 
 556 sub form_pricegroup_header {
 
 557   $main::lxdebug->enter_sub();
 
 559   $main::auth->assert('config');
 
 561   my $form     = $main::form;
 
 562   my $locale   = $main::locale;
 
 564   # $locale->text('Add Pricegroup')
 
 565   # $locale->text('Edit Pricegroup')
 
 567   $form->{title} = $locale->text("$form->{title} Pricegroup");
 
 569   $form->{pricegroup} =~ s/\"/"/g;
 
 576 <form method=post action=$form->{script}>
 
 578 <input type=hidden name=id value=$form->{id}>
 
 579 <input type=hidden name=type value=$form->{type}>
 
 583     <th class=listtop>$form->{title}</th>
 
 590           <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
 
 591           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
 
 597     <td colspan=2><hr size=3 noshade></td>
 
 602   $main::lxdebug->leave_sub();
 
 604 ######################
 
 605 #build up pricegroup_footer
 
 607 sub form_pricegroup_footer {
 
 608   $main::lxdebug->enter_sub();
 
 610   $main::auth->assert('config');
 
 612   my $form     = $main::form;
 
 613   my $locale   = $main::locale;
 
 617 <input name=callback type=hidden value="$form->{callback}">
 
 619 <br><input type=submit class=submit name=action value="|
 
 620     . $locale->text('Save') . qq|">
 
 623   if ($form->{id} && $form->{orphaned}) {
 
 625 <input type=submit class=submit name=action value="|
 
 626       . $locale->text('Delete') . qq|">|;
 
 629 # button for saving history
 
 631     <input type=button onclick=set_history_window(|
 
 633     . qq|); name=history id=history value=|
 
 634     . $locale->text('history')
 
 636 # /button for saving history
 
 644   $main::lxdebug->leave_sub();