| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- Lib::loadClass('RouteBase');
- Lib::loadClass('ProcesHelper');
- Lib::loadClass('Config');
- Lib::loadClass('UI');
- Lib::loadClass('Request');
- Lib::loadClass('ProcesHelper');
- Lib::loadClass('Response');
- Lib::loadClass('DBG');
- Lib::loadClass('Api_WfsNs');
- class Route_UrlAction_TaskManager extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
- public function getStatsAjaxAction() {
- try {
- $id = V::get('ID', 0, $_GET, 'int');
- if ($id <= 0) throw new Exception("ID is not set.");
- $sqlId = DB::getPDO()->quote($id, PDO::PARAM_INT);
- $type = V::get('TYPE', 0, $_GET, 'string');
- $rows = null;
- if ($type == "PROBLEM") {
- $rows = DB::getPDO()->fetchAll("
- SELECT * FROM _SYNC_TASK_PERCENT WHERE ID_TASK = {$sqlId} AND ID_PROJECT = 0
- ");
- }
- if ($type == "PROJECT") {
- $rows = DB::getPDO()->fetchAll("
- SELECT * FROM _SYNC_TASK_PERCENT WHERE ID_PROJECT = {$sqlId} AND ID_TASK = 0
- ");
- }
- Response::sendJsonExit($rows);
- } catch (Exception $e) {
- UI::alert('danger', "Error: " . $e->getMessage());
- }
- }
- public function handleAuth() {
- if (!User::logged()) {
- User::authByRequest();
- }
- }
- public function reinstallAction() {
- try {
- $dropTableSql = "DROP TABLE `_SYNC_TASK_PERCENT`";
- DBG::nicePrint($dropTableSql, '$dropTableSql');
- DB::getPDO()->query($dropTableSql);
- } catch (Exception $e) {
- // SQLSTATE[42000]: Syntax error or access violation: 1305 PROCEDURE SES_USERS2.PROBLEMS__SYNC_PERCENT does not exist
- }
- $createTableSql = file_get_contents(__FILE__ . '.create__SYNC_TASK_PERCENT.sql');
- DBG::nicePrint($createTableSql, '$createTableSql');
- DB::getPDO()->query($createTableSql);
- try {
- $dropProcedureSql = "DROP PROCEDURE `PROBLEMS__SYNC_PERCENT`";
- DBG::nicePrint($dropProcedureSql, '$dropProcedureSql');
- DB::getPDO()->query($dropProcedureSql);
- } catch (Exception $e) {
- // SQLSTATE[42000]: Syntax error or access violation: 1305 PROCEDURE SES_USERS2.PROBLEMS__SYNC_PERCENT does not exist
- }
- $createProcedureSql = file_get_contents(__FILE__ . '.problems_sync_percent.sql');
- DBG::nicePrint($createProcedureSql, '$createProcedureSql');
- DB::getPDO()->query($createProcedureSql);
- }
- public function defaultAction() {
- UI::gora();
- UI::menu();
- try {
- DB::getPDO()->query("CALL `PROBLEMS__SYNC_PERCENT`();");// TODO: BUG zamula
- $id = 0;
- $type = "";
- if (!empty(V::get('ID_PROBLEM', 0, $_REQUEST, 'int'))) {
- $id = V::get('ID_PROBLEM', 0, $_REQUEST, 'int');
- $type = "PROBLEM";
- }
- if (!empty(V::get('ID_PROJECT', 0, $_REQUEST, 'int'))) {
- $id = V::get('ID_PROJECT', 0, $_REQUEST, 'int');
- $type = "PROJECT";
- }
- if ($id <= 0) throw new Exception("Wrong ID");
- $this->showManager($id, $type);
- } catch (Exception $e) {
- UI::alert('danger', "Error: " . $e->getMessage());
- }
- UI::dol();
- }
- public function showManager($id, $type) {
- echo "<div class=container-fluid>";
- echo "<div class=row>";
- echo "<div class='col-lg-6 col-lg-push-6' id=right>";
- echo "</div>";
- echo "<div class='col-lg-6 col-lg-pull-6' id=left>";
- echo "</div>";
- echo "</div>";
- echo "</div>";
- echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
- // echo '<link rel="stylesheet" href="static/task.css?'.time().'" type="text/css" />';
- UI::startTag('style', ['type' => "text/css"]);
- echo file_get_contents(__FILE__ . '.task.css');
- UI::endTag('style');
- echo '<script src="static/sweetalert2.min.js"></script>';
- echo '<script src="static/jquery.ui.autocomplete.js"></script>';
- echo '<script src="static/jquery.ui.menu.js"></script>';
- // echo "<script>var BASE_URL = '".Request::getPathUri()."';var TASK = ".$id.";var USER = '".User::getLogin()."';var TYPE='".$type."'; var ProblemsTableId=".ProcesHelper::getZasobTableID('PROBLEMS').";var ProjectsTableId=".ProcesHelper::getZasobTableID('IN7_MK_BAZA_DYSTRYBUCJI')."</script>";
- // echo '<script src="static/task.js?'.time().'"></script>';
- UI::inlineJS(__FILE__ . '.task.js', [
- 'BASE_URL' => Request::getPathUri(),
- 'BASE_WFS_URL' => Api_WfsNs::getBaseWfsUri(),
- 'TASK' => $id,
- 'USER' => User::getLogin(),
- 'TYPE' => $type,
- 'ProblemsTableId' => ProcesHelper::getZasobTableID('PROBLEMS'),
- 'ProjectsTableId' => ProcesHelper::getZasobTableID('IN7_MK_BAZA_DYSTRYBUCJI'),
- ]);
- }
- }
|