EIOS/rabprog/inc/class_KOMPMODELS_SEM.php

611 lines
30 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
//error_reporting(E_ALL);
class class_KOMPMODELS_SEM{
private $DB=null;
private $TFile='';
private $TUchebplans='';
private $TCompet='';
private $TUchebplans_compet='';
private $TUchebplans_compet_sem='';
private $TCompetModels='';
private $polya=array();
function __construct(){
GLOBAL $DB,$ST;
$this->DB = $DB;
$this->TFile = $ST['dbpf'].'_fshp_file';
$this->TUchebplans = $ST['dbpf'].'_fshp_uchebplans';
$this->TCompet = $ST['dbpf'].'_fshp_compet';
$this->TUchebplans_compet = $ST['dbpf'].'_fshp_uchebplans_compet';
$this->TCompetModels = $ST['dbpf'].'_fshp_competmodels';
$this->TUchebplans_compet_sem = $ST['dbpf'].'_fshp_competmodels_sem';
$this->polya = $this->table_create();
}
/**
* Создание таблицы и возвращение полей таблицы
* @return string[][]
*/
private function table_create(){
$polya = array(
0=>array('name'=>'id','type'=>'int(11)','nul'=>'NOT NULL','dop'=>'AUTO_INCREMENT'),
array('name'=>'id_user','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'id_disc','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'id_compet','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'ofo','type'=>'varchar(255)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'zfo','type'=>'varchar(255)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'ofozfo','type'=>'varchar(255)','nul'=>'NOT NULL','dop'=>''),
array('name'=>'pos','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
);
/*$sql = 'CREATE TABLE IF NOT EXISTS `'.$this->TUchebplans_compet_sem.'` (';
foreach($polya as $k => $v){ $sql .= '`'.$v['name'].'` '.$v['type'].' '.$v['nul'].' '.$v['dop'].',';}
$sql .= 'primary key (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;';
$this->DB->QUR($sql);*/
return $polya;
}
function discip_del_from_comp($id){
$sql = 'SELECT * FROM '.$this->TUchebplans_compet.' WHERE id='.$id.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$upcomp = $rez['rez'][0];
$sql = 'DELETE FROM '.$this->TUchebplans_compet.' WHERE id='.$id.' LIMIT 1';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['err']=0;
$out['msg']='Удалили';
//Удалим назначения семестров!
$sql = 'DELETE FROM '.$this->TUchebplans_compet_sem.' WHERE id_disc='.$upcomp['id_uchebplans'].' AND id_compet='.$upcomp['id_compet'];
$this->DB->QUR($sql);
}else{
$out['err']=1;
$out['msg']='Не удалили';
}
}
return $out;
}
/**
* Основа работы с интерфейсом
* @return string[]|void
* @throws SmartyException
*/
public function HTML(){
GLOBAL $WorkDIR;
$CHPU = new class_CHPU($WorkDIR);
$URLS = $CHPU->uri();
$smartyC = new class_smarty();
$smarty = $smartyC->config(__DIR__.'\..\tpl');
$view = 'all';
$out = array('name'=>'Этапы формирования компенсаций','body'=>'');
//обработка АЯКС запросов
if(isset($_POST['ajdes'])){
header('Content-Type: application/json; charset=utf-8');
$out=array();
//редактирование компетенции
if($_POST['ajdes']=='get_comp_sem'){//получение данных по компетенции
$id_comp = (int)$_POST['id_comp'];
$sql = 'SELECT * FROM '.$this->TCompet.' WHERE id='.$id_comp.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$compet = $rez['rez'][0];
$sql = 'SELECT id_uchebplans FROM '.$this->TUchebplans_compet.' WHERE id_compet='.$id_comp;
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach ($rez['rez'] as $k => $v){
$compet['discips'][] = $v['id_uchebplans'];
}
}else{
$compet['discips'] = array();
}
}
$out['err']=0;
$out['comp'] = $compet;
}
//отображение записи комп.модели
if($_POST['ajdes']=='show_comp_sem'){
$id_comp = (int)$_POST['id_comp'];
$id_file = (int)$_POST['id_file'];
$compets = $this->UCHEBPLAN_comp($id_file,$id_comp);
$compets['id'] = $id_comp;
$smarty->assign('comp',$compets);
$out['html'] = $smarty->fetch('page_komp_models_sem_item.html');
}
//Удаление дисциплины из компетенции
if($_POST['ajdes']=='dele_comp_sem'){
$id = (int)$_POST['ucid'];
$out = $this->discip_del_from_comp($id);
}
//сохранение записи комп.модели
if($_POST['ajdes']=='save_comp_sem'){
/*id_disc id_compet ofo zfo ofozfo*/
$data['id_disc'] = (int)$_POST['id_disc'];
$data['id_compet'] = (int)$_POST['id_compet'];
$data['ofo'] = explode(';',$_POST['ofo']);
$data['ofo'] = array_filter($data['ofo'], function($element) { return !empty($element); });
$data['ofo'] = json_encode($data['ofo']);
$data['zfo'] = explode(';',$_POST['zfo']);
$data['zfo'] = array_filter($data['zfo'], function($element) { return !empty($element); });
$data['zfo'] = json_encode($data['zfo']);
$data['ofozfo'] = explode(';',$_POST['ofozfo']);
$data['ofozfo'] = array_filter($data['ofozfo'], function($element) { return !empty($element); });
$data['ofozfo'] = json_encode($data['ofozfo']);
$data['pos'] = 0;
$out = $this->Update($data);
}echo json_encode($out);
exit();
}
//Создание комп.модели
if(isset($URLS[1])&&$URLS[1]=='edit') {
if(isset($_POST['compsem_des'])){//добавление связки компетенции-дисциплины
$compsem_id_comp = $_POST['compsem_id_comp'];
$compsem_id_file = $_POST['compsem_id_file'];
$compsem_index = $_POST['compsem_index'];
$compsem_descrip = $_POST['compsem_descrip'];
$compsem_disciplins = $_POST['compsem_disciplins'];
if($compsem_id_comp==0) {//добавление
//echo '<pre>'.print_r($_POST,1).'</pre>';
//<pre>Array(
// [compsem_index] = ПКУВ-4.1
// [compsem_descrip] = Нету такой
// [compsem_disciplins] = Array( [0] = 42266 [1] = 42269 [2] = 42271 )
// [compsem_id_file] = 465
// [compsem_des] = Изменить
//)
//</pre>
$sql = 'INSERT INTO ' . $this->TCompet . ' VALUES(0,' . $compsem_id_file . ',"' . $this->DB->rescape($compsem_index) . '","' . $this->DB->rescape($compsem_descrip) . '")';
$rez = $this->DB->QUR($sql);
if (!$rez['err']) {
$id_compet = $this->DB->lastinsertID();
foreach ($compsem_disciplins as $k => $id_uchebplans) {
$sql1 = 'INSERT INTO ' . $this->TUchebplans_compet . ' VALUES(0,' . $id_uchebplans . ',' . $id_compet . ')';
$rez1 = $this->DB->QUR($sql1);
}
}
}else{//редактирование
$sql222 = 'UPDATE '.$this->TCompet.' SET descrip="' . $this->DB->rescape($compsem_descrip) . '",`index`="'.$this->DB->rescape($compsem_index).'" WHERE id='.$compsem_id_comp;
$rez222 = $this->DB->QUR($sql222);
//echo $sql222.'<pre>'.print_r($rez222,1).'</pre>';exit();
$discips_old=array();
//Узнаем назначенные дисциплины
$sql = 'SELECT id_uchebplans FROM '.$this->TUchebplans_compet.' WHERE id_compet='.$compsem_id_comp;
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach ($rez['rez'] as $k => $v){
$discips_old[] = $v['id_uchebplans'];
}
}
//Обойдем Новые дисциплины для добавления
foreach ($compsem_disciplins as $k => $id_uchebplans) {
if(!in_array($id_uchebplans,$discips_old)){//добавлем новую
$sql1 = 'INSERT INTO ' . $this->TUchebplans_compet . ' VALUES(0,' . $id_uchebplans . ',' . $compsem_id_comp . ')';
$rez1 = $this->DB->QUR($sql1);
}
}
//Обойдем Старые дисциплины для удаления
foreach ($discips_old as $k => $id_uchebplans) {
if(!in_array($id_uchebplans,$compsem_disciplins)){//удаляем старую
$sql1 = 'SELECT id FROM '.$this->TUchebplans_compet.' WHERE id_uchebplans='.$id_uchebplans.' AND id_compet='.$compsem_id_comp;
$rez1 = $this->DB->QUR_SEL($sql1);
if(!$rez1['err']&&$rez1['kol']){
$this->discip_del_from_comp($rez1['rez'][0]['id']);
}
}
}
}
}
$id = (int)$URLS[2];
//Надо получить из УП все компетенции
//$SAVES = $this->Item($id);
$UPLAN = $this->UCHEBPLAN($id);
//echo '<pre>'.print_r($UPLAN,1).'</pre>';exit();
//надо убрать из UPLAN компетенции которые уже сохранили!
//foreach ($SAVES as $k => $v){
// foreach($UPLAN['comp'] as $k1 => $v1){
// if($v1['index']==$v['comp_name']) unset($UPLAN['comp'][$k1]);
// }
//}
//$smarty->assign('SAVES', $SAVES);
$smarty->assign('UPLAN', $UPLAN);
$smarty->assign('view', $URLS[1]);
$smarty->assign('ID_PLAN', $id);
$smarty->assign('disciplins', $this->UCHEBPLAN_disciplins($id));
$out['body'] = $smarty->fetch('page_komp_models_sem.html');
}
//Отображение всех УП закрепленных за кафедрой
if(!isset($URLS[1])||$URLS[1]=='all') {
$items = $this->UCHEBPLANS();
$smarty->assign('UCHEBPLANS', $items);
$KAF = array('name'=>$_SESSION['user']['teachers']['kafedra']);
$smarty->assign('kaf',$KAF);
$smarty->assign('view', $view);
$out['body'] = $smarty->fetch('page_komp_models_sem.html');
}
return $out;
}
/**
* Подготовка данных для таблицы
* @param $data
* @return mixed
*/
private function Prepare_data($data){
if(!isset($data['id_disc'])) $data['id_disc']=0; else $data['id_disc']=(int)$data['id_disc'];
if(!isset($data['id_compet'])) $data['id_compet']=0; else $data['id_compet']=(int)$data['id_compet'];
if(!isset($data['ofo'])) $data['ofo']=''; else $data['ofo']=$this->DB->rescape($data['ofo']);
if(!isset($data['zfo'])) $data['zfo']=''; else $data['zfo']=$this->DB->rescape($data['zfo']);
if(!isset($data['ofozfo'])) $data['ofozfo']=''; else $data['ofozfo']=$this->DB->rescape($data['ofozfo']);
if(!isset($data['pos'])) $data['pos']=0; else $data['pos']=(int)$this->DB->rescape($data['pos']);
if($data['pos']=='') $data['pos']=0;
return $data;
}
/**
* Обновление записи
* @param $data
* @return array
*/
private function Update($data){
$data = $this->Prepare_data($data);
$sql = 'SELECT id FROM `'.$this->TUchebplans_compet_sem.'` WHERE id_disc='.$data['id_disc'].' AND id_compet='.$data['id_compet'].' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$data['id'] = $rez['rez'][0]['id'];
$out = $this->Edit($data);
}else{
$out = $this->Save($data);
}
return $out;
}
/**
* Редактирование записи
* @param $data
* @return array
*/
private function Edit($data){
$data = $this->Prepare_data($data);
$sql = 'UPDATE `'.$this->TUchebplans_compet_sem.'` SET id_disc='.$data['id_disc'].',id_compet='.$data['id_compet'].',ofo="'.$data['ofo'].'",zfo="'.$data['zfo'].'",ofozfo="'.$data['ofozfo'].'",pos='.$data['pos'].' WHERE id='.$data['id'].' LIMIT 1';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['err']=0;
$out['msg']='Обновили запись';
$out['id']=$this->DB->lastinsertID();
}else{
$out['err']=1;
$out['msg']='Не обновили запись. Ошибка!';
$out['id']=$data['id'];
}
return $out;
}
/**
* Сохранение записи
* @param $data
* @return array
*/
private function Save($data){
$data = $this->Prepare_data($data);
$sql = 'INSERT INTO `'.$this->TUchebplans_compet_sem.'` VALUES(0,'.$_SESSION['user']['id'].','.$data['id_disc'].','.$data['id_compet'].',"'.$data['ofo'].'","'.$data['zfo'].'","'.$data['ofozfo'].'",'.$data['pos'].');';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['err']=0;
$out['msg']='Добавили запись';
$out['id']=$this->DB->lastinsertID();
}else{
$out['err']=1;
$out['msg']='Не добавили запись. Ошибка!';
$out['id']=0;
}
return $out;
}
/**
* Удаление записи
* @param $data
* @return array
*/
private function Delete($data){
$sql = 'DELETE FROM `'.$this->TUchebplans_compet_sem.'` WHERE id='.$data['id'].' LIMIT 1';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['err']=0;
$out['msg']='Удалили запись';
$out['id']=$data['id'];
}else{
$out['err']=1;
$out['msg']='Не удалили запись. Ошибка!';
$out['id']=0;
}
return $out;
}
/**
* Получение сохраненных компетенций
* @param $id_file
* @return array|mixed
*/
public function Item($id_disc){
$out=array();
$sql = 'SELECT * FROM `'.$this->TUchebplans_compet_sem.'` WHERE id_disc='.$id_disc.' AND id_user='.$_SESSION['user']['id'].' ORDER BY pos ASC';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$out = $rez['rez'];
}
return $out;
}
/**
* Получение сохраненных компетенций без учета пользователя для 71
* @param $id_file
* @return array|mixed
*/
public function ItemNotUser71($id_disc){
$out=array();
$sql = 'SELECT
c.index,c.descrip, c.id_file,cs.id_compet
FROM
'.$this->TUchebplans_compet_sem.' as cs,
'.$this->TCompet.' as c
WHERE
c.id=cs.id_compet AND
cs.id_disc IN ('.implode(',',$id_disc).')
GROUP BY c.index ORDER BY cs.pos ASC';
$rez = $this->DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>';exit();
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $val){
$sql1 = 'SELECT u.name,cs.ofo,cs.zfo,cs.ofozfo FROM '.$this->TUchebplans_compet_sem.' as cs,'.$this->TUchebplans.' as u WHERE u.id=cs.id_disc AND cs.id_compet='.$val['id_compet'];
$rez1 = $this->DB->QUR_SEL($sql1);
//echo $sql1.'<pre>'.print_r($rez1,1).'</pre>';
$out[$val['index']]['disc'] = array();
if(!$rez1['err']&&$rez1['kol']){
foreach($rez1['rez'] as $key1 => $val1){
$val1['ofo'] = array_unique(json_decode(stripslashes($val1['ofo']),1));
$val1['zfo'] = array_unique(json_decode(stripslashes($val1['zfo']),1));
$val1['ofozfo'] = array_unique(json_decode(stripslashes($val1['ofozfo']),1));
$out[$val['index']]['disc'][] = $val1;
}
}
$out[$val['index']]['comp'] = $val;
}
}
//echo $sql.'<pre>'.print_r($out,1).'</pre>';exit();
return $out;
}
/**
* Получение сохраненных компетенций без учета пользователя
* @param $id_file
* @return array|mixed
*/
public function ItemNotUser($id_disc){
$out=array();
$sql = 'SELECT c.index,c.descrip,cs.ofo,cs.zfo,cs.ofozfo,u.name as discip FROM '.$this->TUchebplans_compet_sem.' as cs,'.$this->TCompet.' as c,'.$this->TUchebplans.' as u WHERE c.id=cs.id_compet AND cs.id_disc IN ('.implode(',',$id_disc).') AND cs.id_disc=u.id ORDER BY cs.pos ASC';
$rez = $this->DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>';exit();
//SELECT c.index,c.descrip,cs.ofo,cs.zfo,cs.ofozfo FROM acs_fshp_competmodels_sem as cs,acs_fshp_compet as c WHERE c.id=cs.id_compet AND cs.id_disc IN (263,13) ORDER BY cs.pos ASC
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $val){
$val['ofo'] = json_decode(stripslashes($val['ofo']),1);
$val['zfo'] = json_decode(stripslashes($val['zfo']),1);
$val['ofozfo'] = json_decode(stripslashes($val['ofozfo']),1);
$out[] = $val;
}
}
return $out;
}
/**
* ПОЛУЧЕНИЕ одного УП только кго компетенций
* @param $id
* @return array
*/
public function UCHEBPLAN($id){
$out = array();
$sql = 'SELECT id,shifr,naprav,profil,kvalif,god_nach_podgot,fo FROM '.$this->TFile.' WHERE id_file='.$id.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']) {
$out['up'] = $rez['rez'][0];
}
$sql = 'SELECT id,`index`,descrip FROM '.$this->TCompet.' WHERE id_file='.$id.' ORDER BY `index`';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $comp) {
$tmp=array();
$tmp['id'] = $comp['id'];
$tmp['index'] = $comp['index'];
$tmp['id_file'] = $id;
$tmp['discs']=array();
//$tmp22 = $this->UCHEBPLAN_comp($id,$comp['id']);
//$tmp['discs'] = $tmp22['discs'];
$a=0; if($a==1) {//------------
$sql1 = 'SELECT u.id,u.name,u.json,f.fo,f.program,f.shifr FROM ' . $this->TUchebplans_compet . ' as uc, ' . $this->TUchebplans . ' as u, ' . $this->TFile . ' as f WHERE uc.id_uchebplans=u.id AND u.id_file=' . $id . ' AND uc.id_compet=' . $comp['id'] . ' AND f.id_file = u.id_file';
$rez1 = $this->DB->QUR_SEL($sql1);
echo $sql1 . '<pre>' . print_r($rez1, 1) . '</pre>';
if ($rez1['kol'] != 0) exit();
if (!$rez1['err'] && $rez1['kol']) {
foreach ($rez1['rez'] as $key1 => $val1) {
$j = json_decode($val1['json'], 1);
$sems = array();
foreach ($j as $k1 => $v1) {
foreach ($v1 as $k2 => $v2) {
if ($val1['fo'] == 'Очная') $sems[] = $k2;
if ($val1['fo'] == 'Заочная') $sems1[] = $k2;
if ($val1['fo'] == 'Очно-заочная') $sems2[] = $k2;
}
}
//надо найти ЗФО И ОФОЗФО
$sql2 = 'SELECT u.json,f.fo FROM ' . $this->TUchebplans . ' as u,' . $this->TFile . ' as f WHERE f.shifr="' . $val1['shifr'] . '" AND f.program="' . $val1['program'] . '" AND u.id_file=f.id_file AND f.fo!="' . $val1['fo'] . '" AND u.name="' . $val1['name'] . '"';
$rez2 = $this->DB->QUR_SEL($sql2);
//echo $sql2.'<pre>'.print_r($rez2,1).'</pre>';
if (!$rez2['err'] && $rez2['kol']) {
foreach ($rez2['rez'] as $key2 => $val2) {
$j = json_decode($val2['json'], 1);
$sems1 = $sems2 = array();
foreach ($j as $k1 => $v1) {
foreach ($v1 as $k2 => $v2) {
if ($val2['fo'] == 'Очная') $sems[] = $k2;
if ($val2['fo'] == 'Заочная') $sems1[] = $k2;
if ($val2['fo'] == 'Очно-заочная') $sems2[] = $k2;
}
}
}
}
$tmp['discs'][] = array(
'id' => $val1['id'],
'name' => $val1['name'],
'sems' => $sems,
'sems1' => $sems1,
'sems2' => $sems2,
'save' => $this->get_item_save($val1['id'], $comp['id'])
);
}
}
}//---------вынесли в отдельную функцию!
if(!isset($out['comp'][$comp['index']])) {
$t = explode('-', $comp['index']);
$t1 = explode('.', $t[1]);
$tmp['kod'] = $t[0] . '-' . $t1[0];
$tmp['descrip'] = $comp['descrip'];
$out['comp'][$comp['index']] = $tmp;
}
}
}
//echo '<pre>'.print_r($out,1).'</pre>'; exit();
return $out;
}
public function UCHEBPLAN_disciplins($id_file){
$out = array();
$sql1 = 'SELECT id,index1,name FROM '.$this->TUchebplans.' WHERE id_file='.$id_file.' ORDER BY index1,name';
$rez1 = $this->DB->QUR_SEL($sql1);
//echo '<pre>'.print_r($rez1,1).'</pre>'; exit();
if(!$rez1['err']&&$rez1['kol']) {
//foreach ($rez1['rez'] as $key1 => $val1) {}
$out = $rez1['rez'];
}
return $out;
}
/**
* ПОЛУЧЕНИЕ одного УП только одной компетенции
* @param $id
* @return array
*/
public function UCHEBPLAN_comp($id_file,$id_comp){
$out = array();
$sql1 = 'SELECT u.id,u.name,u.json,f.fo,f.program,f.shifr,uc.id as ucid FROM '.$this->TUchebplans_compet.' as uc, '.$this->TUchebplans.' as u, '.$this->TFile.' as f WHERE uc.id_uchebplans=u.id AND u.id_file='.$id_file.' AND uc.id_compet='.$id_comp.' AND f.id_file = u.id_file';
$rez1 = $this->DB->QUR_SEL($sql1);
//echo $sql1.'<pre>'.print_r($rez1,1).'</pre>'; if($rez1['kol']!=0) exit();
if(!$rez1['err']&&$rez1['kol']) {
foreach ($rez1['rez'] as $key1 => $val1) {
$j=json_decode($val1['json'],1); $sems=array();
foreach($j as $k1 => $v1){
foreach($v1 as $k2 => $v2) {
if($val1['fo']=='Очная') $sems[]=$k2;
if($val1['fo']=='Заочная') $sems1[]=$k2;
if($val1['fo']=='Очно-заочная') $sems2[]=$k2;
}
}
//надо найти ЗФО И ОФОЗФО
$sql2 = 'SELECT u.json,f.fo FROM '.$this->TUchebplans.' as u,'.$this->TFile.' as f WHERE f.shifr="'.$val1['shifr'].'" AND f.program="'.$val1['program'].'" AND u.id_file=f.id_file AND f.fo!="'.$val1['fo'].'" AND u.name="'.$val1['name'].'"';
$rez2 = $this->DB->QUR_SEL($sql2);
//echo $sql2.'<pre>'.print_r($rez2,1).'</pre>';
if(!$rez2['err']&&$rez2['kol']) {
foreach ($rez2['rez'] as $key2 => $val2) {
$j=json_decode($val2['json'],1); $sems1=$sems2=array();
foreach($j as $k1 => $v1){
foreach($v1 as $k2 => $v2) {
if($val2['fo']=='Очная') $sems[]=$k2;
if($val2['fo']=='Заочная') $sems1[]=$k2;
if($val2['fo']=='Очно-заочная') $sems2[]=$k2;
}
}
}
}
$out['discs'][]= array(
'id'=>$val1['id'],
'ucid'=>$val1['ucid'],
'name'=>$val1['name'],
'sems'=>$sems,
'sems1'=>$sems1,
'sems2'=>$sems2,
'save'=>$this->get_item_save($val1['id'],$id_comp)
);
}
}
//echo '<pre>'.print_r($out,1).'</pre>';exit();
return $out;
}
function get_item_save($id_disc,$id_compet){
$out = array();
$sql1 = 'SELECT id,ofo,zfo,ofozfo FROM '.$this->TUchebplans_compet_sem.' WHERE id_disc='.$id_disc.' AND id_compet='.$id_compet;
$rez1 = $this->DB->QUR_SEL($sql1);
if(!$rez1['err']&&$rez1['kol']) {
$save = $rez1['rez'][0];
$out['id'] = $save['id'];
$out['ofo'] = json_decode(stripslashes($save['ofo']),1);
$out['zfo'] = json_decode(stripslashes($save['zfo']),1);
$out['ofozfo'] = json_decode(stripslashes($save['ofozfo']),1);
}
return $out;
}
/**
* ПОЛУЧЕНИЕ одного УП с дисциплинами и их компетенциями
* @param $id
* @return array
*/
public function UCHEBPLAN_discips($id){
$out = array();
$sql = 'SELECT id,shifr,naprav,profil,kvalif,god_nach_podgot,fo FROM '.$this->TFile.' WHERE id='.$id.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$up = $rez['rez'][0];
$sql1 = 'SELECT id,index1,name,ekzamen,zachet,zachetsocenk,kr,kp,kontrol FROM '.$this->TUchebplans.' WHERE id_file='.$id.' ORDER BY index1,name';
$rez1 = $this->DB->QUR_SEL($sql1);
if(!$rez1['err']&&$rez1['kol']){
foreach($rez1['rez'] as $key1 => $discip) {
$discip['sems']=array();
if($discip['ekzamen']!=0) $discip['sems'][]=$discip['ekzamen'];
if($discip['zachet']!=0) $discip['sems'][]=$discip['zachet'];
if($discip['zachetsocenk']!=0) $discip['sems'][]=$discip['zachetsocenk'];
if($discip['kr']!=0) $discip['sems'][]=$discip['kr'];
if($discip['kp']!=0) $discip['sems'][]=$discip['kp'];
if($discip['kontrol']!=0) $discip['sems'][]=$discip['kontrol'];
$discip['sems'] = array_unique($discip['sems']);
$discip['comp'] = array();
$sql2 = 'SELECT c.index,c.descrip FROM '.$this->TUchebplans_compet.' as ut,'.$this->TCompet.' as c WHERE ut.id_uchebplans='.$discip['id'].' AND ut.id_compet=c.id ORDER BY c.index';
$rez2 = $this->DB->QUR_SEL($sql2);
if(!$rez2['err']&&$rez2['kol']){
foreach($rez2['rez'] as $key2 => $val2) {
$discip['comp'][$val2['index']] = $val2['descrip'];
}
}
$discips[] = $discip;
}
}
$out=array('up'=>$up,'discips'=>$discips);
}
return $out;
}
/**
* ПОЛУЧЕНИЕ всех УП для кафедры
* @param $id_kaf
* @return array
*/
public function UCHEBPLANS(){
$out = array();
$kafname = $_SESSION['user']['teachers']['kafedra'];
if($kafname=='Кафедра госпитальной терапии и последипломного образования') $kafname='Госпитальной терапии и последипломного образования';
if($kafname=='Кафедра госпитальной хирургии и последипломного образования') $kafname='Госпитальной хирургии и последипломного образования';
$cYear = 'AND god_nach_podgot='.$_SESSION['year_cur'];
$sql = 'SELECT * FROM '.$this->TFile.' WHERE kafedra="'.$kafname.'" '.$cYear.' ORDER BY shifr,profil,naprav,god_nach_podgot,fo';
$rez = $this->DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>';
if(!$rez['err']&&$rez['kol']){
$out = $rez['rez'];
}
return $out;
}
}