fetchAll(" select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `TYPE`, `IF_TRUE_GOTO`, `IF_TRUE_GOTO_FLAG` 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"]; if(intval($value["PARENT_ID"]) != 0) $state[$id]["PARENT_ID"] = intval($value["PARENT_ID"]); else $state[$id]["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); } //print_r($state); 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"]; //print_r($temp); 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"]; //print_r($temp); 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' "); //print_r($count[0]["c"]); //print_r($state); $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"]; if(intval($value["PARENT_ID"]) != 0) $state[$id]["PARENT_ID"] = intval($value["PARENT_ID"]); else $state[$id]["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); } //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 { $start_id = V::get('START_ID', 0, $_REQUEST, 'int'); $type = V::get('TYPE', 0, $_REQUEST, 'string'); if($type === "zasoby") $type = "res"; else $type = "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 ''; $this->showViewCss(); } public function showViewCss() { ?>