Prozentangaben in der Steuerbeschreibung wieder hinzugefuegt
[kivitendo-erp.git] / bin / mozilla / drafts.pl
1 #======================================================================
2 # LX-Office ERP
3 #
4 #======================================================================
5 #
6 # Saving and loading drafts
7 #
8 #======================================================================
9
10 use SL::Drafts;
11
12 require "bin/mozilla/common.pl";
13
14 sub save_draft {
15   $lxdebug->enter_sub();
16
17   if (!$form->{draft_id} && !$form->{draft_description}) {
18     restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM});
19     $form->{SAVED_FORM} = save_form();
20
21     $form->header();
22     print($form->parse_html_template("drafts/save_new"));
23     return $lxdebug->leave_sub();
24   }
25
26   my ($draft_id, $draft_description) =
27     ($form->{draft_id}, $form->{draft_description});
28
29   restore_form($form->{SAVED_FORM}, 1);
30   delete($form->{SAVED_FORM});
31
32   Drafts->save(\%myconfig, $form, $draft_id, $draft_description);
33
34   $form->{saved_message} = $locale->text("Draft saved.");
35
36   update();
37
38   $lxdebug->leave_sub();
39 }
40
41 sub remove_draft {
42   $lxdebug->enter_sub();
43
44   Drafts->remove(\%myconfig, $form, $form->{draft_id}) if ($form->{draft_id});
45
46   delete($form->{draft_id});
47   delete($form->{draft_description});
48
49   $lxdebug->leave_sub();
50 }
51
52 sub load_draft_maybe {
53   $lxdebug->enter_sub();
54
55   $lxdebug->leave_sub() and return 0 if ($form->{DONT_LOAD_DRAFT});
56
57   my ($draft_nextsub) = @_;
58
59   my @drafts = Drafts->list(\%myconfig, $form);
60
61   $lxdebug->leave_sub() and return 0 unless (@drafts);
62
63   $draft_nextsub = "add" unless ($draft_nextsub);
64
65   delete($form->{action});
66   my $saved_form = save_form();
67
68   $form->header();
69   print($form->parse_html_template("drafts/load",
70                                    { "DRAFTS" => \@drafts,
71                                      "SAVED_FORM" => $saved_form,
72                                      "draft_nextsub" => $draft_nextsub }));
73
74   $lxdebug->leave_sub();
75
76   return 1;
77 }
78
79 sub dont_load_draft {
80   $lxdebug->enter_sub();
81
82   my $draft_nextsub = $form->{draft_nextsub};
83   $draft_nextsub = "add" unless ($form->{draft_nextsub});
84   restore_form($form->{SAVED_FORM}, 1);
85   delete($form->{action});
86   $form->{DONT_LOAD_DRAFT} = 1;
87
88   &{ $draft_nextsub }();
89
90   $lxdebug->leave_sub();
91 }
92
93 sub load_draft {
94   $lxdebug->enter_sub();
95
96   my ($old_form, $id, $description) = Drafts->load(\%myconfig, $form, $form->{id});
97   if ($old_form) {
98     restore_form($old_form, 1);
99     $form->{draft_id} = $id;
100     $form->{draft_description} = $description;
101   }
102
103   update();
104
105   $lxdebug->leave_sub();
106 }
107
108 1;