X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fis.pl;h=77ae22c8b1761180fcf2434c4aeeb56fa43fb3d8;hb=fc490063361896eb3b2aa0939fc0df716ae38262;hp=6ecad007837f259eac22ab135fea1396136b7a33;hpb=01a6bf1b55f003fb6f15a70acf51d3e921af7244;p=kivitendo-erp.git diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 6ecad0078..77ae22c8b 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -83,7 +83,7 @@ sub edit { # show history button $form->{javascript} = qq||; #/show hhistory button - + if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR") { $form->error("Access Denied"); @@ -170,9 +170,8 @@ sub invoice_links { $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; if (@{ $form->{all_customer} }) { - $form->{customer} = "$form->{customer}--$form->{customer_id}"; - map { $form->{selectcustomer} .= "\n" } - (@{ $form->{all_customer} }); + $form->{customer} = "$form->{customer}--$form->{customer_id}"; + $form->{selectcustomer} = "$form->{customer}--$form->{customer_id}"; } # departments @@ -188,13 +187,6 @@ sub invoice_links { $form->{employee} = "$form->{employee}--$form->{employee_id}"; - # sales staff - if ($form->{all_employees}) { - $form->{selectemployee} = ""; - map { $form->{selectemployee} .= "\n" } - (@{ $form->{all_employees} }); - } - # forex $form->{forex} = $form->{exchangerate}; $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; @@ -296,13 +288,13 @@ sub form_header { if ($form->{type} eq "credit_note") { $form->{title} = $locale->text('Edit Credit Note'); - + if ($form->{storno}) { $form->{title} = $locale->text('Edit Storno Credit Note'); } } else { $form->{title} = $locale->text('Edit Sales Invoice'); - + if ($form->{storno}) { $form->{title} = $locale->text('Edit Storno Invoice'); } @@ -338,7 +330,8 @@ sub form_header { "old_id" => \@old_project_ids }, "employees" => "ALL_SALESMEN", "taxzones" => "ALL_TAXZONES", - "currencies" => "ALL_CURRENCIES"); + "currencies" => "ALL_CURRENCIES", + "customers" => "ALL_CUSTOMERS"); my %labels; my @values = (undef); @@ -347,9 +340,53 @@ sub form_header { $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); } - my $contact = - NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"cp_id"})); + my $contact; + if (scalar @values > 1) { + $contact = qq| + + | . $locale->text('Contact Person') . qq| + | . + NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"cp_id"})) + . qq| + + |; + } + + %labels = (); + @values = (); + foreach my $item (@{ $form->{"ALL_SALESMEN"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"name"}; + } + + my $employees = qq| + + | . $locale->text('Employee') . qq| + | . + NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| + + |; + + + %labels = (); + @values = (); + foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) { + push(@values, $item->{name}.qq|--|.$item->{"id"}); + $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"}; + } + + my $customers = qq| + | . $locale->text('Customer') . qq| + | . + (($myconfig{vclimit} <= scalar(@values)) + ? qq|| + : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer}, + '-onChange' => 'document.getElementById(\'update_button\').click();', + '-values' => \@values, '-labels' => \%labels)))) . qq| + + |; %labels = (); @values = (""); @@ -359,12 +396,16 @@ sub form_header { $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"}; } - my $shipto = qq| - | . $locale->text('Shipping Address') . qq| - | . - NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"shipto_id"})) + my $shipto; + if (scalar @values > 1) { + $shipto = qq| + + | . $locale->text('Shipping Address') . qq| + | . + NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"shipto_id"})) . qq||; + } %labels = (); @values = (); @@ -372,9 +413,11 @@ sub form_header { push(@values, $item); $labels{$item} = $item; } - + $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; - my $currencies = qq| + my $currencies; + if (scalar @values) { + $currencies = qq| | . $locale->text('Currency') . qq| | . @@ -382,6 +425,7 @@ sub form_header { '-values' => \@values, '-labels' => \%labels)) . qq| |; + } %labels = (); @values = (""); @@ -450,7 +494,7 @@ sub form_header { #substitute \n and \r to \s (bug 543) $form->{selectcustomer} =~ s/[\n\r]/ /g; - + if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { $creditwarning = 1; } else { @@ -483,14 +527,6 @@ sub form_header { |; - $customer = - ($form->{selectcustomer}) - ? qq|\n| - : qq||; - $department = qq| | . $locale->text('Department') . qq| @@ -505,99 +541,71 @@ onchange="document.getElementById('update_button').click();">| . if ($form->{business}) { $business = qq| - | . $locale->text('Business') . qq| - $form->{business} - | . $locale->text('Trade Discount') . qq| - | + | . $locale->text('Customer type') . qq| + $form->{business}; | . $locale->text('Trade Discount') . qq| | . $form->format_amount(\%myconfig, $form->{tradediscount} * 100) . qq| % - + |; } if ($form->{max_dunning_level}) { $dunning = qq| - - - - - - - - - -
| . $locale->text('Max. Dunning Level') . qq|:$form->{max_dunning_level}| . $locale->text('Dunning Amount') . qq|:| - . $form->format_amount(\%myconfig, $form->{dunning_amount},2) - . qq|
- - + + | . $locale->text('Max. Dunning Level') . qq|: + + $form->{max_dunning_level}; + | . $locale->text('Dunning Amount') . qq|: | + . $form->format_amount(\%myconfig, $form->{dunning_amount},2) + . qq| + + |; } $form->{fokus} = "invoice.customer"; # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; + $form->{jsscript} = 1; $jsscript = ""; if ($form->{type} eq "credit_note") { - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "1", - "invdate", "BL", - "trigger1"); - } else { - - # without JavaScript Calendar - $button1 = - qq||; - $button2 = - qq||; - } + $button1 = qq| + + |; + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "1", + "invdate", "BL", + "trigger1"); } else { - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - - |; - $button2 = qq| - - + $button1 = qq| + + |; - $button3 = qq| - - - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "3", - "invdate", "BL", - "trigger1", "duedate", - "BL", "trigger2", - "deliverydate", "BL", - "trigger3"); - } else { - - # without JavaScript Calendar - $button1 = - qq||; - $button2 = - qq|{duedate} onBlur=\"check_right_date_format(this)\">|; - } + $button2 = qq| + + + |; + $button3 = qq| + + + |; + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "3", + "invdate", "BL", + "trigger1", "duedate", + "BL", "trigger2", + "deliverydate", "BL", + "trigger3"); } + if ($form->{resubmit} && ($form->{format} eq "html")) { $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|; @@ -614,6 +622,7 @@ onchange="document.getElementById('update_button').click();">| . } $form->{"javascript"} .= qq||; + $form->{javascript} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, @@ -633,52 +642,37 @@ onchange="document.getElementById('update_button').click();">| .
| ; -map({print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} - qw(id action type media format queued printed emailed title vc discount - creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id)) ; -print ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") ; -print qq| + + $form->hide_form(qw(id action type media format queued printed emailed title vc discount + creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id + max_dunning_level dunning_amount)); + print qq|

