DB = $DB; if(isset($data['cron'])&&$data['cron']==1){ }else { $CHPU = new class_CHPU($WorkDIR); $this->URLS = $CHPU->uri(); } if(isset($data['fakultet'])) $this->fakultet = $data['fakultet']; if(isset($data['kafedra'])) $this->kafedra = $data['kafedra']; //echo '
'.print_r($data,1).'';exit(); $this->tip = 'prorektor'; if(isset($data['tip'])) $this->tip = $data['tip']; $this->TFile = $ST['dbpf'].'_fshp_file'; $this->TUchebplans = $ST['dbpf'].'_fshp_uchebplans'; } public function HTML(){ GLOBAL $WorkDIR; $out = array(); $smartyC = new class_smarty(); $smarty = $smartyC->config(__DIR__.'\..\tpl'); $urls = $this->URLS; //echo '
'.print_r($urls,1).'';Array([0]=statpur [1]=pdf01) if(isset($urls[1])){ if($urls[1]=='pdf01'&&isset($urls[2])){ $id_fak = (int)$urls[2]; if($this->tip=='prorektor') { $data = $this->get_facultets($id_fak); } if($this->tip=='dekan') { $data = $this->get_facultets($this->get_facultet_by_name($this->fakultet)); } if($this->tip=='zavkaf') { $facultets = $this->get_facultets($this->get_facultet_by_name($this->fakultet)); foreach ($facultets as $key1 => $schools){ foreach ($schools as $key2 => $school){ foreach ($school['kafedras'] as $key3 => $kafedra){ if($kafedra['name']!=$this->kafedra){ unset($facultets[$key1][$key2]['kafedras'][$key3]); } } } } $data = $facultets; //echo '
'.print_r($data,1).''; exit(); } $smarty->assign('TPL',$WorkDIR); $smarty->assign('facultets', $data); $smarty->display('page_statpur_pdf.html'); exit(); } }else { $des='view'; if(isset($_POST['fio_search'])){ $des='search'; $fio = $this->DB->rescape($_POST['fio']); $itogs=array(); $itogsPrep=array(); $itogsPrep2=array(); $sql = 'SELECT id,fio FROM acs_users WHERE fio LIKE "%'.$fio.'%"'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ foreach($rez['rez'] as $key => $val){ $sql1 = 'SELECT dp.id_uchebplans,up.id,up.index1,up.name,up.kaf_kod,up.kaf_name FROM acs_fshp_disciplin_prepod as dp, acs_fshp_uchebplans as up WHERE dp.id_prepod = '.$val['id'].' AND up.id=dp.id_uchebplans'; $rez1 = $this->DB->QUR_SEL($sql1); //echo '
'.print_r($rez1,1).'';exit(); if(!$rez1['err']&&$rez1['kol']) { foreach ($rez1['rez'] as $key1 => $val1) { $itog['kaf_kod'] = $val1['kaf_kod']; $itog['kaf_name'] = $val1['kaf_name']; $itog['index1'] = $val1['index1']; $itog['name'] = $val1['name']; $itog['save'] = array(); $sql2 = 'SELECT sv.* FROM acs_fshp_rpd_save as sv WHERE sv.id_discip='.$val1['id']; $rez2 = $this->DB->QUR_SEL($sql2); //echo '
'.print_r($rez2,1).'';//exit(); if(!$rez2['err']&&$rez2['kol']){ foreach($rez2['rez'] as $key2 => $val2){ $rpdsave=array(); $rpdsave[] = $val2; $itog['save'] = $this->save_calcul($rpdsave); $itogsPrep[$val['fio']][]=round($itog['save']['proc']/100,2); } }else{ $itogsPrep[$val['fio']][]=0; } $itogs[$val['fio']][]=$itog; $itogsPrep2[$val['fio']]['all'] = count($itogsPrep[$val['fio']]); $sums = 0; foreach($itogsPrep[$val['fio']] as $k => $v) $sums+=$v; $itogsPrep2[$val['fio']]['proc'] = round(($sums/count($itogsPrep[$val['fio']]))*100,2); } } } } $smarty->assign('itogs', $itogs); $smarty->assign('itogsPrep2', $itogsPrep2); }else { if ($this->tip == 'prorektor') { $out = array('name' => 'Статистика проректора', 'body' => ''); $smarty->assign('facultets', $this->get_facultets()); } if ($this->tip == 'dekan') { $out = array('name' => 'Статистика "' . $this->fakultet . '"', 'body' => ''); $smarty->assign('facultets', $this->get_facultets($this->get_facultet_by_name($this->fakultet))); } if ($this->tip == 'zavkaf') { $out = array('name' => 'Статистика "' . $this->kafedra . '"', 'body' => ''); $facultets = $this->get_facultets($this->get_facultet_by_name($this->fakultet)); /*Array([tip] => zavkaf[fakultet] => Факультет экономики и управления[kafedra] => Маркетинга, сервиса и туризма)*/ //echo '
'.print_r($facultets,1).''; exit(); foreach ($facultets as $key1 => $schools) { foreach ($schools as $key2 => $school) { foreach ($school['kafedras'] as $key3 => $kafedra) { if ($kafedra['name'] != $this->kafedra) { unset($facultets[$key1][$key2]['kafedras'][$key3]); } } } } $smarty->assign('facultets', $facultets); $otherRPD = $this->get_other_naznach($this->kafedra); $smarty->assign('otherRPD', $otherRPD); } $smarty->assign('fakultet', $this->fakultet); $smarty->assign('kafedra', $this->kafedra); $smarty->assign('tip', $this->tip); } $smarty->assign('des', $des); $out['body'] = $smarty->fetch('page_statpur.html'); //$out['body'] .= '
'.print_r($_SESSION,1).''.'----------------'.$this->fakultet; } return $out; } /** * Получение назначений на РПД для не своей кафедры, зав.кафы могут назначать и другим кафедрам! * @param $kafname * @return array */ function get_other_naznach($kafname){ $sql = 'SELECT up.id,up.index1,up.name, t.kafedra FROM '.$this->TUchebplans.' as up, '.$this->TFile.' as t WHERE up.kaf_name="'.$kafname.'" AND t.kafedra != "'.$kafname.'" AND up.id_file=t.id_file ORDER BY t.shifr,t.god_nach_podgot,t.fo'; $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; exit(); if(!$rez['err']&&$rez['kol']){ foreach($rez['rez'] as $key => $val){ $prepods = $this->get_statUchebPlanDiscipsPrepod($val['id']); if(count($prepods)) { $val['prepods'] = $this->get_statUchebPlanDiscipsPrepod($val['id']); $out[] = $val; } } } //echo $sql.'
'.print_r($out,1).''; exit(); return $out; } function get_facultet_by_name($name){ $out = 0; $sql = 'SELECT id FROM acs_faculties WHERE name="'.$this->fakultet.'"'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ $out = $rez['rez'][0]['id']; } return $out; } function get_facultets($id_fak=0){ $out = array(); if($id_fak==0) { $sql = 'SELECT school.name as school_name, facultie.id as facultie_id, facultie.name as facultie_name FROM acs_schools as school, acs_faculties as facultie WHERE school.id=facultie.id_school ORDER BY school.name,facultie.name'; }else{ $sql = 'SELECT school.name as school_name, facultie.id as facultie_id, facultie.name as facultie_name FROM acs_schools as school, acs_faculties as facultie WHERE school.id=facultie.id_school AND facultie.id='.$id_fak.' ORDER BY school.name,facultie.name'; } $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).'';exit(); if(!$rez['err']&&$rez['kol']){ foreach($rez['rez'] as $key => $val){ $val['kafedras'] = $this->get_kafedras($val['facultie_id']); $out[$val['school_name']][] = $val; } } //echo $sql.'
'.print_r($rez,1).print_r($out,1).'';exit(); return $out; } function get_kafedras($id_fakultet){ $out = array(); $cache = $this->cache_check('kafedras',$id_fakultet); if(count($cache)){ $out = $cache; }else { $sql = 'SELECT id,name,code FROM acs_kafedres WHERE id_facult = ' . $id_fakultet . ' ORDER BY code,name'; $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; if (!$rez['err'] && $rez['kol']) { foreach ($rez['rez'] as $key => $val) { $tmp['id'] = $val['id']; $tmp['name'] = $val['name']; $tmp['code'] = $val['code']; $tmp['up'] = $this->get_statUchebPlan($tmp['name']); $out[] = $tmp; } $this->cache_check('kafedras',$id_fakultet,$out); } } return $out; } function get_statUchebPlan($kafedra){ $out = array(); if($kafedra=='Кафедра госпитальной хирургии и последипломного образования') $kafedra = 'Госпитальной хирургии и последипломного образования'; if($kafedra=='Кафедра госпитальной терапии и последипломного образования') $kafedra = 'Госпитальной терапии и последипломного образования'; $cache = $this->cache_check('statUchebPlan',$kafedra); if(count($cache)){ $out = $cache; }else { $sql = 'SELECT id,data_c,id_file,program,shifr,naprav,profil,kvalif,god_nach_podgot,fo,srok_poluch_obr FROM acs_fshp_file WHERE kafedra = "' . $kafedra . '" AND god_nach_podgot='.$_SESSION['year_cur'].' ORDER BY naprav'; $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).''; //exit(); if (!$rez['err'] && $rez['kol']) { foreach ($rez['rez'] as $key => $val) { $val['discips'] = $this->get_statUchebPlanDiscips($val['id_file']); $out[] = $val; } $this->cache_check('statUchebPlan',$kafedra,$out); } } return $out; } function get_statUchebPlanDiscips($id_file){ $out = array(); $cache = $this->cache_check('statUchebPlanDiscips',$id_file); if(count($cache)){ $out = $cache; }else { $sql = 'SELECT id,index1,name FROM acs_fshp_uchebplans WHERE id_file = ' . $id_file . ' ORDER BY index1'; //echo $sql.'
'.print_r($prepods,1).''; if (count($prepods)) { $val['prepods'] = $prepods;//$this->get_statUchebPlanDiscipsPrepod($val['id']); $out[] = $val; } } $this->cache_check('statUchebPlanDiscips',$id_file,$out); } } //echo 'get_statUchebPlanDiscips:
'.print_r($out,1).''; return $out; } /** * Кэширование SQL запросов * @param $sql1 * @param $key * @return array|mixed|null */ function cache_sess($sql1,$key='StatPUR_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; } function get_statUchebPlanDiscipsPrepod($id_uchebplan){ $out = array(); $cache = $this->cache_check('statUchebPlanDiscipsPrepod',$id_uchebplan); if(count($cache)){ $out = $cache; }else { $sql = 'SELECT u.id,u.fio,fdp.data_c,fdp.descrip,fdp.status FROM acs_fshp_disciplin_prepod as fdp, acs_users as u WHERE fdp.id_uchebplans = ' . $id_uchebplan . ' AND u.id=fdp.id_prepod'; //echo $sql.'