<?php $__env->startSection('page-title', 'Retailer Management'); ?>

<?php $__env->startSection('main-content'); ?>
<div class="page-content">
    <div class="container-fluid">

        <!-- start page title -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                    <h4 class="mb-sm-0">Retailer Management</h4>

                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboards</a></li>
                            <li class="breadcrumb-item"><a href="<?php echo e(route('retailers')); ?>">Retailer Management</a></li>
                            
                        </ol>
                    </div>

                </div>
            </div>
        </div>
        <!-- end page title -->

        <?php echo e(Form::open(['route' => 'retailers.store','id' => 'retailerform', 'data-parsley-validate', 'files' => true, 'autocomplete' => 'off'])); ?>

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header align-items-center d-flex">
                        <h4 class="card-title mb-0 flex-grow-1"> Sales </h4>
                    </div>
                    <div class="card-body">
                        <?php if(Session::has('error')): ?>
                        <div class="alert alert-danger mb-2" role="alert"><?php echo e(Session::get('error')); ?></div>
                        <?php endif; ?>

                        <?php if(Session::has('success')): ?>
                        <div class="alert alert-success mb-2" role="alert"><?php echo e(Session::get('success')); ?></div>
                        <?php endif; ?>

                        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="alert alert-danger mb-2" role="alert"><?php echo $errors->first(); ?></div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        
                        <div class="row">
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="customername" class="form-label">Customer Name <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('customername', '', ['class' => 'form-control', 'placeholder' => 'Enter customer', 'id' => 'customername', 'required'])); ?>

                                </div>
                            </div>
                            
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="civilcrno" class="form-label">Civil/CR.no  <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('civilcrno', '', ['class' => 'form-control', 'placeholder' => 'Enter civilcrno', 'id' => 'civilcrno', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="invoiceno" class="form-label">Invoice No  <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('invoiceno',$invoiceno, ['class' => 'form-control', 'placeholder' => 'Enter invoiceno', 'id' => 'invoiceno', 'required'])); ?>

                                </div>
                            </div>
                            
                            
                        </div>
                        <div class="row">
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="mobile_no" class="form-label">Mobile no <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('mobile_no', '', ['class' => 'form-control', 'placeholder' => 'Enter  mobile no', 'id' => 'mobile_no', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="nationality" class="form-label">Nationality  <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('nationality', '', ['class' => 'form-control', 'placeholder' => 'Enter nationality', 'id' => 'nationality', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-4">
                                <div class="mb-3">
                                    <label for="invoicedate" class="form-label">Invoicedate  <span class="text-danger">*</span></label>
                                    <?php echo e(Form::date('invoicedate', '', ['class' => 'form-control', 'placeholder' => 'select invoicedate', 'id' => 'invoicedate', 'required'])); ?>

                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-12">
                                <div class="mb-3">
                                    <label for="address" class="form-label">Address <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('address', '', ['class' => 'form-control', 'placeholder' => 'Enter address', 'id' => 'address', 'required'])); ?>

                                </div>
                            </div>    
                        </div>
                           
                        <div class="row">
                            <div class="col-2">
                                <div class="mb-3">
                                    <label for="goldrate" class="form-label">Goldrate <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('goldrate', '', ['class' => 'form-control', 'placeholder' => 'Enter goldrate', 'id' => 'goldrate', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-2">
                                <div class="mb-3">
                                    <label for="labourgold" class="form-label">Labour+Gold <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('labourgold', '', ['class' => 'form-control', 'placeholder' => 'Enter labourgold', 'id' => 'labourgold', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-2">
                                <div class="mb-3">
                                    <label for="diamondrate" class="form-label">Diamond Rate <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('diamondrate', '', ['class' => 'form-control', 'placeholder' => 'Enter diamondrate', 'id' => 'diamondrate', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-2">
                                <div class="mb-3">
                                    <label for="custom" class="form-label">Custom <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('custom', '', ['class' => 'form-control', 'placeholder' => 'Enter custom', 'id' => 'custom', 'required'])); ?>

                                </div>
                            </div>
                            <div class="col-2">
                                <div class="mb-3">
                                    <label for="kwdammount" class="form-label">KWD Rate <span class="text-danger">*</span></label>
                                    <?php echo e(Form::text('kwdammount', '', ['class' => 'form-control', 'placeholder' => 'Enter kwdammount', 'id' => 'kwdammount', 'required'])); ?>

                                </div>
                            </div>
                            
                            
                        </div>
                        <div class="row">
                            <div class="col-12">
                                <div class="mb-3">
                                    <label for="stock" class="form-label">Stock <span class="text-danger">*</span></label>
                                    <?php echo e(Form::select('stock',$stocks, '',['class' => 'form-select', 'required', 'placeholder' => 'Please select stock','id' => 'stock'])); ?>

                                </div>
                            </div>
                        </div>
                        <div class="col-xl-12">
                            <div class="card">
                               

                                <div class="card-body">
                                    
                                    <div class="live-preview">
                                        <div class="table-responsive">
                                            <table class="table align-middle table-nowrap mb-0">
                                                <thead class="table-light">
                                                    <tr>
                                                    <th rowspan="2">Sr.No.</th>   
                                                    <th rowspan="2">Item&Discription</th>
                                                    <th rowspan="2">QTY</th>
                                                    <th rowspan="2">GrossWT GM</th>
                                                    <th colspan="3" class="text-center">Gold</th>
                                                    <th colspan="2" class="text-center">Diamond</th>
                                                    <th colspan="2" class="text-center">Color StoneWT</th>
                                                    <th rowspan="2">CERTIFY</th>
                                                    <th rowspan="2">DIA+C.S Amount</th>
                                                    <th rowspan="2">Total</th>
                                                    <th rowspan="2">Custom</th>
                                                    <th rowspan="2">Amount KWD</th>
                                                    
                                                    </tr>
                                                    <tr>
                                                    <th class="text-center">Purity</th>
                                                    <th>Net WT GM</th>
                                                    <th>Labour+Gold</th>
                                                    <th class="text-center">WT CT</th>
                                                    <th class="text-center">Rate</th>
                                                    <th>WT CT</th>
                                                    <th>Rate</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="stock_detail">
                                                
                                                
                                                </tbody>
                                                <tfoot>
                                                    <tr>
                                                        <td><b> Total </b></td>
                                                        <td> </td>
                                                        <td> <input type="text" id="qtytotal" name="qtytotal" class="form-control"></td>
                                                        <td><input type="text" id="grosswtgmstotal" name="grosswtgmstotal" class="form-control">  </td>
                                                        <td> </td>
                                                        <td><input type="text" id="netgoldwtgmstotal" name="netgoldwtgmstotal" class="form-control"> </td>
                                                        <td><input type="text" id="labourgoldtotal" name="labourgoldtotal" class="form-control"> </td>
                                                        <td><input type="text" id="diamondwtctstotal" name="diamondwtctstotal" class="form-control">  </td>
                                                        <td> </td>
                                                        <td><input type="text" id="colorstonewtctstotal" name="colorstonewtctstotal" class="form-control">  </td>
                                                        <td><input type="text" id="colorstoneratetotal" name="colorstoneratetotal" class="form-control">  </td>
                                                        <td><input type="text" id="certifytotal" name="certifytotal" class="form-control">  </td>
                                                        <td><input type="text" id="diacsamounttotal" name="diacsamounttotal" class="form-control">  </td>
                                                        <td><input type="text" id="totalamounttotal" name="totalamounttotal" class="form-control">  </td>
                                                        <td><input type="text" id="customtotal" name="customtotal" class="form-control">  </td>
                                                        <td><input type="text" id="kwdcosttotal" name="kwdcosttotal" class="form-control">  </td>
                                                        
                                                    </tr>
                                                    
                                                    <tr>
                                                        <td class="text-center"><b>Payment Type </b></td>
                                                        <td colspan="3"><?php echo e(Form::select('paymenttype',['knet' => 'Knet','visa' => 'Visa','cash' => 'Cash'],'',['class' => 'form-select', 'required', 'placeholder' => 'PaymentMethod','id' => 'paymenttype'])); ?></td>
                                                        <td><b>PaidAmount</b></td>
                                                        <td colspan="3"> <input type="number"  name="paidamount"  id="paidamount" class="form-control"></td> 
                                                        <td><b> Due </b></td> 
                                                        <td colspan="3" class="text-center"> <input type="number"  name="kwdamount"  id="kwdamount" class="form-control"></td>
                                                    </tr>
                                                      
                                                </tfoot>
                                                
                                            </table>
                                           
                                            <!-- end table -->
                                        </div>
                                        <!-- end table responsive -->
                                    </div>
                                    <div class="d-none code-view">

                                    </div>
                                </div><!-- end card-body -->
                            </div><!-- end card -->
                        </div>
                        

                        <div class="border mt-3 border-dashed mb-4"></div>
                        <div class="row">
                            <div class="col-12">
                                <div class="text-end">
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--end col-->
        </div>
        <?php echo e(Form::close()); ?>

        

    </div>
    <!-- container-fluid -->
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-css'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-js'); ?>
<script>



$(document).ready (function () {  
    $("#stock").change (function () {  
        var id = $(this).children("option:selected").val();
         $.ajax({     
                data: {id: id},
                type: "GET",
                dataType: "html",
                url:"<?php echo e(route('retailers.ajax-list')); ?>",
                success: function(data){  
                     $('#stock_detail').append(data);
                                         
                }
            });
    });
}); 

$(function(){
            $('#paidamount').keyup(function(){
               var value1 = parseFloat($('#paidamount').val());
               var value2 = parseFloat($('#totalamounttotal').val());
               var due = (value2-value1);

               $('#kwdamount').val(due);
               
            }); 
  }); 
  

  $(document).ready( function() {
    $('#mobile_no').keyup(function() {
       var mobileno = parseInt($('#mobile_no').val());
       $.ajax({     
                data: {id: mobileno},
                type: "GET",
                dataType: "json",
                url:"<?php echo e(route('retailers.customer')); ?>",
                success: function(data){  
                    $('#customername').val(data.name);
                    $('#civilcrno').val(data.civil_cr_no);
                    $('#nationality').val(data.nationality);
                    $('#address').val(data.address);
                    
                                         
                }
            });
    });
});
    
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('Layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/cdiagk1jmlvy/public_html/goldiam/resources/views/Retailer/index.blade.php ENDPATH**/ ?>