<?php $__env->startSection('title','قائمة المنتجات التى نفذت'); ?>
<?php $__env->startSection('content'); ?>
<div class="app-content content ">
    <div class="content-overlay"></div>
    <div class="header-navbar-shadow"></div>
    <div class="content-wrapper container-xxl p-0">
      <div class="content-header row">
      </div>
  <div class="content-body">
  <!-- Dashboard Ecommerce Starts -->
      <section id="dashboard-ecommerce">
      <div class="content-header row">
        <div class="content-header-left col-md-9 col-12 mb-2">
          <div class="row breadcrumbs-top">
            <div class="col-12">
              <h2 class="content-header-title float-start mb-0">منتجات نفذت</h2>
              <div class="breadcrumb-wrapper">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.home')); ?>">لوحة التحكم</a>
                  </li>
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.products.index')); ?>">المنجات</a>
                  </li>
                  <li class="breadcrumb-item active">منتجات نفذت
                  </li>
                </ol>
              </div>
            </div>
          </div>
        </div>
        <div class="content-header-right text-md-end col-md-3 col-12 d-md-block d-none">
          <div class="mb-1 breadcrumb-right">
          
            <div class="dropdown">
                <button class="btn-icon btn btn-primary btn-round btn-sm dropdown-toggle waves-effect waves-float waves-light" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i data-feather='chevrons-down'></i></button>
                <div class="dropdown-menu dropdown-menu-end">
                    <a class="dropdown-item" href="<?php echo e(route('client.products.index')); ?>"><span class="align-middle">المنجات المتوفرة </span> <i data-feather='box'></i></a>
                    <a class="dropdown-item" href="<?php echo e(route('client.products.limited')); ?>"><span class="align-middle">منتجات محدودة</span> <i data-feather='archive'></i></a>
                    <a class="dropdown-item" href="<?php echo e(route('client.services.index')); ?>"><span class="align-middle">الخدمات</span> <i data-feather='aperture'></i></a>
                    <a class="dropdown-item" href="<?php echo e(route('client.products.print')); ?>"><span class="align-middle">طباعة المنتجات</span> <i data-feather='printer'></i></a>

                </div>
              </div>
        </div>
      </div>
      <div class="col-xl-12 col-md-12 col-12">
        <div class="card card-statistics">
      <div class="card-body statistics-body">
        <div class="row">
                    <div class="table-responsive">
                        <table id="example2" class="datatables-basic table dataTable no-footer dtr-column collapsed">
                          <thead>
                          <tr>
                              <th>تحكم</th>
                              <th>الكود العالمى</th>
                              <th>المخزن</th>
                              <th>الفئة</th>
                              <th>الاسم</th>
                              <th>جملة</th>
                              <th>قطاعى</th>
                              <th>تكلفة</th>
                              <th>رصيد مخزون</th>

                          </tr>
                          </thead>
                          <tbody>
                              <?php
                              $i=0;
                          ?>
                          <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <tr id="id-<?php echo e($product->id); ?>">
                                  <td >
                                      <a class="pe-1 dropdown-toggle -arrow text-primary" data-bs-toggle="dropdown">
                                        <i data-feather='more-vertical'style="width: 20;height: 20;"></i>
                                      </a>
                                      <div class="dropdown-menu dropdown-menu-end">
                                          
                                          <a href="<?php echo e(route('client.products.edit', $product->id)); ?>" class="dropdown-item"><b> تعديل <i data-feather='edit'></b></i></a>
                                          <a onclick="deleteRow(<?php echo e($product->id); ?>)" class="dropdown-item"><b> حذف <i data-feather='trash-2'></b></i></a>
                                          </div> 
                                  </td>
                                  <td><?php echo e($product->code_universal); ?></td>
                                  <td><?php echo e($product->store->store_name); ?></td>
                                  <td><?php echo e($product->category->category_name); ?></td>
                                  <td><?php echo e($product->product_name); ?></td>
                                  <td><?php echo e(number_format( $product->wholesale_price  )); ?></td>
                                  <td><?php echo e(number_format( $product->sector_price  )); ?></td>
                                  <td><?php echo e(number_format( $product->purchasing_price  )); ?></td>
                                  <td><?php echo e(number_format( $product->first_balance  )); ?>

                                      <?php if(!empty($product->unit_id)): ?>
                                          <?php echo e($product->unit->unit_name); ?>

                                      <?php endif; ?>
                                  </td>


                              </tr>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </tbody>
                      </table>
                    </div>
                </div>
       
        </section>

    </div>
    </div>
    </div>
    <?php $__env->stopSection(); ?>
    
<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('app-assets/js/jquery.dataTables.min.js')); ?>"></script>
<script src="<?php echo e(asset('app-assets/js/dataTables.bootstrap5.min.js')); ?>"></script>
<script src="<?php echo e(asset('app-assets/js/sweetalert.min.js')); ?>"></script>



<script>
  $(function () {
    $("#example2").DataTable();
   
  });
 $('#example2').DataTable({"language": { "url": "<?php echo e(asset('app-assets/data/locales/Arabic.json')); ?>"}}); 

 $('.open_box').on('click',function () {
          $('.box').toggle();
      });
function deleteRow(id){

 swal({

title: "هل أنت متأكد من حذف هذا المنتج", 


type: "warning",

showCancelButton: true,

confirmButtonColor: "#DD6B55",

confirmButtonText: "تأكيد",

cancelButtonText: "إلغاء",

closeOnConfirm: false

}, function (isConfirm) {

if (!isConfirm) return;

$.ajax({

  url: "<?php echo e(route('client.products.delete')); ?>",

    type: "post",

    data: {

        id: id,
        '_token':'<?php echo e(csrf_token()); ?>'
    },

    dataType: "html",

  beforeSend : function (){var ifConnected = window.navigator.onLine;if (!ifConnected) {toastr.info("يتم الآن إعادة الإتصال","لا يوجد إتصال بالإنترنت",{positionClass: "toast-top-right",tapToDismiss: !1,timeOut: 2e3,rtl: $("html").attr("data-textdirection")});}},


    success: function () {

        swal("تم الحذف بنجاح", "", "success");

          $("#id-" +id).remove()

    },

    error: function (xhr, ajaxOptions, thrownError) {

        swal("خطأ في الحذف ", "الرجاء المحاولة مرة آخري", "error");

    }

});

});
}
 </script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('client.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/barasys/public_html/resources/views/client/products/empty.blade.php ENDPATH**/ ?>