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->TCompetModels = $ST['dbpf'].'_fshp_competmodels';
$this->TUchebplans_compet_sem = $ST['dbpf'].'_fshp_competmodels_sem';
$this->Tteachers = $ST['dbpf'].'_teachers';
$this->Tusers = $ST['dbpf'].'_users';
$this->Trpdsave = $ST['dbpf'].'_fshp_rpd_save';
$this->TrpdsaveName = $ST['dbpf'].'_fshp_rpd_save_name';
/*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';
}
/**
* Подгатавливаем сохраненные данные
* @param $SAVE
* @return array|mixed
*/
public function SAVE_prepare($SAVE){
if(!$SAVE['err']){
if($SAVE['all']['razdel5']!='') $SAVE['all']['razdel5'] = json_decode($SAVE['all']['razdel5'],1);
else $SAVE['all']['razdel5'] = array();
if($SAVE['all']['razdel5_4']!='') $SAVE['all']['razdel5_4'] = json_decode($SAVE['all']['razdel5_4'],1);
else $SAVE['all']['razdel5_4'] = array();
if($SAVE['all']['razdel5_5']!='') $SAVE['all']['razdel5_5'] = json_decode($SAVE['all']['razdel5_5'],1);
else $SAVE['all']['razdel5_5'] = array();
if($SAVE['all']['razdel5_6']!='') $SAVE['all']['razdel5_6'] = json_decode($SAVE['all']['razdel5_6'],1);
else $SAVE['all']['razdel5_6'] = array();
if($SAVE['all']['razdel5_8']!='') $SAVE['all']['razdel5_8'] = json_decode($SAVE['all']['razdel5_8'],1);
else $SAVE['all']['razdel5_8'] = array();
if($SAVE['all']['razdel5_9']!='') $SAVE['all']['razdel5_9'] = json_decode($SAVE['all']['razdel5_9'],1);
else $SAVE['all']['razdel5_9'] = array();
if($SAVE['all']['razdel6_1']!='') {
$tmp = json_decode($SAVE['all']['razdel6_1'],1);
if($tmp) $SAVE['all']['razdel6_1'] = $tmp;
}else $SAVE['all']['razdel6_1'] = array();
if($SAVE['all']['razdel6_2']!='') $SAVE['all']['razdel6_2'] = json_decode($SAVE['all']['razdel6_2'],1);
else $SAVE['all']['razdel6_2'] = array();
if($SAVE['all']['razdel7_2']!='') $SAVE['all']['razdel7_2'] = json_decode($SAVE['all']['razdel7_2'],1);
else $SAVE['all']['razdel7_2'] = array();
if($SAVE['all']['razdel8_1']!='') $SAVE['all']['razdel8_1'] = json_decode($SAVE['all']['razdel8_1'],1);
else $SAVE['all']['razdel8_1'] = array();
if($SAVE['all']['razdel8_2']!='') $SAVE['all']['razdel8_2'] = json_decode($SAVE['all']['razdel8_2'],1);
else $SAVE['all']['razdel8_2'] = array();
if($SAVE['all']['razdel10_1']!='') $SAVE['all']['razdel10_1'] = json_decode($SAVE['all']['razdel10_1'],1);
else $SAVE['all']['razdel10_1'] = array();
if($SAVE['all']['razdel10_2']!='') $SAVE['all']['razdel10_2'] = json_decode($SAVE['all']['razdel10_2'],1);
else $SAVE['all']['razdel10_2'] = array();
if($SAVE['all']['razdel11']!='') $SAVE['all']['razdel11'] = json_decode($SAVE['all']['razdel11'],1);
else $SAVE['all']['razdel11'] = array();
if($SAVE['all']['razdel5_5_1']!='') $SAVE['all']['razdel5_5_1'] = json_decode($SAVE['all']['razdel5_5_1'],1);
else $SAVE['all']['razdel5_5_1'] = array();
$saveREZ = $SAVE['all'];
}else{
$saveREZ = array();
}
return $saveREZ;
}
public function DISCIP_get_Main($DISCIPS){
//TODO тут возможна проблема, если при создании РПД
//не будет очной, все привяжется к заочной
// потом добавят очную и функция будет возвращать очное
$out=array();
if(isset($DISCIPS['Очная'])) {
$out['id'] = $DISCIPS['Очная']['uchebplan']['id'];
$out['DISCIP_name'] = $DISCIPS['Очная']['uchebplan']['name'];
$out['id_file'] = $DISCIPS['Очная']['uchebplan']['id_file'];
$out['shifr'] = $DISCIPS['Очная']['title']['shifr'];
$out['namOP'] = $DISCIPS['Очная']['title']['naprav'];
$out['main'] = 'Очная';
}
else if(isset($DISCIPS['Заочная'])) {
$out['id'] = $DISCIPS['Заочная']['uchebplan']['id'];
$out['DISCIP_name'] = $DISCIPS['Заочная']['uchebplan']['name'];
$out['id_file'] = $DISCIPS['Заочная']['uchebplan']['id_file'];
$out['shifr'] = $DISCIPS['Заочная']['title']['shifr'];
$out['namOP'] = $DISCIPS['Заочная']['title']['naprav'];
$out['main'] = 'Заочная';
}
else if(isset($DISCIPS['Очно-заочная'])) {
$out['id'] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
$out['DISCIP_name'] = $DISCIPS['Очно-заочная']['uchebplan']['name'];
$out['id_file'] = $DISCIPS['Очно-заочная']['uchebplan']['id_file'];
$out['shifr'] = $DISCIPS['Очно-заочная']['title']['shifr'];
$out['namOP'] = $DISCIPS['Очно-заочная']['title']['naprav'];
$out['main'] = 'Очно-заочная';
}
//echo '
'.print_r($out,1).'
'; exit();
return $out;
}
public function RPD_SaveHash($id_save,$hash){
/*$this->DB->QUR('CREATE TABLE IF NOT EXISTS `'.$this->Trpdhash.'` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data_c` int(11) NOT NULL,
`id_save` int(11) NOT NULL,
`hash` varchar(255) NOT NULL,
primary key (id)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');*/
$sql = 'SELECT id FROM '.$this->Trpdhash.' WHERE id_save='.$id_save;
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$sql = 'UPDATE '.$this->Trpdhash.' SET hash="'.$hash.'" WHERE id_save='.$id_save;
$rez = $this->DB->QUR($sql);
}else{
$sql = 'INSERT INTO '.$this->Trpdhash.' VALUES (0,'.time().','.$id_save.',"'.$hash.'")';
$rez = $this->DB->QUR($sql);
}
}
public function RPD_GetHash($hash){
GLOBAL $WorkDIR;
$CHPU = new class_CHPU($WorkDIR);
$URLS = $CHPU->uri();
$smartyC = new class_smarty();
$smarty = $smartyC->config(__DIR__.'\..\tpl');
$sql = 'SELECT id_save FROM '.$this->Trpdhash.' WHERE hash="'.$hash.'"';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id_save = $rez['rez'][0]['id_save'];
$sql = 'SELECT id_discip FROM '.$this->Trpdsave.' WHERE id="'.$id_save.'"';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id_discip = $rez['rez'][0]['id_discip'];
$DISCIPS = $this->Disciplin_Get_Grupp($id_discip);
//echo $id_save.''.print_r($DISCIPS,1).'
'; exit();
$DISCIP = $this->DISCIP_get_Main($DISCIPS);
if(isset($URLS[2])&&$URLS[2]=='show') {//ОТОБРАЖАЕМ PDF
$SAVE = $this->RPD_check_row($id_discip,$_SESSION['user']['id']);
$saveREZ = $this->SAVE_prepare($SAVE);
$cFPDF = new class_TCPDF();
$cFPDF->PDF_rpd($DISCIPS,$DISCIP,$saveREZ);
}else {//ОТОБРАЖАЕМ ОТЧЕТ
$class_RPDSign = new class_RPDSign();
$signs = $class_RPDSign->RPDSigns($id_discip,1);
if(count($signs)) {
$signs = array_reverse($signs);
$smarty->assign('signs', $signs);
}
else $smarty->assign('signs', array());
$smarty->assign('DISCIPS', $DISCIPS);
$smarty->assign('DISCIP', $DISCIP);
$smarty->display('page_rpd_QR.html');
}
}
}else{
echo 'НЕТ ТАКОЙ РАБОЧЕЙ ПРОГРАММЫ ДИСЦИПЛИНЫ!';
}
exit();
}
/**
* Получение ПДФ РПД по сохраненному ИД
* @param $id_save
* @param $id_disc_sign
* @param $view
* @return array
* @throws SmartyException
*/
public function RPD_GetPDF_by_SaveID($id_save,$id_disc_sign=0,$view=1){
GLOBAL $smarty;
$id_disc = 0;
$sql = 'SELECT id_discip FROM '.$this->Trpdsave.' WHERE id='.$id_save;
$rez = $this->DB->QUR_SEL($sql);
//echo $sql.''.print_r($rez,1).'
';
if(!$rez['err']&&$rez['kol']){
$id_disc = $rez['rez'][0]['id_discip'];
}
$DISCIPS = $this->Disciplin_Get_Grupp($id_disc);
$DISCIP = $this->DISCIP_get_Main($DISCIPS);
$id_file = $DISCIP['id_file'];
$id_discs = array();
if(isset($DISCIPS['Очная'])) $id_discs[] = $DISCIPS['Очная']['uchebplan']['id'];
if(isset($DISCIPS['Заочная'])) $id_discs[] = $DISCIPS['Заочная']['uchebplan']['id'];
if(isset($DISCIPS['Очно-заочная'])) $id_discs[] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
$DISCIPS['razdel71'] = $this->CompetGet_71($id_discs);
$DISCIPS['razdel7'] = $this->CompetGet($id_file,$id_discs[0]);
if(!count($DISCIPS['razdel7'])){//добавил 14092023
$DISCIPS['razdel7'] = $this->CompetGet_ELSE($id_file,$id_discs,$DISCIPS);
}
$id_disc_sign=$id_disc;
//тут надо понять view_pdf когда ставить 0 или 1
$SAVE = $this->RPD_check_row($id_disc,$_SESSION['user']['id'],$id_save);
$saveREZ = $this->SAVE_prepare($SAVE);
$smarty->assign('save', $saveREZ);
//unset($saveREZ['razdel7_3']);
//echo htmlspecialchars($saveREZ['razdel7_3']);
//echo '$DISCIPS:'.print_r($DISCIPS,1).'; $DISCIP:'.print_r($DISCIP,1).'; $saveREZ:'.print_r($saveREZ,1).'
'; exit();
$cFPDF = new class_TCPDF();
$out = $cFPDF->PDF_rpd($DISCIPS,$DISCIP,$saveREZ,$view,$id_disc_sign);
if(isset($out['hash'])){
$this->RPD_SaveHash($saveREZ['id'],$out['hash']);
}//signs
if($view==1) {//отображаем иначе отдаем имя файла
$out['body'] = $smarty->fetch('page_rpd_pdf.html');
}
return $out;
}
/**
* Получение ПДФ по ид рпд
* @param $id_disc
* @param $id_disc_sign
* @param $view
* @return array
* @throws SmartyException
*/
public function RPD_GetPDF($id_disc,$id_disc_sign=0,$view=1){
GLOBAL $smarty;
$DISCIPS = $this->Disciplin_Get_Grupp($id_disc);
$DISCIP = $this->DISCIP_get_Main($DISCIPS);
$id_file = $DISCIP['id_file'];
$id_discs = array();
if(isset($DISCIPS['Очная'])) $id_discs[] = $DISCIPS['Очная']['uchebplan']['id'];
if(isset($DISCIPS['Заочная'])) $id_discs[] = $DISCIPS['Заочная']['uchebplan']['id'];
if(isset($DISCIPS['Очно-заочная'])) $id_discs[] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
$DISCIPS['razdel71'] = $this->CompetGet_71($id_discs);
$DISCIPS['razdel7'] = $this->CompetGet($id_file,$id_discs[0]);
if(!count($DISCIPS['razdel7'])){//добавил 14092023
$DISCIPS['razdel7'] = $this->CompetGet_ELSE($id_file,$id_discs,$DISCIPS);
}
if($id_disc_sign!=0) $id_disc=$id_disc_sign;
$id_save=0; if(isset($_SESSION['user']['statuses'][79])){
$id_save=0;
$sql = 'SELECT id FROM '.$this->Trpdsave.' WHERE id_discip='.$id_disc.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id_save=$rez['rez'][0]['id'];
}
}
//тут надо понять view_pdf когда ставить 0 или 1
if(!isset($_SESSION['user']['id'])) $SAVE = $this->RPD_check_row($id_disc,565,$id_save);
else $SAVE = $this->RPD_check_row($id_disc,$_SESSION['user']['id'],$id_save);
//echo '$SAVE'.print_r($SAVE,1).'
';
$saveREZ = $this->SAVE_prepare($SAVE);
//echo '$saveREZ'.print_r($saveREZ,1).'
';
$smarty->assign('save', $saveREZ);
//unset($saveREZ['razdel7_3']);
//echo htmlspecialchars($saveREZ['razdel7_3']);
//echo '$DISCIPS:'.print_r($DISCIPS,1).'; $DISCIP:'.print_r($DISCIP,1).'; $saveREZ:'.print_r($saveREZ,1).'
'; exit();
$cFPDF = new class_TCPDF();
$out = $cFPDF->PDF_rpd($DISCIPS,$DISCIP,$saveREZ,$view,$id_disc_sign);
if(isset($out['hash'])){
$this->RPD_SaveHash($saveREZ['id'],$out['hash']);
}
if($view==1) {//отображаем иначе отдаем имя файла
if($this->isRPD_praktik($DISCIP)){
$out['body'] = $smarty->fetch('page_rpd_praktik_pdf.html');
}else {
$out['body'] = $smarty->fetch('page_rpd_pdf.html');
}
}
return $out;
}
/**
* Получение ПДФ аннотации по ид рпд
* @param $id_disc
* @param $id_disc_sign
* @param $view
* @return array
* @throws SmartyException
*/
public function RPD_GetAnnotacPDF($id_disc,$id_disc_sign=0,$view=1){
GLOBAL $smarty;
$DISCIPS = $this->Disciplin_Get_Grupp($id_disc);
$DISCIP = $this->DISCIP_get_Main($DISCIPS);
$id_file = $DISCIP['id_file'];
$id_discs = array();
if(isset($DISCIPS['Очная'])) $id_discs[] = $DISCIPS['Очная']['uchebplan']['id'];
if(isset($DISCIPS['Заочная'])) $id_discs[] = $DISCIPS['Заочная']['uchebplan']['id'];
if(isset($DISCIPS['Очно-заочная'])) $id_discs[] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
$DISCIPS['razdel71'] = $this->CompetGet_71($id_discs);
$DISCIPS['razdel7'] = $this->CompetGet($id_file,$id_discs[0]);
if(!count($DISCIPS['razdel7'])){//добавил 14092023
$DISCIPS['razdel7'] = $this->CompetGet_ELSE($id_file,$id_discs,$DISCIPS);
}
if($id_disc_sign!=0) $id_disc=$id_disc_sign;
//echo $sql.''.print_r($_SESSION['user'],1).'
'; exit();
$id_save=0; if(isset($_SESSION['user']['statuses'][79])||isset($_SESSION['user']['statuses'][23])||isset($_SESSION['user']['statuses'][30])){
$id_save=0;
$sql = 'SELECT id FROM '.$this->Trpdsave.' WHERE id_discip='.$id_disc.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id_save=$rez['rez'][0]['id'];
}
}
//тут надо понять view_pdf когда ставить 0 или 1
if(!isset($_SESSION['user']['id'])) $SAVE = $this->RPD_check_row($id_disc,565,$id_save);
else $SAVE = $this->RPD_check_row($id_disc,$_SESSION['user']['id'],$id_save);
$saveREZ = $this->SAVE_prepare($SAVE);
//echo $sql.''.print_r($saveREZ,1).'
'; exit();
$smarty->assign('save', $saveREZ);
$id_disc_sign = $saveREZ['id_discip'];
$cFPDF = new class_TCPDF();
$out = $cFPDF->PDF_annotac($DISCIPS,$DISCIP,$saveREZ,$view,$id_disc_sign);
if(isset($out['hash'])){
$this->RPD_SaveHash($saveREZ['id'],$out['hash']);
}
if($view==1) {//отображаем иначе отдаем имя файла
if($this->isRPD_praktik($DISCIP)){
//$out['body'] = $smarty->fetch('page_rpd_praktik_pdf.html');
$out['body'] = $smarty->fetch('page_rpd_annotac_pdf.html');
}else {
$out['body'] = $smarty->fetch('page_rpd_annotac_pdf.html');
}
}
return $out;
}
/**
* Получение ПДФ ФОС по ид рпд
* @param $id_disc
* @param $id_disc_sign
* @param $view
* @return array
* @throws SmartyException
*/
public function RPD_GetFOSPDF($id_disc,$id_disc_sign=0,$view=1){
GLOBAL $smarty;
$DISCIPS = $this->Disciplin_Get_Grupp($id_disc);
$DISCIP = $this->DISCIP_get_Main($DISCIPS);
$id_file = $DISCIP['id_file'];
$id_discs = array();
if(isset($DISCIPS['Очная'])) $id_discs[] = $DISCIPS['Очная']['uchebplan']['id'];
if(isset($DISCIPS['Заочная'])) $id_discs[] = $DISCIPS['Заочная']['uchebplan']['id'];
if(isset($DISCIPS['Очно-заочная'])) $id_discs[] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
$DISCIPS['razdel71'] = $this->CompetGet_71($id_discs);
$DISCIPS['razdel7'] = $this->CompetGet($id_file,$id_discs[0]);
if(!count($DISCIPS['razdel7'])){//добавил 14092023
$DISCIPS['razdel7'] = $this->CompetGet_ELSE($id_file,$id_discs,$DISCIPS);
}
if($id_disc_sign!=0) $id_disc=$id_disc_sign;
$id_save=0; if(isset($_SESSION['user']['statuses'][79])){
$id_save=0;
$sql = 'SELECT id FROM '.$this->Trpdsave.' WHERE id_discip='.$id_disc.' LIMIT 1';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id_save=$rez['rez'][0]['id'];
}
}
//тут надо понять view_pdf когда ставить 0 или 1
if(!isset($_SESSION['user']['id'])) $SAVE = $this->RPD_check_row($id_disc,565,$id_save);
else $SAVE = $this->RPD_check_row($id_disc,$_SESSION['user']['id'],$id_save);
if($SAVE['err']==1) $SAVE = $this->RPD_check_row($id_disc,-1,$id_save);
//echo $sql.''.print_r($SAVE,1).'
'; exit();
$saveREZ = $this->SAVE_prepare($SAVE);
//echo $sql.''.print_r($saveREZ,1).'
'; exit();
$smarty->assign('save', $saveREZ);
$id_disc_sign = $saveREZ['id_discip'];
$cFPDF = new class_TCPDF();
$out = $cFPDF->PDF_fos($DISCIPS,$DISCIP,$saveREZ,$view,$id_disc_sign);
if(isset($out['hash'])){
$this->RPD_SaveHash($saveREZ['id'],$out['hash']);
}
if($view==1) {//отображаем иначе отдаем имя файла
if($this->isRPD_praktik($DISCIP)){
//$out['body'] = $smarty->fetch('page_rpd_praktik_pdf.html');
$out['body'] = $smarty->fetch('page_rpd_fos_pdf.html');
}else {
$out['body'] = $smarty->fetch('page_rpd_fos_pdf.html');
}
}
return $out;
}
public function HTML(){
GLOBAL $WorkDIR;
//if($_SESSION['user']['id']!=7335) die('Идут работы...');
$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']=='setdiscipurpdbezdisc'){
$saveiddiscip=(int)$_POST['saveiddiscip'];
$new_discip=(int)$_POST['new_discip'];
$out['err']=0;
$out['msg']='Установка дисциплины!
';
$sql = 'UPDATE '.$this->Trpdsave.' SET id_discip='.$new_discip.' WHERE id='.$saveiddiscip.' AND id_prepod='.$_SESSION['user']['id'].' LIMIT 1';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['msg'].='Установили дисциплину';
}else{
$out['err']=1;
$out['msg'].='Не установили дисциплину'.print_r($rez,1);
}
}
//Дублирование РПД
if($_POST['ajdes']=='dublicate'){
$saveiddiscip=(int)$_POST['saveiddiscip'];
$new_discip=(int)$_POST['new_discip'];
$out = $this->copy_rpd($saveiddiscip,$new_discip);
//$out['err']=0;
//$out['msg']='Дублирование РПД на другую дисциплину!
';
//$out['msg'].='РПД №'.$saveiddiscip.'; Новая дисциплина №'.$new_discip.'
';
//if($new_discip!=0){
// $sql = 'SELECT * FROM '.$this->Trpdsave.' WHERE id='.$saveiddiscip.' LIMIT 1';
// $rez = $this->DB->QUR_SEL($sql);
// if(!$rez['err']&&$rez['kol']){
// $rpd = $rez['rez'][0];
// $out['msg'].='Нашли РПД
';
// $sql = 'SELECT * FROM '.$this->Trpdsave.' WHERE id_discip='.$new_discip.' LIMIT 1';
// $rez = $this->DB->QUR_SEL($sql);
// if(!$rez['err']&&$rez['kol']){
// $out['err']=1;
// $out['msg'].='У новой дисциплины уже есть сохранения РПД!';
// }else{
// /* id data_c id_discip id_prepod
// razdel1 razdel2 razdel3 razdel4 razdel5 razdel5_4 razdel5_5
// razdel5_6 razdel5_7 razdel5_8 razdel5_9 razdel6_1 razdel6_2
// razdel7 razdel7_2 razdel7_3 razdel7_4 razdel8_1 razdel8_2
// razdel8_3 razdel9 razdel10_1 razdel10_2 razdel11
// * */
// $rpd['data_c']=time();
// $rpd['id_discip']=$new_discip;
// //$rpd['razdel5']='';
// //$rpd['razdel5_4']='';
// //$rpd['razdel5_5']='';
// //$rpd['razdel5_6']='';
// $rezs = $this->RPD_save($rpd);
// $out['err'] = $rezs['err'];
// if (!$rezs['err']) $out['msg'].=$rezs['msg'];
// else $out['msg'].=$rezs['msg'];
// }
// }else{
// $out['err']=1;
// $out['msg'].='Не нашли РПД';
// }
//}else{
// $out['err']=1;
// $out['msg'].='пустой номер';
//}
}
//Подпись РПД и отправка на проверку
if($_POST['ajdes']=='RPDSign'){
$out['err']=0;
$out['msg']='---';
/*acs_fshp_rpd_signs: id data_c id_user id_rpd sign descrip */
$id_rpd = (int)$_POST['id_disc'];
$sql = 'INSERT INTO '.$this->Trpdsign.' VALUES (0,'.time().','.$_SESSION['user']['id'].','.$id_rpd.',"Разработчик","Подписал.",1)';
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$out['err']=0;
$out['msg']='Рабочую программу отправили на проверку';
}else{
$out['err']=1;
$out['msg']='Ошибка при сохранении!';
}
}
//Загрузка фото в редакторы
if($_POST['ajdes']=='uploadFileEditor'){
if ($_FILES['file']['name']) {
if (!$_FILES['file']['error']) {
$name = md5(mt_rand(0, 999999));
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$filename = $name.'.'.$ext;
$destination = 'upload/images/'.$_SESSION['user']['id'];
if (!file_exists($destination)) mkdir($destination, 0777, true);
move_uploaded_file($_FILES["file"]["tmp_name"], $destination.'/'.$filename);
$out['err']=0;
$out['url'] = 'https://eios.mkgtu.ru/rabprog/'.$destination.'/'.$filename;
} else {
$out['err']=1;
$out['url'] = '';
//echo $message = 'Ooops! Your upload triggered the following error: '.$_FILES['file']['error'];
}
}
}
//Отключение разделов
if($_POST['ajdes']=='RPD_RazdelNot'){
$ID_DISCIP = (int)$_POST['ID_DISCIP'];
$ID_RPD = (int)$_POST['ID_RPD'];
$pole = $_POST['form'];
$state = $_POST['state'];
$tip = $_POST['tip'];
//if($_POST['form']=='razdel5_4'){ $pole='razdel5_4'; }
if($pole!=''){
$out = $this->RPD_clear($ID_DISCIP,$pole,$state,$tip,$_SESSION['user']['id']);
}
}
//сохранение РПД
if($_POST['ajdes']=='RPD_SaveTable72'){
$ID_DISCIP = (int)$_POST['ID_DISCIP'];
$ID_RPD = (int)$_POST['ID_RPD'];
$kompmodelID = (int)$_POST['kompmodelID'];
$znat = $_POST['znat'];
$umet = $_POST['umet'];
$vladet = $_POST['vladet'];
$name = $_POST['name'];
$pole='razdel7_2';
$data['id_discip'] = $ID_DISCIP;
//print_r($_POST); exit();
/*
* Array([ajdes] => RPD_SaveTable72 [ID_DISCIP] => 263 [ID_RPD] => 0 [kompmodelID] => 209
* [znat] => 1 [umet] => 2 [vladet] => 3 [name] => 4 )
* */
$out = $this->RPD_check_row($ID_DISCIP,$_SESSION['user']['id']);
if(!$out['err']){
if(isset($out['all'])){//посмотрим есть ли такое же поле
if(isset($out['all'][$pole])){//такое поле есть, добавим в него
$j = json_decode($out['all'][$pole],1);
$j[$kompmodelID] = array('kompmodelID'=>$kompmodelID,'znat'=>$znat,'umet'=>$umet,'vladet'=>$vladet,'name'=>$name);
$data[$pole] = json_encode($j);
}else{//такого поля нет добавим
$tmp[$kompmodelID] = array('kompmodelID'=>$kompmodelID,'znat'=>$znat,'umet'=>$umet,'vladet'=>$vladet,'name'=>$name);
$data[$pole] = json_encode($tmp);
}
}
$out = $this->RPD_update($out['id'],$data);
}else{
$tmp[$kompmodelID] = array('kompmodelID'=>$kompmodelID,'znat'=>$znat,'umet'=>$umet,'vladet'=>$vladet,'name'=>$name);
$data[$pole] = json_encode($tmp);
$out = $this->RPD_save($data);
//при первом сохранении надо вернуть ID_RPD
if(!$out['err']) $out['ID_RPD'] = $out['id'];
}
}
if($_POST['ajdes']=='RPD_SaveTable'){
/*Array([ID_DISCIP]=19,[ID_RPD]=2,[form]=table_5_och,
[json]=Array(
[0]=Array([0]=Array([name]=sem,[value]=1-1)[1]=Array([name]=razdel,[value]=1-2),...)
[1]=Array([0]=Array([name]=sem,[value]=2-1),...)
)
)*/
$ID_DISCIP = (int)$_POST['ID_DISCIP'];
$ID_RPD = (int)$_POST['ID_RPD'];
if($_POST['form']=='table_5_och'){ $pole='razdel5'; $pole1 = 'och'; }
if($_POST['form']=='table_5_zao'){ $pole='razdel5'; $pole1 = 'zao'; }
if($_POST['form']=='table_5_ochzao'){ $pole='razdel5'; $pole1 = 'ochzao'; }
if($_POST['form']=='table_54_1'){ $pole='razdel5_4'; $pole1 = '1'; }
if($_POST['form']=='table_55_1'){ $pole='razdel5_5'; $pole1 = '1'; }
if($_POST['form']=='table_56_1'){ $pole='razdel5_6'; $pole1 = '1'; }
if($_POST['form']=='table_58_1'){ $pole='razdel5_8'; $pole1 = '1'; }
if($_POST['form']=='table_59_1'){ $pole='razdel5_9'; $pole1 = '1'; }
if($_POST['form']=='table_61'){ $pole='razdel6_1'; $pole1 = '1'; }
if($_POST['form']=='table_62'){ $pole='razdel6_2'; $pole1 = '1'; }
if($_POST['form']=='table_81'){ $pole='razdel8_1'; $pole1 = '1'; }
if($_POST['form']=='table_82'){ $pole='razdel8_2'; $pole1 = '1'; }
if($_POST['form']=='table_101'){ $pole='razdel10_1'; $pole1 = '1'; }
if($_POST['form']=='table_1021'){ $pole='razdel10_2'; $pole1 = '1'; }
if($_POST['form']=='table_1022'){ $pole='razdel10_2'; $pole1 = '2'; }
if($_POST['form']=='table_11'){ $pole='razdel11'; $pole1 = '1'; }
if($_POST['form']=='table_551_1'){ $pole='razdel5_5_1'; $pole1 = '1'; }
//$value[$pole1] = json_decode($_POST['json'],1);
$jP = json_decode($_POST['json'],1);
//echo ''.print_r($_POST,1).'
'; echo ''.print_r($jP,1).'
';exit();
foreach($jP as $tr => $tds){
$pusto=true; //для каждой строки проверим есть ли данные
foreach($tds as $td => $arr){
$value[$pole1][$tr][$arr['name']]=$arr['value'];
if(trim($arr['value'])!='') $pusto=false;
}
if($pusto) unset($value[$pole1][$tr]); //пустая запись!
}
$data['id_discip'] = $ID_DISCIP;
$out = $this->RPD_check_row($ID_DISCIP,$_SESSION['user']['id']);
//echo ''.print_R($out,1).'
';
if(!$out['err']){
if(isset($out['all'])){//посмотрим есть ли такое же поле
if(isset($out['all'][$pole])){//такое поле есть, добавим в него
$j = json_decode($out['all'][$pole],1);
$j[$pole1] = $value[$pole1];
$data[$pole] = json_encode($j);
}else{//такого поля нет добавим
$data[$pole] = json_encode($value);
}
}
$out = $this->RPD_update($out['id'],$data);
}else{
$data[$pole] = json_encode($value);
$out = $this->RPD_save($data);
//при первом сохранении надо вернуть ID_RPD
if(!$out['err']) $out['ID_RPD'] = $out['id'];
}
}
//сохранение полей input и textarea
if($_POST['ajdes']=='RPD_Save'){
//Array([ID_DISCIP] => 19,[ID_RPD] => 0,[razdel1] =>)
$ID_DISCIP = (int)$_POST['ID_DISCIP'];
$ID_RPD = (int)$_POST['ID_RPD'];
//Подготовим данные для вставки
$data = $this->RPD_POST_to_data($_POST);
$data['id_discip'] = $ID_DISCIP;
$out = $this->RPD_check_row($ID_DISCIP,$_SESSION['user']['id']);
if(!$out['err']){
$out = $this->RPD_update($out['id'],$data);
}else{
$out = $this->RPD_save($data);
//при первом сохранении надо вернуть ID_RPD
if(!$out['err']) $out['ID_RPD'] = $out['id'];
}
$out['data'] = $data;
}
echo json_encode($out);
exit();
}
$view = 'all';
$out = array('name'=>'РПД','body'=>'');
//Отображение РПД
if(isset($URLS[1])&&$URLS[1]=='pdf') {
$id_disc = (int)$URLS[2];
$rez = $this->RPD_GetPDF($id_disc);
$out['body'] = $rez['body'];
}
if(isset($URLS[1])&&$URLS[1]=='anotac') {
$id_disc = (int)$URLS[2];
$rez = $this->RPD_GetAnnotacPDF($id_disc);
$out['body'] = $rez['body'];
}
if(isset($URLS[1])&&$URLS[1]=='fos') {
$id_disc = (int)$URLS[2];
$rez = $this->RPD_GetFOSPDF($id_disc);
$out['body'] = $rez['body'];
}
//Создание РПД
if(isset($URLS[1])&&$URLS[1]=='edit') {
$id_disc = (int)$URLS[2];
$DISCIPS = $this->Disciplin_Get_Grupp($id_disc);
//echo ''.print_r($DISCIPS,1).'
';exit();
$SAVE = $this->RPD_check_row($id_disc,$_SESSION['user']['id']);
$saveREZ = $this->SAVE_prepare($SAVE);
$smarty->assign('save', $saveREZ);
//echo ''.print_r($saveREZ,1).'
'; exit();
$op = $this->DISCIP_get_Main($DISCIPS);
$DISCIP_name = $op['DISCIP_name'];
$id_file = $op['id_file'];
$shifr = $op['shifr'];
$namOP = $op['namOP'];
//echo ''.print_r($DISCIPS,1).print_r($op,1).'
'; exit();
$id_discs = array();
if(isset($DISCIPS['Очная'])) $id_discs[] = $DISCIPS['Очная']['uchebplan']['id'];
if(isset($DISCIPS['Заочная'])) $id_discs[] = $DISCIPS['Заочная']['uchebplan']['id'];
if(isset($DISCIPS['Очно-заочная'])) $id_discs[] = $DISCIPS['Очно-заочная']['uchebplan']['id'];
//$id_discs[] = $id_disc; $id_discs = array_unique($id_discs);
//echo ''.print_r($id_discs,1).'
'; exit();
$DISCIPS['razdel71'] = $this->CompetGet_71($id_discs);
$DISCIPS['razdel7'] = $this->CompetGet($id_file,$id_discs,$DISCIPS);
if($id_disc==46149) $DISCIPS['razdel7']=array();//РУБЕН
//echo $id_file.' - '.$DISCIP_name.'razdel71'.print_r($DISCIPS['razdel71'],1).'razdel7'.print_r($DISCIPS['razdel7'],1).'
';exit();
if(!count($DISCIPS['razdel7'])){//почему то не подбирается компетенции 7.2
for($i=1;$iCompetGet($id_file,$id_discs[$i]);
//echo $i.'::'.$id_file.' - '.$DISCIP_name.''.print_r($DISCIPS['razdel7'],1).'
';
if(count($DISCIPS['razdel7'])) break;
}
}
if(!count($DISCIPS['razdel7'])){
$DISCIPS['razdel7'] = $this->CompetGet_ELSE($id_file,$id_discs,$DISCIPS);
}
//echo $id_file.' - '.$DISCIP_name.''.print_r($DISCIPS['razdel7'],1).print_r($DISCIPS,1).'
'; exit();
$smarty->assign('DISCIPS', $DISCIPS);
$smarty->assign('DISCIP_name', $DISCIP_name);
$obrtech = new class_OBRTECH();
$smarty->assign('OBRTECH', $obrtech->Items());
$LIB = new class_LIBRARY();
$smarty->assign('LIBS61', $LIB->get_literatura($DISCIP_name,'0007AA'));
$smarty->assign('LIBS62', $LIB->get_literatura($DISCIP_name,'000822'));
$smarty->assign('LIBS83', $LIB->get_proBD($DISCIPS));
$SOFTWARE = new class_SOFTWARE();
$softs['mkgtu'] = $SOFTWARE->software();
$softs['gov'] = $SOFTWARE->softwareGOV();
$smarty->assign('SOFTWARE', $softs);
$MATERIAL = new class_MATERIAL();
$smarty->assign('MATERIAL', $MATERIAL->GetItems(array('code'=>$shifr)));//'namedisc'=>$DISCIP_name
$smarty->assign('ID_DISCIP', $id_disc);
$smarty->assign('ID_RPD', 0);
$moduls = new class_MODULS();
$smarty->assign('MODULS', $moduls->Items());
$smarty->assign('aUSER', $_SESSION['user']);
//echo ''.print_r($op,1).print_r($DISCIPS,1).'
';exit();
if($this->isRPD_praktik($op)){
$out['body'] = $smarty->fetch('page_rpd_praktik.html');
}else {
$out['body'] = $smarty->fetch('page_rpd.html');
}
}
if(!isset($URLS[1])||$URLS[1]=='all') {
//die('Технические работы...');
$dis = $this->Disciplins($_SESSION['user']['id']);
//echo ''.print_r($dis,1).'
';exit();
$smarty->assign('DISCIPS', $dis['items']);
$DISCIPS_copy = $this->Disciplins_ALL($_SESSION['user']['id']);
$smarty->assign('DISCIPS_copy', $DISCIPS_copy['items']);
$disNOT = $this->Disciplins_OTDAN($_SESSION['user']['id']);
$disBezUP = $this->Disciplins_BEZUP($_SESSION['user']['id']);
$smarty->assign('disNOT', $disNOT);
$smarty->assign('disBezUP', $disBezUP);
$ks=0; $hh = (int)date('H');
if(!isset($_SESSION['ks'])) {
if ($hh > 0 && $hh <= 8) $ks = mt_rand(40, 120);
if ($hh > 8 && $hh <= 12) $ks = mt_rand(300, 1200);
if ($hh > 12 && $hh <= 13) $ks = mt_rand(120, 300);
if ($hh > 13 && $hh <= 18) $ks = mt_rand(500, 3000);
if ($hh > 18) $ks = mt_rand(400, 900);
$_SESSION['ks'] = $ks;
$_SESSION['kst'] = time();
}else{
if (($_SESSION['kst']+(60*15))