item-shortcut-input.blade.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <div class="modal fade" id="modal-item-shortcut-input" aria-hidden="true" data-backdrop="static" style="z-index: 1049; overflow: auto;">
  2. <div class="modal-dialog m-auto pt-4" style="max-width: 850px;">
  3. <div class="modal-content">
  4. <div class="modal-header bg-skyblue">
  5. <h4 class="modal-title text-white" id="myModalLabel">{{ $moealSetFile['General']['Title'] }}</h4>
  6. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fas fa-times"></i></button>
  7. </div>
  8. <div class="modal-body p-2" style="background-color: #f5f5f5;">
  9. <div class="card mb-2" id="item-shortcut-input-form">
  10. <div class="card-header" id="frm">
  11. <div class="row">
  12. <div class="col-12 col-lg card-header-item">
  13. <div class="card card card-primary mb-3 mb-md-2 mb-lg-0 border-light">
  14. <div class="card-header p-0 mb-2">
  15. </div>
  16. <div class="card-body pb-0">
  17. <div class="d-flex flex-column mb-2">
  18. <label class="m-0">{{ $moealSetFile['FormVars']['Title']['SalesQty'] }}</label>
  19. <input type="number" id="sales-qty-txt" min="1" value="1" class="rounded" autocomplete="off">
  20. </div>
  21. <div class="d-flex flex-column mb-2">
  22. <label class="m-0">{{ $moealSetFile['FormVars']['Title']['BarCode'] }}</label>
  23. <div class="row">
  24. <div class="col-8 pr-0">
  25. <input type="text" id="bar-code-txt" class="rounded w-100" autocomplete="off">
  26. </div>
  27. <div class="col-4 pl-1">
  28. <button class="btn-skyblue rounded w-100 h-100">{{ $moealSetFile['FormVars']['Title']['BarCodeButton'] }}</button>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="row px-2 my-3" id="shortcut-items">
  33. @php
  34. $frequentCount = count($moealSetFile['ItemInputShortcutSetup']['FrequentItems']);
  35. $rowCount = intdiv($frequentCount, 4);
  36. if ($frequentCount % 4 !== 0) { $rowCount ++; }
  37. @endphp
  38. @foreach (collect($moealSetFile['ItemInputShortcutSetup']['FrequentItems'])->chunk($rowCount) as $chunk)
  39. <div class="col-3">
  40. <div class="row">
  41. @foreach ($chunk as $i => $item)
  42. <button class="w-100 btn-skyblue mb-1 mr-1 rounded" onclick="itemShortcutInput.add_frequent_item('{{ $i }}')">
  43. {{ $item['ButtonCation'] }}
  44. </button>
  45. @endforeach
  46. </div>
  47. </div>
  48. @endforeach
  49. </div>
  50. <div class="d-flex flex-column mb-2">
  51. <label class="m-0">{{ $moealSetFile['FormVars']['Title']['DiscountPrc'] }}</label>
  52. <div class="row">
  53. <div class="col-6 pr-0">
  54. <input type="text" id="discount-prc-txt" class="decimal rounded w-100" data-point="{{ $moealSetFile['FormVars']['Format']['DiscountPrc'] }}">
  55. </div>
  56. <div class="col-6 pl-1">
  57. <button class="btn-skyblue rounded w-100 h-100" onclick="itemShortcutInput.add_discount_prc()">
  58. {{ $moealSetFile['FormVars']['Title']['DiscountPrcButton'] }}
  59. </button>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. @once
  74. @push('js')
  75. <script>
  76. $('#modal-item-shortcut-input').on('shown.bs.modal', function () {
  77. itemShortcutInput.data_init()
  78. });
  79. (function( itemShortcutInput, $, undefined ) {
  80. itemShortcutInput.itemInputShortcutSetup = {!! json_encode($moealSetFile['ItemInputShortcutSetup']) !!};
  81. itemShortcutInput.add_frequent_item = function (index) {
  82. const sales_qty = $('#item-shortcut-input-form').find('#sales-qty-txt').val()
  83. $('#modal-item-shortcut-input').trigger('add.frequent-item', [
  84. itemShortcutInput.itemInputShortcutSetup['FrequentItems'][index]['ItemCode'],
  85. isEmpty(sales_qty) ? itemShortcutInput.itemInputShortcutSetup['FrequentItems'][index]['BasicQty'] : sales_qty
  86. ]);
  87. // $('#modal-item-shortcut-input.show').modal('hide')
  88. }
  89. itemShortcutInput.data_init = function () {
  90. input_box_reset_for('#item-shortcut-input-form')
  91. $('#item-shortcut-input-form').find('#sales-qty-txt').val(1)
  92. }
  93. itemShortcutInput.add_discount_prc = function () {
  94. if (isEmpty($('#item-shortcut-input-form').find('#discount-prc-txt').val()) || $('#item-shortcut-input-form').find('#discount-prc-txt').val() <= 0) {
  95. iziToast.error({ title: 'Error', message: @json(_e('Action failed')) });
  96. return
  97. }
  98. $('#modal-item-shortcut-input').trigger('add.discount', [
  99. $('#item-shortcut-input-form').find('#discount-prc-txt').val(),
  100. itemShortcutInput.itemInputShortcutSetup['DiscountItem']
  101. ]);
  102. $('#modal-item-shortcut-input.show').modal('hide')
  103. }
  104. }( window.itemShortcutInput = window.itemShortcutInput || {}, jQuery ));
  105. </script>
  106. @endpush
  107. @endonce