X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=284b2fe5d4fe2f105105d107371fa457d99877b5;hb=fec0904532e2136a1a769f568c351f4875257d56;hp=1b99f5fb53b8ff45b29141d50d9493624d6924a5;hpb=82c784869fbfc8a746a0ee0662947f189f021993;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 1b99f5fb5..284b2fe5d 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; @@ -111,11 +120,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/; - } + NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"cp_id"})); + + %labels = (); + @values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"projectnumber"}; + } + my $globalprojectnumber = + NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, + '-labels' => \%labels, + '-default' => $form->{"globalproject_id"})); + + %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 = qq| + + | . $locale->text('Currency') . qq| + | . + NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, + '-values' => \@values, '-labels' => \%labels)) . 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', '-default' => $form->{"employee"}, + '-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"}; } - $taxzone = qq| - - | . $locale->text('Steuersatz') . qq| - - - |; - - + 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}; @@ -323,12 +396,12 @@ sub form_header { # with JavaScript Calendar $button1 = qq| - {invdate}> + text('button') . qq|> |; $button2 = qq| - {duedate}> + text('button') . qq|> |; @@ -341,12 +414,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, @@ -354,9 +428,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}> @@ -376,6 +452,8 @@ sub form_header { {storno}> {storno_id}> +| . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| + @@ -388,20 +466,18 @@ sub form_header { @@ -472,8 +544,6 @@ sub form_header { $jsscript - -{defaultcurrency}> {fxgain_accno}> {fxloss_accno}> @@ -534,7 +604,8 @@ sub form_footer { $tax .= qq| - + |; @@ -575,7 +646,8 @@ sub form_footer { $tax .= qq| - + @@ -615,7 +687,7 @@ sub form_footer {
$form->{title} - - - + $vendors - {vendor_id}> - - + + + - + - - - + + + $taxzone $department - - + $currencies $exchangerate
| . $locale->text('Vendor') . qq|$vendor| . $locale->text('Contact Person') . qq| $contact
+ @@ -411,24 +487,24 @@ sub form_header {
| . $locale->text('Credit Limit') . qq|$form->{creditremaining}
-
| . $locale->text('Record in') . qq|| . $locale->text('Record in') . qq|
| . $locale->text('Currency') . qq|
- + $employees + @@ -447,21 +523,17 @@ sub form_header { - + - + -
| . $locale->text('Invoice Number') . qq|
| . $locale->text('Order Date') . qq|
| . $locale->text('Quotation Date') . qq|
| . $locale->text('Project Number') . qq| - - - - + $globalprojectnumber
$form->{"${item}_description"}$form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"}
Enthaltene $form->{"${item}_description"}Enthaltene $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"}
$subtotal $tax - 0 + @@ -721,12 +793,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||; @@ -759,12 +831,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 +892,6 @@ sub update { &check_name(vendor); - &check_project; - $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( @@ -841,7 +918,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 +1009,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 +1069,18 @@ 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->{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!')); + } + } $form->error($locale->text('Cannot post payment!')); @@ -1032,10 +1135,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 +1158,6 @@ sub delete { $lxdebug->enter_sub(); $form->header; - print qq| @@ -1077,9 +1189,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();
| . $locale->text('Total') . qq| $form->{invtotal}
{"paid_$i"}>$exchangerate{"datepaid_$i"}> + qq| {"source_$i"}>