412937aa3a7cc2da7b04d442012f344f34ec248e.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php $__env->startSection('panel_content'); ?>
  2. <section class="gry-bg py-4 profile">
  3. <div class="container-fluid">
  4. <form class="" action="" method="POST" enctype="multipart/form-data">
  5. <?php echo csrf_field(); ?>
  6. <div class="row gutters-10">
  7. <div class="col-md">
  8. <div class="row gutters-5 mb-3">
  9. <div class="col-md-6 mb-2 mb-md-0">
  10. <div class="form-group mb-0">
  11. <input class="form-control form-control-lg" type="text" name="keyword"
  12. placeholder="Search by Product Name/Barcode" onkeyup="filterProducts()">
  13. </div>
  14. </div>
  15. <div class="col-md-3 col-6">
  16. <select name="poscategory" class="form-control form-control-lg aiz-selectpicker"
  17. data-live-search="true" onchange="filterProducts()">
  18. <option value=""><?php echo e(translate('All Categories')); ?></option>
  19. <?php $__currentLoopData = \App\Models\Category::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
  20. <option
  21. value="category-<?php echo e($category->id); ?>"><?php echo e($category->getTranslation('name')); ?></option>
  22. <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  23. </select>
  24. </div>
  25. <div class="col-md-3 col-6">
  26. <select name="brand" class="form-control form-control-lg aiz-selectpicker"
  27. data-live-search="true" onchange="filterProducts()">
  28. <option value=""><?php echo e(translate('All Brands')); ?></option>
  29. <?php $__currentLoopData = \App\Models\Brand::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $brand): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
  30. <option value="<?php echo e($brand->id); ?>"><?php echo e($brand->getTranslation('name')); ?></option>
  31. <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  32. </select>
  33. </div>
  34. </div>
  35. <div class="aiz-pos-product-list c-scrollbar-light">
  36. <div class="d-flex flex-wrap justify-content-center" id="product-list">
  37. </div>
  38. <div id="load-more" class="text-center">
  39. <div class="fs-14 d-inline-block fw-600 btn btn-soft-primary c-pointer"
  40. onclick="loadMoreProduct()"><?php echo e(translate('Loading..')); ?></div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="col-md-auto w-md-350px w-lg-400px w-xl-500px">
  45. <div class="card mb-3">
  46. <div class="card-body">
  47. <div class="">
  48. <div class="aiz-pos-cart-list mb-4 mt-3 c-scrollbar-light">
  49. <ul class="list-group list-group-flush" id="product-selection">
  50. </ul>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="pos-footer mar-btm">
  56. <div class="d-flex flex-column flex-md-row justify-content-between">
  57. <div class="d-flex">
  58. <button id="add-all-btn" type="button" class="btn btn-outline-info btn-block"
  59. onclick="addPost(1)">
  60. <span class="spinner-border spinner-border-sm d-none" role="status"
  61. aria-hidden="true"></span>
  62. <?php echo e(translate('Add all to my product')); ?>
  63. </button>
  64. </div>
  65. <div class="my-2 my-md-0">
  66. <button id="add-selection-btn" type="button" class="btn btn-primary btn-block"
  67. onclick="addPost(0)">
  68. <span class="spinner-border spinner-border-sm d-none" role="status"
  69. aria-hidden="true"></span>
  70. <?php echo e(translate('Add to my product')); ?>
  71. </button>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </form>
  78. </div>
  79. </section>
  80. <?php $__env->stopSection(); ?>
  81. <?php $__env->startSection('script'); ?>
  82. <script type="text/javascript">
  83. var products = null;
  84. $(document).ready(function () {
  85. // $('body').addClass('side-menu-closed');
  86. $('#product-list').on('click', '.add-plus:not(.c-not-allowed)', function () {
  87. var product_id = $(this).data('product-id');
  88. var product_name = $(this).data('product-name');
  89. var product_price = $(this).data('product-price');
  90. updateSelection(product_id, product_name, product_price);
  91. });
  92. filterProducts();
  93. });
  94. function updateSelection(product_id, product_name, product_price) {
  95. let already_selected_ids = getSelectedIds()
  96. let container = $('#product-selection');
  97. if (!already_selected_ids.includes(product_id)) {
  98. container.append(`<li class="list-group-item py-3 pl-2" data-product-id="${product_id}">
  99. <div class="row gutters-5 align-items-center">
  100. <div class="col">
  101. <div class="text-truncate-2">${product_name}</div>
  102. <span
  103. class="span badge badge-inline fs-12 badge-soft-secondary"></span>
  104. </div>
  105. <div class="col-auto">
  106. <div class="fs-15 fw-600">${product_price}</div>
  107. </div>
  108. <div class="col-auto">
  109. <button type="button"
  110. class="btn btn-circle btn-icon btn-sm btn-soft-danger ml-2 mr-0"
  111. onclick="removeSelected(${product_id})">
  112. <i class="las la-trash-alt"></i>
  113. </button>
  114. </div>
  115. </div>
  116. </li>`)
  117. } else {
  118. container.find("li[data-product-id='" + product_id + "']")
  119. .clearQueue().stop()
  120. .fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100)
  121. }
  122. }
  123. function getSelectedIds() {
  124. let already_selected_ids = []
  125. $('#product-selection').find('li').each(function () {
  126. already_selected_ids.push($(this).data('product-id'))
  127. })
  128. return already_selected_ids
  129. }
  130. function removeSelected(product_id) {
  131. $('#product-selection').find("li[data-product-id='" + product_id + "']").remove()
  132. }
  133. function filterProducts() {
  134. var keyword = $('input[name=keyword]').val();
  135. var category = $('select[name=poscategory]').val();
  136. var brand = $('select[name=brand]').val();
  137. $.get('<?php echo e(route('seller.product_storehouse.search')); ?>', {
  138. keyword: keyword,
  139. category: category,
  140. brand: brand
  141. }, function (data) {
  142. products = data;
  143. $('#product-list').html(null);
  144. setProductList(data);
  145. });
  146. }
  147. function loadMoreProduct() {
  148. if (products != null && products.links.next != null) {
  149. $('#load-more').find('.btn').html('<?php echo e(translate('Loading..')); ?>');
  150. $.get(products.links.next, {}, function (data) {
  151. products = data;
  152. setProductList(data);
  153. });
  154. }
  155. }
  156. function setProductList(data) {
  157. for (var i = 0; i < data.data.length; i++) {
  158. $('#product-list').append(
  159. `<div class="w-140px w-xl-180px w-xxl-210px mx-2">
  160. <div class="card bg-white c-pointer product-card hov-container">
  161. <div class="position-relative">
  162. <span class="absolute-top-left mt-1 ml-1 mr-0">
  163. ${data.data[i].qty > 0
  164. ? `<span class="badge badge-inline badge-success fs-13"><?php echo e(translate('In stock')); ?>`
  165. : `<span class="badge badge-inline badge-danger fs-13"><?php echo e(translate('Out of stock')); ?>`}
  166. : ${data.data[i].qty}</span>
  167. </span>
  168. ${data.data[i].variant != null
  169. ? `<span class="badge badge-inline badge-warning absolute-bottom-left mb-1 ml-1 mr-0 fs-13 text-truncate">${data.data[i].variant}</span>`
  170. : ''}
  171. <img src="${data.data[i].thumbnail_image}" class="card-img-top img-fit h-120px h-xl-180px h-xxl-210px mw-100 mx-auto" >
  172. </div>
  173. <div class="card-body p-2 p-xl-3">
  174. <div class="text-truncate fw-600 fs-14 mb-2">${data.data[i].name}</div>
  175. <div class="">
  176. ${data.data[i].price != data.data[i].base_price
  177. ? `<del class="mr-2 ml-0">${data.data[i].base_price}</del><span>${data.data[i].price}</span>`
  178. : `<span>${data.data[i].base_price}</span>`
  179. }
  180. </div>
  181. </div>
  182. <div class="add-plus absolute-full rounded overflow-hidden hov-box ${data.data[i].qty <= 0 ? 'c-not-allowed' : ''}" data-product-id="${data.data[i].id}" data-product-name="${data.data[i].name}" data-product-price="${data.data[i].price != data.data[i].base_price ? data.data[i].price : data.data[i].base_price}">
  183. <div class="absolute-full bg-dark opacity-50">
  184. </div>
  185. <i class="las la-plus absolute-center la-6x text-white"></i>
  186. </div>
  187. </div>
  188. </div>`
  189. );
  190. }
  191. if (data.links.next != null) {
  192. $('#load-more').find('.btn').html('<?php echo e(translate('Load More.')); ?>');
  193. } else {
  194. $('#load-more').find('.btn').html('<?php echo e(translate('Nothing more found.')); ?>');
  195. }
  196. }
  197. function addPost(all) {
  198. let addAllBtn = $('#add-all-btn')
  199. let addSelectionBtn = $('#add-selection-btn')
  200. if (all == 0) {
  201. let selected_ids = getSelectedIds()
  202. if (selected_ids.length) {
  203. addAllBtn.prop('disabled', true);
  204. addSelectionBtn.prop('disabled', true);
  205. addSelectionBtn.find('span.spinner-border').removeClass('d-none');
  206. doPost(0, selected_ids)
  207. }
  208. } else {
  209. addAllBtn.prop('disabled', true);
  210. addSelectionBtn.prop('disabled', true);
  211. addAllBtn.find('span.spinner-border').removeClass('d-none');
  212. doPost(1, [])
  213. }
  214. }
  215. function doPost(all, productIds) {
  216. let addAllBtn = $('#add-all-btn')
  217. let addSelectionBtn = $('#add-selection-btn')
  218. $.post('<?php echo e(route('seller.product_storehouse.add')); ?>', {
  219. _token: AIZ.data.csrf,
  220. all: all,
  221. product_ids: productIds
  222. }, function (data) {
  223. if (data.success == 1) {
  224. AIZ.plugins.notify('success', data.message ? data.message : '<?php echo e(translate('Product has been updated successfully')); ?>');
  225. location.reload();
  226. } else {
  227. AIZ.plugins.notify('danger', data.message ? data.message : '<?php echo e(translate('Something went wrong')); ?>');
  228. }
  229. }).fail(function () {
  230. AIZ.plugins.notify('danger', '<?php echo e(translate('Something went wrong')); ?>');
  231. }).always(function () {
  232. addAllBtn.prop('disabled', false);
  233. addSelectionBtn.prop('disabled', false);
  234. addAllBtn.find('span.spinner-border').addClass('d-none');
  235. addSelectionBtn.find('span.spinner-border').addClass('d-none');
  236. });
  237. }
  238. </script>
  239. <?php $__env->stopSection(); ?>
  240. <?php echo $__env->make('seller.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/shaoguo/Desktop/公司资料/小梦/商城/ebayShop/resources/views/seller/product_storehouse/index.blade.php ENDPATH**/ ?>