169 lines
4.3 KiB
PHP
169 lines
4.3 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
$business_unit = $_REQUEST['business_unit'];
|
|
$sub_business_unit = $_REQUEST['sub_business_unit'];
|
|
$section_name = $_REQUEST['section_name'];
|
|
$sub_section_name = $_REQUEST['sub_section_name'];
|
|
|
|
|
|
|
|
$qry_bu ="";
|
|
if(isset($business_unit) && $business_unit!=''){
|
|
$qry_bu.=" and bu_id ='".$business_unit."' ";
|
|
}
|
|
|
|
if(isset($sub_business_unit) && $sub_business_unit!=''){
|
|
$qry_bu.=" and sbu_id ='".$sub_business_unit."' ";
|
|
}
|
|
|
|
if(isset($section_name) && $section_name!=''){
|
|
$qry_bu.=" and section_id ='".$section_name."' ";
|
|
}
|
|
|
|
if(isset($sub_section_name) && $sub_section_name!=''){
|
|
$qry_bu.=" and sub_section_id ='".$sub_section_name."' ";
|
|
}
|
|
|
|
$i=0;
|
|
$record =array();
|
|
|
|
|
|
$query="SELECT count(*) as total FROM employee where emp_habit is null ";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
|
$record[$i]['key'] ='None';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='1' ";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='Only Smoking';
|
|
$record[$i]['total'] =$row['total'];
|
|
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='2' ";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='Only Alcohol';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='3' ";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='Only Tobacco';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='1,3'";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='Tobacco+Smoking';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='2,3'";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='Alcohol+Tobacco';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='1,2'";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
|
$record[$i]['key'] ='Alcohol+Smoking';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
$query="SELECT count(*) as total FROM employee where emp_habit='1,2,3'";
|
|
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
|
$record[$i]['key'] ='Alcohol+Tobacco+Smoking';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="SELECT count(*) as total FROM employee ";
|
|
$qry_bu=preg_replace('/and/', 'where', $qry_bu, 1);
|
|
//echo $query.$qry_bu;
|
|
if (!$result = @mysqli_query($conn,$query.$qry_bu)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
$data['total_count'] = $row['total'];
|
|
}
|
|
}
|
|
$data1=array('total_count'=>$data['total_count'],'data'=>$record);
|
|
|
|
echo json_encode($data1);
|
|
?>
|