<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Remaining Stock</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">Remaining Stock</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <form method="post" action="/priceupdatefilter" class="formFilter">
        <?php echo e(csrf_field()); ?>

        <div class="row">
            <div class="col-md-4">
                <div class="form-group">
                    <label>Select Reseller</label>
                    <select class="form-control" name="reseller_name" id="reseller_name" style="width: 100%;" required>
                        <option value="" selected="selected" disabled>Select</option>
                            <?php $__currentLoopData = $delise; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($data->id); ?>" <?php if($sel==$data->id): ?> selected <?php endif; ?>><?php echo e($data->companyname); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="col-md-1" style="padding-top:30px;"><button type="submit" class="btn btn-info btn-block">Filter</button></div>
            </div>
        </form>
          <br><hr><br>

          <div class="row">
            <div class="col-md-12">
            <table id="example12" data-page-length='500' class="table table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Product ID</th>
                        <th>Product Name</th>
                        <th>Reseller Sell Price</th>
                        <th>Dropshipping Price</th>
                        <th>Weight (KG)</th>
                        <th>Action</th>
                    </tr>
                </thead>

            </table>
            
            </div>
          </div>
          </div>
        </div>
      </div>
    </section>
  </div>
 

 <div class="modal fade" id="editordermodelphone" role="dialog">
        <div class="modal-dialog">
        
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
                    <h4 class="modal-title">Update Product Details</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              
            </div>
            
            <form method="post" enctype="multipart/form-data" id="myform">
            <?php echo e(csrf_field()); ?>

                <div class="modal-body">
                <input type="hidden" id="id" name="id">

                <div class="form-group">
                    <label for="recipient-name" class="col-form-label">Cost :</label>
                    <input type="text" class="form-control" id="cost" name="cost" required>
                </div>
                <div class="form-group">
                    <label for="recipient-name" class="col-form-label">Weight :</label>
                    <input type="text" class="form-control" id="weight" name="weight" required>
                </div>
                    
                </div>
                  
            <div class="modal-footer">
            <input type="submit" name="btnform1" id="action" class="btn btn-primary right" value="Submit"/>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </form>
          </div>
          
        </div>

</div>



  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;

<script>

$('#editordermodelphone').on('show.bs.modal', function (event) {

var button = $(event.relatedTarget) // Button that triggered the modal

var id = button.data('id') 
var phone = button.data('cost') 
var weight = button.data('weight') 
var modal = $(this)
//   modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body #id').val(id)
modal.find('.modal-body #cost').val(phone)
modal.find('.modal-body #weight').val(weight)

})

$('#myform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/updatecost",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                toastr.success('Product Price Update successfully!')
                $("#editordermodelphone").modal('hide');  
                $('#example12').DataTable().ajax.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });


  $(document).ready(function() {
  var table = $('#example12').DataTable({
        "ajax": {   "url": '/selerrpricetabget',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('.formFilter').serialize();
                    }
        },
        columns: [
            { data: 'pro_id', name: 'pro_id' },
            { data: 'pro_name', name: 'pro_name'},
            { data: 'sell_price', name: 'sell_price'},
            { data: 'cost', name: 'cost' },
            { data: 'weight', name: 'weight' },
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ],
    });
} );


$(document).on('click', '.btn-danger', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    let ele = this;
    console.log(id);

                swal({
                title: "Are you sure?",
                text: "Are you Sure to Remove Order",
                icon: "warning",
                showCancelButton: true,
    confirmButtonColor: '#3085d6',
    cancelButtonColor: '#d33',
    confirmButtonText: 'Yes, delete it!',
                dangerMode: true,
            }).then(function(isConfirm) {
                
                if (isConfirm.value===true) {

                        $.ajax({
                            url: "<?php echo e(url('/deletesellerpro')); ?>/"+id ,
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            cache: false,
                            contentType: false,
                            processData: false,
                            dataType: 'JSON',
                            data:{
                                "id":id
                            },
                            success: function (result, code, ex) {
                                toastr.error('Product Removed successfully!')
                                $('#example12').DataTable().ajax.reload();
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                swal("Warning", "Unable to Process your request", "error");
                            },
                        });

                } else {
                    swal("Cancelled", "No Removed", "error");
                }
            })
});
</script>

