function index() { $GLOBALS['phpgw']->xslttpl->add_file(array('user', 'nextmatchs', 'search_field')); $account_info = $this->bo->read(); $content = array(); foreach ($account_info as $entry) { if ($entry['grants']) { $link_training = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiuser.training', 'user_id' => $entry['account_id'])); $text_training = lang('training'); $lang_training_user_text = lang('Training profile'); } else { $link_training = ''; $text_training = ''; $lang_training_user_text = ''; } $content[] = array('first_name' => $entry['account_firstname'], 'last_name' => $entry['account_lastname'], 'link_training' => $link_training, 'link_view' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiuser.view', ' user_id' => $entry['account_id'])), 'lang_view_user_text' => lang('view the user'), 'lang_training_user_text' => $lang_training_user_text, 'lang_edit_user_text' => lang('edit the user'), 'text_view' => lang('view'), 'text_edit' => lang('edit'), 'text_training' => $text_training); } //_debug_array($content); $table_header[] = array('sort_last_name' => $this->nextmatchs->show_sort_order(array('sort' => $this->sort, 'var' => 'account_lastname', 'order' => $this->order, 'extra' => array('menuaction' => 'hrm.uiuser.index', 'query' => $this->query, 'allrows' => $this->allrows))), 'lang_last_name' => lang('Last name'), 'sort_first_name' => $this->nextmatchs->show_sort_order(array('sort' => $this->sort, 'var' => 'account_firstname', 'order' => $this->order, 'extra' => array('menuaction' => 'hrm.uiuser.index', 'query' => $this->query, 'allrows' => $this->allrows))), 'lang_first_name' => lang('First name'), 'lang_training' => lang('training'), 'lang_edit' => lang('edit'), 'lang_view' => lang('view')); if (!$this->allrows) { $record_limit = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; } else { $record_limit = $this->bo->total_records; } $link_data = array('menuaction' => 'hrm.uiuser.index', 'sort' => $this->sort, 'order' => $this->order, 'query' => $this->query); $data = array('menu' => execMethod('hrm.menu.links'), 'allow_allrows' => true, 'allrows' => $this->allrows, 'start_record' => $this->start, 'record_limit' => $record_limit, 'num_records' => count($account_info), 'all_records' => $this->bo->total_records, 'link_url' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'img_path' => $GLOBALS['phpgw']->common->get_image_path('phpgwapi', 'default'), 'lang_searchfield_categorytext' => lang('Enter the search string. To show all entries, empty this field and press the SUBMIT button again'), 'lang_searchbutton_categorytext' => lang('Submit the search string'), 'query' => $this->query, 'lang_search' => lang('search'), 'table_header' => $table_header, 'values' => $content); $appname = lang('user'); $function_msg = lang('list user'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('hrm') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('list' => $data)); $this->save_sessiondata(); }
/** * Get list of contacts to notify at location item * * @param array $data location_id and location_item_id * @return array content. */ public function read($data = array()) { if (!isset($data['location_id']) || !isset($data['location_item_id']) || !$data['location_item_id']) { return array(); } $location_id = (int) $data['location_id']; $location_item_id = $data['location_item_id']; // in case of bigint $sql = "SELECT phpgw_notification.id, phpgw_notification.contact_id,phpgw_notification.user_id," . " phpgw_notification.is_active,phpgw_notification.entry_date,phpgw_notification.notification_method," . " first_name, last_name" . " FROM phpgw_notification" . " {$this->_join} phpgw_contact_person ON phpgw_notification.contact_id = phpgw_contact_person.person_id" . " WHERE location_id = {$location_id} AND location_item_id = '{$location_item_id}'"; $this->_db->query($sql, __LINE__, __FILE__); $values = array(); $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; $lang_yes = lang('yes'); $lang_no = lang('no'); while ($this->_db->next_record()) { $values[] = array('id' => $this->_db->f('id'), 'location_id' => $location_id, 'location_item_id' => $location_item_id, 'contact_id' => $this->_db->f('contact_id'), 'is_active' => $this->_db->f('is_active'), 'notification_method' => $this->_db->f('notification_method', true), 'user_id' => $this->_db->f('user_id'), 'entry_date' => $GLOBALS['phpgw']->common->show_date($this->_db->f('entry_date'), $dateformat), 'first_name' => $this->_db->f('first_name', true), 'last_name' => $this->_db->f('last_name', true)); } $contacts = CreateObject('phpgwapi.contacts'); $socommon = CreateObject('property.socommon'); foreach ($values as &$entry) { $comms = execMethod('addressbook.boaddressbook.get_comm_contact_data', $entry['contact_id']); $entry['email'] = $comms[$entry['contact_id']]['work email']; $entry['sms'] = $comms[$entry['contact_id']]['mobile (cell) phone']; $entry['is_active_text'] = $entry['is_active'] ? $lang_yes : $lang_no; $sql = "SELECT account_id FROM phpgw_accounts WHERE person_id = " . (int) $entry['contact_id']; $this->_db->query($sql, __LINE__, __FILE__); if ($this->_db->next_record()) { $account_id = $this->_db->f('account_id'); $prefs = $socommon->create_preferences('property', $account_id); $entry['email'] = isset($entry['email']) && $entry['email'] ? $entry['email'] : $prefs['email']; $entry['sms'] = isset($entry['sms']) && $entry['sms'] ? $entry['sms'] : $prefs['cellphone']; } } return $values; }
function get_buildings_on_property($user_role, $parent_location_code, $level) { $children = execMethod('property.solocation.get_children', $parent_location_code); foreach ($children as &$entry) { $entry['id'] = "{$parent_location_code}-{$entry['id']}"; } return $children; /* // Property level if ($level == 1) { $property_location_code = $location_code; } // Building level else if ($level > 1) { $split_loc_code_array = explode('-', $location_code); $property_location_code = $split_loc_code_array[0]; } if ($user_role) { $criteria = array(); $criteria['location_code'] = $property_location_code; $criteria['field_name'] = 'loc2_name'; $criteria['child_level'] = '2'; $buildings_on_property = execMethod('property.solocation.get_children', $criteria); } else { $buildings_on_property = execMethod('property.solocation.get_children', $property_location_code); } return $buildings_on_property; */ }
function item_expanded($id) { static $navbar_state; if (!isset($navbar_state)) { $navbar_state = execMethod('phpgwapi.template_portico.retrieve_local', 'navbar_config'); } return isset($navbar_state[$id]); }
public function purge_log() { if ($GLOBALS['phpgw']->acl->check('error_log_access', 1, 'admin')) { $GLOBALS['phpgw']->redirect_link('/index.php'); } execMethod('admin.bolog.purge_log', phpgw::get_var('account_id', 'int')); $GLOBALS['phpgw']->redirect_link('index.php', array('menuaction', 'admin.uilog.list_log')); }
function links() { if (!isset($GLOBALS['phpgw_info']['user']['preferences']['sms']['horisontal_menus']) || $GLOBALS['phpgw_info']['user']['preferences']['sms']['horisontal_menus'] == 'no') { return; } $GLOBALS['phpgw']->xslttpl->add_file(array('menu')); $menu_brutto = execMethod('sms.menu.get_menu'); $selection = explode('::', $GLOBALS['phpgw_info']['flags']['menu_selection']); $level = 0; $menu['navigation'] = $this->get_sub_menu($menu_brutto['navigation'], $selection, $level); return $menu; }
/** * Parse navigation bar * * @param boolean $force */ function parse_navbar($force = False) { // we hack the template root here as this is the template set of last resort $tpl = CreateObject('phpgwapi.Template', dirname(__FILE__), "remove"); $tpl->set_file('navbar', 'navbar.tpl'); $tpl->set_block('navbar', 'app', 'apps'); $navbar = execMethod('phpgwapi.menu.get', 'navbar'); prepare_navbar($navbar); foreach ($navbar as $app => $app_data) { if ($app == 'logout') { if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) { $tpl->set_var(array('url' => "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')", 'text' => lang('help'), 'icon' => $GLOBALS['phpgw']->common->image('manual', 'navbar'))); } $tpl->parse('apps', 'app', true); } $tpl->set_var(array('url' => $app_data['url'], 'text' => $app_data['text'], 'icon' => $GLOBALS['phpgw']->common->image($app_data['image'][0], $app_data['image'][1]))); $tpl->parse('apps', 'app', true); } // Maybe we should create a common function in the phpgw_accounts_shared.inc.php file // to get rid of duplicate code. if (!isset($GLOBALS['phpgw_info']['user']['lastpasswd_change']) || $GLOBALS['phpgw_info']['user']['lastpasswd_change'] == 0) { $api_messages = lang('You are required to change your password during your first login') . '<br> Click this image on the navbar: <img src="' . $GLOBALS['phpgw']->common->image('preferences', 'navbar') . '">'; } else { if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - 86400 * 30) { $api_messages = lang('it has been more then %1 days since you changed your password', 30); } } // This is gonna change if (isset($cd)) { $var['messages'] = "<div class=\"warn\">{$api_messages}<br>\n" . checkcode($cd) . "</div>\n"; } if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) { $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; } else { $tpl->set_block('navbar', 'app_header', 'app_header'); $var['app_header'] = ''; } $tpl->set_var($var); $tpl->pfp('out', 'navbar'); // If the application has a header include, we now include it if ((!isset($GLOBALS['phpgw_info']['flags']['noappheader']) || !$GLOBALS['phpgw_info']['flags']['noappheader']) && isset($_GET['menuaction'])) { list($app, $class, $method) = explode('.', $_GET['menuaction']); if (is_array($GLOBALS[$class]->public_functions) && isset($GLOBALS[$class]->public_functions['header'])) { $GLOBALS[$class]->header(); } } $GLOBALS['phpgw']->template->set_root(PHPGW_APP_TPL); $GLOBALS['phpgw']->hooks->process('after_navbar'); unset($GLOBALS['phpgw_info']['navbar']); }
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 __construct($location_id, $debug = false) { $location_id = (int) $location_id; set_time_limit(10000); //Set the time limit for this request $this->account = (int) $GLOBALS['phpgw_info']['user']['account_id']; $this->db =& $GLOBALS['phpgw']->db; $this->join = $this->db->join; if ($location_id && !($category = execMethod('property.soadmin_entity.get_single_category', $location_id))) { throw new Exception("Not a valid location for {$location_id}"); } if ($debug) { $this->debug = true; } $this->is_eav = !!$category['is_eav']; $this->location_id = $location_id; $this->entity_id = $category['entity_id']; $this->cat_id = $category['id']; if ($this->is_eav) { $this->table = 'fm_bim_item'; $sql = "SELECT fm_bim_type.id FROM fm_bim_type WHERE location_id = {$location_id}"; $this->db->query($sql, __LINE__, __FILE__); $this->db->next_record(); $this->bim_type_id = $this->db->f('id'); $custom = createObject('property.custom_fields'); $attributes = $custom->find2($location_id, 0, '', 'ASC', 'attrib_sort', true, true); $this->metadata['id'] = array('primary_key' => true); $this->metadata['location_id'] = array('primary_key' => true); $this->metadata['model'] = array(); $this->metadata['p_location_id'] = array(); $this->metadata['p_id'] = array(); $this->metadata['location_code'] = array(); $this->metadata['loc1'] = array(); $this->metadata['address'] = array(); $this->metadata['entry_date'] = array(); $this->metadata['user_id'] = array(); foreach ($attributes as $attribute) { $this->metadata[$attribute['column_name']] = array(); } } else { $this->table = "fm_entity_{$category['entity_id']}_{$category['id']}"; $this->metadata = $this->db->metadata($this->table); } }
protected function populate(int $unit_id, &$unit) { $location_code = $this->unmarshal($this->db->f('location_code', true), 'string'); // We get the data from the property module $data = execMethod('property.bolocation.read_single', array('location_code' => $location_code, 'extra' => array('view' => true))); $level = -1; $names = array(); $levelFound = false; for ($i = 1; !$levelFound; $i++) { $loc_name = 'loc' . $i . '_name'; if (array_key_exists($loc_name, $data)) { $level = $i; $names[$level] = $data[$loc_name]; } else { $levelFound = true; } } $gab_id = ''; $gabinfos = execMethod('property.sogab.read', array('location_code' => $location_code, 'allrows' => true)); if ($gabinfos != null && is_array($gabinfos) && count($gabinfos) == 1) { $gabinfo = array_shift($gabinfos); $gab_id = $gabinfo['gab_id']; } $location = new rental_property_location($location_code, rental_uicommon::get_nicely_formatted_gab_id($gab_id), $level, $names); $location->set_address_1($data['street_name'] . ' ' . $data['street_number']); foreach ($data['attributes'] as $attributes) { switch ($attributes['column_name']) { case 'area_gross': $location->set_area_gros($attributes['value']); break; case 'area_net': $location->set_area_net($attributes['value']); break; case 'bruttoareal': $location->set_area_gros($attributes['value']); break; case 'nettoareal': $location->set_area_net($attributes['value']); break; } } return new rental_unit($this->unmarshal($this->db->f('id', true), 'int'), $this->unmarshal($this->db->f('composite_id', true), 'int'), $location); }
function index() { $GLOBALS['phpgw_info']['flags']['xslt_app'] = true; if (!$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'sms')) { $this->bocommon->no_access(); return; } $GLOBALS['phpgw']->xslttpl->add_file(array('poll', 'nextmatchs', 'search_field')); $receipt = $GLOBALS['phpgw']->session->appsession('session_data', 'sms_poll_receipt'); $GLOBALS['phpgw']->session->appsession('session_data', 'sms_poll_receipt', ''); $poll_info = $this->bo->read(); foreach ($poll_info as $entry) { if ($this->bocommon->check_perms($entry['grants'], PHPGW_ACL_DELETE)) { $link_delete = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'sms.uipoll.delete', 'poll_id' => $entry['id'])); $text_delete = lang('delete'); $lang_delete_text = lang('delete the poll code'); } if ($entry['enable'] == 1) { $status = lang('enabled'); } else { $status = lang('disabled'); } $content[] = array('code' => $entry['code'], 'title' => $entry['title'], 'status' => $status, 'user' => $GLOBALS['phpgw']->accounts->id2name($entry['uid']), 'link_edit' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'sms.uipoll.edit', 'poll_id' => $entry['id'])), 'link_delete' => $link_delete, 'link_view' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'sms.uipoll.view', 'poll_id' => $entry['id'])), 'lang_view_config_text' => lang('view the config'), 'lang_edit_config_text' => lang('manage the poll code'), 'text_view' => lang('view'), 'text_edit' => lang('edit'), 'text_delete' => $text_delete, 'lang_delete_text' => $lang_delete_text); unset($link_delete); unset($text_delete); unset($lang_delete_text); } $table_header[] = array('sort_code' => $this->nextmatchs->show_sort_order(array('sort' => $this->sort, 'var' => 'poll_code', 'order' => $this->order, 'extra' => array('menuaction' => 'sms.uipoll.index', 'query' => $this->query, 'cat_id' => $this->cat_id, 'allrows' => $this->allrows))), 'lang_code' => lang('code'), 'lang_delete' => lang('delete'), 'lang_edit' => lang('edit'), 'lang_view' => lang('view'), 'lang_user' => lang('user'), 'lang_title' => lang('title'), 'lang_status' => lang('status')); if (!$this->allrows) { $record_limit = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; } else { $record_limit = $this->bo->total_records; } $link_data = array('menuaction' => 'sms.uipoll.index', 'sort' => $this->sort, 'order' => $this->order, 'cat_id' => $this->cat_id, 'filter' => $this->filter, 'query' => $this->query); $table_add[] = array('lang_add' => lang('add'), 'lang_add_statustext' => lang('add a poll'), 'add_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'sms.uipoll.add'))); $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt); $data = array('msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'menu' => execMethod('sms.menu.links'), 'allow_allrows' => true, 'allrows' => $this->allrows, 'start_record' => $this->start, 'record_limit' => $record_limit, 'num_records' => count($poll_info), 'all_records' => $this->bo->total_records, 'link_url' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'img_path' => $GLOBALS['phpgw']->common->get_image_path('phpgwapi', 'default'), 'lang_searchfield_statustext' => lang('Enter the search string. To show all entries, empty this field and press the SUBMIT button again'), 'lang_searchbutton_statustext' => lang('Submit the search string'), 'query' => $this->query, 'lang_search' => lang('search'), 'table_header' => $table_header, 'table_add' => $table_add, 'values' => $content); $appname = lang('polls'); $function_msg = lang('list SMS polls'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('sms') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('list' => $data)); $this->save_sessiondata(); }
function index() { $GLOBALS['phpgw']->xslttpl->add_file(array('place', 'nextmatchs', 'menu', 'search_field')); $place_info = $this->bo->read(); while (is_array($place_info) && (list(, $entry) = each($place_info))) { $content[] = array('name' => $entry['name'], 'link_edit' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiplace.edit', 'place_id' => $entry['id'])), 'link_delete' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiplace.delete', 'place_id' => $entry['id'])), 'link_view' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiplace.view', 'place_id' => $entry['id'])), 'lang_view_place_text' => lang('view the place'), 'lang_edit_place_text' => lang('edit the place'), 'text_view' => lang('view'), 'text_edit' => lang('edit'), 'text_delete' => lang('delete'), 'lang_delete_place_text' => lang('delete the place')); } //_debug_array($content); $table_header[] = array('sort_name' => $this->nextmatchs->show_sort_order(array('sort' => $this->sort, 'var' => 'name', 'order' => $this->order, 'extra' => array('menuaction' => 'hrm.uiplace.index', 'query' => $this->query, 'cat_id' => $this->cat_id, 'allrows' => $this->allrows))), 'lang_delete' => lang('delete'), 'lang_edit' => lang('edit'), 'lang_view' => lang('view')); if (!$this->allrows) { $record_limit = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; } else { $record_limit = $this->bo->total_records; } $link_data = array('menuaction' => 'hrm.uiplace.index', 'sort' => $this->sort, 'order' => $this->order, 'cat_id' => $this->cat_id, 'filter' => $this->filter, 'query' => $this->query); $table_add[] = array('lang_add' => lang('add'), 'lang_add_statustext' => lang('add a place'), 'add_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'hrm.uiplace.edit'))); $msgbox_data = $this->bocommon->msgbox_data($receipt); $data = array('msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'menu' => execMethod('hrm.menu.links'), 'allow_allrows' => true, 'allrows' => $this->allrows, 'start_record' => $this->start, 'record_limit' => $record_limit, 'num_records' => count($place_info), 'all_records' => $this->bo->total_records, 'link_url' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'img_path' => $GLOBALS['phpgw']->common->get_image_path('phpgwapi', 'default'), 'lang_searchfield_statustext' => lang('Enter the search string. To show all entries, empty this field and press the SUBMIT button again'), 'lang_searchbutton_statustext' => lang('Submit the search string'), 'query' => $this->query, 'lang_search' => lang('search'), 'table_header' => $table_header, 'table_add' => $table_add, 'values' => $content); $appname = lang('place'); $function_msg = lang('list place'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('hrm') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('list' => $data)); $this->save_sessiondata(); }
/** * forward voucher to other persons * */ public function forward() { $GLOBALS['phpgw_info']['flags']['noframework'] = true; $user_lid = phpgw::get_var('user_lid', 'string', 'GET', 'all'); $voucher_id = phpgw::get_var('voucher_id', 'int', 'GET'); $redirect = false; $role_check = array('is_janitor' => lang('janitor'), 'is_supervisor' => lang('supervisor'), 'is_budget_responsible' => lang('b - responsible')); $approve = $this->bo->get_approve_role(); $values = phpgw::get_var('values'); $receipt = array(); if (isset($values['save'])) { if ($GLOBALS['phpgw']->session->is_repost()) { $receipt['error'][] = array('msg' => lang('repost')); } if (!$approve) { $receipt['error'][] = array('msg' => lang('you are not approved for this task')); } if (!$receipt['error']) { $values['voucher_id'] = $voucher_id; $receipt = $this->bo->forward($values); if (!$receipt['error']) { execMethod('property.soworkorder.close_orders', phpgw::get_var('orders')); $redirect = true; } } } $voucher = $this->bo->read_single_voucher($voucher_id); $orders = array(); $_orders = array(); foreach ($voucher as $line) { if ($line['order_id']) { $_orders[] = $line['order_id']; } } $_orders = array_unique($_orders); foreach ($_orders as $_order) { $orders[] = array('id' => $_order); } $approved_list = array(); $approved_list[] = array('role' => $role_check['is_janitor'], 'role_sign' => 'oppsynsmannid', 'initials' => $line['janitor'] ? $line['janitor'] : '', 'date' => $line['oppsynsigndato'] ? $GLOBALS['phpgw']->common->show_date(strtotime($line['oppsynsigndato'])) : '', 'user_list' => !$line['oppsynsigndato'] ? array('options_user' => $this->bocommon->get_user_list_right(32, isset($line['janitor']) ? $line['janitor'] : '', '.invoice')) : ''); $approved_list[] = array('role' => $role_check['is_supervisor'], 'role_sign' => 'saksbehandlerid', 'initials' => $line['supervisor'] ? $line['supervisor'] : '', 'date' => $line['saksigndato'] ? $GLOBALS['phpgw']->common->show_date(strtotime($line['saksigndato'])) : '', 'user_list' => !$line['saksigndato'] ? array('options_user' => $this->bocommon->get_user_list_right(64, isset($line['supervisor']) ? $line['supervisor'] : '', '.invoice')) : ''); $approved_list[] = array('role' => $role_check['is_budget_responsible'], 'role_sign' => 'budsjettansvarligid', 'initials' => $line['budget_responsible'] ? $line['budget_responsible'] : '', 'date' => $line['budsjettsigndato'] ? $GLOBALS['phpgw']->common->show_date(strtotime($line['budsjettsigndato'])) : '', 'user_list' => !$line['budsjettsigndato'] ? array('options_user' => $this->bocommon->get_user_list_right(128, isset($line['budget_responsible']) ? $line['budget_responsible'] : '', '.invoice')) : ''); $my_initials = $GLOBALS['phpgw_info']['user']['account_lid']; foreach ($approve as &$_approve) { if ($_approve['id'] == 'is_janitor' && $my_initials == $line['janitor'] && $line['oppsynsigndato']) { $_approve['selected'] = 1; $sign_orig = 'is_janitor'; } else { if ($_approve['id'] == 'is_supervisor' && $my_initials == $line['supervisor'] && $line['saksigndato']) { $_approve['selected'] = 1; $sign_orig = 'is_supervisor'; } else { if ($_approve['id'] == 'is_budget_responsible' && $my_initials == $line['budget_responsible'] && $line['budsjettsigndato']) { $_approve['selected'] = 1; $sign_orig = 'is_budget_responsible'; } } } } unset($_approve); $approve_list = array(); foreach ($approve as $_approve) { if ($_approve['id'] == 'is_janitor') { if ($my_initials == $line['janitor'] && $line['oppsynsigndato'] || !$line['oppsynsigndato']) { $approve_list[] = $_approve; } } if ($_approve['id'] == 'is_supervisor') { if ($my_initials == $line['supervisor'] && $line['saksigndato'] || !$line['saksigndato']) { $approve_list[] = $_approve; } } if ($_approve['id'] == 'is_budget_responsible') { if ($my_initials == $line['budget_responsible'] && $line['budsjettsigndato'] || !$line['budsjettsigndato']) { $approve_list[] = $_approve; } } } $data = array('redirect' => $redirect ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.index', 'user_lid' => $user_lid)) : null, 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)), 'from_name' => $GLOBALS['phpgw_info']['user']['fullname'], 'form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.forward', 'user_lid' => $user_lid, 'voucher_id' => $voucher_id)), 'approve_list' => $approve_list, 'approved_list' => $approved_list, 'sign_orig' => $sign_orig, 'my_initials' => $my_initials, 'project_group_data' => $project_group_data, 'orders' => $orders, 'value_amount' => $line['amount'], 'value_currency' => $line['currency'], 'value_process_log' => isset($values['process_log']) && $values['process_log'] ? $values['process_log'] : $line['process_log']); $GLOBALS['phpgw']->xslttpl->add_file('invoice'); $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('forward' => $data)); }
public function edit_favorite() { if ($activity_id = phpgw::get_var('id')) { $activity = $this->so->get_single($activity_id); if (isset($GLOBALS['phpgw_info']['user']['preferences']['logistic']['menu_favorites']) && $GLOBALS['phpgw_info']['user']['preferences']['logistic']['menu_favorites']) { $menu_favorites = $GLOBALS['phpgw_info']['user']['preferences']['logistic']['menu_favorites']; } else { $menu_favorites = array(); } if (isset($menu_favorites['activity'][$activity_id])) { unset($menu_favorites['activity'][$activity_id]); } else { $menu_favorites['activity'][$activity_id] = $activity->get_name(); } $GLOBALS['phpgw']->preferences->account_id = $GLOBALS['phpgw_info']['user']['account_id']; $GLOBALS['phpgw']->preferences->read(); $GLOBALS['phpgw']->preferences->add('logistic', 'menu_favorites', $menu_favorites, 'user'); $GLOBALS['phpgw']->preferences->save_repository(); execMethod('phpgwapi.menu.clear'); } $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'logistic.uiactivity.index')); }
<?php $GLOBALS['phpgw_info'] = array(); $GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => false, 'currentapp' => 'home', 'enable_network_class' => true, 'enable_contacts_class' => true, 'enable_nextmatchs_class' => true); include_once '../header.inc.php'; // Start------------------------------------------------- phpgw::import_class('phpgwapi.yui'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/examples/treeview/assets/css/folders/tree.css'); phpgwapi_yui::load_widget('treeview'); phpgwapi_yui::load_widget('cookie'); $GLOBALS['phpgw']->js->validate_file('yahoo', 'test.menu', 'property'); $currentapp = $GLOBALS['phpgw_info']['flags']['currentapp']; $applications = array(); $mapping = array(0 => array('name' => 'first_element_is_dummy')); $exclude = array('home', 'preferences', 'about', 'logout'); $navbar = execMethod('phpgwapi.menu.get', 'navbar'); $i = 1; foreach ($navbar as $app => $app_data) { if (in_array($app, $exclude)) { continue; } $applications[] = array('value' => array('id' => $i, 'app' => $app, 'label' => $app_data['text'], 'href' => str_replace('&', '&', $app_data['url'])), 'children' => array()); $mapping[$i] = array('id' => $i, 'name' => $app, 'expanded' => false, 'highlight' => true, 'is_leaf' => false); $i++; } $applications = json_encode($applications); $mapping = json_encode($mapping); $html = <<<HTML \t\t<div id="MenutreeDiv1"></div> \t\t<script type="text/javascript"> \t\t var apps = {$applications};
} /** * */ function section_end() { $GLOBALS['phpgw']->template->parse('rows', 'spacer_row', true); } /** * * * @param $appname * @param $file * @param $file2 */ function display_section($nav, $items) { section_start($nav['text'], $GLOBALS['phpgw']->common->image($nav['image'][0], $nav['image'][1])); foreach ($items as $item) { section_item($item['url'], $item['text']); } section_end(); } $menus = execMethod('phpgwapi.menu.get'); foreach ($GLOBALS['phpgw_info']['user']['apps'] as $app => $app_info) { if (isset($menus['preferences'][$app])) { display_section($menus['navbar'][$app], $menus['preferences'][$app]); } } $GLOBALS['phpgw']->template->pfp('out', 'list'); $GLOBALS['phpgw']->common->phpgw_footer();
public function query() { $entity_group_id = phpgw::get_var('entity_group_id', 'int'); $location_id = phpgw::get_var('location_id', 'int'); $control_area = phpgw::get_var('control_area', 'int'); $user_id = phpgw::get_var('user_id', 'int'); $district_id = phpgw::get_var('district_id', 'int'); $query = phpgw::get_var('query', 'string'); $year = phpgw::get_var('year', 'int'); $all_items = phpgw::get_var('all_items', 'bool'); $user_only = phpgw::get_var('user_only', 'bool'); $filter_status = phpgw::get_var('status', 'string'); $report_type = phpgw::get_var('report_type', 'string'); if ($filter_component_str = phpgw::get_var('filter_component', 'string')) { $filter_component_arr = explode('_', $filter_component_str); $location_id = $filter_component_arr[0]; $filter_component = $filter_component_arr[1]; } if ($org_unit_id = phpgw::get_var('org_unit_id', 'int')) { $_subs = execMethod('property.sogeneric.read_tree', array('node_id' => $org_unit_id, 'type' => 'org_unit')); $this->org_units[] = $org_unit_id; foreach ($_subs as $entry) { $this->org_units[] = $entry['id']; if (isset($entry['children']) && $entry['children']) { $this->_get_children($entry['children']); } } unset($entry); unset($_subs); } $so_control = CreateObject('controller.socontrol'); $this->so = CreateObject('controller.socheck_list'); // Validates year. If year is not set, current year is chosen $year = execMethod('controller.uicalendar.validate_year', $year); // Gets timestamp of first day in year $from_date_ts = execMethod('controller.uicalendar.get_start_date_year_ts', $year); // Gets timestamp of first day in next year $to_date_ts = execMethod('controller.uicalendar.get_end_date_year_ts', $year); $location_filter = $this->get_location_filter(); foreach ($location_filter as $_location) { $location_type_name[$_location['id']] = $_location['name']; } // _debug_array($location_type_name); $components = array(); $keep_only_assigned_to = 0; // $lookup_stray_items = false; $lookup_stray_items = !!$entity_group_id; if ($user_id < 0) { $user_id = $user_id * -1; $all_items = false; $user_only = true; // $keep_only_assigned_to = $user_id; // $assigned_components = $so_control->get_assigned_control_components($from_date_ts, $to_date_ts, $assigned_to = $user_id); // foreach($assigned_components as $_location_id => $component_list) // { // $_components = execMethod('property.soentity.read',array( // 'filter_entity_group' => $entity_group_id, // 'location_id' => $_location_id, // 'district_id' => $district_id, // 'allrows' => true, // 'filter_item' => $component_list // ) // ); // $components = array_merge($components, $_components); // } } if (!$location_id) { //nothing } else { if ($location_id == -1 && !$entity_group_id) { //nothing } else { if (!$location_id && $entity_group_id) { //still nothing } else { $exclude_locations = array(); foreach ($location_filter as $_location_filter) { if ($location_id > 0 && $_location_filter['id'] != $location_id) { continue; } $_location_id = (int) $_location_filter['id']; $exclude_locations[] = $_location_id; $_components = execMethod('property.soentity.read', array('filter_entity_group' => $entity_group_id, 'location_id' => $_location_id, 'district_id' => $district_id, 'org_units' => $this->org_units, 'allrows' => true, 'control_registered' => !$all_items, 'check_for_control' => true, 'filter_item' => $filter_component ? array($filter_component) : array())); $components = array_merge($components, $_components); } if ($lookup_stray_items) { $_components = execMethod('property.soentity.read_entity_group', array('entity_group_id' => $entity_group_id, 'exclude_locations' => $exclude_locations, 'location_id' => $_location_id, 'district_id' => $district_id, 'org_units' => $this->org_units, 'allrows' => true, 'control_registered' => !$all_items, 'check_for_control' => true)); $components = array_merge($components, $_components); } } } } $all_components = array(); $components_with_calendar_array = array(); // _debug_array($components); foreach ($components as $_component) { $location_id = $_component['location_id']; $component_id = $_component['id']; $all_components["{$location_id}_{$component_id}"] = $_component; $short_description = $_component['short_description']; $short_description .= ' [' . $_component['location_name'] . ']'; if ($all_items && !$_component['has_control']) { continue; } $controls_at_component = $so_control->get_controls_at_component2($_component); foreach ($controls_at_component as $component) { $_control_relation = $component->get_control_relation(); if (!$_control_relation['serie_enabled']) { // continue; } $control_id = $_control_relation['control_id']; $control = $so_control->get_single($control_id); $repeat_type = $control->get_repeat_type(); //FIXME: Not currently supported if ($repeat_type <= controller_control::REPEAT_TYPE_WEEK) { $repeat_type = controller_control::REPEAT_TYPE_MONTH; } // LOCATIONS: Process aggregated values for controls with repeat type day or week if ($repeat_type <= controller_control::REPEAT_TYPE_WEEK) { //FIXME: Not currently supported $component->set_xml_short_desc(" {$location_type_name[$location_id]}</br>{$short_description}"); $component_with_check_lists = $this->so->get_check_lists_for_control_and_component($control_id, $component->get_location_id(), $component->get_id(), $from_date_ts, $to_date_ts, $repeat_type); $cl_criteria = new controller_check_list(); $cl_criteria->set_control_id($control->get_id()); $cl_criteria->set_component_id($component->get_id()); $cl_criteria->set_location_id($component->get_location_id()); $from_month = $this->get_start_month_for_control($control); $to_month = $this->get_end_month_for_control($control); // Loops through controls in controls_for_location_array and populates aggregate open cases pr month array. $agg_open_cases_pr_month_array = $this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month, $to_month); $year_calendar_agg = new year_calendar_agg($control, $year, $location_code, "VIEW_LOCATIONS_FOR_CONTROL"); $calendar_array = $year_calendar_agg->build_calendar($agg_open_cases_pr_month_array); $components_with_calendar_array["{$location_id}_{$component_id}"][] = array("component" => $component->toArray(), "calendar_array" => $calendar_array); } else { if ($repeat_type > controller_control::REPEAT_TYPE_WEEK) { $component->set_xml_short_desc(" {$location_type_name[$location_id]}</br>{$short_description}"); $component_with_check_lists = $this->so->get_check_lists_for_control_and_component($control_id, $component->get_location_id(), $component->get_id(), $from_date_ts, $to_date_ts, $repeat_type); // ,$user_id); $check_lists_array = $component_with_check_lists["check_lists_array"]; /* * start override control with data from serie */ $control_relation = $component->get_control_relation(); if (isset($control_relation['start_date']) && $control_relation['start_date']) { $control->set_start_date($control_relation['start_date']); } if (isset($control_relation['end_date']) && $control_relation['end_date']) { $control->set_end_date($control_relation['end_date']); } if (isset($control_relation['repeat_type']) && $control_relation['repeat_type']) { $control->set_repeat_type($control_relation['repeat_type']); } if (isset($control_relation['repeat_interval']) && $control_relation['repeat_interval']) { $control->set_repeat_interval($control_relation['repeat_interval']); } $year_calendar = new year_calendar($control, $year, $component, null, "component", $control_relation); $calendar_array = $year_calendar->build_calendar($check_lists_array); if ($user_only && $user_id) { $keep_only_assigned_to = $user_id; $found_assigned_to = false; if ($calendar_array) { foreach ($calendar_array as $_month => $_month_info) { if (isset($_month_info['info']['assigned_to']) && $_month_info['info']['assigned_to'] == $user_id) { $found_assigned_to = true; break; } } } if (!$found_assigned_to) { unset($all_components["{$location_id}_{$component_id}"]); continue; } } $components_with_calendar_array["{$location_id}_{$component_id}"][] = array("component" => $component->toArray(), "calendar_array" => $calendar_array); } } } } $total_records = count($all_components); // _debug_array($components_with_calendar_array); unset($component_id); // _debug_array($components_with_calendar_array[1]); // _debug_array($components); // _debug_array(array_keys($components_with_calendar_array)); $repeat_type_array = array("0" => lang('day'), "1" => lang('week'), "2" => lang('month'), "3" => lang('year')); $values = array(); foreach ($components_with_calendar_array as $dummy => $entry) { $location_id = $entry[0]['component']['location_id']; $component_id = $entry[0]['component']['id']; unset($all_components["{$location_id}_{$component_id}"]); $data = array(); $component_link_data = array('menuaction' => 'property.uientity.edit', 'location_id' => $location_id, 'id' => $component_id, 'active_tab' => 'controller'); $data['component_url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" target='_blank'>{$component_id}{$entry[0]['component']['xml_short_desc']}</a>"; $data['component_id'] = $component_id; $data['location_id'] = $location_id; $max_interval_length = 0; //number of months $_data = array(); foreach ($entry as $dataset) { $repeat_type = (int) $dataset['component']['control_relation']['repeat_type']; $repeat_interval = (int) $dataset['component']['control_relation']['repeat_interval']; /* REPEAT_TYPE_DAY = 0; REPEAT_TYPE_WEEK = 1; REPEAT_TYPE_MONTH = 2; REPEAT_TYPE_YEAR = 3; */ switch ($repeat_type) { case controller_control::REPEAT_TYPE_DAY: $interval_length = ceil($repeat_interval / 30); break; case controller_control::REPEAT_TYPE_WEEK: $interval_length = ceil($repeat_interval / 4); break; case controller_control::REPEAT_TYPE_MONTH: $interval_length = $repeat_interval; break; case controller_control::REPEAT_TYPE_YEAR: $interval_length = $repeat_interval * 12; $interval_length = $interval_length > 12 ? 12 : $interval_length; break; default: $interval_length = 0; break; } $service_time = $dataset['component']['control_relation']['service_time']; $controle_time = $dataset['component']['control_relation']['controle_time']; if ($interval_length > $max_interval_length) { $max_interval_length = $interval_length; } foreach ($dataset['calendar_array'] as $month => $calendar) { if ($calendar) { // $repeat_type = $calendar['info']['repeat_type'] ? (int)$calendar['info']['repeat_type'] : $repeat_type; $calendar['info']['service_time'] = $calendar['info']['service_time'] ? $calendar['info']['service_time'] : $service_time; $calendar['info']['controle_time'] = $calendar['info']['controle_time'] ? $calendar['info']['controle_time'] : $controle_time; $_data[$month][$interval_length] = $calendar; $_data[$month][$interval_length]['repeat_type'] = $repeat_type; $_data[$month][$interval_length]['repeat_interval'] = $repeat_interval; } } } for ($_month = 1; $_month < 13; $_month++) { for ($i = $max_interval_length; $i > -1; $i--) { if (isset($_data[$_month][$i])) { $data[$_month] = $_data[$_month][$i]; $data[$_month]['repeat_type'] = "{$repeat_type_array[$_data[$_month][$i]['repeat_type']]}/{$_data[$_month][$i]['repeat_interval']}"; //FIXME break 1; } else { $data[$_month] = array(); } } } $values[] = $data; } unset($entry); unset($component_id); unset($component); if ($report_type == 'summary') { return array('components' => null, 'summary' => $this->get_summary($values, $user_id), 'location_filter' => $location_filter); } $choose_master = false; if ($all_components && count($all_components)) { $choose_master = true; foreach ($all_components as $dummy => $component) { $data = array(); $location_id = $component['location_id']; $component_id = $component['id']; $component_link_data = array('menuaction' => 'property.uientity.edit', 'location_id' => $location_id, 'id' => $component_id, 'active_tab' => 'controller'); $short_description = $component['short_description']; $short_description .= "[ {$component['location_name']} ]"; $data['component_url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" target='_blank'>{$component_id} {$location_type_name[$location_id]}</br>{$short_description}</a>"; $data['component_id'] = $component_id; $data['location_id'] = $location_id; $data['missing_control'] = true; $values[] = $data; } } //_debug_array($values); $data_set = array(); $total_time = array(); foreach ($values as $entry) { $row = array(); $row_sum = array(); $row_sum_actual = array(); //billable_hours $row['component_url'] = $entry['component_url']; $row['year'] = ''; $row['descr'] = ''; if (!isset($entry['missing_control'])) { if ($filter_component_str) { $row['choose'] = '<input id="selected_component" type="checkbox" name="selected_component" checked = "checked" onclick="deselect_component();">'; } else { if ($choose_master) { $row['choose'] = "<input id=\"master_component\" type=\"radio\" name=\"master_component\" value = \"{$entry['location_id']}_{$entry['component_id']}\" >"; } } $row['year'] = $year; $row['descr'] = "Frekvens<br/>Status<br/>Utførende<br/>Tidsbruk"; } else { if ($choose_master) { $row['choose'] = "<input id=\"selected_components\" class=\"mychecks\" type=\"checkbox\" name=\"selected_components[]\" value = \"{$entry['location_id']}_{$entry['component_id']}\">"; } } $found_at_least_one = false; for ($_month = 1; $_month < 13; $_month++) { $row[$_month] = $this->translate_calendar_info($entry[$_month], $year, $_month, $filter_status, $found_at_least_one, $keep_only_assigned_to); if ($row[$_month] && (!$user_id || $entry[$_month]['info']['assigned_to'] == $user_id)) { $row_sum[$_month] = $entry[$_month]['info']['service_time'] + $entry[$_month]['info']['controle_time']; $row_sum_actual[$_month] = +$entry[$_month]['info']['billable_hours']; } else { $row_sum[$_month] = 0; $row_sum_actual[$_month] = 0; } } if (!$filter_status || $found_at_least_one) { $total_time[] = $row_sum; $total_time_actual[] = $row_sum_actual; $data_set[] = $row; } } $fields = $this->get_fields($filter_component_str); $class = ''; $tbody = ''; foreach ($data_set as $row_data) { $tbody .= "<tr {$class}>"; foreach ($fields as $field) { $tbody .= '<td>'; $tbody .= $row_data[$field['key']]; $tbody .= '</td>'; } $tbody .= '</tr>'; $class = $class ? '' : 'class="alt"'; } $result = array('tbody' => $tbody); unset($_month); $sum_year = 0; $sum_year_actual = 0; if (!$total_time) { for ($_month = 1; $_month < 13; $_month++) { $result['time_sum'][$_month] = 0; } } else { foreach ($total_time as $_row) { for ($_month = 1; $_month < 13; $_month++) { $result['time_sum'][$_month] += $_row[$_month]; $sum_year += $_row[$_month]; } } unset($_row); } $result['time_sum'][0] = $sum_year; if (!$total_time_actual) { for ($_month = 1; $_month < 13; $_month++) { $result['time_sum_actual'][$_month] = 0; } } else { foreach ($total_time_actual as $_row) { for ($_month = 1; $_month < 13; $_month++) { $result['time_sum_actual'][$_month] += $_row[$_month]; $sum_year_actual += $_row[$_month]; } } } $result['time_sum_actual'][0] = $sum_year_actual; $result['total_records'] = $total_records; $result['location_filter'] = $location_filter; if ($choose_master) { $lang_save = lang('add'); $lang_select = lang('select'); $result['checkall'] = "<input type=\"button\" value = '{$lang_save}' title = '{$lang_save}' onclick=\"add_from_master('mychecks');\">"; $result['checkall'] .= '</br>'; $result['checkall'] .= "<input type=\"checkbox\" title = '{$lang_select}' onclick=\"checkAll('mychecks');\">"; } else { $result['checkall'] = ''; } return array('components' => $result, 'summary' => null, 'location_filter' => $location_filter); }
} ?> </select> <?php } ?> <label for="district_id"><?php echo lang('district'); ?> </label> <select name="district_id" id="<?php echo $list_id; ?> _district_id"> <?php $districts = execMethod('property.sogeneric.get_list', array('type' => 'district')); echo "<option value=''>" . lang('select') . "</option>"; foreach ($districts as $district) { echo "<option value='{$district['id']}'>{$district['name']}</option>"; } ?> </select> <label for="ctrl_toggle_active_rental_composites"><?php echo lang('availability'); ?> </label> <select name="is_active" id="<?php echo $list_id; ?> _ctrl_toggle_active_rental_composites"> <option value="both" <?php
protected function _update_status_workorder($execute, $status_new, $ids) { if (!$execute || !$status_new) { return; } $historylog = CreateObject('property.historylog', 'workorder'); if ($this->db->get_transaction()) { $this->global_lock = true; } else { $this->db->transaction_begin(); } foreach ($ids as $id) { if (!$id) { continue; } $this->db->query("SELECT status, vendor_id FROM fm_workorder WHERE id = '{$id}'", __LINE__, __FILE__); $this->db->next_record(); $old_status = $this->db->f('status'); $vendor_id = $this->db->f('vendor_id'); if ($old_status != $status_new) { phpgwapi_cache::system_clear('property', "budget_order_{$id}"); $this->db->query("UPDATE fm_workorder SET status = '{$status_new}' WHERE id = '{$id}'", __LINE__, __FILE__); $historylog->add('S', $id, $status_new, $old_status); $historylog->add('RM', $id, 'Status endret via masseoppdatering eller prosjekt'); } $action_params_approved = array('appname' => 'property', 'location' => '.project.workorder', 'id' => $id, 'responsible' => $this->account, 'responsible_type' => 'user', 'action' => 'approval', 'remark' => '', 'deadline' => ''); /* * Sigurd: Consider remove */ /* $action_params_progress = array ( 'appname' => 'property', 'location' => '.project.workorder', 'id' => $id, 'responsible' => $vendor_id, 'responsible_type' => 'vendor', 'action' => 'remind', 'remark' => '', 'deadline' => '' ); */ $this->db->query("SELECT * FROM fm_workorder_status WHERE id = '{$status_new}'"); $this->db->next_record(); if ($this->db->f('approved')) { execMethod('property.sopending_action.close_pending_action', $action_params_approved); } if ($this->db->f('in_progress')) { // execMethod('property.sopending_action.close_pending_action', $action_params_progress); } if ($this->db->f('delivered') || $this->db->f('closed')) { execMethod('property.sopending_action.close_pending_action', $action_params_approved); // execMethod('property.sopending_action.close_pending_action', $action_params_progress); } } if (!$this->global_lock) { $this->db->transaction_commit(); } }
function delete($cat_id = '', $entity_id = '', $attrib_id = '', $acl_location = '', $custom_function_id = '', $group_id = '') { if (!$attrib_id && !$cat_id && $entity_id && !$custom_function_id && !$group_id) { $this->so->delete_entity($entity_id); execMethod('phpgwapi.menu.clear'); } else { if (!$attrib_id && $cat_id && $entity_id && !$custom_function_id && !$group_id) { $this->so->delete_category($entity_id, $cat_id); execMethod('phpgwapi.menu.clear'); } else { if ($group_id && $cat_id && $entity_id && !$custom_function_id && !$attrib_id) { $this->custom->delete_group($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}", $group_id); } else { if ($attrib_id && $cat_id && $entity_id && !$custom_function_id && !$group_id) { $this->custom->delete($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}", $attrib_id); $this->so->delete_history($entity_id, $cat_id, $attrib_id); } else { if ($custom_function_id && $acl_location) { $GLOBALS['phpgw']->custom_functions->delete($this->type_app[$this->type], $acl_location, $custom_function_id); } } } } } }
/** * Parse navigation var * * @param boolean $force * @ignore */ function parse_navbar($force = False) { $tpl = createobject('phpgwapi.Template', PHPGW_TEMPLATE_DIR); $tpl->set_file('navbartpl', 'navbar.tpl'); $tpl->set_block('navbartpl', 'preferences'); $tpl->set_block('navbartpl', 'navbar'); $var['img_root'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/verdilak/images'; $currentapp = $GLOBALS['phpgw_info']['flags']['currentapp']; $applications = ''; $exclude = array('home', 'preferences', 'about', 'logout'); $navbar = execMethod('phpgwapi.menu.get', 'navbar'); prepare_navbar($navbar); foreach ($navbar as $app => $app_data) { if (in_array($app, $exclude)) { continue; } if ($app == $currentapp) { $app_data['text'] = "[<b>{$app_data['text']}</b>]"; } $applications .= <<<HTML \t\t\t\t<br> \t\t\t\t<a href="{$app_data['url']}">{$app_data['text']}</a> HTML; /* $icon = $GLOBALS['phpgw']->common->image($app_data['image'][0], $app_data['image'][1]); $applications .= <<<HTML <br> <a href="{$app_data['url']}"> <img src="{$icon}" alt="{$app_data['text']}" title="{$app_data['text']}"> </a> HTML; */ } $menu_array = execMethod('phpgwapi.menu.get_local_menu', $currentapp); $var['app_menu'] = phpgwapi_menu::render_horisontal_menu($menu_array); $var['applications'] = $applications; $var['logo'] = 'logo.png'; $var['home_url'] = $GLOBALS['phpgw']->link('/home.php'); $var['home_text'] = lang('home'); $var['about_url'] = $GLOBALS['phpgw']->link('/about.php', array('appname' => $GLOBALS['phpgw_info']['flags']['currentapp'])); $var['about_text'] = lang('about'); $var['logout_url'] = $GLOBALS['phpgw']->link('/logout.php'); $var['logout_text'] = lang('logout'); if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) { $var['help_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')"; $var['help_text'] = lang('help'); $var['help_icon'] = 'icon icon-help'; } if ($GLOBALS['phpgw']->acl->check('run', PHPGW_ACL_READ, 'preferences')) { $var['preferences_url'] = $GLOBALS['phpgw']->link('/preferences/index.php'); $var['preferences_text'] = lang('preferences'); } if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') { $var['welcome_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'welcome-red'); } else { $var['welcome_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'welcome-grey'); } if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'preferences') { $var['preferences_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'preferences-red'); } else { $var['preferences_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'preferences-grey'); } $var['logout_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'logout-grey'); $var['powered_by'] = lang('Powered by phpGroupWare version %1', $GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers'])) { $var['current_users'] = '<a style="font-family: Geneva,Arial,Helvetica,sans-serif; font-size: 12pt;" href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uicurrentsessions.list_sessions')) . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; } $now = time(); $var['user_info'] = $GLOBALS['phpgw']->common->display_fullname() . ' - ' . lang($GLOBALS['phpgw']->common->show_date($now, 'l')) . ' ' . $GLOBALS['phpgw']->common->show_date($now, $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); // . lang($GLOBALS['phpgw']->common->show_date($now,'F')) . ' ' // . $GLOBALS['phpgw']->common->show_date($now,'d, Y'); // Maybe we should create a common function in the phpgw_accounts_shared.inc.php file // to get rid of duplicate code. if (!isset($GLOBALS['phpgw_info']['user']['lastpasswd_change']) || $GLOBALS['phpgw_info']['user']['lastpasswd_change'] == 0) { $api_messages = lang('You are required to change your password during your first login') . '<br> Click this image on the navbar: <img src="' . $GLOBALS['phpgw']->common->image('preferences', 'navbar.png') . '">'; } else { if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - 86400 * 30) { $api_messages = lang('it has been more then %1 days since you changed your password', 30); } } // This is gonna change if (isset($cd)) { $var['messages'] = $api_messages . '<br>' . checkcode($cd); } if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) { $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; } else { $tpl->set_block('navbar', 'app_header', 'app_header'); $var['app_header'] = ''; } $tpl->set_var($var); // check if user is allowed to change his prefs if (isset($GLOBALS['phpgw_info']['user']['apps']['preferences']) && $GLOBALS['phpgw_info']['user']['apps']['preferences']) { $tpl->parse('preferences_icon', 'preferences'); } else { $tpl->set_var('preferences_icon', ''); } $tpl->pfp('out', 'navbar'); // If the application has a header include, we now include it $menuaction = phpgw::get_var('menuaction', 'string', 'GET'); if (!isset($GLOBALS['phpgw_info']['flags']['noappheader']) && $menuaction) { list($app, $class, $method) = explode('.', $menuaction); if (is_array($GLOBALS[$class]->public_functions) && isset($GLOBALS[$class]->public_functions['header'])) { $GLOBALS[$class]->header(); } } $GLOBALS['phpgw']->hooks->process('after_navbar'); return; }
/** * Parse navigation var * * @param boolean $force * @ignore */ function parse_navbar($force = False) { $tpl = CreateObject('phpgwapi.Template', PHPGW_TEMPLATE_DIR, 'remove'); $tpl->set_file('navbar', 'navbar.tpl'); $tpl->set_block('navbar', 'app', 'apps'); $tpl->set_block('navbar', 'preferences', 'preferences_icon'); $exclude = array('home', 'preferences', 'about', 'logout'); $navbar = execMethod('phpgwapi.menu.get', 'navbar'); prepare_navbar($navbar); foreach ($navbar as $app => $app_data) { if (in_array($app, $exclude)) { continue; } $tpl->set_var(array('text' => strtoupper($app_data['text']), 'url' => $app_data['url'])); $tpl->parse('apps', 'app', true); } $var['home_link'] = $navbar['home']['url']; $var['preferences_link'] = $navbar['preferences']['url']; $var['logout_link'] = $navbar['logout']['url']; $var['help_link'] = $navbar['about']['url']; if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home') { $var['welcome_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'welcome2'); $var['welcome_img_hover'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'welcome2', '_over'); } else { $var['welcome_img'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'welcome2', '_over'); $var['welcome_img_hover'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'welcome2'); } if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'preferences') { $var['preferences_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'preferences2'); $var['preferences_img_hover'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'preferences2', '_over'); } else { $var['preferences_img'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'preferences2', '_over'); $var['preferences_img_hover'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'preferences2'); } $var['logout_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'log_out2'); $var['logout_img_hover'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'log_out2', '_over'); if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'about') { $var['about_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'question_mark2'); $var['about_img_hover'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'question_mark2', '_over'); } else { $var['about_img'] = $GLOBALS['phpgw']->common->image_on('phpgwapi', 'question_mark2', '_over'); $var['about_img_hover'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'question_mark2'); } $var['content_spacer_middle_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'content_spacer_middle'); $var['em_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'em'); $var['logo_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'logo'); $var['top_spacer_middle_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'top_spacer_middle'); $var['nav_bar_left_spacer_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'nav_bar_left_spacer'); $var['nav_bar_left_top_bg_img'] = $GLOBALS['phpgw']->common->image('phpgwapi', 'nav_bar_left_top_bg'); // "powered_by_color" and "_size" are is also used by number of current users thing $var['powered_by_size'] = '2'; $var['powered_by_color'] = '#ffffff'; if ($GLOBALS['phpgw_info']['server']['showpoweredbyon'] == 'top') { $var['powered_by'] = lang('Powered by phpGroupWare version %1', $GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); $tpl->set_var($var); } else { $var['powered_by'] = ''; $tpl->set_var($var); } if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) { $var['current_users'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uicurrentsessions.list_sessions')) . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; $tpl->set_var($var); } else { $var['current_users'] = ''; $tpl->set_var($var); } $var['user_info_name'] = $GLOBALS['phpgw']->common->display_fullname(); $now = time(); $var['user_info_date'] = lang($GLOBALS['phpgw']->common->show_date($now, 'l')) . ' ' . $GLOBALS['phpgw']->common->show_date($now, $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); $var['user_info'] = $var['user_info_name'] . ' - ' . $var['user_info_date']; $var['user_info_size'] = '2'; $var['user_info_color'] = '#000000'; // Maybe we should create a common function in the phpgw_accounts_shared.inc.php file // to get rid of duplicate code. if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == 0) { $api_messages = lang('You are required to change your password during your first login') . '<br> Click this image on the navbar: <img src="' . $GLOBALS['phpgw']->common->image('preferences', 'navbar.gif') . '">'; } elseif ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - 86400 * 30) { $api_messages = lang('it has been more then %1 days since you changed your password', 30); } // This is gonna change if (isset($cd)) { $var['messages'] = $api_messages . '<br>' . checkcode($cd); } $var['th_bg'] = $GLOBALS['phpgw_info']['theme']['th_bg']; if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) { $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; } else { $tpl->set_block('navbar', 'app_header', 'app_header'); $var['app_header'] = '<br>'; } $tpl->set_var($var); // check if user is allowed to change his prefs if ($GLOBALS['phpgw_info']['user']['apps']['preferences']) { $tpl->parse('preferences_icon', 'preferences'); } else { $tpl->set_var('preferences_icon', ''); } $tpl->pfp('out', 'navbar'); // If the application has a header include, we now include it if (!isset($GLOBALS['phpgw_info']['flags']['noappheader']) && ($menuaction = phpgw::get_var('menuaction', 'string', 'GET'))) { list($app, $class, $method) = explode('.', $menuaction); if (is_array($GLOBALS[$class]->public_functions) && $GLOBALS[$class]->public_functions['header']) { $GLOBALS[$class]->header(); } } $GLOBALS['phpgw']->hooks->process('after_navbar'); return; }
$login = ''; if ($msg->from_email) { $login = sender2phpgw_lid($msg->from_email); } if (!$login) { fwrite(STDERR, "ERROR: Sender's email address [{$msg->from_email}] does not match any user's account, rejecting message\n"); $error = true; } else { // This is a hack and the data is a little dodgy, but it works, so we have a more accurate source IP address $_SERVER['HTTP_HOST'] = $msg->ip; if ($GLOBALS['phpgw']->session->create($login, '', true)) { $mail_handlers = createObject('phpgwapi.mail_handlers'); $handler = $mail_handlers->get_handler($email_to); if (count($handler)) { $msg->handler_id = $handler['handler_id']; $error = execMethod($handler['handler'], $msg); } else { fwrite(STDERR, "ERROR: No handler found for {$email_to}, rejecting message\n"); $error = true; } $GLOBALS['phpgw']->session->destroy($GLOBALS['phpgw_info']['user']['sessionid'], $GLOBALS['phpgw']->session->kp3); } else { fwrite(STDERR, "ERROR: Unable to create session for {$login} (reason: {$GLOBALS['phpgw']->session->cd_reason})\n"); $error = true; } } if ($error) { exit(1); } exit; function sender2phpgw_lid($sender_email)
/** * Parse navigation bar * * @param boolean $force * @ignore */ function parse_navbar($force = false) { $tpl = createobject('phpgwapi.Template', PHPGW_TEMPLATE_DIR); $tpl->set_unknowns('remove'); $tpl->set_file('navbar', 'navbar.tpl'); $tpl->set_block('navbar', 'app_row', 'app_rows'); $var['api_root'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/probusiness/'; /* * folder handling */ if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $mtree = createobject('folders.uifolders', ''); $var['switchlink'] = $mtree->get_switchlink(); $folderMode = $mtree->get_folderMode(); } if (false) { if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $var['navbarview'] = $mtree->get_iframe(); } } else { /* * application list */ $navbar = execMethod('phpgwapi.menu.get', 'navbar'); prepare_navbar($navbar); foreach ($navbar as $app => $app_data) { if ($app == 'logout') { if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) { $tpl->set_var(array('url' => "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')", 'text' => lang('help'), 'image' => $GLOBALS['phpgw']->common->image('manual', 'navbar'))); } $tpl->parse('app_rows', 'app_row', true); } if ($app == $GLOBALS['phpgw_info']['flags']['currentapp']) { $app_data['class'] = ' class="selectedNavLink"'; } $app_data['image'] = $GLOBALS['phpgw']->common->image($app_data['image'][0], $app_data['image'][1]); $tpl->set_var($app_data); $tpl->parse('app_rows', 'app_row', true); } } // get sidebox content and parse it as a menu // it's just a hack. You need to enable the folders module to get an ouput if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $GLOBALS['phpgw']->hooks->single('sidebox_menu', $GLOBALS['phpgw_info']['flags']['currentapp']); $var['sideboxcontent'] = parseMenu(); } if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) { $var['current_users'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uicurrentsessions.list_sessions')) . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; } if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == 0) { $api_messages = lang('You are required to change your password during your first login') . '<br> Click this image on the navbar: <img src="' . $GLOBALS['phpgw']->common->image('preferences', 'navbar.gif') . '">'; } elseif ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - 86400 * 30) { $api_messages = lang('it has been more then %1 days since you changed your password', 30); } // This gonna change if (isset($cd)) { $var['messages'] = $api_messages . '<br>' . checkcode($cd); } if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) { $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; } $tpl->set_var($var); $tpl->pfp('out', 'navbar'); // If the application has a header include, we now include it if (!@$GLOBALS['phpgw_info']['flags']['noappheader'] && @isset($_GET['menuaction'])) { list($app, $class, $method) = explode('.', $_GET['menuaction']); if (is_array($GLOBALS[$class]->public_functions) && isset($GLOBALS[$class]->public_functions['header']) && $GLOBALS[$class]->public_functions['header']) { $GLOBALS[$class]->header(); } } $GLOBALS['phpgw']->hooks->process('after_navbar'); }
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)); }
function read($data = array()) { if ($this->org_unit_id && !$this->org_units) { $_org_unit_id = (int) $this->org_unit_id; $_subs = execMethod('property.sogeneric.read_tree', array('node_id' => $_org_unit_id, 'type' => 'org_unit')); $this->org_units[] = $_org_unit_id; foreach ($_subs as $entry) { $this->org_units[] = $entry['id']; if (isset($entry['children']) && $entry['children']) { $this->_get_children($entry['children']); } } } static $location_data = array(); static $org_units_data = array(); if (isset($this->allrows) && $this->allrows) { $data['allrows'] = true; } $custom = createObject('phpgwapi.custom_fields'); $attrib_data = $custom->find($this->type_app[$this->type], ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 0, '', '', '', true, true); $category = $this->soadmin_entity->read_single_category($this->entity_id, $this->cat_id); $attrib_filter = array(); $javascript_action = array(); $location_id = $GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], ".{$this->type}.{$this->entity_id}.{$this->cat_id}"); if ($attrib_data) { foreach ($attrib_data as $attrib) { if ($attrib['datatype'] == 'LB' || $attrib['datatype'] == 'R') { if ($_attrib_filter_value = phpgw::get_var($attrib['column_name'], 'int')) { if ($category['is_eav']) { $attrib_filter[] = "xmlexists('//{$attrib['column_name']}[text() = ''{$_attrib_filter_value}'']' PASSING BY REF xml_representation)"; } else { $attrib_filter[] = "fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} = '{$_attrib_filter_value}'"; } } } else { if ($attrib['datatype'] == 'CH') { if ($_attrib_filter_value = phpgw::get_var($attrib['column_name'], 'int')) { if ($category['is_eav']) { $attrib_filter[] = "xmlexists('//{$attrib['column_name']}[contains(.,'',{$_attrib_filter_value},'')]' PASSING BY REF xml_representation)"; } else { $attrib_filter[] = "fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} {$GLOBALS['phpgw']->db->like} '%,{$_attrib_filter_value},%'"; } } } } if ($attrib['datatype'] == 'link') { if ($attrib['javascript_action']) { $javascript_action[$attrib['name']] = $attrib['javascript_action']; $js = <<<JS \t\t\t\t\t\t\tjavascript_action_{$attrib['name']} = function(id,location_code) \t\t\t\t\t\t\t{ JS; $js .= str_replace(array('__entity_id__', '__cat_id__', '__location_id__'), array($this->entity_id, $this->cat_id, $location_id), $attrib['javascript_action']); $js .= <<<JS \t\t\t\t\t\t\t} JS; $GLOBALS['phpgw']->js->add_code('', $js); } } } } $entity = $this->so->read(array('start' => $this->start, 'query' => $this->query, 'sort' => $this->sort, 'order' => $this->order, 'filter' => $this->filter, 'cat_id' => $this->cat_id, 'district_id' => $this->district_id, 'part_of_town_id' => $this->part_of_town_id, 'lookup' => isset($data['lookup']) ? $data['lookup'] : '', 'allrows' => isset($data['allrows']) ? $data['allrows'] : '', 'results' => $this->results, 'entity_id' => $this->entity_id, 'status' => $this->status, 'start_date' => $this->bocommon->date_to_timestamp($data['start_date']), 'end_date' => $this->bocommon->date_to_timestamp($data['end_date']), 'dry_run' => $data['dry_run'], 'type' => $data['type'], 'location_code' => $this->location_code, 'criteria_id' => $this->criteria_id, 'attrib_filter' => $attrib_filter, 'p_num' => $this->p_num, 'control_registered' => isset($data['control_registered']) ? $data['control_registered'] : '', 'control_id' => isset($data['control_id']) ? $data['control_id'] : '', 'org_units' => $this->org_units)); $this->total_records = $this->so->total_records; $this->uicols = $this->so->uicols; $user_columns = isset($GLOBALS['phpgw_info']['user']['preferences'][$this->type_app[$this->type]]["{$this->type}_columns_{$this->entity_id}_{$this->cat_id}"]) ? $GLOBALS['phpgw_info']['user']['preferences'][$this->type_app[$this->type]]["{$this->type}_columns_{$this->entity_id}_{$this->cat_id}"] : array(); $custom_cols = $this->get_column_list(); //_debug_array($user_columns); //_debug_array($column_list); $cols_extra = $this->so->cols_extra; $cols_return_lookup = $this->so->cols_return_lookup; foreach ($custom_cols as $col_id => $col_info) { if (in_array($col_id, $user_columns)) { $this->uicols['input_type'][] = 'text'; $this->uicols['name'][] = $col_id; $this->uicols['descr'][] = $custom_cols[$col_id]['descr']; $this->uicols['statustext'][] = $custom_cols[$col_id]['descr']; $this->uicols['exchange'][] = false; $this->uicols['align'][] = ''; $this->uicols['datatype'][] = $custom_cols[$col_id]['datatype']; $this->uicols['formatter'][] = ''; $this->uicols['classname'][] = ''; $this->uicols['sortable'][] = false; $cols_extra[] = $col_id; } } $sogeneric = CreateObject('property.sogeneric'); $sogeneric->get_location_info('org_unit'); foreach ($entity as &$entry) { //_debug_array($entry);die(); if (isset($entry['location_code'])) { if (!isset($location_data[$entry['location_code']])) { $location_data[$entry['location_code']] = $this->solocation->read_single($entry['location_code']); } for ($j = 0; $j < count($cols_extra); $j++) { $entry[$cols_extra[$j]] = $location_data[$entry['location_code']][$cols_extra[$j]]; } if ($cols_return_lookup) { for ($k = 0; $k < count($cols_return_lookup); $k++) { $entry[$cols_return_lookup[$k]] = $location_data[$entry['location_code']][$cols_return_lookup[$k]]; } } } if (isset($entry['org_unit_id'])) { if (!isset($org_units_data[$entry['org_unit_id']])) { $org_unit = $sogeneric->read_single(array('id' => $entry['org_unit_id'])); $org_units_data[$entry['org_unit_id']]['name'] = $org_unit['name']; } $entry['org_unit'] = $org_units_data[$entry['org_unit_id']]['name']; } foreach ($javascript_action as $_name => $_action) { $entry[$_name] = "javascript_action_{$_name}({$entry['id']},{$entry['location_code']})"; $this->uicols['javascript_action'][$_name] = true; } } return $entity; }
public function edit() { $activity_id = phpgw::get_var('activity_id'); $requirement_id = phpgw::get_var('requirement_id'); $allocation_id = phpgw::get_var('id'); if ($activity_id && is_numeric($activity_id)) { $activity = $this->so_activity->get_single($activity_id); } if ($requirement_id && is_numeric($requirement_id)) { $requirement = $this->so_requirement->get_single($requirement_id); } if ($allocation_id && is_numeric($allocation_id)) { $allocation = $this->so->get_single($allocation_id); } else { $allocation = new logistic_requirement_resource_allocation(); } // $accounts = $GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_READ, 'run', 'logistic'); $allocation_suggestions = array(); if ($requirement) { $requirement_values = $this->so_requirement_value->get(null, null, null, null, null, null, array('requirement_id' => $requirement->get_id())); $criterias_array = array(); $location_id = $requirement->get_location_id(); $loc_arr = $GLOBALS['phpgw']->locations->get_name($location_id); $criterias_array['location_id'] = $location_id; $criterias_array['allrows'] = true; $view_criterias_array = array(); $custom = createObject('phpgwapi.custom_fields'); foreach ($requirement_values as $requirement_value) { $attrib_value = $requirement_value->get_value(); $operator = $requirement_value->get_operator(); $cust_attribute_id = $requirement_value->get_cust_attribute_id(); if ($operator == "eq") { $operator_str = "="; } else { if ($operator == "lt") { $operator_str = "<"; } else { if ($operator == "gt") { $operator_str = ">"; } } } $attrib_data = $custom->get($loc_arr['appname'], $loc_arr['location'], $cust_attribute_id); $view_criterias_array[] = array('operator' => $operator_str, 'value' => $attrib_value, 'cust_attribute_data' => $attrib_data); $condition = array('operator' => $operator_str, 'value' => $attrib_value, 'attribute_id' => $cust_attribute_id); $criterias_array['conditions'][] = $condition; } $entity_category = execMethod('property.soadmin_entity.get_single_category', $location_id); $allocation_suggestions = execMethod('property.soentity.get_eav_list', $criterias_array); if ($entity_category['enable_bulk']) { foreach ($allocation_suggestions as &$entry) { $entry['inventory'] = execMethod('property.boentity.get_inventory', array('location_id' => $location_id, 'id' => $entry['id'])); } } } //Start fuzzy //_debug_array($allocation_suggestions);die(); $suggestion_ids = array(); foreach ($allocation_suggestions as $allocation_suggestion) { $suggestion_ids[] = $allocation_suggestion['id']; } reset($allocation_suggestions); $allocated = $this->so->check_calendar($requirement, $suggestion_ids); //_debug_array($allocated);die(); //end fuzzy $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; $activities = array(); foreach ($allocation_suggestions as &$allocation_suggestion) { if (isset($allocated['items'][$allocation_suggestion['id']])) { $allocation_suggestion['allocated'] = true; $allocated_where = array(); $allocated_date = array(); foreach ($allocated['calendar'][$allocation_suggestion['id']] as $calendar_entry) { $allocated_date[] = $GLOBALS['phpgw']->common->show_date($calendar_entry['start_date'], $dateformat) . ' - ' . $GLOBALS['phpgw']->common->show_date($calendar_entry['end_date'], $dateformat); if (!isset($activities[$calendar_entry['activity_id']])) { $activities[$calendar_entry['activity_id']] = $this->so_activity->get_single($calendar_entry['activity_id']); } if ($activities[$calendar_entry['activity_id']]) { $allocated_where[] = $activities[$calendar_entry['activity_id']]->get_name(); } else { $allocated_where[] = 'N/A'; } } $allocation_suggestion['allocated_date'] = implode('; ', $allocated_date); $allocation_suggestion['allocated_where'] = implode('; ', $allocated_where); } if (isset($allocation_suggestion['inventory'])) { foreach ($allocation_suggestion['inventory'] as &$inventory) { //Allocated to another requirement: if (isset($allocated['allocations'][$inventory['inventory_id']]['requirement_id']) && $requirement->get_id() != $allocated['allocations'][$inventory['inventory_id']]['requirement_id']) { $inventory['disabled'] = true; } $inventory['allocated_amount'] = $allocated['inventory'][$inventory['inventory_id']]; $inventory['bookable_amount'] = (int) $inventory['inventory'] - (int) $allocated['allocations'][$inventory['inventory_id']]['total_allocated']; $inventory['allocation_id'] = $allocated['allocations'][$inventory['inventory_id']]['allocation_id']; if ($allocated['allocations'][$inventory['inventory_id']]['start_date']) { $inventory['allocated_date'] = $GLOBALS['phpgw']->common->show_date($allocated['allocations'][$inventory['inventory_id']]['start_date'], $dateformat) . ' - ' . $GLOBALS['phpgw']->common->show_date($allocated['allocations'][$inventory['inventory_id']]['end_date'], $dateformat); } } } } $activity = $this->so_activity->get_single($requirement->get_activity_id()); $data = array('requirement' => $requirement, 'view_criterias_array' => $view_criterias_array, 'activity' => $activity, 'allocation_suggestions' => $allocation_suggestions, 'editable' => true); self::render_template_xsl(array('allocation/book_resources'), $data); }
/** * Public function for viewing control groups * Displays control groups by chosen control area * * @param HTTP:: control id * @return data array */ public function view_control_groups() { $control_id = phpgw::get_var('control_id'); $control = $this->so->get_single($control_id); // Fetches saved control groups from db $saved_control_groups = $this->so_control_group_list->get_control_groups_by_control($control_id); $saved_control_group_ids = array(); foreach ($saved_control_groups as $control_group) { $saved_control_group_ids[] = $control_group->get_id(); } // Fetches control groups based on selected control area $control_area = execMethod('phpgwapi.categories.return_single', $control->get_control_area_id()); $control_groups_as_array = $this->so_control_group->get_control_groups_as_array($control->get_control_area_id()); $control_groups = array(); foreach ($control_groups_as_array as $control_group) { $control_group_id = $control_group['id']; if (in_array($control_group_id, $saved_control_group_ids)) { $control_groups[] = array("checked" => 1, "control_group" => $control_group); } else { $control_groups[] = array("checked" => 0, "control_group" => $control_group); } } $tabs = $this->make_tab_menu($control_id); $data = array('tabs' => $GLOBALS['phpgw']->common->create_tabs($tabs, 1), 'view' => "control_groups", 'editable' => true, 'control' => $control, 'control_area' => $control_area, 'control_groups' => $control_groups); phpgwapi_jquery::load_widget('core'); self::add_javascript('controller', 'yahoo', 'control_tabs.js'); self::add_javascript('controller', 'controller', 'ajax.js'); self::render_template_xsl(array('control/control_tabs', 'control_group/control_groups'), $data); }
/** * @param mixed $data * If $data is an array - then the process is run as cron */ function daemon_manual($data = array()) { $GLOBALS['phpgw_info']['flags']['menu_selection'] = 'admin::sms::refresh'; if (!$this->acl->check('run', PHPGW_ACL_READ, 'admin')) { $this->bocommon->no_access(); return; } $sms = CreateObject('sms.sms'); $sms->getsmsinbox(true); $sms->getsmsstatus(); if (isset($data['cron'])) { $GLOBALS['phpgw_info']['flags']['xslt_app'] = false; return; } $GLOBALS['phpgw']->xslttpl->add_file(array('sms')); $receipt['message'][] = array('msg' => lang('Daemon refreshed')); $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt); $data = array('msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'menu' => execMethod('sms.menu.links')); $appname = lang('config'); $function_msg = lang('Daemon manual refresh'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('sms') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('daemon_manual' => $data)); }
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)); }