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['search_fio_btn'])){ if($_POST['search_fio']!='') $_SESSION['rpd_lib_search_fio'] = $_POST['search_fio']; else unset($_SESSION['rpd_lib_search_fio']); } //обработка АЯКС запросов if(isset($_POST['ajdes'])){ header('Content-Type: application/json; charset=utf-8'); $out=array(); //Возврат РПД назад if($_POST['ajdes']=='RPDLibbackrpd'){ //$data['id'] = (int)$_POST['id']; //$data['cid'] = (int)$_POST['cid']; //$data['razd'] = (int)$_POST['razd']; //$out = $this->RPD_del($data); $who = 'Библиотека'; $descrsql = 'Не подписано. '.$this->DB->rescape($_POST['text']); $id = (int)$_POST['id'];//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']) { $sql = 'UPDATE '.$this->TRPDsigns.' SET sign="'.$who.'", descrip="'.$descrsql.'",status=0 WHERE id='.$rez['rez'][0]['id'].' LIMIT 1'; $rez = $this->DB->QUR($sql); if (!$rez['err']) { $out['err'] = 0; $out['msg'] = 'Отозвали подпись библиотеки'; //Надо еще предыдущую подпись отозвать! } else { $out['err'] = 1; $out['msg'] = 'Ошибка при отзыве подписи библиотеки!'; } }else{ $sql = 'INSERT INTO ' . $this->TRPDsigns . ' VALUES (0,' . time() . ',' . $_SESSION['user']['id'] . ',' . $rpdsave['id_discip'] . ',"' . $who . '","' . $descrsql . '",0)'; $rez = $this->DB->QUR($sql); if (!$rez['err']) { $out['err'] = 0; $out['msg'] = 'Подписали РПД отказом!'; } else { $out['err'] = 1; $out['msg'] = 'Ошибка при сохранении!'; } } } } //удаление 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'] = 'РПД уже имеет подпись от библиотеки!'; $sql = 'UPDATE ' . $this->TRPDsigns . ' SET descrip = "' . $descrsql . '" WHERE id='.$rez['rez'][0]['id'].' LIMIT 1'; $rez = $this->DB->QUR($sql); if (!$rez['err']) { $out['err'] = 0; $out['msg'] .= ' НО МЫ ЕЩЕ РАЗ ПОДПИСАЛИ!'; } else { $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.'
'.print_r($rez,1).'
'; 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('libfil', $libfil); $smarty->assign('libfil_discip', $this->get_name_discip()); if(isset($_SESSION['libfil_disc'])) $smarty->assign('libfil_discip_sel', $_SESSION['libfil_disc']); else $smarty->assign('libfil_discip_sel', ''); if(isset($_SESSION['rpd_lib_search_fio'])) $smarty->assign('search_fio', $_SESSION['rpd_lib_search_fio']); else $smarty->assign('search_fio', ''); } $smarty->assign('view', $view); $out['body'] = $smarty->fetch('page_library_check.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; $ids_users=array(); $isUsers=''; if(isset($_SESSION['rpd_lib_search_fio'])){ $fio = $this->DB->rescape($_SESSION['rpd_lib_search_fio']); $sql = 'SELECT id FROM acs_users WHERE fio LIKE "%'.$fio.'%"'; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ foreach ($rez['rez'] as $k => $v) $ids_users[]=$v['id']; } $isUsers = ' AND r.id_prepod IN('.implode(',',$ids_users).')'; } $isChecks=''; if($_SESSION['libfil']=='notCheck'){ $sql = 'SELECT id_rpd FROM '.$this->TLibraryCheck; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']) { $id_prds=array();foreach($rez['rez'] as $k => $v)$id_prds[]=$v['id_rpd']; $id_prds = array_unique($id_prds); $isChecks = ' AND r.id NOT IN('. implode(',',$id_prds).')'; } } if($_SESSION['libfil']=='yesCheck'){ $sql = 'SELECT id_rpd FROM '.$this->TLibraryCheck; $rez = $this->DB->QUR_SEL($sql); if(!$rez['err']&&$rez['kol']) { $id_prds=array();foreach($rez['rez'] as $k => $v)$id_prds[]=$v['id_rpd']; $id_prds = array_unique($id_prds); $isChecks = ' AND r.id IN('. implode(',',$id_prds).')'; } } $id_signs=array(); $isChecksSign = ''; //Выберем все подписанные проректором $sql = 'SELECT id FROM '.$this->TRPDsigns.' WHERE (sign="Проректор" OR 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 NOT IN('. implode(',',$id_signs).') '; } //echo $isChecksSign; exit(); //47307 s.id=20626 $isDiscip=''; if(isset($_SESSION['libfil_disc'])){ $isDiscip=' AND p.name ="'.$this->DB->rescape($_SESSION['libfil_disc']).'"'; } $sql = 'SELECT r.id,r.id_discip,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.$isChecks.$isDiscip.$isUsers.' GROUP BY r.id'; //echo $sql; exit(); //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 acs_fshp_uchebplans as p, acs_fshp_file as f, acs_fshp_rpd_save as r, acs_users as u, acs_fshp_rpd_signs as s WHERE p.id_file = f.id_file AND f.god_nach_podgot = 2022 AND r.id_discip=p.id AND u.id=r.id_prepod AND p.id=s.id_rpd AND s.id NOT IN(1718,2746,2747,2749,2750,2751,2756,3266,3267,3272,3338,3347,3357,3532,3561,3566,3567,3569,3577,3607,3608,3610,3612,3618,3648,3650,3651,3652,3653,3655,3657,3659,3660,3675,3681,3682,3698,3701,3705,3709,3710,3711,3713,3714,3716,3776,3826,3827,3838,3839,3855,3863,3865,3874,3875,3895,3896,3898,3899,3900,3901,3902,3903,3904,3907,3908,3917,3920,3931,3935,3942,3944,3953,3977,3998,4004,4006,4007,4016,4044,4084,4088,4090,4101,4103,4112,4116,4121,4122,4130,4134,4136,4160,4161,4221,4682,4683,4685,4696,4700,4701,5090) AND r.id NOT IN(56,162,276,403,421,448,475,549,606,607,715,755,991,1022,1044,1115,1500,1631,1726,1729,1892,1900,2094,2095,2167,2175,2209,2213,2226,2228,2288,2385,2511,2568,2577,2642,2679,2682,2684,2702,2755,2776,2779,2786,2800,2809,2813,2824,2826,2832,2873,2894,2981,3012,3038,3055,3633,3638,3640,3650,3653,3654,3655,3656,3657,3658,3659,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3673,3676,3677,3678,3679,3680,3682,3683,3684,3685,3686,3687,3688,3689,3690,3691,3692,3693,3694,3695,3696,3697,3698,3699,3708,3709,3710,3711,3712,3713,3714,3715,3716,3717,3718,3719,3720,3722,3724,3725,3727,3728,3730,3731,3732,3733,3734,3735,3737,3738,3739,3740,3741,3742,3743,3744,3745,3746) GROUP BY r.id $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; } /** * Кэширование 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 RPDs_old(){ $out=array(); $sql = 'SELECT r.id,r.data_c,r.razdel6_1,r.razdel6_2, u.fio, p.index1,p.name 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 u.id=s.id_rpd AND (s.sign="Разработчик" AND s.status=1) GROUP BY r.id ';//(s.sign="Разработчик" AND s.status=1) //echo $sql;exit(); $rez = $this->DB->QUR_SEL($sql); //$out['sqls']['sql'] = $sql; //$out['sqls']['rez'] = $rez; 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']); $out['items'][] = $rpds; } } return $out; } function get_name_discip(){ $out=array(); if(isset($_SESSION['libcheck_discip'][$_SESSION['year_cur']])){ $out = $_SESSION['libcheck_discip'][$_SESSION['year_cur']]; sort($out); }else { $sql = 'SELECT p.name 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 AND (s.sign="Разработчик" AND s.status=1) GROUP BY r.id'; $rez = $this->DB->QUR_SEL($sql); if (!$rez['err'] && $rez['kol']) { foreach ($rez['rez'] as $key => $rpds) { $out[] = $rpds['name']; } } $out = array_unique($out); sort($out); $_SESSION['libcheck_discip'][$_SESSION['year_cur']] = $out; } return $out; } 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; } function RPD_item($id){ $out=array(); //$sql = 'SELECT // r.id,r.data_c,r.razdel6_1,r.razdel6_2, // u.fio, p.index1,p.name //FROM // '.$this->TUschebplans.' as p, // '.$this->TFile.' as f, // '.$this->TRPDsave.' as r, // '.$this->TUsers.' as u, // '.$this->TRPDsigns.' as s //WHERE // r.id = '.$id.' AND // r.id_discip=p.id AND // p.id_file = f.id_file AND // f.god_nach_podgot = '.$_SESSION['year_cur'].' AND // u.id=r.id_prepod AND // r.id=s.id_rpd AND // (s.sign="Разработчик" AND s.status=1) //'; //id, data_c, id_file, program, shifr, naprav, profil, kafedra, fakultet, kvalif, god_nach_podgot, fo, obr_stabdart, srok_poluch_obr, json, status $sql = 'SELECT r.id,r.data_c,r.razdel6_1,r.razdel6_2,r.id_discip, u.fio, p.index1,p.name,s.id as sid, f.program, f.shifr, f.naprav, f.profil, f.kafedra, f.fakultet, f.kvalif, f.fo FROM '.$this->TUschebplans.' as p, '.$this->TFile.' as f, '.$this->TRPDsave.' as r, '.$this->TUsers.' as u, '.$this->TRPDsigns.' as s WHERE r.id = '.$id.' AND 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 AND ((s.sign="Зав.вып.каф." AND s.status=1) OR (s.sign="Зав.каф." AND s.status=1))'; $rez = $this->DB->QUR_SEL($sql); //(s.sign="Разработчик" AND s.status=1) //echo $sql.'
'.print_r($rez,1).'
'; $out['sqls']['sql'] = $sql; $out['sqls']['rez'] = $rez; if(!$rez['err']&&$rez['kol']) { $rpds = $rez['rez'][0]; $rpds['razdel6_1'] = json_decode($rpds['razdel6_1'],1); $rpds['razdel6_2'] = json_decode($rpds['razdel6_2'],1); $rpds['signs'] = $this->RPD_check_Sign($rpds['sid']); $out = $rpds; } 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 LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).'
'; if ($rez) { $out = $rez['rez'][0]; } return $out; } function RPD_check_Sign($id,$type=''){ $out = array(); if($type=='last') { $sql = 'SELECT id_rpd FROM ' . $this->TRPDsigns . ' WHERE id=' . $id . ' LIMIT 1'; //echo $sql;exit(); $rez = $this->DB->QUR_SEL($sql); if ($rez) { $RPDsigns = $rez['rez'][0]; $sql = 'SELECT sign,descrip,status FROM ' . $this->TRPDsigns . ' WHERE id_rpd=' . $RPDsigns['id_rpd'] . ' ORDER BY data_c DESC LIMIT 1'; $rez = $this->DB->QUR_SEL($sql); if ($rez) { $out = $rez['rez'][0]; } } } if($type=='') { $sql = 'SELECT sign,descrip,status FROM ' . $this->TRPDsigns . ' WHERE id=' . $id . ' LIMIT 1'; //echo $sql.'
'; $rez = $this->DB->QUR_SEL($sql); if ($rez) { $out = $rez['rez'][0]; } } return $out; } function RPD_edit($data,$type=''){ $item = $item_old = $this->RPD_item($data['id']); $r= ''; //$out['item'] = $item; if($type=='add') { if ($data['razd'] == '61') { $r = 'razdel6_1'; } if ($data['razd'] == '62') { $r = 'razdel6_2'; } if (!is_array($item[$r])){ $item[$r] = array(); $item[$r][1] = array(); } //$out['item1'] = $item; if (isset($item[$r]) && isset($item[$r][1])) { $books = $item[$r][1]; //добавляем! $books[] = array('name'=>$data['name'],'url'=>$data['url']); $item[$r][1] = $books; $r_value = $this->DB->rescape(json_encode($item[$r], JSON_UNESCAPED_UNICODE)); $sql = 'UPDATE ' . $this->TRPDsave . ' SET ' . $r . '="' . $r_value . '" WHERE id=' . $data['id']; //$out['sql'] = $sql; $rez = $this->DB->QUR($sql); if (!$rez['err']) { $rold_value = $this->DB->rescape(json_encode($item_old[$r], JSON_UNESCAPED_UNICODE)); $sql = 'INSERT INTO ' . $this->TLibraryCheck . ' VALUES(0,' . time() . ',' . $_SESSION['user']['id'] . ',' . $data['id'] . ',"","' . $r_value . '","' . $rold_value . '",1)'; $rez = $this->DB->QUR($sql); $out['err'] = 0; $out['msg'] = 'Добавили'; } else { $out['err'] = 1; $out['msg'] = 'Не добавили'; } }else{ $out['err'] = 1; $out['msg'] = 'Не верный раздел!'; } } if($type=='') { if ($data['razd'] == '61') { $r = 'razdel6_1'; } if ($data['razd'] == '62') { $r = 'razdel6_2'; } if (isset($item[$r]) && isset($item[$r][1])) { $books = $item[$r][1]; if (isset($books[$data['cid']])) { $books[$data['cid']]['name'] = $data['name']; $books[$data['cid']]['url'] = $data['url']; } $item[$r][1] = $books; $r_value = $this->DB->rescape(json_encode($item[$r], JSON_UNESCAPED_UNICODE)); $sql = 'UPDATE ' . $this->TRPDsave . ' SET ' . $r . '="' . $r_value . '" WHERE id=' . $data['id']; $rez = $this->DB->QUR($sql); if (!$rez['err']) { $rold_value = $this->DB->rescape(json_encode($item_old[$r], JSON_UNESCAPED_UNICODE)); $sql = 'INSERT INTO ' . $this->TLibraryCheck . ' VALUES(0,' . time() . ',' . $_SESSION['user']['id'] . ',' . $data['id'] . ',"","' . $r_value . '","' . $rold_value . '",1)'; $rez = $this->DB->QUR($sql); $out['err'] = 0; $out['msg'] = 'Обновили'; } else { $out['err'] = 1; $out['msg'] = 'Не обновили'; } } } //$out['item'] = $item; //{ // "1": [ // { // "name": "Хамирзова, С.К. (Майкопский государственный технологический университет). Маркетинг : учебное пособие / С.К. Хамирзова. - Майкоп : Магарин О.Г., 2011. - 264 с. ", // "url": "http://lib.mkgtu.ru:8004/catalog/fol2." // } // ] //} return $out; } function RPD_del($data){ $item = $item_old = $this->RPD_item($data['id']); $r= ''; if($data['razd']=='61'){ $r = 'razdel6_1'; } if($data['razd']=='62'){ $r = 'razdel6_2'; } if(isset($item[$r])&&isset($item[$r][1])){ $books = $item[$r][1]; if(isset($books[$data['cid']])){ $books[$data['cid']]['name'] = ''; $books[$data['cid']]['url'] = ''; } $item[$r][1] = $books; $r_value = $this->DB->rescape(json_encode($item[$r],JSON_UNESCAPED_UNICODE)); $sql = 'UPDATE '.$this->TRPDsave.' SET '.$r.'="'.$r_value.'" WHERE id='.$data['id']; $rez = $this->DB->QUR($sql); if(!$rez['err']){ $rold_value = $this->DB->rescape(json_encode($item_old[$r],JSON_UNESCAPED_UNICODE)); $sql = 'INSERT INTO '.$this->TLibraryCheck.' VALUES(0,'.time().','.$_SESSION['user']['id'].','.$data['id'].',"","'.$r_value.'","'.$rold_value.'",1)'; $rez = $this->DB->QUR($sql); $out['err'] = 0; $out['msg'] = 'Удалили'; }else{ $out['err'] = 1; $out['msg'] = 'Не удалили'; } } return $out; } }