<?php $__env->startSection('content'); ?>
<style>
label.error{
	color:red;
}
</style>
<div class="common-content">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6>Product Tracking</h6>
                    </div>
                </div>
                <div class="dashboard-cnts">
				    <form method="POST" action="<?php echo e(url('buyers/search_tracking')); ?>" id="product_tracking">
                        <?php echo csrf_field(); ?>
                    <div class="row createSpace">
                        <div class="col-lg-6 col-md-6 col-sm-12" style="margin-bottom: 20px;">
                            <div class="form-inputs">
                                 <div class="form-group">
                                    <label>Department Name</label>
                                    <select id="department_id" class="form-control selectmanufacturer invoiceselect" name="department_id" value="">
									<?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $departmentlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
									  <option value="<?php echo e($departmentlist->id); ?>" <?php if($select_depart==$departmentlist->id){echo "selected";}?>><?php echo e(ucfirst($departmentlist->name)); ?></option>
									<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
									</select>
								 </div>
                            </div>
                          </div>
						<div class="col-lg-6 col-md-6 col-sm-12">
							<button type="submit" class="btn btn-primary">
						       <?php echo e(__('Search')); ?>

							</button>
						</div>
                      </div>
                   </form>
                </div>
			<div class="boxings">
            <div class="custom-tabs" style="margin-top: 0;">
                <!-- nav-tabs End -->
               
                <div class="tab-content">
				
                    <div id="home" class="tab-pane active">
                    <?php if(!empty($sellitems)): ?>
						<table id="table_id1" class="display">
								<thead>
									<tr>
										<th>No</th>
										<th>Issued products</th>
										<th>Received departments</th>
										<th>Issued Date</th>
										<th>Expected Return Date</th>
										<th>Status</th>
									
									</tr>
								</thead>
							<tbody>
							<?php $i=1;?>
							<?php $__currentLoopData = $sellitems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sellitems): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
								<tr>
									<td><?php echo e($i); ?></td>
									<td><?php echo e(ucfirst($sellitems->product_name)); ?></td>
									<td><?php echo e(ucfirst($sellitems->name)); ?></td>
									<td><?php echo e($sellitems->scan_date); ?></td>
									<td><?php echo e($sellitems->expected_date); ?></td>
									<td>

                                        <?php if($sellitems->loan_period_default=='hour'): ?>

                                                <?php if($sellitems->returnstatus==0): ?>
                                            
                                                        <?php
                                                            date_default_timezone_set("Asia/Calcutta");   //India time (GMT+5:30)

                                                            $today = date("d-m-Y H:i");
                                                            $today1=$today.":00";
                                                        ?>

                                                        <?php if(strtotime($today1) == strtotime($sellitems->expected_date)): ?>
                                                            <span  class="status orange">Loan period ends today</span>
                                                        <?php elseif(strtotime($today1) > strtotime($sellitems->expected_date)): ?>
                                                            <span  class="status red">Loan period expired</span>
                                                        <?php else: ?>
                                                        <span  class="status green">Issued</span>
                                                        <?php endif; ?>

                                                <?php else: ?>
                                                     <span  class="status green">Returned</span>
                                 
                                                <?php endif; ?>

                                        <?php else: ?>


                                                    <?php if($sellitems->returnstatus==0): ?>
                                                
                                                        <?php

                                                            $today = date("d-m-Y");
                                                        ?>

                                                        <?php if(strtotime($today) == strtotime($sellitems->expected_date)): ?>
                                                            <span  class="status orange">Loan period ends today</span>
                                                        <?php elseif(strtotime($today) > strtotime($sellitems->expected_date)): ?>
                                                            <span  class="status red">Loan period expired</span>
                                                        <?php else: ?>
                                                        <span  class="status green">Issued</span>
                                                        <?php endif; ?>

                                                    <?php else: ?>
                                                    <span  class="status green">Returned</span>
                                                
                                                    <?php endif; ?>

                                        <?php endif; ?>
                                    </td>
								</tr>
								<?php $i++;?>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>	
							</tbody>
						</table>
					<?php else: ?>
                        No Search result found
                    <?php endif; ?>	
                     </div>  
                    <!-- All Bids< End -->
					
                    <div class="clear"></div>
                </div>
                <!--tab-content End -->
            </div>
            <!--custom-tabs End -->
        </div>
        <!--boxings End -->	
		

	</div>



<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
$(function () {
  $(".invoiceselect").select2();
});
$(document).ready( function () {

    var oTable = $('#table_id1').dataTable( {
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [5 ] }
       
    ]
}); 

    

});

<?php if(Session::has('message')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('message')); ?>",
        type: "success",
        showCancelButton: false,
        dangerMode: false,
        confirmButtonText: 'OK',

    });
<?php endif; ?>
<?php if(Session::has('errormessage')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('errormessage')); ?>",
        type: "error",
        showCancelButton: false,
        dangerMode: true,
        confirmButtonText: 'OK',

    });
<?php endif; ?>

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

<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/buyers/tracking.blade.php ENDPATH**/ ?>