X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=2d82b9d17500be4e344e8ae824253cbe6c09c80a;hb=3da73190b8f201bfb33e3b6d96bbc6330142e922;hp=a2d7175bc23b577bfa5c6f0a93efda5109c21a05;hpb=50133d13d307d4172a0a3c1bd5a283e29609756a;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index a2d7175bc..2d82b9d17 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -35,6 +35,7 @@ use Carp; use POSIX qw(strftime); +use SL::DB::Order; use SL::DO; use SL::FU; use SL::OE; @@ -89,6 +90,16 @@ sub check_oe_access { $main::auth->assert($right); } +sub check_oe_conversion_to_sales_invoice_allowed { + return 1 if $::form->{type} !~ m/^sales/; + return 1 if ($::form->{type} =~ m/quotation/) && $::instance_conf->get_allow_sales_invoice_from_sales_quotation; + return 1 if ($::form->{type} =~ m/order/) && $::instance_conf->get_allow_sales_invoice_from_sales_order; + + $::form->show_generic_error($::locale->text("You do not have the permissions to access this function.")); + + return 0; +} + sub set_headings { $main::lxdebug->enter_sub(); @@ -312,6 +323,18 @@ sub form_header { # Container for template variables. Unfortunately this has to be # visible in form_footer too, so package local level and not my here. %TMPL_VAR = (); + if ($form->{id}) { + my $obj = SL::DB::Order->new(id => $form->{id})->load; + $TMPL_VAR{warn_save_active_periodic_invoice} = + $obj->is_type('sales_order') + && $obj->periodic_invoices_config + && $obj->periodic_invoices_config->active + && ( !$obj->periodic_invoices_config->end_date + || ($obj->periodic_invoices_config->end_date > DateTime->today_local)) + && $obj->periodic_invoices_config->get_previous_billed_period_start_date; + + $TMPL_VAR{oe_obj} = $obj; + } $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -429,7 +452,7 @@ sub form_header { } } - $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details)); + $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details ckeditor/ckeditor ckeditor/adapters/jquery)); $form->header; if ($form->{CFDD_shipto} && $form->{CFDD_shipto_id} ) { @@ -456,6 +479,8 @@ sub form_header { is_pur_ord => scalar ($form->{type} =~ /purchase_order$/), ); + $TMPL_VAR{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; + print $form->parse_html_template("oe/form_header", { %TMPL_VAR }); $main::lxdebug->leave_sub(); @@ -733,6 +758,8 @@ sub search { # constants and subs for template $form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" }; + $form->{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; + $form->header(); print $form->parse_html_template('oe/search', { @@ -800,6 +827,7 @@ sub orders { "vcnumber", "ustid", "country", "shippingpoint", "taxzone", + "order_probability", "expected_billing_date", "expected_netamount", ); # only show checkboxes if gotten here via sales_order form. @@ -812,6 +840,8 @@ sub orders { $form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered}); $form->{l_periodic_invoices} = "Y" if ($form->{periodic_invoices_active} && $form->{periodic_invoices_inactive}); + map { $form->{"l_${_}"} = 'Y' } qw(order_probability expected_billing_date expected_netamount) if $form->{l_order_probability_expected_billing_date}; + my $attachment_basename; if ($form->{vc} eq 'vendor') { if ($form->{type} eq 'purchase_order') { @@ -838,7 +868,8 @@ sub orders { push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber cusordnumber transaction_description transdatefrom transdateto type vc employee_id salesman_id reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive - business_id shippingpoint taxzone_id); + business_id shippingpoint taxzone_id + order_probability_op order_probability_value expected_billing_date_from expected_billing_date_to); my @keys_for_url = grep { $form->{$_} } @hidden_variables; push @keys_for_url, 'taxzone_id' if $form->{taxzone_id} ne ''; # taxzone_id could be 0 @@ -876,6 +907,9 @@ sub orders { 'periodic_invoices' => { 'text' => $locale->text('Per. Inv.'), }, 'shippingpoint' => { 'text' => $locale->text('Shipping Point'), }, 'taxzone' => { 'text' => $locale->text('Steuersatz'), }, + 'order_probability' => { 'text' => $locale->text('Order probability'), }, + 'expected_billing_date' => { 'text' => $locale->text('Exp. bill. date'), }, + 'expected_netamount' => { 'text' => $locale->text('Exp. netamount'), }, ); foreach my $name (qw(id transdate reqdate quonumber ordnumber cusordnumber name employee salesman shipvia transaction_description shippingpoint taxzone)) { @@ -883,7 +917,7 @@ sub orders { $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } - my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr remaining_amount remaining_netamount); + my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr remaining_amount remaining_netamount order_probability expected_billing_date expected_netamount); $form->{"l_type"} = "Y"; map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; @@ -929,6 +963,16 @@ sub orders { push @options, $locale->text('Steuersatz') . " : " . SL::DB::TaxZone->new(id => $form->{taxzone_id})->load->description; } + if (($form->{order_probability_value} || '') ne '') { + push @options, $::locale->text('Order probability') . ' ' . ($form->{order_probability_op} eq 'le' ? '<=' : '>=') . ' ' . $form->{order_probability_value} . '%'; + } + + if ($form->{expected_billing_date_from} or $form->{expected_billing_date_to}) { + push @options, $locale->text('Expected billing date'); + push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{expected_billing_date_from}, 1) if $form->{expected_billing_date_from}; + push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{expected_billing_date_to}, 1) if $form->{expected_billing_date_to}; + } + $report->set_options('top_info_text' => join("\n", @options), 'raw_top_info_text' => $form->parse_html_template('oe/orders_top'), 'raw_bottom_info_text' => $form->parse_html_template('oe/orders_bottom', { 'SHOW_CONTINUE_BUTTON' => $allow_multiple_orders }), @@ -946,6 +990,7 @@ sub orders { my $callback = $form->escape($href); my @subtotal_columns = qw(netamount amount marge_total marge_percent remaining_amount remaining_netamount); + push @subtotal_columns, 'expected_netamount' if $form->{l_order_probability_expected_billing_date}; my %totals = map { $_ => 0 } @subtotal_columns; my %subtotals = map { $_ => 0 } @subtotal_columns; @@ -968,7 +1013,9 @@ sub orders { $subtotals{marge_percent} = $subtotals{netamount} ? ($subtotals{marge_total} * 100 / $subtotals{netamount}) : 0; $totals{marge_percent} = $totals{netamount} ? ($totals{marge_total} * 100 / $totals{netamount} ) : 0; - map { $oe->{$_} = $form->format_amount(\%myconfig, $oe->{$_}, 2) } qw(netamount tax amount marge_total marge_percent remaining_amount remaining_netamount); + map { $oe->{$_} = $form->format_amount(\%myconfig, $oe->{$_}, 2) } qw(netamount tax amount marge_total marge_percent remaining_amount remaining_netamount expected_netamount); + + $oe->{order_probability} = ($oe->{order_probability} || 0) . '%'; my $row = { }; @@ -1300,6 +1347,7 @@ sub invoice { my $locale = $main::locale; check_oe_access(); + check_oe_conversion_to_sales_invoice_allowed(); $main::auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit'); $form->{old_salesman_id} = $form->{salesman_id}; @@ -1930,13 +1978,13 @@ sub edit_periodic_invoices_config { if ('HASH' ne ref $config) { $config = { periodicity => 'y', - start_date_as_date => $::form->{transdate}, + start_date_as_date => $::form->{transdate} || $::form->current_date, extend_automatically_by => 12, active => 1, }; } - $config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } qw(m q y); + $config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } qw(m q b y); $::form->get_lists(printers => "ALL_PRINTERS", charts => { key => 'ALL_CHARTS', @@ -1962,9 +2010,10 @@ sub save_periodic_invoices_config { my $config = { active => $::form->{active} ? 1 : 0, terminated => $::form->{terminated} ? 1 : 0, - periodicity => (any { $_ eq $::form->{periodicity} } qw(m q y)) ? $::form->{periodicity} : 'm', + periodicity => (any { $_ eq $::form->{periodicity} } qw(m q b y)) ? $::form->{periodicity} : 'm', start_date_as_date => $::form->{start_date_as_date}, end_date_as_date => $::form->{end_date_as_date}, + first_billing_date_as_date => $::form->{first_billing_date_as_date}, print => $::form->{print} ? 1 : 0, printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef, copies => $::form->{copies} * 1 ? $::form->{copies} : 1,