';
/*[user][teacher][fakultet][kafedra]
Array
(
[user] => Array
(
[id] => 545
[data_c] => 1494592259
[data_u] => 1524482340
[email] => mirin@list.ru
[status] => 0
[fio] => Мальцева Ирина Сергеевна
[foto] =>
[statuses] => Array
(
[0] => 0
[21] => 21
)
[teacher] => Array
(
[id] => 72
[zvanie] => доцент
[dolgnost] => доцент кафедры экономической теории и мировой экономики
[stepen] => к.э.н
[fakultet] => Факультет экономики и сервиса
[kafedra] => Экономической теории и мировой экономики
[data_u] => 12:59:16 18.04.2018
[status] => 1
)
[lib] => 23a0acb5364fe8c34591e7ac562bb80b
[pm_new] => 0
[pm_kol] => 0
[pm] => Array
(
)
)
)
*/
if(isset($_GET['page'])){
if($_GET['page']=='workprogram'){//Рабочие программы
/*
id int(11)
data_c int(11)
data_u int(11)
id_teacher int(11)
specialnost varchar(255)
kurs tinyint(4)
semestr tinyint(4)
name varchar(255)
descrip text
10 file
*/
$lections=array(); $forms=array();
if(isset($_POST['lection_edit'])||isset($_POST['lection_save'])){
print_r ($_POST);
$specialnost=get_data_fu($_POST['specialnost']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
/*****/
$kurso=array();$kursz=array();$kursoz=array();
if(isset($_POST['kurso'])){
for($i=0;$i<=5;$i++){
if(isset($_POST['kurso'][$i])) $kurso[($i+1)]=1; else $kurso[($i+1)]=0;
}
}else $kurso=array(0,0,0,0,0,0);
if(isset($_POST['kursz'])){
for($i=0;$i<=5;$i++){
if(isset($_POST['kursz'][$i])) $kursz[($i+1)]=1; else $kursz[($i+1)]=0;
}
}else $kursz=array(0,0,0,0,0,0);
if(isset($_POST['kursoz'])){
for($i=0;$i<=5;$i++){
if(isset($_POST['kursoz'][$i])) $kursoz[($i+1)]=1; else $kursoz[($i+1)]=0;
}
}else $kursoz=array(0,0,0,0,0,0);
$kurs = implode(',',$kurso).'|'.implode(',',$kursz).'|'.implode(',',$kursoz);
/*****/
$semestro=array();$semestrz=array();$semestroz=array();
if(isset($_POST['semestro'])){
for($i=0;$i<=11;$i++){
if(isset($_POST['semestro'][$i])) $semestro[($i+1)]=1; else $semestro[($i+1)]=0;
}
}else $semestro=array(0,0,0,0,0,0,0,0,0,0,0,0);
if(isset($_POST['semestrz'])){
for($i=0;$i<=11;$i++){
if(isset($_POST['semestrz'][$i])) $semestrz[($i+1)]=1; else $semestrz[($i+1)]=0;
}
}else $semestrz=array(0,0,0,0,0,0,0,0,0,0,0,0);
if(isset($_POST['semestroz'])){
for($i=0;$i<=11;$i++){
if(isset($_POST['semestroz'][$i])) $semestroz[($i+1)]=1; else $semestroz[($i+1)]=0;
}
}else $semestroz=array(0,0,0,0,0,0,0,0,0,0,0,0);
$semestr = implode(',',$semestro).'|'.implode(',',$semestrz).'|'.implode(',',$semestroz);
//$kurs=(int)get_data_fu($_POST['kurs']); if($kurs=='') $kurs=0;
//$semestr=(int)get_data_fu($_POST['semestr']); if($semestr=='') $semestr=0;
$fo=array();
if(isset($_POST['fo1'])) $fo[]='оч';
if(isset($_POST['fo2'])) $fo[]='заоч';
if(isset($_POST['fo3'])) $fo[]='оч-заоч';
if(count($fo)) $fo = implode('|',$fo); else $fo='';
}
if(isset($_POST['lection_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$file=upload_lection('file','upload/workprogram/');
if ($file!=''){
unlink('upload/workprogram/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql = 'UPDATE '.$ST['dbpf'].'_workprogram SET data_u='.mktime().',specialnost="'.$specialnost.'",kurs="'.$kurs.'",semestr="'.$semestr.'",name="'.$name.'",descrip="'.$descrip.'",fo="'.$fo.'"'.$sf.' WHERE id='.$id.$aid.' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Программа отредактирована!';
//СОХРАНИМ ДЛЯ КАКИХ ГРУПП
$DB->QUR('DELETE FROM '.$ST['dbpf'].'_workprogram_grupp WHERE id_lections='.$id.'');
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
$DB->QUR('INSERT INTO '.$ST['dbpf'].'_workprogram_grupp VALUES (0,'.mktime().','.$id.','.$val.')');
}
}
}
$_GET['des']='';
save_logs('Рабочая программа отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Программа не отредактирована!'.$sql.mysql_error();
}
}
if(isset($_POST['lection_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
/*$specialnost=get_data_fu($_POST['specialnost']);
$kurs=(int)get_data_fu($_POST['kurs']);
$semestr=(int)get_data_fu($_POST['semestr']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$fo=get_data_fu($_POST['fo']);*/
$file=upload_lection('file','upload/workprogram/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_workprogram VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].',"'.$specialnost.'","'.$kurs.'","'.$semestr.'","'.$name.'","'.$descrip.'","'.$file.'","'.$fo.'")';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Программа добавлена!';
$id=mysql_insert_id();
//СОХРАНИМ ДЛЯ КАКИХ ГРУПП
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
$DB->QUR('INSERT INTO '.$ST['dbpf'].'_workprogram_grupp VALUES (0,'.mktime().','.$id.','.$val.')');
}
}
}
$_GET['des']='';
save_logs('Рабочая прорамма добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Программа не добавлена!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_workprogram WHERE id='.$id.$aid.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование рабочей программы';
$form['btn_url']='lection_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
if($rez[1]['fo']=='') $rez[1]['fo']='оч|заоч';
if($rez[1]['fo']!=''){
$t=explode('|',str_replace('/','|',$rez[1]['fo']));
$form['p']['fo1'] = '';
$form['p']['fo2'] = '';
if(count($t)>1){
if($t[0]=='оч') $form['p']['fo1'] = 'оч';
if($t[0]=='заоч') $form['p']['fo2'] = 'заоч';
if($t[0]=='оч-заоч') $form['p']['fo3'] = 'оч-заоч';
if($t[1]=='оч') $form['p']['fo1'] = 'оч';
if($t[1]=='заоч') $form['p']['fo2'] = 'заоч';
if($t[1]=='оч-заоч') $form['p']['fo3'] = 'оч-заоч';
}else{
if($t[0]=='оч') $form['p']['fo1'] = 'оч';
if($t[0]=='заоч') $form['p']['fo2'] = 'заоч';
if($t[0]=='оч-заоч') $form['p']['fo3'] = 'оч-заоч';
}
}
if($rez[1]['kurs']!=''){
$t=explode('|',$rez[1]['kurs']);
if(count($t)>1){
$form['p']['kurso']=explode(',',$t[0]);
$form['p']['kursz']=explode(',',$t[1]);
$form['p']['kursoz']=explode(',',$t[1]);
}else{
if($form['p']['fo1']=='оч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['kurso'][$i]=1; else $form['p']['kurso'][$i]=0;
}
if($form['p']['fo2']=='заоч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['kursz'][$i]=1; else $form['p']['kursz'][$i]=0;
}
if($form['p']['fo3']=='оч-заоч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['kursoz'][$i]=1; else $form['p']['kursoz'][$i]=0;
}
}
}
if($rez[1]['semestr']!=''){
$t=explode('|',$rez[1]['semestr']);
if(count($t)>1){
$form['p']['semestro']=explode(',',$t[0]);
$form['p']['semestrz']=explode(',',$t[1]);
$form['p']['semestroz']=explode(',',$t[1]);
}else{
if($form['p']['fo1']=='оч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['semestro'][$i]=1; else $form['p']['semestro'][$i]=0;
}
if($form['p']['fo2']=='заоч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['semestrz'][$i]=1; else $form['p']['semestrz'][$i]=0;
}
if($form['p']['fo2']=='оч-заоч'){
for($i=1;$i<=6;$i++) if($i==$rez[1]['kurs']) $form['p']['semestroz'][$i]=1; else $form['p']['semestroz'][$i]=0;
}
}
}
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['sokr']=out_data_fu($val1['sokr']);
$rez2=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_workprogram_grupp WHERE id_grupp='.$val1['id'].' AND id_lections='.$rez[1]['id'].'');
if ($rez2) $val1['sel']=1;
$form['p']['grupp'][]=$val1;
}
}
}
//echo '
'.print_r($form['p'],1).'
';
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление рабочей программы';
$form['btn_url']='lection_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$form['p']['fo1']='оч';
$sql1='SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY kurs,sokr';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['sokr']=out_data_fu($val1['sokr']);
$form['p']['grupp'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление рабочей программы';
$id=(int)$_GET['id'];
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_workprogram WHERE id='.$id.$aid.' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/workprogram/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_workprogram WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Рабочая программа удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все рабочие программы';
//if (get_prava_grupp(0)) $aid=''; else
$aid=' WHERE id_teacher='.$_SESSION['user']['teacher']['id'].'';
//$pagi=pagination('SELECT * FROM '.$ST['dbpf'].'_workprogram'.$aid.'',10);
$pagi=pagination('SELECT * FROM '.$ST['dbpf'].'_workprogram'.$aid.'',10);
$sql='SELECT * FROM '.$ST['dbpf'].'_workprogram'.$aid.' ORDER BY specialnost, kurs, semestr, fo,name '.$pagi['limit'];
//echo $sql;
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($val['fo']=='') $val['fo']='оч|заоч|оч-заоч';
$f=explode('|',str_replace('/','|',$val['fo']));
$val['fo'] = str_replace('|',', ',str_replace('/','|',$val['fo']));
if(strpos($val['kurs'],'|')===false){
$kurs = $val['kurs'];
if($f[0]=='оч') {
$val['kurs']=''; for($j=1;$j<=6;$j++) if($kurs==$j) $val['kurs'].='1,'; else $val['kurs'].='0,';
$val['kurs'].='|'; for($j=1;$j<=6;$j++) $val['kurs'].='0,';
}
if($f[0]=='заоч') {
$val['kurs']=''; for($j=1;$j<=6;$j++) $val['kurs'].='0,';
$val['kurs'].='|'; for($j=1;$j<=6;$j++) if($kurs==$j) $val['kurs'].='1,'; else $val['kurs'].='0,';
}
if($f[0]=='оч-заоч') {
$val['kurs']=''; for($j=1;$j<=6;$j++) $val['kurs'].='0,';
$val['kurs'].='|'; for($j=1;$j<=6;$j++) if($kurs==$j) $val['kurs'].='1,'; else $val['kurs'].='0,';
}
}
if(strpos($val['semestr'],'|')===false){
$semestr = $val['semestr'];
if($f[0]=='оч') {
$val['semestr']=''; for($j=1;$j<=6;$j++) if($semestr==$j) $val['semestr'].='1,'; else $val['semestr'].='0,';
$val['semestr'].='|'; for($j=1;$j<=6;$j++) $val['semestr'].='0,';
}
if($f[0]=='заоч') {
$val['semestr']=''; for($j=1;$j<=6;$j++) $val['semestr'].='0,';
$val['semestr'].='|'; for($j=1;$j<=6;$j++) if($semestr==$j) $val['semestr'].='1,'; else $val['semestr'].='0,';
}
if($f[0]=='оч-заоч') {
$val['semestr']=''; for($j=1;$j<=6;$j++) $val['semestr'].='0,';
$val['semestr'].='|'; for($j=1;$j<=6;$j++) if($semestr==$j) $val['semestr'].='1,'; else $val['semestr'].='0,';
}
}
$k = explode('|',$val['kurs']); $val['kurso'] = explode(',',$k[0]); $val['kursz'] = explode(',',$k[1]); $val['kursoz'] = explode(',',$k[1]);
$sh=false; foreach($val['kurso'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['kurs']='Оч: ';foreach($val['kurso'] as $k1 => $v1) if($v1!=0)$val['kurs'] .= $k1.',';
$sh=false; foreach($val['kursz'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['kurs'].='| Заоч: ';foreach($val['kursz'] as $k1 => $v1) if($v1!=0)$val['kurs'] .= $k1.',';
$sh=false; foreach($val['kursz'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['kurs'].='| Оч-заоч: ';foreach($val['kursoz'] as $k1 => $v1) if($v1!=0)$val['kurs'] .= $k1.',';
$s = explode('|',$val['semestr']); $val['semestro'] = explode(',',$s[0]); $val['semestrz'] = explode(',',$s[1]); $val['semestroz'] = explode(',',$s[1]);
$sh=false; foreach($val['semestro'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['semestr']='Оч: ';foreach($val['semestro'] as $k1 => $v1) if($v1!=0)$val['semestr'] .= $k1.',';
$sh=false; foreach($val['semestrz'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['semestr'].='| Заоч: ';foreach($val['semestrz'] as $k1 => $v1) if($v1!=0)$val['semestr'] .= $k1.',';
$sh=false; foreach($val['semestrz'] as $k1 => $v1) if($v1==1)$sh=true;
if($sh) $val['semestr'].='| Оч-заоч: ';foreach($val['semestroz'] as $k1 => $v1) if($v1!=0)$val['semestr'] .= $k1.',';
$lections[$i]=$val;
$i++;
}
}
}
//echo '
'.print_r($lections,1).'
';
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('pagination',$pagi);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_workprogram.html');
}
if($_GET['page']=='kursov'){//Курсовые
$lections=array(); $forms=array();
if(isset($_POST['kursov_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/kursov/');
if ($file!=''){
unlink('upload/kursov/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
$sql = 'UPDATE '.$ST['dbpf'].'_kursov SET data_u='.mktime().',id_lection='.$id_lection.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
$_GET['des']='';
save_logs('Курсовая отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['kursov_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/kursov/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_kursov VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$name.'","'.$descrip.'","'.$file.'")';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$_GET['des']='';
save_logs('Курсовая добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_kursov WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование курсовой';
$form['btn_url']='kursov_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
if ($rez[1]['id_lection']==$val1['id']) $val1['sel']=1;
$form['p']['lection'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление курсовой';
$form['btn_url']='kursov_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
$form['p']['lection'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление курсовой';
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_kursov WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/kursov/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_kursov WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Курсовая удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все курсовые';
$sql='SELECT * FROM '.$ST['dbpf'].'_kursov WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY id_lection';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['lection']=get_lection($val['id_lection']);
$lections[$i]=$val;
$i++;
}
}
}
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_kursov.html');
}
if($_GET['page']=='praktika'){//ПРАКТИКА
//года и форма обучения
$sql = 'SELECT * FROM '.$ST['dbpf'].'_profile_start ORDER BY `id_profile`';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
//выводим профиль подготовки
$sql_profile = 'SELECT * FROM '.$ST['dbpf'].'_profile WHERE `id` = "'.$val["id_profile"].'"';
$rez_profile = $DB->QUR_SEL($sql_profile);
$val['id_profile'] = $rez_profile[1]["name"];
$val['id_areas'] = $rez_profile[1]["id_areas"];
$sql_area = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE `id` = "'.$val["id_areas"].'"';
$rez_area = $DB->QUR_SEL($sql_area);
$val['code'] = $rez_area[1]['code'];
if ($val["forma"] == 1) $val["forma"] = "очная";
else $val["forma"] = "заочная";
$profiles_start[] = $val;
}
}
$smarty->assign('profiles_start', $profiles_start);
//НИЖЕ ИДЕТ СТАРЫЙ КОД
//пока не удаляю
$lections=array(); $forms=array();
if(isset($_POST['praktika_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/praktika/');
if ($file!=''){
unlink('upload/praktika/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
$sql = 'UPDATE '.$ST['dbpf'].'_praktika SET data_u='.mktime().',id_lection='.$id_lection.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
$_GET['des']='';
save_logs('Практика отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['praktika_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/praktika/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_praktika VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$name.'","'.$descrip.'","'.$file.'")';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$_GET['des']='';
save_logs('Практика добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_praktika WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование практики';
$form['btn_url']='praktika_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
if ($rez[1]['id_lection']==$val1['id']) $val1['sel']=1;
$form['p']['lection'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление практики';
$form['btn_url']='praktika_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
$form['p']['lection'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление практики';
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_praktika WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/praktika/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_praktika WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Практика удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все практики';
if (isset($_SESSION['user']['teacher']['id'])){
$sql='SELECT * FROM '.$ST['dbpf'].'_praktika WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY id_lection';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['lection']=get_lection($val['id_lection']);
$lections[$i]=$val;
$i++;
}
}
}
}
//все практики
$sql = 'SELECT * FROM '.$ST['dbpf'].'_practices';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
//направление (профиль) подготовки
$sql_start = 'SELECT * FROM '.$ST['dbpf'].'_profile_start WHERE `id` = "'.$val["id_start"].'"';
$rez_start = $DB->QUR_SEL($sql_start); //year start education
//profile education
$sql_profile = 'SELECT * FROM '.$ST['dbpf'].'_profile WHERE `id` = "'.$rez_start[1]["id_profile"].'"';
$rez_profile = $DB->QUR_SEL($sql_profile);
//areas education
$sql_area = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE `id` = "'.$rez_profile[1]["id_areas"].'"';
$rez_area = $DB->QUR_SEL($sql_area);
//код направления - профиль направления
$val['id_start'] = $rez_area[1]["code"]." ".$rez_profile[1]["name"];
//год подготовки
$val['year'] = $rez_start[1]["year"];
//форма обучения
$val['forma'] = $rez_start[1]["forma"];
if ($val["forma"] == 1) $val["forma"] = "очная";
else $val["forma"] = "заочная";
$practices[] = $val;
}
}
//ВЫБЕРЕМ ДАННЫЕ УЧИТЕЛЯ
$sql = 'SELECT * FROM '.$ST['dbpf'].'_teachers WHERE id_user='.$_SESSION['user']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
$teacher['zvanie']=out_data_fu($rez[1]['zvanie']);
$teacher['dolgnost']=out_data_fu($rez[1]['dolgnost']);
$teacher['stepen']=out_data_fu($rez[1]['stepen']);
$teacher['fakultet']=out_data_fu($rez[1]['fakultet']);
$teacher['kafedra']=out_data_fu($rez[1]['kafedra']);
$teacher['data_u']=date('H:i:s d.m.Y',$rez[1]['data_u']);
if ($rez[1]['status']==0) $teacher['status'] = 'не подтвержден';
if ($rez[1]['status']==1) $teacher['status'] = 'подтвержден';
}
$smarty->assign('teacher',$teacher);
//практики определенной кафедры
$sql = 'SELECT * FROM '.$ST['dbpf'].'_practices';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
//направление (профиль) подготовки
$sql_start = 'SELECT * FROM '.$ST['dbpf'].'_profile_start WHERE `id` = "'.$val["id_start"].'"';
$rez_start = $DB->QUR_SEL($sql_start); //year start education
//profile education
$sql_profile = 'SELECT * FROM '.$ST['dbpf'].'_profile WHERE `id` = "'.$rez_start[1]["id_profile"].'"';
$rez_profile = $DB->QUR_SEL($sql_profile);
//areas education
$sql_area = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE `id` = "'.$rez_profile[1]["id_areas"].'"';
$rez_area = $DB->QUR_SEL($sql_area);
//код направления - профиль направления
$val['id_start'] = $rez_area[1]["code"]." ".$rez_profile[1]["name"];
//год подготовки
$val['year'] = $rez_start[1]["year"];
//форма обучения
$val['forma'] = $rez_start[1]["forma"];
if ($val["forma"] == 1) $val["forma"] = "очная";
else $val["forma"] = "заочная";
$practices_kafedra[] = $val;
}
}
//практики определенной кафедры из учебных планов - для экономии времени
$pract_plans = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_kafedres WHERE name = "'.$teacher['kafedra'].'"';
$rez = $DB->QUR_SEL($sql); //достаем одну кафедру
$id_kaf = $rez[1]["id"]; //айдишник кафедры
$sql_areas = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE `id_kafedra` = "'.$id_kaf.'"';
$rez_areas = $DB->QUR_SEL($sql_areas);
if ($rez_areas){
$code = $rez_areas[1]["code"];
$sql_plans = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE `shifr1` = "'.$code.'"';
$sql_plans = $DB->QUR_SEL($sql_plans);
foreach ($sql_plans as $key => $value) if ($key){
$name = $value["shifr1"].' '.$value['nappodgo'];
$id_plan = $value["id"];
$year = $value["godnap"];
$forma = $value["forobu"];
$sql_stroki = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE `id_plans` = "'.$id_plan.'" AND `discip` LIKE "%Практика%"';
$rez_stroki = $DB->QUR_SEL($sql_stroki);
foreach ($rez_stroki as $key_str => $value_str) if ($key_str){ //перебираем все практики определенного учебного плана для кафедры, которая указана у пользователя
if ($value_str['ekz'] != '') $value_str['control'] = 'экзамен';
else $value_str['control'] = 'зачет';
$value_str['year'] = $year;
$value_str['forma'] = $forma;
$value_str['name'] = $name;
$pract_plans[] = $value_str;
}
}
}
$smarty->assign('pract_plans', $pract_plans);
//************************************ENDD***************************
$smarty->assign('practices',$practices);
$smarty->assign('practices_kafedra',$practices_kafedra);
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_praktika.html');
}
if($_GET['page']=='controln'){//контрольные материалы
$lections=array(); $forms=array();
if(isset($_POST['controln_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/controln/');
if ($file!=''){
unlink('upload/controln/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
$sql = 'UPDATE '.$ST['dbpf'].'_controln SET data_u='.mktime().',id_lection='.$id_lection.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
$_GET['des']='';
save_logs('Контрольная отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['controln_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/controln/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_controln VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$name.'","'.$descrip.'","'.$file.'")';
$rez = $DB->QUR($sql); //echo $sql;
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$_GET['des']='';
save_logs('Контрольная добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_controln WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование контрольной';
$form['btn_url']='controln_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
if ($rez[1]['id_lection']==$val1['id']) $val1['sel']=1;
$form['p']['lection'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление контрольной';
$form['btn_url']='controln_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
$form['p']['lection'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление контрольной';
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_controln WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/controln/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_controln WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Контрольная удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все контрольные';
$sql='SELECT * FROM '.$ST['dbpf'].'_controln WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY id_lection';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['lection']=get_lection($val['id_lection']);
$lections[$i]=$val;
$i++;
}
}
}
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_controln.html');
}
if($_GET['page']=='sr'){//задания для самостоятельной работы студентов
$lections=array(); $forms=array();
if(isset($_POST['sr_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/sr/');
if ($file!=''){
unlink('upload/sr/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
$sql = 'UPDATE '.$ST['dbpf'].'_sr SET data_u='.mktime().',id_lection='.$id_lection.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
$_GET['des']='';
save_logs('Задание для самостоятельной работы отредактировано '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['sr_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/sr/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_sr VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$name.'","'.$descrip.'","'.$file.'")';
$rez = $DB->QUR($sql); //echo $sql;
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$_GET['des']='';
save_logs('Самостоятельная добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_sr WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование контрольной';
$form['btn_url']='sr_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
if ($rez[1]['id_lection']==$val1['id']) $val1['sel']=1;
$form['p']['lection'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление самостоятельной работы';
$form['btn_url']='sr_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
$form['p']['lection'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление контрольной';
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_sr WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/sr/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_sr WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Задание для сам. работы удалено '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все контрольные';
$sql='SELECT * FROM '.$ST['dbpf'].'_sr WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY id_lection';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['lection']=get_lection($val['id_lection']);
$lections[$i]=$val;
$i++;
}
}
}
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_sr.html');
}
if($_GET['page']=='practic'){//практические материалы
/*
id int(11)
data_c int(11)
data_u int(11)
id_teacher int(11)
specialnost varchar(255)
kurs tinyint(4)
semestr tinyint(4)
name varchar(255)
descrip text
10 file
*/
$lections=array(); $forms=array();
if(isset($_POST['practic_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/practic/');
if ($file!=''){
unlink('upload/practic/'.$_POST['ofile']);
$sf=',file="'.$file.'"';
}else $sf='';
$sql = 'UPDATE '.$ST['dbpf'].'_practich SET data_u='.mktime().',id_lection='.$id_lection.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
$_GET['des']='';
save_logs('Практическя отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['practic_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$id_lection=0; if($_POST['id_lection']!='') $id_lection=get_data_fu($_POST['id_lection']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$file=upload_lection('file','upload/practic/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_practich VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$name.'","'.$descrip.'","'.$file.'")';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$_GET['des']='';
save_logs('Практическая добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_practich WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование практической';
$form['btn_url']='practic_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
if ($rez[1]['id_lection']==$val1['id']) $val1['sel']=1;
$form['p']['lection'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление практической';
$form['btn_url']='practic_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY name';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['specialnost']=out_data_fu($val1['specialnost']);
$val1['name']=out_data_fu($val1['name']);
$val1['kurs']=out_data_fu($val1['kurs']);
$val1['semestr']=out_data_fu($val1['semestr']);
$form['p']['lection'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление практической';
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_practich WHERE id='.$id.' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/practic/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_practich WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('практическая удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все практические';
$sql='SELECT * FROM '.$ST['dbpf'].'_practich WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' ORDER BY id_lection';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['lection']=get_lection($val['id_lection']);
$lections[$i]=$val;
$i++;
}
}
}
//echo '
'.print_r($lections,1).'
';
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_practic.html');
}
if($_GET['page']=='lection'){//лекционные материалы
/*
id int(11)
data_c int(11)
data_u int(11)
id_teacher int(11)
specialnost varchar(255)
kurs tinyint(4)
semestr tinyint(4)
name varchar(255)
descrip text
10 file
*/
$lections=array(); $forms=array();
if(isset($_POST['lection_edit'])){//РЕДАКТИРОВАНИЕ МАТЕРИАЛА
$id=(int)$_POST['id'];
$specialnost=get_data_fu($_POST['specialnost']);
$kurs=(int)get_data_fu($_POST['kurs']); if($kurs=='') $kurs=0;
$semestr=(int)get_data_fu($_POST['semestr']); if($semestr=='') $semestr=0;
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$type=get_data_fu($_POST['type']);
if(isset($_POST['del_file'])){
$df=explode('|',$_POST['ofile']);
foreach($_POST['del_file'] as $k => $v){
if($v!=''){
if(in_array($v,$df)){
$key = array_search($v,$df);
unlink('upload/lections/'.$v);
unset($df[$key]);
}
}
}
}
$file=upload_lection('file','upload/lections/');
if ($file!=''){
//unlink('upload/lections/'.$_POST['ofile']);
$sf=',file="'.$file.'|'.implode('|',$df).'"';
}else {
$sf=',file="'.implode('|',$df).'"';
}
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
//$sql = 'UPDATE '.$ST['dbpf'].'_lections SET data_u='.mktime().',specialnost="'.$specialnost.'",kurs='.$kurs.',semestr='.$semestr.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.$aid.' LIMIT 1';
$sql = 'UPDATE '.$ST['dbpf'].'_lections SET data_u='.mktime().',specialnost="'.$specialnost.'",type="'.$type.'",kurs='.$kurs.',semestr='.$semestr.',name="'.$name.'",descrip="'.$descrip.'"'.$sf.' WHERE id='.$id.$aid.' LIMIT 1';
$rez = $DB->QUR($sql); //echo $sql;
if(!$rez['err']){
$form['msg']='Материал отредактирован!';
//СОХРАНИМ ДЛЯ КАКИХ ГРУПП
$DB->QUR('DELETE FROM '.$ST['dbpf'].'_lections_grupp WHERE id_lections='.$id.'');
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
$DB->QUR('INSERT INTO '.$ST['dbpf'].'_lections_grupp VALUES (0,'.mktime().','.$id.','.$val.')');
}
}
}
$_GET['des']='';
save_logs('Лекция отредактирована '.$id.' : '.$name.'');
}else{
$form['err'][]='Материал не отредактирован!'.$sql.mysql_error();
}
}
if(isset($_POST['lection_save'])){//ДОБАВЛЕНИЕ МАТЕРИАЛА
$specialnost=get_data_fu($_POST['specialnost']);
$kurs=(int)get_data_fu($_POST['kurs']);
$semestr=(int)get_data_fu($_POST['semestr']);
$name=get_data_fu($_POST['name']);
$descrip=get_data_fu($_POST['descrip']);
$type=get_data_fu($_POST['type']);
$file=upload_lection('file','upload/lections/');
$sql = 'INSERT INTO '.$ST['dbpf'].'_lections VALUES (0,'.mktime().','.mktime().','.$_SESSION['user']['teacher']['id'].',"'.$specialnost.'",'.$kurs.','.$semestr.',"'.$name.'","'.$descrip.'","'.$file.'","'.$type.'")';
$rez = $DB->QUR($sql); //echo $sql.'
'.print_r($rez,1).'
';
if(!$rez['err']){
$form['msg']='Материал добавлен!';
$id=mysql_insert_id();
//СОХРАНИМ ДЛЯ КАКИХ ГРУПП
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
$DB->QUR('INSERT INTO '.$ST['dbpf'].'_lections_grupp VALUES (0,'.mktime().','.$id.','.$val.')');
}
}
}
$_GET['des']='';
save_logs('Лекция добавлена '.mysql_insert_id().' : '.$name.'');
}else{
$form['err'][]='Материал не добавлен!';
}
}
if(isset($_POST['import_add_teach_mat'])){//ИМПОРТ МАТЕРИАЛОВ ИЗ РАСЧЕТА ЧАСОВ
//echo '
'.print_r($_POST,1).'
';
$fmetka = $_POST['fmetka'];
$json = file_get_contents('tmp/materials/'.$_SESSION['user']['teacher']['id'].'_'.$fmetka.'.json');
foreach($_POST['import_add'] as $key => $val){//обходим все выбранные материалы
$import_tip = $_POST['import_tip'][$key];
$arr = json_decode($json,1);
$sql = 'SELECT id FROM '.$ST['dbpf'].'_'.$import_tip.' WHERE name="'.$arr['raspred'][$key]['name_disp'].'" AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez = $DB->QUR_SEL($sql);
$isset=false;if($rez)$isset=true;
if(!$isset){
//$form['html'] .=$sql.'
'.print_r($rez,1).'
';
$sql = 'SELECT id FROM '.$ST['dbpf'].'_grupp WHERE sokr="'.$arr['raspred'][$key]['spec'].'" AND kurs='.$arr['raspred'][$key]['kurs'].' AND fo="'.$arr['raspred'][$key]['fo'].'"';
$rez = $DB->QUR_SEL($sql);
if(!$rez){
$sql = 'INSERT INTO '.$ST['dbpf'].'_grupp VALUES(0,'.time().','.time().',"","","",'.$arr['raspred'][$key]['kurs'].',"'.$arr['raspred'][$key]['spec'].'","'.$arr['raspred'][$key]['fo'].'",0)';
$rez = $DB->QUR($sql);
$id_grupp = mysql_insert_id();
}else{
$id_grupp = $rez[1]['id'];
}
if($import_tip=='lections'){/*id data_c data_u id_teacher specialnost kurs semestr name descrip file*/
$sql = 'INSERT INTO '.$ST['dbpf'].'_lections VALUES(0,'.time().','.time().','.$_SESSION['user']['teacher']['id'].',"'.$arr['raspred'][$key]['spec'].'",'.$arr['raspred'][$key]['kurs'].','.$arr['raspred'][$key]['semestr'].',"'.$arr['raspred'][$key]['name_disp'].'","Лекции","")';
$rez = $DB->QUR($sql);
}
if($import_tip=='practich'){/*id data_c data_u id_teacher id_lection name descrip file */
$id_lection=check_lection($arr['raspred'][$key]);
$sql = 'INSERT INTO '.$ST['dbpf'].'_practich VALUES(0,'.time().','.time().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$arr['raspred'][$key]['name_disp'].'","Практические занятия","")';
$rez = $DB->QUR($sql);
}
if($import_tip=='controln'){/*id data_c data_u id_teacher id_lection name descrip file */
$id_lection=check_lection($arr['raspred'][$key]);
$sql = 'INSERT INTO '.$ST['dbpf'].'_controln VALUES(0,'.time().','.time().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$arr['raspred'][$key]['name_disp'].'","Контрольные работы","")';
$rez = $DB->QUR($sql);
}
if($import_tip=='kursov'){/*id data_c data_u id_teacher id_lection name descrip file */
$id_lection=check_lection($arr['raspred'][$key]);
$sql = 'INSERT INTO '.$ST['dbpf'].'_kursov VALUES(0,'.time().','.time().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$arr['raspred'][$key]['name_disp'].'","Курсовые работы","")';
$rez = $DB->QUR($sql);
}
if($import_tip=='praktika'){/*id data_c data_u id_teacher id_lection name descrip file */
$id_lection=check_lection($arr['raspred'][$key]);
$sql = 'INSERT INTO '.$ST['dbpf'].'_praktika VALUES(0,'.time().','.time().','.$_SESSION['user']['teacher']['id'].','.$id_lection.',"'.$arr['raspred'][$key]['name_disp'].'","Практика","")';
$rez = $DB->QUR($sql);
}
}
}
$_GET['des'] = 'show';
}
$regim='show';
if (isset($_GET['des'])){
if ($_GET['des']=='link'){//привязка лекций к своему аккаунту
$id=(int)$_GET['id'];
$sql='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$id.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$l=$rez[1];
$sql = 'INSERT INTO '.$ST['dbpf'].'_lections VALUES(0,'.$l['data_c'].','.$l['data_u'].','.$_SESSION['user']['teacher']['id'].',"'.$l['specialnost'].'",'.$l['kurs'].','.$l['semestr'].',"'.$l['name'].'","'.$l['descrip'].'","'.$l['file'].'")';
$rez=$DB->QUR($sql);
if(!$rez['err']){
$id_lection = mysql_insert_id();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp WHERE id_lections='.$id.'';
$rez=$DB->QUR_SEL($sql);
foreach($rez as $key => $val)if($key){
$sql1 = 'INSERT INTO '.$ST['dbpf'].'_lections_grupp VALUES(0,'.$val['data_c'].','.$id_lection.','.$val['id_grupp'].')';
$rez1=$DB->QUR($sql1);
}
}
}
}
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$id.$aid.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование лекции';
$form['btn_url']='lection_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
$form['p']['ofile']='';
$form['p']['mfile']=explode('|',$rez[1]['file']);
$sql1='SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['sokr']=out_data_fu($val1['sokr']);
$rez2=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections_grupp WHERE id_grupp='.$val1['id'].' AND id_lections='.$rez[1]['id'].'');
if ($rez2) $val1['sel']=1;
$form['p']['grupp'][]=$val1;
}
}
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление лекции';
$form['btn_url']='lection_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE NOT sokr LIKE "%Выпуск%" ORDER BY kurs,sokr';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['sokr']=out_data_fu($val1['sokr']);
$val['fo']=out_data_fu($val1['fo']);
$form['p']['grupp'][]=$val1;
}
}
}
if ($_GET['des']=='del'){//удаление
$id=(int)$_GET['id'];
$ST['page']['name'] = 'Удаление лекции';
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$id.$aid.' LIMIT 1';
$rez=$DB->QUR_SEL($sql);
if($rez){
if($rez[1]['file']!='') unlink('upload/lections/'.$rez[1]['file']);
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_lections WHERE id='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Материал успешно удален.';
save_logs('Лекция удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такого материала!';
}
if($_GET['des']=='ch_import'){
$regim='ch_import';
if(!isset($_SESSION['learn_teach_import'])){
$json = file_get_contents('http://local.mkgtu.ru/calchour_2017/get_json.php?json=ln_teach_lection&prepod='.urlencode($_SESSION['user']['fio']).'');
}else{
$json = file_get_contents('tmp/materials/'.$_SESSION['user']['teacher']['id'].'_'.$_SESSION['learn_teach_import'].'.json');
}
if($json!=''){
if(!isset($_SESSION['learn_teach_import'])){
$fmetka = $_SESSION['learn_teach_import'] = time();
file_put_contents('tmp/materials/'.$_SESSION['user']['teacher']['id'].'_'.$fmetka.'.json',$json);
}else $fmetka = $_SESSION['learn_teach_import'];
$arr = json_decode($json,1); $isset=array();
if(!isset($arr['err'])){
//$form['html'].='
'.print_r($arr,1).'
';
$form['html'].='Результат импорта:';
}else $form['err'][]='Не найден преподаватель. Измените свое ФИО в профиле и попробуйте еще раз.';
}else $form['err'][]='Импортирование! Пустой ответ от сервера!';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все лекции';
//if (get_prava_grupp(0)) $aid=''; else //смывсла нет в этом все лекции без поиска и т.д.
$aid=' WHERE id_teacher='.$_SESSION['user']['teacher']['id'].'';
$pagi=pagination('SELECT * FROM '.$ST['dbpf'].'_lections'.$aid.'',500);
//$sql='SELECT * FROM '.$ST['dbpf'].'_lections'.$aid.' ORDER BY kurs,semestr, name '.$pagi['limit'];
$sql='SELECT * FROM '.$ST['dbpf'].'_lections'.$aid.' ORDER BY specialnost '.$pagi['limit'];
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$sql1='SELECT g.* FROM '.$ST['dbpf'].'_lections_grupp as lg,'.$ST['dbpf'].'_grupp as g WHERE lg.id_lections='.$val['id'].' AND g.id=lg.id_grupp';
$rez1=$DB->QUR_SEL($sql1);
$val['grups']=array();
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['grups'][]=$val1;
}
}
$val['mfile']=explode('|',$val['file']);
$lections[$i]=$val;
$i++;
}
}
$leckaf=array();
//выберем все лекции у кафедры!!! $_SESSION['user']['teacher']['kafedra']
$sql = 'SELECT l.* FROM '.$ST['dbpf'].'_teachers as t,'.$ST['dbpf'].'_lections as l WHERE l.id_teacher=t.id AND t.kafedra="'.$_SESSION['user']['teacher']['kafedra'].'"';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$sql1='SELECT g.* FROM '.$ST['dbpf'].'_lections_grupp as lg,'.$ST['dbpf'].'_grupp as g WHERE lg.id_lections='.$val['id'].' AND g.id=lg.id_grupp';
$rez1=$DB->QUR_SEL($sql1);
$val['grups']=array();
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['grups'][]=$val1;
}
}
$leckaf[]=$val;
}
}
}
//список дисциплин из расчета часов - из карточки
$url = 'http://local.mkgtu.ru/calchour_2023/get_json.php?json=get_info_prepod&fio='.urlencode($_SESSION['user']['fio']).'';
//echo $url.' ';
$json = file_get_contents($url);
//file_put_contents($file,$json);
$json = json_decode($json,1);
//$json['db'] = getUniqueArray('name_disp', $json['db']);
//echo '
'; print_r ($json); echo '
';exit();
$disc = array();
foreach ($json['db'] as $key => $val) if ($key){
$val['name_disp'] = trim(preg_replace('/[\t\n\r\s]+/', ' ', $val['name_disp']));
$disc[] = $val;
}
//********************//
$smarty->assign('leckaf',$leckaf);
$smarty->assign('regim',$regim);
$smarty->assign('lections',$lections);
$smarty->assign('pagination',$pagi);
$smarty->assign('form',$form);
$smarty->assign('disc',$disc);
$maincontent = $smarty->fetch('tpl_teacher_lection.html');
}
//ОТМЕНА ПРИВЯЗКИ ГРУПП К ЛЕКЦИЯМ ОПРЕДЕЛЕННОГО ПРЕПОДАВАТЕЛЯ, т.е. под которым сейчас авторизованы
if ($_GET['page'] == 'cancel_binding'){
$sql = 'SELECT * FROM '.$ST['dbpf'].'_lections WHERE id_teacher='.$_SESSION['user']['teacher']['id'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$sql2 = 'DELETE FROM '.$ST['dbpf'].'_lections_grupp WHERE id_lections='.$val['id'].' LIMIT 1';
$rez2 = $DB->QUR_SEL($sql2);
}
}
save_logs('Отменена привязка к лекциям учебных групп у преподавателя (!)'.$_SESSION['user']['teacher']['id'].' ');
$smarty->assign('message',"Привязка лекций к группам отменена");
$smarty->assign('link',"/teach/lection/");
$maincontent = $smarty->fetch('tpl_refresh.html');
}
if($_GET['page']=='tests'){
$TS['view']='teacher';
include 'tests.php';
}
//if($_GET['page']=='ocenki' && false){//оценки
if($_GET['page']=='ocenki'){//оценки
$id_prepod=$_SESSION['user']['teacher']['id'];
$data_c1 = get_data_startsemestr();
$smarty->assign('data_c1',$data_c1);
if(!isset($_GET['des'])){
$regim = 'ocenki_grupps';
$grupps = array();
//выберем все группы
$sql = 'SELECT g.* FROM '.$ST['dbpf'].'_grupp as g, '.$ST['dbpf'].'_grupp_teachers as gt WHERE gt.id_teacher='.$id_prepod.' AND gt.id_grupp=g.id';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$rez1 = $DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].'');
if (isset($_GET["podgruppa"])){ //если указана подгруппа, то выводим только студентов этой подгруппы
$podgruppa = $_GET["podgruppa"];
//$rez1 = $DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].' AND num_grupp='.$podgruppa.'');
$rez1 = $DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].' AND status = 1 AND num_grupp='.$podgruppa.''); //НЕ ОТЧИСЛЕННЫЕ!!!
}
if($rez1){ $val['students'] = $rez1[0]; } else $val['students'] = 0;
$rez1 = $DB->QUR_SEL('SELECT l.id FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$val['id'].' AND lg.id_lections=l.id AND l.id_teacher='.$id_prepod.'');
if($rez1){ $val['lekcii'] = $rez1[0]; } else $val['lekcii'] = 0;
$grupps[]=$val;
}
}
$smarty->assign('grupps',$grupps);
}
//if($_GET['des']=='grupp'||$_GET['des']=='gruppo'){
if($_GET['des']=='grupp'||$_GET['des']=='gruppo'){
$regim = 'ocenki_gruppa';
$id_grupp = (int)$_GET['id'];
if(isset($_POST['save'])){
//echo '
1';
/*
$ocenki['grupp']=array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$id_grupp.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
$ocenki['grupp']=$rez[1];
}
$ocenki['students']=array();
//выберем всех студентов
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$id_grupp.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_users WHERE id='.$val['id_user'].' LIMIT 1';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){ $val['user'] = $rez1[1]; } else $val['user'] = array();
$ocenki['students'][]=$val;
}
}
//выберем все дисциплины
$ocenki['lections']=array();
$sql = 'SELECT l.* FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$id_grupp.' AND lg.id_lections=l.id AND l.id_teacher='.$id_prepod.' ORDER BY l.kurs,l.semestr';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_practich WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['practich'][] = $val1;
}
} else $val['controln'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_controln WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['controln'][] = $val1;
}
} else $val['controln'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_praktika WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['praktika'][] = $val1;
}
} else $val['praktika'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_kursov WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['kursov'][] = $val1;
}
} else $val['kursov'] = array();
$ocenki['lections'][]=$val;
}
}
//выберем все оценки
$sql = 'SELECT * FROM '.$ST['dbpf'].'_ocenki WHERE id_grupp='.$id_grupp.' AND id_prepod='.$id_prepod;
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$ocenki['saves']['propusk'][$val['id_what']][$val['id_student']]=$val['propusk'];
$ocenki['saves']['upv'][$val['id_what']][$val['id_student']]=$val['upv'];
if($val['what']=='lection') {
$ocenki['saves']['ol'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
}
if($val['what']=='practich') {
$ocenki['saves']['pr'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
}
if($val['what']=='controln') {
$ocenki['saves']['co'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
}
if($val['what']=='praktika') {
$ocenki['saves']['pra'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
}
if($val['what']=='kursov') {
$ocenki['saves']['kur'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
}
}
}
//echo '
'.print_r($ocenki,1).'
';
*/
$smarty->assign('ocenki',$ocenki);
}
$typeatt=1;
if($_GET['des']=='fakultet1'){//текущая аттестация
$_GET['des']='fakultet';
$typeatt = 1;
}
if($_GET['des']=='fakultet2'){//итоговая аттестация
$_GET['des']='fakultet';
$typeatt = 2;
}
if($_GET['des']=='fakultet3'){//сводная текущая
$_GET['des']='fakultet';
$typeatt = 3;
}
if($_GET['des']=='fakultet4'){//сводная итоговая
$_GET['des']='fakultet';
$typeatt = 4;
}
$ssl_ind = 0;
if($_GET['des']=='fakultet'){
$regim = 'ocenki_fakultet';
//тут надо получать все группы факультета!
if(!isset($_GET['id'])){
$fak = $_SESSION['user']['teacher']['fakultet'];//[kafedra]
$gruppss = array();
//собираем всех преподов с факультета
$sql = 'SELECT t.id,u.fio FROM '.$ST['dbpf'].'_teachers as t,'.$ST['dbpf'].'_users as u WHERE NOT(u.status = -1) AND u.id=t.id_user AND t.fakultet="'.$fak.'" ';
$rez =$DB->QUR_SEL($sql);
foreach($rez as $key => $val)if($key){
//собираем группы от преподов
$sql1 = 'SELECT g.id,g.sokr,g.fo,g.kurs FROM '.$ST['dbpf'].'_grupp_teachers as gt,'.$ST['dbpf'].'_grupp as g WHERE gt.id_teacher='.$val['id'].' AND gt.id_grupp=g.id';
$rez1 =$DB->QUR_SEL($sql1);
foreach($rez1 as $key1 => $val1)if($key1){
$val1['fio'] = $val['fio'];
$sql2 = 'SELECT count(id) as ks FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val1['id'].'';
$rez2 =$DB->QUR_SEL($sql2);
if($rez2){ $val1['kolstud']=$rez2[1]['ks']; }else $val1['kolstud']=0;
$sql2 = 'SELECT count(id) as ks FROM '.$ST['dbpf'].'_ocenki WHERE id_grupp='.$val1['id'].' AND data_c>='.$data_c1.'';
$rez2 =$DB->QUR_SEL($sql2);
if($rez2){ $val1['kolocenki']=$rez2[1]['ks']; }else $val1['kolocenki']=0;
$add=true;
foreach($gruppss as $k => $v){
$id_grupp = $val1['id'];
//выводим количество преподаваемых дисциплин для этой группы
//$sql3 = 'SELECT l.* FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$id_grupp.' AND lg.id_lections=l.id AND l.id_teacher='.$val['id'].' ORDER BY l.kurs,l.semestr';
$sql3 = 'SELECT l.* FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$id_grupp.' AND lg.id_lections=l.id AND l.id_teacher='.$val['id'].' ORDER BY l.kurs,l.semestr';
$rez3 = $DB->QUR_SEL($sql3);
$i = 0;
foreach ($rez3 as $key3 => $val3) {
if ($key3) $i++;
}
if($v['id']==$val1['id']) { $gruppss[$k]['fio'] .= ' (0 из '.$i.'); '.$val1['fio']; $add=false; }
//if($v['id']==$val1['id']) { $gruppss[$k]['fio'] .= $str.'12'; $add=false; }
}
if($add) $gruppss[]=$val1;
}
}
$smarty->assign('gruppss',$gruppss);
//echo '
'.print_r($gruppss,1).'
1';
}
else{//выбираем все оценки для группы
$id_grupp = (int)$_GET['id'];
$ocenki = get_ocenki($id_grupp,0);
$smarty->assign('ocenki',$ocenki);
$page['name'] = $ocenki['grupp']['sokr'].'-'.$ocenki['grupp']['kurs'];
$site['name'] = 'Промежуточная аттестация и результаты освоения программы';
$smarty->assign('Gdata',date('H:i d.m.Y'));
$smarty->assign('typeatt',$typeatt);
$smarty->assign('page',$page);
$smarty->assign('site',$site);
$smarty->assign('regim',$regim);
if($typeatt==1||$typeatt==2) $smarty->display('tpl_teacher_ocenki_fakultet.html');
if($typeatt==3||$typeatt==4) $smarty->display('tpl_teacher_ocenki_fakultet_svodnaya.html');
//echo '
';
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
$rez=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_grupp_teachers WHERE id_grupp='.$val.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez){
$DB->QUR('INSERT INTO '.$ST['dbpf'].'_grupp_teachers VALUES (0,'.$val.','.$_SESSION['user']['teacher']['id'].')');
}
}
}
}
$_GET['des']='';
$form['msg']='Группа привязаны!';
save_logs('Группа привязаны');
}
if(isset($_POST['grupp_pass'])){//ОТОБРАЖЕНИЕ ПАРОЛЕЙ СТУДЕНТОВ ГРУППЫ
$gr=array();
if(isset($_POST['l_g'])){
if(count($_POST['l_g'])){
foreach($_POST['l_g'] as $key => $val){
//$DB->QUR('INSERT INTO '.$ST['dbpf'].'_lections_grupp VALUES (0,'.mktime().','.$id.','.$val.')');
$gr[]=$val;
}
$sql = 'SELECT u.*,s.num_grupp,s.id_grupp FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE (s.id_grupp='.implode(' OR s.id_grupp=',$gr).') AND u.id=s.id_user';
$rez = $DB->QUR_SEL($sql); //echo $sql.mysql_error();
if($rez){
$passs=array();
foreach($rez as $key => $val)if($key){
$val['fio'] = out_data_fu($val['fio']);
$val['email'] = out_data_fu($val['email']);
$val['pass'] = out_data_fu($val['pass']);
$rez0 = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$val['id_grupp'].'');
$val['grupp'] = out_data_fu($rez0[1]['sokr'].'-'.$rez0[1]['kurs']);
$val['num_grupp'] = out_data_fu($val['num_grupp']);
$passs[] = $val;
}
$smarty->assign('passs',$passs);
}
}else $form['err'][]='Надо выбрать хотя бы 1 группу!';
}else $form['err'][]='Группа не выбрана!';
}
//echo '
'.print_r($_POST,1).'
';
if(isset($_POST['import_add'])||isset($_POST['import_del'])){//обрабатываем форму после подтверждения!
//$form['html'] = '
'.print_r($_POST,1).'
';
if(isset($_POST['import_add'])&&count($_POST['import_add'])){//Добавляем группы
foreach($_POST['import_add'] as $key=> $val){
$sokr = $val['sokr'];
$kurs = $val['kurs'];
$fo = $val['fo'];
$sql = 'SELECT id FROM '.$ST['dbpf'].'_grupp WHERE kurs='.$kurs.' AND sokr="'.$sokr.'" AND fo="'.$fo.'"';
$rez = $DB->QUR_SEL($sql);
if(!$rez){
$sql = 'INSERT INTO '.$ST['dbpf'].'_grupp VALUES(0,'.time().','.time().',"","","",'.$kurs.',"'.$sokr.'","'.$fo.'",0)';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']) $form['html'].='Группа '.$sokr.'-'.$kurs.' добавлена! ';
else $form['html'].='Группа '.$sokr.'-'.$kurs.' не добавлена! ';
}
}
}
if(isset($_POST['import_del'])&&count($_POST['import_del'])){//Удаляем группы
foreach($_POST['import_del'] as $key=> $val){
$sql = 'DELETE FROM '.$ST['dbpf'].'_grupp WHERE id='.$key.' LIMIT 1';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']) $form['html'].='Группа ID='.$key.' удалена! ';
else $form['html'].='Группа ID='.$key.' не удалена! ';
}
}
}
if(isset($_POST['grupp_import'])){
$json = file_get_contents('http://local.mkgtu.ru/raspisnew/export.php?grupp_import');
if($json!=''){
$arr = json_decode($json,1); $isset=array();
$form['html']='Результат импорта:';
}else $form['err'][]='Импортирование! Пустой ответ от сервера!';
}
$regim='show';
if (isset($_GET['des'])){
//ФАКУЛЬТЕТЫ
$faculties = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_faculties ';
$rez = $DB->QUR_SEL($sql);
if ($rez) foreach ($rez as $key => $val){
$faculties[] = $val;
}
if ($_GET['des']=='edit'){//редактирование
$regim='aded'; $id=(int)$_GET['id'];
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$id.$aid.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$form['title']=$ST['page']['name'] = 'Редактирование группы';
$form['btn_url']='grupp_edit';
$form['btn_name']='Редактировать';
$form['id']='';
$form['p']=$rez[1];
//$user = get_teacher_user($rez[1]['id_teacher']);
$form['p']['id_teacher']=get_teacher_inf($rez[1]['id_teacher'],1);
}
}
if ($_GET['des']=='add'){//добавление
$regim='aded';
$form['title']=$ST['page']['name'] = 'Добавление группы';
$form['btn_url']='grupp_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$form['p']['fo1']='ОФО';
$form['p']['fo2']='ЗФО';
$form['p']['fo3']='ОЗФО';
$form['p']['id_teacher']=get_teacher_inf(0,1);
$form['p']['sel_grupp']=get_sel_grupp();
}
if ($_GET['des']=='connect'){//Привязка
$regim='connect';
$form['title']=$ST['page']['name'] = 'Привязка к группам';
$form['btn_url']='grupp_connect_save';
$form['btn_name']='Сохранить';
$form['id']='';
$form['p']=array();
$form['p']['sel_grupp']=get_sel_grupp();
}
if ($_GET['des']=='del'){//удаление
$ST['page']['name'] = 'Удаление группы';
$id=(int)$_GET['id'];
if (get_prava_grupp(0)) $aid=''; else $aid=' AND id_teacher='.$_SESSION['user']['teacher']['id'].'';
$sql='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$id.$aid.' LIMIT 1';
$rez=$DB->QUR_SEL($sql); //echo $sql.' '.mysql_error();
if($rez){
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_grupp WHERE id='.$id.$aid.' LIMIT 1');
if(!$rez['err']){
$form['msg']='Группа успешно удалена.';
save_logs('Группа удалена '.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}else $form['err'][]='Нету такой группы!';
}
if ($_GET['des']=='unconnect'){//отвязка
$ST['page']['name'] = 'Отсоединение группы';
$id=(int)$_GET['id'];
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_grupp_teachers WHERE id_grupp='.$id.' AND id_teacher='.$_SESSION['user']['teacher']['id'].'');
if(!$rez['err']){
$form['msg']='Группа успешно отвязана.';
save_logs('Группа отвязана '.$id.'');
}else $form['err'][]='Ошибка при отвязке!';
}
if ($_GET['des']=='pass'){//пароли
$id=(int)$_GET['id'];
$regim='pass';
$form['title']=$ST['page']['name'] = 'Пароли';
$form['btn_url']='grupp_pass';
$form['btn_name']='Отобразить';
$form['id']='';
$form['p']=array();
$sql1='SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez1=$DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['sokr']=out_data_fu($val1['sokr']);
$form['p']['grupp'][]=$val1;
}
}
}
if ($_GET['des']=='import'){//импортировать из расчета часов
$regim='import';
$form['btn_url']='grupp_import';
$form['btn_name']='получить данные';
$ST['page']['name'] = 'Импортирование';
}
}
if ($regim=='show'){//Все записи
$ST['page']['name'] = 'Все записи';
if ($_SESSION['user']['status']==99) {
$sql='SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY kurs,sokr';
//админка
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['teacher']=get_teacher_user($val['id_teacher']);
$rez1=$DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].'');
if($rez1) $val['students']=$rez1[0]; else $val['students']=0;
if (get_prava_grupp($val['id_teacher'])) $val['edde']=1; else $val['edde']=0;
$items[$val['sokr']][]=$val;
$i++;
}
}
$smarty->assign('items0',$items);
$items = grupp_teachers();
$smarty->assign('items',$items);
}else {
//$sql='SELECT g.* FROM '.$ST['dbpf'].'_grupp as g,'.$ST['dbpf'].'_grupp_teachers as gt WHERE gt.id_teacher='.$_SESSION['user']['teacher']['id'].' AND gt.id_grupp=g.id ORDER BY g.kurs,g.sokr';
//$rez=$DB->QUR_SEL($sql);
//if($rez){
// $i=0; foreach($rez as $key => $val)if($key){
// $val['data_c']=date('H:i d.m.Y',$val['data_c']);
// $val['data_u']=date('H:i d.m.Y',$val['data_u']);
// $val['teacher']=get_teacher_user($val['id_teacher']);
// $rez1=$DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].'');
// if($rez1) $val['students']=$rez1[0]; else $val['students']=0;
// if (get_prava_grupp($val['id_teacher'])) $val['edde']=1; else $val['edde']=0;
// $items[$i]=$val;
// $i++;
// }
//}
$items = grupp_teachers();
$smarty->assign('items',$items);
}
}
//СПЕЦИАЛЬНОСТИ
$areas = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE NOT (code = " ") ORDER BY name,code';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$areas[] = $val;
}
}
/***/
$smarty->assign('faculties',$faculties);
$smarty->assign('regim',$regim);
$smarty->assign('form',$form);
$smarty->assign('areas',$areas);
$smarty->assign('user',$_SESSION['user']); //echo '
'.print_r($_SESSION['user'],1).'
';
$maincontent = $smarty->fetch('tpl_teacher_grupp.html');
}
if($_GET['page']=='grupp_transport'){//перевод группы
$id_grupp = (int)$_GET['des']; $debug = '';
if(isset($_POST['grupp_transport_save'])){
$oid_grupp = (int)$_POST['oid_grupp'];
$nid_grupp = (int)$_POST['id_grupp'];
$sts = array();
foreach($_POST['pere_st'] as $key => $val){
$sts[] = $val;
}
if(count($sts)){
$sql = 'UPDATE '.$ST['dbpf'].'_students SET id_grupp='.$nid_grupp.' WHERE id_grupp='.$oid_grupp.' AND (id_user='.implode(' OR id_user=',$sts).')';
$rez = $DB->QUR($sql);
if(!$rez['err']){
$tmsg['msg'] = 'Студентов перенесли!';
save_logs('Перенос студентов новая группа:'.$nid_grupp.' старая группа: '.$oid_grupp.' Список студентов: '.implode(';',$sts));
}else $tmsg['err'][] = 'Ошибка БД!';
$debug .= $sql;
}else{
$tmsg['err'][] = 'Необходимо выбрать студентов!';
}
}
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id="'.$id_grupp.'"';
$rez = $DB->QUR_SEL($sql);
$rez[1]['data_c'] = date('H:i d.m.Y',$rez[1]['data_c']);
$rez[1]['data_u'] = date('H:i d.m.Y',$rez[1]['data_u']);
$grupp = $rez[1];
//выберем студентов из группы
//$sql = 'SELECT s.id as sid,s.data_c as sdata_c, s.data_u as sdata_u, s.status as sstatus, s.num_zach as snum_zach, s.num_stud as snum_stud, s.num_grupp as snum_grupp,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.fio as ufio FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE s.id_grupp='.$id_grupp.' AND u.id=s.id_user ORDER BY s.data_c DESC';
//$sql = 'SELECT s.id as sid,s.data_c as sdata_c, s.data_u as sdata_u, s.status as sstatus, s.num_zach as snum_zach, s.num_stud as snum_stud, s.num_grupp as snum_grupp,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.fio as ufio FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE NOT(u.status = -1) AND s.id_grupp='.$id_grupp.' AND u.id=s.id_user ORDER BY u.fio, s.data_c DESC';
$sql = 'SELECT s.id as sid,s.data_c as sdata_c, s.data_u as sdata_u, s.status as sstatus, s.num_zach as snum_zach, s.num_grupp as snum_grupp,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.fio as ufio FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE NOT(u.status = -1) AND s.id_grupp='.$id_grupp.' AND u.id=s.id_user ORDER BY u.fio, s.data_c DESC';
$rez = $DB->QUR_SEL($sql);
$students=array();
if($rez){
foreach($rez as $key => $val)if($key){
if($val['sdata_c']<=mktime(0,0,0,8,1,date('Y'))) $val['perevod']=1; else $val['perevod']=0;
$val['sdata_c'] = date('H:i d.m.Y',$val['sdata_c']);
$val['sdata_u'] = date('H:i d.m.Y',$val['sdata_u']);
$val['udata_c'] = date('H:i d.m.Y',$val['udata_c']);
$val['udata_u'] = date('H:i d.m.Y',$val['udata_u']);
$students[]=$val;
}
}
$debug .= '
'.print_r($_POST,1).'
';
//$smarty->assign('debug',$debug);
$smarty->assign('tmsg',$tmsg);
$grupps=get_sel_grupp_tr($id_grupp);
$smarty->assign('id_grupp',$id_grupp);
$smarty->assign('grupps',$grupps);
$smarty->assign('grupp',$grupp);
$smarty->assign('students',$students);
$maincontent = $smarty->fetch('tpl_teacher_grupp_transport.html');
}
//ЛИКВИДАЦИЯ ЗАДОЛЖЕННОСТЕЙ, ИУП
if ($_GET['page'] == 'liquidation_prepod'){
$fakultet = $_SESSION['user']['teacher']['fakultet'];
//направления факультета
$napr = array();
$sql = 'SELECT liq.*, liq.id as id_liq, us.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_users as us WHERE liq.id_teacher = "'.$_SESSION['user']['id'].'" AND liq.id_stat = 0 AND liq.id_teacher = us.id AND liq.mark IS NULL ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
$i++;
$val['i'] = $i;
switch ($val['control']){
case 1: $val['control'] = 'Экзамен'; break;
case 2: $val['control'] = 'Зачет'; break;
case 3: $val['control'] = 'Курсовая работа'; break;
case 4: $val['control'] = 'Курсовая проект'; break;
case 5: $val['control'] = 'Отчет по практике'; break;
case 6: $val['control'] = 'Зачет с оценкой'; break;
}
switch ($val['type']){
case 1: $val['type'] = 'Досрочная'; break;
case 2: $val['type'] = 'Первичная'; break;
case 3: $val['type'] = 'Повторная'; break;
case 4: $val['type'] = 'С комиссией'; break;
}
switch ($val['iup']){
case 0: $val['iup'] = 'УП'; break;
case 1: $val['iup'] = 'ИУП'; break;
}
$val['date_create'] = date('d.m.Y', $val['date_create']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['date_mark'] = date('d.m.Y', $val['date_mark']);
$id_student = $val['id_student'];
$student = get_student($val['id_student']);
$sql_user = 'SELECT st.*, us.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_users as us WHERE st.id = "'.$id_student.'" AND us.id = st.id_user';
$rez_user = $DB->QUR_SEL($sql_user);
$val['id_student'] = $rez_user[1]['fio'];
$student = get_student($rez_user[1]['id']);
$val['gruppa'] = $student['sokr'].'-'.$student['kurs'].$student['num_grupp'].' '.$student['fo']; //
$val['id_user'] = $rez_user[1]['id'];
$napr[] = $val;
}
}
//ведомости для преподавателя
$statements = array();
$sql = 'SELECT liq.*, liq.id as id_liq, us.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_users as us WHERE liq.id_teacher = "'.$_SESSION['user']['id'].'" AND NOT (liq.id_stat = 0) AND liq.id_teacher = us.id AND liq.mark IS NULL GROUP BY liq.id_stat';
$rez = $DB->QUR_SEL($sql);
//echo '
'.print_r($rez,1).'
';
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
$i++;
$val['i'] = $i;
$id = $val['id_stat'];
$val['students'] = array();
$sql_liq = 'SELECT liq.*, liq.id as id_liq, st.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_students as st WHERE liq.id_teacher='.$_SESSION['user']['id'].' AND liq.id_stat = "'.$id.'" AND liq.id_student = st.id';
$rez_liq = $DB->QUR_SEL($sql_liq);
if ($rez_liq){
$j = 0;
foreach ($rez_liq as $kk => $val_liq) if ($kk){
$j++;
$student = get_user($val_liq['id_user']);
$student['j'] = $j;
$student['id_liq'] = $val_liq['id_liq'];
$student['mark'] = $val_liq['mark'];
$val['students'][] = $student;
}
$info_group = get_student($val_liq['id_user']);
$val['gruppa'] = $info_group['sokr'].'-'.$info_group['kurs'].$info_group['num_grupp'];
}
switch ($val['control']){
case 1: $val['control'] = 'Экзамен'; break;
case 2: $val['control'] = 'Зачет'; break;
case 3: $val['control'] = 'Курсовая работа'; break;
case 4: $val['control'] = 'Курсовая проект'; break;
case 5: $val['control'] = 'Отчет по практике'; break;
case 6: $val['control'] = 'Зачет с оценкой'; break;
}
switch ($val['type']){
case 1: $val['type'] = 'Досрочная'; break;
case 2: $val['type'] = 'Первичная'; break;
case 3: $val['type'] = 'Повторная'; break;
case 4: $val['type'] = 'С комиссией'; break;
}
switch ($val['iup']){
case 0: $val['iup'] = 'УП'; break;
case 1: $val['iup'] = 'ИУП'; break;
}
$val['date_create'] = date('d.m.Y', $val['date_create']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['date_mark'] = date('d.m.Y', $val['date_mark']);
$id_student = $val['id_student'];
$info_group = get_student($val_liq['id_user']);
$val['gruppa'] = $info_group['sokr'].'-'.$info_group['kurs'].$info_group['num_grupp'];
$val['fo'] = $info_group['fo'];
$sql_user = 'SELECT st.*, us.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_users as us WHERE st.id = "'.$id_student.'" AND us.id = st.id_user';
$rez_user = $DB->QUR_SEL($sql_user);
$val['id_student'] = $rez_user[1]['fio'];
$val['id_user'] = $rez_user[1]['id'];
$statements[] = $val;
}
}
/************************/
$smarty->assign('naprs', $napr);
$smarty->assign('statements', $statements);
$maincontent = $smarty->fetch('tpl_teacher_liquidation_prepod.html');
}
if ($_GET['page'] == 'liquidation'){
$mgs = 0;
$fakultet = $_SESSION['user']['teacher']['fakultet'];
//сформировать направление
if (isset($_POST['add_liq'])){
$student = $_POST['student'];
$teacher = $_POST['teacher'];
$fakultet = $_POST['fakultet'];
$type = $_POST['type'];
$iup = $_POST['iup'];
$name = $_POST['name'];
$control = $_POST['control'];
$date_create = strtotime($_POST['date_create']);
$date_end = strtotime($_POST['date_end']);
$semestr = $_POST['semestr'];
//$date_create = date("U");
//проверяем есть ли такое направление в системе уже
$rez_is = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id_student = "'.$student.'" AND id_teacher = "'.$teacher.'" AND type = "'.$type.'" AND iup = "'.$iup.'" AND name = "'.$name.'" AND control = "'.$control.'" AND semestr = "'.$semestr.'" AND date_end = "'.$date_end.'" LIMIT 1');
if ($rez_is[0] > 0) $msg = -1; //ошибка при создании направление
else{
$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_liquidation (`id_student`, `id_teacher`, `fakultet`, `type`, `iup`, `name`, `control`, `date_create`, `date_end`, `semestr`) VALUES ("'.$student.'", "'.$teacher.'", "'.$fakultet.'", "'.$type.'", "'.$iup.'", "'.$name.'", "'.$control.'", "'.$date_create.'", "'.$date_end.'", "'.$semestr.'") ');
$date_end = date('d.m.Y', $date_end);
write_message($teacher, '[ОПОВЕЩЕНИЕ] У Вас появилось новое направление по дисциплине '.$name.'. Срок действия направления до '.$date_end);
save_logs('Создано новое направление для студента '.$student.' и преподавателя '.$teacher.' по дисциплине '.$name);
$msg = 1;
}
}
//сформировать ведомость
if (isset($_POST['add_ved'])){
$students = $_POST['students'];
if(empty($students)){
//echo("Вы не выбрали.");
} else{
$N = count($students);
$teacher = $_POST['teacher'];
$fakultet = $_POST['fakultet'];
$type = $_POST['type'];
$iup = $_POST['iup'];
$name = $_POST['name'];
$control = $_POST['control'];
$date_end = strtotime($_POST['date_end']);
$semestr = $_POST['semestr'];
$date_create = date("U");
$rez = $DB->QUR_SEL('INSERT INTO '.$ST['dbpf'].'_statement (`date_create`, `fakultet`) VALUES ("'.$date_create.'", "'.$fakultet.'") ');
$id = mysql_insert_id();
write_message($teacher, '[ОПОВЕЩЕНИЕ] У Вас появилась новая ведомость по дисциплине '.$name);
save_logs('Создана зачетно-экзаменнационная ведомость №'.$id);
$msg = 2;
for($i=0; $i < $N; $i++){
//echo($aDoor[$i] . " ");
$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_liquidation (`id_student`, `id_teacher`, `fakultet`, `type`, `iup`, `name`, `control`, `date_create`, `date_end`, `semestr`, `id_stat`) VALUES ("'.$students[$i].'", "'.$teacher.'", "'.$fakultet.'", "'.$type.'", "'.$iup.'", "'.$name.'", "'.$control.'", "'.$date_create.'", "'.$date_end.'", "'.$semestr.'", "'.$id.'") ');
}
}
}
//ГРУППЫ
$grupp = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez=$DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val){
$grupp[] = $val;
}
}
//активные преподаватели
$teachers = array();
$sql = 'SELECT teach.*, us.* FROM '.$ST['dbpf'].'_teachers as teach, '.$ST['dbpf'].'_users as us WHERE NOT (teach.status = "-1") AND NOT (us.status = "-1") AND us.id = teach.id_user ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$teachers[] = $val;
}
}
//направления факультета
$napr = array();
$sql = 'SELECT liq.*, liq.id as id_liq, us.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_users as us WHERE liq.fakultet = "'.$fakultet.'" AND liq.id_teacher = us.id AND liq.id_stat = 0 ORDER BY id_liq DESC ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
$i++;
$val['i'] = $i;
$val['date_create'] = date('d.m.Y', $val['date_create']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['date_mark'] = date('d.m.Y', $val['date_mark']);
switch ($val['control']){
case 1: $val['control'] = 'экзамен'; break;
case 2: $val['control'] = 'зачет'; break;
case 3: $val['control'] = 'курсовая работа'; break;
case 4: $val['control'] = 'курсовой проект'; break;
case 5: $val['control'] = 'отчет по практике'; break;
case 6: $val['control'] = 'зачет с оценкой'; break;
}
$id_student = $val['id_student'];
$sql_user = 'SELECT st.*, us.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_users as us WHERE st.id = "'.$id_student.'" AND us.id = st.id_user';
$rez_user = $DB->QUR_SEL($sql_user);
$val['id_student'] = $rez_user[1]['fio'];
$napr[] = $val;
}
}
//ведомости факультета на этот семестра
$statements = array();
//если эти два значения совпадают, то отображаем, что ведомость заполнена полностью, если второе значение отлично от нуля -неполностью заполнена, если второе значение = 0, ничего не выводим
$sql = 'SELECT st.*, st.print_st as print_st, liq.* FROM '.$ST['dbpf'].'_statement as st, '.$ST['dbpf'].'_liquidation as liq WHERE st.fakultet = "'.$fakultet.'" AND liq.id_stat = st.id GROUP BY liq.id_stat';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$val['date_create'] = date('d.m.Y', $val['date_create']);
//$val['print_st'] = $val['print_st'];
$id = $val['id_stat'];
$val['students'] = array();
switch ($val['control']){
case 1: $val['control'] = 'экзамен'; break;
case 2: $val['control'] = 'зачет'; break;
case 3: $val['control'] = 'курсовая работа'; break;
case 4: $val['control'] = 'курсовой проект'; break;
case 5: $val['control'] = 'отчет по практике'; break;
case 6: $val['control'] = 'зачет с оценкой'; break;
}
$val['teacher'] = get_user($val['id_teacher']);
$val['all'] = 0; //общее количество студентов, подлежающих оцениванию на экзамене/зачете
$val['marked'] = 0; //количество оценененных студентов
$sql_liq = 'SELECT liq.*, st.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_students as st WHERE liq.id_stat = "'.$id.'" AND liq.id_student = st.id';
$rez_liq = $DB->QUR_SEL($sql_liq);
if ($rez_liq){
$sem = 0;
foreach ($rez_liq as $kk => $val_liq) if ($kk){
$val['all'] += 1; //увеличиваем общее количество студентов, присутствующих на экзамене/зачете
if ($val_liq['mark'] != NULL) $val['marked'] += 1; //увеличиваем количество оцененных студентов на данном экзамене/зачете
$student = get_user($val_liq['id_user']);
$val['students'][]['fio'] = $student['fio'];
$sem = $val_liq['semestr'];
}
$info_group = get_student($val_liq['id_user']);
//$val['gruppa'] = $info_group['sokr'].'-'.$info_group['kurs'].$info_group['num_grupp'];
$val['gruppa'] = $info_group['sokr'].'-'.round($sem/2).$info_group['num_grupp'];
$val['fo'] = $info_group['fo'];
}
$statements[] = $val;
}
}
if (isset($_GET['des'])){
$id = $_GET['des'];
$sql = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE `id` = "'.$id.'" ';
$rez = $DB->QUR_SEL($sql);
switch ($rez[1]['control']){
case 1: $control = 'экзамена'; break;
case 2: $control = 'зачета'; break;
case 3: $control = 'курсовой работы'; break;
case 4: $control = 'курсового проекта'; break;
case 5: $control = 'отчета по практике'; break;
case 6: $control = 'зачета с оценкой'; break;
}
switch ($rez[1]['type']){
case 1: $type = 'досрочную'; break;
case 2: $type = 'первичную'; break;
case 3: $type = 'повторную'; break;
case 4: $type = 'с комиссией'; break;
}
switch ($rez[1]['iup']){
case 0: $iup = 'УП'; break;
case 1: $iup = 'ИУП'; break;
}
/*$val['date_create'] = date('d.m.Y', $val['date_create']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['date_mark'] = date('d.m.Y', $val['date_mark']);*/
//инфа о студенте
$id_student = $rez[1]['id_student'];
$sql_stud = 'SELECT us.*, stud.* FROM '.$ST['dbpf'].'_students as stud, '.$ST['dbpf'].'_users as us WHERE stud.id = "'.$id_student.'" AND us.id = stud.id_user ';
$rez_stud = $DB->QUR_SEL($sql_stud);
$teacher = get_user($rez[1]['id_teacher']);
$grupp = get_grupp($rez_stud[1]['id_grupp']);
if ($grupp['fo'] == 'оч') $grupp['fo'] = 'очная'; else $grupp['fo'] = 'заочная';
$smarty->assign('day_create', date('d', $rez[1]['date_create']));
$smarty->assign('month_create', numberToMonth(date('m', $rez[1]['date_create'])));
$smarty->assign('year_create', date('Y', $rez[1]['date_create']));
$smarty->assign('student_fio', $rez_stud[1]['fio']);
$smarty->assign('student_gr', $rez_stud[1]['num_grupp']);
//$smarty->assign('student_grupp', $rez_stud[1]['fio']);
$smarty->assign('day_end', date('d', $rez[1]['date_end']));
$smarty->assign('month_end', numberToMonth(date('m', $rez[1]['date_end'])));
$smarty->assign('year_end', date('Y', $rez[1]['date_end']));
$smarty->assign('day_mark', date('d', $rez[1]['date_mark']));
$smarty->assign('month_mark', numberToMonth(date('m', $rez[1]['date_mark'])));
$smarty->assign('year_mark', date('Y', $rez[1]['date_mark']));
$smarty->assign('teacher', $teacher['fio']);
$smarty->assign('mark', $rez[1]['mark']);
$smarty->assign('name', $rez[1]['name']);
$smarty->assign('sem', $rez[1]['semestr']);
$smarty->assign('print', $rez[1]['print']);
$smarty->assign('type', $type);
$smarty->assign('iup', $iup);
$smarty->assign('grupp', $grupp);
$smarty->assign('fakultet', $fakultet);
$smarty->assign('stat', $rez[1]['id_stat']);
if ($rez[1]['id_stat'] == 0) { //направление
//Распечатали
$sql = 'UPDATE '.$ST['dbpf'].'_liquidation SET print = "1" WHERE id = "'.$id.'" ';
$rez = $DB->QUR($sql);
//на вывод
$smarty->assign('control', $control);
$smarty->display('tpl_teacher_liquidation_print_nap.html');
}
else { //ведомость
switch ($rez[1]['control']){
case 1: $control = 'экзамен'; break;
case 2: $control = 'зачет'; break;
case 3: $control = 'курсовая работа'; break;
case 4: $control = 'курсовой проект'; break;
case 5: $control = 'отчет по практике'; break;
case 6: $control = 'зачет с оценкой'; break;
}
$sql_list = 'SELECT liq.*, st.* FROM '.$ST['dbpf'].'_liquidation as liq, '.$ST['dbpf'].'_students as st WHERE liq.id_stat = "'.$rez[1]['id_stat'].'" AND st.id = liq.id_student ';
$rez_list = $DB->QUR_SEL($sql_list);
$list_student = array();
$count_otl = 0;
$count_hor = 0;
$count_udov = 0;
$count_neud = 0;
$count_neyvka = 0;
$id_stat = 0;
if ($rez_list){
$i = 0;
foreach ($rez_list as $key => $val) if ($key){
$i++;
$id_stat = $val['id_stat'];
$val['i'] = $i;
$student = get_user($val['id_user']);
$val['fio'] = $student['fio'];
if (($val['mark'] == 'отлично')||($val['mark'] == 'зачтено')) $count_otl++;
if (($val['mark'] == 'хорошо')) $count_hor++;
if (($val['mark'] == 'удовлетворительно')) $count_udov++;
if (($val['mark'] == 'неудовлетворительно')||($val['mark'] == 'не зачтено')) $count_neud++;
if (($val['mark'] == 'не явился')) $count_neyvka++;
$list_student[] = $val;
}
}
//Распечатали
$sql = 'UPDATE '.$ST['dbpf'].'_statement SET print_st = "1" WHERE id = "'.$id_stat.'" ';
$rez = $DB->QUR($sql);
/***********/
$smarty->assign('count', $i);
$smarty->assign('count_otl', $count_otl);
$smarty->assign('count_hor', $count_hor);
$smarty->assign('count_udov', $count_udov);
$smarty->assign('count_neud', $count_neud);
$smarty->assign('count_neyvka', $count_neyvka);
$smarty->assign('list_student', $list_student);
$smarty->assign('control', $control);
$smarty->display('tpl_teacher_liquidation_print_ved.html');
}
exit;
} else{
$smarty->assign('fakultet', $fakultet);
$smarty->assign('naprs', $napr);
$smarty->assign('statements', $statements);
$smarty->assign('teachers', $teachers);
$smarty->assign('grupps', $grupp);
$smarty->assign('msg', $msg);
$smarty->assign('status', $_SESSION['user']['status']);
$maincontent = $smarty->fetch('tpl_teacher_liquidation.html');
}
}
//СВОДНАЯ ВЕДОМОСТЬ ПО ГРУППАМ И СЕМЕСТРАМ
if ($_GET['page'] == 'consolidated'){
$fakultet = $_SESSION['user']['teacher']['fakultet'];
//формируем список групп
$grupps = array();
$sql = 'SELECT gr.* FROM '.$ST['dbpf'].'_grupp as gr WHERE gr.kurs < 7 AND NOT (gr.name LIKE "%выпуск%") ORDER BY gr.sokr, gr.kurs ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$grupps[] = $val;
}
}
//если указана конкретная группа, номер группы в потоке, а также семестр, по которому нужно формировать сводную ведомость
if ((isset($_GET['grupp']))&&(isset($_GET['num']))&&(isset($_GET['sem']))){
$id_grupp = $_GET['grupp']; //группа
$num = $_GET['num']; //номер группы в потоке
$sem = $_GET['sem']; //семестр
//достаем список студентов группы
$students = array();
$sql = 'SELECT gr.*, st.*, us.*, st.id as id_stud FROM '.$ST['dbpf'].'_grupp as gr, '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_users as us WHERE us.id = st.id_user AND st.id_grupp = gr.id AND gr.id = "'.$id_grupp.'" AND st.num_grupp = "'.$num.'" AND NOT(us.status = "-1") ORDER BY us.fio';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
/*$sql_mark = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id_student="'.$val['id_stud'].'" AND semestr = "'.$sem.'" ';
$rez_mark = $DB->QUR_SEL($sql_mark);
foreach ($rez_mark as $key_mark => $val_mark){
$val['mark'] = $val_mark;
}*/
$id_student = $val['id_stud'];
$gruppa = $val['sokr'];
$fo = $val['fo'];
$students[] = $val;
}
}
//достаем уникальный список направлений/ведомостей для данной группы для указанного семестра
$disc = array();
//$date_create;
$sql = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id_student = "'.$id_student.'" AND semestr = "'.$sem.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$fakultet = $val['fakultet'];
$date_create = $val['date_create'];
//первая цифра
$val['marked'][0] = 5;
$val['marked'];
$sql_mark = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE date_create = "'.$date_create.'" AND semestr = "'.$sem.'" ';
$rez_mark = $DB->QUR_SEL($sql_mark);
if ($rez_mark){
foreach ($rez_mark as $key_mark => $val_mark){
$val['marked'][$val_mark['id_student']] = $val_mark['mark'];
}
}
//$sql_mark = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id = "''" ';
$disc[] = $val;
}
}
//отметки
/*********************************/
$smarty->assign('fakultet', $fakultet);
$smarty->assign('disc', $disc);
$smarty->assign('gruppa', $gruppa);
$smarty->assign('fo', $fo);
$smarty->assign('num', $num);
$smarty->assign('sem', $sem);
$smarty->assign('students', $students);
$smarty->display('tpl_teach_consolidated_print.html');
exit;
} else{ //просто выводим список всех групп, где будем выбирать, какую конкретно группу необходимо вывести
$smarty->assign('grupps', $grupps);
$maincontent = $smarty->fetch('tpl_teacher_consolidated.html');
}
}
//РАСПИСАНИЕ ЗАНЯТИЙ В РЕЖИМЕ ВЕБИНАРА
//$API;
if ($_GET['page'] == 'timetable_web'){
//выводим само расписание
$timetable = '';
//формируем список каналов
$channel = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_timetable_zoom ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$API['key'] = $val['key_zoom'];
$API['secret'] = $val['secret'];
$API['url'] = $val['url'];
$API['JWTToken'] = $val['token'];
$users = zoom_getUsers();
$meetings = zoom_meetingList($users[0]);
$date = date('H:i d.m.Y');
foreach($meetings['meetings'] as $key2 => $val2){
$start_time = strtotime($val2['start_time']);
//$val['p1'] = date('H:i d.m.Y',$start_time);
if (date('H:i d.m.Y',$start_time) == '08:00 '.date('d.m.Y')) $val['p1'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '09:40 '.date('d.m.Y')) $val['p2'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '11:30 '.date('d.m.Y')) $val['p3'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '13:10 '.date('d.m.Y')) $val['p4'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '15:00 '.date('d.m.Y')) $val['p5'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '16:40 '.date('d.m.Y')) $val['p6'] = $val2['topic'];
if (date('H:i d.m.Y',$start_time) == '18:20 '.date('d.m.Y')) $val['p7'] = $val2['topic'];
/*$meet = getMeeting($val['uuid']);
echo '
';*/
}
/*$val['p1'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p2'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p3'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p4'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p5'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p6'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";
$val['p7'] = "[ПИ-11] Алгебра и геометрия (Иванов И.И.)";*/
$channel[] = $val;
}
}
$smarty->assign('channel', $channel);
$smarty->assign('timetable', $timetable);
$maincontent = $smarty->fetch('tpl_teach_timetable_web.html');
}
if ($_GET['page'] == 'zamdekan'){
$maincontent = $smarty->fetch('tpl_teacher_zamdekan.html');
}
//Элективные дисциплины по физической культуре и спорту
if ($_GET['page'] == 'fk'){
$message = ''; //контейнер для сообщений
//echo '
'.print_r($_GET,1).'
'; exit();
//Array( [teach] => [page] => fk [des] => prepods [id] => 35)
if(isset($_GET['delstudent'])){//удаляем студента из записи на ЭД
$id = (int)$_GET['id'];
$sql = 'DELETE FROM '.$ST['dbpf'].'_fk_order WHERE id='.$id.' LIMIT 1';
$rez = $DB->QUR($sql);
header('location: https://eios.mkgtu.ru/teach/fk/prepods/');exit();
}
//добавляем в расписание
if (isset($_POST['save_fk'])){
$code = $_POST['code']; //в виде (день-номерпары-преподаватель)
$facult = $_POST['facult']; //массив факультетов
$section = $_POST['section']; //элективная дисциплина по физической культуре и спорту
$course = $_POST['course']; //курс студентов
$count = $_POST['count']; //возможное количество студентов для записи
$disability = $_POST['disability']; //для студентов, имеющих инвалидность
if ($disability == 'on') $disability = 1;
else $disability = 0;
$facults = ''; //массив факультетов в строке, чтобы удобно было в будущем заносить в БД или перебирать (2,6,9 - например)
$i = 0;
while ($i <= (count($facult)-1)){
if ($i != 0) $facults .= ',';
$facults .= $facult[$i];
$i++;
}
//разбиваем день, номер пары и преподавателя
$past = explode('-', $code);
$day = $past[0];
switch ($day){
case 'Пн':
$day = 1;
break;
case 'Вт':
$day = 2;
break;
case 'Ср':
$day = 3;
break;
case 'Чт':
$day = 4;
break;
case 'Пт':
$day = 5;
break;
case 'Сб':
$day = 6;
break;
}
$couple = $past[1];
$teacher = $past[2];
//добавляем расписание
$sql = 'INSERT INTO '.$ST['dbpf'].'_fk_timetable (`id_section`, `id_teacher`, `course`, `count`, `disability`, `fakultets`) VALUES ("'.$section.'", "'.$teacher.'", "'.$course.'", "'.$count.'", "'.$disability.'", "'.$facults.'")';
//$message .= $sql;
$rez = $DB->QUR($sql);
//теперь добавляем день и номер пары, к которому относится данная дисциплина
$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable ORDER BY `id` DESC LIMIT 1';
$rez = $DB->QUR_SEL($sql);
$timetable = $rez[1]['id'];
$sql = 'INSERT INTO '.$ST['dbpf'].'_fk_details (`id_timetable`, `day`, `couple`) VALUES ("'.$timetable.'", "'.$day.'", "'.$couple.'")';
$rez = $DB->QUR($sql);
$message .= 'Расписание успешно отредактировано';
save_logs('Преподаватель '.$_SESSION['user']['id'].' : '.$_SESSION['user']['fio'].' сделал изменения в расписании элективных дисциплин по физической культуре (День: '.$day.', Номер пары: '.$couple.', Преподаватель: '.$teacher.') ');
}
//Редактируем расписание
if (isset($_POST['edit_fk'])){
//echo '
';exit();
//секции, которые доступны определенному преподавателю
$id_teacher = $_SESSION['user']['teacher']['id'];
$sections_teacher = array();
$sql_timetable = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable WHERE `id_teacher` = "'.$id_teacher.'" GROUP BY id_section, course, fakultets';
//Если статус заведующего кафедрой, то доступ ко всем записанным есть
if (($_GET["des"] == 'zavkaf')&&($_SESSION['user']['status'] == 30)) $sql_timetable = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable GROUP BY id_section, course, id_teacher';
//-----------------------------
//print_r($faculties);
$rez_timetable = $DB->QUR_SEL($sql_timetable);
foreach ($rez_timetable as $key => $val) if ($key){
/*преподаватель - имя пользователя*/
$teach = $rez_timetable['id_teacher'];
$sql_teach = 'SELECT us.*, teach.* FROM '.$ST['dbpf'].'_users as us, '.$ST['dbpf'].'_teachers as teach WHERE teach.id = "'.$val["id_teacher"].'" AND us.id = teach.id_user';
$rez_teach = $DB->QUR_SEL($sql_teach);
$val['teacher'] = $rez_teach[1]['fio'];
//*****************
$sql_sect = 'SELECT * FROM '.$ST['dbpf'].'_fk_section WHERE `id` = "'.$val["id_section"].'"';
$rez_sect = $DB->QUR_SEL($sql_sect);
$val['name'] = $fk_section['name'] = $rez_sect[1]['name'];
$val['content'] = '
';//
Промеж.атт (Оценка, пропуски)
$val['content'] .= '
№
Студент
Группа
Текущ.атт (Оценка, пропуски)
Действие
';
$val['content'] .= '';
$sql_student = 'SELECT * FROM '.$ST['dbpf'].'_fk_order WHERE id_timetable = "'.$val['id'].'"';
$rez_student = $DB->QUR_SEL($sql_student);
foreach ($rez_student as $key_s => $val_s) if ($key_s){
$sql_user = 'SELECT * FROM '.$ST['dbpf'].'_users as users, '.$ST['dbpf'].'_students as students WHERE users.id = "'.$val_s['id_student'].'" AND students.id_user = users.id';
$rez_user = $DB->QUR_SEL($sql_user);
//
$sql_grupp = 'SELECT sokr FROM '.$ST['dbpf'].'_grupp WHERE id = '.$rez_user[1]['id_grupp'];
$rez_grupp = $DB->QUR_SEL($sql_grupp);
//$val['content'] .= '
';
//теперь смотрим какие факультеты могут записываться к этому преподавателю на секцию
$facultet_section = explode(",", $val['fakultets']);
$val['fac_name'] = array();
foreach ($facultet_section as $key_f => $val_f){
$sql_ff = 'SELECT * FROM '.$ST['dbpf'].'_faculties WHERE id = "'.$val_f.'"';
$rez_ff = $DB->QUR_SEL($sql_ff);
$val['fac_name'][] = $rez_ff[1]['name'];
}
//print_r($val['fac_name']);
$sections_teacher[] = $val;
}
//список незаписавшихся преподавателей
$no_order_list_students = array();
$sql_no_order = 'SELECT st.*, us.* FROM '.$ST['dbpf'].'_students as st, '.$ST['dbpf'].'_users as us WHERE (st.id_grupp = 171 OR st.id_grupp = 236 OR st.id_grupp = 301) AND st.id_user = us.id';
$rez_no_order = $DB->QUR_SEL($sql_no_order);
foreach ($rez_no_order as $key => $val) if ($key){
$id_user = $val['id_user'];
$sql_is_order = 'SELECT * FROM '.$ST['dbpf'].'_fk_order WHERE `id_student` = "'.$id_user.'"';
$rez_is_order = $DB->QUR_SEL($sql_is_order);
//если нет записи, значит студент еще не записывался
if ($rez_is_order[0] == 0){
$no_order_list_students[] = $val;
}
}
/************************/
$smarty->assign('page', $_GET["des"]);
$smarty->assign('message', $message);
$smarty->assign('teacher', $teachers);
$smarty->assign('faculties', $faculties);
$smarty->assign('sections', $sections);
$smarty->assign('sections_teacher', $sections_teacher);
$smarty->assign('days', $days);
$smarty->assign('zanyato', $zanyato);
$smarty->assign('zanyato_new', $zanyato_new);
$smarty->assign('mesta', $mesta);
$smarty->assign('students_no_order', $no_order_list_students);
$smarty->assign('ident', $ident);
$smarty->assign('kaf', $_SESSION['user']['teacher']['kafedra']);
$maincontent = $smarty->fetch('tpl_teacher_fk.html');
}
if($_GET['page']=='students'){//студенты
$items=array(); $regim='show';
if(isset($_POST['grupp_change_submit'])){
//echo '
'.print_r($_POST,1).'
';
foreach($_POST['grupp_change'] as $id => $val){
$sql = 'UPDATE '.$ST['dbpf'].'_students SET id_grupp='.$val['grupp'].', num_grupp="'.$val['pgrupp'].'", status=1 WHERE id='.$id.'';
$rez = $DB->QUR($sql);
}
}
$ST['page']['name'] = 'Список студентов';
if (isset($_GET['des'])){
if ($_GET['des']=='del'){//удаление
$id=(int)$_GET['id'];
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_students WHERE id='.$id.'');
if(!$rez['err']){
$form['msg']='Анкета успешно удалена.';
save_logs('Анкета студента удалена '.$id.'');
//надо подчистить оценки
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_ocenki WHERE id_student='.$id.'');
}else $form['err'][]='Ошибка при удалении!';
}
if ($_GET['des']=='dec'){//отказ
$id=(int)$_GET['id']; $ST['page']['name'] = 'Отказ студенту';
$rez=$DB->QUR('UPDATE '.$ST['dbpf'].'_students SET id_grupp=0 WHERE id='.$id.'');
if(!$rez['err']){
$form['msg']='Статус анкеты ОТКАЗ.';
save_logs('Анкета студента отказ '.$id.'');
//надо подчистить оценки
$rez=$DB->QUR('DELETE FROM '.$ST['dbpf'].'_ocenki WHERE id_student='.$id.'');
}else $form['err'][]='Ошибка при установки статуса анкеты';
}
if ($_GET['des']=='ace'){//соглас
$id=(int)$_GET['id']; $ST['page']['name'] = 'Подтверждение студенту';
$rez=$DB->QUR('UPDATE '.$ST['dbpf'].'_students SET status=1 WHERE id='.$id.'');
if(!$rez['err']){
$form['msg']='Статус анкеты ПРИНЯЛИ.';
save_logs('Анкета студента принята '.$id.'');
}else $form['err'][]='Ошибка при установки статуса анкеты';
}
}
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=-2 ORDER BY data_u';
if($_SESSION['user']['status']==99) //В ОЖИДАНИИ
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=0 ORDER BY data_u DESC LIMIT 10';//очень много выходит!
else {
$s='SELECT * FROM '.$ST['dbpf'].'_grupp_teachers WHERE id_teacher='.$_SESSION['user']['teacher']['id'].'';
$r=$DB->QUR_SEL($s);if ($r){
$idgrupps =array();
foreach($r as $k => $v)if($k){
$idgrupps[] = $v['id_grupp'];
}
if(count($idgrupps)){
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=0 AND (id_grupp='.implode(' OR id_grupp=',$idgrupps).') ORDER BY data_u';
}
}
}
$rez = $DB->QUR_SEL($sql);//МОДЕРИРОВАНИЕ АНКЕТ
if($rez){
foreach($rez as $key => $val)if($key){
$val['data_с']=date('H:i d.m.Y',$val['data_с']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['user']=get_user($val['id_user']);
$val['grupp']=get_grupp($val['id_grupp']);
$items[]=$val;
}
}
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 ORDER BY data_u';//ОДОБРЕННЫЕ
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=-2 ORDER BY data_u';
if(isset($_POST['search_go'])){//результат поиска
$search_fio = addslashes($_POST['search_fio']);
$sql = 'SELECT s.* FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE u.id=s.id_user AND u.fio LIKE "%'.$search_fio.'%"';
}else{//отображение своих студентов
if($_SESSION['user']['status']==99) //В ОЖИДАНИИ
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 ORDER BY id_grupp,num_grupp,data_u DESC LIMIT 10';
else {
/*$s='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id_teacher='.$_SESSION['user']['teacher']['id'].' LIMIT 1';
$r=$DB->QUR_SEL($s);if ($r){
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 AND id_grupp='.$r[1]['id'].' ORDER BY data_u';
}*/
$s='SELECT * FROM '.$ST['dbpf'].'_grupp_teachers WHERE id_teacher='.$_SESSION['user']['teacher']['id'].'';
$r=$DB->QUR_SEL($s);if ($r){
$idgrupps =array();
foreach($r as $k => $v)if($k){
$idgrupps[] = $v['id_grupp'];
}
if(count($idgrupps)){
$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 AND (id_grupp='.implode(' OR id_grupp=',$idgrupps).') ORDER BY id_grupp,num_grupp,data_u LIMIT 25';
//если выбрана группа
if (isset($_GET['gr'])) {
$id_gr = $_GET['gr'];
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 AND id_grupp='.$id_gr).' ORDER BY id_grupp,num_grupp,data_u ';
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE status=1 AND id_grupp='.$id_gr.' LIMIT 10';
}
}
}
}
}
$rez = $DB->QUR_SEL($sql);//ОДОБРЕННЫЕ СТУДЕНТЫ
//echo $sql.'
'.print_r($rez,1).'
';exit();
if($rez){
foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['user']=get_user($val['id_user']);
$val['grupp']=get_grupp($val['id_grupp']);
$items1[]=$val;
}
}
/*!-- BEGIN ПРИВЯЗАННЫЕ ГРУППЫ К ПРЕПОДАВАТЕЛЮ --*/
$id_prepod=$_SESSION['user']['teacher']['id'];
$sql = 'SELECT g.* FROM '.$ST['dbpf'].'_grupp as g, '.$ST['dbpf'].'_grupp_teachers as gt WHERE gt.id_teacher='.$id_prepod.' AND gt.id_grupp=g.id';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val) if($key){
$grupp[]=$val;
}
}
$smarty->assign('grupp', $grupp);
/*!-- END --*/
//echo '
';
$smarty->assign('sel_grupp',$ggg);
$smarty->assign('regim',$regim);
$smarty->assign('items',$items);
$smarty->assign('items1',$items1);
$smarty->assign('form',$form);
$maincontent = $smarty->fetch('tpl_teacher_students.html');
}
}
function grupp_teachers(){
GLOBAL $ST,$DB; $items = array();
$sql='SELECT g.* FROM '.$ST['dbpf'].'_grupp as g,'.$ST['dbpf'].'_grupp_teachers as gt WHERE gt.id_teacher='.$_SESSION['user']['teacher']['id'].' AND gt.id_grupp=g.id ORDER BY g.kurs,g.sokr';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
$val['teacher']=get_teacher_user($val['id_teacher']);
$rez1=$DB->QUR_SEL('SELECT id FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].' AND status!=0');
if($rez1) $val['students']=$rez1[0]; else $val['students']=0;
if (get_prava_grupp($val['id_teacher'])) $val['edde']=1; else $val['edde']=0;
$items[$i]=$val;
$i++;
}
}
return $items;
}
//для парсинга текста
function getSslPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
//сортировка массива
function aasort (&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
function get_ocenki($id_grupp,$id_prepod){
GLOBAL $ST,$DB;
$ocenki['grupp']=array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$id_grupp.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
$ocenki['grupp']=$rez[1];
}
$ocenki['students']=array();
//выберем всех студентов
/*$sql = 'SELECT * FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$id_grupp.' ';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_users WHERE id='.$val['id_user'].' AND status>-1 LIMIT 1';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$val['user'] = $rez1[1];
$ocenki['students'][]=$val;
} else {
$val['user'] = array();
}
//$ocenki['students']['user']['fio'] = trim($ocenki['students']['user']['fio']);
}
}
*/
//$sql = 'SELECT s.*,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.email as uemail,u.pass as upass,u.status as ustatus,u.fio as ufio,u.foto as ufoto FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE s.id_grupp='.$id_grupp.' AND u.status>-1 AND u.id=s.id_user ORDER BY u.fio';
$sql = 'SELECT s.*,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.email as uemail,u.pass as upass,u.status as ustatus,u.fio as ufio,u.foto as ufoto FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE s.id_grupp='.$id_grupp.' AND s.status = 1 AND u.status>-1 AND u.id=s.id_user ORDER BY u.fio';
if (isset($_GET["podgruppa"])){ //если указана подгруппа, то выводим только студентов этой подгруппы
$podgruppa = $_GET["podgruppa"];
//$sql = 'SELECT s.*,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.email as uemail,u.pass as upass,u.status as ustatus,u.fio as ufio,u.foto as ufoto FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE s.id_grupp='.$id_grupp.' AND s.num_grupp='.$podgruppa.' AND u.status>-1 AND u.id=s.id_user ORDER BY u.fio';
$sql = 'SELECT s.*,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.email as uemail,u.pass as upass,u.status as ustatus,u.fio as ufio,u.foto as ufoto FROM '.$ST['dbpf'].'_students as s,'.$ST['dbpf'].'_users as u WHERE s.id_grupp='.$id_grupp.' AND s.status = 1 AND s.num_grupp='.$podgruppa.' AND u.status>-1 AND u.id=s.id_user ORDER BY u.fio';
}
$rez = $DB->QUR_SEL($sql);
//echo $sql.'
'.print_r($rez,1).'
';
//SELECT s.*,u.id as uid,u.data_c as udata_c,u.data_u as udata_u,u.email as uemail,u.pass as upass,u.status as ustatus,u.fio as ufio,u.foto as ufoto FROM acs_students as s,acs_users as u WHERE s.id_grupp=780 AND s.status = 1 AND u.status>-1 AND u.id=s.id_user ORDER BY u.fio
//Array()
if($rez){
foreach($rez as $key => $val)if($key){
$val['user'] = array('id'=>$val['uid'],'data_c'=>$val['udata_c'],'data_u'=>$val['udata_u'],'email'=>$val['uemail'],'pass'=>$val['upass'],'status'=>$val['ustatus'],'fio'=>$val['ufio'],'foto'=>$val['ufoto']);
$ocenki['students'][]=$val;
}
}
//сортируем массив
//aasort($ocenki['students'], 'fio');
//выберем все дисциплины
$ocenki['lections']=array();
//lections
if($id_prepod!=0)
$sql = 'SELECT l.* FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$id_grupp.' AND lg.id_lections=l.id AND l.id_teacher='.$id_prepod.' ORDER BY l.kurs,l.semestr';
else $sql = 'SELECT l.* FROM '.$ST['dbpf'].'_lections as l,'.$ST['dbpf'].'_lections_grupp as lg WHERE lg.id_grupp='.$id_grupp.' AND lg.id_lections=l.id ORDER BY l.kurs,l.semestr';
$rez = $DB->QUR_SEL($sql);
//echo $sql.'
'.print_r($rez,1).'
';exit();
// [50] => Array( [id] => 60743 [data_c] => 1699872431 [data_u] => 1699872431 [id_teacher] => 295
// [specialnost] => [kurs] => 3 [semestr] => 5 [name] => Элективные дисциплины по физической культуре и спорту
// [descrip] => лекция [file] => [type] => лек )
if($rez){
foreach($rez as $key => $val)if($key){
if($id_prepod==0){
$sql1 = 'SELECT u.fio FROM '.$ST['dbpf'].'_teachers as t,'.$ST['dbpf'].'_users as u WHERE NOT(u.status = -1) AND u.id=t.id_user AND t.id='.$val['id_teacher'].'';
$rez1 =$DB->QUR_SEL($sql1);
$val['fioprep']=$rez1[1]['fio'];
$val["prepod_name"] = $val['fioprep'];
}else{
$val['fioprep']=$_SESSION['user']['fio'];
}
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_practich WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['practich'][] = $val1;
}
} else $val['practich'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_sr WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['sr'][] = $val1;
}
} else $val['sr'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_controln WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['controln'][] = $val1;
}
} else $val['controln'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_praktika WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['praktika'][] = $val1;
}
} else $val['praktika'] = array();
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_kursov WHERE id_lection='.$val['id'].' ORDER BY name';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val['kursov'][] = $val1;
}
} else $val['kursov'] = array();
$ocenki['lections'][]=$val;
}
}
//echo '
'.print_r($ocenki,1).'
';exit();
//[49] => Array(
// [id] => 60743 [data_c] => 1699872431 [data_u] => 1699872431 [id_teacher] => 295
// [specialnost] => [kurs] => 3 [semestr] => 5
// [name] => Элективные дисциплины по физической культуре и спорту
// [descrip] => лекция [file] => [type] => лек
// [fioprep] => Двойникова Елена Сергеевна [prepod_name] => Двойникова Елена Сергеевна
// [practich] => Array (
// [0] => Array (
// [id] => 13395 [data_c] => 1699872431 [data_u] => 1699872431
// [id_teacher] => 295 [id_lection] => 60743
// [name] => Элективные дисциплины по физической культуре и спорту
// [descrip] => практические занятия
// [file] =>
// )
// )
$data_c1 = get_data_startsemestr();
if ($data_c1 < 10) $data_c1 = 0;
//выберем все оценки
if($id_prepod!=0)
$sql = 'SELECT * FROM '.$ST['dbpf'].'_ocenki WHERE id_grupp='.$id_grupp.' AND id_prepod='.$id_prepod.' AND data_c>='.$data_c1.'';
else $sql = 'SELECT * FROM '.$ST['dbpf'].'_ocenki WHERE id_grupp='.$id_grupp.' AND data_c>='.$data_c1.'';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$ocenki['saves']['propusk'][$val['id_what']][$val['id_student']]=$val['propusk'];
$ocenki['saves']['upv'][$val['id_what']][$val['id_student']]=$val['upv'];
if($val['what']=='lection') {
$ocenki['saves']['ol'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
$ocenki['datas']['ol'][$val['id_what']]=date('d.m.Y',$val['data_c']);
}
if($val['what']=='practich') {
$ocenki['saves']['pr'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
$ocenki['datas']['pr'][$val['id_what']]=date('d.m.Y',$val['data_c']);
}
if($val['what']=='controln') {
$ocenki['saves']['co'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
$ocenki['datas']['co'][$val['id_what']]=date('d.m.Y',$val['data_c']);
}
if($val['what']=='praktika') {
$ocenki['saves']['pra'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
$ocenki['datas']['pra'][$val['id_what']]=date('d.m.Y',$val['data_c']);
}
if($val['what']=='kursov') {
$ocenki['saves']['kur'][$val['id_what']][$val['id_student']][$val['type']]=$val['ocenka'];
$ocenki['datas']['kur'][$val['id_what']]=date('d.m.Y',$val['data_c']);
}
}
}
//echo $sql.'
'.print_r($ocenki,1).'
';exit();
//SELECT * FROM acs_ocenki WHERE id_grupp=168 AND data_c>=1576098000
//удалим лекции у которых нет оценок - тогда преподы не могут выставлять
/*foreach ($ocenki['lections'] as $k => $v){
$del=1;
if(isset($ocenki['saves']['propusk'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['upv'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['ol'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['pr'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['co'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['pra'][$v['id']])){ $del=0;}
if(isset($ocenki['saves']['kur'][$v['id']])){ $del=0;}
if($del==1) unset($ocenki['lections'][$k]);
}*/
return $ocenki;
}
/*
function get_sel_grupp0($id){
GLOBAL $ST,$DB; $out=array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez=$DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$out[$key]=$val;
if($id==$val['id']) $out[$key]['active']=1;
}
}
return $out;
}*/
function get_lection($id){//Получение лекций
GLOBAL $ST,$DB; $out=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$id.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$out=$rez[1];
}
return $out;
}
/*
function get_user($id){
GLOBAL $ST,$DB; $out=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_users WHERE id='.$id.'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$out=$rez[1];
unset($out['pass']);
}
return $out;
}
*/
function upload_lection($name,$dir_dest){
$file=''; $tmpfile=array();
//if(count($_FILES[$name]['name'])>0){//загружаем массив файлов
if(is_array($_FILES[$name]['name'])){//загружаем массив файлов
//echo '1';
$masf = $_FILES[$name];
foreach($masf['name'] as $k => $v){
$_FILES[$name]['name']=$v;
$_FILES[$name]['type']=$masf['type'][$k];
$_FILES[$name]['tmp_name']=$masf['tmp_name'][$k];
$_FILES[$name]['error']=$masf['error'][$k];
$_FILES[$name]['size']=$masf['size'][$k];
$handle = new Upload($_FILES[$name]);
if ($handle->uploaded) {
$handle->file_new_name_body = $_SESSION['user']['id'].'_'.$_SESSION['user']['teacher']['id'].'_'.date('HisdmY').'_'.$k;
$handle->Process($dir_dest);
if ($handle->processed) {
$tmpfile[]=$handle->file_dst_name;
}
$handle-> Clean();
}
}
/*Array([file] => Array(
[name] => Array([0] => 25letmgtu.png[1] => геом1.jpg[2] => геом0.jpg)
[type] => Array([0] => image/png[1] => image/jpeg[2] => image/jpeg)
[tmp_name] => Array([0] => /tmp/phpqPxIbC[1] => /tmp/phpmkGpHH[2] => /tmp/phpUSXpCN)
[error] => Array([0] => 0[1] => 0[2] => 0)
[size] => Array([0] => 151792[1] => 455902[2] => 490560) ))*/
if(count($tmpfile)){
$file = implode('|',$tmpfile);
}
}else{
//echo '2';
$handle = new Upload($_FILES[$name]);
if ($handle->uploaded) {
echo '3';
$handle->file_new_name_body = $_SESSION['user']['id'].'_'.$_SESSION['user']['teacher']['id'].'_'.date('HisdmY');
$handle->Process($dir_dest);
if ($handle->processed) {
//echo '4';
$file=$handle->file_dst_name;
}else{
//echo '5';
}
$handle-> Clean();
}
}
//echo $file;
return $file;
}
function get_sel_grupp_tr($id){
GLOBAL $ST,$DB; $out=array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_grupp ORDER BY sokr,kurs';
$rez=$DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$rez1=$DB->QUR_SEL('SELECT count(id) as kol FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].'');
//$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_students WHERE id_grupp='.$val['id'].'');
$val['kol'] = $rez1[1]['kol'];
//$val['kol'] = $rez1[0];
$out[$key]=$val;
if($id==$val['id']) $out[$key]['active']=1;
}
}
return $out;
}
?>