csrtechnew.ohctech.in/invenort_checklist_pdf.php
2025-04-14 13:28:09 +05:30

318 lines
11 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('pdf_header_reverse.php');
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
.btn {
background-color: #4CAF50;
border-radius: 5%;
/* Green */
border: none;
color: white;
padding: 5px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 4px 2px;
cursor: pointer;
}
@media print {
#printPageButton {
display: none;
}
}
#myTable td {
border: groove;
}
</style>
<?php include('pdf_ohc_header.php')?>
<!-- ------------------------- -->
<?php
$cat= $_POST["inventory_cat"];
error_log("PARA::".$cat);
if($_POST["inventory_cat"]!='AMB_CHECK' ) {
$type=$_POST["inventory_type"];
}
else {$type =$_POST["inventory_type2"];}
$db_new_date="";
$last_day="";
$m=0;
$y=0;
$selectedParamMonth = $_REQUEST['param_month'];
// echo "month......"+$selectedShiftMonth;
$selectedParamYear = $_POST['param_year'];
//echo "year.........".$selectedShiftYear;
if(isset($selectedParamYear)&& $selectedParamYear!="" && isset($selectedParamMonth) && $selectedParamMonth!=""){
$last_day = date("t-m-Y", strtotime("".$selectedParamYear."-".($selectedParamMonth+1)."-01"));
// echo "last:date".$last_day;
}
else{
$last_day = date('t-m-Y');
//echo "last:date1".$last_day;
}
$m = date('m',strtotime("".$selectedParamYear."-".($selectedParamMonth+1)."-01"));
////echo "month det".$m;
$y = date('Y',strtotime("".$selectedParamYear."-".($selectedParamMonth+1)."-01"));
//echo "year det".$y;
?>
<script>
var jsonArrayParamData = <?php echo json_encode($param_data); ?>;
</script>
<style>
#modal-add-ailment {
overflow-y: scroll;
}
#myTable thead td {
font-size: 12px;
font-weight: bold;
}
#myTable td {
height: 50px;
border: groove;
text-align: center;
}
</style>
<table width="100%">
<td>
<h1 style="text-align:center;"><?php
if($cat=='INVENTORY'){ echo "INVENTORY ".$type;}
else{echo "AMBULANCE ".$type;}
?>- <span style="color:crimson; ">
<?= date("F", mktime(0, 0, 0, $m, 10)); ?> ( <?= $y ?> )
</h1>
</td>
<td>
<button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button>
</td>
</table>
<table width="100%" style="margin-top: 30px; border: groove;" id="myTable" class="table table-bordered order-list">
<thead>
<tr>
<td></td>
<td>Date</td>
<?php
for($j=1; $j<=$last_day; $j++){
$new_date = $j."-".$m."-".$y;
$day = date('D', strtotime($new_date));
?>
<td><?php echo $j?></td>
<?php }?>
</tr>
<tr>
<td>Sr. No.</td>
<td>Description</td>
<?php
// $last_day = date('t-m-Y');
// $m = date('m');
// $y = date('Y');
for($k=1; $k<=$last_day; $k++){
$new_date = $k."-".$m."-".$y;
$day = date('D', strtotime($new_date));
?>
<td width='3px'><?php echo $day?></td>
<?php }?>
</tr>
</thead>
<tbody>
<?php $count = 1;
$sub_count=1;
$ohc="SELECT ohc_type_id from ohc_type where ohc_type_name = '".$type."' and ohc_category='".$cat."' ";
$results_ohc = mysqli_query($conn,$ohc);
$row_ohc= mysqli_fetch_array($results_ohc);
error_log("ohc Id".$row_ohc['ohc_type_id']);
$i = 1;
$query = "select stock_issue_id from stock_issue where ohc_location_id = '".$row_ohc['ohc_type_id']."' ";
error_log("PARAMS::".$query);
$result = @mysqli_query($conn,$query);
while( $row = mysqli_fetch_assoc($result)){
$row_issue_item_id= getTableFieldValue('stock_issue_items','stock_issue_item_id','stock_issue_id',$row['stock_issue_id']);
$item_desc="";
$sql_issue_items="select * from stock_issue_items where stock_issue_item_id='".$row_issue_item_id."'";
$results_issue_items = mysqli_query($conn,$sql_issue_items);
while ($row_issue_items= mysqli_fetch_assoc($results_issue_items)) {
if($row_issue_items['issue_qty'] != 0){
$item_desc = $item_desc.' <p> '.getItemWithFormName($row_issue_items['item_id'])." ";
//$item_desc = $item_desc.getTableFieldValue('tbl_items','item_name','item_id',$row_issue_items['item_id'])."<br/>";
$item_unit_id=getTableFieldValue('tbl_items','unit_id','item_id',$row_issue_items['item_id']);
$item_unit =getTableFieldValue('unit_master','unit_name','unit_id',$item_unit_id);
// $issuby = getTableFieldValue('patient_master' , 'patient_name' , 'id' , $row_issue_items['stock_issue_emp_id']);
error_log("Userid " . $issuby);
$item_desc=$item_desc.'<b> Qty: '.$row_issue_items['issue_qty'].' '.$item_unit.'</b>';
$item_desc=$item_desc."</p>";
}
else{
$item_desc = $item_desc.' <p> '.getItemWithFormName($row_issue_items['item_id'])." ";
//$item_desc = $item_desc.getTableFieldValue('tbl_items','item_name','item_id',$row_issue_items['item_id'])."<br/>";
$item_unit_id=getTableFieldValue('tbl_items','unit_id','item_id',$row_issue_items['item_id']);
$item_unit =getTableFieldValue('unit_master','unit_name','unit_id',$item_unit_id);
// $issuby = getTableFieldValue('patient_master' , 'patient_name' , 'id' , $row_issue_items['stock_issue_emp_id']);
error_log("Userid " . $issuby);
// $item_desc=$item_desc.'<b>'.$item_unit.'</b>';
$item_desc=$item_desc."</p>";
}
error_log('ttt'.$row_issue_items['stock_issue_item_id']);
?>
<?php if($row_issue_items['issue_qty'] == 0){
$sub_count=1;?>
<tr>
<td style="border:hidden; text-align: right" colspan="10">
<h2><?= $count.". "?></h2>
</td>
<td style="border:hidden; text-align: left" colspan="50">
<h2><?=$item_desc?></h2>
</td>
</tr>
<?php } else {?>
<tr width='80%'>
<td><?php echo $sub_count;
$sub_count++;?></td>
<td style="text-align: left"><?php echo $item_desc; ?></td>
<?php } ?>
<input type="hidden" name="param_id<?php echo $i?>" id="param_id<?php echo $i?>"
value="<?php echo $row_issue_items['stock_issue_item_id'];?>" />
<?php $status_id="";
$param_data =array();
$query1 = "select status_id,param_date, param_id, param_status from inventory_parameters_status where month(param_date)='". $m."' and year(param_date)='".$y."' ";
error_log("PARAMETER QUERY." .$query1);
//echo "selet query......................................".$query1 ;
$result1 = @mysqli_query($conn,$query1);
while( $row_param = @mysqli_fetch_assoc($result1)){
//echo "adarsh";
$status_id=$row_param['status_id'];
$key=$row_param['param_id'].'_'.$row_param['param_date'];
//echo "key:".$key;
$value=$row_param['param_status'];
//echo "value:".$value;
$param_data[$key]=$value;
// array_push($shift_data[$key], $value);
?>
<input type="hidden" name="status_id<?php echo $i?>" id="status_id<?php echo $i?>"
value="<?php echo $status_id?>" />
<?php }?>
<?php
$db_new_date="";
// $last_day = date('t-m-Y');
//$m = date('m');
// $y = date('Y');
for($k=1; $k<=$last_day; $k++){
$new_date = $k."-".$m."-".$y;
$db_new_date = $y."-".$m."-".$k;
$day = date('D', strtotime($new_date));
if($k<10){
$db_new_date = $y."-".$m."-0".$k;
}
?>
<?php
//echo "key:".$row['id'].'_'.$db_new_date;
?>
<?php if($row_issue_items['issue_qty'] != 0){?>
<td>
<div style="width:25px;">
<input type="checkbox" style="margin-left:5px;max-width:50%;"
id="param_status_<?php echo $i?>_<?php echo $k?>"
name="param_status_<?php echo $i?>_<?php echo $k?>[]" />
<script>
document.addEventListener("DOMContentLoaded", () => {
<?php $key= $row_issue_items['stock_issue_item_id'].'_'.$db_new_date;?>
var existingParamValues<?php echo $i?>_<?php echo $k?> =
"<?php echo $param_data[$key]?>"
document.getElementById(
"param_status_<?php echo $i?>_<?php echo $k?>"
).value =
existingParamValues<?php echo $i?>_<?php echo $k?>;
if (document.getElementById(
"param_status_<?php echo $i?>_<?php echo $k?>"
).value == "1" || document.getElementById(
"param_status_<?php echo $i?>_<?php echo $k?>"
).value == "on") {
document.getElementById(
"param_status_<?php echo $i?>_<?php echo $k?>"
).checked = true;
}
});
</script>
<?php } ?>
</div>
</td>
<input type="hidden" name="param_date_<?php echo $i?>_<?php echo $k?>"
id="param_date_<?php echo $i?>_<?php echo $k?>" value="<?php echo $new_date?>" />
<?php }?>
</tr>
<?php
if($row_issue_items['issue_qty'] == 0){
$count++;
}
$i++;
}};
?>
</table>
</body>
<script>
document.addEventListener("DOMContentLoaded", () => {
window.print();
});
</script>