X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fcommon.pl;h=e21b3c5052d6bf3672131d66f79cdc43a40d9ad1;hb=ee56f1b20ab915671ded297f593c0e2e245bad70;hp=a967480f8c8366dbe55108b61eb2eee0024460df;hpb=387cb8faaf8dd342f26783f805c87e6e91e680e3;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index a967480f8..e21b3c505 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -11,10 +11,10 @@ use SL::Common; use SL::DB::Helper::Mappings; -use SL::DBUtils; +use SL::DB; +use SL::DBUtils qw(do_query); use SL::Form; -use SL::MoreCommon; -use SL::Helper::Flash; +use SL::MoreCommon qw(restore_form save_form); use strict; @@ -53,158 +53,6 @@ sub build_std_url { # ------------------------------------------------------------------------- -sub select_part { - $main::lxdebug->enter_sub(); - - my ($callback_sub, @parts) = @_; - - my $form = $main::form; - my $locale = $main::locale; - - my $remap_parts_id = 0; - if (defined($parts[0]->{parts_id}) && !defined($parts[0]->{id})) { - $remap_parts_id = 1; - map { $_->{id} = $_->{parts_id}; } @parts; - } - - my $remap_partnumber = 0; - if (defined($parts[0]->{partnumber}) && !defined($parts[0]->{number})) { - $remap_partnumber = 1; - map { $_->{number} = $_->{partnumber}; } @parts; - } - - my $has_charge = 0; - if (defined($parts[0]->{chargenumber})) { - $has_charge = 1; - map { $_->{has_charge} = 1; } @parts; - } - my $has_bestbefore = 0; - if (defined($parts[0]->{bestbefore})) { - $has_bestbefore = 1; - map { $_->{has_bestbefore} = 1; } @parts; - } - my $has_ean = 0; - if (defined($parts[0]->{ean})) { - $has_ean = 1; - map { $_->{has_ean} = 1; } @parts; - } - - my $old_form = save_form(); - - $form->header(); - print $form->parse_html_template("generic/select_part", - { "PARTS" => \@parts, - "old_form" => $old_form, - "title" => $locale->text("Select a part"), - "nextsub" => "select_part_internal", - "callback_sub" => $callback_sub, - "has_charge" => $has_charge, - "has_bestbefore" => $has_bestbefore, - "has_ean" => $has_ean, - "remap_parts_id" => $remap_parts_id, - "remap_partnumber" => $remap_partnumber }); - - $main::lxdebug->leave_sub(); -} - -sub select_part_internal { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - - my ($new_item, $callback_sub); - - my $re = "^new_.*_$form->{selection}\$"; - - foreach (grep /$re/, keys %{ $form }) { - my $new_key = $_; - $new_key =~ s/^new_//; - $new_key =~ s/_\d+$//; - $new_item->{$new_key} = $form->{$_}; - } - - if ($form->{remap_parts_id}) { - $new_item->{parts_id} = $new_item->{id}; - delete $new_item->{id}; - } - - if ($form->{remap_partnumber}) { - $new_item->{partnumber} = $new_item->{number}; - delete $new_item->{number}; - } - - $callback_sub = $form->{callback_sub}; - - restore_form($form->{old_form}); - - call_sub($callback_sub, $new_item); - - $main::lxdebug->leave_sub(); -} - -sub part_selection_internal { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - my $order_by = "description"; - $order_by = $form->{"order_by"} if (defined($form->{"order_by"})); - my $order_dir = 1; - $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"})); - - my %options; - - foreach my $opt (split m/:/, $form->{options}) { - if ($opt =~ /=/) { - my ($key, $value) = split m/=/, $opt, 2; - $options{$key} = $value; - - } else { - $options{$opt} = 1; - } - } - - map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button); - - my $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir); - - if (0 == scalar(@{$parts})) { - $form->show_generic_information($locale->text("No part was found matching the search parameters.")); - } elsif (1 == scalar(@{$parts})) { - $::request->{layout}->add_javascripts_inline("part_selected('1')"); - } - - map { $parts->[$_]->{selected} = $_ ? 0 : 1; } (0..$#{$parts}); - - my $callback = build_std_url('action=part_selection_internal', qw(partnumber description input_partnumber input_description input_partsid), - grep({ /^[fl]_/ } keys %{ $form })); - - my @header_sort = qw(partnumber description); - my %header_title = ( "partnumber" => $locale->text("Part Number"), - "description" => $locale->text("Part Description"), - ); - - my @header = - map(+{ "column_title" => $header_title{$_}, - "column" => $_, - "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir), - }, - @header_sort); - - $form->{formname} ||= 'Form'; - - $form->{title} = $locale->text("Select a part"); - $form->header(no_layout => 1); - print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header, - "PARTS" => $parts, }); - - $main::lxdebug->leave_sub(); -} - -# ------------------------------------------------------------------------- - sub delivery_customer_selection { $main::lxdebug->enter_sub(); @@ -485,47 +333,6 @@ sub retrieve_partunits { # ------------------------------------------------------------------------- -sub mark_as_paid_common { - $main::lxdebug->enter_sub(); - - my ($myconfig, $db_name) = @_; - - my $form = $main::form; - my $locale = $main::locale; - - if($form->{mark_as_paid}) { - my $dbh ||= $form->get_standard_dbh($myconfig); - my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|; - do_query($form, $dbh, $query, $form->{id}); - $dbh->commit(); - $form->redirect($locale->text("Marked as paid")); - - } else { - my $referer = $ENV{HTTP_REFERER}; - my $script; - my $callback; - if ($referer =~ /action/) { - $referer =~ /^(.*)\?action\=[^\&]*(\&.*)$/; - $script = $1; - $callback = $2; - } elsif ($referer =~ /RESTORE_FORM_FROM_SESSION_ID/){ - $referer =~ /^(.*)\?RESTORE_FORM_FROM_SESSION_ID\=(.*)$/; - $script = $1; - $callback = ""; - } else { - $script = $referer; - $callback = ""; - } - $referer = $script . "?action=mark_as_paid&mark_as_paid=1&id=$form->{id}" . $callback; - $form->header(); - print qq|
|.$locale->text('Mark as paid?').qq|
|; - print qq| |; - print qq||; - } - - $main::lxdebug->leave_sub(); -} - sub cov_selection_internal { $main::lxdebug->enter_sub(); @@ -630,4 +437,6 @@ sub db { goto &SL::DB::Helper::Mappings::db; } +sub continue { call_sub($::form->{nextsub}); } + 1;