items.phtml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. ?>
  8. <section class="admin__page-section">
  9. <div class="admin__page-section-title">
  10. <span class="title"><?= /* @escapeNotVerified */ __('Items to Ship') ?></span>
  11. </div>
  12. <div class="admin__table-wrapper">
  13. <table class="data-table admin__table-primary order-shipment-table">
  14. <thead>
  15. <tr class="headings">
  16. <th class="col-product"><span><?= /* @escapeNotVerified */ __('Product') ?></span></th>
  17. <th class="col-ordered-qty"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></th>
  18. <th class="col-qty<?php if ($block->isShipmentRegular()): ?> last<?php endif; ?>">
  19. <span><?= /* @escapeNotVerified */ __('Qty to Ship') ?></span>
  20. </th>
  21. <?php if (!$block->canShipPartiallyItem()): ?>
  22. <th class="col-ship last"><span><?= /* @escapeNotVerified */ __('Ship') ?></span></th>
  23. <?php endif; ?>
  24. </tr>
  25. </thead>
  26. <?php $_items = $block->getShipment()->getAllItems() ?>
  27. <?php $_i = 0; foreach ($_items as $_item): if ($_item->getOrderItem()->getParentItem()): continue; endif; $_i++ ?>
  28. <tbody class="<?= /* @escapeNotVerified */ $_i%2 ? 'odd' : 'even' ?>">
  29. <?= $block->getItemHtml($_item) ?>
  30. <?= $block->getItemExtraInfoHtml($_item->getOrderItem()) ?>
  31. </tbody>
  32. <?php endforeach; ?>
  33. </table>
  34. </div>
  35. </section>
  36. <section class="admin__page-section">
  37. <div class="admin__page-section-title">
  38. <span class="title"><?= /* @escapeNotVerified */ __('Shipment Total') ?></span>
  39. </div>
  40. <div class="admin__page-section-content order-comments-history">
  41. <div class="admin__page-section-item">
  42. <div class="admin__page-section-item-title">
  43. <span class="title"><?= /* @escapeNotVerified */ __('Shipment Comments') ?></span>
  44. </div>
  45. <div class="admin__page-section-item-content">
  46. <div id="order-history_form" class="admin__field">
  47. <label class="admin__field-label"
  48. for="shipment_comment_text">
  49. <span><?= /* @escapeNotVerified */ __('Comment Text') ?></span></label>
  50. <div class="admin__field-control">
  51. <textarea id="shipment_comment_text"
  52. class="admin__control-textarea"
  53. name="shipment[comment_text]"
  54. rows="3"
  55. cols="5"><?= /* @escapeNotVerified */ $block->getShipment()->getCommentText() ?></textarea>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="admin__page-section-item order-totals order-totals-actions">
  62. <div class="admin__page-section-item-title">
  63. <span class="title"><?= /* @escapeNotVerified */ __('Shipment Options') ?></span>
  64. </div>
  65. <div class="admin__page-section-item-content">
  66. <?php if ($block->canCreateShippingLabel()): ?>
  67. <div class="field choice admin__field admin__field-option field-create">
  68. <input id="create_shipping_label"
  69. class="admin__control-checkbox"
  70. name="shipment[create_shipping_label]"
  71. value="1"
  72. type="checkbox"
  73. onclick="toggleCreateLabelCheckbox();"/>
  74. <label class="admin__field-label"
  75. for="create_shipping_label">
  76. <span><?= /* @escapeNotVerified */ __('Create Shipping Label') ?></span></label>
  77. </div>
  78. <?php endif ?>
  79. <div class="field choice admin__field admin__field-option field-append">
  80. <input id="notify_customer"
  81. class="admin__control-checkbox"
  82. name="shipment[comment_customer_notify]"
  83. value="1"
  84. type="checkbox"/>
  85. <label class="admin__field-label"
  86. for="notify_customer">
  87. <span><?= /* @escapeNotVerified */ __('Append Comments') ?></span></label>
  88. </div>
  89. <?php if ($block->canSendShipmentEmail()): ?>
  90. <div class="field choice admin__field admin__field-option field-email">
  91. <input id="send_email"
  92. class="admin__control-checkbox"
  93. name="shipment[send_email]"
  94. value="1"
  95. type="checkbox"/>
  96. <label class="admin__field-label"
  97. for="send_email">
  98. <span><?= /* @escapeNotVerified */ __('Email Copy of Shipment') ?></span></label>
  99. </div>
  100. <?php endif; ?>
  101. <?= $block->getChildHtml('submit_before') ?>
  102. <div class="order-history-comments-actions actions">
  103. <?= $block->getChildHtml('submit_button') ?>
  104. <?= $block->getChildHtml('submit_after') ?>
  105. </div>
  106. </div>
  107. </div>
  108. </section>
  109. <script>
  110. require([
  111. "jquery",
  112. "Magento_Ui/js/modal/alert",
  113. "prototype"
  114. ], function(jQuery, alert){
  115. //<![CDATA[
  116. var sendEmailCheckbox = $('send_email');
  117. if (sendEmailCheckbox) {
  118. var notifyCustomerCheckbox = $('notify_customer');
  119. var shipmentCommentText = $('shipment_comment_text');
  120. Event.observe(sendEmailCheckbox, 'change', bindSendEmail);
  121. bindSendEmail();
  122. }
  123. function bindSendEmail() {
  124. if (sendEmailCheckbox.checked == true) {
  125. notifyCustomerCheckbox.disabled = false;
  126. }
  127. else {
  128. notifyCustomerCheckbox.disabled = true;
  129. }
  130. }
  131. window.toggleCreateLabelCheckbox = function() {
  132. var checkbox = $('create_shipping_label');
  133. var submitButton = checkbox.up('.order-totals').select('.submit-button span')[0];
  134. if (checkbox.checked) {
  135. submitButton.innerText += '...';
  136. } else {
  137. submitButton.innerText = submitButton.innerText.replace(/\.\.\.$/, '');
  138. }
  139. }
  140. window.submitShipment = function(btn) {
  141. if (!validQtyItems()) {
  142. alert({
  143. content: '<?= /* @escapeNotVerified */ __('Invalid value(s) for Qty to Ship') ?>'
  144. });
  145. return;
  146. }
  147. var checkbox = $(btn).up('.order-totals').select('#create_shipping_label')[0];
  148. if (checkbox && checkbox.checked) {
  149. packaging.showWindow();
  150. } else {
  151. disableElements('submit-button');
  152. // Temporary solution will be replaced after refactoring order functionality
  153. jQuery('#edit_form').on('invalid-form.validate', function() {
  154. enableElements('submit-button');
  155. jQuery('#edit_form').off('invalid-form.validate');
  156. });
  157. jQuery('#edit_form').triggerHandler('save');
  158. }
  159. }
  160. window.validQtyItems = function() {
  161. var valid = true;
  162. $$('.qty-item').each(function(item) {
  163. var val = parseFloat(item.value);
  164. if (isNaN(val) || val < 0) {
  165. valid = false;
  166. }
  167. });
  168. return valid;
  169. }
  170. window.bindSendEmail = bindSendEmail;
  171. window.shipmentCommentText = shipmentCommentText;
  172. window.notifyCustomerCheckbox = notifyCustomerCheckbox;
  173. window.sendEmailCheckbox = sendEmailCheckbox;
  174. //]]>
  175. });
  176. </script>