Revision 9c76baca
Von Sven Schöling vor mehr als 7 Jahren hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
16 | 16 |
use SL::DB::History; |
17 | 17 |
use SL::DB::Helper::ValidateAssembly qw(validate_assembly); |
18 | 18 |
use SL::CVar; |
19 |
use SL::MoreCommon qw(save_form); |
|
19 | 20 |
use Carp; |
20 | 21 |
|
21 | 22 |
use Rose::Object::MakeMethods::Generic ( |
... | ... | |
69 | 70 |
$self->add; |
70 | 71 |
}; |
71 | 72 |
|
73 |
sub action_add_from_record { |
|
74 |
my ($self) = @_; |
|
75 |
|
|
76 |
check_has_valid_part_type($::form->{part}{part_type}); |
|
77 |
|
|
78 |
$self->parse_form; |
|
79 |
$self->add; |
|
80 |
} |
|
81 |
|
|
72 | 82 |
sub action_add { |
73 | 83 |
my ($self) = @_; |
74 | 84 |
|
... | ... | |
139 | 149 |
flash_later('info', $is_new ? t8('The item has been created.') . " " . $self->part->displayable_name : t8('The item has been saved.')); |
140 | 150 |
|
141 | 151 |
if ( $::form->{callback} ) { |
142 |
$self->redirect_to($::form->unescape($::form->{callback})); |
|
152 |
$self->redirect_to($::form->unescape($::form->{callback}) . '&new_parts_id=' . $self->part->id); |
|
153 |
|
|
143 | 154 |
} else { |
144 | 155 |
# default behaviour after save: reload item, this also resets last_modification! |
145 | 156 |
$self->redirect_to(controller => 'Part', action => 'edit', 'part.id' => $self->part->id); |
bin/mozilla/io.pl | ||
---|---|---|
697 | 697 |
} |
698 | 698 |
|
699 | 699 |
sub new_item { |
700 |
$main::lxdebug->enter_sub();
|
|
700 |
_check_io_auth();
|
|
701 | 701 |
|
702 |
my $form = $main::form; |
|
703 |
my %myconfig = %main::myconfig; |
|
702 |
my $price = $::form->{vc} eq 'customer' ? 'sellprice_as_number' : 'lastcost_as_number'; |
|
703 |
my $previousform = $::auth->save_form_in_session; |
|
704 |
my $callback = build_std_url("action=return_from_new_item", "previousform=$previousform"); |
|
705 |
my $i = $::form->{rowcount}; |
|
704 | 706 |
|
705 |
_check_io_auth(); |
|
707 |
my @HIDDENS; |
|
708 |
push @HIDDENS, { 'name' => 'callback', 'value' => $callback }; |
|
709 |
push @HIDDENS, map +{ 'name' => $_, 'value' => $::form->{$_} }, qw(rowcount vc); |
|
710 |
push @HIDDENS, map +{ 'name' => "part.$_", 'value' => $::form->{"${_}_$i"} }, qw(partnumber description unit price_factor_id); |
|
711 |
push @HIDDENS, { 'name' => "part.$price", 'value' => $::form->{"sellprice_$i"} }; |
|
712 |
push @HIDDENS, { 'name' => "part.notes", 'value' => $::form->{"longdescription_$i"} }; |
|
706 | 713 |
|
707 |
my $price_key = ($form->{type} =~ m/request_quotation|purchase_order/) || ($form->{script} eq 'ir.pl') ? 'lastcost' : 'sellprice'; |
|
714 |
$::form->header; |
|
715 |
print $::form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } ); |
|
716 |
} |
|
708 | 717 |
|
709 |
# change callback |
|
710 |
$form->{old_callback} = $form->escape($form->{callback}, 1); |
|
711 |
$form->{callback} = $form->escape("$form->{script}?action=display_form", 1); |
|
718 |
sub return_from_new_item { |
|
719 |
_check_io_auth(); |
|
712 | 720 |
|
713 |
# save all form variables except action in the session and keep the key in the previousform variable |
|
714 |
my $previousform = $::auth->save_form_in_session(skip_keys => [ qw(action) ]); |
|
721 |
my $part = SL::DB::Manager::Part->find_by(id => delete $::form->{new_parts_id}) or die 'can not find part that was just saved!'; |
|
715 | 722 |
|
716 |
my @HIDDENS; |
|
717 |
push @HIDDENS, { 'name' => 'previousform', 'value' => $previousform }; |
|
718 |
push @HIDDENS, map +{ 'name' => $_, 'value' => $form->{$_} }, qw(rowcount vc); |
|
719 |
push @HIDDENS, map +{ 'name' => $_, 'value' => $form->{"${_}_$form->{rowcount}"} }, qw(partnumber description unit); |
|
720 |
push @HIDDENS, { 'name' => 'taxaccount2', 'value' => $form->{taxaccounts} }; |
|
721 |
push @HIDDENS, { 'name' => $price_key, 'value' => $form->parse_amount(\%myconfig, $form->{"sellprice_$form->{rowcount}"}) }; |
|
722 |
push @HIDDENS, { 'name' => 'notes', 'value' => $form->{"longdescription_$form->{rowcount}"} }; |
|
723 |
$::auth->restore_form_from_session(delete $::form->{previousform}, form => $::form); |
|
723 | 724 |
|
724 |
$form->header(); |
|
725 |
print $form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } ); |
|
725 |
$::form->{"id_$::form->{rowcount}"} = $part->id; |
|
726 | 726 |
|
727 |
$main::lxdebug->leave_sub(); |
|
727 |
my $url = build_std_url("script=$::form->{script}", "RESTORE_FORM_FROM_SESSION_ID=" . $::auth->save_form_in_session); |
|
728 |
print $::request->{cgi}->redirect($url); |
|
728 | 729 |
} |
729 | 730 |
|
730 | 731 |
sub check_form { |
templates/webpages/generic/new_item.html | ||
---|---|---|
14 | 14 |
|
15 | 15 |
<p> |
16 | 16 |
|
17 |
<input class="radio" type="radio" name="part_type" value="part" checked> [% 'Part' | $T8 %]<br> |
|
18 |
<input class="radio" type="radio" name="part_type" value="assembly"> [% 'Assembly' | $T8 %]<br> |
|
19 |
<input class="radio" type="radio" name="part_type" value="service"> [% 'Service' | $T8 %]<br> |
|
20 |
<input class="radio" type="radio" name="part_type" value="assortment"> [% 'Assortment' | $T8 %] |
|
17 |
<input class="radio" type="radio" name="part.part_type" value="part" checked> [% 'Part' | $T8 %]<br>
|
|
18 |
<input class="radio" type="radio" name="part.part_type" value="assembly"> [% 'Assembly' | $T8 %]<br>
|
|
19 |
<input class="radio" type="radio" name="part.part_type" value="service"> [% 'Service' | $T8 %]<br>
|
|
20 |
<input class="radio" type="radio" name="part.part_type" value="assortment"> [% 'Assortment' | $T8 %]
|
|
21 | 21 |
<p> |
22 | 22 |
|
23 | 23 |
[%- FOREACH var = HIDDENS %] |
... | ... | |
26 | 26 |
</p> |
27 | 27 |
|
28 | 28 |
<input type="hidden" name="action" value="Part/dispatch"> |
29 |
<input class="submit" type="submit" name="action_add" value="[% 'Continue' | $T8 %]"> |
|
29 |
<input class="submit" type="submit" name="action_add_from_record" value="[% 'Continue' | $T8 %]">
|
|
30 | 30 |
[%- ELSE %] |
31 | 31 |
</h4> |
32 | 32 |
[%- END %] |
Auch abrufbar als: Unified diff
Artikel anlegen mit Rücksprung in Belege