<?php  
include('pdf_header.php');
//include('includes/config/config.php');
//include('includes/functions.php');
include('log_entry.php');
//include('pop_up_top.php');
?>
<!-- <link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" /> -->
<style>

</style>
<table width="100%">
    <tr>
        <div style="font-size:12px">
            <td width="25%" align="left"> Run Date :
                <?php  echo date("d-M-Y"); ?>
            </td>
            <td width="50%" align="center" style="font-size:20px"><strong>Oxygen Cylinder LIST</strong></td>
            <td width="25%" align="left"> User :
                <?php  echo $username ?>
            </td>
    </tr>
</table>
<br>
<table width="100%" border="1px solid black">
<?php  

$ohc_type = $_SESSION['current_ohcttype'];
$primary_ohc_type = getFieldFromTable('primary_ohc_id','ohc_type','ohc_type_id',$ohc_type);


if($primary_ohc_type){
	$ohc_type = $primary_ohc_type;
}else{

$ohc_type = $_SESSION['current_ohcttype'];
}
// $lote = getFieldFromTable('ohc_type_id','ohc_type','ohc_code','LOTE');
$child_ohcs = "SELECT ohc_type_id From ohc_type where primary_ohc_id = '$ohc_type'";

error_log("sql".$child_ohcs);

$child_ohcs_quiry = mysqli_query($conn,$child_ohcs);
$child_ids = array();
while($childs_ohcs = mysqli_fetch_array($child_ohcs_quiry)){
  // $child_ids[] = $childs_ohcs['ohc_type_id'];
  array_push($child_ids,$childs_ohcs['ohc_type_id']);
}

$all_ohc_ids = array_push($child_ids,$ohc_type);

$comma_separated_string = implode(",", $child_ids);


 $sql="select * from oxygen_cylinder_checklist where ohc_type_id in($comma_separated_string)";
 
 error_log("query: ".$sql);
 $result = @mysqli_query($conn,$sql);

  ?><tr bgcolor="#eeeeee">
        <th width="10%">Sr. No.</th>
        <th width="10%">Oxygen Kit No</th>
        <th width="6%">Type Of Cylinder</th>
        <th width="15%">Issued Date</th>
        <th width="15%">Pressure Reading</th>
        <th width="15%">Status</th>
    </tr><?php  
  $i=0;
while($row=@mysqli_fetch_array($result)){
      $i++;


  ?><tr>
        <td><?php echo $i?></td>
        <td><?php echo getFieldFromTable('oxygen_kit_no', 'oxygen_cylinder', 'id', $row['oxygen_cylinder_id'])?></td>
        <td><?php echo getFieldFromTable('type', 'oxygen_cylinder', 'id', $row['oxygen_cylinder_id'])?></td>
        <td><?php echo date_format(date_create($row['issue_date']),"d-M-Y") ?></td>
        <td><?php echo $row['pressure_reading']?></td>
        <td><?php echo $row['status']?></td>
    </tr><?php  
}
?>
</table>
<?php 
include('pdf_footer.php');
?>
<script>


</script>