EIOS/inc/iup_lkprepod.php

271 lines
16 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']);
$id_zayavka = (int)$_POST['id_zayavka'];
//echo '<pre>'.print_r($_POST,1).'</pre>'; exit();
if(isset($_POST['ajdes'])){
$out = array();
//session_start();
header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('Europe/Moscow');
if($_POST['ajdes']=='tr_save'){
$predmets_n = addslashes(htmlspecialchars($_POST['predmets_n']));
$tip = addslashes(htmlspecialchars($_POST['tip'])); if($tip=='') $tip=0;
$ocenka='';
if($tip==1) $ocenka = addslashes(htmlspecialchars($_POST['predmets']));
if($tip==2) $ocenka = addslashes(htmlspecialchars($_POST['predmetsA']));
if($tip==3) $ocenka = 0;
$semestr = addslashes(htmlspecialchars($_POST['semestr'])); if($semestr=='') $semestr = 0;
$day = addslashes(htmlspecialchars($_POST['day'])); if($day=='') $day = date('d.m.Y');
$time = addslashes(htmlspecialchars($_POST['time'])); if($time=='') $time = date('H:i');
$kpro = addslashes(htmlspecialchars($_POST['kpro']));
$krab = addslashes(htmlspecialchars($_POST['krab']));
$aud = addslashes(htmlspecialchars($_POST['aud']));
$comment = addslashes(htmlspecialchars($_POST['comment']));
$id_zayavka = addslashes(htmlspecialchars($_POST['id_z']));
$id_predmet = addslashes(htmlspecialchars($_POST['id_p']));
$data_time = 0; $t0=explode(':',$time); $t1=explode('.',$day);
$data_time = mktime($t0[0],$t0[1],0,$t1[1],$t1[0],$t1[2]);
$sql = 'SELECT id FROM '.$TB['iup_ocenki'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.' ORDER BY id DESC';
$rez = $DB->QUR_SEL($sql);
//$out['sql'] = $sql;
//$out['rez'] = $rez;
if($rez){
$sql = 'UPDATE '.$TB['iup_ocenki'].' SET data_c='.time().',ocenka="'.$ocenka.'",tip='.$tip.',data_time='.$data_time.',semestr='.$semestr.',comment="'.$comment.'",kpro="'.$kpro.'",krab="'.$krab.'",aud="'.$aud.'" WHERE id='.$rez[1]['id'].'';
$rez = $DB->QUR($sql);
if($rez){
$out['html'] = '<span class="label label-success">Обновили!</span>';
save_logs('ИУП: lkprepod Обновили оценки №'.$id_zayavka.' ocenka="'.$ocenka.'",tip='.$tip.',data_time='.$data_time.',semestr='.$semestr.',comment="'.$comment.'",kpro="'.$kpro.'",krab="'.$krab.'",aud="'.$aud.'"');
} else {
$out['html'] = '<span class="label label-important">Не обновили!</span>';
save_logs('ИУП: lkprepod Не обновили оценки №'.$id_zayavka.' ocenka="'.$ocenka.'",tip='.$tip.',data_time='.$data_time.',semestr='.$semestr.',comment="'.$comment.'",kpro="'.$kpro.'",krab="'.$krab.'",aud="'.$aud.'"');
}
}else{
$sql = 'INSERT INTO '.$TB['iup_ocenki'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',"'.$ocenka.'","'.$predmets_n.'",'.$id_predmet.','.$tip.','.$data_time.','.$semestr.',"'.$comment.'","'.$kpro.'","'.$krab.'","'.$aud.'")';
$rez = $DB->QUR($sql);
if($rez){
$out['html'] = '<span class="label label-success">Добавили!</span>';
save_logs('ИУП: lkprepod Добавили оценки №'.$id_zayavka.' '.$_SESSION['user']['id'].',"'.$ocenka.'","'.$predmets_n.'",'.$id_predmet.','.$tip.','.$data_time.','.$semestr.',"'.$comment.'","'.$kpro.'","'.$krab.'","'.$aud.'"');
} else {
$out['html'] = '<span class="label label-important">Не добавили!</span>';
save_logs('ИУП: lkprepod Не добавили оценки №'.$id_zayavka.' '.$_SESSION['user']['id'].',"'.$ocenka.'","'.$predmets_n.'",'.$id_predmet.','.$tip.','.$data_time.','.$semestr.',"'.$comment.'","'.$kpro.'","'.$krab.'","'.$aud.'"');
}
}
//$out['sql'] = $sql;
}
echo json_encode($out);
exit();
}
if(isset($_POST['lkprepod_back'])){//возвращаем атт.комм. уже зам декану
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=0 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'].',2,0,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
save_logs('ИУП: возвращаем атт.комм. уже зам декану №'.$id_zayavka.'');
}
}
//echo '<pre>'.print_r($_POST,1).'</pre>';
if(isset($_POST['attestcom_save'])||isset($_POST['lkprepod_gotovo'])){//сохраняем выставленные оценки
//echo '1233245234'; exit;
//echo '<pre>'.print_r($_POST,1).'</pre>'; exit();
foreach($_POST['predmets_n'] as $key => $val){
$id_predmet = $key;
$predmet = addslashes(htmlspecialchars($_POST['predmets_n'][$key]));
$tip = addslashes(htmlspecialchars($_POST['tip'][$key])); if($tip=='')$tip=0;
$semestr = addslashes(htmlspecialchars($_POST['semestr'][$key])); if($semestr=='')$semestr=0;
$comment = addslashes(htmlspecialchars($_POST['comment'][$key]));
if($tip==1) $ocenka = addslashes(htmlspecialchars($_POST['predmets'][$key]));
if($tip==2) $ocenka = addslashes(htmlspecialchars($_POST['predmetsA'][$key]));
if($tip==3) $ocenka = 0;
$day = addslashes(htmlspecialchars($_POST['day'][$key])); if($day=='')$day=date('d.m.Y');
$time = addslashes(htmlspecialchars($_POST['time'][$key])); if($time=='')$time=date('H:i');
$kpro = addslashes(htmlspecialchars($_POST['kpro'][$key]));
$krab = addslashes(htmlspecialchars($_POST['krab'][$key]));
$aud = addslashes(htmlspecialchars($_POST['aud'][$key]));
$data_time = 0; $t0=explode(':',$time); $t1=explode('.',$day);
$data_time = mktime($t0[0],$t0[1],0,$t1[1],$t1[0],$t1[2]);
$sql = 'SELECT id FROM '.$TB['iup_ocenki'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.' ORDER BY id DESC';
$rez = $DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>'; exit();//Array([0] => 1 [1] => Array([id] => 382565))
if($rez){
$sql = 'UPDATE '.$TB['iup_ocenki'].' SET data_c='.time().',ocenka="'.$ocenka.'",tip='.$tip.',data_time='.$data_time.',semestr='.$semestr.',comment="'.$comment.'",kpro="'.$kpro.'",krab="'.$krab.'",aud="'.$aud.'" WHERE id='.$rez[1]['id'].'';
$rez = $DB->QUR($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>'; exit();
//UPDATE acs_iup_ocenki SET data_c=1698827979,ocenka="0",tip=3,data_time=1698814800,semestr=5,comment="",kpro="",krab="",aud="" WHERE id=382565
save_logs('ИУП: сохраняем выставленные UPDATE оценки №'.$id_zayavka.' ocenka="'.$ocenka.'",tip='.$tip.',data_time='.$data_time.',semestr='.$semestr.',comment="'.$comment.'",kpro="'.$kpro.'",krab="'.$krab.'",aud="'.$aud.'"');
}else{
$sql = 'INSERT INTO '.$TB['iup_ocenki'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',"'.$ocenka.'","'.$predmet.'",'.$id_predmet.','.$tip.','.$data_time.','.$semestr.',"'.$comment.'","'.$kpro.'","'.$krab.'","'.$aud.'")';
$rez = $DB->QUR($sql);
save_logs('ИУП: сохраняем выставленные INSERT оценки №'.$id_zayavka.' '.$_SESSION['user']['id'].',"'.$ocenka.'","'.$predmet.'",'.$id_predmet.','.$tip.','.$data_time.','.$semestr.',"'.$comment.'","'.$kpro.'","'.$krab.'","'.$aud.'"');
}
//echo $sql;
}
if(isset($_POST['lkprepod_gotovo'])){//меняем статус у заявки
$sql = 'UPDATE '.$TB['iup_studentzayavks'].' SET status=1 WHERE id='.$id_zayavka.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
send_email_iup($id_zayavka);
//надо еще студентов оповестить
send_email_iup_stud($id_zayavka);
$sql = 'INSERT INTO '.$TB['iup_statuses'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',2,1,"")';
$rez = $DB->QUR($sql);
if($rez){ $msg['msg'][]='Время изменения статуса сохранено!';}
else{ $msg['err'][]='Время изменения статуса не сохранено!'; }
save_logs('ИУП: меняем статус у заявки №'.$id_zayavka);
}
}else{
$sql = 'INSERT INTO '.$TB['iup_statuses'].' VALUES(0,'.time().','.$id_zayavka.','.$_SESSION['user']['id'].',2,2,"выставление оценок в заявке")';
$rez = $DB->QUR($sql);
//надо еще студентов оповестить
send_email_iup_stud($id_zayavka);
}
$des = 'show';
}
if($des == 'edit'){
$id = (int)$_GET['id'];
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id='.$id.' AND status=2';
$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;
}}
//надо получить предметы которые оцениваем в этой заявке!
$prep_pred=array();
//$sql0 = 'SELECT predmet_id FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka.' AND prepod_id='.$_SESSION['user']['id'].'';
$sql0 = 'SELECT predmet_id FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka.' AND prepod_id='.$_SESSION['user']['id'].' ';
//$sql0 = 'SELECT oc.*, zam.predmet_id as predmet_id FROM '.$TB['iup_zamdekan'].' as zam, '.$TB['iup_ocenki'].' as oc WHERE zam.id_studentzayavks='.$id_zayavka.' AND zam.prepod_id='.$_SESSION['user']['id'].' AND oc.id_studentzayavks='.$id_zayavka.' AND oc.id_predmet = zam.predmet_id';
//echo $sql0;
$rez0 = $DB->QUR_SEL($sql0);
//echo $sql0.'<pre>'.print_r($rez0,1).'</pre>';exit();
if($rez0){
foreach($rez0 as $key0 => $val0)if($key0){
$prep_pred[]=$val0['predmet_id'];
}
}
//получим предметы по привязке ЗАЯВКИ к УЧ.ПЛАНУ
$predmets = iup_get_predmets_BYzp($id_zayavka);
//echo '<pre>'.print_r($predmets,1).'</pre>';
if(!count($predmets)) {
$val['predmets'] = iup_get_predmets($_SESSION['user']['teacher']['fakultet'], $val['pret_naprav'], $val['pret_kurs'], $val['pret_fo'],0);
//echo '<pre>'.print_r($val['predmets'],1).'</pre>'; exit();
}else{
$val['predmets'] = $predmets;
}
//echo '<pre>'.print_r($val['predmets'],1).'</pre>';
//echo '<pre>'.print_r($prep_pred,1).'</pre>';exit();
foreach($val['predmets'] as $k => $v){
$id_predmet = $v['id'];//id_user='.$_SESSION['user']['id'].' AND
if(in_array($id_predmet,$prep_pred)){//записываем предметы только те которые нам назначили
//нужно подгрузить выставленные оценки
$sql0 = 'SELECT * FROM '.$TB['iup_ocenki'].' WHERE id_studentzayavks='.$id_zayavka.' AND id_predmet='.$id_predmet.' ORDER BY id DESC LIMIT 1';
//echo $sql0;
$rez0 = $DB->QUR_SEL($sql0);
//echo $sql0.'<pre>'.print_r($rez0,1).'</pre>'; exit();
if($rez0){
$val0 = $rez0[1];
$val0['day'] = date('d.m.Y',$val0['data_time']);
$val0['time'] = date('H:i',$val0['data_time']);
$val0['comment'] = stripslashes($val0['comment']);
$val['predmets'][$k]['ocenki'] = $val0;
$val['predmets'][$k]['disable']=0;
}
}else{
$val['predmets'][$k]['disable']=1;
$sql11 = 'SELECT prepod_id,prepod_name FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka.' AND predmet_id='.$id_predmet.' ORDER BY id DESC';
$rez11 = $DB->QUR_SEL($sql11);
//echo $sql11.'<pre>'.print_r($rez11,1).'</pre>';
if($rez11){
$val['predmets'][$k]['prepod']=$rez11[1];
}else{
//Проверим на наличие назначенных предметов-преподов 09.10.2023
$sql11 = 'SELECT prepod_id,prepod_name FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka.' AND predmet_name="'.$v['name_disp'].'"';
$rez11 = $DB->QUR_SEL($sql11);
//echo $sql11.'<pre>'.print_r($rez11,1).'</pre>';
if($rez11&&$rez11[1]['prepod_id']==$_SESSION['user']['id']) {
$val['predmets'][$k]['prepod'] = $rez11[1];
$val['predmets'][$k]['disable']=0;
}else {
$val['predmets'][$k]['prepod'] = array();
}
}
//unset($val['predmets'][$k]);
}
}
//echo '<pre>'.print_r($val['predmets'],1).'</pre>';
$zayavka = $val;
$times=array('8:00','9:30','11:10','13:10','15:00','16:40','18:20');
$smarty->assign('times',$times);
$smarty->assign('zayavka',$zayavka);
//echo '<pre>'.print_r($zayavka,1).'</pre>';exit();
}else{
$des = 'show';
}
}
if($des == 'show'){
$zayavks=array(); $idz=array();
//выберем заявки в которых назначили нас преподом ставящим оценки!
$sql = 'SELECT id_studentzayavks FROM '.$TB['iup_zamdekan'].' WHERE prepod_id='.$_SESSION['user']['id'].' GROUP BY id_studentzayavks ORDER BY data_c DESC';
//закомментировал ниже, Галичева сказала, что у нее не отображаются ИУПЫ на странице члена аттестационной комиссии
//$sql = 'SELECT oc.*, zam.id_studentzayavks as id_studentzayavks, zam.predmet_id FROM '.$TB['iup_zamdekan'].' as zam, '.$TB['iup_ocenki'].' as oc WHERE zam.prepod_id='.$_SESSION['user']['id'].' AND oc.id_studentzayavks = zam.id_studentzayavks AND oc.id_predmet = zam.predmet_id GROUP BY zam.id_studentzayavks ORDER BY zam.data_c DESC';
//echo $sql;
$rez = $DB->QUR_SEL($sql); //echo $sql.'<pre>'.print_r().'</pre>';
if($rez){
foreach($rez as $key => $val)if($key){
$idz[]=$val['id_studentzayavks'];
}
}
if(count($idz)){
$sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE (id='.implode(' OR id=',$idz).') AND status=2 ORDER BY data_c DESC';
//echo $sql;
$rez = $DB->QUR_SEL($sql);//echo $sql.'<pre>'.print_r($rez,1).'</pre>';
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']);
//выберем все оценки для заявки
$rez1 = $DB->QUR_SEL('SELECT id FROM '.$TB['iup_zamdekan'].' WHERE id_studentzayavks='.$id_zayavka);
if($rez1){ $val['ocenki_all'] = $rez1[0]; }else{ $val['ocenki_all'] = 0; }
//сколько выставили оценок
//acs_iup_ocenki: id, data_c, id_studentzayavks, id_user, ocenka, predmet, id_predmet, tip, data_time, semestr, comment, kpro, krab, aud
$rez1 = $DB->QUR_SEL('SELECT * FROM '.$TB['iup_ocenki'].' WHERE id_studentzayavks='.$id_zayavka.' AND semestr!=0');
//echo '<pre>'.print_r($rez1,1).'</pre>';
if($rez1){ $val['ocenki_oth'] = $rez1[0]; }else{ $val['ocenki_oth'] = 0; }
//сколько мне надо выставить оценок
//acs_iup_zamdekan: id, data_c, user_id, id_studentzayavks, predmet_id, predmet_name, prepod_id, prepod_name
$rez1 = $DB->QUR_SEL('SELECT id FROM '.$TB['iup_zamdekan'].' WHERE prepod_id='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka);
if($rez1){ $val['ocenki_moi'] = $rez1[0]; }else{ $val['ocenki_moi'] = 0; }
//сколько я уже выставил
$rez1 = $DB->QUR_SEL('SELECT id FROM '.$TB['iup_ocenki'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$id_zayavka.'');
if($rez1){ $val['ocenki_est'] = $rez1[0]; }else{ $val['ocenki_est'] = 0; }
$zayavks[] = $val;
}
}
}
$smarty->assign('zayavks',$zayavks);
}
$smarty->assign('zamdeknaprav',$zamdeknaprav);
$smarty->assign('page',$page);
$smarty->assign('des',$des);
$smarty->assign('msg',$msg);
//$smarty->clear_cache('tpl_iup_main.html');
$maincontent = $smarty->fetch('tpl_iup_main.html');