src.dualinventive.com/mtinfo/dist/webroot/rc-4.05/scripts/page/menu.php

186 lines
9.5 KiB
PHP

<?php
/** \file scripts\page\menu.php
* \brief DI webinterface menu script.
* \author Rob Schalken, Core|Vision
* \version 1.0
* \date 17-10-2008
*
* This file contains the menu script. This file creates the main menu.
* Here the user can choose his next action (when allowed).
*/
//== Required settings ======================
$_PAGE_INFO['page_title'] = _("main menu");
if (!isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
$_PAGE_INFO['history_menu_buttons'] = array("Project overview");
$_PAGE_INFO['history_menu_links'] = array("page/project");
$menu = "menu";
}
else {
$_PAGE_INFO['shortcut_menu_buttons']= array(_("Project overview"), $_PAGE_INFO['HIST_MAIN'], _("Realtime status"), _("Use equipment"), _("Project report"), _("GPS track"));
$_PAGE_INFO['shortcut_menu_links'] = array("page/project", "", "page/menu_rt&action=lance_rt&page_project=" . $_GET['page_project'], "page/menu_lance_use&action=lance_use&page_project=" . $_GET['page_project'], "page/menu_report_info&action=project_report&page_project=" . $_GET['page_project'], "page/menu_report_info&action=gps_report&page_project=" . $_GET['page_project']);
$_PAGE_INFO['shortcut_menu_rights'] = array("", "", "menu:realtime_status", "menu:lans", "menu:rapportages&menu:rapportages:projecten,menu:rapportages:root", "menu:rapportages&menu:rapportages:gps,menu:rapportages:root");
// Initial values
$transfer_submit = FALSE;
// Add document transfer functionality
$transfer = db_fetch_project_transfer($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'], $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
if ((is_array($transfer)) && (!empty($transfer))) {
switch($transfer[0]['status']) {
case 'goedgekeurd':
array_push($_PAGE_INFO['shortcut_menu_buttons'], _("Documentation") . " " . _("accepted"));
array_push($_PAGE_INFO['shortcut_menu_links'], "");
break;
case 'afgekeurd':
array_push($_PAGE_INFO['shortcut_menu_buttons'], _("Documentation") . " " . _("acceptation"));
array_push($_PAGE_INFO['shortcut_menu_links'], "javascript:onSubmit('doc_transfer', '', 1);");
break;
case 'gewijzigd':
$transfer_submit = TRUE;
array_push($_PAGE_INFO['shortcut_menu_buttons'], _("Documentation") . " " . _("changed"));
array_push($_PAGE_INFO['shortcut_menu_links'], "");
break;
}
}
else {
array_push($_PAGE_INFO['shortcut_menu_buttons'], _("Documentation") . " " . _("acceptation"));
array_push($_PAGE_INFO['shortcut_menu_links'], "javascript:onSubmit('doc_transfer', '', 1);");
}
// No rights required
array_push($_PAGE_INFO['shortcut_menu_rights'], "");
$menu = "menu_project";
}
//===========================================
// Button text // Page // Rights needed
$_PAGE_INFO['menu_items'] = array( array(_("Realtime status") ,"page/menu_lance_search&action=lance_rt" ,"menu:realtime_status" ),
array(_("Use equipment") ,"page/menu_lance_search&action=lance_use" ,"menu:lans" ),
array(_("Equipment maintenance") ,"page/menu_lance" ,"menu:lansen:root,menu:lansen" ),
array(_("Company maintenance") ,"page/menu_cust" ,"menu:klanten:root,menu:klanten" ),
array(_("User maintenance") ,"page/menu_user" ,"menu:gebruikers:root,menu:gebruikers" ),
array(_("Project maintenance") ,"page/menu_project" ,"menu:projecten:root,menu:projecten" ),
array(_("Rent equipment") ,"page/menu_lance_market" ,"menu:marktplaats" ),
array(_("Inbox") ,"page/menu_messages&action=messages_inbox" ,"login" ),
array(_("Reports") ,"page/menu_report" ,"menu:rapportages:root,menu:rapportages" ),
array(_("System maintenance") ,"page/menu_system&action=system_overview" ,"menu:systeemonderhoud" ),
// obsolete; replace by knowledge base //array("Documentation" ,"page/menu_doc" ,"menu:documentatie" ),
array(_("Knowledge Base") ,"page/menu_kb" ,"menu:documentatie" ),
array(_("FAQ maintenance") ,"" ,"menu:faq" ));
// Check if project has been selected => log user-project action
$log_info = "";
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
$log_info = array();
$log_info['table'] = "log_gebruiker_project";
$log_info['project_id'] = $_SESSION[$_PAGE_INFO['id']]['login']['project']['id'];
}
else {
unset($_SESSION[$_PAGE_INFO['id']]['project_info']);
unset($_SESSION[$_PAGE_INFO['id']]['project_doc']);
}
// Clear previous session info
unset($_SESSION[$_PAGE_INFO['id']]['action']);
unset($_SESSION[$_PAGE_INFO['id']]['recall']);
unset($_SESSION[$_PAGE_INFO['id']]['main_menu']);
unset($_SESSION[$_PAGE_INFO['id']]['sts']);
unset($_SESSION[$_PAGE_INFO['id']]['tcp_channel']);
unset($_SESSION[$_PAGE_INFO['id']]['LKS']);
unset($_SESSION[$_PAGE_INFO['id']]['log']);
unset($_SESSION[$_PAGE_INFO['id']]['status_di']);
unset($_SESSION[$_PAGE_INFO['id']]['status_owner']);
unset($_SESSION[$_PAGE_INFO['id']]['lance_info']);
unset($_SESSION[$_PAGE_INFO['id']]['wo_info']);
unset($_SESSION[$_PAGE_INFO['id']]['wo_doc']);
unset($_SESSION[$_PAGE_INFO['id']]['report_info']);
unset($_SESSION[$_PAGE_INFO['id']]['periodic_info']);
unset($_SESSION[$_PAGE_INFO['id']]['user_info']);
unset($_SESSION[$_PAGE_INFO['id']]['messages_info']);
unset($_SESSION[$_PAGE_INFO['id']]['customer_info']);
unset($_SESSION[$_PAGE_INFO['id']]['market_info']);
unset($_SESSION[$_PAGE_INFO['id']]['system_info']);
unset($_SESSION[$_PAGE_INFO['id']]['change_info']);
unset($_SESSION[$_PAGE_INFO['id']]['change_doc']);
unset($_SESSION[$_PAGE_INFO['id']]['version_info']);
unset($_SESSION[$_PAGE_INFO['id']]['version_doc']);
unset($_SESSION[$_PAGE_INFO['id']]['syscomp_info']);
unset($_SESSION[$_PAGE_INFO['id']]['syscomp_doc']);
unset($_SESSION[$_PAGE_INFO['id']]['woitem_info']);
unset($_SESSION[$_PAGE_INFO['id']]['woitem_doc']);
// Verify "login" rights!
if (Ver_Rights_Project_Log("login", $menu, $log_info)) {
// Display project info??? => adapt main menu
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
// Set page title (in two places???)
$_SESSION[$_PAGE_INFO['id']]['title'] = $_PAGE_INFO['page_title'] = _("Project info");
}
else {
// Store title
$_SESSION[$_PAGE_INFO['id']]['title'] = _("Main menu");
}
// Show page header
$y_position = ((isset($_SESSION[$_PAGE_INFO['id']]['project_info']['y_position'])) && isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) ? ($_SESSION[$_PAGE_INFO['id']]['project_info']['y_position']) : 0;
print_xml_header($y_position);
// Display project info??? => adapt main menu
if (isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
// Set specific session info
$_SESSION[$_PAGE_INFO['id']]['action'] = "project_info";
$_SESSION[$_PAGE_INFO['id']]['search']['project']['id'] = $_SESSION[$_PAGE_INFO['id']]['login']['project']['id'];
// Display project info
include("scripts/page/menu_project_info_data.php");
include("scripts/page/menu_project_info_content.php");
// Display pop-up for document transfer
if ($transfer_submit) {
echo "<script type=\"text/javascript\">\n";
echo "onSubmit('doc_transfer_changed', '', 1);";
echo "</script>\n";
}
}
else {
// Set session info main menu => to be clear that the main menu was starting point
$_SESSION[$_PAGE_INFO['id']]['main_menu'] = "true";
// Collect menu items
$i = 0;
if (is_array($_PAGE_INFO['menu_items'])) {
foreach ($_PAGE_INFO['menu_items'] as $menu_item) {
$valid = db_ver_rights_user_one_valid($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], $menu_item[2]);
// Normal menu => display all
if (!isset($_SESSION[$_PAGE_INFO['id']]['login']['project']['id'])) {
// Retrieve button text
$menu_items[$i] = $menu_item[0];
// Verify menu rights and available link => enable/disable
if (($valid) && (!empty($menu_item[1]))) {
$menu_rights[$i] = 1;
}
else {
$menu_rights[$i] = 0;
}
// Retrieve button link
$menu_links[$i] = "?id=" . $_PAGE_INFO['id'] . "&href=" . $menu_item[1];
// Increment counter
$i++;
}
}
}
// Display main menu
print_menu(_("Main menu"), $menu_items, $menu_links, $menu_rights);
}
// Show page footer
print_page_footer();
}
?>