QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $val){
$id_file = $val['id'];
$pi = pathinfo($val['file']);
//$pi['filename']//1_3295_200501_PB_OFO_2022plx
//echo '
'.print_r($pi,1).'
';
$file = 'upload/shaht_xlsx/'.$pi['filename'].'_comp.json';
echo $file.'
';
if (file_exists($file)){
$array = json_decode(file_get_contents($file),1);
//echo ''.print_r($array,1).'
';
foreach($array as $kod => $v)if(isset($v['discips'])&&count($v['discips'])){
$index = $v['index'];
$id_co = get_comp($index,$id_file);
if($id_co) {
foreach ($v['discips'] as $k1 => $disc) {
$id_up = get_up($disc['shifr'], $disc['discip'], $id_file);
$id_upco = get_upcomp($id_up,$id_co);
if(!$id_upco && $id_up) {
echo '$id_file=' . $id_file . '; $index=' . $index . '; shifr=' . $disc['shifr'] . '; discip=' . $disc['discip'] . '; ';
echo '$id_co=' . $id_co . '; $id_up=' . $id_up . ';
';
$sql = 'INSERT INTO acs_fshp_uchebplans_compet VALUES(0,'.$id_up.','.$id_co.')';
$rez = $DB->QUR($sql);
}
}
}
}
}
//exit();
}
}
function get_upcomp($id_up,$id_compet){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_uchebplans_compet WHERE id_uchebplans="'.$id_up.'" AND id_compet='.$id_compet;
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}
function get_up($index,$name,$id_file){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_uchebplans WHERE index1="'.$index.'" AND name="'.$name.'" AND id_file='.$id_file.'';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}
function get_comp($index,$id_file){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_compet WHERE `index`="'.$index.'" AND id_file='.$id_file; //echo $sql.'
';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}