|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 | //phpcs:disable Squiz.PHP.NonExecutableCode.Unreachable
|
7 |
| -/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ |
| 7 | +/** |
| 8 | + * @var \Magento\Shipping\Block\Adminhtml\Order\Packaging $block |
| 9 | + * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer |
| 10 | + */ |
8 | 11 | ?>
|
9 | 12 | <div class="grid">
|
10 | 13 | <?php $randomId = rand(); ?>
|
11 | 14 | <div class="admin__table-wrapper">
|
12 |
| - <table class="data-grid"> |
| 15 | + <table id="packaging-data-grid-<?= /* @noEscape */ $randomId ?>" class="data-grid"> |
13 | 16 | <thead>
|
14 |
| - <tr> |
15 |
| - <th class="data-grid-checkbox-cell"> |
16 |
| - <label class="data-grid-checkbox-cell-inner"> |
17 |
| - <input type="checkbox" |
18 |
| - id="select-items-<?= /* @noEscape */ $randomId ?>" |
19 |
| - class="checkbox admin__control-checkbox" |
20 |
| - title="<?= $block->escapeHtmlAttr(__('Select All')) ?>"> |
21 |
| - <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( |
22 |
| - 'onchange', |
23 |
| - 'packaging.checkAllItems(this);', |
24 |
| - 'input#select-items-' . /* @noEscape */ $randomId |
25 |
| - ) ?> |
26 |
| - <label for="select-items-<?= /* @noEscape */ $randomId ?>"></label> |
27 |
| - </label> |
28 |
| - </th> |
29 |
| - <th class="data-grid-th"><?= $block->escapeHtml(__('Product Name')) ?></th> |
30 |
| - <th class="data-grid-th"><?= $block->escapeHtml(__('Weight')) ?></th> |
31 |
| - <th class="data-grid-th custom-value"> |
32 |
| - <?= $block->escapeHtml(__('Customs Value')) ?> |
33 |
| - </th> |
34 |
| - <?php if (!$block->displayCustomsValue()): ?> |
35 |
| - <?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display: none;', 'th.custom-value') ?> |
36 |
| - <?php endif ?> |
37 |
| - <th class="data-grid-th"><?= $block->escapeHtml(__('Qty Ordered')) ?></th> |
38 |
| - <th class="data-grid-th"><?= $block->escapeHtml(__('Qty')) ?></th> |
39 |
| - </tr> |
| 17 | + <tr> |
| 18 | + <th class="data-grid-checkbox-cell"> |
| 19 | + <label class="data-grid-checkbox-cell-inner"> |
| 20 | + <input type="checkbox" |
| 21 | + id="select-items-<?= /* @noEscape */ $randomId ?>" |
| 22 | + class="checkbox admin__control-checkbox" |
| 23 | + title="<?= $block->escapeHtmlAttr(__('Select All')) ?>"> |
| 24 | + <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( |
| 25 | + 'onchange', |
| 26 | + 'packaging.checkAllItems(this);', |
| 27 | + 'input#select-items-' . /* @noEscape */ $randomId |
| 28 | + ) ?> |
| 29 | + <label for="select-items-<?= /* @noEscape */ $randomId ?>"></label> |
| 30 | + </label> |
| 31 | + </th> |
| 32 | + <th class="data-grid-th"><?= $block->escapeHtml(__('Product Name')) ?></th> |
| 33 | + <th class="data-grid-th"><?= $block->escapeHtml(__('Weight')) ?></th> |
| 34 | + <th class="data-grid-th custom-value"> |
| 35 | + <?= $block->escapeHtml(__('Customs Value')) ?> |
| 36 | + </th> |
| 37 | + <?php if (!$block->displayCustomsValue()): ?> |
| 38 | + <?= /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 39 | + 'display:none', |
| 40 | + '#packaging-data-grid-' . $randomId . ' th.custom-value' |
| 41 | + ) ?> |
| 42 | + <?php endif ?> |
| 43 | + <th class="data-grid-th"><?= $block->escapeHtml(__('Qty Ordered')) ?></th> |
| 44 | + <th class="data-grid-th"><?= $block->escapeHtml(__('Qty')) ?></th> |
| 45 | + </tr> |
40 | 46 | </thead>
|
41 | 47 | <tbody>
|
42 |
| - <?php $i=0; ?> |
| 48 | + <?php $i = 0; ?> |
43 | 49 | <?php foreach ($block->getCollection() as $item): ?>
|
44 | 50 | <?php
|
45 | 51 | $_order = $block->getShipment()->getOrder();
|
|
54 | 60 | <?php endif; ?>
|
55 | 61 | <tr class="data-grid-controls-row data-row <?= ($i++ % 2 != 0) ? '_odd-row' : '' ?>">
|
56 | 62 | <td class="data-grid-checkbox-cell">
|
57 |
| - <?php $id = $item->getId() ? $item->getId() : $item->getOrderItemId(); ?> |
| 63 | + <?php $id = $item->getId() ?? $item->getOrderItemId(); ?> |
58 | 64 | <label class="data-grid-checkbox-cell-inner">
|
59 | 65 | <input type="checkbox"
|
60 | 66 | name=""
|
61 | 67 | id="select-item-<?= /* @noEscape */ $randomId . '-' . $id ?>"
|
62 |
| - value="<?= (int) $id ?>" |
| 68 | + value="<?= (int)$id ?>" |
63 | 69 | class="checkbox admin__control-checkbox">
|
64 | 70 | <label for="select-item-<?= /* @noEscape */ $randomId . '-' . $id ?>"></label>
|
65 | 71 | </label>
|
|
78 | 84 | }
|
79 | 85 |
|
80 | 86 | ?>
|
81 |
| - <td class="custom-value"> |
| 87 | + <td id="custom-value-<?= /* @noEscape */ $randomId . '-' . $id ?>" class="custom-value"> |
82 | 88 | <input type="text"
|
83 | 89 | name="customs_value"
|
84 | 90 | class="input-text admin__control-text <?= /* @noEscape */ $customsValueValidation ?>"
|
85 | 91 | value="<?= $block->escapeHtmlAttr($block->formatPrice($item->getPrice())) ?>"
|
86 | 92 | size="10">
|
87 | 93 | </td>
|
88 |
| - <?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display: none;', 'td.custom-value') ?> |
89 |
| - <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( |
90 |
| - 'onblur', |
91 |
| - 'packaging.recalcContainerWeightAndCustomsValue(this);', |
92 |
| - 'td.custom-value' |
93 |
| - ) ?> |
| 94 | + <?php if (!$block->displayCustomsValue()): ?> |
| 95 | + <?= /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 96 | + 'display:none', |
| 97 | + 'td#custom-value-' . $randomId . '-' . $id |
| 98 | + ) ?> |
| 99 | + <?php endif ?> |
94 | 100 | <td>
|
95 |
| - <?= /* @noEscape */ $item->getOrderItem()->getQtyOrdered()*1 ?> |
| 101 | + <?= /* @noEscape */ $item->getOrderItem()->getQtyOrdered() * 1 ?> |
96 | 102 | </td>
|
97 | 103 | <td>
|
98 | 104 | <input type="hidden" name="price" value="<?= $block->escapeHtml($item->getPrice()) ?>">
|
99 | 105 | <input type="text"
|
100 | 106 | name="qty"
|
101 |
| - value="<?= /* @noEscape */ $item->getQty()*1 ?>" |
| 107 | + value="<?= /* @noEscape */ $item->getQty() * 1 ?>" |
102 | 108 | class="input-text admin__control-text qty
|
103 | 109 | <?php if ($item->getOrderItem()->getIsQtyDecimal()): ?>
|
104 | 110 | qty-decimal
|
105 | 111 | <?php endif ?>">
|
106 | 112 | <button type="button"
|
107 |
| - id="packaging-delete-item-<?= /* @noEscape */ $item->getId() ?>" |
| 113 | + id="packaging-delete-item-<?= /* @noEscape */ $randomId . '-' . $id ?>" |
108 | 114 | class="action-delete"
|
109 | 115 | data-action="package-delete-item">
|
110 | 116 | <span><?= $block->escapeHtml(__('Delete')) ?></span>
|
111 | 117 | </button>
|
112 |
| - <?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display:none', 'button.action-delete') ?> |
113 |
| - <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( |
114 |
| - 'onclick', |
115 |
| - 'packaging.deleteItem(this);', |
116 |
| - 'button#packaging-delete-item-' . $item->getId() |
| 118 | + <?= /* @noEscape */ $secureRenderer->renderStyleAsTag( |
| 119 | + 'display:none', |
| 120 | + 'button#packaging-delete-item-' . $randomId . '-' . $id |
117 | 121 | ) ?>
|
118 | 122 | </td>
|
119 | 123 | </tr>
|
120 | 124 | <?php endforeach; ?>
|
121 | 125 | </tbody>
|
122 | 126 | </table>
|
| 127 | + <?php $scriptString = <<<script |
| 128 | + require(['jquery'], function ($) { |
| 129 | + $("#packaging-data-grid-{$randomId}").on('blur', 'td.custom-value input', |
| 130 | + function(){packaging.recalcContainerWeightAndCustomsValue(this)}); |
| 131 | + $("#packaging-data-grid-{$randomId}").on('click', 'button[data-action="package-delete-item"]', |
| 132 | + function(){packaging.deleteItem(this)}); |
| 133 | + }); |
| 134 | +script; |
| 135 | + ?> |
| 136 | + <?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?> |
123 | 137 | </div>
|
124 | 138 | </div>
|
0 commit comments