143 |
143 |
# create links
|
144 |
144 |
$form->create_links("AR", \%myconfig, "customer");
|
145 |
145 |
|
146 |
|
if ($form->{all_customer}) {
|
147 |
|
unless ($form->{customer_id}) {
|
148 |
|
$form->{customer_id} = $form->{all_customer}->[0]->{id};
|
149 |
|
$form->{salesman_id} = $form->{all_customer}->[0]->{salesman_id};
|
150 |
|
}
|
151 |
|
}
|
152 |
|
|
153 |
146 |
my $editing = $form->{id};
|
154 |
147 |
|
155 |
148 |
$form->backup_vars(qw(payment_id language_id taxzone_id salesman_id
|
... | ... | |
158 |
151 |
|
159 |
152 |
IS->get_customer(\%myconfig, \%$form);
|
160 |
153 |
|
161 |
|
#quote all_customer Bug 133
|
162 |
|
foreach my $ref (@{ $form->{all_customer} }) {
|
163 |
|
$ref->{name} = $form->quote($ref->{name});
|
164 |
|
}
|
165 |
|
|
166 |
154 |
$form->restore_vars(qw(id));
|
167 |
155 |
|
168 |
156 |
IS->retrieve_invoice(\%myconfig, \%$form);
|
... | ... | |
171 |
159 |
$form->restore_vars(qw(taxincluded)) if $form->{id};
|
172 |
160 |
$form->restore_vars(qw(salesman_id)) if $editing;
|
173 |
161 |
|
174 |
|
|
175 |
|
# build vendor/customer drop down compatibility... don't ask
|
176 |
|
if (@{ $form->{"all_customer"} }) {
|
177 |
|
$form->{"selectcustomer"} = 1;
|
178 |
|
$form->{customer} = qq|$form->{customer}--$form->{"customer_id"}|;
|
179 |
|
}
|
180 |
|
|
181 |
|
$form->{"oldcustomer"} = $form->{customer};
|
182 |
|
|
183 |
|
if ($form->{"oldcustomer"} !~ m/--\d+$/ && $form->{"customer_id"}) {
|
184 |
|
$form->{"oldcustomer"} .= qq|--$form->{"customer_id"}|
|
185 |
|
}
|
186 |
|
|
187 |
|
|
188 |
|
# $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
|
189 |
|
# $form->{selectcustomer} = 1;
|
190 |
|
|
191 |
162 |
$form->{employee} = "$form->{employee}--$form->{employee_id}";
|
192 |
163 |
|
193 |
164 |
# forex
|
... | ... | |
291 |
262 |
my %TMPL_VAR = ();
|
292 |
263 |
my @custom_hiddens;
|
293 |
264 |
|
294 |
|
if ($form->{id}) {
|
295 |
|
require SL::DB::Invoice;
|
296 |
|
$TMPL_VAR{invoice_obj} = SL::DB::Invoice->new(id => $form->{id})->load;
|
297 |
|
}
|
|
265 |
$TMPL_VAR{customer_obj} = SL::DB::Customer->load_cached($form->{customer_id}) if $form->{customer_id};
|
|
266 |
$TMPL_VAR{invoice_obj} = SL::DB::Invoice->load_cached($form->{id}) if $form->{id};
|
|
267 |
|
298 |
268 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
|
299 |
269 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
|
300 |
270 |
|
... | ... | |
302 |
272 |
|
303 |
273 |
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
|
304 |
274 |
"currencies" => "ALL_CURRENCIES",
|
305 |
|
"customers" => "ALL_CUSTOMERS",
|
306 |
275 |
"price_factors" => "ALL_PRICE_FACTORS");
|
307 |
276 |
|
308 |
277 |
$form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
|
... | ... | |
342 |
311 |
]);
|
343 |
312 |
$TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" };
|
344 |
313 |
|
345 |
|
# customer
|
346 |
|
$TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
|
347 |
|
$TMPL_VAR{vclimit} = $myconfig{vclimit};
|
348 |
|
$TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('customer', '', 0, 0)";
|
349 |
|
push @custom_hiddens, "customer_id";
|
350 |
|
push @custom_hiddens, "oldcustomer";
|
351 |
|
push @custom_hiddens, "selectcustomer";
|
352 |
|
|
353 |
314 |
# currencies and exchangerate
|
354 |
315 |
my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
|
355 |
316 |
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
|
... | ... | |
365 |
326 |
$TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
|
366 |
327 |
$TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
|
367 |
328 |
|
368 |
|
my $follow_up_vc = $form->{customer};
|
369 |
|
$follow_up_vc =~ s/--\d*\s*$//;
|
370 |
|
$TMPL_VAR{customer_name} = $follow_up_vc;
|
371 |
|
|
372 |
329 |
# set option selected
|
373 |
330 |
foreach my $item (qw(AR)) {
|
374 |
331 |
$form->{"select$item"} =~ s/ selected//;
|
... | ... | |
448 |
405 |
$form->{taxaccounts_array} = [ split(/ /, $form->{taxaccounts}) ];
|
449 |
406 |
|
450 |
407 |
if( $form->{customer_id} && !$form->{taxincluded_changed_by_user} ) {
|
451 |
|
my $customer = SL::DB::Customer->new(id => $form->{customer_id})->load();
|
|
408 |
my $customer = SL::DB::Customer->load_cached($form->{customer_id});
|
452 |
409 |
$form->{taxincluded} = defined($customer->taxincluded_checked) ? $customer->taxincluded_checked : $myconfig{taxincluded_checked};
|
453 |
410 |
}
|
454 |
411 |
|
... | ... | |
561 |
518 |
my $taxincluded = $form->{taxincluded} ? "checked" : '';
|
562 |
519 |
$form->{update} = 1;
|
563 |
520 |
|
564 |
|
&check_name("customer");
|
|
521 |
if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
|
|
522 |
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
|
|
523 |
|
|
524 |
IS->get_customer(\%myconfig, $form);
|
|
525 |
}
|
565 |
526 |
|
566 |
527 |
$form->{taxincluded} ||= $taxincluded;
|
567 |
528 |
|
... | ... | |
750 |
711 |
|
751 |
712 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
|
752 |
713 |
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
|
753 |
|
$form->isblank("customer", $locale->text('Customer missing!'));
|
|
714 |
$form->isblank("customer_id", $locale->text('Customer missing!'));
|
754 |
715 |
$form->error($locale->text('Cannot post invoice for a closed period!'))
|
755 |
716 |
if ($form->date_closed($form->{"invdate"}, \%myconfig));
|
756 |
717 |
|
... | ... | |
758 |
719 |
$form->{invnumber} =~ s/\s*$//g;
|
759 |
720 |
|
760 |
721 |
# if oldcustomer ne customer redo form
|
761 |
|
if (&check_name('customer')) {
|
|
722 |
if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
|
762 |
723 |
&update;
|
763 |
724 |
$::dispatcher->end_request;
|
764 |
725 |
}
|
Verkaufsrechnungen: Kundenwahl über Picker