 
<?php 

 
?>


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

.help-block{
  color:red;
}
.is-invalid{border:1px solid red !important;}
      </style>   

<script type="text/javascript">
  
function printData()
{
  //alert("ram");
   var divToPrint=document.getElementById("dataTable");
    divToPrint.border = 1;
        divToPrint.cellSpacing = 0;
        divToPrint.cellPadding = 2;
        divToPrint.style.borderCollapse = 'collapse';
   newWin= window.open("");

 
    newWin.document.write("<h4 align='center'>SANGYA CONSTRUCTION MANAGEMENT SYSTEM </h4>");
     newWin.document.write("<h5 align='center'>Expenses List </h5>");
      $('tr').children().eq(8).hide();
      $('table tr').find('td:eq(8)').hide();
   newWin.document.write(divToPrint.outerHTML);
   newWin.print();
    $('tr').children().eq(8).show();
    $('table tr').find('td:eq(8)').show();
   newWin.close();
}



$(document).ready(function() {
   
$(".approve").click(function(){ 
var rate=$(this).closest('tr').find(".price");
if(rate.val()!='')
{
var distance=parseInt($(this).closest('tr').find(".distance").text());
 
var id=$(this).attr("id");

$.ajax({
           url: 'approvework',
           type: 'post',
           data:{'id':id,'rate':rate.val(),'distance':distance,"_token":"<?php echo e(csrf_token()); ?>"},
           dataType: 'json',
           success: function(response){
             reload.location();
              

           },error:function(error){

           }

  });

}else{
  alert("Enter the amount");
  $(this).closest('tr').find(".price").css("border","1px solid red");
}


});
 });




</script>

<?php
$data=App\Project::all()->pluck('id','projectnm');

?>

<div class="col-sm-12">
 
<form action="<?php echo e(url('worklist')); ?>" method="post">
  <?php echo csrf_field(); ?>
  <div class="card-body">
<div class="row" style="border:1px solid">

  <div class="col-sm-3" >
    <label>date</label>
   <input type="text" name="date" class="datepicker-here form-control" data-language="en"/><br/>
 </div>

 <div class="col-sm-3" >
    <label>project</label>
<select name='project_id' class="form-control">
    <option value=''>-- Select--</option>
<?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
 <option value="<?php echo e($value); ?>"><?php echo e($key); ?></option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
</div>

 
<div class="col-sm-3" >
    <label>Status</label>
<select name='is_approved' class="form-control">
    <option value=''>-- Select--</option>
    <option value="0">Pending</option>
    <option value="1">Approved</option>
    <option value="2">Disapproved</option>

</select>
</div>


<div class="col-sm-3" >
     <label>&nbsp;</label><br/> 
<input type="submit" value="Find" class="btn btn-success" />
</div>
  </div>

 </form>
</div>
 
<div class="row"><br/>
<div class="col-sm-6 text-left">
<a href="<?php echo e(url('addwork')); ?>"  >Add work+ </a>
</div>
<div class="col-sm-6  text-right">
<button onclick="printData()" class="btn btn-primary">Print </button>
</div>
</div><br/>

 <?php $__currentLoopData = ["success","error"]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php if(Session::has($status)): ?>
<div class="alert alert-<?php echo e($status); ?> alert-dismissible">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong><?php echo e($status); ?>!</strong> <?php echo e(Session::get($status)); ?> action.
</div>
<?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  <?php 
//dd($Explist);




//dd($amountlist);

  ?>     


  <div class="card mb-4">
<div class="card-header">
<i class="fas fa-table mr-1"></i>
     Amount List
</div>  
 <div class="card-body">  
<div class="table-responsive">
<table  class="table table-bordered" id="dataTable" width="100%" cellspacing="0" >
<thead>
<tr>
  
  <th>Sr No.</th> <th>Project</th> <th>Person</th> <th>Category Name</th> <th>Subcategory Name</th> <th>type</th> <th>Work</th> <th>distance</th>  <th>unit</th>   <th>Date</th><th>Amount/rate</th> <th>Action</th>
</tr>
</thead>
<tbody>
<?php $i=0; ?>
<?php $__currentLoopData = $worklist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $exp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

<tr>
  <td><?php echo e(++$i); ?></td>

<td><?php echo e($exp->projectnm); ?></td>
  <td><?php echo e($exp->name); ?></td>

  <td><?php echo e($exp->categorynm); ?></td>
  <td><?php echo e($exp->subcategorynm); ?></td>
  <td><?php echo e($exp->type); ?></td>
  <td><?php echo e($exp->work); ?></td>
  <td class='distance'><?php echo e($exp->distance); ?></td>
  <td class='distance'><?php echo e($exp->unit); ?></td>
  <td><?php echo e($exp->date); ?></td>
  <td>
<?php if($exp->is_approved=='0'): ?>
    <input type="text" placeholder="Amount/meter" class="price" /> 
<?php else: ?>
   <?php if($exp->is_approved=='1'): ?>
<?php echo e($exp->total_amount); ?> / <?php echo e($exp->rate); ?>

<?php else: ?>
   <span style="color:red;">rejected</span>
  <?php endif; ?>
<?php endif; ?>
  </td>

  <td> 
  <?php if($exp->is_approved==0): ?>  
   <input type="button" value="Approve" id="<?php echo e($exp->id); ?>" class="approve btn btn-primary btn-sm"/>  
   <a href="<?php echo e(url('disapproved',['id'=>$exp->id,'work'])); ?>" class="btn btn-danger btn-sm">Disapprove </a>
   

   <?php else: ?>
   <?php echo e(($exp->is_approved==1)?"Approved":(($exp->is_approved==2)?"Rejected":"Pending")); ?>

   <?php endif; ?>
    
  </td>

</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>

</table>
</div>
 </div>
</div>
 </div>


     <?php $__env->stopSection(); ?>
             
<?php echo $__env->make('layout/master2', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\sangya\resources\views/worklist.blade.php ENDPATH**/ ?>