EIOS/inc/health.php

218 lines
7.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
$fakultet = $_SESSION['user']['teacher']['fakultet'];
//ФУНКЦИИ
//тип документа
function typeVaccine($is_vac){
switch($is_vac){
case 'да': $is_vac = 'Да, имеется сертификат о полной вакцинации'; break;
case 'медотвод': $is_vac = 'Имеется медотвод'; break;
case 'болел': $is_vac = 'Болел, имеется сертификат переболевшего'; break;
case 'нет': $is_vac = 'Нет, не вакцинирован, медотвод отсутствует'; break;
}
return $is_vac;
}
//вакцинация
if ($_GET['page'] == 'vaccine'){
$id_user = $_SESSION['user']['id'];
//УДАЛЕНИЕ ВАКЦИНЫ
if ($_GET['des'] == 'delete'){
$id = $_GET['dop'];
$sql = 'SELECT * FROM '.$ST['dbpf'].'_vaccine WHERE id = "'.$id.'" LIMIT 1';
$rez = $DB->QUR_SEL($sql);
//echo $rez[1]['sertificat'];
unlink('../'.$rez[1]['sertificat']);
//Удаляем
$sql = 'DELETE FROM '.$ST['dbpf'].'_vaccine WHERE id = "'.$id.'" ';
$rez = $DB->QUR($sql);
$msg = 2;
save_logs('Удалена информация о вакцинации №'.$id);
}
//записать инфу о вакцине
if (isset($_POST['order_vaccine'])){
$is_vac = addslashes($_POST['is_vac']);
$date_vac = strtotime($_POST['date_vac']);
$date_end = strtotime($_POST['date_end']);
//загрузка файлов в директорию
$dir_dest = 'upload/vaccine/';
//паспорт
$sertificat='';
$date_create = date("U");
if(isset($_FILES['sertificat'])){
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/class_SYSTEM.php';
$SYSTEMclass = new SYSTEMclass();
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['sertificat']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$sertificat = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['sertificat']['tmp_name'], $sertificat)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['sertificat']['tmp_name'], $sertificat)) {
$sertificat='';
}
}
//$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_window (`id_user`, `date_create`, `fio`, `phone`, `type`, `gruppa`, `comment`) VALUES ("'.$id_user.'", "'.$date_create.'", "'.$fio.'", "'.$phone.'", "'.$type.'", "'.$gruppa.'", "'.$comment.'") ');
$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_vaccine (`id_user`, `is_vac`, `date_vac`, `date_end`, `sertificat`) VALUES ("'.$id_user.'", "'.$is_vac.'", "'.$date_vac.'", "'.$date_end.'", "'.$sertificat.'") ');
$id = mysql_insert_id();
$msg = 1;
save_logs('Сохранена информация о вакцинации №'.$id);
}
//заявления на рассмотрении
$zayavks = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_vaccine WHERE id_user = "'.$id_user.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
switch($val['is_vac']){
case 'да': $val['is_vac'] = 'Да, имеется сертификат о полной вакцинации'; break;
case 'медотвод': $val['is_vac'] = 'Имеется медотвод'; break;
case 'болел': $val['is_vac'] = 'Болел, имеется сертификат переболевшего'; break;
case 'нет': $val['is_vac'] = 'Нет, не вакцинирован, медотвод отсутствует'; break;
}
$val['date_vac'] = date('d.m.Y', $val['date_vac']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$zayavks[] = $val;
}
}
$smarty->assign('zayavks', $zayavks);
$smarty->assign('msg', $msg);
$maincontent = $smarty->fetch('tpl_health_vaccine.html');
}
//СПИСОК ВАКЦИНИРОВАННЫХ
if ($_GET['page'] == 'list'){
$faculties = array();
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_faculties WHERE name = "'.$fakultet.'"';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_faculties ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['view'] = 0;
if ($val['name'] == $fakultet) $val['view'] = 1;
//общее число вакцинированых и общее число студентов на факультете
$val['all_count'] = 0;
$val['all_vac'] = 0;
//по формам обучения
$val['ofo_count'] = 0;
$val['zfo_count'] = 0;
$val['ozfo_count'] = 0;
$val['ofo_vac'] = 0;
$val['zfo_vac'] = 0;
$val['ozfo_vac'] = 0;
//здесь выбираем группы факультета
$val['grupps'] = array();
$sql_grupp = 'SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id_facult = "'.$val['id'].'" ';
$rez_grupp = $DB->QUR_SEL($sql_grupp);
if ($rez_grupp){
foreach ($rez_grupp as $key_gr => $val_gr) if ($key_gr){
$count_sql = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_students WHERE id_grupp = "'.$val_gr['id'].'" ');
$val_gr['count'] = $count_sql[0];
if ($val_gr['count'] == 0) continue;
//$val_gr['vac'] = 0;
//список студентов с СЕРТИФИКАТАМИ
$val_gr['students'] = array();
//$sql_students = 'SELECT st.*, vac.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_vaccine as vac WHERE st.id_grupp = "'.$val_gr['id'].'" AND vac.id_user = st.id_user';
$sql_students = 'SELECT st.*, vac.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_vaccine as vac WHERE st.id_grupp = "'.$val_gr['id'].'" AND vac.id_user = st.id_user GROUP BY st.id_user';
$rez_students = $DB->QUR_SEL($sql_students);
if ($rez_students){
foreach ($rez_students as $key_st => $val_st) if ($key_st){
$val_st['date_vac'] = date('d.m.Y', $val_st['date_vac']);
$val_st['date_end'] = date('d.m.Y', $val_st['date_end']);
$val_st['is_vac'] = typeVaccine($val_st['is_vac']);
$val_st['user'] = get_user($val_st['id_user']);
$val_gr['students'][] = $val_st;
}
}
$val_gr['vac'] = $rez_students[0];
if ($val_gr['vac'] == '') $val_gr['vac'] = 0;
//прибавляем к общему числу
if ($val_gr['vac'] > 0) {
$val['all_count'] += $val_gr['count'];
$val['all_vac'] += $val_gr['vac'];
//по формам обучения
if ($val_gr['fo'] == 'ОФО'){
$val['ofo_count'] += $val_gr['count'];
$val['ofo_vac'] += $val_gr['vac'];
}
if ($val_gr['fo'] == 'ЗФО'){
$val['zfo_count'] += $val_gr['count'];
$val['zfo_vac'] += $val_gr['vac'];
}
if ($val_gr['fo'] == 'ОЗФО'){
$val['ozfo_count'] += $val_gr['count'];
$val['ozfo_vac'] += $val_gr['vac'];
}
}
$val['grupps'][] = $val_gr;
}
}
$faculties[] = $val;
}
}
/*******/
$smarty->assign('faculties', $faculties);
//$smarty->assign('teachers', $teachers);
$maincontent = $smarty->fetch('tpl_health_vaccine_list.html');
}
//СПИСОК ВАКЦИНИРОВАННЫХ
if ($_GET['page'] == 'listTeachers'){
//теперь преподаватели
$teachers = array();
$sql = 'SELECT teach.*, vac.* FROM '.$ST['dbpf'].'_teachers as teach, '.$ST['dbpf'].'_vaccine as vac WHERE teach.status > 0 AND teach.id_user = vac.id_user';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['date_vac'] = date('d.m.Y', $val['date_vac']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['is_vac'] = typeVaccine($val['is_vac']);
$val['user'] = get_user($val['id_user']);
$teachers[] = $val;
}
}
$smarty->assign('teachers', $teachers);
$maincontent = $smarty->fetch('tpl_health_vaccine_list_teacher.html');
}
?>