<?php $__env->startSection("content"); ?>
<div class="row">
  <div class="col-sm-12">
    <div class="top-content">
      <div class="left-content">
        <div class="title" style="width: 458px;">
          <h2>Budgets</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>
        <div class="tasks" style="width: 655px;">
          <button class="btn btn-primary" onclick="window.location='<?php echo e(URL::asset('/')); ?>budgets/create'">Add New Budget</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>
         <!-- <button class="btn btn-primary" onclick="window.location='/budgets/periods'">Depart. & Periods</button> -->
        </div>
      </div>
    </div>
    <div class="main-content">
      <div class="sidebar align">
        <?php if(count($categories)>0): ?>
        <?php $i=0; ?>
        <?php foreach($categories as $row): ?>
        <?php 
			$class = (Input::get('department')==$row->id ? "departs-group bg-{$colors[$i]}" : "departs-under border-{$colors[$i]}");
			$display = (Input::get('department')==$row->id ? "display:none;" : "display:block;");
			$active = (Input::get('department')==$row->id ? "true" : "false");
		?>
        <a href="<?php echo e(URL::asset('/')); ?>budgets?department=<?php echo e($row->id); ?>&period=<?php echo e($period); ?>" style="display:block;">
        <div class="<?php echo e($class); ?> departs" data-theme="<?php echo e($colors[$i]); ?>" data-type="<?php echo e($active); ?>">
          <p><?php echo e($row->name); ?></p>
          <p style="<?php echo e($display); ?>"><?php echo e(\App\Providers\Common::format_currency($row->from)); ?>/<?php echo e(\App\Providers\Common::format_currency($row->total)); ?></p>
          <p style="<?php echo e($display); ?>">Spent</p>
        </div>
        </a>
        <?php if($i==count($colors)-1){$i=-1;} $i++; ?>
        <?php endforeach; ?>
        <?php endif; ?>
        <br />
      </div>
      <div class="main">
        <div class="budget-table">
          <table class="table table-bordered tbl-border">
            <thead>
              <tr>
                <th Class="tbl-heading">Budget Item</th>
                <th Class="tbl-heading">Unit</th>
                <th Class="tbl-heading">Quantity</th>
                <th Class="tbl-heading">Budget</th>
              </tr>
            </thead>
            <tbody>
            
            <?php if(count($budgets)>0): ?>
            <?php foreach($budgets as $row): ?>
            <tr>
              <td class="requests"><h5><!--<a href="">--><?php echo e($row->item); ?><!--</a>--></h5>
                <p>Created: <span>2 days ago</span> </p>
                <p>By <span class="username"><?php echo e($row->user); ?></span></p></td>
              <td class="amount"><p><?php echo e(\App\Providers\Common::format_currency($row->unit)); ?></p></td>
              <td class="approvers"><?php echo e($row->quantity); ?></td>
              <td class="details"><p><?php echo e(\App\Providers\Common::format_currency($row->budget)); ?></p></td>
            </tr>
            <?php endforeach; ?>
            <?php endif; ?>
              </tbody>
            
          </table>
        </div>
        <?php if(count($budgets)>0): ?>
        <div class="total-things">
          <div class="title">Budget Information</div>
          <div class="details">
            <p>Total budget: <span><?php echo e(\App\Providers\Common::format_currency($info->total)); ?></span></p>
            <p>Spent from budget: <span class="redd"><?php echo e(\App\Providers\Common::format_currency($info->from)); ?></span></p>
            <p>Spent outside budget: <span class="redd"><?php echo e(\App\Providers\Common::format_currency($info->outside)); ?></span></p>
          </div>
        </div>
        <?php else: ?>
        <h4 align="center">No Item Found.</h4>
        <?php endif; ?>
      </div>
    </div>
  </div>
</div>
<?php $__env->startSection("footer"); ?>
<style>
	.sidebar a, 
	.sidebar a:hover{
		text-decoration:none; 
		color:#51595e;
	}
</style>
<script>
	function change_period(id){
		var url = '<?php echo e(URL::asset('/')); ?>budgets?department=<?php echo e($department); ?>&period='+id;
		window.location = url;
	}
</script>

<?php $__env->stopSection(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make("app", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>