Revision c5725a1e
Von Tamino Steinert vor 3 Monaten hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
172 | 172 |
# edit an existing order |
173 | 173 |
sub action_edit { |
174 | 174 |
my ($self) = @_; |
175 |
die "No 'id' was given." unless $::form->{id}; |
|
175 | 176 |
|
176 |
if ($::form->{id}) { |
|
177 |
$self->load_order; |
|
178 |
|
|
179 |
} else { |
|
180 |
# this is to edit an order from an unsaved order object |
|
181 |
|
|
182 |
# set item ids to new fake id, to identify them as new items |
|
183 |
foreach my $item (@{$self->order->items_sorted}) { |
|
184 |
$item->{new_fake_id} = |
|
185 |
join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
|
186 |
} |
|
187 |
# trigger rendering values for second row as hidden, because they |
|
188 |
# are loaded only on demand. So we need to keep the values from |
|
189 |
# the source. |
|
190 |
$_->{render_second_row} = 1 for @{ $self->order->items_sorted }; |
|
191 |
|
|
192 |
if (!$::form->{form_validity_token}) { |
|
193 |
$::form->{form_validity_token} = SL::DB::ValidityToken->create( |
|
194 |
scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE() |
|
195 |
)->token; |
|
196 |
} |
|
197 |
} |
|
177 |
$self->load_order; |
|
198 | 178 |
|
199 | 179 |
$self->pre_render(); |
200 | 180 |
$self->render( |
... | ... | |
1573 | 1553 |
|
1574 | 1554 |
$self->order(SL::DB::DeliveryOrder->new(id => $::form->{id})->load); |
1575 | 1555 |
|
1576 |
# Add an empty custom shipto to the order, so that the dialog can render the cvar inputs. |
|
1577 |
# You need a custom shipto object to call cvars_by_config to get the cvars. |
|
1578 |
$self->order->custom_shipto(SL::DB::Shipto->new(module => 'DO', custom_variables => [])) if !$self->order->custom_shipto; |
|
1579 |
|
|
1580 |
$self->order->prepare_stock_info($_) for $self->order->items; |
|
1556 |
$self->reinit_after_new_order(); |
|
1581 | 1557 |
|
1582 | 1558 |
return $self->order; |
1583 | 1559 |
} |
... | ... | |
1768 | 1744 |
if ($order->shipto) { |
1769 | 1745 |
$self->is_custom_shipto_to_delete(1); |
1770 | 1746 |
} else { |
1771 |
my $custom_shipto = $order->custom_shipto ?
|
|
1772 |
$order->custom_shipto |
|
1773 |
: $order->custom_shipto(
|
|
1774 |
SL::DB::Shipto->new(module => 'DO', custom_variables => []) |
|
1775 |
); |
|
1747 |
my $custom_shipto = |
|
1748 |
$order->custom_shipto
|
|
1749 |
|| $order->custom_shipto(
|
|
1750 |
SL::DB::Shipto->new(module => 'DO', custom_variables => [])
|
|
1751 |
);
|
|
1776 | 1752 |
|
1777 | 1753 |
my $shipto_cvars = { |
1778 | 1754 |
map { my ($key) = m{^shiptocvar_(.+)}; $key => delete $form->{$_}} |
... | ... | |
1845 | 1821 |
delete $::form->{form_validity_token}; |
1846 | 1822 |
} |
1847 | 1823 |
|
1848 |
sub workflow_sales_or_request_for_quotation { |
|
1849 |
my ($self, $destination_type) = @_; |
|
1850 |
|
|
1851 |
# always save |
|
1852 |
$self->save(); |
|
1853 |
|
|
1854 |
my $delivery_order = SL::Model::Record->new_from_workflow( |
|
1855 |
$self->order, $destination_type |
|
1856 |
); |
|
1857 |
$self->order($delivery_order); |
|
1858 |
$self->{converted_from_oe_id} = delete $::form->{id}; |
|
1859 |
|
|
1860 |
$self->reinit_after_new_order(); |
|
1861 |
|
|
1862 |
$self->render( |
|
1863 |
'delivery_order/form', |
|
1864 |
title => $self->get_title_for('edit'), |
|
1865 |
%{$self->{template_args}} |
|
1866 |
); |
|
1867 |
} |
|
1868 |
|
|
1869 | 1824 |
sub reinit_after_new_order { |
1870 | 1825 |
my ($self) = @_; |
1871 | 1826 |
|
1872 | 1827 |
# change form type |
1873 | 1828 |
$::form->{type} = $self->order->type; |
1874 | 1829 |
$self->type($self->init_type); |
1875 |
$self->cv ($self->init_cv); |
|
1830 |
$self->type_data($self->init_type_data); |
|
1831 |
$self->cv($self->init_cv); |
|
1876 | 1832 |
$self->check_auth; |
1877 | 1833 |
|
1834 |
$self->setup_custom_shipto_from_form($self->order, $::form); |
|
1835 |
|
|
1878 | 1836 |
foreach my $item (@{$self->order->items_sorted}) { |
1879 | 1837 |
# set item ids to new fake id, to identify them as new items |
1880 | 1838 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
... | ... | |
1885 | 1843 |
$item->{render_second_row} = 1; |
1886 | 1844 |
} |
1887 | 1845 |
|
1846 |
$self->order->prepare_stock_info($_) for $self->order->items; |
|
1888 | 1847 |
$self->get_unalterable_data(); |
1889 | 1848 |
} |
1890 | 1849 |
|
SL/Controller/Order.pm | ||
---|---|---|
143 | 143 |
|
144 | 144 |
$self->order($order); |
145 | 145 |
|
146 |
$self->action_edit(); |
|
146 |
$self->reinit_after_new_order(); |
|
147 |
|
|
148 |
$self->action_add(); |
|
147 | 149 |
} |
148 | 150 |
|
149 | 151 |
sub action_add_from_email_journal { |
... | ... | |
166 | 168 |
# edit an existing order |
167 | 169 |
sub action_edit { |
168 | 170 |
my ($self) = @_; |
171 |
die "No 'id' was given." unless $::form->{id}; |
|
169 | 172 |
|
170 |
if ($::form->{id}) { |
|
171 |
$self->load_order; |
|
172 |
|
|
173 |
if ($self->order->is_sales && $::lx_office_conf{imap_client}->{enabled}) { |
|
174 |
my $imap_client = SL::IMAPClient->new(%{$::lx_office_conf{imap_client}}); |
|
175 |
if ($imap_client) { |
|
176 |
$imap_client->update_email_files_for_record(record => $self->order); |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
} else { |
|
181 |
# this is to edit an order from an unsaved order object |
|
182 |
|
|
183 |
# set item ids to new fake id, to identify them as new items |
|
184 |
foreach my $item (@{$self->order->items_sorted}) { |
|
185 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
|
186 |
} |
|
187 |
# trigger rendering values for second row as hidden, because they |
|
188 |
# are loaded only on demand. So we need to keep the values from |
|
189 |
# the source. |
|
190 |
$_->{render_second_row} = 1 for @{ $self->order->items_sorted }; |
|
173 |
$self->load_order; |
|
191 | 174 |
|
192 |
if (!$::form->{form_validity_token}) { |
|
193 |
$::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token; |
|
175 |
if ($self->order->is_sales && $::lx_office_conf{imap_client}->{enabled}) { |
|
176 |
my $imap_client = SL::IMAPClient->new(%{$::lx_office_conf{imap_client}}); |
|
177 |
if ($imap_client) { |
|
178 |
$imap_client->update_email_files_for_record(record => $self->order); |
|
194 | 179 |
} |
195 | 180 |
} |
196 | 181 |
|
197 |
$self->recalc(); |
|
198 | 182 |
$self->pre_render(); |
199 | 183 |
$self->render( |
200 | 184 |
'order/form', |
... | ... | |
230 | 214 |
my $target_type = SALES_ORDER_TYPE(); |
231 | 215 |
my $order = SL::Model::Record->new_from_workflow_multi(\@multi_orders, $target_type, sort_sources_by => 'transdate'); |
232 | 216 |
$self->order($order); |
217 |
$self->reinit_after_new_order(); |
|
233 | 218 |
|
234 |
$self->action_edit();
|
|
219 |
$self->action_add();
|
|
235 | 220 |
} |
236 | 221 |
|
237 | 222 |
# delete the order |
... | ... | |
1805 | 1790 |
|
1806 | 1791 |
$self->order(SL::DB::Order->new(id => $::form->{id})->load); |
1807 | 1792 |
|
1808 |
# Add an empty custom shipto to the order, so that the dialog can render the cvar inputs. |
|
1809 |
# You need a custom shipto object to call cvars_by_config to get the cvars. |
|
1810 |
$self->order->custom_shipto(SL::DB::Shipto->new(module => 'OE', custom_variables => [])) if !$self->order->custom_shipto; |
|
1793 |
$self->reinit_after_new_order(); |
|
1811 | 1794 |
|
1812 | 1795 |
return $self->order; |
1813 | 1796 |
} |
... | ... | |
1998 | 1981 |
if ($order->shipto) { |
1999 | 1982 |
$self->is_custom_shipto_to_delete(1); |
2000 | 1983 |
} else { |
2001 |
my $custom_shipto = $order->custom_shipto || $order->custom_shipto(SL::DB::Shipto->new(module => 'OE', custom_variables => [])); |
|
1984 |
my $custom_shipto = |
|
1985 |
$order->custom_shipto |
|
1986 |
|| $order->custom_shipto( |
|
1987 |
SL::DB::Shipto->new(module => 'OE', custom_variables => []) |
|
1988 |
); |
|
2002 | 1989 |
|
2003 | 1990 |
my $shipto_cvars = {map { my ($key) = m{^shiptocvar_(.+)}; $key => delete $form->{$_}} grep { m{^shiptocvar_} } keys %$form}; |
2004 | 1991 |
my $shipto_attrs = {map { $_ => delete $form->{$_}} grep { m{^shipto} } keys %$form}; |
... | ... | |
2174 | 2161 |
$::form->{type} = $self->order->type; |
2175 | 2162 |
$self->type($self->init_type); |
2176 | 2163 |
$self->type_data($self->init_type_data); |
2177 |
$self->cv ($self->init_cv);
|
|
2164 |
$self->cv($self->init_cv); |
|
2178 | 2165 |
$self->check_auth; |
2179 | 2166 |
|
2167 |
$self->setup_custom_shipto_from_form($self->order, $::form); |
|
2168 |
|
|
2180 | 2169 |
foreach my $item (@{$self->order->items_sorted}) { |
2181 | 2170 |
# set item ids to new fake id, to identify them as new items |
2182 | 2171 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
bin/mozilla/io.pl | ||
---|---|---|
1058 | 1058 |
|
1059 | 1059 |
require SL::Controller::Order; |
1060 | 1060 |
my $c = SL::Controller::Order->new(order => $order); |
1061 |
$c->setup_custom_shipto_from_form($order, $::form);
|
|
1062 |
$c->action_edit();
|
|
1061 |
$c->reinit_after_new_order();
|
|
1062 |
$c->action_add();
|
|
1063 | 1063 |
|
1064 | 1064 |
$main::lxdebug->leave_sub(); |
1065 | 1065 |
$::dispatcher->end_request; |
Auch abrufbar als: Unified diff
Beleg laden für Auftrag, Lieferschein und Reklamation angleichen