fetchAll(" select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `TYPE`, `IF_TRUE_GOTO`, `IF_TRUE_GOTO_FLAG`, `SORT_PRIO` from CRM_PROCES WHERE `PARENT_ID`>=0 AND `A_STATUS` <> 'DELETED' AND `ID` <> `PARENT_ID` ORDER BY `SORT_PRIO` ASC, `ID` DESC "); $state = array(); foreach ($rows as $key => $value) { $id = intval($value["ID"]); $parent_id = intval($value["PARENT_ID"]); $state[$id]["ID"] = $value["ID"]; $state[$id]["DESC"] = $value["DESC"]; $state[$id]["OPIS"] = $value["OPIS"]; $state[$id]["TYPE"] = $value["TYPE"]; $state[$id]["IF_TRUE_GOTO"] = intval($value["IF_TRUE_GOTO"]); $state[$id]["IF_TRUE_GOTO_FLAG"] = $value["IF_TRUE_GOTO_FLAG"]; $state[$id]["PARENT_ID"] = (intval($value["PARENT_ID"]) != 0) ? intval($value["PARENT_ID"]) : "#"; $state[$id]["SORT_PRIO"] = $value["SORT_PRIO"]; if (!isset($state[$id]["childs"])) $state[$id]["childs"] = array(); if (!isset($state[$parent_id]["childs"])) $state[$parent_id]["childs"] = array(); $temp = array(); $temp["ID"] = $id; array_push($state[$parent_id]["childs"], $temp); } Response::sendJsonExit($state); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getConnectedProcAjaxAction(){ try { $id = V::get('id', 0, $_REQUEST, 'int'); $rows = DB::getPDO()->fetchAll(" SELECT * FROM `CRM_WSKAZNIK` WHERE `ID_ZASOB` = $id AND `A_STATUS` <> 'DELETED' "); $state = array(); $state["wsk"] = array(); foreach($rows as $key => $value){ $temp["ID"] = $value["ID"]; $temp["ID_PROCES"] = $value["ID_PROCES"]; $temp["ID_ZASOB"] = $value["ID_ZASOB"]; array_push($state["wsk"], $temp); } Response::sendJsonExit($state); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getDetailsAjaxAction(){ try { $id = V::get('id', 0, $_REQUEST, 'int'); $rows = DB::getPDO()->fetchAll(" SELECT * FROM `CRM_WSKAZNIK` WHERE `ID_PROCES` = {$id} AND `A_STATUS` <> 'DELETED' "); $state = array(); $state["wsk"] = array(); foreach($rows as $key => $value){ $temp["ID"] = $value["ID"]; $temp["ID_PROCES"] = $value["ID_PROCES"]; $temp["ID_ZASOB"] = $value["ID_ZASOB"]; array_push($state["wsk"], $temp); } $count = DB::getPDO()->fetchAll(" SELECT count(*) as imgCount FROM `CRM_IMAGE` WHERE `REMOTE_ID` = {$id} AND `REMOTE_TABLE` = 'CRM_PROCES' "); $state["IMG_COUNT"] = $count[0]["imgCount"]; Response::sendJsonExit($state); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function getAllResAjaxAction(){ try { $rows = DB::getPDO()->fetchAll(" select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `ALIAS_ID`, `TYPE` from CRM_LISTA_ZASOBOW WHERE `PARENT_ID`>=0 AND `A_STATUS` <> 'DELETED' AND `ID` <> `PARENT_ID` ORDER BY `SORT_PRIO` ASC, `ID` DESC "); $state = array(); foreach ($rows as $key => $value) { $id = intval($value["ID"]); $parent_id = intval($value["PARENT_ID"]); $state[$id]["ALIAS_ID"] = intval($value["ALIAS_ID"]); $state[$id]["ID"] = $value["ID"]; $state[$id]["DESC"] = $value["DESC"]; $state[$id]["TYPE"] = $value["TYPE"]; $state[$id]["OPIS"] = $value["OPIS"]; $state[$id]["PARENT_ID"] = (intval($value["PARENT_ID"]) != 0) ? intval($value["PARENT_ID"]) : "#"; if (!isset($state[$id]["childs"])) $state[$id]["childs"] = array(); if (!isset($state[$value["PARENT_ID"]])) $state[$parent_id]["childs"] = array(); $temp = array(); $temp["ID"] = $id; array_push($state[$parent_id]["childs"], $temp); } Response::sendJsonExit($state); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } public function handleAuth() { if (!User::logged()) User::authByRequest(); } public function defaultAction() { UI::gora(); UI::menu(); try { $start_id = V::get('START_ID', 0, $_REQUEST, 'int'); $type = V::get('TYPE', '', $_REQUEST, 'string'); $type = ($type == "zasoby") ? "res" : "childs"; $this->showView($start_id, $type); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } UI::dol(); } public function showView($start_id, $type) { echo "
"; echo "
"; echo ""; echo "
"; echo ""; echo "
"; echo "
"; echo ""; echo ''; echo ''; echo ''; echo ''; echo '';// TODO: static v, only in DBG $this->showViewCss(); } public function showViewCss() { ?>