Fehlende Steuerschlüssel
[kivitendo-erp.git] / bin / mozilla / amcvar.pl
index a3e281f..343350a 100644 (file)
@@ -38,12 +38,15 @@ use SL::Form;
 use Data::Dumper;
 use List::MoreUtils qw(any);
 
-1;
-
 require "bin/mozilla/common.pl";
 
+use strict;
+
+1;
+
 # end of main
 
+my $locale   = $main::locale;
 our %translations = ('text'      => $locale->text('Free-form text'),
                      'textfield' => $locale->text('Text field'),
                      'number'    => $locale->text('Number'),
@@ -51,11 +54,15 @@ our %translations = ('text'      => $locale->text('Free-form text'),
                      'timestamp' => $locale->text('Timestamp'),
                      'bool'      => $locale->text('Yes/No (Checkbox)'),
                      'select'    => $locale->text('Selection'),
+                     'customer'  => $locale->text('Customer'),
+                     'vendor'    => $locale->text('Vendor'),
+                     'part'      => $locale->text('Part'),
                      );
 
-our @types = qw(text textfield number date bool select); # timestamp
+our @types = qw(text textfield number date bool select customer vendor part); # timestamp
 
 our @modules = ({ module => 'CT',       description => $locale->text('Customers and vendors')          },
+                { module => 'Contacts', description => $locale->text('Contact persons')                },
                 { module => 'IC',       description => $locale->text('Parts, services and assemblies') },
                 { module => 'Projects', description => $locale->text('Projects')                       },
                );
@@ -75,26 +82,20 @@ sub _is_valid_module {
 }
 
 sub list_cvar_configs {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
+  my $locale   = $main::locale;
 
-  $auth->assert('config');
+  $main::auth->assert('config');
 
   $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
   $form->{module} = 'CT' unless _is_valid_module($form->{module});
 
   my @configs = @{ CVar->get_configs(module => $form->{module}) };
 
-  my $previous_config;
-
   foreach my $config (@configs) {
     $config->{type_tr} = $translations{$config->{type}};
-
-    if ($previous_config) {
-      $previous_config->{next_id} = $config->{id};
-      $config->{previous_id}      = $previous_config->{id};
-    }
-
-    $previous_config = $config;
   }
 
   $form->{title} = $locale->text('List of custom variables');
@@ -102,28 +103,32 @@ sub list_cvar_configs {
   print $form->parse_html_template('amcvar/list_cvar_configs', { CONFIGS => \@configs,
                                                                  MODULES => \@modules });
 
-  $main::lxdebug->dump(0, "modules", \@modules);
+#  $main::lxdebug->dump(0, "modules", \@modules);
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
 sub add_cvar_config {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
 
-  $auth->assert('config');
+  $main::auth->assert('config');
 
   $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
 
   $form->{edit} = 0;
   display_cvar_config_form();
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
 sub edit_cvar_config {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
 
-  $auth->assert('config');
+  $main::auth->assert('config');
 
   my $config = CVar->get_config('id' => $form->{id});
 
@@ -132,13 +137,17 @@ sub edit_cvar_config {
   $form->{edit} = 1;
   display_cvar_config_form();
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
 sub save {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
 
-  $auth->assert('config');
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+  my $locale   = $main::locale;
+
+  $main::auth->assert('config');
 
   $form->isblank('name',        $locale->text('The name is missing.'));
   $form->isblank('description', $locale->text('The description is missing.'));
@@ -163,11 +172,14 @@ sub save {
 
   list_cvar_configs();
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
 sub delete {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
+  my $locale   = $main::locale;
 
   CVar->delete_config('id' => $form->{id});
 
@@ -175,13 +187,17 @@ sub delete {
 
   list_cvar_configs();
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
 sub display_cvar_config_form {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+  my $locale   = $main::locale;
 
-  $auth->assert('config');
+  $main::auth->assert('config');
 
   my @types = map { { 'type' => $_, 'type_tr' => $translations{$_} } } @types;
 
@@ -195,21 +211,30 @@ sub display_cvar_config_form {
   print $form->parse_html_template("amcvar/display_cvar_config_form", { TYPES   => \@types,
                                                                         MODULES => \@modules });
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
-sub swap_cvar_configs {
-  $lxdebug->enter_sub();
+sub update {
+  $main::lxdebug->enter_sub();
 
-  AM->swap_sortkeys(\%myconfig, $form, 'custom_variable_configs');
+  my $form     = $main::form;
 
-  list_cvar_configs();
+  $main::auth->assert('config');
+
+  $form->{included_by_default} = $form->{inclusion} eq 'yes_default_on';
+  $form->{includeable}         = $form->{inclusion} ne 'no';
+
+  display_cvar_config_form();
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
 
+
 sub dispatcher {
-  foreach my $action (qw(list_cvar_configs add_cvar_config)) {
+  my $form     = $main::form;
+  my $locale   = $main::locale;
+
+  foreach my $action (qw(list_cvar_configs add_cvar_config update)) {
     if ($form->{"action_${action}"}) {
       call_sub($action);
       return;
@@ -220,3 +245,4 @@ sub dispatcher {
 }
 
 1;
+