X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdo.pl;h=130cca13039cd799fb844ce645fb65bbee043cd3;hb=893bff3a5c0106b467578b470deac53f87173689;hp=79d8172e37c5e58d368e70a34384608ee55e0b82;hpb=07948c344b0f699314c1b05b4e9c41b8babc3981;p=kivitendo-erp.git diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 79d8172e3..130cca130 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -159,14 +159,19 @@ sub order_links { DO->retrieve('vc' => $form->{vc}, 'ids' => $form->{id}); - $payment_id = $form->{payment_id} if ($form->{payment_id}); - $language_id = $form->{language_id} if ($form->{language_id}); - $taxzone_id = $form->{taxzone_id} if ($form->{taxzone_id}); - $salesman_id = $form->{salesman_id} if ($editing); + $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes)); + $form->{shipto} = 1 if $form->{id}; + # get customer / vendor + if ($form->{vc} eq 'vendor') { + IR->get_vendor(\%myconfig, \%$form); + } else { + IS->get_customer(\%myconfig, \%$form); + } - $taxincluded = $form->{taxincluded}; - $form->{shipto} = 1 if $form->{id}; + $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id)); + $form->restore_vars(qw(taxincluded)) if $form->{id}; + $form->restore_vars(qw(salesman_id)) if $editing; if ($form->{"all_$form->{vc}"}) { unless ($form->{"$form->{vc}_id"}) { @@ -174,16 +179,6 @@ sub order_links { } } - $cp_id = $form->{cp_id}; - $intnotes = $form->{intnotes}; - - $form->{cp_id} = $cp_id; - - $form->{payment_id} = $payment_id if ($payment_id); - $form->{language_id} = $language_id if ($language_id); - $form->{taxzone_id} = $taxzone_id if ($taxzone_id); - $form->{intnotes} = $intnotes if ($intnotes); - ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} }; $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; @@ -227,8 +222,6 @@ sub prepare_order { (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); $dec_qty = length $dec_qty; $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); - - map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit); } $lxdebug->leave_sub(); @@ -346,7 +339,6 @@ sub update_delivery_order { } else { - map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor}; @@ -383,7 +375,7 @@ sub search { check_do_access(); - $form->{vc} = $form->{type} eq 'purchase_order' ? 'vendor' : 'customer'; + $form->{vc} = $form->{type} eq 'purchase_delivery_order' ? 'vendor' : 'customer'; $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, @@ -409,7 +401,7 @@ sub orders { ($form->{ $form->{vc} }, $form->{"${form->{vc}}_id"}) = split(/--/, $form->{ $form->{vc} }); - $form->{sort} ||= 'transdate'; + report_generator_set_default_sort('transdate', 1); DO->transactions(); @@ -455,8 +447,9 @@ sub orders { 'delivered' => { 'text' => $locale->text('Delivered'), }, ); - foreach my $name (qw(id transdate donumber ordnumber name employee shipvia)) { - $column_defs{$name}->{link} = $href . "&sort=$name"; + foreach my $name (qw(id transdate donumber ordnumber name employee shipvia transaction_description)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } $form->{"l_type"} = "Y"; @@ -469,7 +462,7 @@ sub orders { $report->set_export_options('orders', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my @options; if ($form->{customer}) { @@ -646,17 +639,17 @@ sub invoice { $lxdebug->enter_sub(); check_do_access(); - $auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit'); + $auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit'); - $form->{deliverydate} = $form->{transdate}; - $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{convert_from_do_ids} = $form->{id}; + $form->{deliverydate} = $form->{transdate}; + $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{id} = ''; - $form->{closed} = 0; $form->{rowcount}--; - $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + delete @{$form}{qw(id closed delivered)}; if ($form->{type} eq 'purchase_delivery_order') { $form->{title} = $locale->text('Add Vendor Invoice'); @@ -740,12 +733,13 @@ sub invoice_multi { 'back_button' => 1); } - $form->{deliverydate} = $form->{transdate}; - $form->{transdate} = $form->current_date(\%myconfig); - $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); - $form->{type} = "invoice"; - $form->{closed} = 0; - $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + $form->{convert_from_do_ids} = join ' ', @do_ids; + $form->{deliverydate} = $form->{transdate}; + $form->{transdate} = $form->current_date(\%myconfig); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{type} = "invoice"; + $form->{closed} = 0; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); my $buysell; if ($form->{type} eq 'purchase_delivery_order') { @@ -789,6 +783,7 @@ sub save_as_new { $form->{saveasnew} = 1; $form->{closed} = 0; + $form->{delivered} = 0; map { delete $form->{$_} } qw(printed emailed queued); # Let Lx-Office assign a new order number if the user hasn't changed the @@ -905,9 +900,9 @@ sub update_stock_in { my $stock_info = []; foreach my $i (1..$form->{rowcount}) { + $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"}); push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber qty unit) }; } - $main::lxdebug->dump(0, "si", $stock_info); display_stock_in_form($stock_info); @@ -939,7 +934,7 @@ sub display_stock_in_form { $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS' }); - redo_stock_info('stock_info' => $stock_info, 'add_empty_row' => !$form->{closed}); + redo_stock_info('stock_info' => $stock_info, 'add_empty_row' => !$form->{delivered}); get_basic_bin_wh_info($stock_info); @@ -986,7 +981,7 @@ sub stock_out_form { my $stock_info = DO->unpack_stock_information('packed' => $form->{stock}); - if (!$form->{closed}) { + if (!$form->{delivered}) { foreach my $row (@contents) { $row->{available_qty} = $form->format_amount_units('amount' => $row->{qty} * 1, 'part_unit' => $part_info->{unit}, @@ -1012,7 +1007,7 @@ sub stock_out_form { $form->header(); print $form->parse_html_template('do/stock_out_form', { 'UNITS' => $units_data, - 'WHCONTENTS' => $form->{closed} ? $stock_info : \@contents, + 'WHCONTENTS' => $form->{delivered} ? $stock_info : \@contents, 'PART_INFO' => $part_info, }); $lxdebug->leave_sub(); @@ -1056,9 +1051,13 @@ sub set_stock_out { $lxdebug->leave_sub(); } -sub transfer_in_and_close { +sub transfer_in { $lxdebug->enter_sub(); + if (DO->is_marked_as_delivered('id' => $form->{id})) { + $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred in.'), 'back_button' => 1); + } + my @part_ids = map { $form->{"id_${_}"} } grep { $form->{"id_${_}"} && $form->{"stock_in_${_}"} } (1 .. $form->{rowcount}); my @all_requests; @@ -1093,7 +1092,7 @@ sub transfer_in_and_close { } if (@{ $form->{ERRORS} }) { - push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been closed. The warehouse contents have not changed.'); + push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been marked as delivered. The warehouse contents have not changed.'); update(); $lxdebug->leave_sub(); @@ -1105,7 +1104,6 @@ sub transfer_in_and_close { DO->transfer_in_out('direction' => 'in', 'requests' => \@all_requests); - $form->{closed} = 1; $form->{delivered} = 1; save(); @@ -1113,9 +1111,13 @@ sub transfer_in_and_close { $lxdebug->leave_sub(); } -sub transfer_out_and_close { +sub transfer_out { $lxdebug->enter_sub(); + if (DO->is_marked_as_delivered('id' => $form->{id})) { + $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred out.'), 'back_button' => 1); + } + my @part_ids = map { $form->{"id_${_}"} } grep { $form->{"id_${_}"} && $form->{"stock_out_${_}"} } (1 .. $form->{rowcount}); my @all_requests; @@ -1186,7 +1188,7 @@ sub transfer_out_and_close { } if (@{ $form->{ERRORS} }) { - push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been closed. The warehouse contents have not changed.'); + push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been marked as delivered. The warehouse contents have not changed.'); update(); $lxdebug->leave_sub(); @@ -1198,7 +1200,6 @@ sub transfer_out_and_close { DO->transfer_in_out('direction' => 'out', 'requests' => \@all_requests); - $form->{closed} = 1; $form->{delivered} = 1; save(); @@ -1206,6 +1207,19 @@ sub transfer_out_and_close { $lxdebug->leave_sub(); } +sub mark_closed { + $lxdebug->enter_sub(); + + DO->close_orders('ids' => [ $form->{id} ]); + + $form->{closed} = 1; + + update(); + + $lxdebug->leave_sub(); +} + + sub yes { call_sub($form->{yes_nextsub}); }