57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
if(isset($_POST['save'])){
|
|
//echo '<pre>'.print_r($_POST,1).'</pre>'; exit();
|
|
foreach($_POST['value'] as $key => $val){
|
|
$t=explode('_',$key);
|
|
foreach($val as $tipfor => $val1){
|
|
$sql1 = 'SELECT id FROM '.$ST['dbpf'].'_rejtnr_celpok WHERE id_razdel='.$t[0].' AND id_items='.$t[1].' AND id_itemspolyas='.$t[2].' AND tipfor='.$tipfor.'';
|
|
$rez1 = $DB->QUR_SEL($sql1);
|
|
if($rez1){
|
|
$sql = 'UPDATE '.$ST['dbpf'].'_rejtnr_celpok SET celvalue="'.$val1['cel'].'",stimvalue="'.$val1['stim'].'" WHERE id='.$rez1[1]['id'].' LIMIT 1';
|
|
$rez = $DB->QUR($sql);
|
|
}else{
|
|
$sql = 'INSERT INTO '.$ST['dbpf'].'_rejtnr_celpok VALUES(0,'.$t[0].','.$t[1].','.$t[2].',0,"'.$val1['cel'].'","'.$val1['stim'].'",'.$tipfor.')';
|
|
$rez = $DB->QUR($sql);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$items=array();
|
|
$sql = 'SELECT
|
|
razdel.id as rid,razdel.name as rname,
|
|
items.id as iid,items.name as iname,
|
|
itemsp.id as ipid,itemsp.name as ipname
|
|
FROM
|
|
'.$ST['dbpf'].'_rejtnr_razdels as razdel,
|
|
'.$ST['dbpf'].'_rejtnr_items as items,
|
|
'.$ST['dbpf'].'_rejtnr_itemspolyas as itemsp
|
|
WHERE
|
|
items.id_razdel = razdel.id AND
|
|
itemsp.id_item = items.id AND
|
|
razdel.status = 1
|
|
ORDER BY
|
|
razdel.pos,
|
|
items.pos,
|
|
itemsp.pos';
|
|
$rez = $DB->QUR_SEL($sql);
|
|
if($rez){
|
|
foreach($rez as $key => $val)if($key){
|
|
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_rejtnr_celpok WHERE id_razdel='.$val['rid'].' AND id_items='.$val['iid'].' AND id_itemspolyas='.$val['ipid'].'';
|
|
$rez1 = $DB->QUR_SEL($sql1);
|
|
if($rez1){
|
|
foreach($rez1 as $key1 => $val1)if($key1){
|
|
$val['values'][$val1['tipfor']]['cel'] = $val1['celvalue'];
|
|
$val['values'][$val1['tipfor']]['stim'] = $val1['stimvalue'];
|
|
}
|
|
}
|
|
$items[] = $val;
|
|
}
|
|
}
|
|
|
|
$smarty->assign('items',$items);
|
|
$smarty->assign('page',$page);
|
|
$smarty->assign('des',$des);
|
|
$maincontent = $smarty->fetch('tpl_rejt_admincelpoknr.html'); |