<?php $__env->startSection('content'); ?>
<div class="row" style="margin-top: 10px; margin-bottom: 10px">

        <div class="col-lg-12 col-xlg-12 col-md-12">
        <!-- Column -->
        <div class="card">
          <div class="card-body little-profile text-left bg-premium-dark">
            <h3 class="card-title">Create <?php echo e($type); ?> Deal</h3>
            <div class="x_content">
            <form class="form-horizontal form-label-left"  enctype="multipart/form-data"  action="<?php echo e(url('/dealer/upload_bill')); ?>" method="post">
                <?php echo e(csrf_field()); ?>

                <h4 class="card-title">Select Customer And EV Model</h4>
                <div class="row">
                  <div class="col-md-6">
                    <div class="form-group">
                    <label for="username" class="control-label">Customer Username<span class="required">*</span></label>                  
                          <input type="text" name="username" id="sponsor-typeahead" class="form-control form-control-normal" placeholder="Sponsor's Username" value="<?php echo e(old('sponsor')); ?>" required="" style="margin-bottom: 0px; " />
                          <p class="help-block"></p>
                          <?php if($errors->has('username')): ?>
                              <p class="help-block error">
                                  <?php echo e($errors->first('username')); ?>

                              </p>
                          <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                    <label for="select_model" class="control-label">Customer Name<span class="required">*</span></label>
                          <?php echo Form::text('sponsor_name', old('sponsor_name'), ['class' => 'form-control form-control-normal', 'id' => 'sponsor_name', 'placeholder' => '','disabled'=>'']); ?>

                          <p class="help-block"></p>
                          <?php if($errors->has('sponsor_name')): ?>
                              <p class="help-block error">
                                  <?php echo e($errors->first('sponsor_name')); ?>

                              </p>
                          <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                      <label for="select_model" class="control-label"><?php echo e(($type=='EV')?"Select Model":"Select KW"); ?><span class="required">*</span></label>                  
                      <select name="ev_ev_solar_model_id" class="form-control form-control-normal" id="ev_model_sel" required>
                          <?php $__currentLoopData = $ev_ev_solar_model_ids; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ev_ev_solar_model_id): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <option value="<?php echo e($ev_ev_solar_model_id->id); ?>"><?php echo e($ev_ev_solar_model_id->title); ?><?php if($type=='SOLAR'): ?> ( <?php echo e($ev_ev_solar_model_id->kw); ?> KW ) <?php endif; ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </select>
                      <?php if($errors->has('ev_ev_solar_model_id')): ?>
                          <p class="help-block error">
                              <?php echo e($errors->first('ev_ev_solar_model_id')); ?>

                          </p>
                      <?php endif; ?>
                    </div>
                  </div>
                  <?php if($type=='EV' && isset($ev_model->color)): ?>
                  <div class="col-md-3">
                      <div class="form-group">
                      <label for="select_model" class="control-label">Color<span class="required">*</span></label>
                      <select name="color" id="color-dropdown" class="form-control">
                          <?php $__currentLoopData = $colors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $color): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <option value="<?php echo e($color); ?>"><?php echo e($color); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </select>
                      <?php if($errors->has('color')): ?>
                          <p class="help-block error">
                              <?php echo e($errors->first('color')); ?>

                          </p>
                      <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                      <label for="select_model" class="control-label">HSN</label>
                      <p class="help-block" id="hsn-text"><?php echo e($ev_model->hsn); ?></p>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                      <label for="select_model" class="control-label">Amount in INR</label>
                      <p class="help-block" id="amount-text"><?php echo e($ev_model->amount); ?></p>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="chassis_no">Chassis No.</label>
                          <input type="text" id="chassis_no" name="chassis_no" class="form-control" value="">
                            <?php if($errors->has('chassis_no')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('chassis_no')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="motor_no">Motor No.</label>
                          <input type="text" id="motor_no" name="motor_no" class="form-control" value="">
                            <?php if($errors->has('motor_no')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('motor_no')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="battery_make">Battery Make</label>
                          <input type="text" id="battery_make" name="battery_make" class="form-control" value="">
                            <?php if($errors->has('battery_make')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('battery_make')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="battery_no">Battery No.</label>
                          <input type="text" id="battery_no" name="battery_no" class="form-control" value="">
                            <?php if($errors->has('battery_no')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('battery_no')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="battery_type">Battery Type</label>
                          <input type="text" id="battery_type" name="battery_type" class="form-control" value="">
                            <?php if($errors->has('battery_type')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('battery_type')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-3">
                      <div class="form-group">
                          <label class="control-label" for="battery_warranty">Battery Warranty</label>
                          <input type="text" id="battery_warranty" name="battery_warranty" class="form-control" value="">
                            <?php if($errors->has('battery_warranty')): ?>
                              <p class="help-block">
                                  <strong><?php echo e($errors->first('battery_warranty')); ?></strong>
                              </p>
                            <?php endif; ?>
                      </div>
                  </div>
                  <?php else: ?>
                  No Ev Model found
                  <?php endif; ?>
                </div>
                
                <div class="form-group">
                    <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                      <button type="submit" class="btn btn-success">Submit</button>
                    </div>
                  </div>
                
              </form>
              </div>
          </div>
        </div>
    </div>
</div>
<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered" id="users-table">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Type</th>
                            <th>Title</th>
                            <th>KW</th>
                            <th>Amount</th>
                            <th>Paid Amount</th>
                            <th>Balance Amount</th>
                            <th>Dealer Comment</th>
                            <th>Admin Comment</th>
                            <th>Updated On</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
        </div>
    </div>
</div>
<div class="modal fade" id="loadModalAjax" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
    </div>
    <!-- /.modal-content -->
   </div>
  <!-- /.modal-dialog -->
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('javascript'); ?>

    <!-- Date picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
    <!-- Daterange picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- Date Picker Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <!-- Date range Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/jqBootstrapValidation.js"></script>

    <link href="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/easy-autocomplete.min.css" rel="stylesheet">
    <script src="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/jquery.easy-autocomplete.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/typeahead.bundle.js"></script>

    <script>
  $(document).ready(function() {
        
        var t = $('#users-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: '<?php echo url('/'); ?>/dealer/billSentReportAnyData',
                dom: 'Bfrtip',
                'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
                columns: [
                    { data: 'id', name: 'id', searchable:false },
                    { data: 'kw_type', name: 'kw_type' },
                    { data: 'title', name: 'title' },
                    { data: 'kw', name: 'kw' },
                    { data: 'amount', name: 'amount' },
                    { data: 'paid_amount', name: 'paid_amount' },
                    { data: 'balance_amount', name: 'balance_amount' },
                    { data: 'user_comment', name: 'user_comment' },
                    { data: 'admin_comment', name: 'admin_comment' },
                    { data: 'updated_at', name: 'updated_at', searchable:false },
                    { data: 'status', name: 'status' },
                    { data: 'action', name: 'action' },
                ],
                "columnDefs": [
                    {
                        "render": function ( data, type, row, meta) {
                            return meta.row + meta.settings._iDisplayStart + 1;
                         },
                        "targets": 0
                    },
                    // {
                    //     "render": function ( data, type, row ) {
                    //         return data.replace(".00", "")+'%';
                    //     },
                    //     "targets": 3
                    // },

                    {
                        "render": function ( data, type, row ) {
                        if(data==0){
                            return '<span class="table-primary">Pending</span>';
                        }else if(data==2){
                            return '<span class="table-danger">Declined</span>';
                        }else{
                            return '<span class="table-success">Approved</span>';
                        }
                        },
                        "targets": 10
                    }
                ],
                'order': [[1, 'asc']],
                drawCallback: function( settings ) {
                    //openModal();
                  }
            });

    $('#ev_model_sel').on('change', function() {
        var ev_id = this.value;
        $("#color-dropdown").html('');
        $.ajax({
            url:"<?php echo e(url('/')); ?>/dealer/get-color-by-ev",
            type: "POST",
            data: {
            ev_id: ev_id,
            _token: '<?php echo e(csrf_token()); ?>' 
            },
            dataType : 'json',
            success: function(result){
            $('#color-dropdown').html('<option value="">Select Color</option>'); 
            $.each(result.colors,function(key,value){
            $("#color-dropdown").append('<option value="'+value+'">'+value+'</option>');
            });

            $("#hsn-text").html(result.hsn);
            $("#amount-text").html(result.amount);
            }
        });
    });

    var options = {

        url: function(phrase) {
          return "<?php echo e(url('/')); ?>/dealer/getSponsors/" + phrase;
        },

        getValue: function(element) {
          return element.username;
        },

        template: {
            type: "description",
            fields: {
                description: "full_name"
            }
        },
        list: {
              onChooseEvent: function() {
                var data = $("#sponsor-typeahead").getSelectedItemData().full_name;
                $("input#sponsor_name").val(data).trigger("change");
              }
        },
        theme: "plate-dark",
        ajaxSettings: {
          dataType: "json",
          method: "GET",
          data: {
            dataType: "json"
          }
        },
        preparePostData: function(data) {
          data.phrase = $("#sponsor-typeahead").val();
          return data;
        },

        requestDelay: 400
      };

      $("#sponsor-typeahead").easyAutocomplete(options);
  });

            

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

<?php echo $__env->make('layouts.dealer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\xampp\htdocs\yeselectricv.loc\resources\views/dealers/billSentReport.blade.php ENDPATH**/ ?>