[%- USE LxERP %]
[%- USE L %]
+[%- INCLUDE 'generic/set_longdescription.html' %]
+
<div id="ui-tabs-basic-data">
<table width="100%">
<tr valign="top">
<th class="listheading" nowrap width="3" >[%- 'position' | $T8 %] </th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
- <th class="listheading" nowrap width="15">[%- 'Partnumber' | $T8 %] </th>
- <th class="listheading" nowrap >[%- 'Description' | $T8 %] </th>
- <th class="listheading" nowrap width="5" >[%- 'Qty' | $T8 %] </th>
+ <th id="partnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:reorder_items("partnumber")'> [%- 'Partnumber' | $T8 %]</a></th>
+ <th id="description_header_id" class="listheading" nowrap ><a href='#' onClick='javascript:reorder_items("description")'>[%- 'Description' | $T8 %]</a></th>
+ <th id="qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:reorder_items("qty")'> [%- 'Qty' | $T8 %]</a></th>
<th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
<th class="listheading" nowrap width="5" >[%- 'Unit' | $T8 %] </th>
<th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
- <th class="listheading" nowrap width="15">[%- 'Price' | $T8 %] </th>
- <th class="listheading" nowrap width="5" >[%- 'Discount' | $T8 %] </th>
+ <th id="sellprice_header_id" class="listheading" nowrap width="15" ><a href='#' onClick='javascript:reorder_items("sellprice")'> [%- 'Price' | $T8 %]</a></th>
+ <th id="discount_header_id" class="listheading" nowrap width="15" ><a href='#' onClick='javascript:reorder_items("discount")'> [%- 'Discount' | $T8 %]</a></th>
<th class="listheading" nowrap width="10">[%- 'Extended' | $T8 %] </th>
</tr>
</thead>
<script type='text/javascript'>
function reload_cv_dependend_selections() {
- var data = $('#order_form').serialize();
- data += '&action=Order/customer_vendor_changed';
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/customer_vendor_changed' });
$.post("controller.pl", data, kivi.eval_json_result);
}
var oldval = $(select_elt).data('oldval');
$(select_elt).data('oldval', $(select_elt).val());
- var data = $('#order_form').serialize();
- data += '&action=Order/unit_changed';
- data += '&item_id=' + item_id_dom.val();
- data += '&old_unit=' + oldval;
- data += '&sellprice_dom_id=' + sellprice_dom.attr('id');
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/unit_changed' });
+ data.push({ name: 'item_id', value: item_id_dom.val() });
+ data.push({ name: 'old_unit', value: oldval });
+ data.push({ name: 'sellprice_dom_id', value: sellprice_dom.attr('id') });
$.post("controller.pl", data, kivi.eval_json_result);
}
if ($('#add_item_parts_id').val() == '') return;
if (!check_cv()) return;
- var data = $('#order_form').serialize();
- data += '&action=Order/add_item';
+ $('#row_table_id thead a img').remove();
+
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/add_item' });
$.post("controller.pl", data, kivi.eval_json_result);
}
function show_multi_items_dialog() {
if (!check_cv()) return;
+ $('#row_table_id thead a img').remove();
+
kivi.popup_dialog({
url: 'controller.pl?action=Order/show_multi_items_dialog',
data: { type: $('#type').val(),
var row = $(clicked).parents("tbody").first();
var item_id_dom = $(row).find('[name="orderitem_ids[+]"]');
- var data = $('#order_form').serialize();
- data += '&action=Order/price_popup';
- data += '&item_id=' + item_id_dom.val();
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/price_popup' });
+ data.push({ name: 'item_id', value: item_id_dom.val() });
$.post("controller.pl", data, kivi.eval_json_result);
}
}
function recalc_amounts_and_taxes() {
- var data = $('#order_form').serialize();
- data += '&action=Order/recalc_amounts_and_taxes';
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/recalc_amounts_and_taxes' });
$.post("controller.pl", data, kivi.eval_json_result);
}
});
}
+function reorder_items(order_by) {
+ var dir = $('#' + order_by + '_header_id a img').attr("data-sort-dir");
+ $('#row_table_id thead a img').remove();
+
+ var src;
+ if (dir == "1") {
+ dir = "0";
+ src = "image/up.png";
+ } else {
+ dir = "1";
+ src = "image/down.png";
+ };
+
+ $('#' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="[%- LxERP.t8('sort items') %]">');
+
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/reorder_items' });
+ data.push({ name: 'order_by', value: order_by });
+ data.push({ name: 'sort_dir', value: dir });
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+}
+
+function redisplay_items(data) {
+ var old_rows = $('.row_entry').detach();
+ var new_rows = [];
+ $(data).each(function(idx, elt) {
+ new_rows.push(old_rows[elt.old_pos - 1]);
+ });
+ $(new_rows).appendTo($('#row_table_id'));
+ 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 = [];
+ data.push({ name: 'action', value: 'Order/get_item_longdescription' });
+ data.push({ name: 'type', value: $('#type').val() });
+ data.push({ name: 'item_id', value: $(row).find('[name="order.orderitems[+].id"]').val() });
+ data.push({ name: 'parts_id', value: $(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);
});
$('#row_table_id').on('sortstop', function(event, ui) {
+ $('#row_table_id thead a img').remove();
renumber_positions();
});
</script>