quote($idParent, 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` = {$sqlIdParent} ORDER BY g.SORT_PRIO ASC, g.ID DESC "); Response::sendJsonExit($rows); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getResAjaxAction() { try { $word = V::get('word', '', $_GET); $filter = isset($_GET['filter']) ? (int)$_GET['filter'] : 0; $sqlFilter = ""; if (!empty($word)) { $sqlWord = DB::getPDO()->quote("%{$word}%", PDO::PARAM_STR); if (is_numeric($word)) { $sqlFilter .= "AND (g.`DESC` LIKE {$sqlWord} OR g.`ID` LIKE {$sqlWord})" . "\n"; } else { $sqlFilter .= "AND g.`DESC` LIKE {$sqlWord}" . "\n"; } } switch ($filter) { case 2: $sqlFilter .= "AND (g.`TYPE` = 'TABELA' OR g.`TYPE` = 'KOMORKA')" . "\n"; break; case 1: $sqlFilter .= "AND (g.`TYPE` = 'STANOWISKO' OR g.`TYPE` = 'DZIAL' OR g.`TYPE` = 'PODMIOT')" . "\n"; break; } $sql = " 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.`A_STATUS` not in ('DELETED') and (p1.ID is null or p1.`A_STATUS` not in ('DELETED')) and (p2.ID is null or p2.`A_STATUS` not in ('DELETED')) and (p3.ID is null or p3.`A_STATUS` not in ('DELETED')) {$sqlFilter} limit 100 "; DBG::_('DBG_SQL', '>1', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__); $rows = DB::getPDO()->fetchAll($sql); 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."); $ids = V::get('data', null, $_POST, 'uint_array'); if (empty($ids)) throw new Exception("data is not correct."); $sqlWhereIdIn = array(); foreach ($ids as $value) { $sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT); } $sqlWhereIdIn = "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")"; $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"); UI::setTitleJsTag("Edytor Procesu {{$id}}"); $this->showEditor($id); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } UI::dol(); } public function showEditor($id) { echo ''; $this->showEditorCss(); ?>
Uruchamianie aplikacji.