X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=ac4dcf5b4c6b425add16835e4316bc20fc507569;hb=f5e0cdb2123962a7ced378468c6fb29c384c0d4a;hp=d2db33c52cd0e722abe91a57ab80e35acecc8045;hpb=69822fd215cb15e1bb017f1af6f0a185f62a31e2;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index d2db33c52..ac4dcf5b4 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -162,9 +162,8 @@ sub order_links { ($form->{vc} eq 'customer') ? "AR" : "AP"); # retrieve order/quotation - $form->{webdav} = $webdav; - # set jscalendar - $form->{jscalendar} = $jscalendar; + $form->{webdav} = $webdav; + $form->{jsscript} = 1; my $editing = $form->{id}; @@ -331,36 +330,24 @@ sub form_header { shiptophone shiptofax shiptodepartment_1 shiptodepartment_2); # use JavaScript Calendar or not - $form->{jsscript} = $form->{jscalendar}; + $form->{jsscript} = 1; $jsscript = ""; - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - $button2 = qq| - - text('button') . qq|> - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", - "reqdate", "BL", "trigger2"); - - } else { - - # without JavaScript Calendar - $button1 = qq| - |; - $button2 = qq| - |; - } + $button1 = qq| + + text('button') . qq|> + |; + $button2 = qq| + + text('button') . qq|> + |; + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", + "reqdate", "BL", "trigger2"); my @tmp; @@ -387,7 +374,7 @@ sub form_header { } # set option selected - foreach $item ($form->{vc}, currency, department, employee, ($form->{vc} eq "customer" ? customer : vendor)) { + foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) { $form->{"select$item"} =~ s/ selected//; $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; @@ -403,19 +390,19 @@ sub form_header { map({ push(@old_project_ids, $form->{"project_id_$_"}) if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; $form->get_lists("contacts" => "ALL_CONTACTS", "shipto" => "ALL_SHIPTO", "projects" => { "key" => "ALL_PROJECTS", "all" => 0, "old_id" => \@old_project_ids }, - "employees" => "ALL_SALESMEN", + "employees" => "ALL_EMPLOYEES", + "salesmen" => "ALL_SALESMEN", "taxzones" => "ALL_TAXZONES", "payments" => "ALL_PAYMENTS", - "currencies" => "ALL_CURRENCIES"); - ($form->{vc} eq "customer" - ? $form->get_lists("customers" => "ALL_CUSTOMERS") - : $form->get_lists("vendors" => "ALL_VENDORS")); - + "currencies" => "ALL_CURRENCIES", + $vc => "ALL_" . uc($vc)); + my %labels; my @values = (undef); foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { @@ -423,27 +410,39 @@ 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, '-style' => 'width: 250px', + '-labels' => \%labels, '-default' => $form->{"cp_id"})) + . qq| + + |; + } %labels = (); @values = (); foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) { - push(@values, $item->{name}.qq|--|.$item->{"id"}); - $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"}; + push(@values, $item->{"name"}.qq|--|.$item->{"id"}); + $labels{$item->{"name"}.qq|--|.$item->{"id"}} = $item->{name}; } - my $vc = qq| + $vc = qq| + {vc}_id"}) . qq|"> {vc}"}) . qq|"> | . $locale->text(ucfirst($form->{vc})) . qq| | . - (($myconfig{vclimit} == 1 ) - ? qq|{vc}"}) . qq|" name="$form->{vc}">| + (($myconfig{vclimit} <= scalar(@values)) + ? qq|{vc}"} =~ /^(.*)\-\-.*$/)) . qq|" name="$form->{vc}">| : (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"}, '-onChange' => 'document.getElementById(\'update_button\').click();', - '-values' => \@values, '-labels' => \%labels)))) . qq| + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq| + {vc}"}) . qq|">|; @@ -457,7 +456,7 @@ sub form_header { $payments = qq| | . $locale->text('Payment Terms') . qq| | . - NTI($cgi->popup_menu('-name' => 'payment_id', '-values' => \@values, + NTI($cgi->popup_menu('-name' => 'payment_id', '-values' => \@values, '-style' => 'width: 250px', '-labels' => \%labels, '-default' => $form->{payment_id})) . qq||; @@ -465,16 +464,19 @@ sub form_header { @values = (""); foreach my $item (@{ $form->{"ALL_SHIPTO"} }) { push(@values, $item->{"shipto_id"}); - $labels{$item->{"shipto_id"}} = - $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"}; + $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city); } - 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, '-style' => 'width: 250px', + '-labels' => \%labels, '-default' => $form->{"shipto_id"})) . qq||; + } %labels = (); @values = (""); @@ -486,21 +488,20 @@ sub form_header { NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, '-labels' => \%labels, '-default' => $form->{"globalproject_id"})); - - $salesman = ""; + + my $salesmen = ""; + %labels = (); + @values = (); if ($form->{type} =~ /^sales_/) { - %labels = (); - @values = (""); - foreach my $item (@{ $form->{ALL_SALESMEN} }) { - push(@values, $item->{id}); - $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login}; + foreach my $item (@{ $form->{"ALL_SALESMEN"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = ($item->{"name"} ne "" ? $item->{"name"} : $item->{"login"}); } - - $salesman = + $salesmen = qq| | . $locale->text('Salesman') . qq| | . - NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id}, + NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{"salesman_id"} ? $form->{"salesman_id"} : $form->{"employee_id"}, '-values' => \@values, '-labels' => \%labels)) . qq| |; @@ -508,16 +509,16 @@ sub form_header { %labels = (); @values = (); - foreach my $item (@{ $form->{"ALL_SALESMEN"} }) { + foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) { push(@values, $item->{"id"}); - $labels{$item->{"id"}} = $item->{"name"}; + $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"}; } - my $employees = qq| + my $employee = qq| | . $locale->text('Employee') . qq| | . - NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee"}, + NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, '-values' => \@values, '-labels' => \%labels)) . qq| |; @@ -534,7 +535,7 @@ sub form_header { | . $locale->text('Steuersatz') . qq| | . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, - '-values' => \@values, '-labels' => \%labels)) . qq| + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')) . qq| |; @@ -545,9 +546,11 @@ sub form_header { push(@values, $item); $labels{$item} = $item; } - - $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; - my $currencies = qq| + + $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; + my $currencies; + if (scalar @values) { + $currencies = qq| | . $locale->text('Currency') . qq| | . @@ -555,7 +558,7 @@ sub form_header { '-values' => \@values, '-labels' => \%labels)) . qq| |; - + } $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); @@ -594,32 +597,25 @@ sub form_header { if ($form->{business}) { $business = qq| - | . $locale->text('Business') . qq| - $form->{business} - | . $locale->text('Trade Discount') . qq| - | + | . ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor 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| + + |; } @@ -653,20 +649,11 @@ sub form_header { $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; $creditremaining = qq| - - - - - - - - - - - -
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}| . $locale->text('Remaining') . qq|$form->{creditremaining}
- - $shipto + $shipto + + | . $locale->text('Credit Limit') . qq| + $form->{creditlimit}; | . $locale->text('Remaining') . qq| $form->{creditremaining} + |; } else { @@ -713,23 +700,19 @@ sub form_header { $department = qq| | . $locale->text('Department') . qq| - + | if $form->{selectdepartment}; if ($form->{type} eq 'sales_order') { if ($form->{selectemployee}) { - $employee = qq| - {customer_klass}> - $employees -|; + $employee .= qq| + |; } } else { - $employee = qq| - {customer_klass}> - $employees -|; + $employee .= qq| + |; } if ($form->{resubmit} && ($form->{format} eq "html")) { $onload = @@ -752,41 +735,26 @@ sub form_header { # show history button js $form->{javascript} .= qq||; #/show history button js + $form->{javascript} .= qq||; + $form->header; print qq|
{script}> + +|; -{id}> -{action}> - -{type}> -{formname}> -{media}> -{format}> -{proforma}> - - - - - -{vc}> - - - -{discount}> -{creditlimit}> -{creditremaining}> + $form->hide_form(qw(id action type vc formname media format proforma queued printed emailed + title discount creditlimit creditremaining tradediscount business + max_dunning_level dunning_amount)); -{tradediscount}> -{business}> - + print qq| @@ -801,10 +769,7 @@ sub form_header {
$vc - - - + $contact $creditremaining $business $dunning @@ -852,7 +817,7 @@ print qq|
| - . $locale->text('Contact Person') . qq|$contact
$openclosed $employee - $salesman + $salesmen $ordnumber @@ -1071,9 +1036,7 @@ sub form_footer { print $webdav_list; } - print qq| -{jscalendar}> -|; + print qq| - |; - $button2 = qq| - - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3", - "transdateto", "BL", "trigger4"); - } else { - # without JavaScript Calendar - $button1 = qq| - |; - $button2 = qq| - |; - } + $button1 = qq| + + |; + $button2 = qq| + + |; + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3", + "transdateto", "BL", "trigger4"); + + my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 1 }); + "all" => 1 }, + "employees" => "ALL_EMPLOYEES", + $vc => "ALL_" . uc($vc)); my %labels = (); my @values = (""); @@ -1442,6 +1399,40 @@ sub search { NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values, '-labels' => \%labels)); + #employees + %labels = (); + @values = (); + foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"}; + } + + my $employee_block = qq| + + + + |; + + %labels = (); + @values = (""); + + foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) { + push(@values, $item->{name}.qq|--|.$item->{"id"}); + $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"}; + } + + my $vc_label = $form->{vc} eq "customer" ? $locale->text('Customer') : $locale->text('Vendor'); + $vc = + $myconfig{vclimit} <= scalar(@values) + ? qq|{vc}"} =~ /^(.*)\-\-.*$/)) . qq|" name="$form->{vc}">| + : NTI($cgi->popup_menu('-name' => "$form->{vc}", + '-default' => $form->{"old$form->{vc}"}, + '-onChange' => 'document.getElementById(\'update_button\').click();', + '-values' => \@values, + '-labels' => \%labels)); $form->header; print qq| @@ -1458,13 +1449,15 @@ sub search {
| . $locale->text('Project Number') . qq|
@@ -1400,37 +1363,31 @@ sub search { } # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; + $form->{jsscript} = 1; $jsscript = ""; - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - text('button') . qq|> + text('button') . qq|> + text('button') . qq|>
| . $locale->text('Employee') . qq|| . + NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| +
- $vc + + $department + $employee_block @@ -1501,7 +1494,7 @@ sub search { . $locale->text('Required by') . qq| - + @@ -1557,12 +1550,6 @@ $jsscript sub orders { $lxdebug->enter_sub(); - # split vendor / customer - ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = - split(/--/, $form->{ $form->{vc} }); - - OE->transactions(\%myconfig, \%$form); - $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber"; # construct href @@ -1570,11 +1557,18 @@ sub orders { qw(type vc login password transdatefrom transdateto open closed notdelivered delivered department transaction_description); + push @fields, $form->{vc}; $href = "$form->{script}?action=orders&" . join("&", map { "${_}=" . E($form->{$_}) } @fields) . "&${ordnumber}=" . E($form->{$ordnumber}); $callback = $href; + # split vendor / customer + ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = + split(/--/, $form->{ $form->{vc} }); + + OE->transactions(\%myconfig, \%$form); + @columns = ( "transdate", "reqdate", "id", "$ordnumber", @@ -2142,8 +2136,11 @@ sub delete {

$msg $form->{$ordnumber}

+ + @@ -2153,7 +2150,7 @@ sub delete { $lxdebug->leave_sub(); } -sub yes { +sub delete_order_quotation { $lxdebug->enter_sub(); if ($form->{type} =~ /_order$/) { @@ -2164,7 +2161,6 @@ sub yes { $err = $locale->text('Cannot delete quotation!'); } if (OE->delete(\%myconfig, \%$form, $spool)){ - $form->redirect($msg); # saving the history if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; @@ -2172,6 +2168,8 @@ sub yes { $form->save_history($form->dbconnect(\%myconfig)); } # /saving the history + $form->info($msg); + exit(); } $form->error($err); @@ -2516,9 +2514,61 @@ sub save_as_new { $lxdebug->leave_sub(); } +sub check_for_direct_delivery_yes { + $lxdebug->enter_sub(); + + $form->{direct_delivery_checked} = 1; + delete @{$form}{grep /^shipto/, keys %{ $form }}; + map { s/^CFDD_//; $form->{$_} = $form->{"CFDD_${_}"} } grep /^CFDD_/, keys %{ $form }; + $form->{shipto} = 1; + purchase_order(); + $lxdebug->leave_sub(); +} + +sub check_for_direct_delivery_no { + $lxdebug->enter_sub(); + + $form->{direct_delivery_checked} = 1; + delete @{$form}{grep /^shipto/, keys %{ $form }}; + purchase_order(); + + $lxdebug->leave_sub(); +} + +sub check_for_direct_delivery { + $lxdebug->enter_sub(); + + if ($form->{direct_delivery_checked} + || (!$form->{shiptoname} && !$form->{shiptostreet} && !$form->{shipto_id})) { + $lxdebug->leave_sub(); + return; + } + + if ($form->{shipto_id}) { + Common->get_shipto_by_id(\%myconfig, $form, $form->{shipto_id}, "CFDD_"); + + } else { + map { $form->{"CFDD_${_}"} = $form->{$_ } } grep /^shipto/, keys %{ $form }; + } + + delete $form->{action}; + $form->{VARIABLES} = [ map { { "key" => $_, "value" => $form->{$_} } } grep { ref $_ eq "" } keys %{ $form } ]; + + $form->header(); + print $form->parse_html_template("oe/check_for_direct_delivery"); + + $lxdebug->leave_sub(); + + exit 0; +} + sub purchase_order { $lxdebug->enter_sub(); + if ($form->{type} eq 'sales_order') { + check_for_direct_delivery(); + } + if ( $form->{type} eq 'sales_quotation' || $form->{type} eq 'request_quotation') { OE->close_order(\%myconfig, \%$form); @@ -2622,3 +2672,10 @@ sub e_mail { $lxdebug->leave_sub(); } +sub yes { + call_sub($form->{yes_nextsub}); +} + +sub no { + call_sub($form->{no_nextsub}); +}

$vc_label$vc
$ordlabel
| . $locale->text('Transaction description') . qq|
ucfirst($form->{vc}) $vc_label $employee | . $locale->text('Ship via') . qq|