2024-10-16 19:18:52 +05:30
< ? php
include ( 'includes/config/config.php' );
include ( 'includes/functions.php' );
$from_date = date ( 'Y-m-d' , strtotime ( $_POST [ 'DiagDateFrom' ]));
$to_date = date ( 'Y-m-d' , strtotime ( $_POST [ 'DiagDateTo' ]));
error_log ( " from data " . $from_date . " to date " . $to_date );
$ohc_id = $_SESSION [ 'current_ohcttype' ];
$ailment_id = $_REQUEST [ 'ailment_id' ];
if ( count ( $ailment_id ) != 1 ) {
foreach ( array_keys ( $ailment_id , 'ALL' ) as $key ) {
unset ( $ailment_id [ $key ]);
}
}
error_log ( '$ailment_id ' . print_r ( $ailment_id , true ));
?>
< link href = " includes/css-js/admin.css " rel = " stylesheet " type = " text/css " />
< style >
@ page {
margin : 15 px ;
}
. btn {
background - color : #4CAF50;
border - radius : 5 % ;
/* Green */
border : none ;
color : white ;
padding : 5 px 8 px ;
text - align : center ;
text - decoration : none ;
display : inline - block ;
font - size : 12 px ;
margin : 4 px 2 px ;
cursor : pointer ;
}
@ media print {
#printPageButton {
display : none ;
}
}
</ style >
< body >
< ? php include ( 'pdf_ohc_header.php' ); ?>
< table width = " 100% " >
< tr >
< td style = " font-size: 15px; " >< strong style = " margin-left: 400px " > Diagnosis Wise Opd Report </ td >
</ tr >
< tr >
< td align = " left " style = " font-size: 12px " >< strong > From :
2024-11-19 09:59:09 +05:30
< ? php echo date ( " d-M-Y " , strtotime ( $from_date )); ?> To:
< ? php echo date ( " d-M-Y " , strtotime ( $to_date )); ?>
2024-10-16 19:18:52 +05:30
</ strong ></ td >
< td align = " right " style = " font-size: 15px " >< button align = " center " id = " printPageButton " class = " btn btn-success " onClick = " window.print(); " > Print </ button ></ td >
</ tr >
</ table >
< table border = " 1 " width = " 100% " cellspacing = " 0 " >
< ? php
foreach ( $ailment_id as $key => $ailment ) {
if ( $ailment == 'ALL' ) {
$sql = " SELECT count(*) as total FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id=' " . $ohc_id . " ' and a.ailments_new!='' and date(a.appointment_date) BETWEEN ' $from_date ' and ' $to_date ' " ;
} else {
$sql = " SELECT count(*) as total FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id=' " . $ohc_id . " ' and (a.ailments_new LIKE '%, $ailment ,%' or a.ailments_new LIKE '% $ailment ,%' or a.ailments_new LIKE '%, $ailment %' or a.ailments_new LIKE '% $ailment %' or a.ailments_new = ' " . $ailment . " ') and date(a.appointment_date) BETWEEN ' $from_date ' and ' $to_date ' " ;
}
$result_sql = mysqli_query ( $conn , $sql );
$num_rows = mysqli_num_rows ( $result_sql );
$row0 = mysqli_fetch_assoc ( $result_sql );
error_log ( " total sql : " . $sql );
if ( $ailment == 'ALL' ) {
$sql_data = " SELECT DATE_FORMAT(a.appointment_date, '%d-%m-%y') as date, a.*,b.* FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id=' " . $ohc_id . " ' and a.ailments_new!='' and date(a.appointment_date) BETWEEN ' $from_date ' and ' $to_date ' " ;
} else {
$sql_data = " SELECT DATE_FORMAT(a.appointment_date, '%d-%m-%y') as date, a.*,b.* FROM employee_appointment a JOIN view_patient_master b on a.emp_id=b.id WHERE a.ohc_type_id=' " . $ohc_id . " ' and (a.ailments_new LIKE '%, $ailment ,%' or a.ailments_new LIKE '% $ailment ,%' or a.ailments_new LIKE '%, $ailment %' or a.ailments_new LIKE '% $ailment %' or a.ailments_new = ' " . $ailment . " ') and date(a.appointment_date) BETWEEN ' $from_date ' and ' $to_date ' " ;
}
error_log ( " record sql " . $sql_data );
$result_data = mysqli_query ( $conn , $sql_data );
?>
< tr bgcolor = " #eeeeee " >
< th align = " left " width = " 2% " > Sr .</ th >
< th align = " left " width = " 5% " > Date </ th >
< th align = " left " width = " 5% " > Time In </ th >
< th align = " left " width = " 5% " > Time Out </ th >
<!-- < th align = " left " width = " 2% " > Duration </ td > -->
< th valign = " top " align = " left " width = " 3% " > Emp . Code </ th >
< th valign = " top " align = " left " width = " 8% " > Name </ th >
< th valign = " top " align = " left " width = " 2% " > Age </ th >
< th valign = " top " align = " left " width = " 2% " > Sex </ th >
< th valign = " top " align = " left " width = " 5% " > Mobile No .</ th >
< th valign = " top " align = " left " width = " 5% " > Plant </ th >
< th valign = " top " align = " left " width = " 6% " > Employer </ th >
< th valign = " top " align = " left " width = " 6% " > Designation </ th >
<!-- < th valign = " top " align = " left " width = " 3% " > Emp Cadre </ th > -->
< th valign = " top " align = " left " width = " 5% " > Department </ th >
< th valign = " top " align = " left " width = " 6% " > Section </ th >
< th valign = " top " align = " left " width = " 3% " > Complaint </ th >
<!-- < th valign = " top " align = " left " width = " 3% " > Chronic Illness </ th > -->
< th valign = " top " align = " left " width = " 3% " > Diagnosis </ th >
< th valign = " top " align = " left " width = " 5% " > Treatment </ th >
<!-- < th valign = " top " align = " left " width = " 3% " > Chronic Days </ th > -->
</ tr >
< ? php
$count = 1 ;
while ( $row_data = mysqli_fetch_assoc ( $result_data )) {
extract ( $row_data );
?>
< tr >
< td >< ? php echo $count ?> </td>
< td >< ? php echo $row_data [ 'date' ] ?> </td>
< td >< ? php echo date ( " d/M/Y H:i " , strtotime ( $row_data [ 'appointment_date' ])) ?> </td>
< td >
< ? php if ( $row_data [ 'clearance_time' ] != null && $row_data [ 'clearance_time' ] != '' && $row_data [ 'clearance_time' ] != " 00-00-00 00:00:00 " ) {
echo date ( " d/M/Y H:i " , strtotime ( $row_data [ 'clearance_time' ]));
} ?>
</ td >
< td >< ? php echo $row_data [ 'emp_code' ] ?> </td>
< td >< ? php echo $row_data [ 'patient_name' ] ?> </td>
< td >
< ? php
$from = new DateTime ( $row_data [ 'dob' ]);
$to = new DateTime ( 'today' );
echo $from -> diff ( $to ) -> y ;
?>
</ td >
< td >
< ? php if ( $row_data [ 'gender' ] == 'M' ) {
echo 'Male' ;
} else {
echo 'Female' ;
} ?>
</ td >
< td >< ? php echo $row_data [ 'primary_phone' ] ?> </td>
< td >< ? php echo getTableFieldValue ( 'plant_master' , 'plant_name' , 'plant_id' , $row_data [ 'plant_id' ]) ?> </td>
< td >< ? php echo $row_data [ 'employer_contractor_name' ]; ?> </td>
< td >< ? php echo $row_data [ 'designation_name' ]; ?> </td>
< td >< ? php echo $row_data [ 'dept_name' ]; ?> </td>
< td >< ? php echo $row_data [ 'section_name' ]; ?> </td>
< ? php
$complaint_ids = $row_data [ 'complaints' ];
$complaint_ids_array = array ();
$complaint_ids_array = explode ( " , " , $complaint_ids );
$complaints = " " ;
for ( $i = 0 ; $i < count ( $complaint_ids_array ); $i ++ ) {
if ( $i == 0 ) {
if ( is_numeric ( $complaint_ids_array [ $i ])) {
$complaints = getTableFieldValue ( 'complaints' , 'complaint' , 'complaint_id' , $complaint_ids_array [ $i ]);
} else {
$complaints = $complaint_ids_array [ $i ];
}
} else {
if ( is_numeric ( $complaint_ids_array [ $i ])) {
$complaints = $complaints . " , " . getTableFieldValue ( 'complaints' , 'complaint' , 'complaint_id' , $complaint_ids_array [ $i ]);
} else {
$complaints = $complaints . " , " . $complaint_ids_array [ $i ];
}
}
}
?>
< td >< ? php echo strtolower ( $complaints ) ?> </td>
< ? php if ( $ailment == 'ALL' ) { ?>
< td >< ? php echo strtolower ( getCommaSeperatedValuesForInClause ( " select ailment_name from ailment " , " ailment_id " , $row_data [ 'ailments_new' ])); ?> </td>
< ? php } else { ?>
< td >< ? php echo strtolower ( getFieldFromTable ( 'ailment_name' , 'ailment' , 'ailment_id' , $ailment )) ?> </td>
< ? php } ?>
< td >< ? php echo $treatment_text = getTreatmentTextPdf ( $row_data [ 'appointment_id' ]); ?> </td>
</ tr >
< ? php
$count ++ ;
}
}
?>
< tr Height = " 10px " >
< td colspan = " 16 " >< b > TOTAL : & nbsp ; < ? php echo $row0 [ 'total' ] ?> </b></td>
</ tr >
</ table >
</ body >
< script >
$ ( document ) . ready ( function () {
window . print ();
});
</ script >