X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=87ac20768a83161136d8d58836aefd53ff2c8032;hb=85f5b26dd9ae6a9e88f967b601fddeb8046fc59f;hp=3736fbe2cb09f792dc248143d96bd241819ac019;hpb=5b47ed3efe5f4ef0810096b0f4849047cee54690;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 3736fbe2c..87ac20768 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -32,10 +32,13 @@ #====================================================================== use SL::IR; +use SL::IS; use SL::PE; -require "$form->{path}/io.pl"; -require "$form->{path}/arap.pl"; +require "bin/mozilla/io.pl"; +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; 1; @@ -44,6 +47,8 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); + return $lxdebug->leave_sub() if (load_draft_maybe()); + $form->{title} = $locale->text('Add Vendor Invoice'); &invoice_links; @@ -55,7 +60,11 @@ sub add { sub edit { $lxdebug->enter_sub(); - + + # show history button + $form->{javascript} = qq||; + #/show hhistory button + $form->{title} = $locale->text('Edit Vendor Invoice'); &invoice_links; @@ -219,7 +228,7 @@ sub form_header { $lxdebug->enter_sub(); # set option selected - foreach $item (qw(AP vendor currency department contact)) { + foreach $item (qw(AP vendor currency department)) { $form->{"select$item"} =~ s/ selected//; $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; @@ -231,6 +240,9 @@ sub form_header { #quote selectvendor Bug 133 $form->{"selectvendor"} = $form->quote($form->{"selectvendor"}); + #substitute \n and \r to \s (bug 543) + $form->{"selectvendor"} =~ s/[\n\r]/ /g; + $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); @@ -239,20 +251,6 @@ sub form_header { $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); - #build contacts - if ($form->{all_contacts}) { - - $form->{selectcontact} = ""; - foreach $item (@{ $form->{all_contacts} }) { - if ($form->{cp_id} == $item->{cp_id}) { - $form->{selectcontact} .= - ""; - } else { - $form->{selecttaxzone} .= - ""; - } + 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| + + |; - } } else { - $form->{selecttaxzone} =~ s/ selected//g; - if ($form->{taxzone_id} ne "") { - $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/; - } + $taxzone = qq| + + | . $locale->text('Steuersatz') . qq| + + + | . H($labels{$form->{"taxzone_id"}}) . qq| + + |; } - $taxzone = qq| - - | . $locale->text('Steuersatz') . qq| - - - |; - - - $vendor = ($form->{selectvendor}) - ? qq|\n| + ? qq|\n| : qq||; - $contact = - ($form->{selectcontact}) - ? qq|\n| - : qq||; - $department = qq| | . $locale->text('Department') . qq| @@ -331,12 +357,12 @@ sub form_header { # with JavaScript Calendar $button1 = qq| - {invdate}> + text('button') . qq|> |; $button2 = qq| - {duedate}> + text('button') . qq|> |; @@ -349,12 +375,13 @@ sub form_header { # without JavaScript Calendar $button1 = - qq|{invdate}>|; + qq||; $button2 = - qq|{duedate}>|; + qq||; } $form->{"javascript"} .= qq||; + $form->{"javascript"} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, @@ -362,9 +389,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}> @@ -384,6 +413,8 @@ sub form_header { {storno}> {storno_id}> +| . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| + @@ -455,15 +486,19 @@ sub form_header { - + - + -
$form->{title}
| . $locale->text('Order Date') . qq|
| . $locale->text('Quotation Date') . qq|
+ + | . $locale->text('Project Number') . qq| + $globalprojectnumber + + @@ -534,7 +569,8 @@ sub form_footer { $tax .= qq| - $form->{"${item}_description"} + $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} |; @@ -575,7 +611,8 @@ sub form_footer { $tax .= qq| - Enthaltene $form->{"${item}_description"} + Enthaltene $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} @@ -721,12 +758,12 @@ sub form_footer { |; $column_data{"paid_$i"} = - qq|{"paid_$i"}>|; + qq||; $column_data{"exchangerate_$i"} = qq|$exchangerate|; $column_data{"AP_paid_$i"} = qq||; $column_data{"datepaid_$i"} = - qq|{"datepaid_$i"}> + qq| |; $column_data{"source_$i"} = qq|{"source_$i"}>|; @@ -759,12 +796,14 @@ sub form_footer { $closedto = $form->datetonum($form->{closedto}, \%myconfig); 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('Post') . qq|">|; + . $locale->text('Post') . qq|"> | . + NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), + '-class' => 'submit')); } - print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) . - qq| - -{rowcount}> - - + print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers); + $form->hide_form(qw(rowcount callback draft_id draft_description login password)); -{path}> -{login}> -{password}> + # button for saving history + if($form->{id} ne "") { + print qq| + |; + } + # /button for saving history -
+print qq| @@ -813,8 +857,6 @@ sub update { &check_name(vendor); - &check_project; - $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( @@ -841,7 +883,7 @@ sub update { } $i = $form->{rowcount}; - $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; + $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1; if ( ($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") @@ -932,11 +974,27 @@ sub storno { $form->error($locale->text('Cannot storno storno invoice!')); } + if (IS->has_storno(\%myconfig, $form, "ap")) { + $form->error($locale->text("Invoice has already been storno'd!")); + } + + invoice_links(); + prepare_invoice(); + relink_accounts(); + + # 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}; - + $form->{rowcount}++; &post(); $lxdebug->leave_sub(); @@ -976,8 +1034,17 @@ sub post_payment { ($form->{AP}) = split /--/, $form->{AP}; ($form->{AP_paid}) = split /--/, $form->{AP_paid}; - $form->redirect($locale->text(' Payment posted!')) - if (IR->post_payment(\%myconfig, \%$form)); + if (IR->post_payment(\%myconfig, \%$form)){ + + if(!exists $form->{addition} && $form->{id} ne "") { + # saving the history + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "PAYMENT POSTED"; + $form->save_history($form->dbconnect(\%myconfig)); + # /saving the history + $form->redirect($locale->text(' Payment posted!')); + } + } $form->error($locale->text('Cannot post payment!')); @@ -1032,10 +1099,20 @@ sub post { relink_accounts(); - $form->redirect( $locale->text('Invoice') + if (IR->post_invoice(\%myconfig, \%$form)){ + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "POSTED"; + #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber}; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + remove_draft() if $form->{remove_draft}; + $form->redirect( $locale->text('Invoice') . " $form->{invnumber} " - . $locale->text('posted!')) - if (IR->post_invoice(\%myconfig, \%$form)); + . $locale->text('posted!')); + } $form->error($locale->text('Cannot post invoice!')); $lxdebug->leave_sub(); @@ -1045,7 +1122,6 @@ sub delete { $lxdebug->enter_sub(); $form->header; - print qq| @@ -1077,9 +1153,16 @@ sub delete { sub yes { $lxdebug->enter_sub(); - - $form->redirect($locale->text('Invoice deleted!')) - if (IR->delete_invoice(\%myconfig, \%$form)); + 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)); + } + # /saving the history + $form->redirect($locale->text('Invoice deleted!')); + } $form->error($locale->text('Cannot delete invoice!')); $lxdebug->leave_sub();