156 lines
4.6 KiB
PHP
156 lines
4.6 KiB
PHP
|
<?php
|
||
|
session_start();
|
||
|
$maincontent = '';
|
||
|
$smarty->assign('razdel','rejtnr');
|
||
|
if(isset($_GET['page'])){ $page=$_GET['page']; }else{ $page='main'; }
|
||
|
if(isset($_GET['des'])){ $des=$_GET['des']; }else{ $des='show';}
|
||
|
/*
|
||
|
echo '<pre>'.print_r($_POST,1).'</pre>';
|
||
|
echo '<pre>'.print_r($_GET,1).'</pre>';
|
||
|
[rejt] =>
|
||
|
[page] => admin1
|
||
|
[des] => add*/
|
||
|
$TB['razdels'] = $ST['dbpf'].'_rejtnr_razdels';
|
||
|
$TB['items'] = $ST['dbpf'].'_rejtnr_items';
|
||
|
$TB['polyas'] = $ST['dbpf'].'_rejtnr_polyas';
|
||
|
$TB['itemspolyas'] = $ST['dbpf'].'_rejtnr_itemspolyas';
|
||
|
$TB['saves'] = $ST['dbpf'].'_rejtnr_saves';
|
||
|
$TB['otchgods'] = $ST['dbpf'].'_rejt_otchgods';
|
||
|
$TB['nr_celpok'] = $ST['dbpf'].'_rejtnr_celpok';
|
||
|
|
||
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['razdels'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`name` varchar(255) NOT NULL,
|
||
|
`descr` varchar(255) NOT NULL,
|
||
|
`pos` tinyint(4) NOT NULL,
|
||
|
`status` tinyint(4) NOT NULL,
|
||
|
`dostup` tinyint(4) NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);}
|
||
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['items'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`id_razdel` int(11) NOT NULL,
|
||
|
`name` text NOT NULL,
|
||
|
`tip` tinyint(4) NOT NULL,
|
||
|
`pos` tinyint(4) NOT NULL,
|
||
|
`formuls` varchar(255) NOT NULL,
|
||
|
`descr` text NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);}
|
||
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['polyas'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`id_item` int(11) NOT NULL,
|
||
|
`name` text NOT NULL,
|
||
|
`pos` tinyint(4) NOT NULL,
|
||
|
`value` DOUBLE NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);}
|
||
|
{
|
||
|
$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['itemspolyas'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`id_item` int(11) NOT NULL,
|
||
|
`name` varchar(255) NOT NULL,
|
||
|
`pos` tinyint(4) NOT NULL,
|
||
|
`value` varchar(255) NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);}
|
||
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['saves'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`data_c` int(11) NOT NULL,
|
||
|
`id_user` int(11) NOT NULL,
|
||
|
`id_razdel` int(11) NOT NULL,
|
||
|
`id_items` int(11) NOT NULL,
|
||
|
`id_itemspolyas` int(11) NOT NULL,
|
||
|
`id_polyas` int(11) NOT NULL,
|
||
|
`value` text NOT NULL,
|
||
|
`pos` tinyint(4) NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);}
|
||
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['nr_celpok'].'` (
|
||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
|
`id_razdel` int(11) NOT NULL,
|
||
|
`id_items` int(11) NOT NULL,
|
||
|
`id_itemspolyas` int(11) NOT NULL,
|
||
|
`id_polyas` int(11) NOT NULL,
|
||
|
`celvalue` varchar(255) NOT NULL,
|
||
|
`stimvalue` varchar(255) NOT NULL,
|
||
|
`tipfor` tinyint NOT NULL,
|
||
|
PRIMARY KEY (`id`)
|
||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
||
|
$rez = $DB->QUR($sql);
|
||
|
}
|
||
|
|
||
|
function rejt_get_razdels($id=0){
|
||
|
GLOBAL $TB,$DB; $out=array();
|
||
|
if($id){
|
||
|
$sql = 'SELECT * FROM '.$TB['razdels'].' WHERE id='.$id.' LIMIT 1';
|
||
|
}else{
|
||
|
$sql = 'SELECT * FROM '.$TB['razdels'].' ORDER BY pos';
|
||
|
}
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if($rez){
|
||
|
foreach($rez as $key => $val)if($key){
|
||
|
$out[]=$val;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
function rejt_get_items($id=0){
|
||
|
GLOBAL $TB,$DB; $out=array();
|
||
|
if($id){
|
||
|
$sql = 'SELECT * FROM '.$TB['itemspolyas'].' WHERE id='.$id.' LIMIT 1';
|
||
|
}else{
|
||
|
$sql = 'SELECT * FROM '.$TB['itemspolyas'].' ORDER BY id_item,pos';
|
||
|
}
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if($rez){
|
||
|
foreach($rez as $key => $val)if($key){
|
||
|
$sql1 = 'SELECT * FROM '.$TB['items'].' WHERE id='.$val['id_item'].'';
|
||
|
$rez1 = $DB->QUR_SEL($sql1);
|
||
|
if($rez1){
|
||
|
$sql2 = 'SELECT * FROM '.$TB['razdels'].' WHERE id='.$rez1[1]['id_razdel'].'';
|
||
|
$rez2 = $DB->QUR_SEL($sql2);
|
||
|
if($rez2){
|
||
|
$rez1[1]['razdel'] = $rez2[1];
|
||
|
}
|
||
|
$val['item'] = $rez1[1];
|
||
|
}
|
||
|
$out[]=$val;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//if($_SESSION['user']['status']==99){
|
||
|
|
||
|
if($page=='admincelpok'){
|
||
|
include 'rejt_admincelpoknr.php';
|
||
|
}
|
||
|
if($page=='admin'){
|
||
|
$smarty->assign('page',$page);
|
||
|
$smarty->assign('des',$des);
|
||
|
$maincontent = $smarty->fetch('tpl_rejtnr_main.html');
|
||
|
}
|
||
|
if($page=='admin1'){//УПРАВЛЕНИЕ ОСНОВНЫМИ РАЗДЕЛАМИ
|
||
|
include 'rejtnr_admin1.php';
|
||
|
}
|
||
|
if($page=='admin2'){//УПРАВЛЕНИЕ ПОДРАЗДЕЛАМИ
|
||
|
include 'rejtnr_admin2.php';
|
||
|
}
|
||
|
if($page=='admin3'){//УПРАВЛЕНИЕ полями в ПОДРАЗДЕЛАХ
|
||
|
include 'rejtnr_admin3.php';
|
||
|
}
|
||
|
if($page=='admin4'){//УПРАВЛЕНИЕ значениями в полях
|
||
|
include 'rejtnr_admin4.php';
|
||
|
}
|
||
|
if($page=='main'){
|
||
|
include 'rejtnr_anketa.php';
|
||
|
}
|
||
|
//}else{$maincontent = 'в разработке';}
|