'name' => 'retail_price',
'title' => 'Розничная цена, руб',
'type' => BaseColumn::TYPE_TEXT_INPUT,
- 'options' => ['type' => 'number', 'step' => 0.01],
+ 'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
'value' => function($data) {
return $data['retail_price'] ?? '';
},
'name' => 'self_cost',
'title' => 'Себестоимость, руб',
'type' => BaseColumn::TYPE_TEXT_INPUT,
- 'options' => ['type' => 'number', 'step' => 0.01],
+ 'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
'value' => function($data) {
return $data['self_cost'] ?? '';
},
'name' => 'remains_summ',
'title' => 'Сумма остатков (недостача или излишек), руб',
'type' => BaseColumn::TYPE_TEXT_INPUT,
- 'options' => ['type' => 'number', 'step' => 0.01],
+ 'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
'value' => function($data) {
return $data['remains_summ'] ?? '';
},
'name' => 'fact_and_1c_diff',
'title' => 'Разница факт и по программе 1с, шт',
'type' => BaseColumn::TYPE_TEXT_INPUT,
- 'options' => ['type' => 'number', 'step' => 0.01],
+ 'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
'value' => function($data) {
return $data['fact_and_1c_diff'] ?? '';
},
'name' => 'remains_1c',
'title' => 'Остатки по 1с, шт',
'type' => BaseColumn::TYPE_TEXT_INPUT,
- 'options' => ['type' => 'number', 'step' => 0.01],
+ 'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
'value' => function($data) {
return $data['remains_1c'] ?? '';
},
const param24 = $('meta[name=csrf-param]').attr('content');
const token24 = $('meta[name=csrf-token]').attr('content');
-$(document).ready(() => {
- $('.multiple-input').on('afterAddRow', function(e, row, currentIndex) {
- var store = $('#shifttransfer-store_guid');
- var groupLabel = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-group_label');
- var productGuid = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-product_guid');
- var retailPrice = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-retail_price');
- var selfCost = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-self_cost');
- var remains1c = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_1c');
- var remains_summ = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_summ');
- var remains_count = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_count');
- var fact_and_1c_diff = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-fact_and_1c_diff');
+function setMultipleInputHandlers(currentIndex, row) {
+ const store = $('#shifttransfer-store_guid');
+ const groupLabel = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-group_label');
+ const productGuid = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-product_guid');
+ const retailPrice = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-retail_price');
+ const selfCost = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-self_cost');
+ const remains1c = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_1c');
+ const remains_summ = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_summ');
+ const remains_count = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_count');
+ const fact_and_1c_diff = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-fact_and_1c_diff');
- function onChangeTarget() {
- fact_and_1c_diff.val(remains_count.val() - remains1c.val());
- remains_summ.val(remains_count.val() * retailPrice.val())
- }
+ function onChangeTarget() {
+ fact_and_1c_diff.val(remains_count.val() - remains1c.val());
+ remains_summ.val(remains_count.val() * retailPrice.val())
+ }
- groupLabel.on('change', (e) => {
- $.ajax({
- type: 'POST',
- url: '/shift-transfer/get-products-by-group-label',
- data: { groupLabel: e.target.value, [param24]: token24 },
- dataType: 'json',
- success: (data) => {
- productGuid.empty();
- $.each(data, (guid, name) => {
- var option = document.createElement('option');
- option.text = name;
- option.value = guid;
- productGuid.append(option);
- })
- }
- });
+ groupLabel.on('change', (e) => {
+ $.ajax({
+ type: 'POST',
+ url: '/shift-transfer/get-products-by-group-label',
+ data: { groupLabel: e.target.value, [param24]: token24 },
+ dataType: 'json',
+ success: (data) => {
+ productGuid.empty();
+ $.each(data, (guid, name) => {
+ const option = document.createElement('option');
+ option.text = name;
+ option.value = guid;
+ productGuid.append(option);
+ })
+ }
});
- productGuid.on('change', (e) => {
- $.ajax({
- type: 'POST',
- url: '/shift-transfer/get-product-price-self-cost-and-remains',
- data: { productGuid: e.target.value, storeGuid: store.val(), [param24]: token24 },
- dataType: 'json',
- success: (data) => {
- if (data.price) { retailPrice.val(data.price); }
- if (data.selfCost) { selfCost.val(data.selfCost); }
- if (data.quantity) { remains1c.val(data.quantity); }
- }
- });
+ });
+
+ productGuid.on('change', (e) => {
+ $.ajax({
+ type: 'POST',
+ url: '/shift-transfer/get-product-price-self-cost-and-remains',
+ data: { productGuid: e.target.value, storeGuid: store.val(), [param24]: token24 },
+ dataType: 'json',
+ success: (data) => {
+ if (data.price) { retailPrice.val(data.price); }
+ if (data.selfCost) { selfCost.val(data.selfCost); }
+ if (data.quantity) { remains1c.val(data.quantity); }
+ }
});
- remains_count.on('change', onChangeTarget);
+ });
+ remains_count.on('change', onChangeTarget);
+}
+
+
+$(document).ready(() => {
+ $('.multiple-input').on('afterInit', function(){
+ const rows = $('.multiple-input-list__item');
+ for (let currentIndex = 0; currentIndex < rows.length; currentIndex++) {
+ setMultipleInputHandlers(currentIndex, rows[currentIndex]);
+ }
+ }).on('afterAddRow', function(e, row, currentIndex) {
+ setMultipleInputHandlers(currentIndex, row);
});
});