���� 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; if($arr_data['weight']=='' and $arr_data['height']==''){ $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'weight or height is required!'; echo jsonutf($arr_res); exit(); } if($arr_data['type_height']!='m' and $arr_data['type_height']!='cm'){ $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'type_height is "m" or "cm"'; echo jsonutf($arr_res); exit(); } if(isset($arr_data['type_height']) && $arr_data['type_height']=='cm'){ $arr_data['height'] = $arr_data['height']/100; } $v_pupil_id = $arr_data['pupil_id']; $r_pupil = $DB->fetch_row($DB->query("SELECT * FROM TB_PUPIL WHERE PUPIL_ID='$v_pupil_id' LIMIT 1 ")); if(!$r_pupil){ $arr_res['status'] = 'Error'; $arr_res['status_note'] = 'pupil_id is not found!'; echo jsonutf($arr_res); exit(); } $arr_phanloai = array('1'=>'Thiếu cân','2'=>'Sức khỏe dinh dưỡng tốt','3'=>'Nguy cơ béo phì','4'=>' Béo phì','5'=>'Trẻ suy dinh dưỡng thể gầy còm mức độ nặng','6'=>'Trẻ suy dĩnh dưỡng thể gầy còm','7'=>'Trẻ bình thường','8'=>'Trẻ thừa cân','9'=>'Trẻ béo phì'); $v_year = $arr_data['learn_year']??''; $v_month = $arr_data['txt_month']??''; $row_check = $DB->fetch_row($DB->query("SELECT * FROM TB_HEALTH WHERE `PUPIL_ID`='".$v_pupil_id."' AND `YEAR`='$v_year' AND MONTH='$v_month' LIMIT 1")); if(!$row_check){ $DB->query("INSERT INTO TB_HEALTH (`PUPIL_ID`, `YEAR`, `MONTH`) VALUES ('$v_pupil_id', '$v_year', '$v_month');"); } $DB->query(" UPDATE TB_HEALTH SET HEIGHT='" . $arr_data['height'] . "',WEIGHT='" . $arr_data['weight'] . "' WHERE `PUPIL_ID`='" . $v_pupil_id . "' AND `YEAR`='$v_year' AND `MONTH`='$v_month' "); if($r_pupil['PUPIL_SEX']==2){ $v_gender = 'Nữ'; }else{ $v_gender = 'Nam'; } $v_birthday = strtotime($r_pupil['PUPIL_BIRTH_DAY'].' 00:00:00'); //$v_age_pupil = time() - $v_birthday; $arr_age = secondsToTime($v_birthday); if($arr_data['height']>0) { $v_bmi = round($arr_data['weight'] / ($arr_data['height'] * $arr_data['height']),2); }else{ $v_bmi = null; } if($v_bmi != null){ $v_phan_loai = result_bmi($r_pupil['PUPIL_SEX'],$v_bmi,$arr_age['years'],$arr_age['months']); }else{ $v_phan_loai = null; } if($v_phan_loai!=null){ $DB->query(" UPDATE TB_HEALTH SET PHANLOAI='" . $v_phan_loai . "' WHERE `PUPIL_ID`='" . $v_pupil_id . "' AND `YEAR`='$v_year' AND `MONTH`='$v_month' "); } $arr_res['BMI'] = $v_bmi; $arr_res['Distribute'] = null; if($v_phan_loai!=null and isset($arr_phanloai[$v_phan_loai])) { $arr_res['Distribute'] = $arr_phanloai[$v_phan_loai]; } $arr_res['status'] = 'Success'; $arr_res['status_note'] = 'Cập nhật sức khoẻ dinh dưỡng thành công'; echo jsonutf($arr_res); exit(); ?>