<?php
include(''. $config['LocalPath'] . '/includes/.sql_con.php');
?>
<div class="row">
  <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
    <div class="card card-mini">
      <div class="card-header">
        <div class="card-title"><b>Asset Overview</b></div>
        <ul class="card-action">
          <li>
            <a href="/">
              <i class="fa fa-refresh"></i>
            </a>
          </li>
        </ul>
      </div>
      <div class="card-body no-padding table-responsive">
        <table class="table card-table">
          <thead>
            <tr>
              <th><b>Asset</b></th>
              <th class="right"><b># of Tasks Assigned to Asset</b></th>
              <th><b>Task Status</b></th>
            </tr>
          </thead>
          <tbody>
<?php


$device_result = mysql_query('SELECT DISTINCT(SERVICE_ID), SERVICE_NAME FROM TASK');

while ($row=mysql_fetch_array($device_result)){
	$device_name=$row['SERVICE_NAME'];
	$service_id=$row['SERVICE_ID'];

$task_count = file_get_contents(''.$config['URL']. '/api/get_device_task_count.php?id=' . $service_id . '');
$tasks_completed = file_get_contents('' .$config['URL']. '/api/get_device_tasks_completed.php?id=' . $service_id . '');
$tasks_due = file_get_contents('' .$config['URL']. '/api/get_device_tasks_due.php?id=' . $service_id . '');
$tasks_overdue = file_get_contents('' .$config['URL']. '/api/get_device_tasks_overdue.php?id=' . $service_id . '');
	
?>
            <tr>
              <td><?php echo $device_name;?></td>
              <td class="right"><?php echo $task_count;?> </td>
              <td><span class="badge badge-success badge-icon"><i class="fa fa-check" aria-hidden="true"></i><span><b> <?php echo $tasks_completed;?> </b>&nbsp; Completed</span></span>&nbsp;&nbsp;
			<span class="badge badge-warning badge-icon"><i class="fa fa-warning" aria-hidden="true"></i><span><b> <?php echo $tasks_due;?></b>&nbsp;  Due</span></span>&nbsp;&nbsp;
			<span class="badge badge-danger badge-icon"><i class="fa fa-warning" aria-hidden="true"></i><span><b> <?php echo $tasks_overdue;?></b>&nbsp;  Over Due</span></span>&nbsp;&nbsp;
	      </td>
            </tr>
<?php
}
?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
