

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

<div class="main-mobile-header doc-mobile-header">
      <a id="menuLink" href="#" class="menu-link"><i class="ri-menu-line"></i></a>
    </div>

   

    



     <div class="main main-app p-3 p-lg-4">
        

        <div class="mb-4">
          <ol class="breadcrumb fs-sm mb-1">
            <li class="breadcrumb-item"><a href="#">Dashboard</a></li>
            <li class="breadcrumb-item active" aria-current="page">Trailer Documents List</li>
          </ol>
        </div>



      <div class="">
        <div class="row">

          <div class="col-lg-8">
            <h2 class="main-title">Trailer Documents List</h2>
            
          </div>
          <div style="text-align: right;" class="col-lg-4 text-right">
           <!--  <button type="button" class="btn btn-primary">Add Employee</button> -->
            <!-- <a href="/form" class="btn btn-primary">Create Hotel</a> -->
            <button type="button" class="btn btn-primary btn-icon-text mb-2 mb-md-0" data-bs-toggle="modal" data-bs-target="#myFlight">
        Add Trailer Documents
      </button>
          </div>

        </div>

        <hr class="main-separator">        
    


<!--         <h5 id="section9" class="main-subtitle">Basic Example</h5>
 -->        <!-- <p>In this examples, we load the data from an existing HTML table.</p> -->

        <div class="card card-example">
          <div class="card-body" style="background-color:white;">
            <div class="table-responsive ">
              <table id="tableGrid1" class="table table-hover">
              <thead class="text-center">
            <tr>
              <th>No</th>
              <th>Document Type</th>
              <th>ID Number</th>
              <th>Issue Date</th>
              <th>Expiry Date</th>
              <th>Renewal Date</th>
              <th>Attachment</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>
            <?php $__currentLoopData = $documents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            
            <tr>
           
              <td><?php echo e($key+1); ?></td>
              <td><?php echo e($data->document_type); ?></td>
              <td><?php echo e($data->id_number); ?></td>
              <td><?php echo e($data->issue_date); ?></td>
              <td><?php echo e($data->expiry_date); ?></td>
              <td><?php echo e($data->renewal_date); ?></td>
              <td>
                  <a href="/uploads/<?php echo e($data->attachment_file); ?>">
                      <?php echo e($data->attachment_file); ?>

                  </a>
              </td>
              
              <td>
             
                <button style="padding:0;background-color: transparent;  background-repeat: no-repeat;  border: none;    cursor: pointer;    overflow: hidden;    outline: none;" value="/trailer/documents/delete/<?php echo e($data->id); ?>" class="  deletebtnpopup"><span style="color:#506fd9;"><i style="font-size: 20px;" class="ri-delete-bin-6-line"></i></span></button>
                <button style="padding:0;background-color: transparent;  background-repeat: no-repeat;  border: none;    cursor: pointer;    overflow: hidden;    outline: none;" value="<?php echo e($data->id); ?>" class="editbtn"><span style="color:#506fd9;"><i style="font-size: 20px;" class="ri-edit-box-line"></i></span></button>

            </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </tbody>
                
              </table>
            </div><!-- table-responsive -->
          </div><!-- card-body -->
          
        </div><!-- card -->

        <br><br><br>

        

      </div><!-- container -->

     
    <style>
    tbody tr:hover {background-color: #F5F5F5;}
    .card-example>.card-body::before {
    content: ""
    }
    </style>

    <script type="text/javascript">
      $("#tableGrid1").Grid({
        className: {
          table: 'table table-bordered mb-0'
        },
        search: true
      });
    </script>


<!-- The Modal -->
<div class="modal" id="myFlight">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header" >
        <h4 class="modal-title">Add trailer Documents</h4>
        <button type="button" class="btn-close" data-bs-dismiss="modal" style="margin-top: 1px;"></button>
      </div>
      <!-- Modal body -->
      <div class="modal-body" style="margin-top: -15px;">
        <div class="card-body">
          <form action="/trailer/documents/store" method="POST" id="cat" enctype="multipart/form-data">
          <?php echo csrf_field(); ?>
            <input type="hidden" name="trailer_id" id="trailer_id" value="<?php echo e($id); ?>">
          
          <br>
          <div class="row">

            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Document Type
                <span class="required-field">*</span>
              </label>
              <select class="form-select" name="document_type" id="document_type">
                  <?php $__currentLoopData = $document_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <option><?php echo e($data->name); ?></option>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </select>
                </div>
            </div>
            <!--<div class="col-sm-6">-->
            <!--    <div class="mb-3">-->
            <!--        <label class="form-label">trailer Id-->
            <!--    <span class="required-field">*</span>-->
            <!--  </label>-->
            <!--    <input type="text" name="trailer_id" id="trailer_id" class="form-control" required>-->
            <!--    </div>-->
            <!--</div>-->

            <!--<div class="col-sm-6">-->
            <!--    <div class="mb-3">-->
            <!--        <label class="form-label">Chasis No-->
            <!--    <span class="required-field">*</span>-->
            <!--  </label>-->
            <!--    <input type="text" name="chasis_no" id="chasis_no" class="form-control" required>-->
            <!--    </div>-->
            <!--</div>-->
            
            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">ID Number
                <span class="required-field">*</span>
              </label>
                <input type="text" name="id_number" id="id_number" class="form-control" required>
                </div>
            </div>
            
            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Issue Date
                <span class="required-field">*</span>
              </label>
                <input type="date" name="issue_date" id="issue_date" class="form-control" required>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Expiry Date
                <span class="">*</span>
              </label>
                <input type="date" name="expiry_date" id="expiry_date" class="form-control" required>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Renewal Date
                <span class="">*</span>
              </label>
                <input type="date" name="renewal_date" id="renewal_date" class="form-control" required>
                </div>
            </div>
            
                            
            <div class="col-sm-6">
              <div class="mb-3">

                  <label class="form-label">Attachment File

                      <small class="optional-color">(optional)</small>
                  </label>
                  <input class="form-control" name="attachment_file" type="file" id="attachment_file">
              </div>
          </div>
          
                      <div class="col-sm-12">
              <div class="mb-3">

                  <label class="form-label">Remarks
                      <span class="required-field">*</span>
                  </label>
                  <textarea name="remarks" id="remarks" class="form-control"></textarea>
              </div>
          </div><!-- Col -->

          </div><!-- Row -->
          <div class="buttons-alignment mt-4 ml-auto">
            <button type="submit" class="btn btn-primary">Submit</button>
          </div>
                </form>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="modal" id="edit-category">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header" >
        <h4 class="modal-title">Edit trailer Documents</h4>
        <button type="button" class="btn-close" data-bs-dismiss="modal" style="margin-top: 1px;"></button>
      </div>
      <!-- Modal body -->
      <div class="modal-body" style="margin-top: -15px;">
        <div class="card-body">
          <form action="/trailer/documents/update" method="POST" id="cat" enctype="multipart/form-data">

          <?php echo csrf_field(); ?>
          <input type="hidden" name="trailer_id" id="trailer_id">
          <br>
          


          <div class="row">
            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Document Type
                <span class="required-field">*</span>
              </label>
              <select class="form-select" name="document_type" id="document_type">
                  <?php $__currentLoopData = $document_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <option><?php echo e($data->name); ?></option>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </select>
                </div>
            </div>
            
            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">ID Number
                <span class="required-field">*</span>
              </label>
                <input type="text" name="id_number" id="id_number" class="form-control" required>
                </div>
            </div>
            
            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Issue Date
                <span class="required-field">*</span>
              </label>
                <input type="date" name="issue_date" id="issue_date" class="form-control" required>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Expiry Date
                <span class="">*</span>
              </label>
                <input type="date" name="expiry_date" id="expiry_date" class="form-control" required>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="mb-3">
                    <label class="form-label">Renewal Date
                <span class="">*</span>
              </label>
                <input type="date" name="renewal_date" id="renewal_date" class="form-control" required>
                </div>
            </div>
            
                            
            <div class="col-sm-6">
              <div class="mb-3">

                  <label class="form-label">Attachment File

                      <small class="optional-color">(optional)</small>
                  </label>
                  <input class="form-control" name="attachment_file" type="file" id="attachment_file">
              </div>
          </div>
          
                      <div class="col-sm-12">
              <div class="mb-3">

                  <label class="form-label">Remarks
                      <span class="required-field">*</span>
                  </label>
                  <textarea name="remarks" id="remarks" class="form-control"></textarea>
              </div>
          </div><!-- Col -->

          </div><!-- Row -->
          <div class="buttons-alignment mt-4 ml-auto">
            <button type="submit" class="btn btn-primary">Update</button>
          </div>
                </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
    $(document).ready(function() {
    $(document).on('click', '.editbtn', function() {
      var cat_id = $(this).val();
      //alert(service_id);
      $('#edit-category').modal('show');
             console.log(cat_id)


    var initialData = <?php echo json_encode($documents->toArray()); ?>;
    console.log(initialData)

   var filteredData = initialData.filter(function(category) {
       return category.id == cat_id;
      });

       console.log(filteredData)
      
    $('#edit-category #trailer_id').val(filteredData[0].id);
    $('#edit-category #document_type').val(filteredData[0].document_type);
    $('#edit-category #id_number').val(filteredData[0].id_number);
    $('#edit-category #issue_date').val(filteredData[0].issue_date);
    $('#edit-category #expiry_date').val(filteredData[0].expiry_date);
    $('#edit-category #renewal_date').val(filteredData[0].renewal_date);
    $('#edit-category #attachment_file').val(filteredData[0].attachment_file);
    $('#edit-category #remarks').val(filteredData[0].remarks);



  


    });
  });

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/megamarket/public_html/tms/resources/views/trailer/trailer_documents.blade.php ENDPATH**/ ?>