EIOS/inc/rejtnr_anketa.php

115 lines
4.2 KiB
PHP
Raw Permalink Normal View History

2023-12-28 15:39:22 +03:00
<?php
$otchgods=array();//выберем активный отчетный период
unset($_SESSION['otchgods'][4]);
$sql = 'SELECT * FROM '.$TB['otchgods'].' WHERE status=1';
$rez = $DB->QUR_SEL($sql);
/*
echo '<pre>'.print_r($rez,1).'</pre>'; exit();
Array
(
[0] => 2
[1] => Array
(
[id] => 12
[data_c] => 1622531286
[tip] => 3
[data_s1] => 1577826000
[data_s2] => 1623704400
[name] => Эффективный контракт
[descrip] => НПР Эффективный контракт 2020-2021 год
[status] => 1
)
[2] => Array
(
[id] => 13
[data_c] => 1622531552
[tip] => 4
[data_s1] => 1577826000
[data_s2] => 1623704400
[name] => Эффективный контракт. Базовые показатели
[descrip] => НПР база 2020-2021 год
[status] => 1
)
)
*/
if($rez){
foreach($rez as $key => $val)if($key){
$otchgods = $val;
$otchgods['konec'] = 0; if(time()>=$otchgods['data_s2']) $otchgods['konec'] = 1;
if($_SESSION['user']['id']==4870||$_SESSION['user']['id']==19603){ $otchgods['konec']=0; }
$_SESSION['otchgods'][$otchgods['tip']] = $otchgods;//для подсчета баллов
}
}
//echo '<pre>'.print_r($otchgods,1).'</pre>';
$smarty->assign('otchgods',$otchgods);
$items=array(); $BALLS=0;
$sql = 'SELECT * FROM '.$TB['razdels'].' WHERE status=1 ORDER BY pos';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
$val['razdel']=array();
$sql1 = 'SELECT * FROM '.$TB['items'].' WHERE id_razdel='.$val['id'].' ORDER BY pos';
$rez1 = $DB->QUR_SEL($sql1); //echo $sql1.'<pre>'.print_r($rez1,1).'</pre>';
if($rez1){
foreach($rez1 as $key1 => $val1)if($key1){
$val1['itemspolyas']=array();
$sql2 = 'SELECT * FROM '.$TB['itemspolyas'].' WHERE id_item='.$val1['id'].' ORDER BY pos';
$rez2 = $DB->QUR_SEL($sql2); //echo $sql2.'<pre>'.print_r($rez2,1).'</pre>';
if($rez2){
$kolsaves=0;
foreach($rez2 as $key2 => $val2)if($key2){
$val2['polyas']=array();
//выбираем выпадающие элементы
$sql3 = 'SELECT * FROM '.$TB['polyas'].' WHERE id_item='.$val2['id'].' ORDER BY pos';
$rez3 = $DB->QUR_SEL($sql3); //echo $sql3.'<pre>'.print_r($rez3,1).'</pre>';
if($rez3){
foreach($rez3 as $key3 => $val3)if($key3){
$val2['polyas'][]=$val3;
}
}
$val2['saves']=array();
$sql4 = 'SELECT * FROM '.$TB['saves'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_razdel='.$val['id'].' AND id_items='.$val1['id'].' AND id_itemspolyas='.$val2['id'].' AND (data_c BETWEEN '.$_SESSION['otchgods'][4]['data_s1'].' AND '.$_SESSION['otchgods'][4]['data_s2'].') ORDER BY pos';
$rez4 = $DB->QUR_SEL($sql4); //echo $sql4.'<pre>'.print_r($rez4,1).'</pre>';
if($rez4){
if($rez4[0]>$kolsaves) $kolsaves=$rez4[0];
foreach($rez4 as $key4 => $val4)if($key4){
$val2['saves'][$val4['pos']+1]=$val4;
}
}
$val1['itemspolyas'][]=$val2;
}
}
$val1['kolsaves']=$kolsaves;
//$val1['formuls'] = rejt_raschet($val1['id'],$_SESSION['user']['id']);
//$BALLS+=$val1['formuls']['itogo'];
$val1['formuls1'] = $val1['formuls'];
$tmp01 = explode('|',$val1['formuls']);//определяем по формуле, пользователь вводит число или оно расчитывается
if(count($tmp01)==2&&$tmp01[0]==0){
$val1['edit'] = false;
//надо расчитать и сохранить в базу
$val1['formuls2'] = rejtnr_raschet($val1['id'],$_SESSION['user']['id']);
//$BALLS+=$val1['formuls2']['itogo'];
}else{
$val1['edit'] = true;
$val1['formuls'] = rejtnr_raschet($val1['id'],$_SESSION['user']['id']);
$BALLS+=$val1['formuls']['itogo'];
}
$val['razdel'][]=$val1;
}
}
$items[]=$val;
}
}
$smarty->assign('BALLS',$BALLS);
$smarty->assign('items',$items);
$smarty->assign('page',$page);
$smarty->assign('des',$des);
$maincontent = $smarty->fetch('tpl_rejtnr_anketa.html');