Revision 8f84155d
Von Sven Schöling vor etwa 13 Jahren hinzugefügt
bin/mozilla/bp.pl | ||
---|---|---|
44 | 44 |
# end of main |
45 | 45 |
|
46 | 46 |
sub assert_bp_access { |
47 |
my $form = $main::form; |
|
48 |
|
|
49 | 47 |
my %access_map = ( |
50 | 48 |
'invoice' => 'invoice_edit', |
51 | 49 |
'sales_order' => 'sales_order_edit', |
... | ... | |
56 | 54 |
'receipt' => 'cash', |
57 | 55 |
); |
58 | 56 |
|
59 |
if ($form->{type} && $access_map{$form->{type}}) {
|
|
60 |
$main::auth->assert($access_map{$form->{type}});
|
|
57 |
if ($::form->{type} && $access_map{$::form->{type}}) {
|
|
58 |
$::auth->assert($access_map{$::form->{type}});
|
|
61 | 59 |
|
62 | 60 |
} else { |
63 |
$main::auth->assert('DOES_NOT_EXIST');
|
|
61 |
$::auth->assert('DOES_NOT_EXIST'); |
|
64 | 62 |
} |
65 | 63 |
} |
66 | 64 |
|
... | ... | |
97 | 95 |
} |
98 | 96 |
|
99 | 97 |
sub remove { |
100 |
$main::lxdebug->enter_sub(); |
|
101 |
|
|
102 |
my $form = $main::form; |
|
103 |
my $locale = $main::locale; |
|
104 |
|
|
105 |
assert_bp_access(); |
|
106 |
|
|
107 |
my $selected = 0; |
|
108 |
|
|
109 |
for my $i (1 .. $form->{rowcount}) { |
|
110 |
if ($form->{"checked_$i"}) { |
|
111 |
$selected = 1; |
|
112 |
last; |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
$form->error('Nothing selected!') unless $selected; |
|
117 |
|
|
118 |
$form->{title} = $locale->text('Confirm!'); |
|
119 |
|
|
120 |
$form->header; |
|
121 |
|
|
122 |
print qq| |
|
123 |
<body> |
|
124 |
|
|
125 |
<form method=post action=bp.pl> |
|
126 |
|; |
|
127 |
|
|
128 |
map { delete $form->{$_} } qw(action header); |
|
129 |
|
|
130 |
foreach my $key (keys %$form) { |
|
131 |
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); |
|
132 |
print qq|<input type=hidden name=$key value="$form->{$key}">\n|; |
|
133 |
} |
|
134 |
|
|
135 |
print qq| |
|
136 |
<h2 class=confirm>$form->{title}</h2> |
|
137 |
|
|
138 |
<h4>| |
|
139 |
. $locale->text( |
|
140 |
'Are you sure you want to remove the marked entries from the queue?') |
|
141 |
. qq|</h4> |
|
142 |
|
|
143 |
<input name=action class=submit type=submit value="| |
|
144 |
. $locale->text('Yes') . qq|"> |
|
145 |
</form> |
|
146 |
|
|
147 |
</body> |
|
148 |
</html> |
|
149 |
|; |
|
150 |
|
|
151 |
$main::lxdebug->leave_sub(); |
|
152 |
} |
|
153 |
|
|
154 |
sub yes { |
|
155 |
$main::lxdebug->enter_sub(); |
|
156 |
|
|
157 |
my $form = $main::form; |
|
158 |
my %myconfig = %main::myconfig; |
|
159 |
my $locale = $main::locale; |
|
160 |
|
|
98 |
$::lxdebug->enter_sub; |
|
161 | 99 |
assert_bp_access(); |
162 | 100 |
|
163 |
$form->info($locale->text('Removing marked entries from queue ...'));
|
|
164 |
$form->{callback} .= "&header=1" if $form->{callback};
|
|
101 |
$::form->info($::locale->text('Removing marked entries from queue ...'));
|
|
102 |
$::form->{callback} .= "&header=1" if $::form->{callback};
|
|
165 | 103 |
|
166 |
$form->redirect($locale->text('Removed spoolfiles!'))
|
|
167 |
if (BP->delete_spool(\%myconfig, \%$form));
|
|
168 |
$form->error($locale->text('Cannot remove files!'));
|
|
104 |
$::form->redirect($::locale->text('Removed spoolfiles!'))
|
|
105 |
if BP->delete_spool(\%::myconfig, $::form);
|
|
106 |
$::form->error($::locale->text('Cannot remove files!'));
|
|
169 | 107 |
|
170 |
$main::lxdebug->leave_sub();
|
|
108 |
$::lxdebug->leave_sub;
|
|
171 | 109 |
} |
172 | 110 |
|
173 | 111 |
sub print { |
174 |
$main::lxdebug->enter_sub(); |
|
175 |
|
|
176 |
my $form = $main::form; |
|
177 |
my %myconfig = %main::myconfig; |
|
178 |
my $locale = $main::locale; |
|
179 |
|
|
112 |
$::lxdebug->enter_sub; |
|
180 | 113 |
assert_bp_access(); |
181 | 114 |
|
182 |
$form->get_lists(printers => 'ALL_PRINTERS'); |
|
115 |
$::form->get_lists(printers => 'ALL_PRINTERS');
|
|
183 | 116 |
# use the command stored in the databse or fall back to $myconfig{printer} |
184 | 117 |
my $selected_printer = first { $_ } map ({ $_ ->{printer_command} } |
185 |
grep { $_->{id} eq $form->{printer} } |
|
186 |
@{ $form->{ALL_PRINTERS} }), |
|
187 |
$myconfig{printer}; |
|
188 |
|
|
189 |
if ($form->{callback}) { |
|
190 |
map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
|
|
191 |
(1 .. $form->{rowcount}); |
|
192 |
$form->{callback} .= "&header=1"; |
|
118 |
grep { $_->{id} eq $::form->{printer} }
|
|
119 |
@{ $::form->{ALL_PRINTERS} }),
|
|
120 |
$::myconfig{printer};
|
|
121 |
|
|
122 |
if ($::form->{callback}) {
|
|
123 |
map { $::form->{callback} .= "&checked_$_=1" if $::form->{"checked_$_"} }
|
|
124 |
(1 .. $::form->{rowcount});
|
|
125 |
$::form->{callback} .= "&header=1";
|
|
193 | 126 |
} |
194 | 127 |
|
195 |
for my $i (1 .. $form->{rowcount}) { |
|
196 |
if ($form->{"checked_$i"}) { |
|
197 |
$form->info($locale->text('Printing ... '));
|
|
128 |
for my $i (1 .. $::form->{rowcount}) {
|
|
129 |
if ($::form->{"checked_$i"}) {
|
|
130 |
$::form->info($::locale->text('Printing ... '));
|
|
198 | 131 |
|
199 |
if (BP->print_spool(\%myconfig, \%$form, "| $selected_printer")) {
|
|
200 |
print $locale->text('done'); |
|
201 |
$form->redirect($locale->text('Marked entries printed!'));
|
|
132 |
if (BP->print_spool(\%::myconfig, $::form, "| $selected_printer")) {
|
|
133 |
print $::locale->text('done');
|
|
134 |
$::form->redirect($::locale->text('Marked entries printed!'));
|
|
202 | 135 |
} |
203 | 136 |
::end_of_request(); |
204 | 137 |
} |
205 | 138 |
} |
206 | 139 |
|
207 |
$form->error('Nothing selected!'); |
|
140 |
$::form->error('Nothing selected!');
|
|
208 | 141 |
|
209 |
$main::lxdebug->leave_sub();
|
|
142 |
$::lxdebug->leave_sub;
|
|
210 | 143 |
} |
211 | 144 |
|
212 | 145 |
sub list_spool { |
... | ... | |
262 | 195 |
$::lxdebug->leave_sub; |
263 | 196 |
} |
264 | 197 |
|
265 |
sub select_all { |
|
266 |
$main::lxdebug->enter_sub(); |
|
267 |
|
|
268 |
my $form = $main::form; |
|
269 |
|
|
270 |
assert_bp_access(); |
|
271 |
|
|
272 |
map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount}); |
|
273 |
&list_spool; |
|
274 |
|
|
275 |
$main::lxdebug->leave_sub(); |
|
276 |
} |
|
277 |
|
|
278 |
sub continue { call_sub($main::form->{"nextsub"}); } |
|
198 |
sub continue { call_sub($::form->{"nextsub"}); } |
|
279 | 199 |
|
Auch abrufbar als: Unified diff
bp delete confirm und checkall ins template verschoben.