X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=701c91bb4e45ba6d53640eb17c4b2dc9e4e0a973;hb=d6bf475aee947e7451eb9b797ed0ad5ab5bcf6f8;hp=d72ca7ed852868aa8f7bbb34edbfeeab35a04d57;hpb=a104b890a4cb1c11d1992d6556ce3335c52b0e42;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index d72ca7ed8..701c91bb4 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -35,9 +35,9 @@ 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; @@ -78,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"); @@ -120,22 +118,10 @@ 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} .= - ""; - } + %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| + + |; - } - } 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_VENDORS"} }) { + push(@values, $item->{name}.qq|--|.$item->{"id"}); + $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"}; } - $taxzone = qq| - - | . $locale->text('Steuersatz') . qq| - - - |; + $form->{selectvendor} = ($myconfig{vclimit} > scalar(@values)); + my $vendors = qq| + | . $locale->text('Vendor') . qq| + | . + (($myconfig{vclimit} <= scalar(@values)) + ? qq|| + : (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor}, + '-onChange' => 'document.getElementById(\'update_button\').click();', + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . 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, '-style' => 'width: 250px')) . 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}; @@ -344,36 +401,28 @@ 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|> + + $button1 = qq| + + text('button') . qq|> |; + $button2 = qq| + + text('button') . qq|> + |; - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", - "duedate", "BL", "trigger2"); - } else { - - # 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||; + $form->{javascript} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, @@ -381,83 +430,55 @@ 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}> +|; -{id}> - - -{type}> -{level}> - -{creditlimit}> -{creditremaining}> + $form->hide_form(qw(id title vc type level creditlimit creditremaining + closedto locked shippted storno storno_id + max_dunning_level dunning_amount)); -{closedto}> -{locked}> + print qq|

$form->{saved_message}

| if $form->{saved_message}; -{shipped}> -{storno}> -{storno_id}> + print qq| -| . ($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 + @@ -476,13 +497,13 @@ sub form_header { - - + - - + @@ -497,8 +518,6 @@ sub form_header { $jsscript - -{defaultcurrency}> {fxgain_accno}> {fxloss_accno}> @@ -642,7 +661,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 + @@ -681,9 +700,6 @@ sub form_footer { print $webdav_list; } print qq| -{jscalendar}> -|; - print qq|
| . $locale->text('Total') . qq| $form->{invtotal}
@@ -713,7 +729,9 @@ sub form_footer { |; - my @triggers = (); + my @triggers = (); + my $totalpaid = 0; + $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); for $i (1 .. $form->{paidaccounts}) { @@ -725,6 +743,8 @@ sub form_footer { $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/; + $totalpaid += $form->{"paid_$i"}; + # format amounts if ($form->{"paid_$i"}) { $form->{"paid_$i"} = @@ -748,12 +768,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||; @@ -768,7 +788,22 @@ sub form_footer { push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); } + my $paid_missing = $form->{oldinvtotal} - $totalpaid; + print qq| + + + + + + + + + + + + + {oldinvtotal}> {paidaccounts}> @@ -785,6 +820,10 @@ 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"); @@ -806,9 +845,6 @@ sub form_footer { } - print qq||; - if (!$form->{id} && ($invdate > $closedto)) { print qq| | . @@ -816,19 +852,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 "") { @@ -840,7 +865,12 @@ sub form_footer { . qq|">|; } # /button for saving history - + # mark_as_paid button + if($form->{id} ne "") { + print qq||; + } + # /mark_as_paid button print qq| @@ -850,6 +880,12 @@ print qq| $lxdebug->leave_sub(); } +sub mark_as_paid { + $lxdebug->enter_sub(); + &mark_as_paid_common(\%myconfig,"ap"); + $lxdebug->leave_sub(); +} + sub update { $lxdebug->enter_sub(); @@ -979,16 +1015,30 @@ sub storno { $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(); } @@ -1028,17 +1078,19 @@ sub post_payment { ($form->{AP}) = split /--/, $form->{AP}; ($form->{AP_paid}) = split /--/, $form->{AP_paid}; if (IR->post_payment(\%myconfig, \%$form)){ - - if(!exists $form->{addition} && $form->{id} ne "") { + 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!')); + # /saving the history } + + $form->redirect($locale->text('Payment posted!')); } - $form->error($locale->text('Cannot post payment!')); + $form->error($locale->text('Cannot post payment!')); $lxdebug->leave_sub(); } @@ -1049,6 +1101,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; @@ -1094,7 +1149,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)); } @@ -1147,6 +1203,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"}>
| . $locale->text('Total') . qq|| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|
| . $locale->text('Missing amount') . qq|| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|