DB = $DB; $this->TFile = $ST['dbpf'].'_fshp_file'; $this->TFiles = $ST['dbpf'].'_fshp_files'; $this->TUchebplans = $ST['dbpf'].'_fshp_uchebplans'; $this->TUchebplansPrepod = $ST['dbpf'].'_fshp_disciplin_prepod'; $this->TUchebplans_compet = $ST['dbpf'].'_fshp_uchebplans_compet'; $this->TCompet = $ST['dbpf'].'_fshp_compet'; $this->Tteachers = $ST['dbpf'].'_teachers'; $this->Tusers = $ST['dbpf'].'_users'; $this->Trpdsave = $ST['dbpf'].'_fshp_rpd_save'; /*acs_fshp_rpd_signs: id data_c id_user id_rpd sign descrip */ $this->Trpdsign = $ST['dbpf'].'_fshp_rpd_signs'; $this->Trpdhash = $ST['dbpf'].'_fshp_rpd_save_hash'; $this->TLibCheck = $ST['dbpf'].'_fshp_libchecks'; $this->debug=array(); } public function RPD_sign_DES($data){ $out['err']=0; $out['msg']='---'; /*acs_fshp_rpd_signs: id data_c id_user id_rpd sign descrip */ $id_rpd = (int)$data['id_disc']; $sign = (int)$data['sign']; $kafvyp = (int)$data['kafvyp']; $descr = $this->DB->rescape($data['descr']); $who = '---'; $pr_kaf=0; $out['file_pdf']=''; if(isset($_SESSION['user']['statuses'][79])){ $who = 'Проректор'; //сам проректор может быть завкафом $sql = 'SELECT sign FROM '.$this->Trpdsign.' WHERE id_rpd='.$id_rpd.' ORDER BY data_c DESC LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']&&$rez['rez'][0]['sign']=='Разработчик') { $pr_kaf=1; if($kafvyp==1) $who = 'Зав.вып.каф.'; else $who = 'Зав.каф.'; } }else{ if(isset($_SESSION['user']['statuses'][30])){ if($kafvyp==1) $who = 'Зав.вып.каф.'; else $who = 'Зав.каф.'; } } if($sign==1){ if(isset($_SESSION['user']['statuses'][79])){//надо сформировать PDF! if($pr_kaf==0) {//только когда проректор! $id_disc = $id_rpd; $class_RPD = new class_RPD(); //получаем главную дисциплину учебного плана $DISCIPS = $class_RPD->Disciplin_Get_Grupp($id_disc); //echo '
'.print_r($DISCIPS,1).''; exit(); $DISCIP = $class_RPD->DISCIP_get_Main($DISCIPS); //echo '
'.print_r($DISCIP,1).''; exit(); $fpdf = $class_RPD->RPD_GetPDF($DISCIP['id'], $id_disc, 0); //echo '$id_disc='.$id_disc.'
'.print_r($fpdf,1).''; //echo '
'.print_r($DISCIPS,1).''; //echo '
'.print_r($DISCIP,1).''; //exit(); //$fpdf = $class_RPD->RPD_GetPDF_by_SaveID($id_disc,0,0); $out['file_pdf'] = $fpdf['file']; $descrsql = $out['file_pdf']; }else{//иначе проректор подписывает как зав.каф $descrsql = 'Подписано. '.$descr; } }else{ $descrsql = 'Подписано. '.$descr; } if($_SESSION['user']['id'] == 343 && $who == 'Проректор'){ $id_user = 565; //Задорожная Людмила Ивановна }else{ $id_user = $_SESSION['user']['id']; } $sql = 'INSERT INTO '.$this->Trpdsign.' VALUES (0,'.time().','.$_SESSION['user']['id'].','.$id_rpd.',"'.$who.'","'.$descrsql.'",1)'; $rez = $this->DB->QUR($sql); if(!$rez['err']){ $out['err']=0; $out['msg']='Рабочую программу отправили далее на подпись'; }else{ $out['err']=1; $out['msg']='Ошибка при сохранении!'; } }else{ $sql = 'INSERT INTO '.$this->Trpdsign.' VALUES (0,'.time().','.$_SESSION['user']['id'].','.$id_rpd.',"'.$who.'","Не подписано. '.$descr.'",0)'; $rez = $this->DB->QUR($sql); if(!$rez['err']){ $out['err']=0; $out['msg']='Рабочую программу отправили на доработку!'; }else{ $out['err']=1; $out['msg']='Ошибка при сохранении!'; } } //Удалим из кэша $sql1 = 'SELECT sign FROM '.$this->Trpdsign.' WHERE id_rpd='.$id_rpd.' ORDER BY data_c DESC LIMIT 1'; $this->cache_sess($sql1,'RPDsign_Cache','del'); return $out; } public function HTML(){ GLOBAL $WorkDIR; $CHPU = new class_CHPU($WorkDIR); $URLS = $CHPU->uri(); $smartyC = new class_smarty(); $smarty = $smartyC->config(__DIR__.'\..\tpl'); //обработка АЯКС запросов if(isset($_POST['ajdes'])){ header('Content-Type: application/json; charset=utf-8'); $out=array(); //Подпись РПД и отправка на проверку if($_POST['ajdes']=='RPDSignURL'){ $id_disc = (int)$_POST['id_disc']; $hr = $this->DB->rescape($_POST['hr']); $url = $this->DB->rescape($_POST['url']); $descrip = $hr.'|#|'.$url; $sql = 'UPDATE '.$this->Trpdsign.' SET descrip="'.$descrip.'" WHERE id_rpd='.$id_disc.' AND sign="Проректор" AND status=1'; $rez = $this->DB->QUR($sql); //$out['sql']=$sql; //$out['rez']=$rez; if(!$rez['err']){ $out['err']=0; $out['msg']='Сохранили ссылку'; }else{ $out['err']=1; $out['msg']='Ссылку не сохранили. ошибка!'; } } if($_POST['ajdes']=='RPDSign'){ $out = $this->RPD_sign_DES($_POST); } echo json_encode($out); exit(); } $view = 'all'; $out = array('name'=>'РПД','body'=>''); //Удаление подписи РПД if(isset($URLS[1])&&$URLS[1]=='delsign') { $id = (int)$URLS[2]; $sql = 'DELETE FROM '.$this->Trpdsign.' WHERE id='.$id.' AND id_user='.$_SESSION['user']['id']; $rez = $this->DB->QUR($sql); } //Отображение РПД if(isset($URLS[1])&&$URLS[1]=='pdf') { $id_disc = (int)$URLS[2]; $class_RPD = new class_RPD(); $rez = $class_RPD->RPD_GetPDF_by_SaveID($id_disc); $out['body'] = $rez['body']; } $show='all'; if(isset($_SESSION['user']['statuses'][79])){ $show='rs1'; } if($URLS[1]=='rs1') { $show='rs1'; } if($URLS[1]=='rs2') { $show='rs2'; } if($URLS[1]=='rs3') { $show='rs3'; } if($URLS[1]=='rs4') { $show='rs4'; } if(!isset($URLS[1])||$URLS[1]=='all'||$URLS[1]=='rs1'||$URLS[1]=='rs2'||$URLS[1]=='rs3'||$URLS[1]=='rs4') { $dis = $this->Disciplins($show); $smarty->assign('navpages', $dis['nav']); $smarty->assign('DISCIPS', $dis['items']); $smarty->assign('aUSER',$_SESSION['user']); $smarty->assign('show',$show); $smarty->assign('debug_sql',$this->debug); $out['body'] = $smarty->fetch('page_rpds_signs.html'); } return $out; } function debug_sql($sql){ $key = md5($sql); if(!isset($this->debug[$key])) { $this->debug[$key]['sql'] = $sql; $this->debug[$key]['times'][] = round(microtime(),3); }else{ $last = round(microtime(),3); $this->debug[$key]['times'][] = $last; $this->debug[$key]['time'] = $last - $this->debug[$key]['times'][0]; } } /** * Кэширование SQL запросов * @param $sql1 * @param $key * @return array|mixed|null */ function cache_sess($sql1,$key='RPDsign_Cache',$des='add'){ if($des=='del'){ if(isset($_SESSION[$key][md5($sql1)])) unset($_SESSION[$key][md5($sql1)]); }else { if (!isset($_SESSION[$key][md5($sql1)])) { $rez1 = $this->DB->QUR_SEL($sql1); $_SESSION[$key][md5($sql1)] = $rez1; } else { $rez1 = $_SESSION[$key][md5($sql1)]; } } return $rez1; } /** * Выбор назначенных дисциплин преподавтелю * @param int $id_user * @return array */ public function Disciplins($show=''){ GLOBAL $URLS; $out=array(); $debug=array(); //if($id_user==0) $id_user = $_SESSION['user']['id']; //echo '
'.print_r($_SESSION,1).''; //echo '
'.print_r($URLS,1).'';exit(); $perpage = 10; $navpage = 1; if(isset($URLS['navpage'])) $navpage = (int)$URLS['navpage']; $start = ($navpage-1)*$perpage; $kafname = $_SESSION['user']['teachers']['kafedra']; $search = ''; if(isset($_POST['search'])) $search = $this->DB->rescape($_POST['search']); $cYear = 'AND f.god_nach_podgot='.$_SESSION['year_cur']; if(isset($_SESSION['user']['statuses'][79])){ //$sql = 'SELECT // u.id,u.index1,u.kaf_name,u.name,f.shifr,f.program,f.naprav,f.kafedra as kaf_name_vyp,f.god_nach_podgot,f.fo,f.srok_poluch_obr //FROM // '.$this->TUchebplansPrepod.' as up, // '.$this->TUchebplans.' as u, // '.$this->TFile.' as f, // '.$this->Trpdsign.' as s //WHERE // up.id_uchebplans=u.id AND // u.id_file = f.id_file AND // s.id_rpd=u.id'; //if($show=='all') $sql .= ' AND (s.sign="Зав.вып.каф." OR s.sign="Зав.каф.") AND s.status=1'; //if($show=='rs1') $sql .= ' AND (s.sign="Зав.вып.каф." AND s.status=1)';//на подпись от проректора //if($show=='rs2') $sql .= ' AND (s.sign="Проректор") AND s.status=1';//подписанные проректором $rpds=array(); if($show=='all') $sql = 'SELECT id_rpd FROM '.$this->Trpdsign.' WHERE (sign="Зав.вып.каф." OR sign="Зав.каф.") AND status=1 ORDER BY data_c DESC'; if($show=='rs1') $sql = 'SELECT id_rpd FROM '.$this->Trpdsign.' WHERE sign="Зав.вып.каф." AND status=1 ORDER BY data_c DESC'; if($show=='rs2') $sql = 'SELECT id_rpd FROM '.$this->Trpdsign.' WHERE sign="Проректор" AND status=1 ORDER BY data_c DESC'; if($show=='rs3') $sql = 'SELECT id_rpd FROM '.$this->Trpdsign.' WHERE (sign="Разработчик" OR sign="Зав.каф.") AND status=1 ORDER BY data_c DESC'; if($show=='rs4') $sql = 'SELECT id_rpd FROM '.$this->Trpdsign.' WHERE (sign="Проректор") AND status=1 ORDER BY data_c DESC'; $rez = $this->DB->QUR_SEL($sql); //echo $sql; exit(); if(!$rez['err']&&$rez['kol']){ foreach($rez['rez'] as $key => $val){ if($show=='all'||$show=='rs2') $rpds[]=$val['id_rpd']; if($show=='rs1'){ $sql1 = 'SELECT sign FROM '.$this->Trpdsign.' WHERE id_rpd='.$val['id_rpd'].' ORDER BY data_c DESC LIMIT 1'; $rez1 = $this->cache_sess($sql1); if (!$rez1['err'] && $rez1['kol'] && $rez1['rez'][0]['sign'] == "Зав.вып.каф.") $rpds[] = $val['id_rpd']; } if($show=='rs3'){ $sql1 = 'SELECT sign FROM '.$this->Trpdsign.' WHERE id_rpd='.$val['id_rpd'].' ORDER BY data_c DESC LIMIT 1'; $rez1 = $this->cache_sess($sql1); if(!$rez1['err']&&$rez1['kol']&&($rez1['rez'][0]['sign']=="Зав.каф."||$rez1['rez'][0]['sign']=="Разработчик")) $rpds[]=$val['id_rpd']; } if($show=='rs4'){ $sql1 = 'SELECT sign FROM '.$this->Trpdsign.' WHERE id_rpd='.$val['id_rpd'].' ORDER BY data_c DESC LIMIT 1'; $rez1 = $this->cache_sess($sql1); if(!$rez1['err']&&$rez1['kol']&&($rez1['rez'][0]['sign']=="Проректор")) $rpds[]=$val['id_rpd']; } } } $kafname = $_SESSION['user']['teachers']['kafedra']; $sql = 'SELECT u.id,u.index1,u.kaf_name,u.name,f.shifr,f.program,f.naprav,f.profil,f.kafedra as kaf_name_vyp,f.god_nach_podgot,f.fo,f.srok_poluch_obr FROM '.$this->TUchebplansPrepod.' as up, '.$this->TUchebplans.' as u, '.$this->TFile.' as f WHERE up.id_uchebplans=u.id AND u.id_file = f.id_file '.$cYear.' AND u.id IN ('.implode(',',$rpds).')'; if($show=='rs3') $sql .= ' AND (u.kaf_name="'.$kafname.'" OR f.kafedra="'.$kafname.'")'; if($show=='rs4') $sql .= ' AND (u.kaf_name="'.$kafname.'" OR f.kafedra="'.$kafname.'")'; if($search!='') $sql .= ' AND (u.index1 LIKE "%'.$search.'%" OR name LIKE "%'.$search.'%")'; //echo $sql; exit(); } else{ //тут надо разделить зав.кафов преподов и зав.кафов выпускающ кафедр! if(isset($_SESSION['user']['statuses'][30])){ $kafname = $_SESSION['user']['teachers']['kafedra']; if($kafname=='Кафедра госпитальной терапии и последипломного образования') $kafname='Госпитальной терапии и последипломного образования'; if($kafname=='Кафедра госпитальной хирургии и последипломного образования') $kafname='Госпитальной хирургии и последипломного образования'; //иностранного языка //u.kaf_kod! //SELECT // u.id,u.index1,u.kaf_name,u.name,f.shifr,f.program,f.naprav,f.kafedra as kaf_name_vyp,f.god_nach_podgot,f.fo,f.srok_poluch_obr // FROM // acs_fshp_disciplin_prepod as up, // acs_fshp_uchebplans as u, // acs_fshp_file as f, // acs_fshp_rpd_signs as s // WHERE // (u.kaf_name="Иностранных языков" OR f.kafedra="Иностранных языков") AND // up.id_uchebplans=u.id AND // u.id_file = f.id_file AND // s.id_rpd=u.id AND // s.id_rpd=u.id AND s.sign="Разработчик" AND s.status=1 $sql = 'SELECT u.id,u.index1,u.kaf_name,u.name,f.shifr,f.program,f.naprav,f.profil,f.kafedra as kaf_name_vyp,f.god_nach_podgot,f.fo,f.srok_poluch_obr FROM '.$this->TUchebplansPrepod.' as up, '.$this->TUchebplans.' as u, '.$this->TFile.' as f, '.$this->Trpdsign.' as s WHERE (u.kaf_name="'.$kafname.'" OR f.kafedra="'.$kafname.'") AND up.id_uchebplans=u.id AND u.id_file = f.id_file '.$cYear.' AND s.id_rpd=u.id AND s.id_rpd=u.id AND s.sign="Разработчик" AND s.status=1'; if($search!='') $sql .= ' AND (u.index1 LIKE "%'.$search.'%" OR name LIKE "%'.$search.'%")'; } } //echo '--'.$search.'
'.print_r($rez,1).'';exit(); if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $v){ $v['saveinfo'] = $this->SaveInfo($v['id']); $rpdsigns = $this->RPDSigns($v['id']); if(count($rpdsigns)==0) $edit=0; else $edit=1; //определяем зав.каф является зав.кафедрой и зав. выпускающей кафедрой //if($v['kaf_name']==$v['kaf_name_vyp']) $v['kafvyp'] = 1; else $v['kafvyp'] = 0; //$v['kaf_name_vyp1'] = $kafname; if(mb_strtolower(trim($kafname))==mb_strtolower(trim($v['kaf_name_vyp']))) { $v['kafvyp'] = 1; } else { $v['kafvyp'] = 0; } //echo '['.$kafname.'] = ['.$v['kaf_name_vyp'].'] = '.$v['kafvyp'].'
'.print_R($rpdsigns[0],1).''; if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; }else{ if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; } }else { if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 1; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 0; } }else{ if(isset($_SESSION['user']['statuses'][79])){ //echo $k.'
'.print_r($v,1).''; //ПРОРЕКТОР ТОЖЕ ЗАВ.КАФЕДРОЙ! if($v['kafvyp']==1){//мы являемся и кафедрой выпускающей if(mb_strtolower(trim($v['kaf_name']))==mb_strtolower(trim($kafname))){//мы являемся и кафедрой препода и выпускающей if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) { $edit = 1; $v['pur'] = 1; } if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; }else{ if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; } }else { $v['pur'] = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 0; } } } $v['file_pdf'] = ''; if($rpdsigns[0]['sign']=='Проректор'&&$rpdsigns[0]['status']==1) { $tmp = explode('|#|',$rpdsigns[0]['descrip']); //$v['file_pdf'] = $rpdsigns[0]['descrip']; $v['file_pdf'] = $tmp[0]; $v['url_pdf'] = $tmp[1]; } $v['rpdsigns'] = $rpdsigns; $v['edit'] = $edit; $out['items'][] = $v; } } //echo $sql.'
'.print_r($out,1).'';exit(); return $out; } /** * Выбор назначенных дисциплин преподавтелю * @param int $id_user * @return array */ public function Disciplins_for_ZAVYPKAF($show=''){ GLOBAL $URLS; $out=array(); $kafname = $_SESSION['user']['teachers']['kafedra']; $cYear = 'AND f.god_nach_podgot='.$_SESSION['year_cur']; //тут надо разделить зав.кафов преподов и зав.кафов выпускающ кафедр! if(isset($_SESSION['user']['statuses'][30])){ $kafname = $_SESSION['user']['teachers']['kafedra']; if($kafname=='Кафедра госпитальной терапии и последипломного образования') $kafname='Госпитальной терапии и последипломного образования'; if($kafname=='Кафедра госпитальной хирургии и последипломного образования') $kafname='Госпитальной хирургии и последипломного образования'; $sql = 'SELECT u.id,u.index1,u.kaf_name,u.name,f.shifr,f.program,f.naprav,f.kafedra as kaf_name_vyp,f.god_nach_podgot,f.fo,f.srok_poluch_obr FROM '.$this->TUchebplansPrepod.' as up, '.$this->TUchebplans.' as u, '.$this->TFile.' as f, '.$this->Trpdsign.' as s WHERE f.kafedra="'.$kafname.'" AND up.id_uchebplans=u.id AND u.id_file = f.id_file '.$cYear.' AND s.id_rpd=u.id AND s.id_rpd=u.id AND s.sign="Разработчик" AND s.status=1'; }//(u.kaf_name="'.$kafname.'" OR f.kafedra="'.$kafname.'") AND if (isset($_SESSION['user']['statuses'][30]) && !isset($_SESSION['user']['statuses'][79])) { $sql .= ' GROUP BY u.id ORDER BY f.god_nach_podgot,f.shifr,f.naprav,f.profil, up.data_c DESC'; } else {//проректор $sql .= ' GROUP BY u.id ORDER BY f.god_nach_podgot,f.shifr,f.naprav,f.profil, up.data_c DESC'; } $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; exit(); if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $v){ $rpdsigns = $this->RPDSigns($v['id']); if(count($rpdsigns)==0) $edit=0; else $edit=1; //определяем зав.каф является зав.кафедрой и зав. выпускающей кафедрой if(mb_strtolower($kafname)==mb_strtolower($v['kaf_name_vyp'])) $v['kafvyp'] = 1; else $v['kafvyp'] = 0; $v['pur']=0; if(isset($_SESSION['user']['statuses'][30])&&!isset($_SESSION['user']['statuses'][79])){ if($v['kafvyp']==1){ if(mb_strtolower($v['kaf_name'])==mb_strtolower($kafname)){//мы являемся и кафедрой препода и выпускающей if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; }else{ if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; } }else { if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 1; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 0; } }else{ if(isset($_SESSION['user']['statuses'][79])){ //ПРОРЕКТОР ТОЖЕ ЗАВ.КАФЕДРОЙ! if($v['kafvyp']==1){//мы являемся и кафедрой выпускающей if(mb_strtolower($v['kaf_name'])==mb_strtolower($kafname)){//мы являемся и кафедрой препода и выпускающей if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) { $edit = 1; $v['pur'] = 1; } if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; }else{ if ($rpdsigns[0]['sign'] == 'Разработчик' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 0) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 1; } }else { $v['pur'] = 1; if ($rpdsigns[0]['sign'] == 'Зав.каф.' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Зав.вып.каф.' && $rpdsigns[0]['status'] == 1) $edit = 1; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 1) $edit = 0; if ($rpdsigns[0]['sign'] == 'Проректор' && $rpdsigns[0]['status'] == 0) $edit = 0; } } } $v['file_pdf'] = ''; if($rpdsigns[0]['sign']=='Проректор'&&$rpdsigns[0]['status']==1) { $tmp = explode('|#|',$rpdsigns[0]['descrip']); //$v['file_pdf'] = $rpdsigns[0]['descrip']; $v['file_pdf'] = $tmp[0]; $v['url_pdf'] = $tmp[1]; } $v['rpdsigns'] = $rpdsigns; $v['edit'] = $edit; $out['items'][] = $v; } } return $out; } /** * Получение информации о сохраненных данных * @param $id_rpd * @return array */ public function RPDSigns($id_rpd,$user=0){ $out=array(); /*acs_fshp_rpd_signs: id data_c id_user id_rpd sign descrip*/ if($user==0) {//не берем ФИО $sql = 'SELECT * FROM ' . $this->Trpdsign . ' WHERE id_rpd=' . $id_rpd . ' ORDER BY data_c DESC'; }else{ $sql = 'SELECT s.*,u.fio,t.zvanie,t.dolgnost,t.stepen,t.fakultet,t.kafedra FROM ' . $this->Trpdsign . ' as s,'.$this->Tusers.' as u,'.$this->Tteachers.' as t WHERE s.id_rpd=' . $id_rpd . ' AND s.id_user=u.id AND u.id=t.id_user ORDER BY s.data_c DESC'; } $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_R($rez,1).'';exit(); if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $v){ $out[] = $v; } } return $out; } /** * Получение информации о сохраненных данных для PDF нужны только последние * @param $id_rpd * @return array */ public function RPDSignsPDF($id_rpd,$user=0,$kafname=''){ $out=array(); /*acs_fshp_rpd_signs: id data_c id_user id_rpd sign descrip*/ if($user==0) {//не берем ФИО $sql = 'SELECT * FROM ' . $this->Trpdsign . ' WHERE id_rpd=' . $id_rpd . ' ORDER BY data_c DESC'; }else{ $sql = 'SELECT s.*,u.fio,t.zvanie,t.dolgnost,t.stepen,t.fakultet,t.kafedra FROM ' . $this->Trpdsign . ' as s, '.$this->Tusers.' as u, '.$this->Tteachers.' as t WHERE s.id_rpd=' . $id_rpd . ' AND s.status=1 AND s.id_user=u.id AND u.id=t.id_user ORDER BY s.data_c DESC'; } $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; exit(); $wh['raz']=0;//Разработчик $wh['zak']=0;//Зав.каф. $wh['zvk']=0;//Зав.вып.каф. $wh['pur']=0;//Проректор $dubl=array(); if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $v){ if($v['sign']=='Разработчик'&& $wh['raz']==0) { $out['raz'] = $v; $wh['raz']=1; } if($v['sign']=='Зав.каф.'&& $wh['zak']==0) { if($v['fio']=='хадж мохамед риад мурадович') $v['fio']=''; $out['zak'] = $v; $wh['zak']=1; } if($v['sign']=='Зав.вып.каф.'&&$wh['zvk']==0) { $out['zvk'] = $v; $wh['zvk']=1; $dubl = $v; $dubl['sign'] = 'Зав.каф.'; } if($v['sign']=='Проректор'&& $wh['pur']==0) { $out['pur'] = $v; $wh['pur']=1; } if(count($dubl)){//Дублируем зав.вып.каф на зав.каф. $out['zak'] = $dubl; $dubl=array(); } } } //echo $sql.'
'.print_R($out,1).'';exit(); //Получаем подпись библиотеки! $this->TLibCheck.id_rpd - это acs_fshp_rpd_save.id $out['lib']['fio']='И. Б. Берберьян'; $out['lib']['zvanie']=''; $out['lib']['dolgnost']=''; $out['lib']['stepen']=''; $out['lib']['fakultet']=''; $out['lib']['kafedra']='НБ МГТУ'; $out['lib']['data_c']=$rez['rez'][0]['data_c']; $out['lib']['sign']='НБ МГТУ'; $out['lib']['descrip']='Не проверено'; $out['lib']['status']=0; $sql = 'SELECT id FROM ' . $this->Trpdsave . ' WHERE id_discip=' . $id_rpd . ' ORDER BY data_c DESC LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']) { $id_save = $rez['rez'][0]['id']; $sql = 'SELECT * FROM ' . $this->TLibCheck . ' WHERE id_rpd=' . $id_save . ' ORDER BY data_c DESC'; $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; $out['lib'] = array(); if (!$rez['err'] && $rez['kol']) { //s.*,u.fio,t.zvanie,t.dolgnost,t.stepen,t.fakultet,t.kafedra //Согласовано: НБ МГТУ ——также подпись простая электронная как у всех из кабинета, с выводом фамилии И. Б. Берберьян $out['lib']['fio'] = 'И. Б. Берберьян'; $out['lib']['zvanie'] = ''; $out['lib']['dolgnost'] = ''; $out['lib']['stepen'] = ''; $out['lib']['fakultet'] = ''; $out['lib']['kafedra'] = 'НБ МГТУ'; $out['lib']['data_c'] = $rez['rez'][0]['data_c']; $out['lib']['sign'] = 'НБ МГТУ'; $out['lib']['descrip'] = 'Проверено'; $out['lib']['status'] = 1; } } $out1[] = $out['pur']; $out1[] = $out['lib']; $out1[] = $out['zvk']; $out1[] = $out['zak']; $out1[] = $out['raz']; //echo '$out1=
'.print_r($out1,1).'';exit(); return $out1; } /** * Получение информации о сохраненных данных * @param $id_rpd * @return array */ public function SaveInfo($id_rpd){ $out=array('err'=>1,'msg'=>'пустой запрос'); //$polyas = array('razdel1'=>'Раздел 1','razdel2'=>'Раздел 2','razdel3'=>'Раздел 3','razdel4'=>'Раздел 4','razdel5'=>'Раздел 5','razdel5_4'=>'Раздел 5.4','razdel5_5'=>'Раздел 5.5','razdel5_6'=>'Раздел 5.6','razdel5_7'=>'Раздел 5.7','razdel5_8'=>'Раздел 5.8','razdel5_9'=>'Раздел 5.9','razdel6_1'=>'Раздел 6.1','razdel6_2'=>'Раздел 6.2','razdel7'=>'Раздел 7.1','razdel7_2'=>'Раздел 7.2','razdel7_3'=>'Раздел 7.3','razdel7_4'=>'Раздел 7.4','razdel8_1'=>'Раздел 8.1','razdel8_2'=>'Раздел 8.2','razdel8_3'=>'Раздел 8.3','razdel9'=>'Раздел 9','razdel10_1'=>'Раздел 10.1','razdel10_2'=>'Раздел 10.2','razdel11'=>'Раздел 11'); $polyas = array('razdel1'=>'1','razdel2'=>'2','razdel3'=>'3','razdel4'=>'4','razdel5'=>'5','razdel5_4'=>'5.4','razdel5_5'=>'5.5','razdel5_6'=>'5.6','razdel5_7'=>'5.7','razdel5_8'=>'5.8','razdel5_9'=>'5.9','razdel6_1'=>'6.1','razdel6_2'=>'6.2','razdel7'=>'7.1','razdel7_2'=>'7.2','razdel7_3'=>'7.3','razdel7_4'=>'7.4','razdel8_1'=>'8.1','razdel8_2'=>'8.2','razdel8_3'=>'8.3','razdel9'=>'9','razdel10_1'=>'10.1','razdel10_2'=>'10.2','razdel11'=>'11'); //TODO проблема когда назначаем одному преподавателю он делает, потом назначаем другому он делает и опять возвращаем первому, но дата сохранения остается от последнего! и сохранения возвращаем не те (не последние) $sql = 'SELECT * FROM '.$this->Trpdsave.' WHERE id_discip='.$id_rpd.' ORDER BY data_c DESC LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); //$out['rez']=$rez; if(!$rez['err']&&$rez['kol']){ $save = $rez['rez'][0]; $out['err']=0; $out['save_id']=$save['id']; $out['msg']='получили данные'; $out['is']=array(); $out['nul']=array(); foreach ($polyas as $k => $p){ if($save[$k]!='') $out['is'][] = $p; else $out['nul'][] = $p; } } return $out; } /** * Получение информации о дисциплине * @param $id * @return array */ public function Disciplin($id){ $out = array(); $sql = 'SELECT * FROM '.$this->TUchebplans.' WHERE id='.$id.' LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ $rez['rez'][0]['json'] = json_decode($rez['rez'][0]['json'],1); $out['uchebplan'] = $rez['rez'][0]; //надо подсчитать итого $itogs = array(); foreach ($out['uchebplan']['json'] as $kurs => $kv) { foreach ($kv as $sem => $kzan){ foreach ($kzan as $k => $zan){ if($k!='ze') $itogs[$kurs][$sem] += $zan; } } } $out['uchebplan']['itogs'] = $itogs; $sql = 'SELECT * FROM '.$this->TFile.' WHERE id_file='.$out['uchebplan']['id_file'].' LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ $out['title'] = $rez['rez'][0]; }else{ $out['title'] = array(); } $sql = 'SELECT c.* FROM '.$this->TUchebplans_compet.' as uc,'.$this->TCompet.' as c WHERE uc.id_uchebplans='.$id.' AND uc.id_compet=c.id ORDER BY c.index'; //GROUP BY c.index $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $val){ $out['comp'][$val['index']] = $val['descrip']; } }else{ $out['comp'] = array(); } } return $out; } /** * Автоподписание рпд после промежутка времени * @param $hours * @return void */ public function rpdsign_auto($hours){ $rpds = array(); //собираем все РПД с подписью от Зав.вып.каф. $sql = 'SELECT data_c,id_rpd FROM acs_fshp_rpd_signs WHERE sign="Зав.вып.каф." AND status=1 GROUP BY id_rpd ORDER BY RAND()'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']) { foreach ($rez['rez'] as $key => $val) { $rpds[] = $val; } } //echo '
'.print_r($rpds,1).''; $rpds0 = array(); //Убираем все что уже пописано ПРОРЕКТОРОМ foreach ($rpds as $key => $val) { $sql1 = 'SELECT id_rpd FROM acs_fshp_rpd_signs WHERE sign="Проректор" AND status=1 AND id_rpd='.$val['id_rpd']; $rez1 = $this->DB->QUR_SEL($sql1); if(!$rez1['err']&&$rez1['kol']) {}else $rpds0[] = $val; } //echo '
'.print_r($rpds0,1).''; //проверим все ли попадают под время $now = time(); foreach ($rpds0 as $key => $val) { if( ($now - $val['data_c'])>=(60*60*3) ) { //echo $val['id_rpd'] . ':' . date('H:i:s d.m.Y', $val['data_c']) . '