2043 lines
114 KiB
PHP
2043 lines
114 KiB
PHP
<?php
|
||
error_reporting(0);
|
||
//die('скоро откроется...');
|
||
class class_ShahtPlans{
|
||
private $DB=null;
|
||
private $TFile='';
|
||
private $TFiles='';
|
||
private $TUchebplans='';
|
||
private $TUchebplans_compet='';
|
||
private $TCompet='';
|
||
private $planINSERTdb=1;
|
||
private $planINSERTarray=array();
|
||
function __construct(){
|
||
GLOBAL $DB,$ST;
|
||
$this->DB = $DB;
|
||
$this->TFile = $ST['dbpf'].'_fshp_file';
|
||
$this->TFiles = $ST['dbpf'].'_fshp_files';
|
||
$this->TUchebplans = $ST['dbpf'].'_fshp_uchebplans';
|
||
$this->TUchebplans_compet = $ST['dbpf'].'_fshp_uchebplans_compet';
|
||
$this->TCompet = $ST['dbpf'].'_fshp_compet';
|
||
}
|
||
|
||
/**
|
||
* ПОЛУЧЕНИЕ ИЗ XLSX ПЛАНА
|
||
* @param $id_file
|
||
* @return array
|
||
* @throws PHPExcel_Exception
|
||
* @throws PHPExcel_Reader_Exception
|
||
*/
|
||
function uchebplan_get_discip($id_file){
|
||
$plan = array();
|
||
//Получим файл
|
||
$sql = 'SELECT file FROM '.$this->TFiles.' WHERE id='.$id_file;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']) {
|
||
$file = $rez['rez'][0]['file'];
|
||
|
||
require_once 'inc/PHPExcel.php';
|
||
$excel = PHPExcel_IOFactory::load($file);
|
||
$this->planINSERTdb = 0;
|
||
|
||
$title = $this->sheet_title($excel, $file, $id_file, $this->planINSERTdb);
|
||
$praktik = $this->sheet_praktik($excel, $file);
|
||
if ($title['fakultet'] == 'Филиал') $isFILIAL = true;
|
||
|
||
$this->sheet_plan($excel, $file, $title, $praktik, $id_file);
|
||
$plan = $this->planINSERTarray;
|
||
|
||
}
|
||
return $plan;
|
||
}
|
||
|
||
/**
|
||
* Вставляем связку компетенция - дисциплина
|
||
* @param $data
|
||
* @return void
|
||
*/
|
||
function insert_uchebplan_compet($data){
|
||
$out=array();
|
||
$out['err']=1;
|
||
//Надо выбрать ее ИД
|
||
$sql2 = 'SELECT id FROM ' . $this->TCompet . ' WHERE id_file=' . $data['id_file'] . ' AND `index`="' . $this->DB->rescape($data['comp']['index']) . '" AND descrip="' . $this->DB->rescape($data['comp']['comp']) . '"';
|
||
$rez2 = $this->DB->QUR_SEL($sql2);
|
||
//echo $sql2.print_r($rez2,1).'<bR>';
|
||
if (!$rez2['err'] && $rez2['kol']) {
|
||
$id_compet = $rez2['rez'][0]['id'];
|
||
//Надо связать компетенцию и Дисциплину
|
||
$sql2 = 'SELECT id FROM ' . $this->TUchebplans_compet . ' WHERE id_uchebplans=' .$data['id_uchebplans'] . ' AND id_compet=' . $id_compet;
|
||
$rez2 = $this->DB->QUR_SEL($sql2);
|
||
if (!$rez2['err'] && $rez2['kol']) {}else{//Вставим если такой связки нет
|
||
$sql2 = 'INSERT INTO ' . $this->TUchebplans_compet . ' VALUES(0,' . $data['id_uchebplans'] . ',' . $id_compet . ')';
|
||
$rez2 = $this->DB->QUR($sql2);
|
||
if (!$rez2['err']) $out['err']=0;
|
||
}
|
||
}
|
||
return $out;
|
||
}
|
||
public function HTML(){
|
||
GLOBAL $WorkDIR,$ST,$DB;
|
||
$CHPU = new class_CHPU($WorkDIR);
|
||
$URLS = $CHPU->uri();
|
||
//echo '<pre>'.print_r($URLS,1).'</pre>';exit();
|
||
$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']=='compet_del_uchebplan'){
|
||
$compid = (int)$_POST['compid'];
|
||
$uchebid = (int)$_POST['uchebid'];
|
||
$sql = 'DELETE FROM ' . $ST['dbpf'] . '_fshp_uchebplans_compet WHERE id_uchebplans='.$uchebid.' AND id_compet='.$compid;
|
||
$rez = $DB->QUR($sql);
|
||
if(!$rez['err']) {
|
||
$out['err']=0;
|
||
$out['msg']='Удалили дисциплину к этой компетенции';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка удаления дисциплины к компетенции';
|
||
}
|
||
}
|
||
//Добавление дисциплины для компетенции
|
||
if($_POST['ajdes']=='compet_add_uchebplan'){
|
||
$compid = (int)$_POST['compid'];
|
||
$uchebid = (int)$_POST['uchebid'];
|
||
$out['err']=0;
|
||
$sql = 'SELECT id FROM ' . $ST['dbpf'] . '_fshp_uchebplans_compet WHERE id_uchebplans='.$uchebid.' AND id_compet=' . $compid ;
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']) {
|
||
$out['err']=1;
|
||
$out['msg']='Такая дисциплина уже есть у этой компетенции';
|
||
}else{
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_uchebplans_compet VALUES (0,' . $uchebid . ',' . $compid . ')';
|
||
$rez = $DB->QUR($sql);
|
||
if(!$rez['err']) {
|
||
$out['err']=0;
|
||
$out['msg']='Добавили дисциплину к этой компетенции';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка добавления дисциплины к компетенции';
|
||
}
|
||
}
|
||
}
|
||
//Смена дисциплины у преподавателя
|
||
if($_POST['ajdes']=='plan_plan_change_save_discip'){
|
||
$saveid = (int)$_POST['saveid']; //id сохранения
|
||
$new_iddiscip = (int)$_POST['new_iddiscip']; //id новой дисциплины
|
||
$saveiddiscip = (int)$_POST['saveiddiscip']; //id старой дисциплины
|
||
$saveidprepod = (int)$_POST['saveidprepod']; //id старый препод
|
||
$out['err']=0;
|
||
if($new_iddiscip!=0) {
|
||
//$out['msg']='Меняем у сохранения '.$saveid.' IDdisc0='.$saveiddiscip.' IDprep0='.$saveidprepod.' IDdisc1='.$new_iddiscip;
|
||
$out['msg'] = 'Меняем у сохранения Дисциплину<br>';
|
||
$sql = 'SELECT * FROM acs_fshp_rpd_save WHERE id=' . $saveid . ' LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$sql = 'SELECT * FROM acs_fshp_rpd_save WHERE id_discip=' . $new_iddiscip . ' LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Такая дисциплина уже разрабатывается!<br>';
|
||
} else {
|
||
//Узнаем есть ли назначение по старой дисциплине
|
||
$sql = 'SELECT id FROM acs_fshp_disciplin_prepod WHERE id_uchebplans=' . $saveiddiscip . ' AND id_prepod=' . $saveidprepod . ' LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out['msg'] .= 'Дисциплина была назначена, сменим дисциплину!<br>';
|
||
$sql = 'UPDATE acs_fshp_disciplin_prepod SET id_uchebplans=' . $new_iddiscip . ' WHERE id=' . $rez['rez'][0]['id'] . ' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if (!$rez['err']) {
|
||
$out['msg'] .= 'Назначение дисциплины изменили<br>';
|
||
$sql = 'UPDATE acs_fshp_rpd_save SET id_discip=' . $new_iddiscip . ' WHERE id=' . $saveid . ' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if (!$rez['err']) {
|
||
$out['msg'] .= 'Изменили дисциплину для РПД<br>';
|
||
} else {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Не изменили дисциплину для РПД<br>';
|
||
}
|
||
} else {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Назначение дисциплины не изменили<br>';
|
||
}
|
||
} else {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Нет назначения на новую дисциплину!<br>';
|
||
}
|
||
}
|
||
} else {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Не нашли такого сохранения<br>';
|
||
}
|
||
}else{
|
||
$out['msg'] .= 'Выберите дисциплину<br>';
|
||
}
|
||
}
|
||
//Установка поиска для таблиц
|
||
if($_POST['ajdes']=='table_search') {
|
||
$shifr = $DB->rescape($_POST['shifr']);
|
||
if($shifr!='') $_SESSION['search']['shifr'] = $shifr;
|
||
else unset($_SESSION['search']['shifr']);
|
||
}
|
||
//Удаление дисциплины из плана
|
||
if($_POST['ajdes']=='plan_plan_dele') {
|
||
$out['err']=0;
|
||
$out['msg']='';
|
||
$id = (int)$_POST['id'];
|
||
$sql = 'SELECT id FROM acs_fshp_rpd_save WHERE id_discip='.$id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_save = $rez['rez'][0]['id'];
|
||
$out['err']=1;
|
||
$out['msg'].='<span style="color:red;">Нельзя удалить, ДИСЦИПЛИНА уже имеет РПД!</span><br>';
|
||
//найдем подходящую!
|
||
$sql = 'SELECT id_file,index1 FROM acs_fshp_uchebplans WHERE id='.$id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_file = $rez['rez'][0]['id_file'];
|
||
$index1 = $rez['rez'][0]['index1'];
|
||
//Выберем по шифру такую же
|
||
$sql = 'SELECT id FROM acs_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="'.$index1.'" AND id!='.$id.' ORDER BY id ASC LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$new_id_disc = $rez['rez'][0]['id'];
|
||
//Обновим назначение
|
||
$rez = $this->DB->QUR('UPDATE acs_fshp_rpd_save SET id_discip='.$new_id_disc.' WHERE id='.$id_save);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg'].='<span style="color:green;">Заменили дисциплину в РПД!</span><br>';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$sql = 'SELECT id FROM acs_fshp_disciplin_prepod WHERE id_uchebplans='.$id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_dp = $rez['rez'][0]['id'];
|
||
$out['err']=1;
|
||
$out['msg'].='<span style="color:red;">Нельзя удалить, ДИСЦИПЛИНУ назначили!</span><br>';
|
||
//найдем подходящую!
|
||
$sql = 'SELECT id_file,index1 FROM acs_fshp_uchebplans WHERE id='.$id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_file = $rez['rez'][0]['id_file'];
|
||
$index1 = $rez['rez'][0]['index1'];
|
||
//Выберем по шифру такую же
|
||
$sql = 'SELECT id FROM acs_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="'.$index1.'" AND id!='.$id.' ORDER BY id ASC LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$new_id_disc = $rez['rez'][0]['id'];
|
||
//Обновим назначение
|
||
$rez = $this->DB->QUR('UPDATE acs_fshp_disciplin_prepod SET id_uchebplans='.$new_id_disc.' WHERE id='.$id_dp);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg'].='<span style="color:green;">Заменили дисциплину в назначениях!</span><br>';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(!$out['err']){
|
||
$out['err']=0;
|
||
/*$sql = 'DELETE FROM acs_fshp_uchebplans_compet WHERE id_uchebplans='.$id;
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['msg'].='Удалили записи компетенций<br>';
|
||
}else{
|
||
$out['msg'].='Не удалили записи компетенций<br>';
|
||
}*/
|
||
$sql = 'DELETE FROM acs_fshp_uchebplans WHERE id='.$id;
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['msg'].='Удалили запись дисциплины<br>';
|
||
}else{
|
||
$out['msg'].='Не удалили запись дисциплины<br>';
|
||
}
|
||
/*$sql = 'DELETE FROM acs_fshp_disciplin_prepod WHERE id_uchebplans='.$id;
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['msg'].='Удалили назначения преподавателя<br>';
|
||
}else{
|
||
$out['msg'].='Не удалили назначения преподавателя<br>';
|
||
}*/
|
||
$sql = 'DELETE FROM acs_fshp_competmodels_sem WHERE id_disc='.$id;
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['msg'].='Удалили комп.модель.сем.<br>';
|
||
}else{
|
||
$out['msg'].='Не удалили комп.модель.сем.<br>';
|
||
}
|
||
}
|
||
}
|
||
//обновление данных дисциплины JSON
|
||
if($_POST['ajdes']=='plan_plan_save_json') {
|
||
$out['err']=0;
|
||
$out['msg']='обрабатываем...';
|
||
$id = (int)$_POST['id'];
|
||
$json = stripslashes(base64_decode($_POST['json']));
|
||
$sql = 'UPDATE '.$this->TUchebplans.' SET json="'.$this->DB->rescape($json).'" WHERE id='.$id.' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg']='Обновили';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка обновления';
|
||
}
|
||
}
|
||
//обновление данных дисциплины только JSON
|
||
if($_POST['ajdes']=='plan_plan_save_json_only') {
|
||
$out['err']=0;
|
||
$out['msg']='обрабатываем...';
|
||
$id = (int)$_POST['id_discip'];
|
||
$json = stripslashes(base64_decode($_POST['json']));
|
||
$json = stripslashes($_POST['json']);
|
||
//file_put_contents('ttttt.txt',$_POST['json'].PHP_EOL,FILE_APPEND);
|
||
//file_put_contents('ttttt.txt',$json.PHP_EOL,FILE_APPEND);
|
||
$sql = 'UPDATE '.$this->TUchebplans.' SET json="'.$this->DB->rescape($json).'" WHERE id='.$id.' LIMIT 1';
|
||
//file_put_contents('ttttt.txt',$sql.PHP_EOL,FILE_APPEND);
|
||
$rez = $this->DB->QUR($sql);
|
||
//file_put_contents('ttttt.txt',print_r($rez,1).PHP_EOL,FILE_APPEND);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg']='Обновили';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка обновления';
|
||
}
|
||
}
|
||
//обновление данных дисциплины
|
||
if($_POST['ajdes']=='plan_plan_save') {
|
||
$out['err']=0;
|
||
$out['msg']='обрабатываем...';
|
||
$id = (int)$_POST['id'];
|
||
$index1 = $this->DB->rescape($_POST['index1']);
|
||
$name = $this->DB->rescape($_POST['name']);
|
||
$ekzamen = $this->DB->rescape($_POST['ekzamen']);
|
||
$zachet = $this->DB->rescape($_POST['zachet']);
|
||
$zachetsocenk = $this->DB->rescape($_POST['zachetsocenk']);
|
||
$kr = $this->DB->rescape($_POST['kr']);
|
||
$kp = $this->DB->rescape($_POST['kp']);
|
||
$kontrol = $this->DB->rescape($_POST['kontrol']);
|
||
$kaf_kod = $this->DB->rescape($_POST['kaf_kod']);
|
||
$kaf_name = $this->DB->rescape($_POST['kaf_name']);
|
||
$sql = 'UPDATE '.$this->TUchebplans.' SET index1="'.$index1.'",name="'.$name.'",kaf_kod="'.$kaf_kod.'",kaf_name="'.$kaf_name.'",ekzamen='.$ekzamen.',zachet='.$zachet.',zachetsocenk='.$zachetsocenk.',kr='.$kr.',kp='.$kp.',kontrol='.$kontrol.' WHERE id='.$id.' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg']='Обновили';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка обновления';
|
||
}
|
||
}
|
||
//Удаление дисциплины из плана
|
||
if($_POST['ajdes']=='plan_competen_dele') {
|
||
$out['err']=0;
|
||
$out['msg']='';
|
||
$id = (int)$_POST['id'];
|
||
if($id!=0) {//Удаление одиночно!
|
||
$sql = 'SELECT id FROM acs_fshp_competmodels WHERE id_comp=' . $id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Компетенция сохранена в моделях!';
|
||
}
|
||
$sql = 'SELECT id FROM acs_fshp_competmodels_sem WHERE id_compet=' . $id;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out['err'] = 1;
|
||
$out['msg'] .= 'Компетенция сохранена в моделях-семестрах!';
|
||
}
|
||
if(!$out['err']){
|
||
$out['err']=0;
|
||
$sql = 'DELETE FROM acs_fshp_compet WHERE id='.$id;
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['msg'].='Удалили компетенцию<br>';
|
||
$rez = $this->DB->QUR('DELETE FROM acs_fshp_uchebplans_compet WHERE id_compet='.$id);
|
||
}else{
|
||
$out['msg'].='Не удалили компетенцию<br>';
|
||
}
|
||
}
|
||
}else{//удаление массово
|
||
$idfile = (int)$_POST['idfile']; $deletes=array(); $saves=0; $discip=0;
|
||
//не выбираем компетенции "заголовок" ОПК - 1 только ОПК - 1.1
|
||
$sql = 'SELECT id FROM acs_fshp_compet WHERE id_file='.$idfile.' AND `index` LIKE "%.%"';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out['msg'].='Выбрали из плана '.$rez['kol'].' компетенций<br>';
|
||
//Проверяем есть ли дисциплины
|
||
foreach($rez['rez'] as $kol => $val){
|
||
$isdiscip = 0;
|
||
$sql1 = 'SELECT id,id_uchebplans FROM acs_fshp_uchebplans_compet WHERE id_compet='.$val['id'];
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if (!$rez1['err'] && $rez1['kol']) {
|
||
$id_uchebplans_compet = $rez1['rez'][0]['id'];
|
||
$id_uchebplans = $rez1['rez'][0]['id_uchebplans'];
|
||
//а есть ли дисциплины?
|
||
$rez0 = $this->DB->QUR_SEL('SELECT id FROM `acs_fshp_uchebplans` WHERE `id`='.$id_uchebplans);
|
||
if (!$rez0['err'] && $rez0['kol']){
|
||
$isdiscip = 1;
|
||
$discip++;//есть дисциплины
|
||
}else{//нет такого учебного плана!!! возможно остался от не правильного удаления!
|
||
$isdiscip = 0;
|
||
$rez0 = $this->DB->QUR('DELETE FROM acs_fshp_uchebplans_compet WHERE id='.$id_uchebplans_compet);
|
||
}
|
||
}else {//нет дисцциплин
|
||
$isdiscip = 0;
|
||
}
|
||
if($isdiscip == 0){
|
||
$err=0;//Проверим есть ли сохранения к этой компетенции
|
||
$rez0 = $this->DB->QUR_SEL('SELECT id FROM acs_fshp_competmodels WHERE id_comp='.$val['id']);
|
||
if (!$rez0['err'] && $rez0['kol']){$err=1; $saves++;}
|
||
$rez0 = $this->DB->QUR_SEL('SELECT id FROM acs_fshp_competmodels_sem WHERE id_compet='.$val['id']);
|
||
if (!$rez0['err'] && $rez0['kol']){$err=1; $saves++;}
|
||
if($err==0){
|
||
$rez0 = $this->DB->QUR('DELETE FROM acs_fshp_compet WHERE id='.$val['id']);
|
||
if(!$rez0['err']) $deletes[]=$val['id'];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$out['msg'].='Удалили '.count($deletes).'шт. компетенций.<br>';
|
||
$out['msg'].='С сохранениями '.$saves.'шт.<br>';
|
||
$out['msg'].='С дисциплинами '.$discip.'шт.<br>';
|
||
$out['deletes']=$deletes;
|
||
}
|
||
}
|
||
//Копирование дисциплин из плана
|
||
if($_POST['ajdes']=='plan_competen_copy') {
|
||
$out['err']=0;
|
||
$out['msg']='Сохранили номер, выберите куда вставить';
|
||
$_SESSION['competen_copy_id'] = (int)$_POST['id'];
|
||
}
|
||
//Вставка дисциплин из ранее копируемой компетенции
|
||
if($_POST['ajdes']=='plan_competen_paste') {
|
||
$out['err']=0;
|
||
$out['msg']='';
|
||
$id_compet = (int)$_POST['id'];
|
||
$sql = 'SELECT * FROM '.$this->TUchebplans_compet.' WHERE id_compet='.$_SESSION['competen_copy_id'];
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
$col=0; $err=0;
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach ($rez['rez'] as $key => $val){
|
||
$rez1 = $this->DB->QUR('INSERT INTO '.$this->TUchebplans_compet.' VALUES(0,'.$val['id_uchebplans'].','.$id_compet.')');
|
||
if(!$rez1['err']) $col++; else $err++;
|
||
}
|
||
}
|
||
|
||
$out['msg']='Добавили '.$col.' шт. ощибок'.$err.' шт.';
|
||
unset($_SESSION['competen_copy_id']);
|
||
}
|
||
//обновление данных дисциплины
|
||
if($_POST['ajdes']=='plan_competen_save') {
|
||
$out['err']=0;
|
||
$out['msg']='обрабатываем...';
|
||
$id = (int)$_POST['id'];
|
||
$index = $this->DB->rescape($_POST['index']);
|
||
$descrip = $this->DB->rescape($_POST['descrip']);
|
||
$sql = 'UPDATE '.$this->TCompet.' SET `index`="'.$index.'",descrip="'.$descrip.'" WHERE id='.$id.' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg']='Обновили';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка обновления';
|
||
}
|
||
}
|
||
//обнолвение данных титула учебного плана
|
||
if($_POST['ajdes']=='plan_title_save'){
|
||
$out['err']=0;
|
||
$out['msg']='обрабатываем...';
|
||
$id = (int)$_POST['id'];
|
||
$program = $this->DB->rescape($_POST['program']);
|
||
$shifr = $this->DB->rescape($_POST['shifr']);
|
||
$naprav = $this->DB->rescape($_POST['naprav']);
|
||
$profil = $this->DB->rescape($_POST['profil']);
|
||
$kafedra = $this->DB->rescape($_POST['kafedra']);
|
||
$fakultet = $this->DB->rescape($_POST['fakultet']);
|
||
$kvalif = $this->DB->rescape($_POST['kvalif']);
|
||
$god_nach_podgot = (int)$_POST['god_nach_podgot']; if ($god_nach_podgot=='') $god_nach_podgot=0;
|
||
$fo = $this->DB->rescape($_POST['fo']);
|
||
$obr_stabdart = $this->DB->rescape($_POST['obr_stabdart']);
|
||
$srok_poluch_obr = $this->DB->rescape($_POST['srok_poluch_obr']);
|
||
|
||
//id data_c id_file program shifr naprav profil kafedra fakultet kvalif god_nach_podgot fo obr_stabdart srok_poluch_obr json status
|
||
$sql = 'UPDATE '.$this->TFile.' SET program="'.$program.'",shifr="'.$shifr.'",naprav="'.$naprav.'",profil="'.$profil.'",kafedra="'.$kafedra.'",fakultet="'.$fakultet.'",kvalif="'.$kvalif.'",god_nach_podgot='.$god_nach_podgot.',fo="'.$fo.'",obr_stabdart="'.$obr_stabdart.'",srok_poluch_obr="'.$srok_poluch_obr.'" WHERE id='.$id.' LIMIT 1';
|
||
$rez = $this->DB->QUR($sql);
|
||
if(!$rez['err']){
|
||
$out['err']=0;
|
||
$out['msg']='Обновили';
|
||
}else{
|
||
$out['err']=1;
|
||
$out['msg']='Ошибка обновления';
|
||
}
|
||
}
|
||
echo json_encode($out);
|
||
exit();
|
||
}
|
||
if (isset($_POST['upload0'])){
|
||
echo '<pre>'.print_r($_FILES,1).'</pre>';exit();
|
||
$pi = pathinfo($_FILES['file0']['name'],PATHINFO_EXTENSION );
|
||
if(mb_strtolower($pi)=='xlsx') {
|
||
$cSystem = new class_SYSTEM();
|
||
$file = $cSystem->uploadfile('file0', 'shaht_xlsx', 1);
|
||
$smarty->assign('file', $file);
|
||
if (!$file['err']) {
|
||
$rez = $this->parse_xls($file['path'] . $file['file']);
|
||
if($rez['err']==0) {
|
||
$view = 'one';
|
||
$smarty->assign('PLAN', $rez);
|
||
$smarty->assign('view', $view);
|
||
$out['body'] = $smarty->fetch('page_shahtplan.html');
|
||
return $out;
|
||
}else{
|
||
$view = 'all';
|
||
$smarty->assign('uplmes',$rez['file']);
|
||
}
|
||
} else {
|
||
$rez = array();
|
||
}
|
||
}else{
|
||
$view = 'all';
|
||
$smarty->assign('uplmes','Файл должен быть Excel формата!');
|
||
}
|
||
}
|
||
if (isset($_POST['upload'])){
|
||
//echo '<pre>'.print_r($_FILES,1).'</pre>';exit();
|
||
$pi = pathinfo($_FILES['file']['name'],PATHINFO_EXTENSION );
|
||
if(mb_strtolower($pi)=='xlsx') {
|
||
$cSystem = new class_SYSTEM();
|
||
$file = $cSystem->uploadfile('file', 'shaht_xlsx', 1);
|
||
$smarty->assign('file', $file);
|
||
if (!$file['err']) {
|
||
$rez = $this->parse_xls($file['path'] . $file['file']);
|
||
if($rez['err']==0) {
|
||
$view = 'one';
|
||
$smarty->assign('PLAN', $rez);
|
||
$smarty->assign('view', $view);
|
||
$out['body'] = $smarty->fetch('page_shahtplan.html');
|
||
return $out;
|
||
}else{
|
||
$view = 'all';
|
||
$smarty->assign('uplmes',$rez['file']);
|
||
}
|
||
} else {
|
||
$rez = array();
|
||
}
|
||
}else{
|
||
$view = 'all';
|
||
$smarty->assign('uplmes','Файл должен быть Excel формата!');
|
||
}
|
||
}
|
||
|
||
if(isset($URLS[1])&&$URLS[1]=='compet_check') {
|
||
$view = 'compet_check'; //$URLS[1]='all';
|
||
$id_file = (int)$URLS[2];
|
||
//Выберем компетенции из БАЗЫ
|
||
$DBCOMP = array();
|
||
$sql = 'SELECT * FROM '.$this->TCompet.' WHERE id_file='.$id_file.' ORDER BY id ASC';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach ($rez['rez'] as $key => $val){
|
||
$sql1 = 'SELECT u.id,u.index1,u.name,uc.id as ucid FROM '.$this->TUchebplans_compet.' as uc,'.$this->TUchebplans.' as u WHERE uc.id_compet='.$val['id'].' AND u.id=uc.id_uchebplans';
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
$val['discips'] = $rez1['rez'];
|
||
foreach ($val['discips'] as $key1 => $val1) {
|
||
$kkk = trim($val1['index1']).' '.trim($val1['name']);
|
||
$DBCOMP[$val['index']][$kkk][] = array('id_disc'=>$val1['id'],'id_comp'=>$val1['ucid']);
|
||
}
|
||
}
|
||
//$DBCOMP[] = $val;
|
||
}
|
||
}
|
||
//echo '<pre>'.print_r($DBCOMP,1).'</pre>';exit();
|
||
//$DBCOMP=Array(
|
||
// [УК-1.1] => Array(
|
||
// [Б1.О.07 Информационные технологии] => Array(
|
||
// [0] => Array( [id_disc] => 33923 [id_comp] => 332115 )
|
||
// )
|
||
//Выберем компетенции из json файла после парсинга XLSX
|
||
$sql = 'SELECT file FROM '.$this->TFiles.' WHERE id='.$id_file;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$file = $rez['rez'][0]['file'];
|
||
$pi = pathinfo($file);
|
||
$json = $pi['dirname'] . '/' . $pi['filename'] . '_comp.json';
|
||
$FCOMP = json_decode(file_get_contents($json),1);
|
||
$NOCOMP = array();
|
||
//$zamena_discip = array('Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы'=>'РВКР');
|
||
$zamena_discip = array('Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы'=>'ВКР');
|
||
//обойдем все компетенции из файла
|
||
foreach($FCOMP as $kod => $comp)if(isset($comp['discips'])){
|
||
//$FCOMP = [УК-1.1] => Array(
|
||
// [index] => УК-1.1 [comp] => Анализирует задачу, выделяя ее базовые составляющие, осуществляет декомпозицию задачи
|
||
// [discips] => Array ( [0] => Array ( [shifr] => Б1.О.02 [discip] => Философия ) )
|
||
//)
|
||
foreach($comp['discips'] as $key => $discip){// Array ( [shifr] => Б1.О.02 [discip] => Философия )
|
||
if(isset($zamena_discip[trim($discip['discip'])]))
|
||
$kkk = trim($discip['shifr']).' '.$zamena_discip[trim($discip['discip'])];
|
||
else $kkk = trim($discip['shifr']).' '.trim($discip['discip']);
|
||
if(!isset($DBCOMP[$kod][$kkk])){//сравним с табличными и если нету запишем
|
||
$tmp = $discip;
|
||
$tmp['komp'] = $comp;
|
||
unset($tmp['komp']['discips']);
|
||
//Ищем есть такая дисциплина в таблице
|
||
$sql1 = 'SELECT id FROM '.$this->TUchebplans.' WHERE id_file='.$id_file.' AND index1="'.$this->DB->rescape($tmp['shifr']).'" AND name="'.$this->DB->rescape($tmp['discip']).'"';
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){//есть
|
||
$tmp['id_ucheb_plan'] = $rez1['rez'][0]['id'];
|
||
//вставим связку
|
||
$data_5['id_file'] = $id_file;
|
||
$data_5['comp'] = $comp;
|
||
$data_5['id_uchebplans'] = $tmp['id_ucheb_plan'];
|
||
$tmp['insert_rez'] = $this->insert_uchebplan_compet($data_5);
|
||
}else {//такой дисциплины нет в таблице
|
||
$tmp['id_ucheb_plan'] = 0;
|
||
$z_discip=''; //Некоторые мы меняли название!!!!
|
||
//if($tmp['discip']=='Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы'){
|
||
if($tmp['discip']=='Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы'){
|
||
$z_discip = 'ВКР';
|
||
}
|
||
$tmp['id_ucheb_plan_s'] = 0;
|
||
if($z_discip!='') {
|
||
$sql1 = 'SELECT id FROM ' . $this->TUchebplans . ' WHERE id_file=' . $id_file . ' AND index1="' . $this->DB->rescape($tmp['shifr']) . '" AND name="' . $this->DB->rescape($z_discip) . '"';
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if (!$rez1['err'] && $rez1['kol']) {
|
||
$tmp['id_ucheb_plan_s'] = $rez1['rez'][0]['id'];
|
||
//Есть компетенция $comp['index'] $comp['comp'] $id_file
|
||
$data_5['id_file'] = $id_file;
|
||
$data_5['comp'] = $comp;
|
||
$data_5['id_uchebplans'] = $tmp['id_ucheb_plan_s'];
|
||
$tmp['insert_rez'] = $this->insert_uchebplan_compet($data_5);
|
||
}
|
||
}
|
||
}
|
||
$NOCOMP[] = $tmp;
|
||
}
|
||
}
|
||
}
|
||
//$NOCOMP= Array(
|
||
// [0] => Array(
|
||
// [shifr] => Б3.01
|
||
// [discip] => Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы
|
||
// [komp] => Array(
|
||
// [index] => УК-1.1
|
||
// [comp] => Анализирует задачу, выделяя ее базовые составляющие, осуществляет декомпозицию задачи
|
||
// )
|
||
// [id_ucheb_plan] = 0|123
|
||
// )
|
||
|
||
//$smarty->assign('FCOMP', $FCOMP);
|
||
//$smarty->assign('DBCOMP', $DBCOMP);
|
||
//$PLAN = $this->uchebplan_get_discip($id_file);
|
||
//$smarty->assign('PLAN', $PLAN);
|
||
$smarty->assign('NOCOMP', $NOCOMP);
|
||
$smarty->assign('view',$view);
|
||
$out['body'] = $smarty->fetch('page_shahtplan_checks.html');
|
||
}
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='del0') {
|
||
$view = 'all'; $URLS[1]='all';
|
||
$id_file = (int)$URLS[2];
|
||
$sql = 'UPDATE '.$this->TFile.' SET status=-1 WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='del1') {
|
||
$view = 'all'; $URLS[1]='all';
|
||
$id_file = (int)$URLS[2];
|
||
$sql = 'UPDATE '.$this->TFile.' SET status=1 WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='del') {
|
||
$view = 'all'; $URLS[1]='all';
|
||
$id_file = (int)$URLS[2];
|
||
$sql = 'SELECT * FROM '.$this->TFiles.' WHERE id='.$id_file;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$file = $rez['rez'][0]['file'];
|
||
$pi = pathinfo($file);
|
||
$ftitle = $pi['dirname'].'/'.$pi['filename'].'_title.json';
|
||
if(file_exists($ftitle)) unlink($ftitle);
|
||
if(file_exists($file)) unlink($file);
|
||
$sql = 'DELETE FROM '.$this->TFiles.' WHERE id='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
|
||
$sql = 'DELETE FROM '.$this->TFile.' WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
|
||
$sql1 = 'SELECT id FROM ' . $this->TUchebplans . ' WHERE id_file='.$id_file;
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
foreach($rez1['rez'] as $key1 => $val1) {
|
||
$sql = 'DELETE FROM ' . $this->TUchebplans_compet . ' WHERE id_uchebplans=' . $val1['id'];
|
||
$rez = $this->DB->QUR($sql);
|
||
}
|
||
}
|
||
$sql = 'DELETE FROM ' . $this->TUchebplans . ' WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
|
||
$sql = 'DELETE FROM '.$this->TCompet.' WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
|
||
$sql = 'DELETE FROM '.$ST['dbpf'].'_fshp_competmodels WHERE id_file='.$id_file;
|
||
$rez = $this->DB->QUR($sql);
|
||
}
|
||
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='pere') {
|
||
$view = 'pere'; $checks=array();
|
||
$id_file = (int)$URLS[2];
|
||
$sql = 'SELECT file FROM '.$ST['dbpf'].'_fshp_files WHERE id='.$id_file;
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$file = $rez['rez'][0]['file'];
|
||
$checks = $this->check_xls($id_file,$file);
|
||
}
|
||
//$smarty->assign('PLAN', $this->plan_show($id_file));
|
||
$smarty->assign('view',$view);
|
||
$smarty->assign('rez',$checks);
|
||
$out['body'] = $smarty->fetch('page_shahtplan.html');
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='edit') {
|
||
$view = 'edit';
|
||
$id_file = (int)$URLS[2];
|
||
$smarty->assign('PLAN', $this->edit_plan($id_file));
|
||
$smarty->assign('view',$view);
|
||
$out['body'] = $smarty->fetch('page_shahtplan_edit.html');
|
||
}
|
||
if(isset($URLS[1])&&$URLS[1]=='one') {
|
||
$view = 'one';
|
||
$id_file = (int)$URLS[2];
|
||
$smarty->assign('PLAN', $this->plan_show($id_file));
|
||
$smarty->assign('view',$view);
|
||
$out['body'] = $smarty->fetch('page_shahtplan.html');
|
||
}
|
||
if(!isset($URLS[1])||$URLS[1]=='all') {
|
||
//die('Обновление системы, ожидайте...');
|
||
$npage=1;if(isset($URLS['navpage'])) $npage=$URLS['navpage'];
|
||
$PLANS = $this->UchebPlans_All($npage);
|
||
$PLANS['nav']['curpage'] = $npage;
|
||
$smarty->assign('navpages', $PLANS['nav']);
|
||
$smarty->assign('PLANS', $PLANS['items']);
|
||
$smarty->assign('view',$view);
|
||
$out['body'] = $smarty->fetch('page_shahtplans.html');
|
||
}
|
||
return $out;
|
||
}
|
||
|
||
function cache_eplan($id=0,$des='cache',$data=array()){
|
||
$out=array();
|
||
$file = 'tmp/shahtplans/planizfile_'.$id.'.json';
|
||
if($des=='save') {
|
||
file_put_contents($file,json_encode($data,JSON_UNESCAPED_UNICODE ));
|
||
}
|
||
if($des=='check') {
|
||
if (file_exists($file)) {
|
||
$out = json_decode(file_get_contents($file), 1);
|
||
} else {
|
||
$out = array();
|
||
}
|
||
}
|
||
return $out;
|
||
}
|
||
|
||
function parse_file_bezDB($id_file,$title){
|
||
$plan=array();
|
||
$cache = $this->cache_eplan($id_file,'check');
|
||
if(!count($cache)) {
|
||
$sql = 'SELECT file FROM ' . $this->TFiles . ' WHERE id=' . $id_file . ' LIMIT 1';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$file = $rez['rez'][0]['file'];
|
||
require_once 'inc/PHPExcel.php';
|
||
$excel = PHPExcel_IOFactory::load($file);
|
||
$this->planINSERTdb = 0;
|
||
|
||
$title = $this->sheet_title($excel, $file, $id_file, $this->planINSERTdb);
|
||
$praktik = $this->sheet_praktik($excel, $file);
|
||
if ($title['fakultet'] == 'Филиал') $isFILIAL = true;
|
||
|
||
$this->sheet_plan($excel, $file, $title, $praktik, $id_file);
|
||
$plan = $this->planINSERTarray;
|
||
}
|
||
$this->cache_eplan($id_file,'save',$plan);
|
||
}else{
|
||
$plan = $cache;
|
||
}
|
||
return $plan;
|
||
}
|
||
|
||
function edit_plan($id_file){
|
||
$out = array();
|
||
$sql = 'SELECT * FROM '.$this->TFile.' WHERE id_file='.$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 * FROM '.$this->TUchebplans.' WHERE id_file='.$id_file.' ORDER BY id ASC';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach($rez['rez'] as $key => $val){
|
||
$val['json'] = json_decode($val['json'],1);
|
||
//проверим в назначениях!
|
||
$sql1 = 'SELECT * FROM acs_fshp_disciplin_prepod WHERE id_uchebplans='.$val['id'];
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
$val['discip_prepod']=$rez1['rez'];
|
||
}else{
|
||
$val['discip_prepod']=array();
|
||
}
|
||
$sql1 = 'SELECT id,data_c,id_prepod FROM acs_fshp_rpd_save WHERE id_discip='.$val['id'];
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
$val['discip_save']=$rez1['rez'];
|
||
}else{
|
||
$val['discip_save']=array();
|
||
}
|
||
$out['plan'][] = $val;
|
||
}
|
||
}else{
|
||
$out['plan']=array();
|
||
}
|
||
$sql = 'SELECT * FROM '.$this->TCompet.' WHERE id_file='.$id_file.' ORDER BY id ASC';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach ($rez['rez'] as $key => $val){
|
||
$sql1 = 'SELECT u.id,u.index1,u.name FROM '.$this->TUchebplans_compet.' as uc,'.$this->TUchebplans.' as u WHERE uc.id_compet='.$val['id'].' AND u.id=uc.id_uchebplans';
|
||
$rez1 = $this->DB->QUR_SEL($sql1);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
$val['discips'] = $rez1['rez'];
|
||
}else{
|
||
$val['discips'] = array();
|
||
}
|
||
$out['competen'][] = $val;
|
||
}
|
||
}else{
|
||
$out['competen']=array();
|
||
}
|
||
$sql = 'SELECT up.id,up.index1,up.name,dp.descrip,us.fio FROM acs_fshp_uchebplans as up, acs_fshp_disciplin_prepod as dp, acs_users as us WHERE up.id_file='.$id_file.' AND up.id=dp.id_uchebplans AND us.id=dp.id_prepod ORDER BY up.id ASC';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$out['upprepods'] = $rez['rez'];
|
||
foreach($rez['rez'] as $key => $val){
|
||
$val['save']=array();
|
||
$sql = 'SELECT id,data_c,id_discip,id_prepod FROM acs_fshp_rpd_save WHERE id_discip='.$val['id'];
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$val['save']=$rez['rez'][0];
|
||
}
|
||
$out['upprepods'][] = $val;
|
||
}
|
||
}else{
|
||
$out['upprepods']=array();
|
||
}
|
||
|
||
$out['planfile'] = $this->parse_file_bezDB($id_file,$out['title']);
|
||
//echo '<pre>'.print_r($out,1).'</pre>';exit();
|
||
return $out;
|
||
}
|
||
|
||
/**
|
||
* Получение всех планов в базе
|
||
* @return array
|
||
*/
|
||
function UchebPlans_All($npage=1,$nkol=20){
|
||
$out = array(); $WH=array();
|
||
if(isset($_SESSION['search'])){
|
||
if(isset($_SESSION['search']['shifr'])) $WH[] = 'shifr LIKE "%'.$_SESSION['search']['shifr'].'%"';
|
||
}
|
||
$WH[] = 'god_nach_podgot='.$_SESSION['year_cur'];
|
||
if(count($WH)){
|
||
$sql = 'SELECT * FROM '.$this->TFile.' WHERE '.implode(' AND ', $WH).' ORDER BY shifr,naprav';
|
||
}else $sql = 'SELECT * FROM '.$this->TFile.' ORDER BY shifr,naprav';
|
||
$nav = $this->DB->navpage($sql,'id',$nkol);
|
||
$sql .= ' LIMIT '.(($npage-1)*$nkol).','.$nkol;
|
||
//echo $sql; exit();
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach($rez['rez'] as $k => $title){
|
||
$title['disc_kol']=0;
|
||
$rez1 = $this->DB->QUR_SEL('SELECT COUNT(id) as kol FROM acs_fshp_uchebplans WHERE id_file='.$title['id_file']);
|
||
if(!$rez1['err']&&$rez1['kol']){
|
||
$title['disc_kol']=$rez1['rez'][0]['kol'];
|
||
}
|
||
$out[] = $title;
|
||
}
|
||
}
|
||
return array('items'=>$out,'nav'=>$nav);
|
||
}
|
||
|
||
/**
|
||
* Обход файлов xls и обработка данных в них
|
||
*/
|
||
function plans_get(){
|
||
$work_file_time = 'upload/plans_work_time.txt';
|
||
if(file_exists($work_file_time)){
|
||
$time =file_get_contents($work_file_time);
|
||
//Если рабочий файл имеет метку времени более текущего-15минут, то выходим
|
||
//надо для работы крона, чтобы два раза не делал одно и тоже
|
||
if($time>=(time()-(60*15))) return array();
|
||
}
|
||
file_put_contents($work_file_time,time());
|
||
$work_file = 'upload/plans_work.txt';
|
||
if(file_exists($work_file)){
|
||
$wFile = explode(':',file_get_contents($work_file));
|
||
}else{
|
||
$wFile[0]=0;
|
||
$wFile[1]='';
|
||
}
|
||
$dir = 'upload/shaht_xlsx/';
|
||
$files = scandir($dir);
|
||
$i=0; $plans = array();
|
||
foreach($files as $key => $file)if($file!='.'&&$file!='..')if($key>=$wFile[0]){
|
||
$pi = pathinfo($file,PATHINFO_EXTENSION);
|
||
if($pi == 'xls'){
|
||
$tmp['file'] = $dir.$file;
|
||
$tmp['rez'] = $this->parse_xls($dir.$file);
|
||
//$i++; if($i==3) return $plans;
|
||
file_put_contents($work_file,$key.':'.$dir.$file);
|
||
$plans[]=$tmp;
|
||
}
|
||
}
|
||
return $plans;
|
||
}
|
||
|
||
/**
|
||
* Получение информации по одному плану
|
||
* @param string $file
|
||
* @return array
|
||
* @throws PHPExcel_Reader_Exception
|
||
*/
|
||
function plan_show($id_file){
|
||
$sql = 'SELECT * FROM '.$this->TFiles.' WHERE id='.$id_file;
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$PLAN = $this->parse_xls($rez['rez'][0]['file']);
|
||
}
|
||
return $PLAN;
|
||
}
|
||
|
||
/**
|
||
* Разбираем файл XLS и получаем данные
|
||
* @param $file
|
||
* @return array
|
||
* @throws PHPExcel_Reader_Exception
|
||
*/
|
||
function parse_xls($file){
|
||
GLOBAL $ST,$DB; $out = array();
|
||
$out['err']=0;
|
||
require_once 'inc/PHPExcel.php';
|
||
$excel = PHPExcel_IOFactory::load($file);
|
||
$id_file=0;
|
||
//ПРОВЕРКА ПО НАЗВАНИЮ ФАЙЛА!
|
||
$sql = 'SELECT id FROM '.$ST['dbpf'].'_fshp_files WHERE file="'.$file.'"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_file = $rez['rez'][0]['id'];
|
||
$out['err']=0;
|
||
$out['file']='был';
|
||
$out['id_file']=$id_file;
|
||
}else{
|
||
$sql = 'INSERT INTO '.$ST['dbpf'].'_fshp_files VALUES(0,'.time().',"'.$file.'",0)';
|
||
$rez = $DB->QUR($sql);
|
||
if(!$rez['err']) {
|
||
$id_file = $DB->lastinsertID();
|
||
$out['err']=0;
|
||
$out['file']='добавили';
|
||
$out['id_file']=$id_file;
|
||
}else{
|
||
$out['err']=1;
|
||
$out['file']='не добавили, ошибка БД';
|
||
$out['id_file']=0;
|
||
}
|
||
}
|
||
if($id_file) {
|
||
$title = $this->sheet_title($excel, $file, $id_file);
|
||
//Файл может обновляться и надо контролировать
|
||
//echo $id_file.':'.$file.'<pre>'.print_r($title,1).'</pre>'; exit();
|
||
//echo '<pre>'.print_r($out,1).'</pre>';
|
||
$tt = $this->check_title($title,$file);
|
||
if(isset($tt['id_file'])) $id_file = $tt['id_file'];
|
||
//echo $id_file.'<pre>'.print_r($tt,1).'</pre>'; exit();
|
||
$out['title']=$title;
|
||
$praktik = $this->sheet_praktik($excel, $file);
|
||
//echo $id_file.'<pre>'.print_r($praktik,1).'</pre>'; exit();
|
||
$out['praktik']=$praktik;
|
||
if ($title['fakultet'] == 'Филиал') $isFILIAL = true;
|
||
$plan = $this->sheet_plan($excel, $file, $title, $praktik, $id_file);
|
||
if(!count($plan)) return array('err'=>1,'file'=>'Файл учебного плана не правильно сохранен в формат Excel, на вкладке "План" нет разбиения по семетрам!');
|
||
//echo $id_file.'<pre>'.print_r($plan,1).'</pre>'; exit();
|
||
$out['plan']=$plan;
|
||
$competen = $this->sheet_competen($excel, $file, $id_file);
|
||
$out['competen']=$competen;
|
||
}
|
||
return $out;
|
||
}
|
||
/**
|
||
* Проверим файл XLS и получаем данные
|
||
* @param $file
|
||
* @return array
|
||
* @throws PHPExcel_Reader_Exception
|
||
*/
|
||
function check_xls($id_file,$file){
|
||
GLOBAL $ST,$DB; $out = array();
|
||
$out['err']=0;
|
||
//$this->planINSERTdb = 0;//для просмотра но не для записи в БД!!!
|
||
|
||
require_once 'inc/PHPExcel.php';
|
||
$excel = PHPExcel_IOFactory::load($file);
|
||
if($id_file) {
|
||
$out['title'] = $this->sheet_title($excel, $file, $id_file,$this->planINSERTdb);
|
||
$out['praktik'] = $this->sheet_praktik($excel, $file);
|
||
if ($out['title']['fakultet'] == 'Филиал') $isFILIAL = true;
|
||
$out['plan'] = $this->sheet_plan($excel, $file, $out['title'], $out['praktik'], $id_file);
|
||
//if(!count($plan)) return array('err'=>1,'file'=>'Файл учебного плана не правильно сохранен в формат Excel, на вкладке "План" нет разбиения по семетрам!');
|
||
$out['competen'] = $this->sheet_competen($excel, $file, $id_file);
|
||
}
|
||
return $out;
|
||
}
|
||
|
||
/**
|
||
* Проверка ТИТЛЕ в базе и если есть надо менять файлы
|
||
* @param $title
|
||
* @return array
|
||
*/
|
||
function check_title($title,$file){
|
||
$out = array();
|
||
$sql = 'SELECT * FROM '.$this->TFile.' WHERE program="'.$title['program'].'" AND shifr="'.$title['shifr'].'" AND naprav="'.$title['naprav'].'" AND profil="'.$title['profil'].'" AND kafedra="'.$title['kafedra'].'" AND fakultet="'.$title['fakultet'].'" AND kvalif="'.$title['kvalif'].'" AND god_nach_podgot='.$title['god_nach_podgot'].' AND fo="'.$title['fo'].'" AND srok_poluch_obr="'.$title['srok_poluch_obr'].'" ORDER BY data_c';
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
if($rez['kol']>1){//Уже есть такой в ТАБЛИЦЕ
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';
|
||
$old_title = $rez['rez'][0];
|
||
$new_title = $rez['rez'][1];
|
||
$out['id_file'] = $old_title['id_file'];
|
||
//Заменяем старые данные на новые
|
||
$sql = 'UPDATE '.$this->TFile.' SET data_c=' .$new_title['data_c'] . ',program="' . $new_title['program'] . '",shifr="' . $new_title['shifr'] . '",naprav="' . $new_title['naprav'] . '",profil="' . $new_title['profil'] . '",kafedra="' . $new_title['kafedra'] . '",fakultet="' . $new_title['fakultet'] . '",kvalif="' . $new_title['kvalif'] . '",god_nach_podgot=' . $new_title['god_nach_podgot'] . ',fo="' . $new_title['fo'] . '",obr_stabdart="' . $new_title['obr_stabdart'] . '",srok_poluch_obr="' . $new_title['srok_poluch_obr'] . '",json="' . $this->DB->rescape($new_title['json']) . '",status=' . $new_title['status'] . ' WHERE id='.$old_title['id'];
|
||
$rez = $this->DB->QUR($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';
|
||
//Удаляем новый загруженный титл
|
||
$sql = 'DELETE FROM '.$this->TFile.' WHERE id='.$new_title['id'];
|
||
$rez = $this->DB->QUR($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';
|
||
//Берем старый файл
|
||
$sql = 'SELECT id,file FROM '.$this->TFiles.' WHERE id='.$old_title['id_file'];
|
||
$rez = $this->DB->QUR_SEL($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';
|
||
if(!$rez['err']&&$rez['kol']){//Удаляем файлы
|
||
if(file_exists($rez['rez'][0]['file'])) unlink($rez['rez'][0]['file']);
|
||
$pi = pathinfo($rez['rez'][0]['file']);
|
||
$ftitle = $pi['dirname'].'/'.$pi['filename'].'_title.json';
|
||
if(file_exists($ftitle)) unlink($ftitle);
|
||
//обновим имя файла
|
||
$sql = 'UPDATE '.$this->TFiles.' SET file="' .$file . '" WHERE id='.$rez['rez'][0]['id'];
|
||
$rez = $this->DB->QUR($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';
|
||
//Удаляем новый загруженный файл
|
||
$sql = 'DELETE FROM '.$this->TFiles.' WHERE id='.$new_title['id_file'];
|
||
$rez = $this->DB->QUR($sql);
|
||
}
|
||
}
|
||
}
|
||
return $out;
|
||
}
|
||
|
||
/**
|
||
* Разбираем лист ТИТУЛ
|
||
* @param $excel
|
||
* @param $file
|
||
* @return array|mixed
|
||
*/
|
||
function sheet_title($excel,$file,$id_file,$save=1){
|
||
$out = array();
|
||
$pi = pathinfo($file);
|
||
$ftitle = $pi['dirname'].'/'.$pi['filename'].'_title.json';
|
||
//if(file_exists($ftitle)){
|
||
//$data = json_decode(file_get_contents($ftitle),1);
|
||
//$out = $this->save_db_title($file,$data,$id_file);
|
||
//}else{
|
||
$excel->setActiveSheetIndex(0);
|
||
$objWorksheet = $excel->getSheetByName('Титул');
|
||
|
||
$rowH = $objWorksheet->getHighestRow();
|
||
$colH =30; $yearIS=false; $profilIS=false; $obr_stabdartIS=false; $kodsIS=0; $kods=array();
|
||
$m1=array('_x000d_',"_x000d_",'_x000D_',"_x000D_","Направление подготовки:","Направление подготовки","Направление:","Направление","Специальность:","Специальность ","специальность ");
|
||
$m2=array('',"",'',"","","","","","","","");
|
||
$m3=array('Профиль подготовки','Профиль:','профиль','Магистерская программа','Программа магитратуры:','Специализация','Программа магистратуры:');
|
||
$m4=array('|#|','|#|','|#|','|#|','|#|','|#|','|#|');
|
||
$m5=array('"','«','»');
|
||
$m6=array('','','');
|
||
$smesch = 0;
|
||
for ($row = 1; $row <= $rowH; $row++) {
|
||
for ($col = 0; $col < $colH; $col++) {
|
||
$cell = $objWorksheet->getCellByColumnAndRow($col, $row);
|
||
$value = trim($cell->getValue());
|
||
if(strpos($value, 'План одобрен') !== false && $row>10) $smesch = 10;
|
||
//echo '$row='.$row.'; $col='.$col.'; ['.$value.']<br>';
|
||
|
||
if(strpos($value, 'по программе') !== false) if($out['program']==''){ $out['program'] = trim(str_replace('по программе ','',$value)); }
|
||
if($row>=(16+$smesch)&&$row<=(18+$smesch)&&$out['shifr']==''&&$value!=''&&$col!=0){ $out['shifr']=trim($value); }
|
||
if($row>=(18+$smesch)&&$row<=(19+$smesch)&&$out['naprav']==''&&$value!=''&&$col!=0){
|
||
//[naprav] => Направление подготовки:Техносферная безопасность Профиль: Охрана природной среды и ресурсосбережение
|
||
$out['naprav']=trim(str_replace($out['shifr'],'',$value));
|
||
$out['naprav'] = str_replace($m1,$m2, $out['naprav']);
|
||
|
||
$tmp = explode('|#|',str_replace($m3,$m4, $out['naprav']));
|
||
if(count($tmp)>1){
|
||
$out['naprav'] = trim($tmp[0]);
|
||
$out['profil'] = str_replace('"','',trim($tmp[1]));
|
||
}
|
||
|
||
$out['naprav'] = str_replace($m5,$m6, $out['naprav']);
|
||
$out['profil'] = str_replace($m5,$m6, $out['profil']);
|
||
}
|
||
if($profilIS){
|
||
if($value!='') {
|
||
if($out['profil']==''){
|
||
$out['profil'] = $value; $profilIS=false;
|
||
}
|
||
}
|
||
}
|
||
if(strpos($value, 'Профиль') !== false) { $profilIS=true; }
|
||
|
||
if(strpos($value, 'Кафедра') !== false) {
|
||
$c = $objWorksheet->getCellByColumnAndRow($col+1, $row);
|
||
$v = trim($c->getValue());
|
||
$out['kafedra']=$v;
|
||
}
|
||
if(strpos($value, 'Филиал') !== false) {
|
||
$out['fakultet']='Филиал';
|
||
}
|
||
if(strpos($value, 'Факультет') !== false) {
|
||
if($out['fakultet']!='Филиал') {
|
||
$c = $objWorksheet->getCellByColumnAndRow($col + 1, $row);
|
||
$v = trim($c->getValue());
|
||
$out['fakultet'] = $v;
|
||
}
|
||
}
|
||
|
||
if(strpos($value, 'Квалификация') !== false) {
|
||
$out['kvalif'] = trim(str_replace('Квалификация:','',$value));
|
||
}
|
||
if($yearIS&&$value!=''){ $out['god_nach_podgot'] = $value; $yearIS=false; }
|
||
if(strpos($value, 'Год начала подготовки') !== false) { $yearIS=true; }
|
||
|
||
if(strpos($value, 'Форма обучения') !== false) {
|
||
$out['fo'] = trim(str_replace('Форма обучения:','',$value));
|
||
}
|
||
if(strpos($value, 'Срок получения образования') !== false) {
|
||
$out['srok_poluch_obr'] = trim(str_replace('Срок получения образования:','',$value));
|
||
}
|
||
if($obr_stabdartIS){
|
||
if($out['obr_stabdart']==''&&trim($value)!='') {
|
||
$out['obr_stabdart'] = trim($value);
|
||
$obr_stabdartIS=false;
|
||
}
|
||
}
|
||
if(strpos($value, 'Образовательный стандарт') !== false) {
|
||
$obr_stabdartIS = true;
|
||
}
|
||
if(strpos($value, 'Код') !== false){
|
||
$kodsIS=1;
|
||
}
|
||
if($kodsIS==1){
|
||
if($value!='') {
|
||
$kods[$row][$col]=$value;
|
||
}
|
||
}
|
||
}
|
||
if(count($kods[$row])==1) {//после таблицы идет пустая строка
|
||
$kodsIS=0;
|
||
unset($kods[$row]);
|
||
}
|
||
}
|
||
$i=0; $kodsi = array();
|
||
foreach($kods as $k => $v){
|
||
if($i!=0) {//Удалим первую строку
|
||
if(isset($v[0])) unset($v[0]);
|
||
$kodsi[$v[1]] = $v[2];
|
||
}
|
||
$i++;
|
||
}
|
||
$out['json'] = json_encode(array('kods'=>$kodsi));
|
||
//echo '<pre>'.print_r($out,1).'</pre>'; exit();
|
||
file_put_contents($ftitle,json_encode($out));
|
||
if($save==1) $out = $this->save_db_title($pi['filename'],$out,$id_file);
|
||
//}
|
||
return $out;
|
||
}
|
||
/**
|
||
* Разбираем ЛИСТ КОМПЕТЕНЦИИ
|
||
* @param $excel
|
||
* @param $file
|
||
* @return mixed
|
||
* @throws PHPExcel_Exception
|
||
*/
|
||
function sheet_competen($excel,$file, $id_file){
|
||
$items = array();
|
||
$pi = pathinfo($file);
|
||
try {
|
||
$excel->setActiveSheetIndex(3);
|
||
if (!$excel->sheetNameExists('Компетенции')) return $items;
|
||
$worksheet = $excel->getSheetByName('Компетенции');
|
||
$json = $pi['dirname'] . '/' . $pi['filename'] . '_comp.json';
|
||
//определим параметры листа
|
||
$process['row'] = 1;
|
||
$process['col'] = 0;
|
||
$process['highestRow'] = $worksheet->getHighestRow();
|
||
$process['highestColumn'] = $worksheet->getHighestColumn();
|
||
$process['highestColumnIndex'] = PHPExcel_Cell::columnIndexFromString($process['highestColumn']);
|
||
$process['nrColumns'] = ord($process['highestColumn']) - 64;
|
||
//обойдем все данные в листе
|
||
$comp = array();
|
||
$comp_index = '';
|
||
$comp_comp = '';
|
||
//В некоторых планах описание компетенции сбивается на следующий столбец
|
||
$col_sod = 3;
|
||
if ($process['highestColumnIndex'] == 7) $col_sod = 4;
|
||
$pkuv_otstup = 0;
|
||
//if(!file_exists($json)) {
|
||
for ($row = $process['row']; $row <= $process['highestRow']; $row++) {
|
||
$tmp = array(); //собираем по столбцам массив
|
||
//echo $process['highestColumnIndex'];
|
||
for ($col = $process['col']; $col < $process['highestColumnIndex']; $col++) {
|
||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||
$value = $cell->getValue();
|
||
//echo '$row='.$row.'; $col='.$col.'; $val='.$value.'<br>';
|
||
if ($col == 0 && $value != '') {//есть комп.которые имеют доп.отступ "Тип задач проф. деятельности: проектно-конструкторский"
|
||
if (strpos($value, ':') !== False) {
|
||
$pkuv_otstup = 1;
|
||
continue;
|
||
}
|
||
}
|
||
if ($col == (0 + $pkuv_otstup) && $value != '') {
|
||
if (strpos($value, '-') !== False) $tmp['index'] = trim($value);
|
||
}
|
||
if ($col == (1 + $pkuv_otstup) && $value != '') $tmp['index'] = trim($value);
|
||
if ($col == (2 + $pkuv_otstup) && $value != '') $tmp['shifr'] = trim($value);
|
||
if ($col == $col_sod && $value != '' && !isset($tmp['shifr'])) $tmp['comp'] = trim($value);
|
||
if ($col == $col_sod && $value != '' && isset($tmp['shifr'])) $tmp['discip'] = trim($value);
|
||
}
|
||
//if ($row>=527) echo $row.' = <prE>'.print_r($tmp,1).'</prE>';
|
||
//собираем результат в массив
|
||
if (isset($tmp['index'])) {
|
||
$comp_index = $tmp['index'];
|
||
$comp_comp = $tmp['comp'];
|
||
$comp[$comp_index]['index'] = $comp_index;
|
||
$comp[$comp_index]['comp'] = $comp_comp;
|
||
}
|
||
if (isset($tmp['shifr'])) {
|
||
$comp[$comp_index]['discips'][] = $tmp;
|
||
}
|
||
//echo $comp_index.' = <prE>'.print_r($comp[$comp_index],1).'</prE>';
|
||
}
|
||
//запишем в файл данные
|
||
//echo '<prE>'.print_r($comp,1).'</prE>';exit();
|
||
file_put_contents($json, json_encode($comp));
|
||
$items = $comp;
|
||
//}else{
|
||
//$items = json_decode(file_get_contents($json), 1);
|
||
//}
|
||
if (count($items)) foreach ($items as $index => $val) {
|
||
$comp['index'] = $val['index'];
|
||
$comp['comp'] = $val['comp'];
|
||
//echo '<prE>'.print_r($val,1).'</prE>';exit();
|
||
$this->save_db_competens($comp, $val['discips'], $id_file);
|
||
}
|
||
}catch(Exception $e){
|
||
//$excel->createSheet(1);
|
||
//$sheet = $excel->setActiveSheetIndex(1);
|
||
}
|
||
return $items;
|
||
}
|
||
/**
|
||
* Разбираем лист ПРАКТИКИ
|
||
* @param $excel
|
||
* @param $file
|
||
* @return array
|
||
* @throws PHPExcel_Exception
|
||
*/
|
||
function sheet_praktik($excel,$file){
|
||
$out = array();
|
||
$pi = pathinfo($file);
|
||
try{
|
||
$excel->setActiveSheetIndex(0);
|
||
if(!$excel->sheetNameExists('Практики')) return $out;
|
||
$worksheet = $excel->getSheetByName('Практики');
|
||
$cname=-1;
|
||
$ckurs=-1;
|
||
$cseme=-1;
|
||
$cweek=-1;
|
||
$tp='УП'; $tpo='';
|
||
for ($row = 1; $row <= $worksheet->getHighestRow(); $row++) {
|
||
$tr=array();
|
||
for ($col = 0; $col < PHPExcel_Cell::columnIndexFromString($worksheet->getHighestColumn()); $col++) {
|
||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||
$value = $cell->getValue();
|
||
if($row==1){
|
||
if($cname==-1&&$value=='Название практики') $cname = 1;
|
||
if($ckurs==-1&&$value=='Курс') $ckurs = $col;
|
||
if($cseme==-1&&$value=='Сем. курса') $cseme = $col;
|
||
if($cweek==-1&&$value=='Продолжительность (недель)') $cweek = $col;
|
||
}else{
|
||
if($col==0&&$value!=''){
|
||
if (strpos($value, 'Учебная практика') !== false) { $tp = 'УП'; $tpo=trim(str_replace('Вид практики: ','',$value)); }
|
||
if (strpos($value, 'Производственная практика') !== false) { $tp = 'ППП'; $tpo=trim(str_replace('Вид практики: ','',$value)); }
|
||
if (strpos($value, 'Преддипломная практика') !== false) { $tp = 'ППП'; $tpo=trim(str_replace('Вид практики: ','',$value)); }
|
||
if (strpos($value, 'Научно-исследовательская работа') !== false) { $tp = 'ППП'; $tpo=trim(str_replace('Вид практики: ','',$value)); }
|
||
}
|
||
if($col==$cname) $tr['name']=$value;
|
||
if($col==$ckurs) $tr['kurs']=$value;
|
||
if($col==$cseme) $tr['seme']=$value;
|
||
if($col==$cweek) {
|
||
$tr['week']=$value;
|
||
$tr['days']=(floatval(str_replace(',','.',$value))*6);
|
||
}
|
||
}
|
||
}
|
||
if($tr['name']!=''){
|
||
//$tr['name'] = $tp.' '.$tr['name']; //практикам добавляется УП или ППП
|
||
$tr['name'] = $tr['name'];
|
||
$tr['tp'] = $tpo;
|
||
if(!isset($tr['seme'])){
|
||
if($tr['kurs']==1) $tr['seme'] = 2;
|
||
if($tr['kurs']==2) $tr['seme'] = 4;
|
||
if($tr['kurs']==3) $tr['seme'] = 6;
|
||
if($tr['kurs']==4) $tr['seme'] = 8;
|
||
if($tr['kurs']==5) $tr['seme'] = 10;
|
||
if($tr['kurs']==6) $tr['seme'] = 12;
|
||
}
|
||
$out[] = $tr;
|
||
}
|
||
}
|
||
}catch(Exception $e){
|
||
//$excel->createSheet(1);
|
||
//$sheet = $excel->setActiveSheetIndex(1);
|
||
}
|
||
return $out;
|
||
}
|
||
/**
|
||
* Разбираем ЛИСТ ПЛАН
|
||
* @param $excel
|
||
* @param $file
|
||
* @param $title
|
||
* @return array
|
||
* @throws PHPExcel_Exception
|
||
*/
|
||
function sheet_plan($excel,$file,$title,$praktik,$id_file){
|
||
GLOBAL $isFILIAL; $out = array();
|
||
|
||
if(strpos($title['fo'], 'Очно-заочная') !== false) {
|
||
$fo='oz';
|
||
}else{
|
||
if(strpos($title['fo'], 'Заочная') !== false) {
|
||
$fo='z';
|
||
}else{
|
||
$fo='o';
|
||
}
|
||
}
|
||
$pi = pathinfo($file);
|
||
$excel->setActiveSheetIndex(3);
|
||
$worksheet = $excel->getSheetByName('План');
|
||
$fprocess = $pi['dirname'].'/'.$pi['filename'].'_process.json';
|
||
$json = $pi['dirname'].'/'.$pi['filename'].'.json';
|
||
$file = $pi['filename'];
|
||
|
||
$process['row']=1;
|
||
$process['col']=0;
|
||
$process['highestRow']=$worksheet->getHighestRow();
|
||
$process['highestColumn']=$worksheet->getHighestColumn();
|
||
$process['highestColumnIndex']=PHPExcel_Cell::columnIndexFromString($process['highestColumn']);
|
||
$process['nrColumns']=ord($process['highestColumn']) - 64;
|
||
$HEAD=array();
|
||
$TMP['sem']=1;
|
||
$isIssetUstanSess=0;
|
||
$tr=array();
|
||
$tr1=array();
|
||
$GEKTD=false;
|
||
for ($row = $process['row']; $row <= $process['highestRow']; $row++) {
|
||
if($row<=5){//обходим первые 3 строки для создания шапки столбцов!
|
||
for ($col = $process['col']; $col < $process['highestColumnIndex']; $col++) {
|
||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||
$value = $cell->getValue();
|
||
if($row==1){//Узнаем КУРСЫ
|
||
if (strpos($value,'Курс')!==FALSE) {
|
||
$HEAD['KURS'][str_replace('Курс ','',$value)]=$col;
|
||
$HEAD['KURS1'][$col]=str_replace('Курс ','',$value);
|
||
}
|
||
if (strpos($value,'Закрепленная кафедра')!==FALSE) {
|
||
$HEAD['KAF']=$col;
|
||
}
|
||
}
|
||
if($row==2){//Узнаем семестры
|
||
//echo '$col='.$col.'; $TMP[sem]='.$TMP['sem'].'; <br>';
|
||
if (strpos($value,'Семестр')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
}
|
||
if (strpos($value,'Сем.')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
}
|
||
if (strpos($value,'Сессия')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
}
|
||
if (strpos($value,'Установочная сессия')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
$isIssetUstanSess=1;
|
||
}
|
||
if (strpos($value,'Зимняя сессия')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
}
|
||
if (strpos($value,'Летняя сессия')!==FALSE) {
|
||
$HEAD['SEM1'][$col]=$TMP['sem'];
|
||
$HEAD['SEM'][$TMP['sem']]=$col;
|
||
$TMP['sem']++;
|
||
}
|
||
}
|
||
//if(count($HEAD)) echo '<pre>'.print_r($HEAD,1).'</pre>';
|
||
if($row==3){//Узнаем Нагрузку
|
||
if(strpos($value,'Считать в плане')!==FALSE) $HEAD['title']['SVP']=$col;
|
||
if(strpos($value,'Индекс')!==FALSE) $HEAD['title']['IND']=$col;
|
||
if(strpos($value,'Наименование')!==FALSE) if(!isset($HEAD['title']['name'])) $HEAD['title']['name']=$col;
|
||
if(strpos($value,'Экза')!==FALSE) $HEAD['title']['ekzamen']=$col;
|
||
if(strpos($value,'Зачет')!==FALSE) if(!isset($HEAD['title']['zachet'])) $HEAD['title']['zachet']=$col;
|
||
if(strpos($value,'с оц.')!==FALSE) if(!isset($HEAD['title']['zachetSo'])) $HEAD['title']['zachetSo']=$col;
|
||
if(trim($value)=='КР') if(!isset($HEAD['title']['KR'])) $HEAD['title']['KR']=$col;
|
||
if(trim($value)=='КП') if(!isset($HEAD['title']['KP'])) $HEAD['title']['KP']=$col;
|
||
if(!isset($HEAD['KAF'])&&trim($value)=='Код') $HEAD['KAF']=$col;
|
||
//Лек Лаб Пр СРП СР КРАт Конт роль Формы контр. Итого
|
||
$HEAD['cols'][$col]=$value;//тут лежат все столбцы ключи = номер столбца!
|
||
$HEAD['cols1'][$value]=$col;//тут лежат все столбцы номер столбца = ключи!
|
||
}
|
||
if($row>5){//тут находятся данные
|
||
break;//тут можем уже не ходить по столбцам!!!
|
||
}
|
||
}
|
||
}
|
||
else{//Надо разобраться с курсами и семетсрами
|
||
//у заочников семестры=сессии, делаем так 1и2 сессия = 1 семестру 3 сессия=2 семестру...
|
||
//в планах бывает не по 5 курсов есть и по три курса!
|
||
//обходим курсы
|
||
$semi=0;
|
||
foreach($HEAD['SEM'] as $sem => $colS){
|
||
foreach($HEAD['KURS'] as $kurs => $colK){
|
||
if(isset($HEAD['KURS'][$kurs+1])) $endK = $HEAD['KURS'][$kurs+1]; else $endK = $HEAD['KAF']-1;
|
||
if($colS>=$colK&&$colS<$endK){
|
||
$semi++;
|
||
$HEAD['KURSSEM1'][$kurs][$semi]['start']=$colS;
|
||
if(isset($HEAD['SEM'][$sem+1])) $endS = $HEAD['SEM'][$sem+1]; else $endS = $HEAD['KAF']-1;
|
||
$HEAD['KURSSEM1'][$kurs][$semi]['end']=$endS;
|
||
}
|
||
}
|
||
}
|
||
//if(count($HEAD['KURSSEM1'])) echo '<pre>'.print_r($HEAD['KURSSEM1'],1).'</pre>';
|
||
//KURSSEM1 в некоторых курсах может быть один или два или три семестра! надо упорядочить!
|
||
$sem=0;
|
||
foreach($HEAD['KURSSEM1'] as $kurs => $valK){
|
||
if(count($valK)==3){//есть первый семестр-УСТАНОВОЧНЫЙ его не берем
|
||
$first=false;
|
||
}else{
|
||
$first=true;
|
||
}
|
||
|
||
foreach($valK as $semi => $valS){
|
||
if($first==true){
|
||
$sem++;
|
||
$HEAD['KURSSEM'][$kurs][$sem]=$valS;
|
||
}
|
||
$first=true;
|
||
}
|
||
}
|
||
}
|
||
$tr['ezfo_ze']='';
|
||
//echo '<pre>'.print_r($HEAD['cols'],1).'</pre>';// exit();
|
||
if(isset($HEAD['cols'])&&count($HEAD['cols'])) foreach($HEAD['cols'] as $col => $title){//формируем заголовок дисциплины
|
||
$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||
$value = $cell->getValue(); //echo '$row='.$row.'; $col='.$col.'; $value=['.$value.']<br>';
|
||
if($title=='Считать в плане') $tr['schitatVplane'] = $value;
|
||
if($title=='Индекс') $tr['index'] = $value;
|
||
if($title=='Наименование') $tr['name'] = $value;
|
||
if($fo!='z'){//у заочников в форме котнроля это стоит! гл в практиках не стоит зачет с оценкой!
|
||
if($title=='Экза мен') $tr['ekzamen'] = $value;
|
||
if($title=='Экзамен') $tr['ekzamen'] = $value;
|
||
if($title=='Зачет') $tr['zachet'] = $value;
|
||
if($title=='Зачет с оц.') $tr['zachetsocenk'] = $value;
|
||
if($title=='КР') $tr['kr'] = $value;
|
||
if($title=='КП') $tr['kp'] = $value;
|
||
}
|
||
//У Заочников ЗЕ беруться из поля З.Е. Экспер тное
|
||
if($title=='Экспер тное') if($tr['ezfo_ze']=='') $tr['ezfo_ze'] = $value;
|
||
if($title=='Экспертное') if($tr['ezfo_ze']=='') $tr['ezfo_ze'] = $value;
|
||
if($title=='Зачет с оц.') $tr['zachetsocenk'] = $value;
|
||
//if(isset($tr['name'])&&$title=='Наименование') $tr['kafname'] = $value;//стоит последним
|
||
if($col>=$HEAD['SEM'][1]) {
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['KAF'], $row);
|
||
$value = $cell->getValue();
|
||
$tr['kafcod'] = $value;
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['KAF']+1, $row);
|
||
$value = $cell->getValue();
|
||
$tr['kafname'] = $value;
|
||
break;//дальше первого семестра не надо идти
|
||
}
|
||
}
|
||
//if($row==74){
|
||
// echo '+++<pre>'.print_r($tr,1).'</pre>';
|
||
//}
|
||
$sbit=0;
|
||
//в некоторых планах сбиты строки сдвинуты влево!!!
|
||
if($tr['index']==''){
|
||
$sbit=1;
|
||
$cell = $worksheet->getCellByColumnAndRow(1, $row);
|
||
$tr['index'] = $cell->getValue();
|
||
}
|
||
if($tr['name']==''){
|
||
$sbit=1;
|
||
$cell = $worksheet->getCellByColumnAndRow(3, $row);
|
||
$tr['name'] = $cell->getValue();
|
||
}
|
||
if($tr['ekzamen']==0&&$sbit==1){
|
||
if(isset($HEAD['cols1']['Экза мен'])) $ccol = $HEAD['cols1']['Экза мен'];
|
||
elseif(isset($HEAD['cols1']['Экзамен'])) $ccol = $HEAD['cols1']['Экзамен'];
|
||
else $ccol = 5;
|
||
$cell = $worksheet->getCellByColumnAndRow($ccol, $row);
|
||
$tr['ekzamen'] = $cell->getValue();
|
||
}
|
||
if($tr['zachet']==0&&$sbit==1){
|
||
if(isset($HEAD['cols1']['Зачет'])) $ccol = $HEAD['cols1']['Зачет'];
|
||
else $ccol = 7;
|
||
$cell = $worksheet->getCellByColumnAndRow($ccol, $row);
|
||
$tr['zachet'] = $cell->getValue();
|
||
}
|
||
if($tr['zachetsocenk']==0&&$sbit==1){
|
||
if(isset($HEAD['cols1']['Зачет с оц.'])) $ccol = $HEAD['cols1']['Зачет с оц.'];
|
||
else $ccol = 9;
|
||
$cell = $worksheet->getCellByColumnAndRow($ccol, $row);
|
||
$tr['zachetsocenk'] = $cell->getValue();
|
||
}
|
||
if($tr['kp']==0&&$sbit==1){
|
||
if(isset($HEAD['cols1']['КП'])) {
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['cols1']['КП'], $row);
|
||
$tr['kp'] = $cell->getValue();
|
||
}
|
||
}
|
||
if($tr['kr']==0&&$sbit==1){
|
||
if(isset($HEAD['cols1']['КР'])) {
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['cols1']['КР'], $row);
|
||
$tr['kr'] = $cell->getValue();
|
||
}
|
||
}
|
||
if($tr['kafcod']==''&&$sbit==1){
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['KAF']-1, $row);
|
||
$tr['kafcod'] = $cell->getValue();
|
||
}
|
||
if($tr['kafname']==''&&$sbit==0){
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['KAF']+2, $row);
|
||
$tr['kafname'] = $cell->getValue();
|
||
if($tr['kafname']==''){
|
||
$cell = $worksheet->getCellByColumnAndRow($HEAD['KAF']-1, $row);
|
||
$tr['kafname'] = $cell->getValue();
|
||
}
|
||
}
|
||
//$tr['kafcod'] .= '|'.$HEAD['KAF'].'|'.($HEAD['KAF']-1);
|
||
|
||
//надо проверить sbit тут может и не надо сдвигать!
|
||
//каждые семестр начинается с з.е. будем это проверять
|
||
//$ff = $this->array_first($HEAD['KURSSEM']); print_r($ff); exit();
|
||
if($HEAD['cols'][$HEAD['KURSSEM'][1][1]['start']]=='з.е.') $sbit=0;
|
||
|
||
if(isset($HEAD['KURSSEM'])&&count($HEAD['KURSSEM'])) foreach($HEAD['KURSSEM'] as $kurs => $semar){//формируем по семестрам!
|
||
if (count($semar)==3) $csemar=3; else $csemar=2;//сдвинуть семестры! установочной сессии нет
|
||
foreach($semar as $sem => $diap){
|
||
for($col=$diap['start'];$col<$diap['end'];$col++){
|
||
$cell = $worksheet->getCellByColumnAndRow($col-$sbit, $row);
|
||
//$cell = $worksheet->getCellByColumnAndRow($col, $row);
|
||
$value = $cell->getValue();
|
||
|
||
if($csemar==3){
|
||
if ($sem==1) continue; if ($sem==2) $sem1=1; if ($sem==3) $sem1=2;
|
||
if ($sem==4) continue; if ($sem==5) $sem1=3; if ($sem==6) $sem1=4;
|
||
if ($sem==7) continue; if ($sem==8) $sem1=5; if ($sem==9) $sem1=6;
|
||
if ($sem==10) continue; if ($sem==11) $sem1=7; if ($sem==12) $sem1=8;
|
||
if ($sem==13) continue; if ($sem==14) $sem1=9; if ($sem==15) $sem1=10;
|
||
if ($sem==16) continue; if ($sem==17) $sem1=11; if ($sem==18) $sem1=12;
|
||
}else{
|
||
$sem1= $sem;
|
||
}
|
||
|
||
if(!isset($tr['data'][$kurs][$sem1]['ze'])) {
|
||
if ($HEAD['cols'][$col] == 'з.е.' && $value != '') {
|
||
$tr['data'][$kurs][$sem1]['ze'] = $value;
|
||
}
|
||
}
|
||
if($HEAD['cols'][$col]=='Лек'&&$value!='') $tr['data'][$kurs][$sem1]['lekcii'] = $value;
|
||
if($HEAD['cols'][$col]=='Лаб'&&$value!='') {
|
||
if(!isset($tr['data'][$kurs][$sem1]['labs'])) $tr['data'][$kurs][$sem1]['labs']=0;
|
||
$tr['data'][$kurs][$sem1]['labs'] += $value;
|
||
}
|
||
if($HEAD['cols'][$col]=='Пр'&&$value!='') {
|
||
if(!isset($tr['data'][$kurs][$sem1]['pr'])) $tr['data'][$kurs][$sem1]['pr']=0;
|
||
$tr['data'][$kurs][$sem1]['pr'] += $value;
|
||
}
|
||
if($HEAD['cols'][$col]=='Кл'&&$value!='') {
|
||
if(!isset($tr['data'][$kurs][$sem1]['labs'])) $tr['data'][$kurs][$sem1]['labs']=0;
|
||
$tr['data'][$kurs][$sem1]['labs'] += $value;
|
||
}
|
||
if($HEAD['cols'][$col]=='Сем'&&$value!='') {
|
||
if(!isset($tr['data'][$kurs][$sem1]['pr'])) $tr['data'][$kurs][$sem1]['pr']=0;
|
||
$tr['data'][$kurs][$sem1]['pr'] += $value;
|
||
}
|
||
//В XL файле Лечебное дело 31.05.01 строка 46 Б1.О.41 Госпитальная терапия, эндокринология
|
||
//в столбцах 220,241, 262 «СЗ» отображены часы отведенные на «Симуляционные занятия»,
|
||
//которые не отображаются в рабочих программах
|
||
if($HEAD['cols'][$col]=='СЗ'&&$value!='') {
|
||
if(!isset($tr['data'][$kurs][$sem1]['sz'])) $tr['data'][$kurs][$sem1]['sz']=0;
|
||
$tr['data'][$kurs][$sem1]['sz'] += $value;
|
||
}
|
||
if($HEAD['cols'][$col]=='СРП'&&$value!='') $tr['data'][$kurs][$sem1]['srp'] = $value;
|
||
if($HEAD['cols'][$col]=='СРП пр. подгот'&&$value!='') $tr['data'][$kurs][$sem1]['srpprpo'] = $value;
|
||
if($HEAD['cols'][$col]=='СР'&&$value!='') $tr['data'][$kurs][$sem1]['sr'] = $value;
|
||
if($HEAD['cols'][$col]=='СР пр. подгот'&&$value!='') $tr['data'][$kurs][$sem1]['srprpo'] = $value;
|
||
if($HEAD['cols'][$col]=='КРАт'&&$value!='') $tr['data'][$kurs][$sem1]['krat'] = $value;
|
||
if($HEAD['cols'][$col]=='КРаТ'&&$value!='') $tr['data'][$kurs][$sem1]['krat'] = $value;
|
||
if($HEAD['cols'][$col]=='Конт роль'&&$value!='') $tr['data'][$kurs][$sem1]['kontrol'] = $value;
|
||
if($HEAD['cols'][$col]=='Контроль'&&$value!='') $tr['data'][$kurs][$sem1]['kontrol'] = $value;
|
||
if($HEAD['cols'][$col]=='Формы контр.'&&$value!='') {
|
||
if($sem1==10) $sem1='A';
|
||
if($sem1==11) $sem1='B';
|
||
if($sem1==12) $sem1='C';
|
||
if (strpos($value, 'э') !== false) if(!strpos($tr['ekzamen'],$sem1)) $tr['ekzamen'] .= $sem1;
|
||
if (strpos($value, 'р') !== false) if(!strpos($tr['kr'],$sem1)) $tr['kr'] .= $sem1;
|
||
if (strpos($value, 'з') !== false) if(!strpos($tr['zachet'],$sem1)) $tr['zachet'] .= $sem1;
|
||
if (strpos($value, 'п') !== false) if(!strpos($tr['kp'],$sem1)) $tr['kp'] .= $sem1;
|
||
if (strpos($value, 'к') !== false) if(!strpos($tr['kontrol'],$sem1)) $tr['kontrol'] .= $sem1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$tmp = $this->prepare_tr($tr,$title,$file,$praktik,$GEKTD,$id_file);
|
||
//echo $row.'<pre>'.print_r($tr,1).'</pre>';
|
||
$GEKTD = $tmp['GEKTD'];
|
||
//echo $row.'::'.$tr['name'].'<br>';
|
||
//if($tr['name']=='Основы сестринского дела'){
|
||
//echo $row.'<pre>'.print_r($tr,1).'</pre>';
|
||
//echo $sbit.'<pre>'.print_r($HEAD['cols'],1).'</pre>';
|
||
//echo '<pre>'.print_r($tmp,1).'</pre>';
|
||
//exit();
|
||
//}
|
||
$out = array_merge($out, $tmp['out']);
|
||
$tr1[]=$tr;
|
||
$tr=array();
|
||
}
|
||
//echo '<pre>'.print_r($out,1).'</pre>'; exit();
|
||
return $out;
|
||
}
|
||
function array_first($array, $default = null){
|
||
foreach ($array as $item) {
|
||
return $item;
|
||
}
|
||
return $default;
|
||
}
|
||
function prepare_tr($tr,$title,$file,$praktik,$GEKTD,$id_file){
|
||
GLOBAL $isFILIAL;
|
||
$out=array();
|
||
|
||
//Для заочников ЗЕ берем из Экспертное З.Е.
|
||
if(isset($tr['ezfo_ze'])&&$tr['ezfo_ze']!='') {
|
||
foreach ($tr['data'] as $k => $v)foreach ($v as $s => $d){
|
||
if(!isset($d['ze'])) $tr['data'][$k][$s]['ze'] = $tr['ezfo_ze'];
|
||
}
|
||
}
|
||
if(count($tr)) {
|
||
if(isset($tr['name'])&&$tr['name']!='') {
|
||
//надо подправить Филиал Яблоновку
|
||
if($isFILIAL) {
|
||
$tr['kafcod'] = '0'.$tr['kafcod'].'Я';
|
||
}
|
||
//$disc_isk = array('Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы');
|
||
if (
|
||
(strpos($tr['name'], 'государственного экзамена') !== false)OR
|
||
(strpos($tr['name'], 'итогового экзамена') !== false)OR
|
||
(strpos($tr['name'], 'ащита выпуск') !== false)OR
|
||
(strpos($tr['name'], 'ащита ВКР') !== false)) {
|
||
if($GEKTD==false){//два раза этот блок не записываем
|
||
$tr['ekzamen'] = 0;
|
||
$tr['zachet'] = 0;
|
||
$tr['zachetsocenk'] = 0;
|
||
$tr['kr'] = 0;
|
||
$tr['name'] = 'ОЛ';
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['name'] = 'ГЭК';
|
||
if(isset($tr['data'])&&count($tr['data']))foreach($tr['data'] as $kurs1 => $ff) {
|
||
foreach($ff as $seme1 => $ff1) {
|
||
if(isset($tr['data'][$kurs1][$seme1]['lekcii'])){
|
||
$tr['data'][$kurs1][$seme1]=array();
|
||
}
|
||
}
|
||
}
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['name'] = 'РИН';
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['name'] = 'ПГЭК';
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['name'] = 'ЗВКР';
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['name'] = 'РВКР';
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$GEKTD=true;
|
||
}
|
||
//if(in_array($tr['name'],$disc_isk)){//Запишем эти дисциплины
|
||
// $tr['name'] = trim($tr['name']);
|
||
// $this->save_db_plans($file,$tr,$id_file);
|
||
// $out[] = $tr;
|
||
//}
|
||
}
|
||
else{
|
||
$pr=false;
|
||
$tr['name'] = trim($tr['name']);
|
||
$dataclear = $tr['data'];
|
||
foreach($praktik as $k9 => $v9){
|
||
if (strpos($v9['name'], $tr['name']) !== false) {//находим практику и заносим
|
||
$pr=true;
|
||
$tr['name'] = $v9['name'];
|
||
if($v9['kurs']==1){ if($v9['seme']==1) $s9 = 1; if($v9['seme']==2) $s9 = 2; }
|
||
if($v9['kurs']==2){ $s9 = $v9['seme']; if($v9['seme']==1) $s9 = 3; if($v9['seme']==2) $s9 = 4; }
|
||
if($v9['kurs']==3){ $s9 = $v9['seme']; if($v9['seme']==1) $s9 = 5; if($v9['seme']==2) $s9 = 6; }
|
||
if($v9['kurs']==4){ $s9 = $v9['seme']; if($v9['seme']==1) $s9 = 7; if($v9['seme']==2) $s9 = 8; }
|
||
if($v9['kurs']==5){ $s9 = $v9['seme']; if($v9['seme']==1) $s9 = 9; if($v9['seme']==2) $s9 = 10; }
|
||
if($v9['kurs']==6){ $s9 = $v9['seme']; if($v9['seme']==1) $s9 = 11; if($v9['seme']==2) $s9 = 12; }
|
||
|
||
if(isset($tr['zachet'])) $tr['zachet']=$s9;
|
||
if(isset($tr['zachetsocenk'])) $tr['zachet']=$s9;
|
||
if($tr['zachet']==10) $tr['zachet']='A';
|
||
if($tr['zachet']==11) $tr['zachet']='B';
|
||
if($tr['zachet']==12) $tr['zachet']='C';
|
||
|
||
$tr['data'][$v9['kurs']][$s9]['tp']=$tr['tp']=$v9['tp'];
|
||
if(strpos($tr['tp'],'Научно-исследовательская')!==FALSE){ //НИР практика
|
||
$tr['data'][$v9['kurs']][$s9]['nir_pr'] = $v9['days'];
|
||
}
|
||
if(strpos($tr['tp'],'Преддипломная')!==FALSE){ //Преддипл. практика (количество недель)
|
||
$tr['data'][$v9['kurs']][$s9]['preddip_prakt'] = $v9['week'];
|
||
}
|
||
if(strpos($tr['tp'],'Производственная')!==FALSE){ //Производственная практика (количество дней)
|
||
$tr['data'][$v9['kurs']][$s9]['proizv_prakt'] = $v9['days'];
|
||
}
|
||
if(strpos($tr['tp'],'Учебная')!==FALSE){ //Производственная практика (количество дней)
|
||
$tr['data'][$v9['kurs']][$s9]['ucheb_prakt'] = $v9['days'];
|
||
}
|
||
if(strpos($tr['tp'],'полевая')!==FALSE){ //Учебная практика (полевая) (кол-во рабочих дней)
|
||
$tr['data'][$v9['kurs']][$s9]['ucheb_prakt_polev'] = $v9['days'];
|
||
}
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
$tr['data']=$dataclear;
|
||
}
|
||
}
|
||
if($pr==false){//не практика а предмет
|
||
//file_put_contents($json,json_encode($tr)."\n",FILE_APPEND);
|
||
$this->save_db_plans($file,$tr,$id_file);
|
||
$out[] = $tr;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return array('GEKTD'=>$GEKTD,'out'=>$out);
|
||
}
|
||
|
||
function checkSems($str){
|
||
$out=array();
|
||
$sems = str_split($str);//разобъем на символы
|
||
$m1=array('A','B','C');
|
||
$m2=array(10,11,12);
|
||
foreach($sems as $k => $v){
|
||
$tmp = str_replace($m1,$m2,$v);
|
||
$out[] = floatval($tmp);
|
||
}
|
||
return $out;
|
||
}
|
||
|
||
function parse_semestrs($string){
|
||
if(strpos($string, 'A')!==false) $string = str_replace('A',',10,',$string);
|
||
if(strpos($string, 'B')!==false) $string = str_replace('B',',11,',$string);
|
||
if(strpos($string, 'C')!==false) $string = str_replace('C',',12,',$string);
|
||
$tmp=explode(',',$string);
|
||
if($tmp[0]!='') $string = $tmp[0];
|
||
else if($tmp[1]!='') $string = $tmp[1];
|
||
else if($tmp[2]!='') $string = $tmp[2];
|
||
return $string;
|
||
}
|
||
|
||
/**
|
||
* Сохранение плана в базу
|
||
* @param $file
|
||
* @param $data
|
||
* @param $id_file
|
||
*/
|
||
function save_db_plans($file,$data,$id_file){
|
||
GLOBAL $ST,$DB; //return array();
|
||
$data['json']=$DB->rescape(json_encode($data['data']));
|
||
unset($data['data']);
|
||
foreach($data as $k => $v) if($k!='json') $data[$k] = $DB->rescape(trim($v));
|
||
if(!isset($data['kafcod'])) $data['kafcod']=0;
|
||
if(!isset($data['kafname'])) $data['kafname']='';
|
||
if(!isset($data['ekzamen'])) $data['ekzamen']=0; else if($data['ekzamen']=='') $data['ekzamen']=0;
|
||
$data['ekzamen'] = $this->parse_semestrs($data['ekzamen']);
|
||
|
||
if(!isset($data['zachet'])) $data['zachet']=0; else if($data['zachet']=='') $data['zachet']=0;
|
||
$data['zachet'] = $this->parse_semestrs($data['zachet']);
|
||
|
||
if(!isset($data['zachetsocenk'])) $data['zachetsocenk']=0; else if($data['zachetsocenk']=='') $data['zachetsocenk']=0; else $data['zachetsocenk']=(int)$data['zachetsocenk'];
|
||
$data['zachetsocenk'] = $this->parse_semestrs($data['zachetsocenk']);
|
||
|
||
if(!isset($data['kr'])) $data['kr']=0; else if($data['kr']=='') $data['kr']=0;
|
||
$data['kr'] = $this->parse_semestrs($data['kr']);
|
||
|
||
if(!isset($data['kp'])) $data['kp']=0; else if($data['kp']=='') $data['kp']=0;
|
||
$data['kp'] = $this->parse_semestrs($data['kp']);
|
||
|
||
if(!isset($data['kontrol'])) $data['kontrol']=0; else if($data['kontrol']=='') $data['kontrol']=0;
|
||
$data['kontrol'] = $this->parse_semestrs($data['kontrol']);
|
||
|
||
|
||
if($data['index']=='Индекс') return false;
|
||
if(!is_numeric($data['ekzamen'])) $data['ekzamen']=0;
|
||
if(!is_numeric($data['zachetsocenk'])) $data['zachetsocenk']=0;
|
||
if(!is_numeric($data['kr'])) $data['kr']=0;
|
||
if(!is_numeric($data['kp'])) $data['kp']=0;
|
||
if(!is_numeric($data['kontrol'])) $data['kontrol']=0;
|
||
|
||
//$sql = 'SELECT id FROM '.$ST['dbpf'].'_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="'.$data['index'].'" AND name="'.$data['name'].'" AND ekzamen='.$data['ekzamen'].' AND zachet='.$data['zachet'].' AND zachetsocenk='.$data['zachetsocenk'].' AND kr='.$data['kr'].' AND kp='.$data['kp'].' AND kontrol='.$data['kontrol'].' AND json="'.$data['json'].'" AND kaf_kod="'.$data['kafcod'].'" AND kaf_name="'.$data['kafname'].'"';
|
||
if($this->planINSERTdb==1) {
|
||
$sql = 'SELECT id FROM ' . $ST['dbpf'] . '_fshp_uchebplans WHERE id_file=' . $id_file . ' AND index1="' . $data['index'] . '"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';//exit();
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
foreach ($rez['rez'] as $k0 => $v0) {
|
||
$sql = 'UPDATE ' . $ST['dbpf'] . '_fshp_uchebplans SET index1="' . $data['index'] . '",name="' . $data['name'] . '",ekzamen=' . $data['ekzamen'] . ',zachet=' . $data['zachet'] . ',zachetsocenk=' . $data['zachetsocenk'] . ',kr=' . $data['kr'] . ',kp=' . $data['kp'] . ',kontrol=' . $data['kontrol'] . ',json="' . $data['json'] . '",kaf_kod="' . $data['kafcod'] . '",kaf_name="' . $data['kafname'] . '" WHERE id=' . $v0['id'];
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
} else {
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_uchebplans VALUES(0,' . $id_file . ',"' . $data['index'] . '","' . $data['name'] . '",' . $data['ekzamen'] . ',' . $data['zachet'] . ',' . $data['zachetsocenk'] . ',' . $data['kr'] . ',' . $data['kp'] . ',' . $data['kontrol'] . ',"' . $data['json'] . '",1,"' . $data['kafcod'] . '","' . $data['kafname'] . '")';
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
}else{
|
||
$data['json1'] = json_decode(stripslashes($data['json']),1);
|
||
$this->planINSERTarray[$data['index']]=$data;
|
||
}
|
||
//echo '2:'.$sql.'<pre>'.print_r($rez,1).'</pre>';
|
||
|
||
}
|
||
//тут дисциплина разбивается на семестры, в этой системе так не надо!
|
||
function save_db_plans_old($file,$data,$id_file){
|
||
GLOBAL $ST,$DB; //return array();
|
||
$data['json']=$DB->rescape(json_encode($data['data']));
|
||
unset($data['data']);
|
||
foreach($data as $k => $v) if($k!='json') $data[$k] = $DB->rescape(trim($v));
|
||
if(!isset($data['kafcod'])) $data['kafcod']=0;
|
||
if(!isset($data['kafname'])) $data['kafname']='';
|
||
$Iekzamen=array(); $Izachet=array(); $Izachetsocenk=array(); $Ikr=array(); $Ikp=array(); $Ikontrol=array();
|
||
if(!isset($data['ekzamen'])) $data['ekzamen']=0; else {
|
||
$tmp = $this->checkSems($data['ekzamen']);
|
||
if(count($tmp)>1){ $Iekzamen = $tmp; }else{ $data['ekzamen']=$tmp[0]; }
|
||
}
|
||
if(!isset($data['zachet'])) $data['zachet']=0; else {
|
||
$tmp = $this->checkSems($data['zachet']);
|
||
if(count($tmp)>1){ $Izachet = $tmp; }else{ $data['zachet']=$tmp[0]; }
|
||
}
|
||
if(!isset($data['zachetsocenk'])) $data['zachetsocenk']=0; else {
|
||
$tmp = $this->checkSems($data['zachetsocenk']);
|
||
if(count($tmp)>1){ $Izachetsocenk = $tmp; }else{ $data['zachetsocenk']=$tmp[0]; }
|
||
}
|
||
if(!isset($data['kr'])) $data['kr']=0; else {
|
||
$tmp = $this->checkSems($data['kr']);
|
||
if(count($tmp)>1){ $Ikr = $tmp; }else{ $data['kr']=$tmp[0]; }
|
||
}
|
||
if(!isset($data['kp'])) $data['kp']=0; else {
|
||
$tmp = $this->checkSems($data['kp']);
|
||
if(count($tmp)>1){ $Ikp = $tmp; }else{ $data['kp']=$tmp[0]; }
|
||
}
|
||
if(!isset($data['kontrol'])) $data['kontrol']=0; else {
|
||
$tmp = $this->checkSems($data['kontrol']);
|
||
if(count($tmp)>1){ $Ikontrol = $tmp; }else{ $data['kontrol']=$tmp[0]; }
|
||
}
|
||
|
||
//$data['zachet'] $data['ekzamen'] $data['zachetsocenk'] $data['kr'] $data['kontrol'] тут может быть и 56 и 123456 и А!!!!
|
||
if(count($Iekzamen)||count($Izachet)||count($Izachetsocenk)||count($Ikr)||count($Ikp)||count($Ikontrol)){//несколько
|
||
$result = array_merge($Iekzamen, $Izachet,$Izachetsocenk,$Ikr,$Ikp,$Ikontrol); //сольем все в один
|
||
$result = array_unique($result);//сделаем уникальным
|
||
foreach($result as $k => $val){
|
||
$data['ekzamen']=0; $data['zachet']=0; $data['zachetsocenk']=0; $data['kr']=0; $data['kp']=0; $data['kontrol']=0;
|
||
if (in_array($val, $Iekzamen)) { $data['ekzamen']=$val; }
|
||
if (in_array($val, $Izachet)) { $data['zachet']=$val; }
|
||
if (in_array($val, $Izachetsocenk)) { $data['zachetsocenk']=$val; }
|
||
if (in_array($val, $Ikr)) { $data['kr']=$val; }
|
||
if (in_array($val, $Ikp)) { $data['kp']=$val; }
|
||
if (in_array($val, $Ikontrol)) { $data['kontrol']=$val; }
|
||
if($data['ekzamen']!=0||$data['zachet']!=0||$data['zachetsocenk']!=0||$data['kr']!=0||$data['kp']!=0||$data['kontrol']!=0){
|
||
$sql = 'SELECT id FROM '.$ST['dbpf'].'_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="'.$data['index'].'" AND name="'.$data['name'].'" AND ekzamen='.$data['ekzamen'].' AND zachet='.$data['zachet'].' AND zachetsocenk='.$data['zachetsocenk'].' AND kr='.$data['kr'].' AND kp='.$data['kp'].' AND kontrol='.$data['kontrol'].' AND json="'.$data['json'].'" AND kafcod="'.$data['kafcod'].'" AND kafname="'.$data['kafname'].'"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach ($rez['rez'] as $k0 => $v0) {
|
||
$sql = 'UPDATE ' . $ST['dbpf'] . '_fshp_uchebplans SET index1="' . $data['index'] . '",name="' . $data['name'] . '",ekzamen=' . $data['ekzamen'] . ',zachet=' . $data['zachet'] . ',zachetsocenk=' . $data['zachetsocenk'] . ',kr=' . $data['kr'] . ',kp=' . $data['kp'] . ',kontrol=' . $data['kontrol'] . ',json="' . $data['json'] . '",kaf_kod="' . $data['kafcod'] . '",kaf_name="' . $data['kafname'] . '" WHERE id=' . $v0['id'];
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
}else {
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_uchebplans VALUES(0,' . $id_file . ',"' . $data['index'] . '","' . $data['name'] . '",' . $data['ekzamen'] . ',' . $data['zachet'] . ',' . $data['zachetsocenk'] . ',' . $data['kr'] . ',' . $data['kp'] . ',' . $data['kontrol'] . ',"' . $data['json'] . '",1,"' . $data['kafcod'] . '","' . $data['kafname'] . '")';
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
//echo '1:'.$sql.'<pre>'.print_r($rez,1).'</pre>';
|
||
}
|
||
}
|
||
}else{
|
||
$sql = 'SELECT id FROM '.$ST['dbpf'].'_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="'.$data['index'].'" AND name="'.$data['name'].'" AND ekzamen='.$data['ekzamen'].' AND zachet='.$data['zachet'].' AND zachetsocenk='.$data['zachetsocenk'].' AND kr='.$data['kr'].' AND kp='.$data['kp'].' AND kontrol='.$data['kontrol'].' AND json="'.$data['json'].'" AND kaf_kod="'.$data['kafcod'].'" AND kaf_name="'.$data['kafname'].'"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
//echo '<pre>'.print_r($rez,1).'</pre>';exit();
|
||
if(!$rez['err']&&$rez['kol']){
|
||
foreach ($rez['rez'] as $k0 => $v0) {
|
||
$sql = 'UPDATE ' . $ST['dbpf'] . '_fshp_uchebplans SET index1="' . $data['index'] . '",name="' . $data['name'] . '",ekzamen=' . $data['ekzamen'] . ',zachet=' . $data['zachet'] . ',zachetsocenk=' . $data['zachetsocenk'] . ',kr=' . $data['kr'] . ',kp=' . $data['kp'] . ',kontrol=' . $data['kontrol'] . ',json="' . $data['json'] . '",kaf_kod="' . $data['kafcod'] . '",kaf_name="' . $data['kafname'] . '" WHERE id='.$v0['id'];
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
}else {
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_uchebplans VALUES(0,' . $id_file . ',"' . $data['index'] . '","' . $data['name'] . '",' . $data['ekzamen'] . ',' . $data['zachet'] . ',' . $data['zachetsocenk'] . ',' . $data['kr'] . ',' . $data['kp'] . ',' . $data['kontrol'] . ',"' . $data['json'] . '",1,"' . $data['kafcod'] . '","' . $data['kafname'] . '")';
|
||
$rez = $DB->QUR($sql);
|
||
}
|
||
//echo '2:'.$sql.'<pre>'.print_r($rez,1).'</pre>';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Сохранение титула в базу $table=0 не сохраняет
|
||
* @param $file
|
||
* @param $data
|
||
* @param $id_file
|
||
* @param $table
|
||
* @return mixed
|
||
*/
|
||
function save_db_title($file,$data,$id_file,$table=1){
|
||
GLOBAL $ST,$DB;
|
||
if(!isset($data['json'])) $data['json']='';
|
||
$m1=array('по программе','Направление подготовки','Квалификация:','Форма обучения:','Срок получения образования:','Специальность',':','подготовки');
|
||
$m2=array('','','','','','','','');
|
||
foreach($data as $k => $v) $data[$k] = $DB->rescape(trim(str_replace($m1,$m2,$v)));
|
||
|
||
$m1=array('"','«','»',"'","\n","\r","\t",'\n','\r','\t','\\');
|
||
$m2=array('','','','','','','','','','');
|
||
$data['naprav'] = str_replace($m1,$m2,str_replace('Направление','',$data['naprav']));
|
||
$t = explode('Профиль',$data['naprav']);
|
||
$data['naprav'] = trim($t[0]);
|
||
if($data['profil']=='') $data['profil'] = trim($t[1]);
|
||
|
||
$data['program'] = $DB->rescape($data['program']);
|
||
$data['shifr'] = $DB->rescape($data['shifr']);
|
||
$data['naprav'] = $DB->rescape($data['naprav']);
|
||
$data['profil'] = $DB->rescape($data['profil']);
|
||
$data['kafedra'] = $DB->rescape($data['kafedra']);
|
||
$data['fakultet'] = $DB->rescape($data['fakultet']);
|
||
$data['kvalif'] = $DB->rescape($data['kvalif']);
|
||
$data['god_nach_podgot'] = $DB->rescape($data['god_nach_podgot']);
|
||
$data['fo'] = $DB->rescape($data['fo']);
|
||
$data['obr_stabdart'] = $DB->rescape($data['obr_stabdart']);
|
||
$data['srok_poluch_obr'] = $DB->rescape($data['srok_poluch_obr']);
|
||
|
||
if($table==1) {
|
||
$sql = 'SELECT * FROM ' . $ST['dbpf'] . '_fshp_file WHERE id_file=' . $id_file . ' AND program="' . $data['program'] . '" AND shifr="' . $data['shifr'] . '" AND naprav="' . $data['naprav'] . '" AND profil="' . $data['profil'] . '" AND kafedra="' . $data['kafedra'] . '" AND fakultet="' . $data['fakultet'] . '" AND kvalif="' . $data['kvalif'] . '" AND god_nach_podgot=' . $data['god_nach_podgot'] . ' AND fo="' . $data['fo'] . '"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if (!$rez['err'] && $rez['kol']) {
|
||
$out = $rez['rez'][0];
|
||
$out['rez'] = 'был';
|
||
} else {//id data_c program shifr naprav profil kafedra fakultet kvalif god_nach_podgot fo obr_stabdart srok_poluch_obr json status
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_file VALUES(0,' . time() . ',' . $id_file . ',"' . $data['program'] . '","' . $data['shifr'] . '","' . $data['naprav'] . '","' . $data['profil'] . '","' . $data['kafedra'] . '","' . $data['fakultet'] . '","' . $data['kvalif'] . '",' . $data['god_nach_podgot'] . ',"' . $data['fo'] . '","' . $data['obr_stabdart'] . '","' . $data['srok_poluch_obr'] . '","' . $data['json'] . '",1)';
|
||
$rez = $DB->QUR($sql);
|
||
$out = $data;
|
||
$out['file'] = $file;
|
||
$out['rez'] = 'добавили';
|
||
}
|
||
}
|
||
$out = $data;
|
||
return $out;
|
||
}
|
||
/**
|
||
* Сохранение компетенций учебного плана
|
||
* @param $comp
|
||
* @param $discips
|
||
* @param $id_titles
|
||
*/
|
||
function save_db_competens($comp,$discips,$id_file){
|
||
GLOBAL $ST,$DB; //return array();
|
||
//echo '<pre>'.print_r($comp,1).print_r($discips,1).'</pre>';exit();
|
||
$comp['index'] = $DB->rescape($comp['index']);
|
||
$comp['comp'] = $DB->rescape($comp['comp']);
|
||
$sql = 'SELECT id FROM ' . $ST['dbpf'] . '_fshp_compet WHERE id_file='.$id_file.' AND `index`="' . $comp['index'] . '" AND descrip="'.$comp['comp'].'"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
//echo $sql.'<pre>'.print_r($rez,1).'--'.print_r($discips,1).'</pre>';exit();
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_compet = $rez['rez'][0]['id'];
|
||
}else{
|
||
if($this->planINSERTdb==1) {
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_compet VALUES (0,' . $id_file . ',"' . $comp['index'] . '","' . $comp['comp'] . '")';
|
||
$rez = $DB->QUR($sql);
|
||
if (!$rez['err']) {
|
||
$id_compet = $DB->lastinsertID();
|
||
} else {
|
||
$id_compet = 0;
|
||
}
|
||
}
|
||
}
|
||
if($id_compet!=0){
|
||
foreach($discips as $key => $val){
|
||
//$val['discip']=Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы
|
||
//А дисциплину мы записали как ЗВКР или РВКР (Защита ВКР и Руководство ВКР)
|
||
//if($val['discip']=='Выполнение, подготовка к процедуре защиты и защита выпускной квалификационной работы') $val['discip']='РВКР';
|
||
$sql = 'SELECT id FROM ' . $ST['dbpf'] . '_fshp_uchebplans WHERE id_file='.$id_file.' AND index1="' . $DB->rescape($val['shifr']) . '" AND name="'.trim($DB->rescape(trim($val['discip']))).'"';
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']){
|
||
$id_uchebplans = $rez['rez'][0]['id'];
|
||
|
||
$sql = 'SELECT id FROM ' . $ST['dbpf'] . '_fshp_uchebplans_compet WHERE id_uchebplans='.$id_uchebplans.' AND id_compet=' . $id_compet ;
|
||
$rez = $DB->QUR_SEL($sql);
|
||
if(!$rez['err']&&$rez['kol']) {
|
||
|
||
}else{
|
||
if($this->planINSERTdb==1) {
|
||
$sql = 'INSERT INTO ' . $ST['dbpf'] . '_fshp_uchebplans_compet VALUES (0,' . $id_uchebplans . ',' . $id_compet . ')';
|
||
$DB->QUR($sql);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |