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


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

<div style="position: relative; left: 50%;">

</div>


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

    <div class="card">
        <div class="card-header">
            <h3 class="card-title"><?php //List of expenses ?></h3>
            <br>



<?php 
$products = \App\expense_types::all();
?>

        <div class="row">
<?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <!-- ./col -->
        <div class="col-lg-3 col-xs-6">
          <!-- small box -->
          <div class="small-box bg-red">
            <div class="inner" style="text-align: center;">
              <h3>
                <?php
                  $s_accounts = \App\expenses::where('expense_id',$r->id)
				  
				  ->get();
                  $total_amount = 0;    

                  foreach($s_accounts as $r2)  {
                    $total_amount = $total_amount + $r2->expense_price;
                  }

                  echo number_format($total_amount);

                ?>
              </h3>

              <p><a href="<?php echo e(url('admin/expenses/')); ?>/<?php echo e($r->id); ?>" style="text-decoration: none; color: white; cursor: pointer;">اجمالي <?php echo e($r->title); ?></a></p>
            </div>
            <div class="icon">
              <i class="ion ion-stats-bars"></i>
            </div>
          </div>
        </div>

<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div> <!-- End of Row -->


        </div>

       




        <!-- /.card-header -->
        <div class="card-body">

<table style="">
    <tr>
        <td>
		
		
		<?php 
$last_shift = \App\shifts::orderby('id','desc')->first();
?>
<?php if($last_shift): ?>
    <?php if($last_shift->shift_end == null): ?> <!-- This means the shift is open -->
        <!-- If shift is open, show Close Shift button -->

                    <a href="<?php echo e(url('admin/expenses/create')); ?>" class="btn btn-primary">اضافة منصرف </a>

    <?php else: ?>
		
	        <form action="<?php echo e(url('/admin/shift/begin')); ?>" method="POST">
            <?php echo method_field('POST'); ?>
            <?php echo csrf_field(); ?>
            <button onclick="return confirm(' بداية الوردية ؟ ');" style="border: 0px; color:black; background:none; cursor:pointer;">
                <i class="fas fa-plus"></i>  بداية وردية   
            </button>
        </form>          
		
        <!-- If shift is closed, show Begin Shift button -->
    <?php endif; ?>
<?php endif; ?>




        </td>
        <td>
                    <a href="<?php echo e(url('admin/report_between')); ?>" class="btn btn-danger"> 
                        تقرير عن المنصرفات
                    </a>

        </td>
    </tr>
</table>


            <table id="example1" class="table table-bordered table-striped" style="">
                <thead>
                <tr>

                    <th>#</th>
                    <th>التاريخ</th>
                    <th>اسم المنصرف</th>
                    <th>قيمة المنصرف</th>
                    <th>تفاصيل</th>
                    <th>تعديل</th>
                    <th>حذف</th>
                </tr>
                </thead>
                <tbody>

<?php
$expenses = $expenses->where('shift_id','0');
?>
<?php $__empty_1 = true; $__currentLoopData = $expenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $expense): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                <tr>
                    <td> <?php echo e($expense->id); ?></td>
                    <td> <?php echo e($expense->expense_date); ?> </td>
                    <td><?php echo e($expense->expense_name); ?> </td>
                    <td> <?php echo e(number_format($expense->expense_price)); ?> </td>
                    <td> <?php echo e($expense->expense_note); ?> </td>


                    <td>
                        <a class="btn btn-info btn-sm" href="<?php echo e(url('/admin/expenses')); ?>/<?php echo e($expense->id); ?>/edit">
                            <i class="fas fa-pencil-alt">
                            </i>
                            تعديل
                        </a>
                    </td>

                    <td>
                        
                            <span class="btn btn-danger btn-sm" >
                                <form action="<?php echo e(url('/admin/expenses')); ?>/<?php echo e($expense->id); ?>" method="post">
                                    <?php echo method_field('DELETE'); ?>
                                    <button onclick="return confirm('هل انت متأكد ؟');" style="border: 0px; background:none; color: white">
                                        <i class="fas fa-trash"></i>
                                        حذف</button>
                                    <?php echo csrf_field(); ?>
                                </form>


                            </span>
                        
                    </td>
                </tr>

    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

    <tr>
       <div style="color: red; font-size: 18px; font-weight: bolder;">لايوجد بيانات</div>
    </tr>

                <?php endif; ?>










                </tbody>

            </table>
        </div>
        <!-- /.card-body -->
    </div>




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

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\php\pear\~\resources\views/admin/expenses/list.blade.php ENDPATH**/ ?>