EIOS/inc/iup_sekdek.php

175 lines
7.5 KiB
PHP
Raw Normal View History

2023-12-28 15:39:22 +03:00
<?php
$zamdeknaprav = iup_get_zamdeknaprav($_SESSION['user']['teacher']['fakultet']);
if(isset($_POST['sekdek_zaversh'])||isset($_POST['sekdek_gotovo'])){//сохраняем заявку
$id_zayavka = (int)$_POST['id_zayavka'];
if(isset($_POST['sekdek_gotovo'])){//меняем статус у заявки
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=6 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'].',5,6,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
}
}elseif(isset($_POST['sekdek_vernutkaf'])){
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=4 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'].',5,4,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
}
}
$des = 'show';
}
if($des == 'edit'){
$id = (int)$_GET['id'];
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id='.$id.' AND (status=5 OR status=6)';
$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;
}
foreach($val['predmets'] as $k => $v){
$id_predmet = $v['id'];
//оценки от аттком
$sql1 = 'SELECT * FROM '.$TB['iup_attkom'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.'';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$val['predmets'][$k]['ocenka1'] = $rez1[1]['ocenka'];
$val['day'] = date('d.m.Y',$rez1[1]['data_time']);
$val['time'] = date('H:i',$rez1[1]['data_time']);
}
//оценки от преподов
$sql1 = 'SELECT * FROM '.$TB['iup_ocenki'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.'';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$val['predmets'][$k]['ocenka0'] = $rez1[1]['ocenka'];
}
}
$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);
}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=5 OR status=6) OR perevod=1 ORDER BY data_c DESC LIMIT 250';
//echo $sql;exit();
//БЛОК А. меняем запрос - если преподаватель НЕ с филиала, то выводим дисциплины, которые НЕ начинаются с Фс
//ВЫБЕРЕМ ДАННЫЕ о ВУЗЕ
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_users WHERE id='.$_SESSION['user']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql1);
$vyz = out_data_fu($rez[1]['high_school']);
//echo $vyz;
if ($vyz != 2){ //если не филиал
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE (pret_naprav LIKE "%'.implode('%" OR pret_naprav LIKE "%',$zamdeknaprav).'%") AND NOT(pret_naprav LIKE "Фс:%") AND (status=5 OR status=6) OR (perevod=1 AND NOT(pret_naprav LIKE "Фс:%")) ORDER BY data_c DESC LIMIT 250';
//пришлось немного переписать условие - было просто OR perevod = 1 - это полностью перекрывало все остальные условия
}
//поиск по ФИО
if (isset($_POST["search"])){
$fio = $_POST["fio"];
//$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE fio = "%'.$fio.'%" AND (pret_naprav LIKE "%'.implode('%" OR pret_naprav LIKE "%',$zamdeknaprav).'%") AND (status=5 OR status=6) OR perevod=1 ORDER BY data_c DESC';
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE fio LIKE "%'.$fio.'%" LIMIT 250';
}
//echo $sql;
/*ЗАВЕРШАЕМ БЛОК А*/
$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'];
}
$val['znomer'] = ''; $val['zdata'] = '';
if($val['perevod']==1){
$sql = 'SELECT nomer,data FROM '.$ST['dbpf'].'_iup_studkadr WHERE id_studentzayavks='.$val['id'].' LIMIT 1';
$rez = $DB->QUR_SEL($sql);
if($rez){
$val['znomer'] = $rez[1]['nomer'];
$val['zdata'] = $rez[1]['data'];
}
}
$zayavks[] = $val;
}
}
$smarty->assign('zayavks',$zayavks);
}
if($des=='print1'){
//require_once( "iup_pdf.php" );
$otchet = 'umu_student';
require_once( "iup_otchets.php" );
}
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();
}
$smarty->assign('zamdeknaprav',$zamdeknaprav);
$smarty->assign('page',$page);
$smarty->assign('des',$des);
$smarty->assign('msg',$msg);
$maincontent = $smarty->fetch('tpl_iup_main.html');