public function get_db()
 {
     if ($this->db && is_object($this->db)) {
         return $this->db;
     }
     $config = CreateObject('phpgwapi.config', 'rental');
     $config->read();
     if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) {
         $message = "Database server {$config->config_data['external_db_host']} is not accessible";
         phpgwapi_cache::message_set($message, 'error');
         return false;
     }
     $db = createObject('phpgwapi.db', null, null, true);
     $db->debug = !!$config->config_data['external_db_debug'];
     $db->Host = $config->config_data['external_db_host'];
     $db->Port = $config->config_data['external_db_port'];
     $db->Type = $config->config_data['external_db_type'];
     $db->Database = $config->config_data['external_db_name'];
     $db->User = $config->config_data['external_db_user'];
     $db->Password = $config->config_data['external_db_password'];
     try {
         $db->connect();
         $this->connected = true;
     } catch (Exception $e) {
         $status = lang('unable_to_connect_to_database');
     }
     $this->db = $db;
     return $db;
 }
 public function get_db()
 {
     if ($this->db && is_object($this->db)) {
         return $this->db;
     }
     $config = CreateObject('phpgwapi.config', 'rental');
     $config->read();
     if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) {
         $message = "Database server {$config->config_data['external_db_host']} is not accessible";
         phpgwapi_cache::message_set($message, 'error');
         return false;
     }
     $db = createObject('phpgwapi.db', null, null, true);
     $db->debug = !!$config->config_data['external_db_debug'];
     $db->Host = $config->config_data['external_db_host'];
     $db->Port = $config->config_data['external_db_port'];
     $db->Type = $config->config_data['external_db_type'];
     $db->Database = $config->config_data['external_db_name'];
     $db->User = $config->config_data['external_db_user'];
     $db->Password = $config->config_data['external_db_password'];
     $db->Halt_On_Error = 'no';
     try {
         $db->connect();
     } catch (Exception $e) {
         phpgwapi_cache::message_set('Could not connect to backend-server ' . $config->config_data['external_db_host'], 'error');
         $GLOBALS['phpgw']->redirect_link('/home.php');
     }
     $this->db = $db;
     return $db;
 }
 /**
  * Add a contact to a location
  *
  * @return void
  */
 public function add_location_contact($data)
 {
     if (!isset($data['location_code']) || !$data['location_code']) {
         phpgwapi_cache::message_set("location_code not set", 'error');
         return false;
     }
     $value_set = array();
     $value_set['location_code'] = $data['location_code'];
     $value_set['contact_id'] = $data['contact_id'];
     $value_set['user_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
     $value_set['entry_date'] = time();
     $value_set['modified_date'] = time();
     $cols = implode(',', array_keys($value_set));
     $values = $GLOBALS['phpgw']->db->validate_insert(array_values($value_set));
     $sql = "INSERT INTO fm_location_contact ({$cols}) VALUES ({$values})";
     $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
     if ($data['email']) {
         $pref = CreateObject('phpgwapi.preferences', $data['account_id']);
         $pref->read();
         $pref->add('property', 'email', $data['email'], 'user');
         $pref->save_repository();
     }
     $message = lang('user %1 added to %2', $data['account_lid'], $data['location_code']);
     phpgwapi_cache::message_set($message, 'message');
 }
 public function __construct()
 {
     phpgwapi_cache::session_set('frontend', 'tab', $GLOBALS['phpgw']->locations->get_id('frontend', '.drawings'));
     parent::__construct();
     $this->location_code = $this->header_state['selected_location'];
     //			$this->location_code = '1102-01';
 }
 /**
  * View a list of all resultunits
  */
 public function index()
 {
     $search_for = phpgw::get_var('search_for');
     if ($search_for) {
         phpgwapi_cache::session_set('rental', 'resultunit_query', $search_for);
     }
     $this->render('resultunit_list.php');
 }
 public function __construct()
 {
     $extra_tabs = array();
     $extra_tabs[0] = array('label' => lang('messages'), 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.uimessages.index", 'noframework' => $noframework)));
     phpgwapi_cache::session_set('frontend', 'extra_tabs', $extra_tabs);
     phpgwapi_cache::session_set('frontend', 'tab', 0);
     parent::__construct();
 }
 public function __construct()
 {
     $this->contract_state_identifier = "contract_state";
     $this->contracts_per_location_identifier = "contracts_per_location";
     //	$this->form_url = "index.php?menuaction=frontend.uicontract_internal.index";
     $this->form_url = $GLOBALS['phpgw']->link('/', array('menuaction' => 'frontend.uicontract_internal.index'));
     phpgwapi_cache::session_set('frontend', 'tab', $GLOBALS['phpgw']->locations->get_id('frontend', '.rental.contract'));
     parent::__construct();
 }
 public function execute()
 {
     $orders = array();
     $sql = "SELECT DISTINCT fm_workorder.id as order_id" . " FROM fm_workorder " . " {$this->join} fm_workorder_budget ON fm_workorder.id = fm_workorder_budget.order_id" . " WHERE continuous = 1" . " ORDER BY fm_workorder.id";
     $this->db->query($sql, __LINE__, __FILE__);
     $_order_budget = array();
     while ($this->db->next_record()) {
         $orders[] = $this->db->f('order_id');
     }
     foreach ($orders as $order_id) {
         phpgwapi_cache::system_clear('property', "budget_order_{$order_id}");
         execMethod('property.soworkorder.get_budget', $order_id);
     }
     $count_orders = count($orders);
     $this->receipt['message'][] = array('msg' => "Rekalkulert budsjett for {$count_orders} løpende bestillinger");
 }
 public function store_doc_to_vfs($file)
 {
     $root_directory = self::$ROOT_FOR_DOCUMENTS;
     $type_directory = self::$HELP_DOCUMENTS;
     $lang_directory = self::$LANG_DIR;
     $vfs = CreateObject('phpgwapi.vfs');
     $vfs->override_acl = 1;
     $path = $root_directory;
     $dir = array('string' => $path, RELATIVE_NONE);
     if (!$vfs->file_exists($dir)) {
         if (!$vfs->mkdir($dir)) {
             return;
         }
     }
     $path .= $type_directory;
     $dir = array('string' => $path, RELATIVE_NONE);
     if (!$vfs->file_exists($dir)) {
         if (!$vfs->mkdir($dir)) {
             return;
         }
     }
     $path .= $lang_directory;
     $dir = array('string' => $path, RELATIVE_NONE);
     if (!$vfs->file_exists($dir)) {
         if (!$vfs->mkdir($dir)) {
             return;
         }
     }
     $mime_magic = createObject('phpgwapi.mime_magic');
     $mime = $mime_magic->filename2mime($file['name']);
     if ($mime != 'application/pdf') {
         $message = 'Only PDF is supported for this one';
         phpgwapi_cache::message_set($message, 'error');
         return $message;
     }
     $file_path = "{$path}/helpdesk.index.pdf";
     $result = $vfs->write(array('string' => $file_path, RELATIVE_NONE, 'content' => file_get_contents($file['tmp_name'])));
     if ($result) {
         $message = 'Stored in vfs';
         phpgwapi_cache::message_set($message, 'message');
         return $message;
     }
     return "something failed...";
 }
 /**
  * Add a contact to a location
  *
  * @return void
  */
 public function add_contract_from_composite(&$data)
 {
     if (!isset($data['location_code']) || !$data['location_code']) {
         phpgwapi_cache::message_set("location_code not set", 'error');
         return false;
     }
     $criteria = array('appname' => 'rental', 'location' => $data['acl_location'], 'pre_commit' => true, 'allrows' => true);
     $custom_functions = $GLOBALS['phpgw']->custom_functions->find($criteria);
     foreach ($custom_functions as $entry) {
         // prevent path traversal
         if (preg_match('/\\.\\./', $entry['file_name'])) {
             continue;
         }
         $file = PHPGW_SERVER_ROOT . "/rental/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
         if ($entry['active'] && is_file($file) && !$entry['client_side']) {
             require $file;
         }
     }
 }
 public function __construct()
 {
     $this->db =& $GLOBALS['phpgw']->db;
     $location_id = $GLOBALS['phpgw']->locations->get_id('admin', 'vfs_filedata');
     $c = CreateObject('admin.soconfig', $location_id);
     $section = 'braArkiv';
     $location_url = $c->config_data[$section]['location_url'];
     //'http://braarkiv.adm.bgo/service/services.asmx';
     $braarkiv_user = $c->config_data[$section]['braarkiv_user'];
     $braarkiv_pass = $c->config_data[$section]['braarkiv_pass'];
     if (!isset($c->config_data) || !$c->config_data) {
         $this->config = $c;
         $this->init_config();
     }
     if (!$location_url || !$braarkiv_pass || !$braarkiv_pass) {
         throw new Exception('braArkiv is not configured');
     }
     $wdsl = "{$location_url}?WSDL";
     $options = array();
     $options[Bra5WsdlClass::WSDL_URL] = $wdsl;
     $options[Bra5WsdlClass::WSDL_ENCODING] = 'UTF-8';
     $options[Bra5WsdlClass::WSDL_TRACE] = false;
     $options[Bra5WsdlClass::WSDL_SOAP_VERSION] = SOAP_1_2;
     try {
         $wsdlObject = new Bra5WsdlClass($options);
     } catch (Exception $e) {
         if ($e) {
             phpgwapi_cache::message_set($e->getMessage(), 'error');
             return false;
         }
     }
     $bra5ServiceLogin = new Bra5ServiceLogin();
     if ($bra5ServiceLogin->Login(new Bra5StructLogin($braarkiv_user, $braarkiv_pass))) {
         $this->secKey = $bra5ServiceLogin->getResult()->getLoginResult()->LoginResult;
     } else {
         throw new Exception('vfs_fileoperation_braArkiv::Login failed');
     }
 }
 public function get_username()
 {
     $config = CreateObject('phpgwapi.config', 'rental');
     $config->read();
     if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) {
         $message = "Database server {$config->config_data['external_db_host']} is not accessible";
         phpgwapi_cache::message_set($message, 'error');
         return false;
     }
     $db = createObject('phpgwapi.db', null, null, true);
     $db->debug = !!$config->config_data['external_db_debug'];
     $db->Host = $config->config_data['external_db_host'];
     $db->Port = $config->config_data['external_db_port'];
     $db->Type = $config->config_data['external_db_type'];
     $db->Database = $config->config_data['external_db_name'];
     $db->User = $config->config_data['external_db_user'];
     $db->Password = $config->config_data['external_db_password'];
     try {
         $db->connect();
     } catch (Exception $e) {
         $message = lang('unable_to_connect_to_database');
         phpgwapi_cache::message_set($message, 'error');
         return false;
     }
     $headers = getallheaders();
     //			$headers['Osso-User-Dn'] = 'cn=02035701829,cn=users,dc=usrv,dc=ubergenkom,dc=no';// test
     $header_regular_expression = '/^cn=(.*),cn=users.*$/';
     $header_key = 'Osso-User-Dn';
     $matches = array();
     preg_match_all($header_regular_expression, $headers[$header_key], $matches);
     $fodsels_nr = $matches[1][0];
     $uid = $headers['uid'];
     $fodsels_nr = $uid ? $uid : $fodsels_nr;
     $sql = "SELECT BRUKERNAVN FROM V_AD_PERSON WHERE FODSELSNR ='{$fodsels_nr}'";
     $db->query($sql, __LINE__, __FILE__);
     $db->next_record();
     return $db->f('BRUKERNAVN', true);
 }
 public function __construct()
 {
     $GLOBALS['phpgw']->translation->add_app('property');
     $this->location_id = phpgw::get_var('location_id', 'int', 'REQUEST', 0);
     $location_info = $GLOBALS['phpgw']->locations->get_name($this->location_id);
     $this->acl_location = $location_info['location'];
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
     $this->acl =& $GLOBALS['phpgw']->acl;
     $this->acl_read = $this->acl->check($this->acl_location, PHPGW_ACL_READ, 'frontend');
     phpgwapi_cache::session_set('frontend', 'tab', $this->location_id);
     parent::__construct();
     $this->location_code = $this->header_state['selected_location'];
     /*
     			$this->bo->location_code = $this->location_code;
     			
     			$_org_units = array();
     			if(is_array($this->header_state['org_unit']))
     			{
     				foreach ($this->header_state['org_unit'] as $org_unit)
     				{
     					$_org_unit_id = (int)$org_unit['ORG_UNIT_ID'];
     					$_subs = execMethod('property.sogeneric.read_tree',array('node_id' => $_org_unit_id, 'type' => 'org_unit'));
     					$_org_units[$_org_unit_id] = true;
     					foreach($_subs as $entry)
     					{
     						$_org_units[$entry['id']] = true;
     						if(isset($entry['children']) && $entry['children'])
     						{
     							$this->_get_children($entry['children'], $_org_units);			
     						}
     					}
     				}
     			}
     			$org_units = array_keys($_org_units);
     			$this->bo->org_units = $org_units;
     */
 }
 public function index()
 {
     if (!$this->acl_read) {
         echo lang('no access');
         $GLOBALS['phpgw']->common->phpgw_exit();
     }
     $app = phpgw::get_var('app', 'string', 'GET');
     //get session's values
     $data = phpgwapi_cache::session_get($app, 'id_debug');
     if (isset($data)) {
         //clear session
         phpgwapi_cache::session_clear($app, 'id_debug');
         //replace '<' and '>'
         if (is_array($data)) {
             self::_my_print_rec($data, 0);
         } else {
             $data = htmlspecialchars($data);
         }
         _debug_array($data);
     } else {
         echo "empty session's value";
     }
     $GLOBALS['phpgw']->common->phpgw_exit();
 }
 function edit($view = '')
 {
     $get_history = phpgw::get_var('get_history', 'bool', 'POST');
     $change_type = phpgw::get_var('change_type', 'int', 'POST');
     $lookup_tenant = phpgw::get_var('lookup_tenant', 'bool');
     $location_code = phpgw::get_var('location_code');
     $sibling = phpgw::get_var('sibling');
     $parent = phpgw::get_var('parent');
     $values_attribute = phpgw::get_var('values_attribute');
     $location = explode('-', $location_code);
     $error_id = false;
     if ($sibling) {
         $parent = array();
         $sibling = explode('-', $sibling);
         $this->type_id = count($sibling);
         for ($i = 0; $i < count($sibling) - 1; $i++) {
             $parent[] = $sibling[$i];
         }
         $parent = implode('-', $parent);
     }
     $type_id = $this->type_id;
     if ($location_code) {
         $type_id = count($location);
     }
     if ($type_id && !$lookup_tenant) {
         $GLOBALS['phpgw_info']['flags']['menu_selection'] .= "::loc_{$type_id}";
     } else {
         $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::tenant';
     }
     if ($view) {
         if (!$this->acl_read) {
             $this->bocommon->no_access();
             return;
         }
         $mode = 'view';
     } else {
         if (!$this->acl_add && !$this->acl_edit) {
             $this->bocommon->no_access();
             return;
         }
         $mode = 'edit';
     }
     $values = array();
     if (isset($_POST['save']) && !$view) {
         $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property');
         $GLOBALS['phpgw']->session->appsession('insert_record', 'property', '');
         if (isset($insert_record['location']) && is_array($insert_record['location'])) {
             for ($i = 0; $i < count($insert_record['location']); $i++) {
                 $values[$insert_record['location'][$i]] = phpgw::get_var($insert_record['location'][$i], 'string', 'POST');
             }
         }
         $insert_record_attributes = $GLOBALS['phpgw']->session->appsession('insert_record_values' . '.location.' . $this->type_id, 'property');
         if (is_array($insert_record_attributes)) {
             foreach ($insert_record_attributes as $attribute) {
                 foreach ($values_attribute as &$attr) {
                     if ($attr['name'] == $attribute) {
                         $attr['value'] = phpgw::get_var($attribute, 'string', 'POST');
                     }
                 }
             }
         }
         if (isset($insert_record['extra']) && is_array($insert_record['extra'])) {
             for ($i = 0; $i < count($insert_record['extra']); $i++) {
                 $values[$insert_record['extra'][$i]] = phpgw::get_var($insert_record['extra'][$i], 'string', 'POST');
             }
         }
     }
     $GLOBALS['phpgw']->xslttpl->add_file(array('location', 'attributes_form'));
     if ($values) {
         for ($i = 1; $i < $type_id + 1; $i++) {
             if (!$values["loc{$i}"] && (!isset($location[$i - 1]) || !$location[$i - 1]) || !$values["loc{$i}"]) {
                 $receipt['error'][] = array('msg' => lang('Please select a location %1 ID !', $i));
                 $error_id = true;
             }
             $values['location_code'][] = $values["loc{$i}"];
             if ($i < $type_id) {
                 $location_parent[] = $values["loc{$i}"];
             }
         }
         if (!$values['cat_id']) {
             $receipt['error'][] = array('msg' => lang('Please select a category'));
         }
         if (isset($values_attribute) && is_array($values_attribute)) {
             foreach ($values_attribute as $attribute) {
                 if ($attribute['nullable'] != 1 && !$attribute['value']) {
                     $receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text']));
                 }
                 if ($attribute['datatype'] == 'I' && isset($attribute['value']) && $attribute['value'] && !ctype_digit($attribute['value'])) {
                     $receipt['error'][] = array('msg' => lang('Please enter integer for attribute %1', $attribute['input_text']));
                 }
             }
         }
         if (isset($insert_record['extra']) && array_search('street_id', $insert_record['extra']) && (!isset($values['street_id']) || !$values['street_id'])) {
             $receipt['error'][] = array('msg' => lang('Please select a street'));
         }
         if (isset($insert_record['extra']) && array_search('part_of_town_id', $insert_record['extra']) && (!isset($values['part_of_town_id']) || !$values['part_of_town_id'])) {
             $receipt['error'][] = array('msg' => lang('Please select a part of town'));
         }
         if (isset($insert_record['extra']) && array_search('owner_id', $insert_record['extra']) && (!isset($values['owner_id']) || !$values['owner_id'])) {
             $receipt['error'][] = array('msg' => lang('Please select an owner'));
         }
         $values['location_code'] = implode("-", $values['location_code']);
         if ($values['location_code'] && !$location_code) {
             if ($this->bo->check_location($values['location_code'], $type_id)) {
                 $receipt['error'][] = array('msg' => lang('This location is already registered!') . '[ ' . $values['location_code'] . ' ]');
                 $error_location_id = true;
                 $error_id = true;
             }
         }
         if ($location_code) {
             $action = 'edit';
             $values['change_type'] = $change_type;
             if (!$values['change_type']) {
                 $receipt['error'][] = array('msg' => lang('Please select change type'));
             }
         }
         if (!isset($receipt['error'])) {
             $receipt = $this->bo->save($values, $values_attribute, $action, $type_id, isset($location_parent) ? $location_parent : '');
             $error_id = isset($receipt['location_code']) && $receipt['location_code'] ? false : true;
             $location_code = $receipt['location_code'];
         } else {
             if (isset($location_parent) && $location_parent) {
                 $location_code_parent = implode('-', $location_parent);
                 $values = $this->bo->read_single($location_code_parent);
                 $values['attributes'] = $this->bo->find_attribute(".location.{$this->type_id}");
                 $values = $this->bo->prepare_attribute($values, ".location.{$this->type_id}");
                 /* restore date from posting */
                 if (isset($insert_record['extra']) && is_array($insert_record['extra'])) {
                     for ($i = 0; $i < count($insert_record['extra']); $i++) {
                         $values[$insert_record['extra'][$i]] = phpgw::get_var($insert_record['extra'][$i], 'string', 'POST');
                     }
                 }
             }
         }
     }
     if (!$error_id && $location_code) {
         $values = $this->bo->read_single($location_code, array('tenant_id' => 'lookup'));
         $check_history = $this->bo->check_history($location_code);
         if ($get_history) {
             $history = $this->bo->get_history($location_code);
             $uicols = $this->bo->uicols;
             $j = 0;
             if (isset($history) && is_array($history)) {
                 foreach ($history as $entry) {
                     $k = 0;
                     for ($i = 0; $i < count($uicols['name']); $i++) {
                         if ($uicols['input_type'][$i] != 'hidden') {
                             $content[$j]['row'][$k]['value'] = $entry[$uicols['name'][$i]];
                             $content[$j]['row'][$k]['name'] = $uicols['name'][$i];
                         }
                         $content[$j]['hidden'][$k]['value'] = $entry[$uicols['name'][$i]];
                         $content[$j]['hidden'][$k]['name'] = $uicols['name'][$i];
                         $k++;
                     }
                     $j++;
                 }
             }
             $uicols_count = count($uicols['descr']);
             for ($i = 0; $i < $uicols_count; $i++) {
                 if ($uicols['input_type'][$i] != 'hidden') {
                     $table_header[$i]['header'] = $uicols['descr'][$i];
                     $table_header[$i]['width'] = '5%';
                     $table_header[$i]['align'] = 'center';
                 }
             }
         }
     }
     /* Preserve attribute values from post */
     if (isset($receipt['error']) && (isset($values_attribute) && is_array($values_attribute))) {
         $values = $this->bocommon->preserve_attribute_values($values, $values_attribute);
         unset($values['location_code']);
     }
     if (!$values) {
         $values['attributes'] = $this->bo->find_attribute(".location.{$this->type_id}");
         $values = $this->bo->prepare_attribute($values, ".location.{$this->type_id}");
     }
     if ($values['cat_id']) {
         $this->cat_id = $values['cat_id'];
     }
     $link_data = array('menuaction' => $view ? 'property.uilocation.view' : 'property.uilocation.edit', 'location_code' => $location_code, 'type_id' => $type_id, 'lookup_tenant' => $lookup_tenant);
     $lookup_type = $view ? 'view' : 'form';
     if (!$location_code && $parent) {
         $_values = $this->bo->read_single($parent, array('noattrib' => true));
         $_values['attributes'] = $values['attributes'];
     } else {
         $_values = $values;
     }
     $location_data = $this->bo->initiate_ui_location(array('values' => $_values, 'type_id' => $type_id - 1, 'no_link' => $type_id, 'tenant' => false, 'lookup_type' => $lookup_type));
     unset($_values);
     $location_types = $this->bo->location_types;
     $config = $this->bo->config;
     if ($location_code) {
         $function_msg = lang('edit');
     } else {
         $function_msg = lang('add');
     }
     $function_msg .= ' ' . $location_types[$type_id - 1]['name'];
     $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property');
     if (!is_array($insert_record)) {
         $insert_record = array();
     }
     $j = 0;
     $additional_fields[$j]['input_text'] = $location_types[$type_id - 1]['name'];
     $additional_fields[$j]['statustext'] = $location_types[$type_id - 1]['descr'];
     $additional_fields[$j]['datatype'] = 'varchar';
     $additional_fields[$j]['input_name'] = 'loc' . $type_id;
     $additional_fields[$j]['name'] = 'loc' . $type_id;
     $additional_fields[$j]['value'] = isset($values[$additional_fields[$j]['input_name']]) ? $values[$additional_fields[$j]['input_name']] : '';
     $additional_fields[$j]['class'] = 'th_text';
     $insert_record['extra'][] = $additional_fields[$j]['input_name'];
     $j++;
     $additional_fields[$j]['input_text'] = lang('name');
     $additional_fields[$j]['statustext'] = lang('enter the name for this location');
     $additional_fields[$j]['datatype'] = 'varchar';
     $additional_fields[$j]['input_name'] = 'loc' . $type_id . '_name';
     $additional_fields[$j]['name'] = 'loc' . $type_id . '_name';
     $additional_fields[$j]['value'] = isset($values[$additional_fields[$j]['input_name']]) ? $values[$additional_fields[$j]['input_name']] : '';
     $additional_fields[$j]['size'] = $additional_fields[$j]['value'] ? strlen($additional_fields[$j]['value']) + 5 : 30;
     $insert_record['extra'][] = $additional_fields[$j]['input_name'];
     $j++;
     //_debug_array($attributes_values);
     $_config = CreateObject('phpgwapi.config', 'property');
     $_config->read();
     $insert_record['extra'][] = 'cat_id';
     $config_count = count($config);
     for ($j = 0; $j < $config_count; $j++) {
         if ($config[$j]['location_type'] == $type_id) {
             if ($config[$j]['column_name'] == 'street_id') {
                 $edit_street = true;
                 $insert_record['extra'][] = 'street_id';
                 $insert_record['extra'][] = 'street_number';
             }
             if ($config[$j]['column_name'] == 'tenant_id') {
                 if (!isset($_config->config_data['suppress_tenant']) || !$_config->config_data['suppress_tenant']) {
                     $edit_tenant = true;
                     $insert_record['extra'][] = 'tenant_id';
                 }
             }
             if ($config[$j]['column_name'] == 'part_of_town_id') {
                 $edit_part_of_town = true;
                 $select_name_part_of_town = 'part_of_town_id';
                 $part_of_town_list = $this->bocommon->select_part_of_town('select', $values['part_of_town_id']);
                 $lang_town_statustext = lang('Select the part of town the property belongs to. To do not use a part of town -  select NO PART OF TOWN');
                 $insert_record['extra'][] = 'part_of_town_id';
             }
             if ($config[$j]['column_name'] == 'owner_id') {
                 $edit_owner = true;
                 $lang_owner = lang('Owner');
                 $owner_list = $this->bo->get_owner_list('', $values['owner_id']);
                 $lang_select_owner = lang('Select owner');
                 $lang_owner_statustext = lang('Select the owner');
                 $insert_record['extra'][] = 'owner_id';
             }
         }
     }
     $GLOBALS['phpgw']->session->appsession('insert_record', 'property', $insert_record);
     if (isset($receipt)) {
         $msgbox_data = $this->bocommon->msgbox_data($receipt);
     }
     if ($location_code) {
         $change_type_list = $this->bo->select_change_type($values['change_type']);
         $location_types = $this->soadmin_location->read(array('order' => 'id', 'sort' => 'ASC'));
         foreach ($location_types as $location_type) {
             if ($type_id != $location_type['id']) {
                 if ($type_id > $location_type['id']) {
                     $entities_link[] = array('entity_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => "property.uilocation.{$mode}", 'location_code' => implode('-', array_slice($location, 0, $location_type['id'])))), 'lang_entity_statustext' => $location_type['descr'], 'text_entity' => '<- ' . $location_type['name']);
                 } else {
                     $_location_code = implode('-', array_slice($location, 0, $location_type['id']));
                     $marker = str_repeat('-', $location_type['id'] - $type_id);
                     $entities_link[] = array('entity_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $location_type['id'], 'query' => $_location_code, 'location_code' => $_location_code)), 'lang_entity_statustext' => $location_type['descr'], 'text_entity' => "{$marker}> " . $location_type['name']);
                     unset($_location_code);
                 }
             }
         }
     }
     phpgwapi_yui::tabview_setup('location_edit_tabview');
     $tabs = array();
     $tabs['general'] = array('label' => $location_types[$type_id - 1]['name'], 'link' => '#general');
     if (isset($values['attributes']) && is_array($values['attributes'])) {
         foreach ($values['attributes'] as &$attribute) {
             if ($attribute['history'] == true) {
                 $link_history_data = array('menuaction' => 'property.uilocation.attrib_history', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'attrib_id' => $attribute['id'], 'id' => $id, 'edit' => true);
                 $attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php', $link_history_data);
             }
         }
         $location = ".location.{$type_id}";
         $attributes_groups = $this->bo->get_attribute_groups($location, $values['attributes']);
         //	_debug_array($attributes_groups);die();
         $attributes_general = array();
         $attributes = array();
         foreach ($attributes_groups as $group) {
             if (isset($group['attributes']) && isset($group['group_sort'])) {
                 $tabs[str_replace(' ', '_', $group['name'])] = array('label' => $group['name'], 'link' => '#' . str_replace(' ', '_', $group['name']));
                 $group['link'] = str_replace(' ', '_', $group['name']);
                 $attributes[] = $group;
             } else {
                 if (isset($group['attributes']) && !isset($group['group_sort'])) {
                     $attributes_general = array_merge($attributes_general, $group['attributes']);
                 }
             }
         }
         unset($attributes_groups);
     }
     $documents = array();
     $file_tree = array();
     $integration = array();
     if ($location_code) {
         $_role_criteria = array('type' => 'responsibility_role', 'filter' => array('location_level' => $type_id), 'order' => 'name');
         $roles = execMethod('property.sogeneric.get_list', $_role_criteria);
         $soresponsible = CreateObject('property.soresponsible');
         $contacts = createObject('phpgwapi.contacts');
         foreach ($roles as &$role) {
             $responsible_item = $soresponsible->get_active_responsible_at_location($location_code, $role['id']);
             $role['responsibility_contact'] = $contacts->get_name_of_person_id($responsible_item['contact_id']);
             $responsibility = $soresponsible->read_single_contact($responsible_item['id']);
             $role['responsibility_name'] = $responsibility['responsibility_name'];
         }
         if ($roles) {
             $tabs['roles'] = array('label' => lang('contacts'), 'link' => '#roles');
         }
         //_debug_array($roles);die();
         $location_arr = explode('-', $location_code);
         //_debug_array($location_arr);die();
         $related = array();
         $_location_level_arr = array();
         foreach ($location_arr as $_location_level) {
             $_exact = $location_code == $_location_level ? false : true;
             $_location_level_arr[] = $_location_level;
             $location_level = implode('-', $_location_level_arr);
             $related[$location_level] = $this->bo->read_entity_to_link($location_level, $_exact);
         }
         //_debug_array($related);die();
         $location_type_info = $this->soadmin_location->read_single($type_id);
         $documents = array();
         if ($location_type_info['list_documents']) {
             $document = CreateObject('property.sodocument');
             $documents = $document->get_files_at_location(array('location_code' => $location_code));
         }
         if ($documents) {
             $tabs['document'] = array('label' => lang('document'), 'link' => '#document');
             $documents = json_encode($documents);
         }
         $_dirname = '';
         $_files_maxlevel = 0;
         if (isset($_config->config_data['external_files_maxlevel']) && $_config->config_data['external_files_maxlevel']) {
             $_files_maxlevel = $_config->config_data['external_files_maxlevel'];
         }
         $_files_filterlevel = 0;
         if (isset($_config->config_data['external_files_filterlevel']) && $_config->config_data['external_files_filterlevel']) {
             $_files_filterlevel = $_config->config_data['external_files_filterlevel'];
         }
         $_filter_info = explode('-', $location_code);
         if (isset($_config->config_data['external_files']) && $_config->config_data['external_files']) {
             $_dirname = $_config->config_data['external_files'];
             $file_tree = $document->read_file_tree($_dirname, $_files_maxlevel, $_files_filterlevel, $_filter_info[0]);
         }
         unset($_config);
         if ($file_tree) {
             $tabs['file_tree'] = array('label' => lang('Files'), 'link' => '#file_tree');
             $file_tree = json_encode($file_tree);
         }
         $_related = array();
         foreach ($related as $_location_level => $related_info) {
             if (isset($related_info['related'])) {
                 foreach ($related_info as $related_key => $related_data) {
                     if ($related_key == 'gab') {
                         foreach ($related_data as $entry) {
                             $entities_link[] = array('entity_link' => $entry['entity_link'], 'lang_entity_statustext' => $entry['descr'], 'text_entity' => $entry['name']);
                         }
                     } else {
                         foreach ($related_data as $entry) {
                             $_related[] = array('where' => $_location_level, 'url' => "<a href=\"{$entry['entity_link']}\" > {$entry['name']}</a>");
                         }
                     }
                 }
             }
         }
         $related_link = $_related ? true : false;
         $tabs['related'] = array('label' => lang('related'), 'link' => '#related');
         $datavalues = array();
         $myColumnDefs = array();
         $datavalues[0] = array('name' => "0", 'values' => json_encode($_related), 'total_records' => count($_related), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 0);
         $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'where', 'label' => lang('where'), 'sortable' => false, 'resizeable' => true), array('key' => 'url', 'label' => lang('what'), 'sortable' => false, 'resizeable' => true))));
         // ---- START INTEGRATION -------------------------
         $location_id = $GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
         $custom_config = CreateObject('admin.soconfig', $location_id);
         $_config = isset($custom_config->config_data) && $custom_config->config_data ? $custom_config->config_data : array();
         //_debug_array($custom_config->config_data);die();
         // required settings:
         /*
         				integration_tab
         				integration_height
         				integration_url
         				integration_parametres
         				integration_action
         				integration_action_view
         				integration_action_edit
         				integration_auth_key_name
         				integration_auth_url
         				integration_auth_hash_name
         				integration_auth_hash_value
         				integration_location_data
         */
         foreach ($_config as $_config_section => $_config_section_data) {
             if (isset($_config_section_data['tab'])) {
                 if (!isset($_config_section_data['url'])) {
                     phpgwapi_cache::message_set("'url' is a required setting for integrations, '{$_config_section}' is disabled", 'error');
                     break;
                 }
                 //get session key from remote system
                 $arguments = array($_config_section_data['auth_hash_name'] => $_config_section_data['auth_hash_value']);
                 $query = http_build_query($arguments);
                 $auth_url = $_config_section_data['auth_url'];
                 $request = "{$auth_url}?{$query}";
                 $aContext = array('http' => array('request_fulluri' => true));
                 if (isset($GLOBALS['phpgw_info']['server']['httpproxy_server'])) {
                     $aContext['http']['proxy'] = "{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
                 }
                 $cxContext = stream_context_create($aContext);
                 $response = trim(file_get_contents($request, False, $cxContext));
                 $_config_section_name = str_replace(' ', '_', $_config_section);
                 $integration[] = array('section' => $_config_section_name, 'height' => isset($_config_section_data['height']) && $_config_section_data['height'] ? $_config_section_data['height'] : 500);
                 $_config_section_data['url'] = htmlspecialchars_decode($_config_section_data['url']);
                 $_config_section_data['parametres'] = htmlspecialchars_decode($_config_section_data['parametres']);
                 /*
                  * 'parametres' In the form:
                  * <targetparameter1>=__<attrbute_name1>__&<targetparameter2>=__<attrbute_name2>__&
                  * Example: objId=__id__&lon=__posisjon_lengde__&lat=__posisjon_bredde__
                  */
                 parse_str($_config_section_data['parametres'], $output);
                 $_values = array();
                 foreach ($output as $_dummy => $_substitute) {
                     $_keys[] = $_substitute;
                     $__value = false;
                     if (!($__value = urlencode($values[trim($_substitute, '_')]))) {
                         foreach ($values['attributes'] as $_attribute) {
                             if (trim($_substitute, '_') == $_attribute['name']) {
                                 $__value = urlencode($_attribute['value']);
                                 break;
                             }
                         }
                     }
                     if ($__value) {
                         $_values[] = $__value;
                     }
                 }
                 //_debug_array($_config_section_data['parametres']);
                 //_debug_array($_values);
                 unset($output);
                 unset($__value);
                 $_sep = '?';
                 if (stripos($_config_section_data['url'], '?')) {
                     $_sep = '&';
                 }
                 $_param = $_config_section_data['parametres'] ? $_sep . str_replace($_keys, $_values, $_config_section_data['parametres']) : '';
                 unset($_keys);
                 unset($_values);
                 //				$integration_src = phpgw::safe_redirect("{$_config_section_data['url']}{$_sep}{$_param}");
                 $integration_src = "{$_config_section_data['url']}{$_param}";
                 if ($_config_section_data['action']) {
                     $_sep = '?';
                     if (stripos($integration_src, '?')) {
                         $_sep = '&';
                     }
                     //$integration_src .= "{$_sep}{$_config_section_data['action']}=" . $_config_section_data["action_{$mode}"];
                 }
                 $arguments = array($_config_section_data['auth_key_name'] => $response);
                 //in the form: sakstittel=__loc1__.__loc4__
                 if (isset($_config_section_data['location_data']) && $_config_section_data['location_data']) {
                     $_config_section_data['location_data'] = htmlspecialchars_decode($_config_section_data['location_data']);
                     parse_str($_config_section_data['location_data'], $output);
                     foreach ($output as $_dummy => $_substitute) {
                         //$_substitute = '__loc1__.__loc4__%';
                         $regex = "/__([\\w]+)__/";
                         preg_match_all($regex, $_substitute, $matches);
                         foreach ($matches[1] as $__substitute) {
                             $_values[] = urlencode($values[$__substitute]);
                         }
                     }
                     //FIXME
                     $integration_src .= $_config_section_data['url_separator'] . str_replace($matches[0], $_values, $_config_section_data['location_data']);
                 }
                 if (isset($_config_section_data['auth_key_name']) && $_config_section_data['auth_key_name']) {
                     $integration_src .= "&{$_config_section_data['auth_key_name']}={$response}";
                 }
                 //FIXME NOT WORKING!! test for webservice, auth...
                 if (isset($_config_section_data['method']) && $_config_section_data['method'] == 'POST') {
                     $aContext = array('http' => array('method' => 'POST', 'request_fulluri' => true));
                     if (isset($GLOBALS['phpgw_info']['server']['httpproxy_server'])) {
                         $aContext['http']['proxy'] = "{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
                     }
                     $cxContext = stream_context_create($aContext);
                     $response = trim(file_get_contents($integration_src, False, $cxContext));
                 }
                 //_debug_array($values);
                 //_debug_array($integration_src);die();
                 $tabs[$_config_section] = array('label' => $_config_section_data['tab'], 'link' => "#{$_config_section_name}", 'function' => "document.getElementById('{$_config_section_name}_content').src = '{$integration_src}';");
             }
         }
         // ---- END INTEGRATION -------------------------
     }
     unset($values['attributes']);
     $property_js = "/property/js/yahoo/property2.js";
     if (!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || !$GLOBALS['phpgw_info']['server']['no_jscombine']) {
         $cachedir = urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
         $property_js = "/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . str_replace('/', '--', ltrim($property_js, '/'));
     }
     $data = array('property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'integration' => $integration, 'roles' => $roles, 'edit' => $view ? '' : true, 'lang_change_type' => lang('Change type'), 'lang_no_change_type' => lang('No Change type'), 'lang_change_type_statustext' => lang('Type of changes'), 'change_type_list' => isset($change_type_list) ? $change_type_list : '', 'check_history' => isset($check_history) ? $check_history : '', 'lang_history' => lang('History'), 'lang_history_statustext' => lang('Fetch the history for this item'), 'table_header' => isset($table_header) ? $table_header : '', 'values' => isset($content) ? $content : '', 'lang_related_info' => lang('related info'), 'entities_link' => isset($entities_link) ? $entities_link : '', 'related_link' => $related_link, 'edit_street' => isset($edit_street) ? $edit_street : '', 'edit_tenant' => isset($edit_tenant) ? $edit_tenant : '', 'edit_part_of_town' => isset($edit_part_of_town) ? $edit_part_of_town : '', 'edit_owner' => isset($edit_owner) ? $edit_owner : '', 'select_name_part_of_town' => isset($select_name_part_of_town) ? $select_name_part_of_town : '', 'part_of_town_list' => isset($part_of_town_list) ? $part_of_town_list : '', 'lang_town_statustext' => isset($lang_town_statustext) ? $lang_town_statustext : '', 'lang_part_of_town' => lang('Part of town'), 'lang_no_part_of_town' => lang('No part of town'), 'lang_owner' => isset($lang_owner) ? $lang_owner : '', 'owner_list' => isset($owner_list) ? $owner_list : '', 'lang_select_owner' => isset($lang_select_owner) ? $lang_select_owner : '', 'lang_owner_statustext' => isset($lang_owner_statustext) ? $lang_owner_statustext : '', 'additional_fields' => $additional_fields, 'attributes_group' => $attributes, 'attributes_general' => array('attributes' => $attributes_general), 'lookup_functions' => isset($values['lookup_functions']) ? $values['lookup_functions'] : '', 'lang_none' => lang('None'), 'msgbox_data' => isset($msgbox_data) ? $GLOBALS['phpgw']->common->msgbox($msgbox_data) : '', 'street_link' => "menuaction:'" . 'property' . ".uilookup.street'", 'lang_street' => lang('Address'), 'lang_select_street_help' => lang('Select the street name'), 'lang_street_num_statustext' => lang('Enter the street number'), 'value_street_id' => isset($values['street_id']) ? $values['street_id'] : '', 'value_street_name' => isset($values['street_name']) ? $values['street_name'] : '', 'value_street_number' => isset($values['street_number']) ? $values['street_number'] : '', 'tenant_link' => "menuaction:'" . 'property' . ".uilookup.tenant'", 'lang_tenant' => lang('tenant'), 'value_tenant_id' => isset($values['tenant_id']) ? $values['tenant_id'] : '', 'value_last_name' => isset($values['last_name']) ? $values['last_name'] : '', 'value_first_name' => isset($values['first_name']) ? $values['first_name'] : '', 'lang_tenant_statustext' => lang('Select a tenant'), 'size_last_name' => isset($values['last_name']) ? strlen($values['last_name']) : '', 'size_first_name' => isset($values['first_name']) ? strlen($values['first_name']) : '', 'lookup_type' => $lookup_type, 'location_data' => $location_data, 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $type_id, 'lookup_tenant' => $lookup_tenant)), 'lang_save' => lang('save'), 'lang_done' => lang('done'), 'lang_done_statustext' => lang('Back to the list'), 'lang_save_statustext' => lang('Save the location'), 'lang_category' => lang('category'), 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the category the location belongs to. To do not use a category select NO CATEGORY'), 'select_name' => 'cat_id', 'cat_list' => $this->bocommon->select_category_list(array('format' => 'select', 'selected' => $values['cat_id'], 'type' => 'location', 'type_id' => $type_id, 'order' => 'descr')), 'textareacols' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 40, 'textarearows' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 6, 'tabs' => phpgwapi_yui::tabview_generate($tabs, 'general'), 'documents' => $documents, 'file_tree' => $file_tree, 'lang_expand_all' => lang('expand all'), 'lang_collapse_all' => lang('collapse all'));
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/examples/treeview/assets/css/folders/tree.css');
     phpgwapi_yui::load_widget('dragdrop');
     phpgwapi_yui::load_widget('datatable');
     phpgwapi_yui::load_widget('menu');
     phpgwapi_yui::load_widget('connection');
     phpgwapi_yui::load_widget('loader');
     phpgwapi_yui::load_widget('tabview');
     phpgwapi_yui::load_widget('paginator');
     phpgwapi_yui::load_widget('animation');
     phpgwapi_yui::load_widget('treeview');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
     $GLOBALS['phpgw']->js->validate_file('yahoo', 'location.edit', 'property');
     $appname = lang('location');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
 }