$form->{saved_message}

| if $form->{saved_message}; + + print qq| +
$form->{title}
+ - - - - -
$form->{title}
- - -
- - - - - - - - - - - - - - $shipto - - $business - $dunning +
| . $locale->text('Customer') . qq|$customer| - . $locale->text('Contact Person') . qq|$contact
- - - - - - - - -
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}| . $locale->text('Remaining') . qq|$form->{creditremaining}
-
+ + + $customers + + + + + + $contact + $shipto + + + + + $dunning + $business @@ -700,7 +694,11 @@ print qq| - |; + + + + + |; # # - @@ -1170,7 +1163,7 @@ if ($form->{type} eq "credit_note") { | . -$cgi->hidden("-name" => "callback", "-value" => $form->{callback}) +$cgi->hidden("-name" => "callback", "-value" => $form->{callback}) . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]); map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password)); @@ -1194,10 +1187,19 @@ sub update { $form->{print_and_post} = 0; } + + if($form->{taxincluded}) { + $taxincluded = "checked"; + } $form->{update} = 1; &check_name(customer); + if(!$form->{taxincluded}) { + $form->{taxincluded} = $taxincluded; + } + + $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( @@ -1385,6 +1387,9 @@ sub post { $form->isblank("invdate", $locale->text('Invoice Date missing!')); $form->isblank("customer", $locale->text('Customer missing!')); + $form->{invnumber} =~ s/^\s*//g; + $form->{invnumber} =~ s/\s*$//g; + # if oldcustomer ne customer redo form if (&check_name(customer)) { &update; @@ -1451,7 +1456,7 @@ sub post { "POSTED"; $form->save_history($form->dbconnect(\%myconfig)); } - + $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!')) unless $print_post; @@ -1495,21 +1500,25 @@ sub storno { } map({ my $key = $_; delete($form->{$key}) - unless (grep({ $key eq $_ } qw(login password id type))); } + unless (grep({ $key eq $_ } qw(login password id stylesheet type))); } keys(%{ $form })); - &invoice_links; - &prepare_invoice; + invoice_links(); + prepare_invoice(); relink_accounts(); + # Payments must not be recorded for the new storno invoice. + $form->{paidaccounts} = 0; + map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form }; + $form->{storno_id} = $form->{id}; $form->{storno} = 1; $form->{id} = ""; $form->{invnumber} = "Storno zu " . $form->{invnumber}; + $form->{rowcount}++; - &post(); + post(); $lxdebug->leave_sub(); - } sub preview { @@ -1579,7 +1588,7 @@ sub credit_note { $form->{script} = 'is.pl'; $script = "is"; $buysell = 'buy'; - + # bo creates the id, reset it map { delete $form->{$_} } @@ -1622,12 +1631,12 @@ sub yes { if (IS->delete_invoice(\%myconfig, \%$form, $spool)) { # saving the history if(!exists $form->{addition}) { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history - $form->redirect($locale->text('Invoice deleted!')); + # /saving the history + $form->redirect($locale->text('Invoice deleted!')); } $form->error($locale->text('Cannot delete invoice!'));
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}; | . $locale->text('Remaining') . qq| $form->{creditremaining}
| . $locale->text('Record in') . qq|
| . $locale->text('Ship via') . qq|
| . $locale->text('Transaction description') . qq|| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|
# @@ -723,14 +721,9 @@ print qq| # print qq|
+ - - - - - - + $employees $salesman |; if ($form->{type} eq "credit_note") { @@ -766,8 +759,8 @@ print qq| - - + @@ -775,8 +768,8 @@ print qq| - - + @@ -796,20 +789,20 @@ print qq| -| . +| . $jsscript . qq| | ; -map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } +map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2)); print qq| |; -map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } +map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(message email subject cc bcc taxaccounts)); print qq||; foreach $item (split(/ /, $form->{taxaccounts})) { - map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } + map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } ("${item}_rate", "${item}_description", "${item}_taxnumber")); } $lxdebug->leave_sub(); @@ -832,12 +825,12 @@ sub form_footer { $intnotes = qq||; - $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; + $form->{taxincluded} = ($form->{taxincluded} ? "checked" : ""); $taxincluded = ""; if ($form->{taxaccounts}) { $taxincluded = qq| - {taxincluded}> | + {taxincluded}> | . $locale->text('Tax Included') . qq|

|; } @@ -1070,7 +1063,7 @@ if ($form->{type} eq "credit_note") { push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); } - map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal)); + map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal)); print qq|
| . $locale->text('Employee') . qq|
| . $locale->text('Order Date') . qq| +
| . $locale->text('Quotation Number') . qq|
| . $locale->text('Quotation Date') . qq| +
| . $locale->text('Customer Order Number') . qq|