EIOS/inc/college.php

111 lines
3.5 KiB
PHP
Raw Normal View History

2023-12-28 15:39:22 +03:00
<?
//КОЛЛЕДЖ
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/class_SYSTEM.php';
$SYSTEMclass = new SYSTEMclass();
//ДОКУМЕНТЫ
if ($_GET['page'] == 'docs'){
//разделы документов
$razdels = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_college_razdel ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$razdels[] = $val;
}
}
//print_r ($razdels);
$smarty->assign('razdels', $razdels);
$maincontent = $smarty->fetch('tpl_college_docs.html');
}
//АДМИНИСТРИРОВАНИЕ
if ($_GET['page'] == 'admin'){
$msg = 0; //message
//добавление раздела
if (isset($_POST['add_college_razdel'])){
$name = addslashes($_POST['name']);
$category = addslashes($_POST['category']);
$sql = 'INSERT INTO '.$ST['dbpf'].'_college_razdel (`name`, `category`) VALUES ("'.$name.'", "'.$category.'") ';
$rez = $DB->QUR($sql);
//echo $sql;
$id = mysql_insert_id();
$msg = 1;
save_logs('Добавлен новый пункт в разделы электронной учительской №'.$id);
}
//добавить документ
if (isset($_POST['add_docs'])){
$id_razdel = addslashes($_POST['id_razdel']);
$name = addslashes($_POST['name']);
$date_create = date("U");
//файл - загрузка файла
$uploadfile='';
if(isset($_FILES['file'])){
$dir_dest = 'upload/college/';
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = $date_create.$_FILES['file']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$uploadfile = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file']['tmp_name'], $uploadfile)) {
$uploadfile='';
}
}
$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_college_docs (`name`, `link`, `date_create`, `id_razdel`) VALUES ("'.$name.'", "'.$uploadfile.'", "'.$date_create.'", "'.$id_razdel.'") ');
$id = mysql_insert_id();
$msg = 1;
save_logs('Колледж загрузил документ №'.$id);
}
//разделы документов
$razdels = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_college_razdel ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
switch ($val['category']){
case 1: $val['category'] = 'Учебно-организационный отдел'; break;
case 2: $val['category'] = 'Учебно-воспитательный отдел'; break;
case 3: $val['category'] = 'Учебно-методический отдел'; break;
case 4: $val['category'] = 'Физкультура и спорт'; break;
}
$razdels[] = $val;
}
}
//документы
$docs = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_college_docs';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$sql_dop = 'SELECT * FROM '.$ST['dbpf'].'_college_razdel WHERE id = "'.$val['id_razdel'].'" ';
//echo $sql_dop;
$rez_dop = $DB->QUR_SEL($sql_dop);
$val['name_razdel'] = $rez_dop[1]['name'];
$val['date_create'] = date("d.m.Y", $val['date_create']);
//echo $val['name_razdel'];
$docs[] = $val;
}
}
$smarty->assign('msg', $msg);
$smarty->assign('razdels', $razdels);
$smarty->assign('docs', $docs);
$maincontent = $smarty->fetch('tpl_college_admin.html');
}
?>