X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/cca9bcd19f7034fb1b06f6e55f95b6d8a72296ff..0cb6e3af8457c1b10c356a1749269b16c5cd3328:/bin/mozilla/io.pl diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 58c7d815b..3c6c087da 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -47,9 +47,12 @@ use SL::CT; use SL::IC; use SL::IO; +use SL::DB::Customer; use SL::DB::Default; use SL::DB::Language; use SL::DB::Printer; +use SL::DB::Vendor; +use SL::Helper::CreatePDF; use SL::Helper::Flash; require "bin/mozilla/common.pl"; @@ -274,12 +277,12 @@ sub display_row { my $linetotal = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2); my $rows = $form->numtextrows($form->{"description_$i"}, 30, 6); - $column_data{runningnumber} = $cgi->textfield(-name => "runningnumber_$i", -size => 5, -value => $i); # HuT - $column_data{partnumber} = $cgi->textfield(-name => "partnumber_$i", -size => 12, -value => $form->{"partnumber_$i"}); + $column_data{runningnumber} = $cgi->textfield(-name => "runningnumber_$i", -id => "runningnumber_$i", -size => 5, -value => $i); # HuT + $column_data{partnumber} = $cgi->textfield(-name => "partnumber_$i", -id => "partnumber_$i", -size => 12, -value => $form->{"partnumber_$i"}); $column_data{description} = (($rows > 1) # if description is too large, use a textbox instead - ? $cgi->textarea( -name => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30) - : $cgi->textfield(-name => "description_$i", -size => 30, -value => $form->{"description_$i"})) - . $cgi->button(-value => $locale->text('L'), -onClick => "set_longdescription_window('longdescription_$i')"); + ? $cgi->textarea( -name => "description_$i", -id => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30) + : $cgi->textfield(-name => "description_$i", -id => "description_$i", -value => $form->{"description_$i"}, -size => 30)) + . $cgi->button(-value => $locale->text('L'), -onClick => "kivi.SalesPurchase.edit_longdescription($i)"); my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; @@ -434,9 +437,9 @@ sub display_row { my @HIDDENS = map { value => $_}, ( $cgi->hidden("-name" => "unit_old_$i", "-value" => $form->{"selected_unit_$i"}), $cgi->hidden("-name" => "price_new_$i", "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"})), - map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" } + map { ($cgi->hidden("-name" => $_, "-id" => $_, "-value" => $form->{$_})); } map { $_."_$i" } (qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes - income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber + income_accno expense_accno listprice assembly taxaccounts ordnumber donumber transdate cusordnumber longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars) ); @@ -749,7 +752,7 @@ sub remove_emptied_rows { taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values - sellprice_pg pricegroup_old price_old price_new unit_old ordnumber + sellprice_pg pricegroup_old price_old price_new unit_old ordnumber donumber transdate longdescription basefactor marge_total marge_percent marge_price_factor lastcost price_factor_id partnotes stock_out stock_in has_sernumber reqdate); @@ -868,8 +871,6 @@ sub order { } $form->{script} = 'oe.pl'; - $form->{shipto} = 1; - $form->{rowcount}--; $form->{cp_id} *= 1; @@ -934,8 +935,6 @@ sub quotation { $form->{script} = 'oe.pl'; - $form->{shipto} = 1; - $form->{rowcount}--; require "bin/mozilla/$form->{script}"; @@ -1206,17 +1205,12 @@ sub print { } $form->{print_and_save} = 1; my $formname = $form->{formname}; - save(); + &save(); $form->{formname} = $formname; - edit(); + &edit(); $::lxdebug->leave_sub(); ::end_of_request(); } - elsif (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)) { - $form->{print_and_save} = 1; - save(); - } - &print_form($old_form); @@ -1236,7 +1230,7 @@ sub print_form { $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; $form->{templates} = $defaults->templates; - my ($old_form) = @_; + my ($old_form, %params) = @_; my $inv = "inv"; my $due = "due"; @@ -1332,6 +1326,14 @@ sub print_form { $form->{label} = $form->{formname} eq 'pick_list' ? $locale->text('Pick List') : $locale->text('Delivery Order'); } + $form->{TEMPLATE_DRIVER_OPTIONS} = { }; + if (any { $form->{type} eq $_ } qw(sales_quotation sales_order sales_delivery_order invoice request_quotation purchase_order purchase_delivery_order)) { + $form->{TEMPLATE_DRIVER_OPTIONS}->{variable_content_types} = { + longdescription => 'html', + partnotes => 'html', + }; + } + $form->isblank("email", $locale->text('E-mail address missing!')) if ($form->{media} eq 'email'); $form->isblank("${inv}date", @@ -1346,31 +1348,7 @@ sub print_form { # $locale->text('Quotation Number missing!') # $locale->text('Quotation Date missing!') - # assign number $form->{what_done} = $form->{formname}; - if (!$form->{"${inv}number"} && !$form->{preview} && !$form->{id}) { - $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld); - if ($form->{media} ne 'email') { - - # get pricegroups for parts - IS->get_pricegroups_for_parts(\%myconfig, \%$form); - - # build up html code for prices_$i - set_pricegroup($form->{rowcount}); - - $form->{rowcount}--; - - call_sub($display_form); - # saving the history - if(!exists $form->{addition}) { - $form->{snumbers} = "${inv}number" . "_" . $form->{"${inv}number"}; - $form->{addition} = "PRINTED"; - $form->save_history; - } - # /saving the history - ::end_of_request(); - } - } &validate_items; @@ -1437,28 +1415,6 @@ sub print_form { $form->get_shipto(\%myconfig); } - my @a = qw(name department_1 department_2 street zipcode city country contact phone fax email); - - my $shipto = 1; - - # if there is no shipto fill it in from billto - foreach my $item (@a) { - if ($form->{"shipto$item"}) { - $shipto = 0; - last; - } - } - - if ($shipto) { - if ( $form->{formname} eq 'purchase_order' - || $form->{formname} eq 'request_quotation') { - $form->{shiptoname} = $defaults->company; - $form->{shiptostreet} = $defaults->address; - } else { - map { $form->{"shipto$_"} = $form->{$_} } @a; - } - } - $form->{notes} =~ s/^\s+//g; delete $form->{printer_command}; @@ -1534,18 +1490,20 @@ sub print_form { } # search for the template - my @template_files; - push @template_files, "$form->{formname}_email$form->{language}$printer_code.$extension" if $form->{media} eq 'email'; - push @template_files, "$form->{formname}$form->{language}$printer_code.$extension"; - push @template_files, "$form->{formname}.$extension"; - push @template_files, "default.$extension"; - @template_files = uniq @template_files; - $form->{IN} = first { -f ($defaults->templates . "/$_") } @template_files; - - if (!defined $form->{IN}) { + my ($template_file, @template_files) = SL::Helper::CreatePDF->find_template( + name => $form->{formname}, + email => $form->{media} eq 'email', + language_id => $form->{language_id}, + printer_id => $form->{printer_id}, + extension => $extension, + ); + + if (!defined $template_file) { $::form->error($::locale->text('Cannot find matching template for this print request. Please contact your template maintainer. I tried these: #1.', join ', ', map { "'$_'"} @template_files)); } + $form->{IN} = $template_file; + delete $form->{OUT}; if ($form->{media} eq 'printer') { @@ -1680,7 +1638,10 @@ sub print_form { ($form->{media} eq 'printer') ? $locale->text('sent to printer') : $locale->text('emailed to') . " $form->{email}"; - $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|); + + if (!$params{no_redirect}) { + $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|); + } } if ($form->{printing}) { call_sub($display_form); @@ -1754,8 +1715,11 @@ sub ship_to { $::form->{title} = $::locale->text('Ship to'); $::form->header; + my $vc_obj = ($::form->{vc} eq 'customer' ? "SL::DB::Customer" : "SL::DB::Vendor")->new(id => $::form->{$::form->{vc} . "_id"})->load; + print $::form->parse_html_template('io/ship_to', { previousform => $previous_form, nextsub => $::form->{display_form} || 'display_form', + vc_obj => $vc_obj, }); $main::lxdebug->leave_sub(); @@ -1901,16 +1865,18 @@ sub _render_custom_variables_inputs { foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { $cvar->{valid} = $params{part_id} && $valid->($cvar->{id}); + my $show = 0; my $description = ''; if ($cvar->{flag_editable} && $cvar->{valid}) { $num_visible_cvars++; $description = $cvar->{description} . ' '; + $show = 1; } my $form_key = "ic_cvar_" . $cvar->{name} . "_$params{row}"; push @{ $params{ROW2} }, { - line_break => $num_visible_cvars == 1, + line_break => $show && !(($num_visible_cvars - 1) % ($::myconfig{form_cvars_nr_cols}*1 || 3)), description => $description, cvar => 1, render_options => {