<?php 
include 'head.php';
include 'nav.php';

$bdd=new DB();
?>
<style>
.btnCursor{
	cursor: default;
}
.row .col-md-4{
	padding-top:5px;
}
</style>
<div class="content-wrapper">
	<section class="content-header">
		<h1 style="text-align:center">Dashboard</h1>
    </section>
	<div class="row" style="margin-top:25px"></div>
    <section class="content"> 
		<div class="row">
		<?php if($_SESSION['ticl_user_type']=="admin" || in_array('Add-Truck', $userPermissions)){ ?>
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-primary btn-lg btnCursor">
							<a href="AddTruck.php" class="btn btn-app btn-success">
								<i class="fa fa-truck"></i> Add Truck Record
							</a>               
						</button>               
					</div>
				</div>
			</div>
		<?php }
		if($_SESSION['ticl_user_type']=="admin" || in_array('PDI', $userPermissions)){
		?>
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-success btn-lg btnCursor">
							<a href="InGodown.php" class="btn btn-app btn-success">
								<?php
								$values=array();
								$row = $bdd->getOne("SELECT count(TruckId) as total FROM truckno WHERE Status='pending'",$values);
								?>
								<span class="badge bg-purple"><?php echo $row['total'];?></span>
								<i class="fa fa-archive"></i> PDI
							</a>               
						</button>
					</div>
				</div>
			</div>
		<?php }
		if($_SESSION['ticl_user_type']=="admin" || in_array('Completed', $userPermissions)){ ?>
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-warning btn-lg btnCursor">
							<a href="Completed.php" class="btn btn-app btn-success">
								<?php
								$values=array();
								$row = $bdd->getOne("SELECT count(TruckId) as total FROM truckno WHERE Status='completed'",$values);
								?>
								<span class="badge bg-purple"><?php echo $row['total'];?></span>
								<i class="fa fa-upload"></i> Completed
							</a>               
						</button>
					</div>
				</div>
			</div>
		<?php } if($_SESSION['ticl_user_type']=="admin" || in_array('Approved', $userPermissions)){ ?>
		<!--</div>
		
		<div class="row" style="margin-top:10px">-->
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-primary btn-lg btnCursor">
							<a href='approved?type=approved' class="btn btn-app btn-success">
								<?php
								$values=array();
								//$row = $bdd->getOne("SELECT COUNT(Id) AS total FROM truckdetails WHERE FIND_IN_SET(TruckNo,(SELECT GROUP_CONCAT(TruckId) FROM `truckno` WHERE show_status='ok'))",$values);
								$row = $bdd->getOne("SELECT count(td.Id) AS total FROM truckdetails as td WHERE td.select_status ='approved'",$values);
								?>
								<span class="badge bg-purple"><?php echo $row['total'];?></span>
								<i class="fa fa-thumbs-up"></i> Approved
							</a>               
						</button>
					</div>
				</div>
			</div>
			<?php } if($_SESSION['ticl_user_type']=="admin" || in_array('Selected', $userPermissions)){ ?>
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-success btn-lg btnCursor">
							<a href='approved?type=selected' class="btn btn-app btn-success">
								<?php
								$values=array();
								$row = $bdd->getOne("SELECT count(Id) as total FROM truckdetails WHERE select_status='selected'",$values);
								?>
								<span class="badge bg-purple"><?php echo $row['total'];?></span>
								<i class="fa fa-check-square"></i> Selected
							</a>               
						</button>
					</div>
				</div>
			</div>
			<?php } if($_SESSION['ticl_user_type']=="admin" || in_array('Truck-Details', $userPermissions)){ ?>
			<div class="col-md-4 col-sm-12 col-xs-12">
				<div class="card">
					<div class="card-body">
						<button type="button" class="btn btn-block btn-warning btn-lg btnCursor">
							<a href="TruckDetail.php" class="btn btn-app btn-success">
								<?php
								$values=array();
								$row = $bdd->getOne("SELECT count(TruckId) as total FROM truckno WHERE Status='approved'",$values);
								?>
								<span class="badge bg-purple"><?php echo $row['total'];?></span>
								<i class="fa fa-list"></i> Truck Details
							</a>               
						</button>               
					</div>
				</div>
			</div>
		<?php } ?>	
		</div>

    </section>
</div>

<?php
$bdd->disconnect();
include 'footer.php';
?>

