Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7589c136

Von Tamino Steinert vor 9 Monaten hinzugefügt

  • ID 7589c13627fe3de8b397d3dae6270f566664d3d2
  • Vorgänger 0cdb369e
  • Nachfolger 976b7115

S:C:Order: Positionskonfiguration für Wied. Rech. bearbeiten können

Unterschiede anzeigen:

SL/Controller/Order.pm
use SL::DB::Order::TypeData qw(:types);
use SL::DB::DeliveryOrder::TypeData qw(:types);
use SL::DB::Reclamation::TypeData qw(:types);
use SL::DB::PeriodicInvoiceItemsConfig;
use SL::Helper::CreatePDF qw(:all);
use SL::Helper::PrintOptions;
......
$_[0]->render(\ !!$has_active_periodic_invoices, { type => 'text' });
}
sub action_show_periodic_invoice_items_config_dialog {
my ($self) = @_;
my $config = SL::DB::PeriodicInvoiceItemsConfig->new(
%{$::form->{periodic_invoice_items_config}}
);
$self->render(
'order/tabs/_edit_periodic_invoice_items_config', { layout => 0 },
CONFIG => $config,
ITEM_ID => $::form->{item_id},
);
}
sub action_update_periodic_invoice_items_config_button {
my ($self) = @_;
my $config = SL::DB::PeriodicInvoiceItemsConfig->new(
%{$::form->{periodic_invoice_items_config}}
);
my $item_id = $::form->{item_id} or die "No item id given";
my $button_text = $self->get_button_text_for_periodic_invoice_items_config($config);
$self->js->val("#periodic_invoice_items_config_button_$item_id", $button_text)->render();
}
sub get_button_text_for_periodic_invoice_items_config {
my ($self, $config) = @_;
my $button_text = t8('Periodic Invoices') . ': ';
if ($config && $config->periodicity) {
my %peridoicity_to_text = (
p => t8("same as periodicity"),
n => t8("never"),
o => t8("one time"),
m => t8("monthly"),
q => t8("every third month"),
b => t8("semiannually"),
y => t8("yearly")
);
$button_text .= $peridoicity_to_text{$config->periodicity};
$button_text .= " | ";
$button_text .= $config->start_date_as_date || "_";
$button_text .= " " . t8("to") . " ";
$button_text .= $config->end_date_as_date || "_";
if ($config->terminated) {
$button_text .= " X";
} elsif ($config->extend_automatically_by) {
$button_text .= " +" . $config->extend_automatically_by;
}
} else {
$button_text .= t8('standard');
}
return $button_text;
}
sub action_save_and_new_record {
my ($self) = @_;
my $to_type = $::form->{to_type};
......
$item->parse_custom_variable_values;
}
my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item, TYPE => $self->type);
my $row_as_html = $self->p->render(
'order/tabs/_second_row',
SELF => $self,
ITEM => $item,
ID => $item_id,
TYPE => $self->type
);
$self->js
->html('#second_row_' . $item_id, $row_as_html)
SL/DB/OrderItem.pm
__PACKAGE__->configure_acts_as_list(group_by => [qw(trans_id)]);
__PACKAGE__->before_save('_before_save_remove_empty_periodic_invoice_items_config');
sub _before_save_remove_empty_periodic_invoice_items_config {
my ($self) = @_;
if ($self->periodic_invoice_items_config
&& $self->periodic_invoice_items_config->periodicity eq '') {
$self->periodic_invoice_items_config->delete if $self->periodic_invoice_items_config->order_item_id;
$self->periodic_invoice_items_config(undef);
}
return 1;
}
sub is_price_update_available {
my $self = shift;
return $self->origprice > $self->part->sellprice;
js/kivi.Order.js
return true;
};
ns.show_periodic_invoice_items_config_dialog = function(clicked) {
if ($('#type').val() !== 'sales_order') return;
let second_row = $(clicked).parents("tbody").first();
let first_row = $(second_row).parents("tbody").first();
let data = {
type: $('#type').val(),
id: $('#id').val(),
item_id: $(first_row).find('[name="orderitem_ids[+]"]').val(),
};
for (const value_key of [
'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
'extend_automatically_by'
]) {
data[`periodic_invoice_items_config.${value_key}`] =
$(second_row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val();
}
kivi.popup_dialog({
url: 'controller.pl?action=Order/show_periodic_invoice_items_config_dialog',
data: data,
id: 'periodic_invoice_items_config_dialog',
load: kivi.reinit_widgets,
dialog: {
title: kivi.t8('Edit the configuration for periodic invoice item'),
width: 800,
height: 650
}
});
return true;
};
ns.assign_periodic_invoice_items_config = function(item_id) {
let row = $(`#item_${item_id}`).parents("tbody").first();
let dialog = $('#periodic_invoice_items_config_dialog');
for (const value_key of [
'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
'extend_automatically_by'
]) {
$(row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val(
$(dialog).find(`#periodic_invoice_items_config_${value_key}`).val()
);
}
kivi.submit_ajax_form("controller.pl", '#periodic_invoice_items_config_from',
{
action: 'Order/update_periodic_invoice_items_config_button',
type: $('#type').val(),
id: $('#id').val(),
item_id: item_id,
}
);
dialog.dialog('close');
return 1;
}
ns.delete_periodic_invoice_items_config = function(item_id) {
let row = $(`#item_${item_id}`).parents("tbody").first();
let dialog = $('#periodic_invoice_items_config_dialog');
for (const value_key of [
'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
'extend_automatically_by'
]) {
$(row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val(null);
}
let data = [];
data.push({name: 'action', value: 'Order/update_periodic_invoice_items_config_button'});
data.push({name: 'type', value: $('#type').val()});
data.push({name: 'id', value: $('#id').val()});
data.push({name: 'item_id', value: item_id});
$.post("controller.pl", data, kivi.eval_json_result);
dialog.dialog('close');
return 1;
}
ns.close_periodic_invoices_config_dialog = function() {
$('#jq_periodic_invoices_config_dialog').dialog('close');
};
templates/design40_webpages/order/tabs/_edit_periodic_invoice_items_config.html
[% USE HTML %]
[% USE LxERP %]
[% USE L %]
<h1>[% title %]</h1>
<form id="periodic_invoice_items_config_from">
<div class="buttons">
[% L.button_tag('
kivi.Order.assign_periodic_invoice_items_config("' _ ITEM_ID _ '")',
LxERP.t8('Assign'))
%]
[% L.button_tag(
'kivi.Order.delete_periodic_invoice_items_config("' _ ITEM_ID _ '")',
LxERP.t8('Delete'), class='neutral')
%]
</div>
<div class="wrapper">
<table class="tbl-horizontal">
<caption>[% title %]</caption>
<colgroup> <col class="wi-normal"><col class="wi-lightwide"> </colgroup>
<tbody>
<tr>
<th>[% LxERP.t8('Terminated') %]</th>
<td>
[% L.yes_no_tag('periodic_invoice_items_config.terminated', CONFIG.terminated) %]
</td>
</tr>
<tr>
<th>[% LxERP.t8('Periodicity') %]</th>
<td>
[% L.select_tag("periodic_invoice_items_config.periodicity", [
[ "p", LxERP.t8("same as periodicity") ],
[ "n", LxERP.t8("never") ],
[ "o", LxERP.t8("one time") ],
[ "m", LxERP.t8("monthly") ],
[ "q", LxERP.t8("every third month") ],
[ "b", LxERP.t8("semiannually") ],
[ "y", LxERP.t8("yearly") ]
],
default=CONFIG.periodicity || 'p',
) %]
</td>
</tr>
<tr>
<th>[% LxERP.t8('Start date') %]</th>
<td>[% L.date_tag("periodic_invoice_items_config.start_date_as_date", CONFIG.start_date_as_date) %]</td>
</tr>
<tr>
<th>[% LxERP.t8('End date') %]</th>
<td>[% L.date_tag("periodic_invoice_items_config.end_date_as_date", CONFIG.end_date_as_date) %]</td>
</tr>
<tr>
<th>[% LxERP.t8('Extend automatically by n months') %]</th>
<td>
[% L.input_tag("periodic_invoice_items_config.extend_automatically_by", CONFIG.extend_automatically_by, type='number') %]
</td>
</tr>
</tbody>
</table>
</div><!-- /.wrapper -->
</form>
templates/design40_webpages/order/tabs/_second_row.html
[% END %]
<b>[% 'Subtotal' | $T8 %]</b> [% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]
[% IF TYPE == "sales_order" %]
<b>[% 'Recurring billing' | $T8 %]</b>
[% L.select_tag("order.orderitems[].recurring_billing_mode", [[ 'always', LxERP.t8('always') ], [ 'once', LxERP.t8('once') ], [ 'never', LxERP.t8('never') ]], default=ITEM.recurring_billing_mode) %]
<b>
[% FOREACH value_key = [
'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
'extend_automatically_by', 'order_item_id'
] %]
[%L.hidden_tag('order.orderitems[].periodic_invoice_items_config.' _ value_key, ITEM.periodic_invoice_items_config.$value_key) %]
[% END %]
[% L.button_tag('kivi.Order.show_periodic_invoice_items_config_dialog(this)',
SELF.get_button_text_for_periodic_invoice_items_config(ITEM.periodic_invoice_items_config),
id = 'periodic_invoice_items_config_button_' _ ID,
class = 'neutral',
)
%]<b>
[% END %]
[% IF (TYPE == "sales_order_intake" || TYPE == "sales_order" || TYPE == "sales_quotation") %]
<b>[% 'Ertrag' | $T8 %]</b>
templates/webpages/order/tabs/_edit_periodic_invoice_items_config.html
[% USE HTML %]
[% USE LxERP %]
[% USE L %]
<h1>[% title %]</h1>
<form id="periodic_invoice_items_config_from">
<div class="buttons">
[% L.button_tag('
kivi.Order.assign_periodic_invoice_items_config("' _ ITEM_ID _ '")',
LxERP.t8('Assign'))
%]
[% L.button_tag(
'kivi.Order.delete_periodic_invoice_items_config("' _ ITEM_ID _ '")',
LxERP.t8('Delete'), class='neutral')
%]
</div>
<table>
<caption>[% title %]</caption>
<tbody>
<tr>
<th>[% LxERP.t8('Terminated') %]</th>
<td>
[% L.yes_no_tag('periodic_invoice_items_config.terminated', CONFIG.terminated) %]
</td>
</tr>
<tr>
<th>[% LxERP.t8('Periodicity') %]</th>
<td>
[% L.select_tag("periodic_invoice_items_config.periodicity", [
[ "p", LxERP.t8("same as periodicity") ],
[ "n", LxERP.t8("never") ],
[ "o", LxERP.t8("one time") ],
[ "m", LxERP.t8("monthly") ],
[ "q", LxERP.t8("every third month") ],
[ "b", LxERP.t8("semiannually") ],
[ "y", LxERP.t8("yearly") ]
],
default=CONFIG.periodicity || 'p',
) %]
</td>
</tr>
<tr>
<th>[% LxERP.t8('Start date') %]</th>
<td>[% L.date_tag("periodic_invoice_items_config.start_date_as_date", CONFIG.start_date_as_date) %]</td>
</tr>
<tr>
<th>[% LxERP.t8('End date') %]</th>
<td>[% L.date_tag("periodic_invoice_items_config.end_date_as_date", CONFIG.end_date_as_date) %]</td>
</tr>
<tr>
<th>[% LxERP.t8('Extend automatically by n months') %]</th>
<td>
[% L.input_tag("periodic_invoice_items_config.extend_automatically_by", CONFIG.extend_automatically_by, type='number') %]
</td>
</tr>
</tbody>
</table>
</form>
templates/webpages/order/tabs/_second_row.html
<b>[%- 'Subtotal' | $T8 %]</b>&nbsp;
[% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]&nbsp;
[%- IF TYPE == "sales_order" %]
<b>[%- 'Recurring billing' | $T8 %]</b>&nbsp;
[% L.select_tag("order.orderitems[].recurring_billing_mode", [[ 'always', LxERP.t8('always') ], [ 'once', LxERP.t8('once') ], [ 'never', LxERP.t8('never') ]], default=ITEM.recurring_billing_mode) %]&nbsp;
<b>
[% FOREACH value_key = [
'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
'extend_automatically_by', 'order_item_id'
] %]
[%L.hidden_tag('order.orderitems[].periodic_invoice_items_config.' _ value_key, ITEM.periodic_invoice_items_config.$value_key) %]
[% END %]
[% L.button_tag('kivi.Order.show_periodic_invoice_items_config_dialog(this)',
SELF.get_button_text_for_periodic_invoice_items_config(ITEM.periodic_invoice_items_config),
id = 'periodic_invoice_items_config_button_' _ ID,
class = 'neutral',
)
%]<b>
[%- END %]
[%- IF (TYPE == "sales_order_intake" || TYPE == "sales_order" || TYPE == "sales_quotation") %]
<b>[%- 'Ertrag' | $T8 %]</b>&nbsp;

Auch abrufbar als: Unified diff