$sql_attendance="SELECT ar.in_time as in_time FROM `attendance_detail` ar LEFT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '".$ohc_idd."' and day(ar.in_time)='$i' and month(a.attendance_date) = '".$_POST['attend_month']."' and year(a.attendance_date)='".$year."'";
$sql_attendance="SELECT ar.out_time as out_time FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '".$ohc_idd."' and day(ar.out_time)='$i' and month(ar.out_time) = '".$month."' and year(a.attendance_date)='".$year."' ";
$sql_attendance="SELECT ar.out_time as out_time FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '".$ohc_idd."' and ar.out_time>'$indate_formatted' and day(ar.out_time)='$i' and month(ar.out_time) = '".$month."' and year(a.attendance_date)='".$year."' ";
$sql_attendance="SELECT ar.ot as ot FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '".$ohc_idd."' and day(ar.in_time)='$i' and month(a.attendance_date) = '".$_POST['attend_month']."' and year(a.attendance_date)='".$year."' ";
$sql_attendance="SELECT ar.remark as remarks FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '".$ohc_idd."' and day(ar.in_time)='$i' and month(a.attendance_date) = '".$_POST['attend_month']."' and year(a.attendance_date)='".$year."'";
$sql_attendance="SELECT a.relay_set_work FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' ";
$sql_days="SELECT in_time , out_time from attendance_detail a left join attendance_master b on a.attendance_id = b.attendance_id where a.staff_id='$id' AND a.staff_deploy_ohc = '".$ohc_idd."' and month(b.attendance_date) = '".$_POST['attend_month']."' and a.wo!='W' and year(b.attendance_date)='".$year."'";
$sql_days="SELECT count(*) as total from attendance_detail a left join attendance_master b on a.attendance_id = b.attendance_id where a.staff_id='$id' AND a.staff_deploy_ohc = '".$ohc_idd."' and month(b.attendance_date) = '".$_POST['attend_month']."' and a.wo='W' and year(a.attendance_date)='".$year."'";
<?php$sql_attend="SELECT distinct(s.staff_id) as staff_id, s.staff_name as staff_name from `staff_master` s left join attendance_detail a ON s.staff_id = a.staff_id WHERE a.staff_deploy_ohc = '".$ohc_id."'";
$sql_sign_rk="select a.*,d.emp_sign as empSign,d.image_type from attendance_master a left join attendance_detail b on a.attendance_id = b.attendance_id left join tbl_users c on a.approval_user=c.user_id left join employee_signature d on c.staff_id=d.staff_id where a.mine_name='".$_SESSION['current_mine']."'";
$sql_sign="select a.*,d.emp_sign as empSign,d.image_type from attendance_master a left join attendance_detail b on a.attendance_id = b.attendance_id left join tbl_users c on a.created_by=c.user_id left join employee_signature d on c.staff_id=d.staff_id where a.mine_name='".$_SESSION['current_mine']."'";
error_log("SIGN QUERY::".$sql_sign);
$result_sign=mysqli_query($conn,$sql_sign);
$row_sign=mysqli_fetch_assoc($result_sign);
error_log("total worked array".print_r($total_hours,true));