EIOS/inc/iup_lkumu.php

225 lines
9.2 KiB
PHP
Raw Permalink 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.

<?php
$zamdeknaprav = iup_get_zamdeknaprav($_SESSION['user']['teacher']['fakultet']);
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/class_SYSTEM.php';
$SYSTEMclass = new SYSTEMclass();
if(isset($_POST['lkumu_zaversh'])||isset($_POST['lkumu_gotovo'])||isset($_POST['lkumu_vernutkaf'])){//сохраняем выставленные режимы для предметов
$id_zayavka = (int)$_POST['id_zayavka'];
//загрузка файла umu_file
if(isset($_POST['del_file'])){foreach($_POST['del_file'] as $fid => $val){
$sql = 'SELECT * FROM '.$TB['iup_kafedrs_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$fid.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
$val = $rez[1];
unlink($val['file']);
$rez = $DB->QUR_SEL('DELETE FROM '.$TB['iup_kafedrs_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$fid.'');
$msg['err'][]='Файл удален!';
}else{
$msg['err'][]='Файл не найден в базе данных.';
}
}}
//echo '<pre>'.print_r($_FILES,1).'</pre>';
if(isset($_FILES['umu_file'])){
//foreach($_FILES['umu_file']['tmp_name'] as $k => $v){
$v = $_FILES['umu_file']['tmp_name'];
if($v!=''){//загружаем файл
$dir_dest = 'upload/iup/'.$_SESSION['user']['id'].'/';
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $_FILES['umu_file']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$uploadfile = $dir_dest . basename(translit($fn).'.'.$ext);
//if (move_uploaded_file($v, $uploadfile)) {
if ($SYSTEMclass->sysUPLOAD($v, $uploadfile)) {
$sql1 = 'INSERT INTO `'.$TB['iup_kafedrs_files'].'` VALUES (0,'.time().','.$_SESSION['user']['id'].','.$id_zayavka.',"Файл кафедры ИУП","'.$uploadfile.'",2);';
$rez1 = $DB->QUR($sql1);
if($rez1){
$msg['msg'][]='Файл загружен и сохранен в БД!';
}else{
$msg['err'][]='Файл загружен и не сохранен в БД!';
}
} else {
$msg['err'][]='Файл не загружен!';
}
}
//}
}
if(isset($_POST['chat_umu'])&&$_POST['chat_umu']!=''){//сохраняем чат с уму
$chat_umu = addslashes(htmlspecialchars(strip_tags($_POST['chat_umu'])));
$sql = 'INSERT INTO '.$TB['iup_kafumu_chat'].' VALUES(0,'.time().','.$_SESSION['user']['id'].','.$id_zayavka.',"'.$_SESSION['user']['fio'].'","'.$chat_umu.'",2)';
$rez = $DB->QUR_SEL($sql);
}
if(isset($_POST['lkumu_gotovo'])){//меняем статус у заявки
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=5 WHERE id='.$id_zayavka.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
send_email_iup($id_zayavka);
$sql = 'INSERT INTO '.$TB['iup_statuses'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',4,5,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
}
}elseif(isset($_POST['lkumu_vernutkaf'])){
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=3 WHERE id='.$id_zayavka.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
send_email_iup($id_zayavka);
$sql = 'INSERT INTO '.$TB['iup_statuses'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',4,3,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
}
}
//$smarty->assign('debug','<pre>'.print_r($_POST,1).'</pre>');
$des = 'show';
}
if($des == 'attved1'){//ПРОТОКОЛ 1
$id = (int)$_GET['id'];
print_vedomost($id,1,'tpl_iup_attved1.html');
exit();
}
if($des == 'attved2'){//ПРОТОКОЛ 2
$id = (int)$_GET['id'];
print_vedomost($id,2,'tpl_iup_attved2.html');
exit();
}
/*if($des == 'attved3'){//ПРОТОКОЛ 3 Перечень о перезачтенных дисциплинах
$id = (int)$_GET['id'];
print_vedomost($id,3,'tpl_iup_attved3.html');
exit();
}*/
if($des == 'attved4'){//ПРОТОКОЛ 4
$id = (int)$_GET['id'];
print_vedomost($id,3,'tpl_iup_attved4.html');
exit();
}
if($des == 'edit'){
$id = (int)$_GET['id'];
//$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id='.$id.' AND (status=4 OR status=3)';
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id='.$id.' '; //теперь отражаем любую заявку
$rez = $DB->QUR_SEL($sql);
if($rez){
$val = $rez[1]; $id_zayavka=$val['id'];
$val['data_c'] = date('H:i:s d.m.Y',$val['data_c']);
$val['diplom_data'] = date('d.m.Y',$val['diplom_data']);
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks_files'].' WHERE id_studentzayavks='.$id_zayavka.' ORDER BY data_c';
$rez = $DB->QUR_SEL($sql);
if($rez){foreach($rez as $k => $v)if($k){
$v['data_c'] = date('H:i:s d.m.Y',$v['data_c']);
$val['files'][]=$v;
}}
//получим предметы по привязке ЗАЯВКИ к УЧ.ПЛАНУ
$predmets = iup_get_predmets_BYzp($id_zayavka);
if(!count($predmets)) {
$val['predmets'] = iup_get_predmets($_SESSION['user']['teacher']['fakultet'], $val['pret_naprav'], $val['pret_kurs'], $val['pret_fo']);
}else{
$val['predmets'] = $predmets;
}
$at=0;$ad=0;$addtime=0;$addday=0;
foreach($val['predmets'] as $k => $v){
$id_predmet = $v['id'];
$sql3 = 'SELECT prepod_name FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka.' AND predmet_id='.$id_predmet.'';
$rez3 = $DB->QUR_SEL($sql3);
if($rez3){
$val['predmets'][$k]['prepodfio']=$rez3[1]['prepod_name'];
$sql4 = 'SELECT * FROM '.$TB['iup_ocenki'].' WHERE id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.' ORDER BY data_c DESC';
$rez4 = $DB->QUR_SEL($sql4);
if($rez4){
$val['predmets'][$k]['ocenki']=$rez4[1];
}
}else{
$val['predmets'][$k]['prepodfio']='';
}
}
$sql = 'SELECT * FROM '.$TB['iup_kafedrs_files'].' WHERE id_studentzayavks='.$val['id'].' ORDER BY data_c';
$rez = $DB->QUR_SEL($sql);
if($rez){foreach($rez as $k => $v)if($k){
$v['data_c'] = date('H:i:s d.m.Y',$v['data_c']);
$namefile=''; $t=explode('/',$v['file']); $namefile=$t[count($t)-1];
$v['namefile'] = $namefile;
$val['filesk'][]=$v;
}}
$sql = 'SELECT * FROM '.$TB['iup_kafumu_chat'].' WHERE id_studentzayavks='.$val['id'].' ORDER BY data_c';
$rez = $DB->QUR_SEL($sql);
if($rez){foreach($rez as $k => $v)if($k){
$v['data_c'] = date('H:i:s d.m.Y',$v['data_c']);
$v['text'] = stripslashes($v['text']);
$val['chat_umu'][]=$v;
}}
//echo '<pre>'.print_r($val['predmets'],1).'</pre>';
$zayavka = $val;
$smarty->assign('zayavka',$zayavka);
$smarty->assign('id_zayavka',$id);
}else{
$des = 'show';
}
}
if($des == 'show'){
$zayavks=array();
//$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE (pret_naprav LIKE "%'.implode('" OR pret_naprav LIKE "%',$zamdeknaprav).'") AND (status=4 OR status=3) ORDER BY data_c DESC';
//$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE (status=4 OR status=3) ORDER BY data_c DESC';
//echo '<pre>'.print_r($_POST,1).'</pre>';
if(isset($_POST['search_go'])){
$_SESSION['search']['umu']['fio'] = addslashes(htmlspecialchars($_POST['search_fio']));
}
if(isset($_POST['search_goall'])){
unset($_SESSION['search']['umu']['fio']);
}
$whsql=''; $order = ' ORDER BY data_c DESC';
if(isset($_SESSION['search'])){
$whsql = ' AND fio LIKE "%'.$_SESSION['search']['umu']['fio'].'%"';
$order = ' ORDER BY fio';
}
$smarty->assign('search_fio',$_SESSION['search']['umu']['fio']);
if(isset($_POST['filterstatus'])){
$fs = (int)$_POST['filterstatus'];
if($fs>0) $filterstatus = 'status='.$fs;
else $filterstatus = 'status>=3';
}else{ $filterstatus='status>=3';}
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE '.$filterstatus.''.$whsql.$order.' LIMIT 250';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$id_zayavka = $val['id'];
$val['data_c'] = date('H:i:s d.m.Y',$val['data_c']);
$sql1 = 'SELECT * FROM '.$TB['iup_ocenki'].' WHERE id_studentzayavks='.$id_zayavka.'';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$ocall=0; $ociss=0;
foreach($rez1 as $key1 => $val1)if($key1){
if($val1['ocenka']!='') $ociss++;
$ocall++;
}
$val['ocenki']['all']=$ocall;
$val['ocenki']['iss']=$ociss;
}
$sql1 = 'SELECT count(id) as kol FROM '.$TB['iup_attkom'].' WHERE id_studentzayavks='.$id_zayavka.'';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$val['attkom']['all']=$ocall;
$val['attkom']['iss']=$rez1[1]['kol'];
}
$zayavks[] = $val;
}
}
$smarty->assign('zayavks',$zayavks);
}
if($des=='print1'){
//require_once( "iup_pdf.php" );
$otchet = 'umu_student';
require_once( "iup_otchets.php" );
}
$smarty->assign('zamdeknaprav',$zamdeknaprav);
$smarty->assign('page',$page);
$smarty->assign('des',$des);
$smarty->assign('msg',$msg);
$maincontent = $smarty->fetch('tpl_iup_main.html');