���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/api-truyentranh/includes/post/ |
<?php global $DB; $json = file_get_contents('php://input'); $arr_data = json_decode($json, true); //$arr_res = $arr_data; $user_key = $arr_data['user_key']??''; if(empty($user_key)){ $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'user_key không tìm thấy'; echo jsonutf($arr_res); exit(); } $r_user = $DB->fetch_row($DB->query("SELECT * FROM TB_USER WHERE USER_KEY='$user_key'")); if(!$r_user) { $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'user_key không tìm thấy'; echo jsonutf($arr_res); exit(); } $user_id = $r_user['USER_ID']; $r_teacher = $DB->fetch_row($DB->query("SELECT * FROM TB_TEACHER WHERE USER_ID='$user_id'")); if(!$r_teacher) { $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'user_key không tìm thấy'; echo jsonutf($arr_res); exit(); } $TEACHER_ID = $r_teacher['TEACHER_ID']; $v_school_id = $r_teacher['SCHOOL_ID']; $v_teacher_id = $r_teacher['TEACHER_ID']; $learn_year = $arr_data['learn_year']??''; $hoc_ky = $arr_data['hoc_ky']??''; $class_id = $arr_data['class_id']??0; $hoc_ky_tih = $arr_data['hoc_ky_tih']??''; $row_check_class = $DB->fetch_row($DB->query(" SELECT * FROM TB_CLASS WHERE CLASS_ID='$class_id' AND (CLASS_TEACHER = '".$v_teacher_id."' OR CLASS_TEACHER_2 = '".$v_teacher_id."') AND CLASS_STATUS = 0 AND LEARN_YEAR='".$learn_year."' LIMIT 1 ")); if(!$row_check_class) { $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'Giáo viên không phải giáo viên chủ nhiệm lớp'; echo jsonutf($arr_res); exit(); } $arr_items = $arr_data['items']; foreach($arr_items as $val){ $v_pupil_id = $val['pupil_id']??0; /*$row_pupil = $DB->fetch_row($DB->query("SELECT * FROM TB_PUPIL WHERE PUPIL_ID='$v_pupil_id' LIMIT 1")); if(!$row_pupil) { $arr_res_sub[] = array('pupil_id'=>$v_pupil_id,'hanh_kiem_key'=>$val['hanh_kiem_key'],'hanh_kiem_value'=>$val['hanh_kiem_value'],'status'=>'Error'); continue; }*/ $hanh_kiem_key = $val['hanh_kiem_key']??''; $hanh_kiem_value = $val['hanh_kiem_value']??''; if($learn_year=='' or $hoc_ky_tih=='' or $hanh_kiem_key=='' or $hanh_kiem_value=='' ) { $arr_res_sub[] = array('pupil_id'=>$v_pupil_id,'hanh_kiem_key'=>$hanh_kiem_key,'hanh_kiem_value'=>$hanh_kiem_value,'status'=>'Error'); continue; } $arr_nangluc = array('T'=>'Tốt(T)','D'=>'Đạt(D)','C'=>'Cần cố gắng(C)'); $arr_nangluc_key = array_keys($arr_nangluc); if(!in_array($hanh_kiem_value, $arr_nangluc_key) and $hanh_kiem_key!='nhan_xet_chung_cua_gvcn'){ $arr_res_sub[] = array('pupil_id'=>$v_pupil_id,'hanh_kiem_key'=>$hanh_kiem_key,'hanh_kiem_value'=>$hanh_kiem_value,'status'=>'Error value input: '.$hanh_kiem_value); continue; } if($hanh_kiem_key=='nhan_xet_chung_cua_gvcn'){ $hanh_kiem_value = textformatdb($hanh_kiem_value); } $row_check = $DB->fetch_row($DB->query(" SELECT * FROM TB_HANH_KIEM_TH_NEW WHERE 1 AND PUPIL_ID='".$v_pupil_id."' AND HANH_KIEM_HK='".$hoc_ky_tih."' AND HANH_KIEM_YEAR='".$learn_year."' AND HANH_KIEM_TYPE='".$hanh_kiem_key."' LIMIT 1 ")); if(!$row_check){ $arr_insert = array( 'SCHOOL_ID'=>$v_school_id,'PUPIL_ID'=>$v_pupil_id,'HANH_KIEM_HK'=>$hoc_ky_tih,'HANH_KIEM_YEAR'=>$learn_year,'HANH_KIEM_VALUE'=>$hanh_kiem_value,'HANH_KIEM_TYPE'=>$hanh_kiem_key,'HANH_KIEM_UPDATE_TIME'=>date('Y-m-d H:i:s'),'TEACHER_ID'=>$v_teacher_id ); $DB->do_insert('TB_HANH_KIEM_TH_NEW',$arr_insert); $arr_res_sub[] = array('pupil_id'=>$v_pupil_id,'hanh_kiem_key'=>$hanh_kiem_key,'hanh_kiem_value'=>showutf($hanh_kiem_value),'status'=>'Insert Success'); }else{ $arr_update = array( 'HANH_KIEM_VALUE'=>$hanh_kiem_value,'HANH_KIEM_UPDATE_TIME'=>date('Y-m-d H:i:s'),'TEACHER_ID'=>$v_teacher_id ); $DB->do_update('TB_HANH_KIEM_TH_NEW',$arr_update," WHERE HANH_KIEM_ID='".$row_check['HANH_KIEM_ID']."' "); $arr_res_sub[] = array('pupil_id'=>$v_pupil_id,'hanh_kiem_key'=>$hanh_kiem_key,'hanh_kiem_value'=>showutf($hanh_kiem_value),'status'=>'Update Success'); } } $arr_res['data_res'] = $arr_res_sub; $arr_res['status'] = 'Success'; $arr_res['status_note'] = 'Đã cập nhật hạnh kiểm'; echo jsonutf($arr_res); exit(); ?>