EIOS/rabprog/workKomp.php

63 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

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

<?php
exit();
//Проверка связки компетенций и дисциплин $_GET['id_file']-конкретный УП, $_GET['do_it']=1 обновить
include_once 'config.php';
$id_file = 0; if(isset($_GET['id_file'])) $id_file = (int)$_GET['id_file'];
$do_it = 0; if(isset($_GET['do_it'])) $do_it = (int)$_GET['do_it'];
if($id_file==0) $sql = 'SELECT * FROM acs_fshp_files';
else $sql = 'SELECT * FROM acs_fshp_files WHERE id='.$id_file;
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$filer = $rez['rez'][0];
$id_file = $filer['id'];
$pi = pathinfo($filer['file']);
$file_comp = $pi['dirname'] . '/' . $pi['filename'] . '_comp.json';
$array = json_decode(file_get_contents($file_comp),1);
foreach ($array as $index => $val) {
if(isset($val['discips'])){
$rez1 = $DB->QUR_SEL('SELECT id FROM acs_fshp_compet WHERE id_file='.$id_file.' AND `index`="'.$index.'"');
if(!$rez1['err']&&$rez1['kol']) {
$id_compet = $rez1['rez'][0]['id'];
foreach ($val['discips'] as $key => $discip) {
$rez1 = $DB->QUR_SEL('SELECT id,index1,name FROM acs_fshp_uchebplans WHERE id_file='.$id_file.' AND `index1`="'.trim($discip['shifr']).'"');
if(!$rez1['err']&&$rez1['kol']) {
$id_uchebplan = $rez1['rez'][0]['id'];
$name = $rez1['rez'][0]['index1'].' '.$rez1['rez'][0]['name'];
$rez1 = $DB->QUR_SEL('SELECT id FROM acs_fshp_uchebplans_compet WHERE id_uchebplans='.$id_uchebplan.' AND id_compet='.$id_compet);
if(!$rez1['err']&&$rez1['kol']) {
$id_uchebplan_compet = $rez1['rez'][0]['id'];
//echo $id_file.':'.$id_compet.' :'.$id_uchebplan.'='.$id_uchebplan_compet.' есть связь<br>';
}else{
echo $id_file.':'.$id_compet.' :'.$id_uchebplan.' ['.$name.'] нет связи';
if($do_it) {
$rez1 = $DB->QUR('INSERT INTO acs_fshp_uchebplans_compet VALUES (0,' . $id_uchebplan . ',' . $id_compet . ')');
if (!$rez1['err']) echo ' - добавили'; else echo ' - не добавили';
}
echo '<br>';
}
}
}
}
}
}
//echo '<pre>'.print_r($array,1).'</pre>';
}
/*
SELECT * FROM `acs_fshp_compet` WHERE `id_file`=113 AND `index`="УК-1.1"
fshp_compet
id
18620
45926
50858
SELECT * FROM `acs_fshp_uchebplans` WHERE `id_file`=113 AND `name` LIKE "%Ознакомит%"
shp_uchebplans
id 18601
index1 Б2.О.01(У)
SELECT * FROM `acs_fshp_uchebplans_compet` WHERE `id_uchebplans`=18601
* */