253 lines
10 KiB
PHP
253 lines
10 KiB
PHP
<?php
|
|
class class_LIBRARY_CHECK_BIB{
|
|
function __construct(){
|
|
GLOBAL $DB,$ST;
|
|
$this->DB = $DB;
|
|
$this->TLibraryCheck = $ST['dbpf'].'_fshp_libchecks';
|
|
$this->TRPDsave = $ST['dbpf'].'_fshp_rpd_save';
|
|
$this->TRPDsigns = $ST['dbpf'].'_fshp_rpd_signs';
|
|
$this->TUschebplans = $ST['dbpf'].'_fshp_uchebplans';
|
|
$this->TUsers = $ST['dbpf'].'_users';
|
|
$this->TFile = $ST['dbpf'].'_fshp_file';
|
|
$this->polya = $this->table_create();
|
|
}
|
|
|
|
/**
|
|
* Создание таблицы и возвращение полей таблицы
|
|
* @return string[][]
|
|
*/
|
|
private function table_create(){
|
|
$polya = array(
|
|
0=>array('name'=>'id','type'=>'int(11)','nul'=>'NOT NULL','dop'=>'AUTO_INCREMENT'),
|
|
array('name'=>'data_c','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'id_user','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'id_rpd','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'primech','type'=>'text','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'new_data','type'=>'longtext','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'old_data','type'=>'longtext','nul'=>'NOT NULL','dop'=>''),
|
|
array('name'=>'status','type'=>'int(11)','nul'=>'NOT NULL','dop'=>''),
|
|
);
|
|
//$sql = 'CREATE TABLE IF NOT EXISTS `'.$this->TLibraryCheck.'` (';
|
|
//foreach($polya as $k => $v){ $sql .= '`'.$v['name'].'` '.$v['type'].' '.$v['nul'].' '.$v['dop'].',';}
|
|
//$sql .= 'primary key (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;';
|
|
//$this->DB->QUR($sql);
|
|
return $polya;
|
|
}
|
|
|
|
function HTML(){
|
|
GLOBAL $WorkDIR;
|
|
$CHPU = new class_CHPU($WorkDIR);
|
|
$URLS = $CHPU->uri();
|
|
|
|
$smartyC = new class_smarty();
|
|
$smarty = $smartyC->config(__DIR__.'\..\tpl');
|
|
|
|
$view = 'all';
|
|
$out = array('name'=>'Проверка литературы в РПД','body'=>'');
|
|
|
|
////обработка АЯКС запросов
|
|
//if(isset($_POST['ajdes'])){
|
|
// header('Content-Type: application/json; charset=utf-8');
|
|
// $out=array();
|
|
// //удаление
|
|
// if($_POST['ajdes']=='RPDLibDel'){
|
|
// $data['id'] = (int)$_POST['id'];
|
|
// $data['cid'] = (int)$_POST['cid'];
|
|
// $data['razd'] = (int)$_POST['razd'];
|
|
// $out = $this->RPD_del($data);
|
|
// }
|
|
// //сохранение
|
|
// if($_POST['ajdes']=='RPDLibSave'){
|
|
// $data['id'] = (int)$_POST['id'];
|
|
// $data['cid'] = (int)$_POST['cid'];
|
|
// $data['razd'] = (int)$_POST['razd'];
|
|
// $data['name'] = $_POST['name'];
|
|
// $data['url'] = $_POST['url'];
|
|
// $out = $this->RPD_edit($data);
|
|
// }
|
|
// if($_POST['ajdes']=='RPDLibSaveA'){
|
|
// $data['id'] = (int)$_POST['id'];
|
|
// $data['cid'] = (int)$_POST['cid'];
|
|
// $data['razd'] = (int)$_POST['razd'];
|
|
// $data['name'] = $_POST['name'];
|
|
// $data['url'] = $_POST['url'];
|
|
// $out = $this->RPD_edit($data,'add');
|
|
// }
|
|
// echo json_encode($out);
|
|
// exit();
|
|
//}
|
|
|
|
////Подписать RPD библиотекой
|
|
//if(isset($URLS[1])&&$URLS[1]=='sign') {
|
|
// $who = 'Библиотека';
|
|
// $descrsql = 'Подписано';
|
|
// $id = (int)$URLS[2];//acs_fshp_rpd_save.id
|
|
// $sql = 'SELECT * FROM '.$this->TRPDsave.' WHERE id='.$id;
|
|
// $rez = $this->DB->QUR_SEL($sql);
|
|
// //Array( [err] => [kol] => 1 [rez] => Array (
|
|
// // [0] => Array (
|
|
// // [id] => 4078 [data_c] => 1694760284 [id_discip] => 37544 [id_prepod] => 3059
|
|
// // [razdel1] => ... [razdel6_1] => [razdel6_2] => ... [razdel5_5_1] =>
|
|
// if(!$rez['err']&&$rez['kol']){
|
|
// $rpdsave = $rez['rez'][0];
|
|
// $sql = 'SELECT id FROM '.$this->TRPDsigns.' WHERE id_rpd='.$rpdsave['id_discip'].' AND sign="'.$who.'" AND status=1';
|
|
// $rez = $this->DB->QUR_SEL($sql);
|
|
// if(!$rez['err']&&$rez['kol']) {
|
|
// $out['err'] = 1;
|
|
// $out['msg'] = 'РПД уже имеет подпись от библиотеки!';
|
|
// }else{
|
|
// $sql = 'INSERT INTO ' . $this->TRPDsigns . ' VALUES (0,' . time() . ',' . $_SESSION['user']['id'] . ',' . $rpdsave['id_discip'] . ',"' . $who . '","' . $descrsql . '",1)';
|
|
// $rez = $this->DB->QUR($sql);
|
|
// //echo $sql.'<pre>'.print_r($rez,1).'</pre>';
|
|
// if (!$rez['err']) {
|
|
// $out['err'] = 0;
|
|
// $out['msg'] = 'Подписали РПД';
|
|
// } else {
|
|
// $out['err'] = 1;
|
|
// $out['msg'] = 'Ошибка при сохранении!';
|
|
// }
|
|
// }
|
|
// }
|
|
// $smarty->assign('sign_result', $out);
|
|
// $URLS[1]='all';
|
|
//}
|
|
//if(isset($URLS[1])&&$URLS[1]=='edit') {
|
|
// $id = (int)$URLS[2];
|
|
// $item = $this->RPD_item($id);
|
|
// $smarty->assign('rpd_id', $id);
|
|
// $smarty->assign('item', $item);
|
|
// $view = 'edit';
|
|
//}
|
|
|
|
//if(isset($URLS[1])&&$URLS[1]=='fi_notCheck') {
|
|
// $_SESSION['libfil']='notCheck';
|
|
// $URLS[1]='all';
|
|
//}
|
|
//if(isset($URLS[1])&&$URLS[1]=='fi_yesCheck') {
|
|
// $_SESSION['libfil']='yesCheck';
|
|
// $URLS[1]='all';
|
|
//}
|
|
//if(isset($URLS[1])&&$URLS[1]=='fi_all') {
|
|
// $_SESSION['libfil']='all';
|
|
// $URLS[1]='all';
|
|
//}
|
|
//if(isset($URLS[1])&&strpos($URLS[1],'dd_')!==false) {
|
|
// $disc_sel=str_replace('dd_','',urldecode($URLS[1]));
|
|
// if($disc_sel!='all')
|
|
// $_SESSION['libfil_disc'] = $disc_sel;
|
|
// else unset($_SESSION['libfil_disc']);
|
|
// $URLS[1]='all';
|
|
//}
|
|
|
|
//$libfil = 'notCheck'; if(isset($_SESSION['libfil'])) $libfil = $_SESSION['libfil'];
|
|
//else $_SESSION['libfil'] = $libfil;
|
|
|
|
//Отображение всех РПД подписанных преподом
|
|
if(!isset($URLS[1])||$URLS[1]=='all') {
|
|
$rpds = $this->RPDs();
|
|
$smarty->assign('items', $rpds['items']);
|
|
$smarty->assign('navpages', $rpds['nav']);
|
|
}
|
|
$smarty->assign('view', $view);
|
|
$out['body'] = $smarty->fetch('page_library_check_bib.html');
|
|
return $out;
|
|
}
|
|
|
|
function RPDs(){
|
|
GLOBAL $URLS;
|
|
$out=array();
|
|
$perpage = 13;
|
|
$navpage = 1; if(isset($URLS['navpage'])) $navpage = (int)$URLS['navpage'];
|
|
|
|
$start = ($navpage-1)*$perpage;
|
|
|
|
$id_signs=array(); $isChecksSign = ''; //Выберем все подписанные библиотекой
|
|
$sql = 'SELECT id FROM '.$this->TRPDsigns.' WHERE sign="Библиотека" AND status=1';
|
|
$rez = $this->DB->QUR_SEL($sql);
|
|
if(!$rez['err']&&$rez['kol']) {
|
|
foreach($rez['rez'] as $k => $v)$id_signs[]=$v['id'];
|
|
$id_signs = array_unique($id_signs);
|
|
if(count($id_signs)) $isChecksSign = ' AND s.id IN('. implode(',',$id_signs).') ';
|
|
}
|
|
|
|
$sql = 'SELECT
|
|
r.id,r.data_c,r.razdel6_1,r.razdel6_2,
|
|
u.fio, p.id as pid,p.index1,p.name,s.sign,s.descrip,s.status ,s.id as sid
|
|
FROM
|
|
'.$this->TUschebplans.' as p, '.$this->TFile.' as f,
|
|
'.$this->TRPDsave.' as r, '.$this->TUsers.' as u,
|
|
'.$this->TRPDsigns.' as s
|
|
WHERE
|
|
p.id_file = f.id_file AND
|
|
f.god_nach_podgot = '.$_SESSION['year_cur'].' AND
|
|
r.id_discip=p.id AND
|
|
u.id=r.id_prepod AND
|
|
p.id=s.id_rpd
|
|
'.$isChecksSign.'
|
|
GROUP BY r.id';
|
|
//ORDER BY s.data_c DESC
|
|
//(s.sign="Разработчик" AND s.status=1) //((s.sign="Зав.вып.каф." AND s.status=1) OR (s.sign="Зав.каф." AND s.status=1)).$isChecksSign
|
|
//echo $sql; exit();
|
|
|
|
$nav['all'] = 0;
|
|
$nav['pages'] = 0;
|
|
$nav = $this->DB->navpage($sql, 'r.id', $perpage);
|
|
$sql .= ' LIMIT ' . $start . ',' . $perpage;
|
|
$rez = $this->cache_sess($sql);
|
|
if(!$rez['err']&&$rez['kol']) {
|
|
foreach ($rez['rez'] as $key => $rpds){
|
|
$rpds['razdel6_1'] = json_decode($rpds['razdel6_1'],1);
|
|
$rpds['razdel6_2'] = json_decode($rpds['razdel6_2'],1);
|
|
$rpds['edited'] = $this->get_count_edit($rpds['id']);
|
|
$rpds['signs'] = $this->RPD_check_SignS($rpds['pid']);
|
|
$out['items'][] = $rpds;
|
|
}
|
|
}
|
|
$out['nav'] = $nav;
|
|
$out['nav']['curpage'] = $navpage;
|
|
return $out;
|
|
}
|
|
|
|
function RPD_check_SignS($id){
|
|
$out = array();
|
|
$sql = 'SELECT sign,descrip,status FROM ' . $this->TRPDsigns . ' WHERE id_rpd=' . $id . ' ORDER BY data_c DESC';
|
|
$rez = $this->DB->QUR_SEL($sql);
|
|
//echo $sql.'<pre>'.print_r($rez,1).'</pre>';
|
|
if ($rez) {
|
|
$out = $rez['rez'];
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
/**
|
|
* Кэширование SQL запросов
|
|
* @param $sql1
|
|
* @param $key
|
|
* @return array|mixed|null
|
|
*/
|
|
function cache_sess($sql1,$key='LIBRARYCHECK_Cache',$des='add'){
|
|
if($des=='del'){
|
|
if(isset($_SESSION[$key][md5($sql1)]))
|
|
unset($_SESSION[$key][md5($sql1)]);
|
|
}else {
|
|
//if (!isset($_SESSION[$key][md5($sql1)])) {
|
|
$rez1 = $this->DB->QUR_SEL($sql1);
|
|
// $_SESSION[$key][md5($sql1)] = $rez1;
|
|
//} else {
|
|
// $rez1 = $_SESSION[$key][md5($sql1)];
|
|
//}
|
|
}
|
|
return $rez1;
|
|
}
|
|
|
|
function get_count_edit($id_rpd){
|
|
$out = 0;
|
|
$sql = 'SELECT COUNT(id) as kol FROM '.$this->TLibraryCheck.' WHERE id_rpd='.$id_rpd;
|
|
$rez = $this->DB->QUR_SEL($sql);
|
|
if(!$rez['err']&&$rez['kol']){
|
|
$out = $rez['rez'][0]['kol'];
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
} |