<?php 
include('includes/config/config.php');
error_reporting(E_ERROR | E_PARSE);
$ohc_location = $_REQUEST['ohc_location'];
$patient_category = $_REQUEST['patient_category'];
$dept = $_REQUEST['dept'];
$emp_designation = $_REQUEST['emp_designation'];
$emp_cadre = $_REQUEST['emp_cadre'];
$employer_contractor = $_REQUEST['employer_contractor'];
$gender = $_REQUEST['gender'];







$start_date = $_REQUEST['startDate'];
$end_date= $_REQUEST['endDate'];
$year= $_POST['year'];
error_log("abcde".$year);



// $qry_bu ="";
// $qry_date="";

// if(isset($ohc_location) && $ohc_location!=''){
// 	$qry_bu.=" and ohc_location_id ='".$ohc_location."' ";
// }


// if(isset($patient_category) && $patient_category!=''){
// 	$qry_bu.=" and emp_cat_id ='".$patient_category."' ";
// }

// if(isset($dept) && $dept!=''){
// 	$qry_bu.=" and dept_id ='".$dept."' ";
// }

// if(isset($emp_designation) && $emp_designation!=''){
// 	$qry_bu.=" and designation_id ='".$emp_designation."' ";
// }

// if(isset($emp_cadre) && $emp_cadre!=''){
// 	$qry_bu.=" and emp_cadre ='".$emp_cadre."' ";
// }

// if(isset($employer_contractor) && $employer_contractor!=''){
// 	$qry_bu.=" and employer_contractor_id ='".$employer_contractor."' ";
// }

// if(isset($gender) && $gender!=''){
// 	$qry_bu.=" and gender ='".$gender."' ";
// }





// if(isset($start_date) && $start_date!=''){
// 	//$qry_date.=" and checkup_date >='".$start_date."' ";
// 	$qry_date.=" and medical_entry_date >=str_to_date('".$start_date."','%d-%m-%Y') ";
	
	
	
// }
// if(isset($end_date) && $end_date!=''){
// 	//$qry_date.=" and checkup_date <='".$end_date."' ";
// $qry_date.=" and medical_entry_date <=str_to_date('".$end_date."','%d-%m-%Y') ";
// }


// $i=0;
// $weight =array(1,2,3,4,5,-1,-2,-3,-4,-5,0);


for ($i = 1;$i<=12;$i++){
    if($i<10){
        $var="0".$i;

    }
    else{
        $var=$i;
    }
    error_log($var);
    $sql="SELECT count(*) as total,MONTHNAME(STR_TO_DATE($var, '%m')) as months FROM `employee_appointment` a WHERE a.appointment_type='O' AND DATE_FORMAT(a.appointment_date, '%m')='".$var."' and year(a.appointment_date)='".$year."'";
    $result=mysqli_query($conn,$sql);
    $total=mysqli_num_rows($result);
    $row0= mysqli_fetch_assoc($result);
    error_log($sql);

    $array1 = array($var,$row0['months'],$row0['total']);
    $data[]=$array1;

}
    

   
	
 echo json_encode($data);
?>