
<?php $__env->startSection('custom-styles'); ?>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/izitoast/dist/css/iziToast.min.css">
    <style>
   body.dragging,
    body.dragging * {
    	cursor: grabbing !important;
    }
    .dragged {
    	position: absolute !important;
    	opacity: 0.6;
    	z-index: 2000;
    }
    .handle {
    	cursor: grab;
    }
</style>
  
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

        
        <div class="card">
            <div class="card-body">
                 <ol class="list-unstyled sortable" store_id="<?php echo e(request()->segment(count(request()->segments()))); ?>">
                            <!--<input type="hidden" name="store_id" value="" />-->
                            <?php $count = 1; ?>
                            <?php $__currentLoopData = $query; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <input type="hidden" value="<?php echo e($row->store_id); ?>" name="store_id"  class="store_id"/>
                            <li class="sort" id="item_<?php echo e($row->id); ?>" no="<?php echo e($row->id); ?>" sortingno="<?php echo e($row->sorting_order); ?>">
    							<div class="card mb-1">
    								<div class="card-header p-2">
    									<div class="row form-inline">
    										<div class="col-sm-1">
    										    <div class="parent-icon handle"> 
    										   <i class="material-icons">list</i>
    										   </div>
                                            </div>
    										<div class="col-sm-4"> <?php echo e($row->title); ?> </div>
    										<div class="col-sm-2"></div>
    										<div class="col-sm-2"></div>
    										<div class="col-sm-2"></div>
    										<div class="col-sm-1 text-right">
    											
    										</div>
    									</div>
    								</div>
    							</div>
						    </li>
						    
						    
						    <?php $count++; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ol>
                        <button class="btn btn-primary btn-save">Save</button>
            </div>
        </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('custom-scripts'); ?>
<script src="<?php echo e(asset('admin-assets/js/bs-custom-file-input.js')); ?>"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/izitoast/dist/js/iziToast.min.js"></script>
  <script>
   $(document).ready(function () {
       var data = '';
  bsCustomFileInput.init();
  $(".sortable").sortable({

	});
	
	$('.btn-save').click(function(){
	    var arr = [];
	    var store_id = $('.store_id').val();
	    var id = $('.sortable').attr('store_id');
	    $(".sortable li").each(function(i,v){
	        arr.push($(this).attr('no')); 
	    });
	    console.log(id);
	    console.log(store_id);
	    console.log(arr);
        // POST to server using $.post or $.ajax
        $.ajax({
        //     headers: {
        //         'X-CSRF-Token': '<?php echo e(csrf_token()); ?>' 
        //   },
            type: 'GET',
            url: '<?php echo e(route('update_order')); ?>',
            dataType:'json',
            data: {item:arr,store_id:store_id},
            success: function(resp){
              
                if (resp.errors) {
                    var errorMsg = '';
                    $.each(resp.errors, function(field, errors) {
                        $.each(errors, function(index, error) {
                            errorMsg += error + '<br>';
                        });
                    });
                    iziToast.error({
                        message: resp.error,
                        position: 'topRight'
                    });
    
                } else {
                    iziToast.success({
                        message: 'Sorting Saved',
                        position: 'topRight'
    
                    });
                }
            },
            error: function(resp){
                console.log(resp);
                  iziToast.error({
                            message: 'Sorting Failed',
                            position: 'topRight'
                        });
            }
        }); 
	});
});
</script>
<script src="<?php echo e(asset('public/assets/plugins/datatable/js/jquery.dataTables.min.js')); ?>"></script>
<script src="<?php echo e(asset('public/assets/plugins/datatable/js/dataTables.bootstrap5.min.js')); ?>"></script>
<script src="<?php echo e(asset('public/assets/js/table-datatable.js')); ?>"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/mdwdigizhb/blogzcenter.com/resources/views/admin/pages/stores/couponlist.blade.php ENDPATH**/ ?>