Example #16
0
<?php

/**************************************************************************\
	* eGroupWare - FeLaMiMail                                                  *
	* http://www.egroupware.org                                                *
	* http://www.phpgw.de                                                      *
	* http://www.linux-at-work.de                                              *
	* Written by Lars Kneschke [lkneschke@linux-at-work.de]                    *
	* -----------------------------------------------                          *
	*  This program is free software; you can redistribute it and/or modify it *
	*  under the terms of the GNU General Public License as published by the   *
	*  Free Software Foundation; either version 2 of the License, or (at your  *
	*  option) any later version.                                              *
	\**************************************************************************/
/* $Id$ */
// this is to get css inclusion working
$_GET['menuaction'] = 'felamimail.uifelamimail.viewMainScreen';
$GLOBALS['phpgw_info']['flags'] = array('currentapp' => 'felamimail', 'noheader' => True, 'nonavbar' => True, 'include_xajax' => True);
include '../header.inc.php';
try {
    execmethod('felamimail.uifelamimail.viewMainScreen');
} catch (Exception $e) {
    phpgwapi_cache::message_set($e->getMessage(), 'error');
    $GLOBALS['phpgw']->redirect_link('/home.php');
}
 public function query()
 {
     $params = array('start' => phpgw::get_var('startIndex', 'int', 'REQUEST', 0), 'results' => phpgw::get_var('results', 'int', 'REQUEST', null), 'query' => phpgw::get_var('query'), 'sort' => phpgw::get_var('sort'), 'dir' => phpgw::get_var('dir'), 'filters' => $filters);
     if ($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0) {
         $user_rows_per_page = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
     } else {
         $user_rows_per_page = 10;
     }
     // YUI variables for paging and sorting
     $start_index = phpgw::get_var('startIndex', 'int');
     $num_of_objects = phpgw::get_var('results', 'int', 'GET', $user_rows_per_page);
     $sort_field = phpgw::get_var('sort');
     $sort_ascending = phpgw::get_var('dir') == 'desc' ? false : true;
     // Form variables
     $search_for = phpgw::get_var('query');
     $search_type = phpgw::get_var('search_option');
     // Create an empty result set
     $result_objects = array();
     $result_count = 0;
     //Retrieve a contract identifier and load corresponding contract
     $exp_param = phpgw::get_var('export');
     $export = false;
     if (isset($exp_param)) {
         $export = true;
         $num_of_objects = null;
     }
     //Retrieve the type of query and perform type specific logic
     $query_type = phpgw::get_var('type');
     switch ($query_type) {
         case 'children':
             $activity_id = phpgw::get_var('activity_id');
             $filters = array('id' => $activity_id);
             $result_objects = $this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters);
             $object_count = $this->so->get_count();
             array_shift($result_objects);
             if ($result_objects) {
                 $object_count--;
             }
             break;
         case 'activity_id':
             $activity_id = phpgw::get_var('activity_id');
             $filters = array('id' => $activity_id);
             $result_objects = $this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters);
             $object_count = $this->so->get_count($search_for, $search_type, $filters);
             break;
         default:
             // ... all activities, filters (active and vacant)
             phpgwapi_cache::session_set('logistic', 'activity_query', $search_for);
             $filters = array('project' => phpgw::get_var('project'), 'user' => phpgw::get_var('user'), 'activity' => phpgw::get_var('filter', 'int'));
             $result_objects = $this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters);
             $object_count = $this->so->total_records;
             break;
     }
     //Create an empty row set
     $rows = array();
     foreach ($result_objects as $activity) {
         if (isset($activity)) {
             $filters = array('activity' => $activity->get_id());
             $requirements_for_activity = $this->so_requirement->get(0, null, null, null, null, null, $filters);
             if (count($requirements_for_activity) > 0) {
                 $total_num_alloc = 0;
                 $total_num_required = 0;
                 foreach ($requirements_for_activity as $requirement) {
                     $filters = array('requirement_id' => $requirement->get_id());
                     $num_allocated = $this->so_resource_allocation->get_count(null, null, $filters);
                     $num_required = $requirement->get_no_of_items();
                     $total_num_alloc += $num_allocated;
                     $total_num_required += $num_required;
                 }
                 if ($total_num_alloc == $total_num_required) {
                     $status = "Behov dekket";
                 } else {
                     $status = "Udekket behov (" . ($total_num_required - $total_num_alloc) . ")";
                 }
             } else {
                 $status = "Ingen registerte behov";
             }
             $activity_arr = $activity->serialize();
             $activity_arr['status'] = $status;
             $href = self::link(array('menuaction' => 'logistic.uiactivity.view', 'id' => $activity_arr['id']));
             $activity_arr['id_link'] = "<a href=\"{$href}\">" . $activity_arr['id'] . "</a>";
             $activity_arr['name'] = "<a href=\"{$href}\">" . $activity_arr['name'] . "</a>";
             $rows[] = $activity_arr;
         }
     }
     // ... add result data
     $result_data = array('results' => $rows);
     $result_data['total_records'] = $object_count;
     $result_data['start'] = $params['start'];
     $result_data['sort'] = $params['sort'];
     $result_data['dir'] = $params['dir'];
     $editable = phpgw::get_var('editable') == 'true' ? true : false;
     if (!$export) {
         //Add action column to each row in result table
         /*
         				array_walk(
         								$result_data['results'],
         								array($this, '_add_links'),
         								"logistic.uiactivity.view"
         				);
         */
     }
     return $this->yui_results($result_data);
 }
 public function login($frontend = '')
 {
     if (isset($_REQUEST['skip_remote']) && $_REQUEST['skip_remote']) {
         $GLOBALS['phpgw_remote_user_fallback'] = 'sql';
     }
     if (isset($_GET['logout']) && $_GET['logout']) {
         $GLOBALS['phpgw_remote_user_fallback'] = 'sql';
         $_REQUEST['skip_remote'] = true;
     }
     require_once dirname(realpath(__FILE__)) . '/sso/include_login.inc.php';
     $lightbox = isset($_REQUEST['lightbox']) && $_REQUEST['lightbox'] ? true : false;
     $partial_url = "{$frontend}/login.php";
     $phpgw_url_for_sso = 'phpgwapi/inc/sso/login_server.php';
     if (isset($GLOBALS['phpgw_remote_user']) && !empty($GLOBALS['phpgw_remote_user'])) {
         $partial_url = 'phpgwapi/inc/sso/login_server.php';
     }
     if ($frontend) {
         $GLOBALS['phpgw']->hooks->process('set_auth_type', array($frontend));
     }
     if (isset($_REQUEST['skip_remote']) && $_REQUEST['skip_remote']) {
         $GLOBALS['phpgw_info']['server']['auth_type'] = $GLOBALS['phpgw_remote_user_fallback'];
     }
     /* Program starts here */
     $uilogin = new phpgw_uilogin($tmpl, $GLOBALS['phpgw_info']['server']['auth_type'] == 'remoteuser' && !isset($GLOBALS['phpgw_remote_user']));
     if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'remoteuser' && isset($GLOBALS['phpgw_info']['server']['mapping']) && !empty($GLOBALS['phpgw_info']['server']['mapping']) && isset($_SERVER['REMOTE_USER'])) {
         $login = $GLOBALS['phpgw']->mapping->get_mapping($_SERVER['REMOTE_USER']);
         if ($login == '') {
             if (isset($GLOBALS['phpgw_info']['server']['auto_create_acct']) && $GLOBALS['phpgw_info']['server']['auto_create_acct'] == true) {
                 // Redirection to create the new account :
                 $GLOBALS['phpgw']->redirect_link('/phpgwapi/inc/sso/create_account.php');
             } else {
                 if ($GLOBALS['phpgw_info']['server']['mapping'] == 'table' || $GLOBALS['phpgw_info']['server']['mapping'] == 'all') {
                     // Redirection to create a new mapping :
                     $GLOBALS['phpgw']->redirect_link('/phpgwapi/inc/sso/create_mapping.php');
                 } else {
                     if (!(isset($_GET['cd']) && $_GET['cd'] != '0')) {
                         // An error occurs, bailed out
                         $GLOBALS['phpgw']->redirect_link('/' . $partial_url, array('cd' => '20'));
                     }
                 }
             }
         }
         $passwd = $login;
         if (!(isset($_GET['cd']) && $_GET['cd'] != '0')) {
             $_POST['submitit'] = true;
         }
     } else {
         $login = phpgw::get_var('login', 'string', 'POST');
         // remove entities to stop mangling
         $passwd = html_entity_decode(phpgw::get_var('passwd', 'string', 'POST'));
     }
     if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) {
         $submit = true;
         $login = $_SERVER['PHP_AUTH_USER'];
         $passwd = $_SERVER['PHP_AUTH_PW'];
     }
     if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'ntlm' && isset($_SERVER['REMOTE_USER']) && (!isset($_REQUEST['skip_remote']) || !$_REQUEST['skip_remote'])) {
         $login = $_SERVER['REMOTE_USER'];
         $passwd = '';
         $GLOBALS['hook_values'] = array('account_lid' => $login);
         $GLOBALS['phpgw']->hooks->process('auto_addaccount', array('frontend'));
         //------------------Start login ntlm
         $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd);
         if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) {
             $cd_array = array();
             if ($GLOBALS['phpgw']->session->cd_reason) {
                 $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason;
             }
             $cd_array['skip_remote'] = true;
             $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
             exit;
         }
         $forward = phpgw::get_var('phpgw_forward');
         if ($forward) {
             $extra_vars['phpgw_forward'] = $forward;
             foreach ($_GET as $name => $value) {
                 if (preg_match('/phpgw_/', $name)) {
                     $name = urlencode($name);
                     $extra_vars[$name] = urlencode($value);
                 }
             }
         }
         if (!isset($GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) || !$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) {
             //			$uilogin->check_langs();
         }
         $extra_vars['cd'] = 'yes';
         $GLOBALS['phpgw']->hooks->process('login');
         $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars);
         //----------------- End login ntlm
     }
     # Apache + mod_ssl style SSL certificate authentication
     # Certificate (chain) verification occurs inside mod_ssl
     if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) {
         # an X.509 subject looks like:
         # /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/
         # the username is deliberately lowercase, to ease LDAP integration
         $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']);
         # skip the part in front of the first '/' (nothing)
         while ($sslattrib = next($sslattribs)) {
             list($key, $val) = explode('=', $sslattrib);
             $sslattributes[$key] = $val;
         }
         if (isset($sslattributes['Email'])) {
             $submit = true;
             # login will be set here if the user logged out and uses a different username with
             # the same SSL-certificate.
             if (!isset($_POST['login']) && isset($sslattributes['Email'])) {
                 $login = $sslattributes['Email'];
                 # not checked against the database, but delivered to authentication module
                 $passwd = $_SERVER['SSL_CLIENT_S_DN'];
             }
         }
         unset($key);
         unset($val);
         unset($sslattributes);
     }
     if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'customsso' && !isset($_GET['cd'])) {
         //Reset auth object
         $GLOBALS['phpgw']->auth = createObject('phpgwapi.auth');
         $login = $GLOBALS['phpgw']->auth->get_username();
         $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, '');
         if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) {
             $cd_array = array();
             if ($GLOBALS['phpgw']->session->cd_reason) {
                 $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason;
             }
             $cd_array['skip_remote'] = true;
             $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
             exit;
         }
         $forward = phpgw::get_var('phpgw_forward');
         if ($forward) {
             $extra_vars['phpgw_forward'] = $forward;
             foreach ($_GET as $name => $value) {
                 if (preg_match('/phpgw_/', $name)) {
                     $name = urlencode($name);
                     $extra_vars[$name] = urlencode($value);
                 }
             }
         }
         $extra_vars['cd'] = 'yes';
         $GLOBALS['phpgw']->hooks->process('login');
         $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars);
     }
     if (isset($_POST['submitit']) || isset($_POST['submit_x']) || isset($_POST['submit_y'])) {
         if ($_SERVER['REQUEST_METHOD'] != 'POST' && !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['REMOTE_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) {
             $GLOBALS['phpgw']->redirect_link('/' . $partial_url, array('cd' => '5'));
         }
         $logindomain = phpgw::get_var('logindomain', 'string', 'POST');
         if (strstr($login, '#') === false && $logindomain) {
             $login .= "#{$logindomain}";
         }
         $receipt = array();
         if (isset($GLOBALS['phpgw_info']['server']['usecookies']) && $GLOBALS['phpgw_info']['server']['usecookies']) {
             if (isset($_COOKIE['domain']) && $_COOKIE['domain'] != $logindomain) {
                 $GLOBALS['phpgw']->session->phpgw_setcookie('kp3');
                 $GLOBALS['phpgw']->session->phpgw_setcookie('domain');
                 //				$GLOBALS['phpgw']->redirect_link("/{$partial_url}", array('cd' =>22)); // already within a session
                 //				exit;
                 $receipt[] = lang('Info: you have changed domain from "%1" to "%2"', $_COOKIE['domain'], $logindomain);
             }
         }
         $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd);
         if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) {
             $cd_array = array();
             if ($GLOBALS['phpgw']->session->cd_reason) {
                 $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason;
             }
             $cd_array['skip_remote'] = true;
             $cd_array['lightbox'] = $lightbox;
             $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
             exit;
         }
         if ($receipt) {
             phpgwapi_cache::message_set($receipt, 'message');
         }
         $forward = phpgw::get_var('phpgw_forward');
         if ($forward) {
             $extra_vars['phpgw_forward'] = $forward;
             foreach ($_GET as $name => $value) {
                 if (preg_match('/phpgw_/', $name)) {
                     //$extra_vars[$name] = $value;
                     $name = urlencode($name);
                     $extra_vars[$name] = urlencode($value);
                 }
             }
         }
         if (!isset($GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) || !$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) {
             //			$uilogin->check_langs();
         }
         $extra_vars['cd'] = 'yes';
         $GLOBALS['phpgw']->hooks->process('login');
         if ($lightbox) {
             $GLOBALS['phpgw']->redirect_link("{$frontend}/login.php", array('hide_lightbox' => true));
         } else {
             $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars);
         }
     }
     //Build vars :
     $variables = array();
     $variables['lang_login'] = lang('login');
     $variables['partial_url'] = $partial_url;
     $variables['lang_frontend'] = $frontend ? lang($frontend) : '';
     if (isset($GLOBALS['phpgw_info']['server']['half_remote_user']) && $GLOBALS['phpgw_info']['server']['half_remote_user'] == 'remoteuser') {
         $variables['lang_additional_url'] = lang('use sso login');
         $variables['additional_url'] = $GLOBALS['phpgw']->link('/' . $phpgw_url_for_sso);
     }
     $uilogin->phpgw_display_login($variables);
 }
 function get_location_info($type, $type_id)
 {
     $type_id = (int) $type_id;
     $this->type = $type;
     $this->type_id = $type_id;
     $info = array();
     if (!$type) {
         return $info;
     }
     switch ($type) {
         //-------- ID type integer
         case 'part_of_town':
             $info = array('table' => 'fm_part_of_town', 'id' => array('name' => 'part_of_town_id', 'type' => 'int', 'descr' => lang('id')), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'nullable' => false, 'size' => 20), array('name' => 'district_id', 'descr' => lang('district'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'district', 'selected' => '##district_id##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('part of town'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::town', 'check_grant' => false);
             break;
         case 'project_group':
             $info = array('table' => 'fm_project_group', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'budget', 'descr' => lang('budget'), 'type' => 'int')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::project_group');
             break;
         case 'dimb':
             $info = array('table' => 'fm_ecodimb', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'org_unit_id', 'descr' => lang('department'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'org_unit', 'selected' => '##org_unit_id##')))), 'custom_criteria' => array('dimb_role_user' => array('join' => array("{$this->_db->join} fm_ecodimb_role_user ON fm_ecodimb.id = fm_ecodimb_role_user.ecodimb"), 'filter' => array('fm_ecodimb_role_user.user_id = ' . (int) $this->account))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimb'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_dimb');
             break;
         case 'dimd':
             $info = array('table' => 'fm_ecodimd', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimd'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_dimd');
             break;
         case 'periodization':
             $info = array('table' => 'fm_eco_periodization', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('periodization'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::periodization');
             break;
         case 'tax':
             $info = array('table' => 'fm_ecomva', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'percent', 'descr' => lang('percent'), 'type' => 'int'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_tax');
             break;
         case 'voucher_cat':
             $info = array('table' => 'fm_ecobilag_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::voucher_cats');
             break;
         case 'voucher_type':
             $info = array('table' => 'fm_ecoart', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::voucher_type');
             break;
         case 'tender_chapter':
             $info = array('table' => 'fm_chapter', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tender');
             break;
         case 'location':
             $this->_db->query("SELECT id FROM fm_location_type WHERE id ={$type_id}", __LINE__, __FILE__);
             if ($this->_db->next_record()) {
                 $info = array('table' => "fm_location{$type_id}_category", 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => "admin::property::location::location::category_{$type_id}");
             } else {
                 throw new Exception(lang('ERROR: illegal type %1', $type_id));
             }
             break;
         case 'owner_cats':
             $info = array('table' => 'fm_owner_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::owner::owner_cats');
             break;
         case 'tenant_cats':
             $info = array('table' => 'fm_tenant_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('tenant category'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tenant::tenant_cats');
             break;
         case 'vendor_cats':
             $info = array('table' => 'fm_vendor_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('vendor category'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::vendor::vendor_cats');
             break;
         case 'vendor':
             $info = array('table' => 'fm_vendor', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'contact_phone', 'descr' => lang('contact phone'), 'type' => 'varchar'), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'vendor_cats', 'selected' => '##category##'))), array('name' => 'member_of', 'descr' => lang('member'), 'type' => 'multiple_select', 'nullable' => true, 'filter' => true, 'sortable' => false, 'hidden' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_categories', 'method_input' => array('app' => 'property', 'acl_location' => '.vendor', 'selected' => '##member_of##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('vendor'), 'acl_app' => 'property', 'acl_location' => '.vendor', 'menu_selection' => 'property::invoice::vendor', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()')));
             break;
         case 'owner':
             $info = array('table' => 'fm_owner', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'text'), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'owner_cats', 'selected' => '##category##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('owner'), 'acl_app' => 'property', 'acl_location' => '.owner', 'menu_selection' => 'admin::property::owner', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()')));
             break;
         case 'tenant':
             $info = array('table' => 'fm_tenant', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'contact_email', 'descr' => lang('contact_email'), 'type' => 'varchar', 'sortable' => true), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'tenant_cats', 'selected' => '##category##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('tenant'), 'acl_app' => 'property', 'acl_location' => '.tenant', 'menu_selection' => 'admin::property::tenant', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()')));
             break;
         case 'district':
             $info = array('table' => 'fm_district', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('district'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::district');
             break;
         case 'street':
             $info = array('table' => 'fm_streetaddress', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('streetaddress'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::street');
             break;
         case 's_agreement':
             $info = array('table' => 'fm_s_agreement_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::agreement::service_agree_cats');
             break;
         case 'tenant_claim':
             $info = array('table' => 'fm_tenant_claim_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tenant::claims_cats');
             break;
         case 'wo_hours':
             $info = array('table' => 'fm_wo_hours_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::workorder_detail');
             break;
         case 'r_condition_type':
             $info = array('table' => 'fm_request_condition_type', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => 'condition type', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_condition');
             break;
         case 'authorities_demands':
             $info = array('table' => 'fm_authorities_demands', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('authorities demands'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::authorities_demands', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false);
             break;
         case 'b_account':
         case 'b_account_category':
             $info = array('table' => 'fm_b_account_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'project_group', 'descr' => lang('mandatory project group'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('budget account group'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_cats');
             break;
         case 'dimb_role':
             $info = array('table' => 'fm_ecodimb_role', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit role'), 'add_msg' => lang('add role'), 'name' => lang('dimb role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::dimb_role');
             break;
         case 'condition_survey_status':
             $info = array('table' => 'fm_condition_survey_status', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('request status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::condition_survey_status');
             break;
         case 'request_responsible_unit':
             $_lang_responsible_unit = lang('responsible unit');
             $info = array('table' => 'fm_request_responsible_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit') . ' ' . $_lang_responsible_unit, 'add_msg' => lang('add') . ' ' . $_lang_responsible_unit, 'name' => $_lang_responsible_unit, 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_responsible_unit');
             break;
         case 'ticket_priority':
             $_lang_priority = lang('priority');
             $info = array('table' => 'fm_tts_priority', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit') . ' ' . $_lang_priority, 'add_msg' => lang('add') . ' ' . $_lang_priority, 'name' => $_lang_priority, 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::ticket::ticket_priority');
             break;
             //-------- ID type varchar
         //-------- ID type varchar
         case 'project_status':
             $info = array('table' => 'fm_project_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('project status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::project_status');
             break;
         case 'workorder_status':
             $info = array('table' => 'fm_workorder_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('workorder status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::workorder_status');
             break;
         case 'request_status':
             $info = array('table' => 'fm_request_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('request status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_status');
             break;
         case 'agreement_status':
             $info = array('table' => 'fm_agreement_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('agreement status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::agreement::agreement_status');
             break;
         case 'building_part':
             $config = CreateObject('phpgwapi.config', 'property');
             $config->read();
             $filter_buildingpart = isset($config->config_data['filter_buildingpart']) ? $config->config_data['filter_buildingpart'] : array();
             $info = array('table' => 'fm_building_part', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'filter_1', 'descr' => isset($filter_buildingpart[1]) && $filter_buildingpart[1] ? $filter_buildingpart[1] : 'Filter 1', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_2', 'descr' => isset($filter_buildingpart[2]) && $filter_buildingpart[2] ? $filter_buildingpart[2] : 'Filter 2', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_3', 'descr' => isset($filter_buildingpart[3]) && $filter_buildingpart[3] ? $filter_buildingpart[3] : 'Filter 3', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_4', 'descr' => isset($filter_buildingpart[4]) && $filter_buildingpart[4] ? $filter_buildingpart[4] : 'Filter 4', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active')))))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('building part'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::building_part');
             break;
         case 'document_status':
             $info = array('table' => 'fm_document_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('document status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::document_status');
             break;
         case 'unit':
             $info = array('table' => 'fm_standard_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::unit');
             break;
         case 'budget_account':
             $info = array('table' => 'fm_b_account', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'b_account', 'selected' => '##category##'))), array('name' => 'mva', 'descr' => lang('tax code'), 'type' => 'int', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'responsible', 'descr' => lang('responsible'), 'type' => 'select', 'filter' => true, 'get_single' => 'get_user', 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_user_list_right2', 'method_input' => array('selected' => '##responsible##', 'right' => 128, 'acl_location' => '.invoice'))), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('budget account'), 'acl_app' => 'property', 'acl_location' => '.b_account', 'menu_selection' => 'property::invoice::budget_account', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false);
             break;
         case 'voucher_process_code':
             $info = array('table' => 'fm_ecobilag_process_code', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit process code'), 'add_msg' => lang('add process code'), 'name' => lang('process code'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::process_code', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')));
             break;
         case 'org_unit':
             $info = array('table' => 'fm_org_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true), array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'org_unit', 'role' => 'parent', 'selected' => '##parent_id##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('department'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::org_unit', 'default' => array('created_by' => array('add' => '$this->account'), 'created_on' => array('add' => 'time()'), 'modified_by' => array('edit' => '$this->account'), 'modified_on' => array('edit' => 'time()')), 'check_grant' => false);
             break;
             //-------- ID type auto
         //-------- ID type auto
         case 'dimb_role_user':
             $info = array('table' => 'fm_ecodimb_role_user', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'ecodimb', 'descr' => lang('dim b'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'dimb', 'selected' => '##ecodimb##'))), array('name' => 'role_id', 'descr' => lang('role type'), 'type' => 'select', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'dimb_role', 'selected' => '##role_id##'))), array('name' => 'user_id', 'descr' => lang('user'), 'type' => 'select', 'filter' => true, 'get_single' => 'get_user', 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_user_list_right2', 'method_input' => array('selected' => '##user_id##', 'right' => 1, 'acl_location' => '.invoice'))), array('name' => 'default_user', 'descr' => lang('default'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimb role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::dimb_role_user', 'default' => array('created_by' => array('add' => '$this->account'), 'created_on' => array('add' => 'time()')), 'check_grant' => false);
             break;
         case 'order_dim1':
             $info = array('table' => 'fm_order_dim1', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar', 'nullable' => false)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('order_dim1'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::order_dim1');
             break;
         case 'branch':
             $info = array('table' => 'fm_branch', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('branch'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::branch');
             break;
         case 'key_location':
             $info = array('table' => 'fm_key_loc', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('key location'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('branch'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::key_location');
             break;
         case 'async':
             $info = array('table' => 'fm_async_method', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'data', 'descr' => lang('data'), 'type' => 'text'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('Async services'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::async');
             break;
         case 'event_action':
             $info = array('table' => 'fm_event_action', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'action', 'descr' => lang('action'), 'type' => 'varchar'), array('name' => 'data', 'descr' => lang('data'), 'type' => 'text'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('event action'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::event_action', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')));
             break;
         case 'ticket_status':
             $info = array('table' => 'fm_tts_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'color', 'descr' => lang('color'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox'), array('name' => 'actual_cost', 'descr' => lang('mandatory actual cost'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('ticket status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::ticket::ticket_status');
             break;
         case 'regulations':
             $info = array('table' => 'fm_regulations', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'regulations', 'role' => 'parent', 'selected' => '##parent_id##'))), array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'sortable' => true), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text'), array('name' => 'external_ref', 'descr' => lang('external ref'), 'type' => 'link')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('regulations'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::regulations', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')));
             break;
             //START HELPDESK - APP
         //START HELPDESK - APP
         case 'helpdesk_status':
             // the helpdesk app
             $info = array('table' => 'phpgw_helpdesk_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'color', 'descr' => lang('color'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('event action'), 'acl_app' => 'helpdesk', 'acl_location' => '.admin', 'menu_selection' => 'admin::helpdesk::ticket_status');
             break;
             //END HELPDESK - APP
         //END HELPDESK - APP
         case 'pending_action_type':
             $info = array('table' => 'fm_action_pending_category', 'id' => array('name' => 'num', 'type' => 'varchar'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('Pending action type'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::action_type');
             break;
         case 'order_template':
             $info = array('table' => 'fm_order_template', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'content', 'descr' => lang('content'), 'type' => 'text'), array('name' => 'public', 'descr' => lang('public'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('order template'), 'acl_app' => 'property', 'acl_location' => '.ticket.order', 'menu_selection' => 'property::helpdesk::order_template', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => true);
             break;
         case 'response_template':
             $info = array('table' => 'fm_response_template', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'content', 'descr' => lang('content'), 'type' => 'text'), array('name' => 'public', 'descr' => lang('public'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('response template'), 'acl_app' => 'property', 'acl_location' => '.ticket', 'menu_selection' => 'property::helpdesk::response_template', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => true);
             break;
         case 'responsibility_role':
             $info = array('table' => 'fm_responsibility_role', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'text'), array('name' => 'location_level', 'descr' => lang('location level'), 'type' => 'select', 'values_def' => array('valueset' => false, 'method' => 'preferences.boadmin_acl.get_locations', 'method_input' => array('acl_app' => 'property', 'selected' => '##location##'))), array('name' => 'responsibility_id', 'descr' => lang('responsibility'), 'type' => 'select', 'values_def' => array('valueset' => false, 'get_single_value' => 'property.soresponsible.get_responsibility_name', 'method' => 'property.boresponsible.get_responsibilities', 'method_input' => array('appname' => '$this->appname', 'selected' => '##responsibility_id##')))), 'edit_action' => 'property.uiresponsible.edit_role', 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('responsibility role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::responsibility_role', 'default' => array('appname' => array('add' => '$this->appname'), 'user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false, 'filter' => array('appname' => '$this->appname'));
             break;
         case 'custom_menu_items':
             $info = array('table' => 'fm_custom_menu_items', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'custom_menu_items', 'role' => 'parent', 'selected' => '##parent_id##', 'mapping' => array('name' => 'text')))), array('name' => 'text', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'url', 'descr' => lang('url'), 'type' => 'text'), array('name' => 'target', 'descr' => lang('target'), 'type' => 'select', 'filter' => false, 'values_def' => array('valueset' => array(array('id' => '_blank', 'name' => '_blank'), array('id' => '_parent', 'name' => '_parent')))), array('name' => 'location', 'descr' => lang('location'), 'type' => 'select', 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'preferences.boadmin_acl.get_locations', 'method_input' => array('acl_app' => 'property', 'selected' => '##location##'))), array('name' => 'local_files', 'descr' => lang('local files'), 'type' => 'checkbox', 'default' => '')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('custom menu items'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::custom_menu_items', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false, 'mapping' => array('name' => 'text'));
             break;
         case 'location_contact':
             $info = array('table' => 'fm_location_contact', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'contact_id', 'descr' => lang('contact'), 'type' => 'int', 'nullable' => false), array('name' => 'location_code', 'descr' => lang('location_code'), 'type' => 'varchar', 'nullable' => false)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('location contact'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::location_contact', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')));
             break;
         case 'periodization_outline':
             $valueset_month = array();
             for ($i = 1; $i < 13; $i++) {
                 $valueset_month[] = array('id' => $i, 'name' => $i);
             }
             $info = array('table' => 'fm_eco_periodization_outline', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'periodization_id', 'descr' => lang('periodization'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'periodization', 'selected' => '##periodization_id##'))), array('name' => 'month', 'descr' => lang('month'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => $valueset_month)), array('name' => 'value', 'descr' => lang('value'), 'type' => 'numeric', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'dividend', 'descr' => lang('fraction::dividend'), 'type' => 'integer', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'divisor', 'descr' => lang('fraction::divisor'), 'type' => 'integer', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('periodization'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::periodization_outline');
             break;
         case 'period_transition':
             $valueset_month = array();
             $valueset_day = array();
             $valueset_hour = array();
             $lang_default = lang('default');
             for ($i = 1; $i < 14; $i++) {
                 $valueset_month[] = array('id' => $i, 'name' => $i == 13 ? "{$i} ({$lang_default})" : $i);
             }
             for ($i = 1; $i < 32; $i++) {
                 $valueset_day[] = array('id' => $i, 'name' => $i);
             }
             for ($i = 1; $i < 25; $i++) {
                 $valueset_hour[] = array('id' => $i, 'name' => $i);
             }
             $info = array('table' => 'fm_eco_period_transition', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'month', 'descr' => lang('month'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => $valueset_month)), array('name' => 'day', 'descr' => lang('day'), 'type' => 'select', 'nullable' => false, 'size' => 4, 'sortable' => true, 'values_def' => array('valueset' => $valueset_day)), array('name' => 'hour', 'descr' => lang('hour'), 'type' => 'select', 'nullable' => true, 'size' => 4, 'sortable' => true, 'values_def' => array('valueset' => $valueset_hour)), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'varchar', 'nullable' => true, 'size' => 60, 'sortable' => true)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('period transition'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::period_transition', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')));
             break;
         case 'entity_group':
             $info = array('table' => 'fm_entity_group', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('entity group'), 'acl_app' => 'property', 'acl_location' => '.admin.entity', 'menu_selection' => 'admin::property::entity::entity_group', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('add' => 'time()', 'edit' => 'time()')), 'check_grant' => false);
             break;
             // START BOOKING TABLES
         // START BOOKING TABLES
         case 'bb_office':
             $info = array('table' => 'bb_office', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'description', 'descr' => lang('description'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => $GLOBALS['phpgw']->translation->translate('office', array(), false, 'booking'), 'acl_app' => 'booking', 'acl_location' => '.office', 'menu_selection' => 'booking::settings::office', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false);
             break;
         case 'bb_office_user':
             $info = array('table' => 'bb_office_user', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'office', 'descr' => $GLOBALS['phpgw']->translation->translate('office', array(), false, 'booking'), 'type' => 'select', 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'bb_office', 'selected' => '##office##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => $GLOBALS['phpgw']->translation->translate('office user', array(), false, 'booking'), 'acl_app' => 'booking', 'acl_location' => '.office.user', 'menu_selection' => 'booking::settings::office::office_user', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false);
             break;
             // END BOOKING TABLES
             // START CONTROLLER TABLES
         // END BOOKING TABLES
         // START CONTROLLER TABLES
         case 'controller_check_item_status':
             $info = array('table' => 'controller_check_item_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'open', 'descr' => lang('open'), 'type' => 'checkbox'), array('name' => 'pending', 'descr' => lang('pending'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('status'), 'acl_app' => 'controller', 'acl_location' => 'admin', 'menu_selection' => 'admin::controller::check_item_status');
             break;
             // END CONTROLLER TABLES
             // START RENTAL TABLES
         // END CONTROLLER TABLES
         // START RENTAL TABLES
         case 'composite_standard':
             $info = array('table' => 'rental_composite_standard', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'factor', 'descr' => lang('factor'), 'type' => 'numeric', 'nullable' => false, 'size' => 4, 'sortable' => true)), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'rental', 'acl_location' => '.admin', 'menu_selection' => 'admin::rental::composite_standard');
             break;
         case 'responsibility_unit':
             $info = array('table' => 'rental_contract_responsibility_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'rental', 'acl_location' => '.admin', 'menu_selection' => 'admin::rental::responsibility_unit');
             break;
             // END RENTAL TABLES
         // END RENTAL TABLES
         default:
             $message = lang('ERROR: illegal type %1', $type);
             phpgwapi_cache::message_set($message, 'error');
             //				throw new Exception(lang('ERROR: illegal type %1', $type));
     }
     $this->location_info = $info;
     return $info;
 }
 function get_column_list()
 {
     $columns = array();
     // defined i property_bocommon::generate_sql()
     $location_relation_data = phpgwapi_cache::system_get('property', 'location_relation_data');
     $this->location_relation_data = $location_relation_data && is_array($location_relation_data) ? $location_relation_data : array();
     if ($this->location_relation_data && is_array($this->location_relation_data)) {
         foreach ($this->location_relation_data as $entry) {
             $columns[$entry['name']] = array('id' => $entry['name'], 'input_type' => 'text', 'name' => $entry['name'], 'descr' => $entry['descr'], 'statustext' => $entry['descr'], 'align' => '', 'datatype' => $entry['datatype'], 'sortable' => false, 'exchange' => false, 'formatter' => '', 'classname' => '');
         }
     }
     /*
     			$columns['user_id'] = array
     			(
     				'id'			=> 'user_id',
     				'input_type'	=> 'text',
     				'name'			=> 'user_id',
     				'descr'			=> lang('User'),
     				'statustext'	=> lang('User'),
     				'align' 		=> '',
     				'datatype'		=> 'user',
     				'sortable'		=> false,
     				'exchange'		=> false,
     				'formatter'		=> '',
     				'classname'		=> ''
     			);
     */
     return $columns;
 }
<?php 
if ($list_form) {
    ?>
<form id="<?php 
    echo $list_id;
    ?>
_form" method="GET">
<?php 
    $populate = phpgw::get_var('populate_form');
    //Avoid Notices
    $q = false;
    $s_type = false;
    if (isset($populate)) {
        $q = phpgwapi_cache::session_get('rental', 'resultunit_query');
        $s_type = phpgwapi_cache::session_get('rental', 'resultunit_search_type');
    }
    ?>
	<fieldset>
		<!-- Search -->
		<h3><?php 
    echo lang('search_options');
    ?>
</h3>
		<label for="ctrl_search_query"><?php 
    echo lang('search_for');
    ?>
</label>
		<input id="<?php 
    echo $list_id;
    ?>
 /**
  * Set a message on bottom of home-screen
  *
  * @return void
  */
 function home_screen_message()
 {
     if (!$GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin')) {
         $GLOBALS['phpgw']->redirect_link('/admin/index.php');
     }
     if (phpgw::get_var('msg_title', 'string')) {
         $msg_title = phpgw::get_var('msg_title', 'string');
     } else {
         $msg_title = lang("important message");
     }
     if (phpgw::get_var('message', 'string')) {
         phpgwapi_cache::system_set('phpgwapi', 'phpgw_home_screen_message_title', $msg_title);
         phpgwapi_cache::system_set('phpgwapi', 'phpgw_home_screen_message', phpgw::get_var('message', 'html'));
     }
     if (phpgw::get_var('delete_message', 'bool')) {
         phpgwapi_cache::system_clear('phpgwapi', 'phpgw_home_screen_message_title');
         phpgwapi_cache::system_clear('phpgwapi', 'phpgw_home_screen_message');
     }
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('administration');
     $data = array('value_title' => phpgwapi_cache::system_get('phpgwapi', 'phpgw_home_screen_message_title'), 'value_message' => phpgwapi_cache::system_get('phpgwapi', 'phpgw_home_screen_message'), 'form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.home_screen_message')), 'lang_cancel' => lang('cancel'), 'lang_submit' => lang('submit'));
     $GLOBALS['phpgw']->xslttpl->add_file('home_screen_message');
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('home_screen_message' => $data));
 }
 /**
  * Add budget to project if missing.
  * @param integer $project_id
  * @param integer $year
  * @param boolean $force
  */
 public function check_and_update_project_budget($project_id, $year, $force = false)
 {
     $update_project_budget_from_order = isset($this->config->config_data['update_project_budget_from_order']) && $this->config->config_data['update_project_budget_from_order'] ? $this->config->config_data['update_project_budget_from_order'] : false;
     if (!$force && !$update_project_budget_from_order) {
         return;
     }
     $project_id = (int) $project_id;
     $year = $year ? (int) $year : date('Y');
     $current_year = date('Y');
     $activate = false;
     if ($year == $current_year) {
         $activate = true;
     }
     $ids = array();
     $this->db->query("SELECT id FROM fm_workorder WHERE project_id = {$project_id}", __LINE__, __FILE__);
     while ($this->db->next_record()) {
         $id = $this->db->f('id');
         $ids[] = $id;
         phpgwapi_cache::system_clear('property', "budget_order_{$id}");
     }
     if (!$ids) {
         return false;
     }
     $this->db->query("SELECT sum(budget) AS budget FROM fm_workorder_budget WHERE year = {$year} AND order_id IN (" . implode(',', $ids) . ')', __LINE__, __FILE__);
     $this->db->next_record();
     $workorder_budget = $this->db->f('budget');
     $this->db->query("SELECT sum(budget) AS budget FROM fm_project_budget WHERE project_id = {$project_id} AND year = {$year}", __LINE__, __FILE__);
     $this->db->next_record();
     $project_budget = $this->db->f('budget');
     $update = false;
     if ($project_budget < 0 && $workorder_budget < $project_budget) {
         $update = true;
     } else {
         if ($workorder_budget > $project_budget) {
             $update = true;
         }
     }
     if ($update) {
         $this->db->query("UPDATE fm_project_budget SET active = 0 WHERE project_id = {$project_id} AND year != {$current_year}", __LINE__, __FILE__);
         $this->db->query("SELECT id, periodization_id FROM fm_project WHERE id = {$project_id}", __LINE__, __FILE__);
         if ($this->db->next_record()) {
             $periodization_id = (int) $this->db->f('periodization_id');
             $this->update_budget($project_id, $year, $periodization_id, (int) $workorder_budget, true, 'update', $activate);
         }
     }
 }
 /**
  * Public function for deleting a document. Deletes the document from
  * the database and the virtual file system (vfs).
  * 
  * @param HTTP::id	the document id
  * @return true if successful, false if error, permission denied message on
  * 			not enough privileges
  */
 public function delete()
 {
     $document_id = intval(phpgw::get_var('id'));
     $document = $this->so->get_single($document_id);
     $procedure_id = intval(phpgw::get_var('procedure_id'));
     if (!$this->delete) {
         phpgwapi_cache::message_set('No access', 'error');
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uidocument.show', 'procedure_id' => $procedure_id, 'tab' => 'documents'));
     }
     $procedure = $this->so_procedure->get_single($procedure_id);
     $document_properties = $this->get_type_and_id($document);
     /*if(!$this->check_permissions($document,$document_properties))
       {
           $this->render('permission_denied.php');
           return;
       }*/
     $result = $this->so->delete_document_from_vfs($document_properties['document_type'], $document_properties['id'], $document->get_name());
     if ($result) {
         $this->so->delete_document($document_id);
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uidocument.show', 'procedure_id' => $procedure->get_id(), 'tab' => 'documents'));
     }
     // TODO: communicate error/message to user
     return false;
 }
 /**
  * Cache an account object in the system cache
  *
  * @param object $account phpgw_account object to cache
  *
  * @return void
  */
 protected function _cache_account($account)
 {
     phpgwapi_cache::system_set('phpgwapi', "account_{$account->id}", $account);
 }
 private function get_location_filter()
 {
     $entity_group_id = phpgw::get_var('entity_group_id', 'int');
     $location_id = phpgw::get_var('location_id', 'int');
     $location_filter = phpgwapi_cache::session_get('controller', "location_filter_{$entity_group_id}");
     if (!$location_filter) {
         $this->soadmin_entity = CreateObject('property.soadmin_entity');
         $entity_list = $this->soadmin_entity->read(array('allrows' => true));
         $location_filter = array();
         foreach ($entity_list as $entry) {
             $categories = $this->soadmin_entity->read_category(array('entity_id' => $entry['id'], 'order' => 'name', 'sort' => 'asc', 'enable_controller' => true, 'allrows' => true));
             foreach ($categories as $category) {
                 if ($category['enable_controller']) {
                     if ($entity_group_id && $category['entity_group_id'] != $entity_group_id) {
                         continue;
                     }
                     $sort_arr = explode(' ', $category['name']);
                     $location_filter[] = array('id' => $category['location_id'], 'name' => "{$entry['name']}::{$category['name']}", 'sort_key' => trim($sort_arr[0]));
                 }
             }
         }
         // Obtain a list of columns
         foreach ($location_filter as $key => $row) {
             $id[$key] = $row['sort_key'];
         }
         array_multisort($id, SORT_ASC, SORT_STRING, $location_filter);
         phpgwapi_cache::session_set('controller', "location_filter_{$entity_group_id}", $location_filter);
     }
     foreach ($location_filter as &$location) {
         $location['selected'] = $location['id'] == $location_id ? 1 : 0;
     }
     return $location_filter;
 }
 public function add_ticket()
 {
     $values = phpgw::get_var('values');
     $p_entity_id = phpgw::get_var('p_entity_id', 'int');
     $p_cat_id = phpgw::get_var('p_cat_id', 'int');
     $p_num = phpgw::get_var('p_num');
     $origin = phpgw::get_var('origin');
     if ($p_entity_id && $p_cat_id && $p_num) {
         $item = execMethod('property.boentity.read_single', array('id' => $p_num, 'entity_id' => $p_entity_id, 'cat_id' => $p_cat_id, 'view' => true));
     }
     $bo = CreateObject('property.botts', true);
     $boloc = CreateObject('property.bolocation', true);
     $location_details = $boloc->read_single($this->location_code, array('noattrib' => true));
     $missingfields = false;
     $msglog = array();
     // Read default assign-to-group from config
     $config = CreateObject('phpgwapi.config', 'frontend');
     $config->read();
     $default_cat = $config->config_data['tts_default_cat'] ? $config->config_data['tts_default_cat'] : 0;
     if (!$default_cat) {
         throw new Exception('Default category is not set in config');
         $GLOBALS['phpgw']->common->phpgw_exit();
     }
     $cat_id = isset($values['cat_id']) && $values['cat_id'] ? $values['cat_id'] : $default_cat;
     if (isset($values['save'])) {
         foreach ($values as $key => $value) {
             if (empty($value) && $key !== 'file') {
                 $missingfields = true;
             }
         }
         if (!$missingfields && !phpgw::get_var('added')) {
             $location = array();
             $_location_arr = explode('-', $this->location_code);
             $i = 1;
             foreach ($_location_arr as $_loc) {
                 $location["loc{$i}"] = $_loc;
                 $i++;
             }
             $assignedto = execMethod('property.boresponsible.get_responsible', array('location' => $location, 'cat_id' => $cat_id));
             if (!$assignedto) {
                 $default_group = (int) $config->config_data['tts_default_group'];
             } else {
                 $default_group = 0;
             }
             $ticket = array('origin_id' => $GLOBALS['phpgw']->locations->get_id('property', $origin), 'origin_item_id' => $p_num, 'cat_id' => $cat_id, 'group_id' => $default_group ? $default_group : null, 'assignedto' => $assignedto, 'priority' => 3, 'status' => 'O', 'subject' => $values['title'], 'details' => $values['locationdesc'] . ":\n\n" . $values['description'], 'apply' => lang('Apply'), 'contact_id' => 0, 'location' => $location, 'location_code' => $this->location_code, 'street_name' => $location_details['street_name'], 'street_number' => $location_details['street_number'], 'location_name' => $location_details['loc1_name']);
             $result = $bo->add($ticket);
             if ($result['message'][0]['msg'] != null && $result['id'] > 0) {
                 $msglog['message'][] = array('msg' => lang('Ticket added'));
                 $noform = true;
                 // Files
                 $values['file_name'] = @str_replace(' ', '_', $_FILES['file']['name']);
                 if ($values['file_name'] && $result['id']) {
                     $bofiles = CreateObject('property.bofiles');
                     $to_file = $bofiles->fakebase . '/fmticket/' . $result['id'] . '/' . $values['file_name'];
                     if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
                         $msglog['error'][] = array('msg' => lang('This file already exists !'));
                     } else {
                         $bofiles->create_document_dir("fmticket/{$result['id']}");
                         $bofiles->vfs->override_acl = 1;
                         if (!$bofiles->vfs->cp(array('from' => $_FILES['file']['tmp_name'], 'to' => $to_file, 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL)))) {
                             $msglog['error'][] = array('msg' => lang('Failed to upload file!'));
                         }
                         $bofiles->vfs->override_acl = 0;
                     }
                 }
                 $redirect = true;
                 phpgwapi_cache::session_set('frontend', 'msgbox', $msglog);
                 // /Files
             }
         } else {
             $msglog['error'][] = array('msg' => lang('Missing field(s)'));
         }
     }
     $tts_frontend_cat_selected = $config->config_data['tts_frontend_cat'] ? $config->config_data['tts_frontend_cat'] : array();
     $cats = CreateObject('phpgwapi.categories', -1, 'property', '.ticket');
     $cats->supress_info = true;
     $categories = $cats->return_sorted_array(0, false, '', '', '', true, '', false);
     $category_list = array();
     foreach ($categories as $category) {
         if (in_array($category['id'], $tts_frontend_cat_selected)) {
             $category_list[] = array('id' => $category['id'], 'name' => $category['name'], 'selected' => $category['id'] == $default_cat ? 1 : 0);
         }
     }
     $form_action_data = array('menuaction' => 'frontend.uihelpdesk.add_ticket', 'noframework' => '1', 'origin' => $origin, 'p_entity_id' => $p_entity_id, 'p_cat_id' => $p_cat_id, 'p_num' => $p_num);
     $data = array('redirect' => isset($redirect) ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uihelpdesk.index')) : null, 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog)), 'form_action' => $GLOBALS['phpgw']->link('/index.php', $form_action_data), 'title' => $values['title'], 'locationdesc' => $values['locationdesc'], 'description' => $values['description'], 'noform' => $noform, 'category_list' => $category_list, 'custom_attributes' => array('attributes' => $item['attributes']));
     $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 'helpdesk', 'attributes_view'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('add_ticket' => $data));
 }
    /**
     * Check the consumption  on an order - and notify the coordinator
     * @param integer $order_id
     */
    function notify_coordinator_on_consumption($order_id)
    {
        $notify_coordinator = true;
        if (!$notify_coordinator) {
            return false;
        }
        $toarray = array();
        $workorder = $this->so->read_single($order_id);
        if (!$workorder['continuous']) {
            return false;
        }
        $project = ExecMethod('property.boproject.read_single_mini', $workorder['project_id']);
        $coordinator = $project['coordinator'];
        $prefs_coordinator = $this->bocommon->create_preferences('property', $coordinator);
        if (isset($prefs_coordinator['email']) && $prefs_coordinator['email']) {
            $toarray[] = $prefs_coordinator['email'];
        }
        if ($toarray) {
            $budget_info = $this->so->get_order_budget_percent($order_id);
            if ($budget_info['percent'] < 90) {
                return false;
            }
            if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['email']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['email']) {
                $from_name = $GLOBALS['phpgw_info']['user']['fullname'];
                $from_email = $GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
            } else {
                $from_name = 'noreply';
                $from_email = "{$from_name}<*****@*****.**>";
            }
            $subject = "Bestilling # {$order_id} har disponert {$budget_info['percent']} prosent av budsjettet";
            $lang_budget = lang('budget');
            $lang_actual_cost = lang('actual cost');
            $lang_percent = lang('percent');
            $lang_obligation = lang('obligation');
            $_budget = number_format($budget_info['budget'], 0, ',', ' ');
            $_actual_cost = number_format($budget_info['actual_cost'], 0, ',', ' ');
            $_budget = number_format($budget_info['budget'], 0, ',', ' ');
            $_obligation = number_format($budget_info['obligation'], 0, ',', ' ');
            $to = implode(';', $toarray);
            $cc = false;
            $bcc = false;
            $body = '<a href ="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiworkorder.edit', 'id' => $order_id), false, true) . '">' . lang('workorder %1 has been edited', $order_id) . '</a>' . "\n";
            $body .= <<<HTML
\t\t\t\t</br>
\t\t\t\t<h2>{$workorder['title']}</h2>
\t\t\t\t</br>
\t\t\t\t</br>
\t\t\t\t<table>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t{$lang_budget}
\t\t\t\t\t\t</td>
\t\t\t\t\t\t<td align = 'right'>
\t\t\t\t\t\t\t{$_budget}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t{$lang_actual_cost}
\t\t\t\t\t\t</td>
\t\t\t\t\t\t<td align = 'right'>
\t\t\t\t\t\t\t{$_actual_cost}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t{$lang_percent}
\t\t\t\t\t\t</td>
\t\t\t\t\t\t<td align = 'right'>
\t\t\t\t\t\t\t{$budget_info['percent']}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t{$lang_obligation}
\t\t\t\t\t\t</td>
\t\t\t\t\t\t<td align = 'right'>
\t\t\t\t\t\t\t{$_obligation}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t</table>
HTML;
            if (!is_object($GLOBALS['phpgw']->send)) {
                $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
            }
            try {
                $ok = $GLOBALS['phpgw']->send->msg('email', $to, $subject, $body, false, $cc, $bcc, $from_email, $from_name, 'html');
            } catch (phpmailerException $e) {
                phpgwapi_cache::message_set($e->getMessage(), 'error');
            }
            if ($ok) {
                $historylog = CreateObject('property.historylog', 'workorder');
                $historylog->add('ON', $order_id, lang('%1 is notified', $to));
                $historylog->add('RM', $order_id, $subject);
                return true;
            }
        }
    }
<form id="<?php 
    echo $list_id;
    ?>
_form" method="GET">
<?php 
    $populate = phpgw::get_var('populate_form');
    //Avoid Notices
    $q = false;
    $s_type = false;
    $status = false;
    $status_contract = false;
    if (isset($populate)) {
        $q = phpgwapi_cache::session_get('rental', 'composite_query');
        $s_type = phpgwapi_cache::session_get('rental', 'composite_search_type');
        $status = phpgwapi_cache::session_get('rental', 'composite_status');
        $status_contract = phpgwapi_cache::session_get('rental', 'composite_status_contract');
    }
    ?>
	<fieldset>
		<!-- Search -->
		<h3><?php 
    echo lang('search_options');
    ?>
</h3>
		<label for="ctrl_search_query"><?php 
    echo lang('search_for');
    ?>
</label>
		<input id="<?php 
    echo $list_id;
    ?>
 private function update_ticket($id, $project, $values_attribute)
 {
     $_finnish_date = (int) $project['end_date'];
     if (!$_finnish_date) {
         return;
     }
     $finnish_date = $_finnish_date;
     $note = 'FerdigDato er automatisk til prosjekt sluttDato';
     if ($project['b_account_id'] == 48) {
         //search for 2 working day delay
         for ($i = 2; $i < 10; $i++) {
             $finnish_date = $_finnish_date + 86400 * $i;
             $working_days = phpgwapi_datetime::get_working_days($_finnish_date, $finnish_date);
             if ($working_days == 2) {
                 $note = 'FerdigDato er automatisk oppdatert til 2 virkedager etter prosjekt sluttDato';
                 break;
             }
         }
     }
     $this->db->query("SELECT status, finnish_date, finnish_date2 FROM fm_tts_tickets WHERE id='{$id}'", __LINE__, __FILE__);
     $this->db->next_record();
     $status = $this->db->f('status');
     /**
      * Kun oppdatere åpne meldinger
      */
     if ($status == 'X') {
         return;
     }
     $oldfinnish_date = (int) $this->db->f('finnish_date');
     $oldfinnish_date2 = (int) $this->db->f('finnish_date2');
     $update = false;
     if ($oldfinnish_date && $finnish_date && $oldfinnish_date2 != $finnish_date) {
         $this->db->query("UPDATE fm_tts_tickets SET finnish_date2='{$finnish_date}' WHERE id='{$id}'", __LINE__, __FILE__);
         $old_value = $oldfinnish_date2;
         $update = true;
     } else {
         if (!$oldfinnish_date && $finnish_date && $oldfinnish_date != $finnish_date) {
             $this->db->query("UPDATE fm_tts_tickets SET finnish_date='{$finnish_date}' , finnish_date2='{$finnish_date}' WHERE id='{$id}'", __LINE__, __FILE__);
             $old_value = $oldfinnish_date;
             $update = true;
         }
     }
     if ($update) {
         $fields_updated = array('finnish_date');
         $this->historylog->add('F', $id, $finnish_date, $old_value);
         $this->historylog->add('C', $id, $note);
         $this->botts->mail_ticket($id, $fields_updated, $receipt = array(), $project['location_code'], false, true);
         phpgwapi_cache::message_set(lang('finnish date changed'), 'message');
     }
 }