public function __construct() { // This module uses XSLT templates $GLOBALS['phpgw_info']['flags']['xslt_app'] = true; $this->config = CreateObject('phpgwapi.config', 'frontend'); $this->config->read(); $use_fellesdata = $this->config->config_data['use_fellesdata']; $logo_path = $this->config->config_data['logo_path']; // Get the mode: in frame or full screen $mode = phpgwapi_cache::session_get('frontend', 'noframework'); $noframework = isset($mode) ? $mode : true; /* Get the tabs and check to see whether the user has specified a tab or has a selected tab on session */ $tabs = $this->get_tabs(); $location_id = phpgw::get_var('location_id', 'int', 'REQUEST'); $tab = isset($location_id) ? $location_id : phpgwapi_cache::session_get('frontend', 'tab'); $selected = isset($tab) && $tab ? $tab : array_shift(array_keys($tabs)); $this->tabs = $GLOBALS['phpgw']->common->create_tabs($tabs, $selected); $this->menu = $this->create_menu($tabs, $selected); phpgwapi_cache::session_set('frontend', 'tab', $selected); // Get header state $this->header_state = phpgwapi_cache::session_get('frontend', 'header_state'); $this->header_state['use_fellesdata'] = $use_fellesdata; $this->header_state['logo_path'] = $logo_path; $this->header_state['form_action'] = $tabs[$selected]['link']; // Get navigation parameters $param_selected_location = phpgw::get_var('location'); // New location selected from locations list $param_selected_org_unit = phpgw::get_var('org_unit_id'); // New organisational unit selected from organisational units list $param_only_org_unit = phpgw::get_var('org_enhet_id'); // Frontend access from rental module regarding specific organisational unit //Refresh organisation list $refresh = phpgw::get_var('refresh', 'bool'); $property_locations_update = false; /* If the user has selected an organisational unit or all units */ if (isset($param_selected_org_unit) && $param_selected_org_unit && $param_selected_org_unit != 'none') { //Specify which unit(s) if ($param_selected_org_unit == 'all') { $org_unit_ids = $this->header_state['org_unit']; } else { if ($this->org_unit_in_selection($param_selected_org_unit, $this->header_state['org_unit'])) { //Creating a temporary array holding the single organisational unit in query $org_unit_ids = array(array("ORG_UNIT_ID" => $param_selected_org_unit)); } else { //If the organisational unit selected is not in list; do default 'all' $org_unit_ids = $this->header_state['org_unit']; $param_selected_org_unit = 'none'; } } $this->header_state['selected_org_unit'] = $param_selected_org_unit; //Update locations according to organisational unit specification $property_locations = frontend_borental::get_property_locations($org_unit_ids, $this->header_state['org_unit']); $property_locations_update = true; } else { if ($param_selected_org_unit == 'none') { $this->header_state['selected_org_unit'] = $param_selected_org_unit; $property_locations = array(); $this->header_state['locations'] = $property_locations; $this->header_state['number_of_locations'] = count($property_locations); } else { if (isset($param_only_org_unit) && $param_only_org_unit && $param_selected_org_unit != 'none') { //TODO: check permissions if ($use_fellesdata) { $name_and_result_number = frontend_bofellesdata::get_instance()->get_organisational_unit_info($param_only_org_unit); //Specify unit $org_unit_ids = array(array("ORG_UNIT_ID" => $param_only_org_unit, "ORG_NAME" => $name_and_result_number['UNIT_NAME'], "UNIT_ID" => $name_and_result_number['UNIT_NUMBER'])); //Update header state $this->header_state['org_unit'] = $org_unit_ids; $this->header_state['number_of_org_units'] = '1'; //$this->header_state['selected_org_unit'] = $name_and_result_number['UNIT_NUMBER']; $this->header_state['selected_org_unit'] = $param_only_org_unit; //Update locations $property_locations = frontend_borental::get_property_locations($org_unit_ids, $this->header_state['org_unit']); $property_locations_update = true; $noframework = false; // In regular frames phpgwapi_cache::session_set('frontend', 'noframework', $noframework); // Store mode on session $GLOBALS['phpgw_info']['flags']['menu_selection'] = "frontend::{$selected}"; $this->insert_links_on_header_state(); } } else { if (!isset($this->header_state) || isset($refresh) || !isset($this->header_state['locations'])) { if ($use_fellesdata) { //Specify organisational units $org_units = frontend_bofellesdata::get_instance()->get_result_units($GLOBALS['phpgw_info']['user']['account_lid']); //Merge with delegation units $delegation_org_ids = frontend_bofrontend::get_delegations($GLOBALS['phpgw_info']['user']['account_id']); if (count($delegation_org_ids) > 0) { $delegation_units = frontend_bofellesdata::get_instance()->populate_result_units($delegation_org_ids); $org_units = array_merge($org_units, $delegation_units); } //Update org units on header state $this->header_state['org_unit'] = $org_units; $this->header_state['number_of_org_units'] = count($org_units); $this->header_state['selected_org_unit'] = 'none'; //Update locations //FIXME Sigurd 15. okt 2013: deselect 'all' on initial view //$property_locations = frontend_borental::get_property_locations($org_units, $this->header_state['org_unit']); } else { if ($param_selected_org_unit != 'none') { //If no organisational database is in use: get rented properties based on username $usernames[] = $GLOBALS['phpgw_info']['user']['account_lid']; $property_locations = frontend_borental::get_property_locations($usernames, $this->header_state['org_unit']); } } $property_locations_update = true; $this->insert_links_on_header_state(); } } } } if ($property_locations_update) { if (count($property_locations) > 0) { $this->header_state['selected_location'] = $property_locations[0]['location_code']; $param_selected_location = $property_locations[0]['location_code']; } else { $this->header_state['selected_location'] = ''; $param_selected_location = ''; } $this->header_state['locations'] = $property_locations; $this->header_state['number_of_locations'] = count($property_locations); //FIXME $this->calculate_totals($property_locations); } /* If the user has selected a location or as a side-effect from selecting organisational unit */ if ($param_selected_location) { $locs = $this->header_state['locations']; $exist = false; foreach ($locs as $loc) { if ($loc['location_code'] == $param_selected_location) { $exist = true; } } if ($exist) { $this->header_state['selected_location'] = $param_selected_location; $parties = frontend_borental::get_all_parties(array(), $this->header_state['selected_org_unit']); $totals = frontend_borental::get_total_cost_and_area($parties, $param_selected_location); $this->header_state['selected_total_price'] = number_format($totals['sum_total_price'], 2, ",", " ") . " " . lang('currency'); $this->header_state['selected_total_area'] = number_format($totals['sum_total_area'], 2, ",", " ") . " " . lang('square_meters'); phpgwapi_cache::session_set('frontend', 'header_state', $this->header_state); } else { //Set totals to 0 $this->header_state['selected_location'] = $param_selected_location; $this->header_state['selected_total_price'] = lang('no_selection'); $this->header_state['selected_total_area'] = lang('no_selection'); phpgwapi_cache::session_set('frontend', 'header_state', $this->header_state); } phpgwapi_cache::session_clear('frontend', 'contract_state'); phpgwapi_cache::session_clear('frontend', 'contract_state_in'); phpgwapi_cache::session_clear('frontend', 'contract_state_ex'); } /* Store the header state on the session*/ $bomessenger = CreateObject('messenger.bomessenger'); $total_messages = $bomessenger->total_messages(" AND message_status = 'N'"); if ($total_messages > 0) { $this->header_state['new_messages'] = "({$total_messages})"; } else { $this->header_state['new_messages'] = lang('no_new_messages'); } phpgwapi_cache::session_set('frontend', 'header_state', $this->header_state); $GLOBALS['phpgw']->css->add_external_file('frontend/templates/base/base.css'); $GLOBALS['phpgw_info']['flags']['noframework'] = true; $GLOBALS['phpgw']->js->validate_file('jquery', 'menu', 'frontend'); }