X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=136d6790f78bbf642e170c11ffb5ff589660789b;hb=d7f060429e809653d45e93e86b3c5c8d7129e0a9;hp=e088def44288c74aa448bd4b70290043b49b3c8f;hpb=5ceaf343f897027dff7edcde6315824b8dc64db7;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index e088def44..136d6790f 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -32,11 +32,12 @@ #====================================================================== use SL::IR; +use SL::IS; use SL::PE; -require "$form->{path}/io.pl"; -require "$form->{path}/arap.pl"; -require "$form->{path}/common.pl"; +require "bin/mozilla/io.pl"; +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; 1; @@ -77,10 +78,8 @@ sub invoice_links { $lxdebug->enter_sub(); # create links - $form->{webdav} = $webdav; - - # set jscalendar - $form->{jscalendar} = $jscalendar; + $form->{webdav} = $webdav; + $form->{jsscript} = 1; $form->create_links("AP", \%myconfig, "vendor"); @@ -119,11 +118,6 @@ sub invoice_links { $form->{taxzone_id} = $taxzone_id; } - # currencies - @curr = split(/:/, $form->{currencies}); - chomp $curr[0]; - $form->{defaultcurrency} = $curr[0]; - map { $form->{selectcurrency} .= ""; - } else { - $form->{selecttaxzone} .= - ""; - } - - } - } else { - $form->{selecttaxzone} =~ s/ selected//g; - if ($form->{taxzone_id} ne "") { - $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/; - } + + %labels = (); + @values = (); + my $i = 0; + foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) { + push(@values, $item); + $labels{$item} = $item; + } + + $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; + my $currencies; + if (scalar @values) { + $currencies = qq| + + | . $locale->text('Currency') . qq| + | . + NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, + '-values' => \@values, '-labels' => \%labels)) . qq| + + |; } - $taxzone = qq| - - | . $locale->text('Steuersatz') . qq| - - - |; + %labels = (); + @values = (); + my $i = 0; + 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_id', '-default' => $form->{"employee_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| + + |; + + %labels = (); + @values = (); + my $i = 0; + foreach my $item (@{ $form->{"ALL_VENDORS"} }) { + push(@values, $item->{name}.qq|--|.$item->{"id"}); + $labels{$item->{"id"}} = $item->{"name"}.qq|--|.$item->{"id"}; + } + my $vendors = qq| + | . $locale->text('Vendor') . qq| + | . + NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{"vendor"}, + '-onChange' => 'document.getElementById(\'update_button\').click();', + '-values' => \@values, '-labels' => \%labels)) . qq| + |; + %labels = (); + @values = (); + foreach my $item (@{ $form->{"ALL_TAXZONES"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"description"}; + } + if (!$form->{"id"}) { + $taxzone = qq| + + | . $locale->text('Steuersatz') . qq| + | . + NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| + + |; - $vendor = - ($form->{selectvendor}) - ? qq|\n| - : qq||; + } else { + $taxzone = qq| + + | . $locale->text('Steuersatz') . qq| + + + | . H($labels{$form->{"taxzone_id"}}) . qq| + + |; + } $department = qq| | . $locale->text('Department') . qq| - - + + | if $form->{selectdepartment}; @@ -343,36 +401,27 @@ sub form_header { $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; # use JavaScript Calendar or not - $form->{jsscript} = $form->{jscalendar}; + $form->{jsscript} = 1; $jsscript = ""; - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - {invdate}> - text('button') . qq|> - |; - $button2 = qq| - {duedate}> - text('button') . qq|> - |; - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", - "duedate", "BL", "trigger2"); - } else { + $button1 = qq| + + text('button') . qq|> + |; + $button2 = qq| + + text('button') . qq|> + |; - # without JavaScript Calendar - $button1 = - qq|{invdate}>|; - $button2 = - qq|{duedate}>|; - } + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", + "duedate", "BL", "trigger2"); $form->{"javascript"} .= qq||; + $form->{"javascript"} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, @@ -380,9 +429,11 @@ sub form_header { "quodate", "BL", "trigger_quodate"); $form->header; - + $onload = qq|focus()|; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| - +
{script}> @@ -404,59 +455,38 @@ sub form_header { | . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| +
$form->{title}
+ - - - - -
$form->{title}
- - -
+ + $vendors + + + + $contact + + + + - - - - - - - {vendor_id}> - - - - - - - - - - + + + $taxzone $department - - + $currencies $exchangerate
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}; | . $locale->text('Remaining') . qq| $form->{creditremaining}
| . $locale->text('Vendor') . qq|$vendor| - . $locale->text('Contact Person') . qq|$contact
- - - - - - - - -
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}| . $locale->text('Remaining') . qq|$form->{creditremaining}
-
| . $locale->text('Record in') . qq|| . $locale->text('Record in') . qq|
| . $locale->text('Currency') . qq|
- + $employees + @@ -475,13 +505,13 @@ sub form_header { - - + - - + @@ -496,8 +526,6 @@ sub form_header { $jsscript - -{defaultcurrency}> {fxgain_accno}> {fxloss_accno}> @@ -641,7 +669,7 @@ sub form_footer {
| . $locale->text('Invoice Number') . qq|
| . $locale->text('Order Date') . qq| +
| . $locale->text('Quotation Date') . qq| +
| . $locale->text('Project Number') . qq|
$subtotal $tax - 0 + @@ -680,9 +708,6 @@ sub form_footer { print $webdav_list; } print qq| -{jscalendar}> -|; - print qq|
| . $locale->text('Total') . qq| $form->{invtotal}
@@ -747,12 +772,12 @@ sub form_footer { |; $column_data{"paid_$i"} = - qq||; + qq||; $column_data{"exchangerate_$i"} = qq||; $column_data{"AP_paid_$i"} = qq||; $column_data{"datepaid_$i"} = - qq||; $column_data{"source_$i"} = qq||; @@ -784,13 +809,19 @@ sub form_footer { $invdate = $form->datetonum($form->{invdate}, \%myconfig); $closedto = $form->datetonum($form->{closedto}, \%myconfig); + print qq| +|; + if ($form->{id}) { + my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap"); + print qq| |; print qq| -| unless ($form->{storno}); +| if ($show_storno); if ($form->{radier}) { print qq| text('Update') . qq|">|; - if (!$form->{id} && ($invdate > $closedto)) { print qq| | . @@ -813,19 +841,8 @@ sub form_footer { '-class' => 'submit')); } - print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) . - qq| - -{rowcount}> - - - -{path}> -{login}> -{password}> -| - . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) - . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]); + print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers); + $form->hide_form(qw(rowcount callback draft_id draft_description login password)); # button for saving history if($form->{id} ne "") { @@ -972,16 +989,34 @@ sub storno { $form->error($locale->text('Cannot storno storno invoice!')); } - if (IR->has_storno(\%myconfig, $form)) { + if (IS->has_storno(\%myconfig, $form, "ap")) { $form->error($locale->text("Invoice has already been storno'd!")); } + my $employee_id = $form->{employee_id}; + 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 }; + + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "CANCELED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + $form->{storno_id} = $form->{id}; $form->{storno} = 1; $form->{id} = ""; $form->{invnumber} = "Storno zu " . $form->{invnumber}; - - &post(); + $form->{rowcount}++; + $form->{employee_id} = $employee_id; + post(); $lxdebug->leave_sub(); } @@ -1024,7 +1059,9 @@ sub post_payment { if(!exists $form->{addition} && $form->{id} ne "") { # saving the history + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "PAYMENT POSTED"; + $form->{what_done} = $form->{currency} . qq| | . $form->{paid} . qq| | . $locale->text("POSTED"); $form->save_history($form->dbconnect(\%myconfig)); # /saving the history $form->redirect($locale->text(' Payment posted!')); @@ -1042,6 +1079,9 @@ sub post { $form->isblank("invdate", $locale->text('Invoice Date missing!')); $form->isblank("vendor", $locale->text('Vendor missing!')); + $form->{invnumber} =~ s/^\s*//g; + $form->{invnumber} =~ s/\s*$//g; + # if the vendor changed get new values if (&check_name(vendor)) { &update; @@ -1087,7 +1127,8 @@ sub post { if (IR->post_invoice(\%myconfig, \%$form)){ # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $form->{addition} = "POSTED"; + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "POSTED"; #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber}; $form->save_history($form->dbconnect(\%myconfig)); } @@ -1140,6 +1181,7 @@ sub yes { if (IR->delete_invoice(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); }
{"paid_$i"}>$exchangerate{"datepaid_$i"}> + qq| {"source_$i"}>