quote($_GET['parent_id'], PDO::PARAM_INT); $rows = DB::getPDO()->fetchAll(" select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC from CRM_LISTA_ZASOBOW g left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID) left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID) left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID) where g.`PARENT_ID` = ".$parent_id." ORDER BY g.SORT_PRIO "); Response::sendJsonExit($rows); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getResAjaxAction(){ try { if(!isset($_GET['word'])) throw new Exception("word is not set."); $word = DB::getPDO()->quote("%".$_GET['word']."%", PDO::PARAM_STR); $filter = isset($_GET['filter']) ? (int)$_GET['filter'] : 0; $sqlFilter = ""; switch($filter){ case 2: $sqlFilter = "AND (g.`TYPE` = 'TABELA' OR g.`TYPE` = 'KOMORKA')";break; case 1: $sqlFilter = "AND (g.`TYPE` = 'STANOWISKO' OR g.`TYPE` = 'DZIAL' OR g.`TYPE` = 'PODMIOT')";break; } $rows = DB::getPDO()->fetchAll(" select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC from CRM_LISTA_ZASOBOW g left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID) left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID) left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID) where (g.`DESC` LIKE ".$word." OR g.`ID` LIKE ".$word.") ".$sqlFilter." LIMIT 0,100 "); Response::sendJsonExit($rows); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getSingleResAjaxReponseCallback(){ if (!isset($_POST['data'])) throw new Exception("data is not set."); $data = $_POST['data']; $sqlWhereIdIn = array(); foreach ($data as $value) { $sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT); } $sqlWhereIdIn = (!empty($sqlWhereIdIn)) ? "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")" : "1=1"; $rows = DB::getPDO()->fetchAll(" select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC from CRM_LISTA_ZASOBOW g left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID) left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID) left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID) where {$sqlWhereIdIn}"); return $rows; } public function getSingleResAjaxAction(){ Response::sendTryCatchJson(array($this, 'getSingleResAjaxReponseCallback')); } public function handleAuth() { if (!User::logged()) { //throw new HttpException('Unauthorized', 401); User::authByRequest(); } // zapisać jsona w sesji } public function defaultAction() { UI::gora(); UI::menu(); try { $id = V::get('id', 0, $_REQUEST, 'int'); if ($id <= 0) throw new Exception("Wrong ID"); $this->showEditor($id); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } UI::dol(); } public function showEditor($id) { echo ''; $this->showEditorCss(); ?>