} } break; case 'logout': $user->logout(); $user->showLogin(); break; default: $page = $system->getRequest('page'); switch ($page) { case 'home': $home = new Home(); $home->show(); break; case 'workunits': $workunits = new Workunits(); $workunits->show(); break; case 'workunit': $workunit = new Workunit(); $workunit->show(); break; case 'workorders': $workorders = new Workorders(); $workorders->show(); break; case 'workorder': $workorder = new Workorder(); $workorder->show(); break; case 'incidents':
private function showIncident($tab = "view", $message = "") { $system = System::getInstance(); $ui = Ui::getInstance(); $ui->createPage(); // Header options $header_title = __("Ticket") . " #" . $this->id_incident; $left_href = "index.php?page=incidents"; $header_left_button = $ui->createHeaderButton(array('icon' => 'back', 'pos' => 'left', 'text' => __('Back'), 'href' => $left_href)); $right_href = "index.php?page=home"; $header_right_button = $ui->createHeaderButton(array('icon' => 'home', 'pos' => 'right', 'text' => __('Home'), 'href' => $right_href)); // Content $selected_tab_detail = ""; $selected_tab_workunit = ""; $selected_tab_file = ""; $ui->beginContent(); // Message popup if ($message != "") { $options = array('popup_id' => 'message_popup', 'popup_content' => $message); $ui->addPopup($options); $ui->contentAddHtml("<script type=\"text/javascript\">\n\t\t\t\t\t\t\t\t\t\t\$(document).on('pageshow', function() {\n\t\t\t\t\t\t\t\t\t\t\t\$(\"#message_popup\").popup(\"open\");\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script>"); } switch ($tab) { case 'detail': $selected_tab_detail = "class=\"ui-btn-active ui-state-persist\""; $ui->contentAddHtml($this->getIncidentDetail()); // Header options $right_href = "index.php?page=home"; // Edit in the future $header_right_button = $ui->createHeaderButton(array('icon' => 'home', 'pos' => 'right', 'text' => __('Home'), 'href' => $right_href)); break; case 'edit': break; case 'workunits': $selected_tab_workunit = "class=\"ui-btn-active ui-state-persist\""; $workunits = new Workunits(); $href = "index.php?page=incident&tab=workunit&id_incident=" . $this->id_incident; $delete_button = false; $delete_href = ""; // Workunits listing $html = $workunits->getWorkUnitsList($href, $delete_button, $delete_href); $ui->contentAddHtml($html); if ($workunits->getCountWorkUnits() > $system->getPageSize()) { $ui->contentAddHtml('<div style="text-align:center;" id="loading_rows"> <img src="../images/spinner.gif"> ' . __('Loading...') . '</img> </div>'); $workunits->addWorkUnitsLoader($href); } unset($workunits); // Header options $right_href = "index.php?page=incident&tab=workunit&id_incident=" . $this->id_incident; $header_right_button = $ui->createHeaderButton(array('icon' => 'add', 'pos' => 'right', 'text' => __('New'), 'href' => $right_href)); break; case 'workunit': $selected_tab_workunit = "class=\"ui-btn-active ui-state-persist\""; $workunit = new Workunit(); $action = "index.php?page=incident&tab=workunit"; $ui->contentAddHtml($workunit->getWorkUnitForm($action, "POST")); unset($workunit); // Header options if ($id_workunit = $system->getRequest('id_workunit', false)) { $header_title = __("Workunit") . " #" . $id_workunit; } else { $header_title = __("Workunit"); } $right_href = "index.php?page=incident&tab=workunits&id_incident=" . $this->id_incident; $header_right_button = $ui->createHeaderButton(array('icon' => 'grid', 'pos' => 'right', 'text' => __('List'), 'href' => $right_href)); break; case 'files': $selected_tab_file = "class=\"ui-btn-active ui-state-persist\""; $ui->contentAddHtml($this->getFilesList()); // Header options $right_href = "index.php?page=incident&tab=file&id_incident=" . $this->id_incident; $header_right_button = $ui->createHeaderButton(array('icon' => 'add', 'pos' => 'right', 'text' => __('New'), 'href' => $right_href)); break; case 'file': $selected_tab_file = "class=\"ui-btn-active ui-state-persist\""; $ui->contentAddHtml($this->getFileForm()); // Header options $header_title = __("File"); $right_href = "index.php?page=incident&tab=files&id_incident=" . $this->id_incident; $header_right_button = $ui->createHeaderButton(array('icon' => 'grid', 'pos' => 'right', 'text' => __('List'), 'href' => $right_href)); break; default: $tab = 'detail'; $selected_tab_detail = "class=\"ui-btn-active ui-state-persist\""; $ui->contentAddHtml($this->getIncidentDetail()); } $ui->endContent(); // Header $ui->createHeader($header_title, $header_left_button, $header_right_button); // Navigation bar $tab_detail = "<a href='index.php?page=incident&tab=view&id_incident=" . $this->id_incident . "' {$selected_tab_detail} data-role='button' data-icon='info'>" . __('Info') . "</a>\n"; $tab_workunit = "<a href='index.php?page=incident&tab=workunits&id_incident=" . $this->id_incident . "' {$selected_tab_workunit} data-role='button' data-icon='star'>" . __('Workunit') . "</a>\n"; $tab_file = "<a href='index.php?page=incident&tab=files&id_incident=" . $this->id_incident . "' {$selected_tab_file} data-role='button' data-icon='plus'>" . __('Files') . "</a>\n"; $buttons = array($tab_detail, $tab_workunit, $tab_file); $ui->addNavBar($buttons); $ui->showPage(); }