fetchAll(" select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `TYPE` 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"]; if(intval($value["PARENT_ID"]) != 0) $state[$id]["PARENT_ID"] = intval($value["PARENT_ID"]); else $state[$id]["PARENT_ID"] = "#"; $state[$id]["active"] = false; $state[$id]["details"] = false; if(!isset($state[$id]["childs"])) $state[$id]["childs"] = array(); if(!isset($state[$value["PARENT_ID"]])){ $state[$parent_id]["active"] = false; $state[$parent_id]["details"] = false; $state[$parent_id]["childs"] = array(); } $temp = array(); $temp["ID"] = $id; array_push($state[$parent_id]["childs"], $temp); } //print_r($state); Response::sendJsonExit($state); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } } 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 { $this->showView(); } catch (Exception $e) { UI::alert('danger', "Error: " . $e->getMessage()); } UI::dol(); } public function showView() { echo "