<?php
	if($type=='client'){
		$title = trans('front.debt');
	}elseif($type=='supplier'){
		$title = trans('front.suppliersdebt');
	}
?>
<?php $__env->startSection('title',$title); ?>
<?php $__env->startSection('content'); ?>
	<!-- Content Header (Page header) -->
	<section class="content-header">
		<h1>
			<?php echo e($title); ?>

		</h1>
	</section>

	<!-- Main content -->
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
				
				<!-- /.box-header -->
					<div class="box-body">
						<table  id="dataList" class="table table-striped table-bordered" style="width: 100%">
							<thead>
							<tr>
								<th>#</th>
								<th><?php echo app('translator')->getFromJson('front.name'); ?></th>
								<th><?php echo app('translator')->getFromJson('front.telephone'); ?></th>
								<th><?php echo app('translator')->getFromJson('front.balance'); ?> </th>
								<th><?php echo app('translator')->getFromJson('front.Last Order'); ?></th>
								<th><?php echo app('translator')->getFromJson('front.Last Payment'); ?></th>
								<th><?php echo app('translator')->getFromJson('front.value'); ?></th>
                                <th></th>
							</tr>
							</thead>
							<tbody>
							<?php $__currentLoopData = $persons; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $person): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php

                                       if(!$person->balnce_text){
                                            continue;
                                       }
                                       $flag = false;
                                       $transDate = $person->last_transaction?:$person->last_order;
                                       if($transDate){
                                           $now = \Carbon\Carbon::now();
                                           $last_transaction = new \Carbon\Carbon($transDate);
                                           if($now->diffInDays($transDate)>=30){
                                               $flag = true;
                                           }
                                       }
                                ?>
								<tr class="<?php echo e($flag?'danger':''); ?>">
									<td><?php echo e($loop->iteration); ?></td>
									<td><?php echo e($person->name); ?></td>
									<td><?php echo e($person->mobile); ?></td>
                                    <td><?php echo $person->balnce_text; ?></td>
									<td><?php echo e($person->last_order); ?></td>
									<td><?php echo e($person->last_transaction); ?></td>
									<td><?php echo e($person->last_transaction_value); ?></td>
									<td class="actions">
										<a href="<?php echo e(route('persons.show',$person)); ?>" class="btn btn-warning btn-xs">
											<i class="fa fa-pencil fa-fw" aria-hidden="true"></i>
											<?php echo app('translator')->getFromJson('front.show'); ?>
										</a>
										<a data-toggle="modal" data-target="#myModal" href="<?php echo e(route('persons.addPayment',$person)); ?>" class="btn btn-success btn-xs">
											<i class="fa fa-money fa-fw" aria-hidden="true"></i>
											<?php echo app('translator')->getFromJson('front.Pay'); ?>
										</a>

									</td>
								</tr>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
							</tbody>
						</table>
					</div>
					<!-- /.box-body -->
				</div>
				<!-- /.box -->
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
	</section>
	<!-- /.content -->

	<div id="myModal" class="modal fade" style="overflow:hidden;" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title"></h4>
				</div>
				<div class="modal-body">
					<p class="text-center"><div class="fa-3x text-center"><i class="fa fa-cog fa-spin"></i>                    <?php echo app('translator')->getFromJson('front.Loading ....'); ?>                </div>                </p>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-outline pull-left" data-dismiss="modal">إغلاق</button>
				</div>
			</div>
		</div>
	</div>
<?php $__env->stopSection(); ?>

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