EIOS/inc/accredit.php

192 lines
8.1 KiB
PHP
Raw Normal View History

2023-12-28 15:39:22 +03:00
<?
$id_user = $_SESSION['user']['id'];
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/class_SYSTEM.php';
$SYSTEMclass = new SYSTEMclass();
//АККРЕДИТАЦИЯ - ЗАЯВЛЕНИЯ и подача документов
if ($_GET['page'] == 'order'){
$msg = 0; //нет сообщений
//загрузить заявление и добавить данные
if (isset($_POST['add_accredit'])){
$accredit = $_POST['accredit'];
$surname = addslashes($_POST['surname']);
$name = addslashes($_POST['name']);
$patronymic = addslashes($_POST['patronymic']);
$sex = addslashes($_POST['sex']);
$type = addslashes($_POST['type']);
$citizenship = addslashes($_POST['citizenship']);
$fellow = addslashes($_POST['fellow']);
$attidude = addslashes($_POST['attidude']);
$snils = addslashes($_POST['snils']);
$phone_number = addslashes($_POST['phone_number']);
$date_born = addslashes($_POST['date_born']);
$index_reg = addslashes($_POST['index_reg']);
$address = addslashes($_POST['address']);
$vid_doc = addslashes($_POST['vid_doc']);
$seria_doc = addslashes($_POST['seria_doc']);
$num_doc = addslashes($_POST['num_doc']);
$date_doc = addslashes($_POST['date_doc']);
$kem_doc = addslashes($_POST['kem_doc']);
$type_edu = addslashes($_POST['type_edu']);
$level_edu = addslashes($_POST['level_edu']);
$spec_edu = addslashes($_POST['spec_edu']);
$seria_edu = addslashes($_POST['seria_edu']);
$num_edu = addslashes($_POST['num_edu']);
$date_edu = addslashes($_POST['date_edu']);
$kem_edu = addslashes($_POST['kem_edu']);
$date_create = date("U");
//загрузка файлов в директорию
$dir_dest = 'upload/accredit/';
//паспорт
$file_pasport='';
if(isset($_FILES['file_pasport'])){
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file_pasport']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$file_pasport = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file_pasport']['tmp_name'], $file_pasport)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_pasport']['tmp_name'], $file_pasport)) {
$file_pasport='';
}
}
//диплом
$file_edu='';
if(isset($_FILES['file_edu'])){
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file_edu']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$file_edu = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file_edu']['tmp_name'], $file_edu)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_edu']['tmp_name'], $file_edu)) {
$file_edu='';
}
}
//военный билет
$file_vb='';
if(isset($_FILES['file_vb'])){
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file_vb']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$file_vb = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file_vb']['tmp_name'], $file_vb)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_vb']['tmp_name'], $file_vb)) {
$file_vb='';
}
}
//СНИЛС
$file_snils='';
if(isset($_FILES['file_snils'])){
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file_snils']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$file_snils = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file_snils']['tmp_name'], $file_snils)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_snils']['tmp_name'], $file_snils)) {
$file_snils='';
}
}
//заявление
$file_zayv='';
if(isset($_FILES['file_zayv'])){
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file_zayv']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$file_zayv = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file_zayv']['tmp_name'], $file_zayv)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_zayv']['tmp_name'], $file_zayv)) {
$file_zayv='';
}
}
//ДОБАВЛЕНИЕ В БАЗУ
$sql = 'INSERT INTO '.$ST['dbpf'].'_accredit (`id_user`, `surname`, `name`, `patronymic`, `sex`, `type`, `citizenship`, `fellow`, `attidude`, `snils`, `phone_number`, `date_born`, `index_reg`, `address`, `vid_doc`, `seria_doc`, `num_doc`, `date_doc`, `kem_doc`, `type_edu`, `level_edu`, `spec_edu`, `seria_edu`, `num_edu`, `date_edu`, `kem_edu`, `file_pasport`, `file_edu`, `file_vb`, `file_snils`, `file_zayv`, `date_create`, `status`, `accredit`) VALUES ("'.$id_user.'", "'.$surname.'", "'.$name.'", "'.$patronymic.'", "'.$sex.'", "'.$type.'", "'.$citizenship.'", "'.$fellow.'", "'.$attidude.'", "'.$snils.'", "'.$phone_number.'", "'.$date_born.'", "'.$index_reg.'", "'.$address.'", "'.$vid_doc.'", "'.$seria_doc.'", "'.$num_doc.'", "'.$date_doc.'", "'.$kem_doc.'", "'.$type_edu.'", "'.$level_edu.'", "'.$spec_edu.'", "'.$seria_edu.'", "'.$num_edu.'", "'.$date_edu.'", "'.$kem_edu.'", "'.$file_pasport.'", "'.$file_edu.'", "'.$file_vb.'", "'.$file_snils.'", "'.$file_zayv.'", "'.$date_create.'", "0", "'.$accredit.'") ';
//echo $sql;
$rez = $DB->QUR($sql);
$id = mysql_insert_id();
//НУЖНО ЕЩЕ ЗАГРУЗИТЬ ФАЙЛЫ И УКАЗАТЬ ССЫЛКИ В БАЗЕ
$msg = 1;
save_logs('Заявление на аккредитацию оформлено №'.$id);
}
//мои заявления
$zayavks = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_accredit WHERE id_user = "'.$id_user.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
/*$val['date_born'] = date('d.m.Y', $val['date_born']);
$val['date_doc'] = date('d.m.Y', $val['date_doc']);
$val['date_edu'] = date('d.m.Y', $val['date_edu']);*/
$val['date_create'] = date('d.m.Y', $val['date_create']);
$zayavks[] = $val;
}
}
$fio = $_SESSION['user']['fio'];
$smarty->assign('fio', $fio);
$smarty->assign('msg', $msg);
$smarty->assign('zayavks', $zayavks);
$maincontent = $smarty->fetch('tpl_accredit_order.html');
}
//ПРЕДСЕДАТЕЛЬ АККРЕДИТАЦИОННОЙ КОМИССИИ
if ($_GET['page'] == 'chairman'){
//заявления на рассмотрении
$zayavks = array();
$sql = 'SELECT ac.*, us.* FROM '.$ST['dbpf'].'_accredit as ac, '.$ST['dbpf'].'_users as us WHERE ac.status = "0" AND ac.id_user = us.id AND ac.date_create >= "'.(date("U")-3600*24*90).'"';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['date_create'] = date('d.m.Y', $val['date_create']);
$zayavks[] = $val;
}
}
$smarty->assign('zayavks', $zayavks);
$maincontent = $smarty->fetch('tpl_accredit_chairman.html');
}
//ПРОСМОТР ОБЩЕЙ ТАБЛИЦЫ
if (($_GET['page'] == 'print0')||($_GET['page'] == 'print')){ //0 в конце - СПО
//заявления
$zayavks = array();
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_accredit ';
if ($_GET['page'] == 'print0') $sql = 'SELECT ac.*, us.* FROM '.$ST['dbpf'].'_accredit as ac, '.$ST['dbpf'].'_users as us WHERE ac.status = "0" AND ac.id_user = us.id AND ac.date_create >= "'.(date("U")-3600*24*90).'" AND ac.level_edu = "Среднее профессиональное образование"';
else $sql = 'SELECT ac.*, us.* FROM '.$ST['dbpf'].'_accredit as ac, '.$ST['dbpf'].'_users as us WHERE ac.status = "0" AND ac.id_user = us.id AND ac.date_create >= "'.(date("U")-3600*24*90).'" AND ac.level_edu = "Высшее образование"';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['date_create'] = date('d.m.Y', $val['date_create']);
$zayavks[] = $val;
}
}
$smarty->assign('zayavks', $zayavks);
$smarty->display('tpl_accredit_print.html');
exit;
}
?>