EIOS/rabprog/inc/class_Prepods.php

57 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2023-12-28 15:39:22 +03:00
<?php
class class_Prepods{
private $DB;
function __construct(){
GLOBAL $DB;
$this->DB = $DB;
}
public function HTML(){
$smartyC = new class_smarty();
$smarty = $smartyC->config(__DIR__.'\..\tpl');
//echo __DIR__.'\tpl';
$out = array('name'=>'Струткура МГТУ','body'=>'');
$smarty->assign('structure',$this->structure_get());
$out['body'] = $smarty->fetch('page_prepods.html');
return $out;
}
function structure_get(){
$out = array();
$sql = 'SELECT
school.name as school_name,
facultie.name as facultie_name,
kafedre.name as kafedre_name,
kafedre.code as kafedre_code
FROM
acs_schools as school,
acs_faculties as facultie,
acs_kafedres as kafedre
WHERE
school.id=facultie.id_school AND
facultie.id = kafedre.id_facult
ORDER BY school.name,facultie.name,kafedre.name';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $val){
$tmp['kafedra'] = $val['kafedre_name'];
$tmp['code'] = $val['kafedre_code'];
$tmp['prepods'] = $this->prepods_get($val['facultie_name'],$val['kafedre_name']);
$out[$val['school_name']][$val['facultie_name']][] = $tmp;
}
}
return $out;
}
function prepods_get($fakultet,$kafedra){
$out = array();
//$sql = 'SELECT id,data_c,data_u,id_user,zvanie,dolgnost,stepen FROM acs_teachers WHERE fakultet="'.$fakultet.'" AND kafedra="'.$kafedra.'"';
$sql = 'SELECT t.id,t.id_user,t.zvanie,t.dolgnost,t.stepen,u.data_c,u.data_u,u.fio FROM acs_teachers as t, acs_users as u WHERE t.fakultet="'.$fakultet.'" AND t.kafedra="'.$kafedra.'" AND t.id_user=u.id ORDER BY u.fio';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$out = $rez['rez'];
}
return $out;
}
}