Revision ed04f337
Von Bernd Bleßmann vor etwa 9 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
$self->render_price_dialog($item);
|
||
}
|
||
|
||
sub action_get_item_longdescription {
|
||
my $longdescription;
|
||
|
||
if ($::form->{item_id}) {
|
||
$longdescription = SL::DB::OrderItem->new(id => $::form->{item_id})->load->longdescription;
|
||
} elsif ($::form->{parts_id}) {
|
||
$longdescription = SL::DB::Part->new(id => $::form->{parts_id})->load->notes;
|
||
}
|
||
$_[0]->render(\ $longdescription, { type => 'text' });
|
||
}
|
||
|
||
|
||
sub _js_redisplay_linetotals {
|
||
my ($self) = @_;
|
||
|
||
... | ... | |
my $item;
|
||
$item = first { $_->id == $attr->{id} } @{$record->items} if $attr->{id};
|
||
|
||
my $is_new = !$item;
|
||
|
||
# add_custom_variables adds cvars to an orderitem with no cvars for saving, but
|
||
# they cannot be retrieved via custom_variables until the order/orderitem is
|
||
# saved. Adding empty custom_variables to new orderitem here solves this problem.
|
||
$item ||= SL::DB::OrderItem->new(custom_variables => []);
|
||
|
||
$item->assign_attributes(%$attr);
|
||
$item->longdescription($item->part->notes) if $is_new && !defined $attr->{longdescription};
|
||
|
||
return $item;
|
||
}
|
||
... | ... | |
$new_attr{active_price_source} = $price_src;
|
||
$new_attr{active_discount_source} = $discount_src;
|
||
|
||
$new_attr{longdescription} = $part->notes if ! defined $attr->{longdescription};
|
||
|
||
# add_custom_variables adds cvars to an orderitem with no cvars for saving, but
|
||
# they cannot be retrieved via custom_variables until the order/orderitem is
|
||
# saved. Adding empty custom_variables to new orderitem here solves this problem.
|
||
... | ... | |
my ($self) = @_;
|
||
|
||
foreach my $item (@{ $self->order->items }) {
|
||
if ($item->id) {
|
||
# load data from orderitems (db)
|
||
my $db_item = SL::DB::OrderItem->new(id => $item->id)->load;
|
||
$item->$_($db_item->$_) for qw(longdescription);
|
||
} else {
|
||
# set data from part (or other sources)
|
||
$item->longdescription($item->part->notes);
|
||
}
|
||
|
||
# autovivify all cvars that are not in the form (cvars_by_config can do it).
|
||
# workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values).
|
||
foreach my $var (@{ $item->cvars_by_config }) {
|
||
... | ... | |
} } @all_objects;
|
||
}
|
||
|
||
$::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
|
||
$::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery);
|
||
}
|
||
|
||
sub _create_pdf {
|
templates/webpages/order/tabs/_row.html | ||
---|---|---|
confirm=LxERP.t8("Are you sure?")) %]
|
||
</td>
|
||
<td>
|
||
[% HTML.escape(ITEM.part.partnumber) %]
|
||
<div name="partnumber">[% HTML.escape(ITEM.part.partnumber) %]</div>
|
||
</td>
|
||
<td>
|
||
[% L.input_tag("order.orderitems[].description",
|
||
ITEM.description,
|
||
style='width: 300px') %]
|
||
[%- L.button_tag("show_longdescription_dialog(this)", LxERP.t8("L")) %]
|
||
</td>
|
||
<td>
|
||
[%- L.input_tag("order.orderitems[].qty_as_number",
|
templates/webpages/order/tabs/basic_data.html | ||
---|---|---|
[%- USE LxERP %]
|
||
[%- USE L %]
|
||
|
||
[%- INCLUDE 'generic/set_longdescription.html' %]
|
||
|
||
<div id="ui-tabs-basic-data">
|
||
<table width="100%">
|
||
<tr valign="top">
|
||
... | ... | |
renumber_positions();
|
||
}
|
||
|
||
function show_longdescription_dialog(clicked) {
|
||
var row = $(clicked).parents("tbody").first();
|
||
var position = $(row).find('[name="position"]').html();
|
||
var partnumber = $(row).find('[name="partnumber"]').html();
|
||
var description_elt = $(row).find('[name="order.orderitems[].description"]');
|
||
var description = description_elt.val();
|
||
var longdescription_elt = $(row).find('[name="order.orderitems[].longdescription"]');
|
||
var longdescription;
|
||
|
||
if (!longdescription_elt.length) {
|
||
var data = 'action=Order/get_item_longdescription';
|
||
data += '&type=' + $('#type').val();
|
||
data += '&item_id=' + $(row).find('[name="order.orderitems[+].id"]').val();
|
||
data += '&parts_id=' + $(row).find('[name="order.orderitems[].parts_id"]').val();
|
||
$.ajax({
|
||
url: 'controller.pl',
|
||
data: data,
|
||
method: "GET",
|
||
async: false,
|
||
dataType: 'text',
|
||
success: function(val){
|
||
longdescription = val;
|
||
}
|
||
});
|
||
} else {
|
||
longdescription = longdescription_elt.val();
|
||
}
|
||
|
||
var params = { runningnumber: position,
|
||
partnumber: partnumber,
|
||
description: description,
|
||
default_longdescription: longdescription,
|
||
set_function: function(val){
|
||
longdescription_elt.remove();
|
||
$('<input type="hidden" name="order.orderitems[].longdescription">').insertAfter(description_elt).val(val);
|
||
}
|
||
};
|
||
|
||
kivi.SalesPurchase.edit_longdescription_with_params(params);
|
||
}
|
||
|
||
$(function(){
|
||
$('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
|
||
[%- IF SELF.cv == 'customer' %]
|
Auch abrufbar als: Unified diff
Auftrags-Controller: longdescription