ESH/bio_medical_waste_report_new_pdf.php
2024-10-23 18:28:06 +05:30

97 lines
4.6 KiB
PHP

<?php
// include('pdf_header.php');
include ('includes/config/config.php');
include ('includes/functions.php');
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=excel_waste_list.xls');
?>
<body>
<table width="100%" cellspacing="0">
<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:15px"><strong>BIO WASTE GENERATION REPORT</strong></td>
<td width="25%" align="center"> User : <?php echo $username ?></td>
</tr>
<tr>
<?php
?>
<!-- <td colspan="2" ><strong>Filters Applied-</strong> <u>Range:</u><?php echo date_format(date_create($row1['waste_gen_date']),"d-M-Y ")?> </td> -->
</tr>
</table>
<table border="1" width="100%" cellspacing="0">
<?php
?>
<tr><td colspan="1"></td><td align="center" bgcolor="#f9e84e" colspan="3">YELLOW</td><td align="center" bgcolor="#eeeeee" colspan="3">WHITE</td><td align="center" bgcolor="#6495ed" colspan="3">BLUE</td><td bgcolor="#fa8072" align="center" colspan="3">RED</td></tr>
<strong><tr ><td align="left" width="8%">Date</td><td align="left" bgcolor="#f9e84e" width="8%">PLANT</td><td valign="top" width="8%" bgcolor="#f9e84e" align="left">MINES</td><td valign="top" bgcolor="#f9e84e" align="left" width="7%">TOTAL</td><td width="8%" bgcolor="#eeeeee" valign="top" align="left">PLANT</td><td bgcolor="#eeeeee" valign="top" align="left" width="8%">MINES</td><td width="7%" bgcolor="#eeeeee" valign="top" align="left">TOTAL</td><td bgcolor="#6495ed" width="8%" valign="top" align="left">PLANT</td><td width="8%" bgcolor="#6495ed" valign="top" align="left">MINES</td><td width="7%" bgcolor="#6495ed" valign="top" align="left">TOTAL</td><td width="8%" bgcolor="#fa8072" valign="top" align="left">PLANT</td><td width="8%" bgcolor="#fa8072" valign="top" align="left">MINES</td><td width="7%" bgcolor="#fa8072" valign="top" align="left">TOTAL</td></strong></tr>
<?php
$sum1=0;
$sum2=0;
$sum3=0;
$sum4=0;
$sum5=0;
$sum6=0;
$sum7=0;
$sum8=0;
$sum9=0;
$sum10=0;
$sum11=0;
$sum12=0;
$data="";
$year=$_POST['year'];
error_log($year);
for($i=1;$i<=12;$i++){
$month_name = date("F", mktime(0, 0, 0, $i, 10));
$query="select MONTHNAME(STR_TO_DATE($i, '%m')) as month,YEAR(waste_gen_date) as year,sum(plant_yellow_qty) as plant_yellow,sum(mines_yellow_qty) as mines_yellow,sum(yellow_qty_total) as yellow_qty,sum(plant_white_qty) as plant_white,sum(mines_white_qty) as mines_white,sum(white_qty_total) as white_qty,sum(plant_blue_qty) as plant_blue,sum(mines_blue_qty) as mines_blue,sum(blue_qty_total) as blue_qty,sum(plant_red_qty) as plant_red,sum(mines_red_qty) as mines_red,sum(red_qty_total) as red_qty from bio_medical_waste_new WHERE year(waste_gen_date) = $year AND month(waste_gen_date)=$i group by date_format(waste_gen_date, '%M') ORDER BY `year` ASC ";
error_log($query);
$result=mysqli_query($conn,$query);
$total=mysqli_num_rows($result);
error_log($total);
if($total!=0){
while($row=mysqli_fetch_assoc($result)){
$data.="<tr><td>".$row['month']."</td><td>".$row['plant_yellow']."</td><td>".$row['mines_yellow']."</td><td>".$row['yellow_qty']."</td><td>".$row['plant_white']."</td><td>".$row['mines_white']."</td><td>".$row['white_qty']."</td><td>".$row['plant_blue']."</td><td>".$row['mines_blue']."</td><td>".$row['blue_qty']."</td><td>".$row['plant_red']."</td><td>".$row['mines_red']."</td><td>".$row['red_qty']."</td></tr>";
$sum1+=$row['plant_yellow'];
$sum2+=$row['mines_yellow'];
$sum3+=$row['yellow_qty'];
$sum4+=$row['plant_white'];
$sum5+=$row['mines_white'];
$sum6+=$row['white_qty'];
$sum7+=$row['plant_blue'];
$sum8+=$row['mines_blue'];
$sum9+=$row['blue_qty'];
$sum10+=$row['plant_red'];
$sum11+=$row['mines_red'];
$sum12+=$row['red_qty'];
}}
else{
$data.="<tr><td>$month_name</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td><td>00</td></tr>";
}
}
error_log($sum10);
?>
<?php echo $data; ?>
<b>
<tr><td colspan="1" align="center">TOTAL</td><td><?php echo $sum1?></td><td><?php echo $sum2?></td><td><?php echo $sum3?></td><td><?php echo $sum4?></td><td><?php echo $sum5?></td><td><?php echo $sum6?></td><td><?php echo $sum7?></td><td><?php echo $sum8?></td><td><?php echo $sum9?></td><td><?php echo $sum10?></td><td><?php echo $sum11?></td><td><?php echo $sum12?></td></tr>
</b>
</table>
</body>