<?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">
            <h4 class="card-title">Upload <?php echo e($type); ?> Bill</h4>
            <div class="x_content">
            <form class="form-horizontal form-label-left"  enctype="multipart/form-data"  action="<?php echo e(url('/distributor/upload_bill')); ?>" method="post">
                <?php echo e(csrf_field()); ?>


                <div class="form-group">
                  <label for="username" class="control-label col-md-3 col-sm-3 col-xs-12">Customer Username<span class="required">*</span></label>
                  <div class="col-lg-4 col-md-4 col-sm-6 form-group">
                        <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>
                <!--/span-->
                <div class="form-group">
                  <label for="select_model" class="control-label col-md-3 col-sm-3 col-xs-12">Customer Name<span class="required">*</span></label>
                  <div class="col-lg-4 col-md-4 col-sm-6 form-group">
                        <?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="form-group">
                  <label for="select_model" class="control-label col-md-3 col-sm-3 col-xs-12"><?php echo e(($type=='EV')?"Select Model":"Select KW"); ?><span class="required">*</span></label>
                  <div class="col-lg-4 col-md-4 col-sm-6 form-group">
                    <select name="ev_ev_solar_model_id" class="form-control col-md-7 col-xs-12">
                        <?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 echo e($ev_ev_solar_model_id->kw); ?> KW )</option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                  </div>
                </div>

                
                <div class="form-group">
                  <label for="bill_comment" class="control-label col-md-3 col-sm-3 col-xs-12">Comment</label>
                  <div class="col-lg-4 col-md-4 col-sm-6 form-group">
                  <textarea name="bill_comment" id="bill_comment" placeholder="Comment" type="text" class="form-control col-md-7 col-xs-12"></textarea>
                  </div>
                </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>KW</th>
                            <th>Distributor 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'); ?>
    <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('/'); ?>/distributor/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: 'kw', name: 'kw' },
                    { 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": 6
                    }
                ],
                'order': [[1, 'asc']],
                drawCallback: function( settings ) {
                    //openModal();
                  }
            });

    // $('#state-dropdown').on('change', function() {
    //     var state_id = this.value;
    //     $("#city-dropdown").html('');
    //     $.ajax({
    //         url:"<?php echo e(url('/')); ?>/get-cities-by-state",
    //         type: "POST",
    //         data: {
    //         state_id: state_id,
    //         _token: '<?php echo e(csrf_token()); ?>' 
    //         },
    //         dataType : 'json',
    //         success: function(result){
    //         $('#city-dropdown').html('<option value="">Select City</option>'); 
    //         $.each(result.cities,function(key,value){
    //         $("#city-dropdown").append('<option value="'+value.id+'">'+value.name+'</option>');
    //         });
    //         }
    //     });
    // });

    var options = {

        url: function(phrase) {
          return "<?php echo e(url('/')); ?>/distributor/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.distributor', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\xampp\htdocs\yeselectricv.loc\resources\views/distributors/billSentReport.blade.php ENDPATH**/ ?>