Aus Versehen wurde in 4026 diese Änderung rückgängig gemacht, also noch einmal committen.
[kivitendo-erp.git] / bin / mozilla / am.pl
index 45333c1..da221ae 100644 (file)
@@ -55,6 +55,7 @@ sub delete   { call_sub("delete_$form->{type}"); }
 sub save     { call_sub("save_$form->{type}"); }
 sub edit     { call_sub("edit_$form->{type}"); }
 sub continue { call_sub($form->{"nextsub"}); }
+sub save_as_new { call_sub("save_as_new_$form->{type}"); }
 
 sub add_account {
   $lxdebug->enter_sub();
@@ -373,6 +374,12 @@ sub form_footer {
       . $locale->text('Delete') . qq|">|;
   }
 
+  if ($form->{id} && $form->{type} eq "account") {
+    print qq|
+    <input class=submit type=submit name=action value="|
+      . $locale->text('Save as new') . qq|">|;
+  }
+
   print qq|
 </form>
 
@@ -402,6 +409,36 @@ sub save_account {
   $lxdebug->leave_sub();
 }
 
+sub save_as_new_account {
+  $lxdebug->enter_sub();
+
+  $auth->assert('config');
+
+  $form->isblank("accno",       $locale->text('Account Number missing!'));
+  $form->isblank("description", $locale->text('Account Description missing!'));
+  
+  if ($form->{charttype} eq 'A'){
+    $form->isblank("category",  $locale->text('Account Type missing!'));
+  }
+
+  for my $taxkey (0 .. 9) {
+    if ($form->{"taxkey_id_$taxkey"}) {
+      $form->{"taxkey_id_$taxkey"} = "NEW";
+    }
+  }
+
+  $form->{id} = 0;
+  if ($form->{"original_accno"} &&
+      ($form->{"accno"} eq $form->{"original_accno"})) {
+    $form->error($locale->text('Account Number already used!'));
+  }
+  $form->redirect($locale->text('Account saved!'))
+    if (AM->save_account(\%myconfig, \%$form));
+  $form->error($locale->text('Cannot save account!'));
+
+  $lxdebug->leave_sub();
+}
+
 sub list_account {
   $lxdebug->enter_sub();
 
@@ -2489,10 +2526,9 @@ sub config {
     };
   }
 
-  $myconfig{show_form_details}              = 1 unless (defined($myconfig{show_form_details}));
-  $form->{"menustyle_$myconfig{menustyle}"} = 1;
-  $form->{CAN_CHANGE_PASSWORD}              = $auth->can_change_password();
-  $form->{todo_cfg}                         = { TODO->get_user_config('login' => $form->{login}) };
+  $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
+  $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password();
+  $form->{todo_cfg}            = { TODO->get_user_config('login' => $form->{login}) };
 
   $form->{title}                            = $locale->text('Edit Preferences for #1', $form->{login});