<?php $__env->startSection("content"); ?>
<div class="row">
  <div class="col-sm-12">
    <div class="container">
      <div class="top-content">
        <div class="right-content">
          <div class="title">
            <h2>Expenses</h2>
            <p>( Period: <a>2015 Q4</a> <i class="fa fa-info-circle" data-toggle="tooltip" data-placement="top" title="Timeline Q4"></i>)</p>
            <!--<div class="dropdown">
              <button href="#" class="btn-text dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Sort by Date Created <span class="caret"></span></button>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li><a href="#">Separated link</a></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </div>-->
          </div>
          <div class="tasks">
            <button class="btn" onclick="window.location='/expenses/create'">Add New Expense</button>
            <div class="dropdown">
              <select class="form-control chosen-select" onchange="change_period($(this).val())">
              <option value="all">Choose Budget Period</option>
              <?php if(count($periods)>0): ?>
              <?php foreach($periods as $row): ?>
              <option value="<?php echo e($row->id); ?>" <?php if($period==$row->id){echo 'selected="selected"';} ?>><?php echo e(\App\Providers\Common::format_date($row->from)); ?> to <?php echo e(\App\Providers\Common::format_date($row->to)); ?></option>
              <?php endforeach; ?>
              <?php endif; ?>
            </select>
            </div>
          </div>
        </div>
      </div>
      <div class="main-content">
        <div class="sidebar">
          <nav>
            <ul class="navigations">
              <li <?php if($status=="all") echo 'class="active"'; ?>> <a href="expenses?department=<?php echo e($department); ?>&status=all&period=<?php echo e($period); ?>&page=<?php echo e($page); ?>">All Expenses</a> </li>
              <li <?php if($status=="Pending") echo 'class="active"'; ?>> <a href="/expenses?department=<?php echo e($department); ?>&status=Pending&period=<?php echo e($period); ?>&page=<?php echo e($page); ?>">Pending</a> </li>
              <li <?php if($status=="Approved") echo 'class="active"'; ?>> <a href="/expenses?department=<?php echo e($department); ?>&status=Approved&period=<?php echo e($period); ?>&page=<?php echo e($page); ?>">Approved</a> </li>
              <li <?php if($status=="Denied") echo 'class="active"'; ?>> <a href="/expenses?department=<?php echo e($department); ?>&status=Denied&period=<?php echo e($period); ?>&page=<?php echo e($page); ?>">Denied</a> </li>
              <!--<li> <a href="">Overdue</a> </li>
              <li> <a href="">Owned</a> </li>
              <li> <a href="">Paid</a> </li>
              <li> <a href="">Excess Cash</a> </li>-->
            </ul>
          </nav>
          <div class="departments">
            <select class="form-control chosen-select" data-placeholder="Departments" onchange="change_department($(this).val())">
              <option value="all">All Departments</option>
              <?php if(count($categories)>0): ?>
              <?php foreach($categories as $row): ?>
              <option value="<?php echo e($row->id); ?>" <?php if($department==$row->id) echo 'selected="selected"'; ?>><?php echo e($row->name); ?></option>
              <?php endforeach; ?>
              <?php endif; ?>
            
            </select>
          </div>
          <!--<div class="approver">
            <select class="form-control chosen-select" data-placeholder="Approver">
              <option></option>
              <option>Dominic Temple</option>
              <option>Mark Essien</option>
              <option>Mihai Daraban</option>
            </select>
          </div>--> 
          <!--<div class="requester">
            <select class="form-control chosen-select" data-placeholder="Requester">
              <option></option>
              <option>Dominic Temple</option>
              <option>Mark Essien</option>
              <option>Mihai Daraban</option>
            </select>
          </div>--> 
        </div>
        <div class="main">
          <div class="expense-table">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th></th>
                  <th>Requests</th>
                  <th>$</th>
                  <th>Approvers</th>
                  <th>Details</th>
                </tr>
              </thead>
              <tbody>
              <form role="form" action="/expenses/edit" method="post">
              <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
              <?php if(count($expenses)>0): ?>
              <?php $i=0; ?>
              <?php foreach($expenses as $row): ?>
              <?php
                  $color = "purple";
                  if($row->status=="Pending"){ $color = "yellow"; }
                  if($row->status=="Approved"){ $color = "green"; }
                  if($row->status=="Denied"){ $color = "red"; }
                ?>
              <tr class="border-<?php echo e($color); ?>">
                <td class="select"><input type="checkbox" name="expenses[]" value="<?php echo e($row->id); ?>" /></td>
                <td class="requests"><h5><?php echo e($row->item); ?></h5>
                  <p>From: <span><?php echo e($row->user); ?></span>, Created: <span><?php echo e(\App\Providers\Common::format_date($row->created_at)); ?></span> </p>
                  
                  <!--<p><span class="red">Late</span> by <span>Nosa Obaseki</span></p>--></td>
                <td class="amount"><p><?php echo e(\App\Providers\Common::format_currency($row->budget)); ?></p>
                  <span class="overdue bg-<?php echo e($color); ?>"><?php echo e($row->status); ?></span></td>
                <td class="approvers">
                <?php if($row->approver!=""): ?>
                <div class="group"> <p align="center"><img src="/uploads/<?php echo e($row->approver_logo); ?>" width="20px" /></p>
                    <p><?php echo e($row->approver); ?></p>
                </div>
                <?php endif; ?>
                </td>
                <td class="details"><h5><?php echo e($row->category); ?></h5>
                  <p><span><?php echo e(\App\Providers\Common::format_currency($row->price)); ?></span> requested</p>
                  <p class="green"><span><?php echo e(\App\Providers\Common::format_currency($row->budget-$row->price)); ?></span> Left</p></td>
              </tr>
              <?php if($i==count($colors)-1){$i=-1;} $i++; ?>
              <?php endforeach; ?>
              <?php endif; ?>
                </tbody>
              
            </table>
          </div>
          <nav>
            <div class="page-details"> <?php echo $expenses->render(); ?> </div>
            <?php if(Auth::user()->role!=3): ?>
            <div class="status-trigger">
              <button class="btn btn-danger" name="status" value="Denied" type="submit">Deny</button>
              <button class="btn btn-success" name="status" value="Approved" type="submit">Approve</button>
            </div>
            <?php endif; ?>
          </nav>
        </div>
        </form>
      </div>
    </div>
  </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection("footer"); ?> 
<script>
	function change_department(id){
		var url = '/expenses?department='+id+'&status=<?php echo e($status); ?>&period=<?php echo e($period); ?>&page<?php echo e($page); ?>';
		window.location = url;
	}
	function change_period(id){
		var url = '/expenses?department=<?php echo e($department); ?>&status=<?php echo e($status); ?>&period='+id+'&page<?php echo e($page); ?>';
		//var url = '/budgets?department=<?php echo e($department); ?>&period='+id;
		window.location = url;
	}
</script> 
<?php $__env->stopSection(); ?> 
<?php echo $__env->make("app", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>