<?php

require_once 'pdf.php';

 

 include('db_con.php');

 if (isset($_SESSION['user_id'])) {

    $user_type = $_SESSION['user_type'];

    $user_id = $_SESSION['user_id'];

    $user_name = $_SESSION['user_name'];

    $branch_id = $_SESSION['branch_id'];

    $branch_name = $_SESSION['branch_name'];

    $store_id = $_SESSION['store_id'];

    $store_name = $_SESSION['store_name'];

}else{

  header('Location: login');

  die();

}

date_default_timezone_set('Asia/Karachi');

 $dated = date('d-m-Y h:i a');

 

 $from_store =$_GET['to_store']; 

 $to_store = $_GET['from_store'];

 $item_status = $_GET['item_status'];

  $statement = $connect->prepare("select store_name from store where store_id = '".$from_store."'

  ");

 $statement->execute();

 $from_store_name = $statement->fetchColumn();

 $statement = $connect->prepare("select store_name from store where store_id = '".$to_store."'

  ");

 $statement->execute();

 $to_store_name = $statement->fetchColumn();

$tot_qty= 0;
$tot_ctn = 0;

     

  $statement = $connect->prepare("

    select m.do_id,m.s_id,m.dated,m.description,s.store_name,

    CONCAT(i.item_name,' ',t.type_name, ' ' ,b.brand_name, ' ', l.color_name) as item_name,d.ctn,d.qty,d.item_status from do m,do_detail d,items i, item_brand b,item_type t,item_color l,store s where i.brand_id=b.brand_id and i.color_id=l.color_id and t.type_id=i.type_id and m.do_id=d.do_id and d.item_no=i.item_id and m.store_id=s.store_id and d.store_id = '".$from_store."' and d.item_status LIKE '".$item_status."%' and m.store_id = :to_store

  ");

 $statement->execute(

  array(  

   ':to_store'       =>  $to_store

  )

 );

 $result = $statement->fetchAll();

 ?>

 

 <!DOCTYPE html>

<html>

<head>

  <title>

  </title>

  <style>

* {

  font-size: 11px;

  font-family: arial;

}

  .rightside {text-align: right;}

  table td{   

    border-bottom: 1px solid gray;

  }

  .head_row {

    font-weight: bold;

  }

  thead td {

    font-weight: bold;

     border-bottom: 1px solid gray;

      border-top: 1px solid gray;

       background-color: :  gray;

  }

  .total {

    font-weight: bold;

  }

  table.head_table {

    font-weight: bold;

  }

  </style>

</head>

<body>

  

  <h3>Delivery Order Status as on : <?php echo $dated .$item_status;?></h3>

  <hr />

  <table width="100%" class="head_table">

  

  <tr>

  <td width="15%">From Store : </td><td width="20%"><?php echo $to_store_name;?></td>

  </tr>



  <tr>

  <td width="15%">To Store : </td><td width="20%"><?php echo $from_store_name;?></td>

  </tr>

  

  

  </table>

  <table width="100%" id="table_header">

  

<thead>

  <tr>

  <td width="5%">Sr</td>
  <td width="5%">S_ID</td>
  <td width="15%">Date</td>

  <td width="35%">Item Name</td>

  
<td width="10%" class="rightside">Ctn</td>
  <td width="10%" class="rightside">Qty</td>

  <td width="25%"class="rightside">Status</td>

  

 

  </tr>

  </thead>

  

  

  

<?php

$count = 0;

foreach($result as $row)

 {

  $qty = $row["qty"];
  $ctn = $row["ctn"];
  $tot_qty = $tot_qty + $qty;
  $tot_ctn = $tot_ctn + $ctn;

   $count = $count +1;

  

echo '

<tr>

  <td width="5%">'.$count.'</td>
  <td width="5%">'.$row["s_id"].'</td>
<td width="15%">'.$row["dated"].'</td>
<td width="35%">'.$row["item_name"].'</td>
<td width="10%" class="rightside">'.number_format($ctn, 0).'</td>
<td width="10%" class="rightside">'.number_format($qty, 2).'</td>

<td width="25%" class="rightside">'.$row["item_status"].'</td>

  

   

    

   </tr>

   ';

   

}

?>

<table width="100%">

<tr>

<td class="rightside" width="60%">Total :</td>

<td width="15%" class="rightside"><?php echo number_format($tot_qty, 2);?></td>

<td class ="rightside" width="25%"></td>

</tr>

</table>