protected function _generate_tabs()
 {
     $tabs = array('general' => array('label' => lang('general'), 'link' => '#general'), 'budget' => array('label' => lang('documents'), 'link' => '#documents'), 'history' => array('label' => lang('history'), 'link' => '#history'));
     phpgwapi_yui::tabview_setup('project_tabview');
     return phpgwapi_yui::tabview_generate($tabs, 'general');
 }
 protected function _generate_tabs($tabs_ = array(), $suppress = array(), $selected = 'general')
 {
     $tabs = array('general' => array('label' => lang('general'), 'link' => '#general', 'function' => "set_tab('general')"), 'location' => array('label' => lang('location'), 'link' => '#location', 'function' => "set_tab('location')"), 'budget' => array('label' => lang('Time and budget'), 'link' => '#budget', 'function' => "set_tab('budget')"), 'coordination' => array('label' => lang('coordination'), 'link' => '#coordination', 'function' => "set_tab('coordination')"), 'documents' => array('label' => lang('documents'), 'link' => '#documents', 'function' => "set_tab('documents')"), 'history' => array('label' => lang('history'), 'link' => '#history', 'function' => "set_tab('history')"));
     $tabs = array_merge($tabs, $tabs_);
     foreach ($suppress as $tab => $remove) {
         if ($remove) {
             unset($tabs[$tab]);
         }
     }
     phpgwapi_yui::tabview_setup('project_tabview');
     return phpgwapi_yui::tabview_generate($tabs, $selected);
 }
 protected function _generate_tabs($history = '')
 {
     if (!($tab = phpgw::get_var('tab'))) {
         $tab = 'general';
     }
     $tabs = array('general' => array('label' => lang('general'), 'link' => '#general'), 'notify' => array('label' => lang('notify'), 'link' => '#notify'));
     if ($history) {
         $tabs['history'] = array('label' => lang('history'), 'link' => '#history');
     }
     phpgwapi_yui::tabview_setup('ticket_tabview');
     return phpgwapi_yui::tabview_generate($tabs, $tab);
 }
 function edit()
 {
     $GLOBALS['phpgw_info']['flags']['noframework'] = true;
     if (!$this->acl_add) {
         $this->bocommon->no_access();
         return;
     }
     $location = phpgw::get_var('location');
     $attrib_id = phpgw::get_var('attrib_id');
     $item_id = phpgw::get_var('item_id');
     //might be bigint
     $id = phpgw::get_var('id', 'int');
     $values = phpgw::get_var('values');
     $values['contact_id'] = phpgw::get_var('contact', 'int', 'POST');
     //			$GLOBALS['phpgw_info']['apps']['manual']['section'] = 'general.edit.' . $type;
     $GLOBALS['phpgw']->xslttpl->add_file(array('event'));
     $receipt = array();
     if (is_array($values)) {
         $values['location_id'] = $GLOBALS['phpgw']->locations->get_id('property', $location);
         $values['attrib_id'] = $attrib_id;
         $values['item_id'] = $item_id;
         $attrib = $this->custom->get('property', $location, $attrib_id);
         $field_name = $attrib ? $attrib['column_name'] : $attrib_id;
         if (isset($values['save']) && $values['save'] || isset($values['apply']) && $values['apply']) {
             if (!isset($values['descr']) || !$values['descr']) {
                 $receipt['error'][] = array('msg' => lang('Please enter a description'));
             }
             if (!isset($values['contact_id']) || !$values['contact_id']) {
                 $receipt['error'][] = array('msg' => lang('Please select a responsible'));
             }
             if (!isset($values['action']) || !$values['action']) {
                 $receipt['error'][] = array('msg' => lang('Please select an action'));
             }
             if (!isset($values['start_date']) || !$values['start_date']) {
                 $receipt['error'][] = array('msg' => lang('Please select a start date'));
             }
             if (!isset($values['repeat_type']) || !$values['repeat_type']) {
                 $receipt['error'][] = array('msg' => lang('Please select a repeat type'));
             }
             /*					if(isset($values['repeat_day']))
             					{
             						$values['repeat_interval'] = 0;
             					}
              */
             if ($id) {
                 $values['id'] = $id;
             } else {
                 $id = $values['id'];
             }
             if (!$receipt['error']) {
                 $receipt = $this->bo->save($values, $action);
                 $js = "opener.document.form.{$field_name}.value = '{$receipt['id']}';\n";
                 $js .= "opener.document.form.{$field_name}_descr.value = '{$values['descr']}';\n";
                 $js .= "opener.document.form.submit();\n";
                 if (isset($values['save']) && $values['save']) {
                     $js .= "window.close();";
                 }
                 $GLOBALS['phpgw']->js->add_event('load', $js);
                 $id = $receipt['id'];
             } else {
                 unset($values['id']);
                 $id = '';
             }
         } else {
             if (isset($values['delete']) && $values['delete']) {
                 $attrib = $this->custom->get('property', $location, $attrib_id);
                 $js = "opener.document.form.{$field_name}.value = '';\n";
                 $js .= "opener.document.form.{$field_name}_descr.value = '';\n";
                 if ($this->delete($id)) {
                     $GLOBALS['phpgw']->js->add_event('load', $js);
                     unset($values);
                     unset($id);
                 }
             } else {
                 if (isset($values['cancel']) && $values['cancel']) {
                     $GLOBALS['phpgw']->js->add_event('load', "window.close();");
                 }
             }
         }
         unset($js);
         unset($attrib);
     }
     if ($id) {
         $values = $this->bo->read_single($id);
         $function_msg = lang('edit event');
     } else {
         $function_msg = lang('add event');
         $values['enabled'] = true;
     }
     $link_data = array('menuaction' => 'property.uievent.edit', 'location' => $location, 'attrib_id' => $attrib_id, 'item_id' => $item_id, 'id' => $id);
     $link_schedule_data = array('menuaction' => 'property.uievent.schedule_week', 'location' => $location, 'attrib_id' => $attrib_id, 'item_id' => $item_id, 'id' => $id);
     //_debug_array($link_data);
     $tabs = array();
     phpgwapi_yui::tabview_setup('general_edit_tabview');
     $tabs['general'] = array('label' => lang('general'), 'link' => '#general');
     $tabs['repeat'] = array('label' => lang('repeat'), 'link' => '#repeat');
     if ($id) {
         $tabs['plan'] = array('label' => lang('plan'), 'link' => '#plan');
     }
     $GLOBALS['phpgw']->jqcal->add_listener('values_start_date');
     $GLOBALS['phpgw']->jqcal->add_listener('values_end_date');
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     $contact_data = $this->bocommon->initiate_ui_contact_lookup(array('contact_id' => $values['contact_id'], 'field' => 'contact', 'type' => 'form'));
     $data = array('contact_data' => $contact_data, 'link_schedule' => $GLOBALS['phpgw']->link('/index.php', $link_schedule_data), 'lang_start_date_statustext' => lang('Select the date for the event'), 'lang_start_date' => lang('date'), 'value_start_date' => $values['start_date'], 'value_enabled' => isset($values['enabled']) ? $values['enabled'] : '', 'lang_enabled' => lang('enabled'), 'lang_end_date_statustext' => lang('Select the estimated end date for the event'), 'lang_end_date' => lang('end date'), 'value_end_date' => $values['end_date'], 'repeat_type' => $this->bo->get_rpt_type_list(isset($values['repeat_type']) ? $values['repeat_type'] : ''), 'lang_repeat_type' => lang('repeat type'), 'repeat_day' => $this->bo->get_rpt_day_list(isset($values['repeat_day']) ? $values['repeat_day'] : ''), 'lang_repeat_day' => lang('repeat day'), 'lang_repeat_interval' => lang('interval'), 'value_repeat_interval' => isset($values['repeat_interval']) ? $values['repeat_interval'] : 0, 'lang_repeat_interval_statustext' => lang('interval'), 'lang_action' => lang('action'), 'action' => $this->bo->get_action(isset($values['action']) ? $values['action'] : ''), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uievent.index', 'type' => $type, 'type_id' => $type_id)), 'lang_id' => lang('ID'), 'lang_descr' => lang('Description'), 'lang_save' => lang('save'), 'lang_cancel' => lang('cancel'), 'lang_apply' => lang('apply'), 'value_id' => isset($values['id']) ? $values['id'] : '', 'lang_next_run' => lang('next run'), 'value_next_run' => isset($values['next']) ? $values['next'] : '', 'value_descr' => $values['descr'], 'lang_descr_text' => lang('Enter a description of the record'), 'lang_save_text' => lang('Save the record'), 'lang_apply_statustext' => lang('Apply the values'), 'lang_cancel_statustext' => lang('Leave the actor untouched and return back to the list'), 'lang_save_statustext' => lang('Save the actor and return back to the list'), 'lang_delete' => lang('delete'), 'lang_delete_text' => lang('delete the record'), 'lang_delete_statustext' => lang('delete the record'), 'textareacols' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 60, 'textarearows' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 10, 'tabs' => phpgwapi_yui::tabview_generate($tabs, 'general'));
     $schedule = array();
     if ($id) {
         $schedule = $this->schedule2($id);
     } else {
         $data['td_count'] = '""';
         $data['base_java_url'] = '""';
         $data['property_js'] = '""';
     }
     $data = array_merge($schedule, $data);
     $appname = lang('event');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . "::{$appname}::{$function_msg}";
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
 }
 public function edit()
 {
     $id = phpgw::get_var('id', 'string');
     $bo = createobject('registration.boreg');
     if (isset($_POST['save']) && $id) {
         $values = phpgw::get_var('values');
         $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property');
         $insert_record_entity = $GLOBALS['phpgw']->session->appsession('insert_record_entity', 'property');
         if (isset($insert_record_entity) && is_array($insert_record_entity)) {
             for ($j = 0; $j < count($insert_record_entity); $j++) {
                 $insert_record['extra'][$insert_record_entity[$j]] = $insert_record_entity[$j];
             }
         }
         $values['account_permissions'] = phpgw::get_var('account_permissions');
         $values['account_permissions_admin'] = phpgw::get_var('account_permissions_admin');
         $values['account_groups'] = phpgw::get_var('account_groups');
         $values = $this->bocommon->collect_locationdata($values, $insert_record);
         $values['id'] = $id;
         //_debug_array($account_permissions);
         //_debug_array($account_permissions_admin);
         //_debug_array($values);die();
         if ($this->bo->update_pending_user($values)) {
             $this->bo->process_users($values);
             $message = lang('messages_saved_form');
             phpgwapi_cache::message_set($message, 'message');
         } else {
             $error = lang('messages_form_error');
             phpgwapi_cache::message_set($message, 'error');
         }
     }
     if (isset($_POST['cancel'])) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'registration.uipending.index'));
     }
     if (isset($_POST['delete']) && $id) {
         $this->bo->delete($id);
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'registration.uipending.index'));
     }
     if ($id) {
         $user = $bo->get_pending_user($id);
     }
     $fields = $bo->fields;
     $user_data = array();
     $user_data[] = array('text' => 'username', 'value' => $user['reg_lid']);
     foreach ($fields as $key => $field_info) {
         if ($user['reg_info'][$field_info['field_name']]) {
             $user_data[] = array('text' => $field_info['field_text'], 'value' => $user['reg_info'][$field_info['field_name']]);
         }
     }
     $bolocation = CreateObject('property.bolocation');
     $user['location_data'] = isset($user['reg_info']['location_code']) && $user['reg_info']['location_code'] ? $bolocation->read_single($user['reg_info']['location_code'], array('view' => true)) : '';
     $location_data = $bolocation->initiate_ui_location(array('values' => $user['location_data'], 'type_id' => -1, 'no_link' => false, 'tenant' => false, 'lookup_type' => 'form', 'lookup_entity' => false, 'entity_data' => false));
     /* groups */
     $group_list = array();
     $all_groups = $GLOBALS['phpgw']->accounts->get_list('groups');
     //FIXME!!
     /*
     if(!$GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin'))
     {
     	$available_apps = $GLOBALS['phpgw_info']['apps'];
     	$valid_groups = array();
     	foreach($available_apps as $_app => $dummy)
     	{
     		if($GLOBALS['phpgw']->acl->check('admin', phpgwapi_acl::ADD, $_app))
     		{
     			$valid_groups	= array_merge($valid_groups,$GLOBALS['phpgw']->acl->get_ids_for_location('run', phpgwapi_acl::READ, $_app));
     		}
     	}
     
     	$valid_groups = array_unique($valid_groups);
     }
     else
     {
     	$valid_groups = array_keys($all_groups);
     }
     */
     $valid_groups = array_keys($all_groups);
     $user['reg_info']['account_groups'] = isset($user['reg_info']['account_groups']) && $user['reg_info']['account_groups'] ? $user['reg_info']['account_groups'] : array();
     if ($this->config['default_group_id'] && !in_array($this->config['default_group_id'], $user['reg_info']['account_groups'])) {
         $user['reg_info']['account_groups'] = array_merge($user['reg_info']['account_groups'], array($this->config['default_group_id']));
     }
     foreach ($all_groups as $group) {
         $group_list[] = array('account_id' => $group->id, 'account_lid' => $group->__toString(), 'i_am_admin' => in_array($group->id, $valid_groups) ? 1 : 0, 'checked' => in_array($group->id, $user['reg_info']['account_groups']) ? 1 : 0);
     }
     /* create list of available apps */
     $available_apps = $GLOBALS['phpgw_info']['apps'];
     asort($available_apps);
     if (!$GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin')) {
         $valid_apps = $GLOBALS['phpgw']->acl->get_app_list_for_id('admin', phpgwapi_acl::ADD, $GLOBALS['phpgw_info']['user']['account_id']);
     } else {
         $valid_apps = array_keys($available_apps);
     }
     foreach ($available_apps as $key => $application) {
         if ($application['enabled'] && $application['status'] != 3) {
             $perm_display[] = array('app_name' => $key, 'translated_name' => lang($key));
         }
     }
     asort($perm_display);
     $app_list = array();
     foreach ($perm_display as $perm) {
         $app_list[] = array('app_title' => $perm['translated_name'], 'checkbox_name' => "account_permissions[{$perm['app_name']}]", 'checked' => in_array($perm['app_name'], $user['reg_info']['account_permissions']) ? 1 : 0, 'checkbox_name_admin' => "account_permissions_admin[{$perm['app_name']}]", 'checked_admin' => in_array($perm['app_name'], $user['reg_info']['account_permissions_admin']) ? 1 : 0, 'i_am_admin' => in_array($perm['app_name'], $valid_apps) ? 1 : 0);
     }
     //_debug_array($app_list);die();
     $tabs = array('main' => array('label' => lang('user'), 'link' => '#main'), 'groups' => array('label' => lang('groups'), 'link' => '#groups'), 'apps' => array('label' => lang('applications'), 'link' => '#apps'));
     $active_tab = 'main';
     phpgwapi_yui::tabview_setup('edit_user_tabview');
     $data = array('tabs' => phpgwapi_yui::tabview_generate($tabs, $active_tab), 'value_id' => $id, 'user_data' => $user_data, 'location_data' => $location_data, 'value_approved' => $user['reg_approved'], 'app_list' => $app_list, 'group_list' => $group_list);
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('registration') . '::' . lang('edit user');
     self::render_template_xsl('user_edit', $data);
 }
Exemple #6
0
<?php

include "common.php";
phpgwapi_yui::load_widget('tabview');
phpgwapi_yui::tabview_setup('composite_tabview');
$config = CreateObject('phpgwapi.config', 'rental');
$config->read();
echo rental_uicommon::get_page_error($error);
echo rental_uicommon::get_page_message($message);
?>

<div class="identifier-header">
<h1><img src="<?php 
echo RENTAL_TEMPLATE_PATH;
?>
images/32x32/actions/go-home.png" /> <?php 
echo lang('showing_composite');
?>
</h1>
	<div>
		<button onclick="javascript:window.location.href ='<?php 
echo $cancel_link;
?>
;'">&laquo;&nbsp;<?php 
echo lang('composite_back');
?>
</button><br/>
		<label><?php 
echo lang('name');
?>
 </label><?php 
    function edit($mode = 'edit')
    {
        $id = phpgw::get_var('id', 'int');
        $_lean = phpgw::get_var('lean', 'bool');
        if ($mode == 'edit' && (!$this->acl_add && !$this->acl_edit)) {
            $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uientity.view', 'id' => $id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type));
        }
        if ($mode == 'view') {
            if (!$this->acl_read) {
                $this->bocommon->no_access();
                return;
            }
        } else {
            if (!$this->acl_add && !$this->acl_edit) {
                $this->bocommon->no_access();
                return;
            }
        }
        //	$config		= CreateObject('phpgwapi.config','property');
        $bolocation = CreateObject('property.bolocation');
        $values = phpgw::get_var('values');
        $values_attribute = phpgw::get_var('values_attribute');
        $bypass = phpgw::get_var('bypass', 'bool');
        $lookup_tenant = phpgw::get_var('lookup_tenant', 'bool');
        $tenant_id = phpgw::get_var('tenant_id', 'int');
        $GLOBALS['phpgw']->xslttpl->add_file(array('entity', 'attributes_form', 'files'));
        $values['vendor_id'] = phpgw::get_var('vendor_id', 'int', 'POST');
        $values['vendor_name'] = phpgw::get_var('vendor_name', 'string', 'POST');
        $values['date'] = phpgw::get_var('date');
        $receipt = array();
        if ($_POST && !$bypass) {
            $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property');
            $insert_record_entity = $GLOBALS['phpgw']->session->appsession('insert_record_values' . $this->acl_location, $this->type_app[$this->type]);
            if (is_array($insert_record_entity)) {
                for ($j = 0; $j < count($insert_record_entity); $j++) {
                    $insert_record['extra'][$insert_record_entity[$j]] = $insert_record_entity[$j];
                }
            }
            $values = $this->bocommon->collect_locationdata($values, $insert_record);
        } elseif ($mode == 'edit') {
            $location_code = phpgw::get_var('location_code');
            $values['descr'] = phpgw::get_var('descr');
            $p_entity_id = phpgw::get_var('p_entity_id', 'int');
            $p_cat_id = phpgw::get_var('p_cat_id', 'int');
            if ($p_entity_id) {
                $values['p'][$p_entity_id]['p_entity_id'] = $p_entity_id;
                $values['p'][$p_entity_id]['p_cat_id'] = $p_cat_id;
                $values['p'][$p_entity_id]['p_num'] = phpgw::get_var('p_num');
            }
            $origin = phpgw::get_var('origin');
            $origin_id = phpgw::get_var('origin_id', 'int');
            if ($p_entity_id && $p_cat_id) {
                $entity_category = $this->soadmin_entity->read_single_category($p_entity_id, $p_cat_id);
                $values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
            }
            if ($location_code) {
                $values['location_data'] = $bolocation->read_single($location_code, array('tenant_id' => $tenant_id, 'p_num' => $p_num, 'view' => true));
            }
        }
        if (isset($values['origin']) && $values['origin']) {
            $origin = $values['origin'];
            $origin_id = $values['origin_id'];
        }
        $interlink = CreateObject('property.interlink');
        if (isset($origin) && $origin) {
            unset($values['origin']);
            unset($values['origin_id']);
            $values['origin'][0]['location'] = $origin;
            $values['origin'][0]['descr'] = $interlink->get_location_name($origin);
            $values['origin'][0]['data'][] = array('id' => $origin_id, 'link' => $interlink->get_relation_link(array('location' => $origin), $origin_id));
        }
        if (isset($tenant_id) && $tenant_id) {
            $lookup_tenant = true;
        }
        if ($this->cat_id) {
            $category = $this->soadmin_entity->read_single_category($this->entity_id, $this->cat_id);
        } else {
            $cat_list = $this->bo->select_category_list('select', '', PHPGW_ACL_ADD);
        }
        if (isset($values['cancel']) && $values['cancel']) {
            $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uientity.index', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type));
        }
        if (isset($values['save']) && $values['save'] || isset($values['apply']) && $values['apply']) {
            if ($category['org_unit']) {
                $values['extra']['org_unit_id'] = phpgw::get_var('org_unit_id', 'int');
            }
            if ($GLOBALS['phpgw']->session->is_repost()) {
                $receipt['error'][] = array('msg' => lang('Hmm... looks like a repost!'));
            }
            if (!$values['location'] && isset($category['location_level']) && $category['location_level']) {
                $receipt['error'][] = array('msg' => lang('Please select a location !'));
                $error_id = true;
            }
            if (!$this->cat_id) {
                $receipt['error'][] = array('msg' => lang('Please select entity type !'));
                $error_id = true;
            }
            if (isset($values_attribute) && is_array($values_attribute)) {
                foreach ($values_attribute as $attribute) {
                    if ($attribute['nullable'] != 1 && (!$attribute['value'] && !$values['extra'][$attribute['name']])) {
                        $receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text']));
                    }
                    if (isset($attribute['value']) && $attribute['value'] && $attribute['datatype'] == 'I' && !ctype_digit($attribute['value'])) {
                        $receipt['error'][] = array('msg' => lang('Please enter integer for attribute %1', $attribute['input_text']));
                    }
                }
            }
            if (isset($id) && $id) {
                $values['id'] = $id;
                $action = 'edit';
            }
            if (!isset($receipt['error'])) {
                $receipt = $this->bo->save($values, $values_attribute, $action, $this->entity_id, $this->cat_id);
                $id = $receipt['id'];
                $function_msg = lang('edit entity');
                //--------------files
                $loc1 = isset($values['location']['loc1']) && $values['location']['loc1'] ? $values['location']['loc1'] : 'dummy';
                if ($this->type_app[$this->type] == 'catch') {
                    $loc1 = 'dummy';
                }
                $bofiles = CreateObject('property.bofiles');
                if (isset($values['file_action']) && is_array($values['file_action'])) {
                    $bofiles->delete_file("/{$this->category_dir}/{$loc1}/{$id}/", $values);
                }
                if (isset($values['file_jasperaction']) && is_array($values['file_jasperaction'])) {
                    $values['file_action'] = $values['file_jasperaction'];
                    $bofiles->delete_file("/{$this->category_dir}/{$loc1}/{$id}/", $values);
                }
                $files = array();
                if (isset($_FILES['file']['name']) && $_FILES['file']['name']) {
                    $file_name = str_replace(' ', '_', $_FILES['file']['name']);
                    $to_file = "{$bofiles->fakebase}/{$this->category_dir}/{$loc1}/{$id}/{$file_name}";
                    if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
                        $receipt['error'][] = array('msg' => lang('This file already exists !'));
                    } else {
                        $files[] = array('from_file' => $_FILES['file']['tmp_name'], 'to_file' => $to_file);
                    }
                    unset($to_file);
                    unset($file_name);
                }
                if (isset($_FILES['jasperfile']['name']) && $_FILES['jasperfile']['name']) {
                    $file_name = 'jasper::' . str_replace(' ', '_', $_FILES['jasperfile']['name']);
                    $to_file = "{$bofiles->fakebase}/{$this->category_dir}/{$loc1}/{$id}/{$file_name}";
                    if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
                        $receipt['error'][] = array('msg' => lang('This file already exists !'));
                    } else {
                        $files[] = array('from_file' => $_FILES['jasperfile']['tmp_name'], 'to_file' => $to_file);
                    }
                    unset($to_file);
                    unset($file_name);
                }
                foreach ($files as $file) {
                    $bofiles->create_document_dir("{$this->category_dir}/{$loc1}/{$id}");
                    $bofiles->vfs->override_acl = 1;
                    if (!$bofiles->vfs->cp(array('from' => $file['from_file'], 'to' => $file['to_file'], 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL)))) {
                        $receipt['error'][] = array('msg' => lang('Failed to upload file !'));
                    }
                    $bofiles->vfs->override_acl = 0;
                }
                unset($loc1);
                unset($files);
                unset($file);
                //-------------end files
                if (isset($values['save']) && $values['save']) {
                    $GLOBALS['phpgw']->session->appsession('session_data', 'entity_receipt_' . $this->entity_id . '_' . $this->cat_id, $receipt);
                    $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uientity.index', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type));
                }
            } else {
                if ($values['location']) {
                    $location_code = implode("-", $values['location']);
                    $values['extra']['view'] = true;
                    $values['location_data'] = $bolocation->read_single($location_code, $values['extra']);
                }
                if ($values['extra']['p_num']) {
                    $values['p'][$values['extra']['p_entity_id']]['p_num'] = $values['extra']['p_num'];
                    $values['p'][$values['extra']['p_entity_id']]['p_entity_id'] = $values['extra']['p_entity_id'];
                    $values['p'][$values['extra']['p_entity_id']]['p_cat_id'] = $values['extra']['p_cat_id'];
                    $values['p'][$values['extra']['p_entity_id']]['p_cat_name'] = phpgw::get_var('entity_cat_name_' . $values['extra']['p_entity_id']);
                }
            }
        }
        if ($id) {
            $values = $this->bo->read_single(array('entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'id' => $id));
        } else {
            if ($this->cat_id) {
                $values = $this->bo->read_single(array('entity_id' => $this->entity_id, 'cat_id' => $this->cat_id), $values);
            }
        }
        /* 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);
        }
        $lookup_type = $mode == 'edit' ? 'form' : 'view';
        $entity = $this->soadmin_entity->read_single($this->entity_id);
        if ($id) {
            $function_msg = lang('edit') . ' ' . $category['name'];
        } else {
            $function_msg = lang('add') . ' ' . $category['name'];
        }
        if (isset($values['cat_id']) && $values['cat_id']) {
            $this->cat_id = $values['cat_id'];
        }
        $lookup_entity = array();
        if (isset($entity['lookup_entity']) && is_array($entity['lookup_entity'])) {
            foreach ($entity['lookup_entity'] as $lookup_id) {
                $entity_lookup = $this->soadmin_entity->read_single($lookup_id);
                $lookup_entity[] = array('id' => $lookup_id, 'name' => $entity_lookup['name']);
            }
        }
        if (isset($category['lookup_tenant']) && $category['lookup_tenant']) {
            $lookup_tenant = true;
        }
        if ($location_code) {
            $category['location_level'] = count(explode('-', $location_code));
        }
        if ($this->cat_id && (!isset($category['location_level']) || !$category['location_level'])) {
            $category['location_level'] = -1;
        }
        $_no_link = false;
        if ($lookup_entity && $category['location_link_level']) {
            $_no_link = (int) $category['location_link_level'] + 2;
        }
        $location_data = array();
        if ($entity['location_form'] && $category['location_level'] > 0) {
            $location_data = $bolocation->initiate_ui_location(array('values' => $values['location_data'], 'type_id' => (int) $category['location_level'], 'no_link' => $_no_link, 'lookup_type' => $lookup_type, 'tenant' => $lookup_tenant, 'lookup_entity' => $lookup_entity, 'entity_data' => isset($values['p']) ? $values['p'] : ''));
        }
        if (isset($error_id) && $error_id) {
            unset($values['id']);
            unset($id);
        }
        $link_data = array('menuaction' => "property.uientity.{$mode}", 'id' => $id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type, 'lean' => $_lean, 'noframework' => isset($GLOBALS['phpgw_info']['flags']['noframework']) ? $GLOBALS['phpgw_info']['flags']['noframework'] : false);
        $msgbox_data = $this->bocommon->msgbox_data($receipt);
        //		$config->read();
        //		$link_to_files = $config->config_data['files_url'];
        if (isset($values['files']) && is_array($values['files'])) {
            $j = count($values['files']);
            for ($i = 0; $i < $j; $i++) {
                $values['files'][$i]['file_name'] = urlencode($values['files'][$i]['name']);
            }
        }
        $project_link_data = array('menuaction' => 'property.uiproject.edit', 'bypass' => true, 'location_code' => $values['location_code'], 'p_num' => $id, 'p_entity_id' => $this->entity_id, 'p_cat_id' => $this->cat_id, 'tenant_id' => $values['tenant_id'], 'origin' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'origin_id' => $id);
        $add_to_project_link_data = array('menuaction' => 'property.uiproject.index', 'from' => 'workorder', 'lookup' => true, 'query' => isset($values['location_data']['loc1']) ? $values['location_data']['loc1'] : '', 'tenant_id' => $values['tenant_id'], 'origin' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'origin_id' => $id);
        $ticket_link_data = array('menuaction' => 'property.uitts.add', 'bypass' => true, 'location_code' => $values['location_code'], 'p_num' => $id, 'p_entity_id' => $this->entity_id, 'p_cat_id' => $this->cat_id, 'tenant_id' => $values['tenant_id'], 'origin' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'origin_id' => $id);
        //_debug_array($values['origin']);
        //			$GLOBALS['phpgw']->js->validate_file('overlib','overlib','property');
        $pdf_data = array('menuaction' => 'property.uientity.print_pdf', 'id' => $id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type);
        $tabs = array();
        if (isset($values['attributes']) && is_array($values['attributes'])) {
            foreach ($values['attributes'] as &$attribute) {
                if ($attribute['history'] == true) {
                    $link_history_data = array('menuaction' => 'property.uientity.attrib_history', 'acl_location' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'attrib_id' => $attribute['id'], 'id' => $id, 'edit' => true, 'type' => $this->type);
                    $attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php', $link_history_data);
                }
                /*
                 * Hide dummy attributes that act as placeholders
                 */
                if ($attribute['datatype'] == 'R' && isset($attribute['choice']) && !$attribute['choice']) {
                    $attribute['hide_row'] = true;
                }
            }
            phpgwapi_yui::tabview_setup('entity_edit_tabview');
            $active_tab = phpgw::get_var('active_tab');
            if ($category['location_level'] > 0) {
                $tabs['location'] = array('label' => lang('location'), 'link' => '#location', 'function' => "set_tab('location')");
                $active_tab = $active_tab ? $active_tab : 'location';
            }
            $_enable_controller = !!$category['enable_controller'] || !!$values['entity_group_id'];
            if ($_enable_controller) {
                $tabs['controller'] = array('label' => lang('controller'), 'link' => '#controller', 'function' => "set_tab('controller')");
                $active_tab = $active_tab ? $active_tab : 'location';
                $GLOBALS['phpgw']->jqcal->add_listener('control_start_date');
            }
            $location = ".{$this->type}.{$this->entity_id}.{$this->cat_id}";
            $attributes_groups = $this->bo->get_attribute_groups($location, $values['attributes']);
            $attributes_general = array();
            $i = -1;
            $attributes = array();
            foreach ($attributes_groups as $_key => $group) {
                if (isset($group['attributes']) && (isset($group['group_sort']) || !$location_data)) {
                    if ($group['level'] == 0) {
                        $_tab_name = str_replace(' ', '_', $group['name']);
                        $active_tab = $active_tab ? $active_tab : $_tab_name;
                        $tabs[$_tab_name] = array('label' => $group['name'], 'link' => "#{$_tab_name}", 'function' => "set_tab('{$_tab_name}')");
                        $group['link'] = $_tab_name;
                        $attributes[] = $group;
                        $i++;
                    } else {
                        $attributes[$i]['attributes'][] = array('datatype' => 'section', 'descr' => '<H' . ($group['level'] + 1) . "> {$group['descr']} </H" . ($group['level'] + 1) . '>', 'level' => $group['level']);
                        $attributes[$i]['attributes'] = array_merge($attributes[$i]['attributes'], $group['attributes']);
                    }
                    unset($_tab_name);
                } else {
                    if (isset($group['attributes']) && !isset($group['group_sort']) && $location_data) {
                        $attributes_general = array_merge($attributes_general, $group['attributes']);
                    }
                }
            }
            unset($attributes_groups);
            if ($category['fileupload'] || isset($values['files']) && $values['files']) {
                $tabs['files'] = array('label' => lang('files'), 'link' => '#files', 'function' => "set_tab('files')");
            }
            /*
            				if($category['jasperupload'])
            				{
            					$tabs['jasper']	= array('label' => lang('jasper reports'), 'link' => '#jasper');
            				}
            */
        }
        // ---- START INTEGRATION -------------------------
        $custom_config = CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], $this->acl_location));
        $_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
        */
        $integration = array();
        foreach ($_config as $_config_section => $_config_section_data) {
            if (isset($_config_section_data['tab']) && $values['id']) {
                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));
                $integration[] = array('section' => $_config_section, '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']);
                parse_str($_config_section_data['parametres'], $output);
                foreach ($output as $_dummy => $_substitute) {
                    /**
                    * Alternative
                    
                    $regex = "/__([\w]+)__/";
                    preg_match_all($regex, $_substitute, $matches);
                    foreach($matches[1] as $__substitute)
                    {
                    	$_values[] = urlencode($values[$__substitute]);									
                    }
                    */
                    $_keys[] = $_substitute;
                    $__value = false;
                    if (!($__value = urlencode($values[str_replace(array('__', '*'), array('', ''), $_substitute)]))) {
                        foreach ($values['attributes'] as $_attribute) {
                            if (str_replace(array('__', '*'), array('', ''), $_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 = 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']}{$_sep}{$_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);
                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) {
                        $_keys[] = $_substitute;
                        $_values[] = urlencode($values['location_data'][trim($_substitute, '_')]);
                    }
                    $integration_src .= '&' . str_replace($_keys, $_values, $_config_section_data['location_data']);
                }
                $integration_src .= "&{$_config_section_data['auth_key_name']}={$response}";
                //_debug_array($values);
                //_debug_array($integration_src);die();
                $tabs[$_config_section] = array('label' => $_config_section_data['tab'], 'link' => "#{$_config_section}", 'function' => "document.getElementById('{$_config_section}_content').src = '{$integration_src}';");
            }
        }
        // ---- END INTEGRATION -------------------------
        unset($values['attributes']);
        $link_file_data = array('menuaction' => 'property.uientity.view_file', 'loc1' => $values['location_data']['loc1'], 'id' => $id, 'cat_id' => $this->cat_id, 'entity_id' => $this->entity_id, 'type' => $this->type);
        $content_files = array();
        for ($z = 0; $z < count($values['files']); $z++) {
            $content_files[$z]['file_name'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $link_file_data) . '&amp;file_name=' . urlencode($values['files'][$z]['name']) . '" target="_blank" title="' . lang('click to view file') . '">' . $values['files'][$z]['name'] . '</a>';
            if ($mode == 'edit') {
                $content_files[$z]['delete_file'] = '<input type="checkbox" name="values[file_action][]" value="' . $values['files'][$z]['name'] . '" title="' . lang('Check to delete file') . '">';
            } else {
                $content_files[$z]['delete_file'] = '';
            }
        }
        $datavalues[0] = array('name' => "0", 'values' => json_encode($content_files), 'total_records' => count($content_files), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 0);
        $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'file_name', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'delete_file', 'label' => lang('Delete file'), 'sortable' => false, 'resizeable' => true))));
        //_Debug_Array($datavalues);
        //die();
        /*
        			$link_file_data['jasper']		= true;
        			$content_jasperfiles = array();
        			for($z=0; $z<count($values['jasperfiles']); $z++)
        			{
        				$link_file_data['file_name']	= $values['jasperfiles'][$z]['name'];
        				$content_jasperfiles[$z]['file_name'] = '<a href="'.$GLOBALS['phpgw']->link('/index.php',$link_file_data).'" target="_blank" title="'.lang('click to view file').'">'.$values['jasperfiles'][$z]['name'].'</a>';			
        				$content_jasperfiles[$z]['delete_file'] = '<input type="checkbox" name="values[file_jasperaction][]" value="'.$values['jasperfiles'][$z]['name'].'" title="'.lang('Check to delete file').'">';
        			}									
        
        			$datavalues[1] = array
        			(
        					'name'					=> "1",
        					'values' 				=> json_encode($content_jasperfiles),
        					'total_records'			=> count($content_jasperfiles),
        					'edit_action'			=> "''",
        					'is_paginator'			=> 0,
        					'footer'				=> 0
        			);
        
        			$myColumnDefs[1] = array
        			(
        				'name'		=> "1",
        				'values'	=>	json_encode(array(	array('key' => 'file_name','label'=>lang('Filename'),'sortable'=>false,'resizeable'=>true),
        													array('key' => 'delete_file','label'=>lang('Delete file'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
        			);
        */
        if ($id) {
            $get_docs = false;
            $check_doc = $this->bocommon->get_lookup_entity('document');
            foreach ($check_doc as $_check) {
                if ($_check['id'] == $this->entity_id) {
                    $get_docs = true;
                    break;
                }
            }
            if ($get_docs) {
                $document = CreateObject('property.sodocument');
                $documents = $document->get_files_at_location(array('entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'num' => $values['num']));
                if ($documents) {
                    $tabs['document'] = array('label' => lang('document'), 'link' => '#document', 'function' => "set_tab('document')");
                    $documents = json_encode($documents);
                }
            }
            if (!$category['enable_bulk']) {
                $tabs['related'] = array('label' => lang('log'), 'link' => '#related', 'function' => "set_tab('related')");
            }
            $_target = array();
            if (isset($values['target']) && $values['target']) {
                foreach ($values['target'] as $_target_section) {
                    foreach ($_target_section['data'] as $_target_entry) {
                        $_target[] = array('url' => "<a href=\"{$_target_entry['link']}\" > {$_target_entry['id']}</a>", 'type' => $_target_section['descr'], 'title' => $_target_entry['title'], 'status' => $_target_entry['statustext'], 'user' => $GLOBALS['phpgw']->accounts->get($_target_entry['account_id'])->__toString(), 'entry_date' => $GLOBALS['phpgw']->common->show_date($_target_entry['entry_date'], $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']));
                    }
                }
            }
            $related = $this->bo->read_entity_to_link(array('entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'id' => $id));
            $_related = array();
            if (isset($related['related'])) {
                foreach ($related as $related_key => $related_data) {
                    foreach ($related_data as $entry) {
                        $_related[] = array('url' => "<a href=\"{$entry['entity_link']}\" > {$entry['name']}</a>");
                    }
                }
            }
            $datavalues[1] = array('name' => "1", 'values' => json_encode($_target), 'total_records' => count($_target), 'edit_action' => "''", 'is_paginator' => 1, 'footer' => 0);
            $myColumnDefs[1] = array('name' => "1", 'values' => json_encode(array(array('key' => 'url', 'label' => lang('id'), 'sortable' => false, 'resizeable' => true), array('key' => 'type', 'label' => lang('type'), 'sortable' => true, 'resizeable' => true), array('key' => 'title', 'label' => lang('title'), 'sortable' => false, 'resizeable' => true), array('key' => 'status', 'label' => lang('status'), 'sortable' => false, 'resizeable' => true), array('key' => 'user', 'label' => lang('user'), 'sortable' => true, 'resizeable' => true), array('key' => 'entry_date', 'label' => lang('entry date'), 'sortable' => false, 'resizeable' => true))));
            $datavalues[2] = array('name' => "2", 'values' => json_encode($_related), 'total_records' => count($_related), 'edit_action' => "''", 'is_paginator' => 1, 'footer' => 0);
            $myColumnDefs[2] = array('name' => "2", 'values' => json_encode(array(array('key' => 'url', 'label' => lang('where'), 'sortable' => false, 'resizeable' => true))));
            if ($category['enable_bulk']) {
                $tabs['inventory'] = array('label' => lang('inventory'), 'link' => '#inventory', 'function' => "set_tab('inventory')");
            }
            $_inventory = $this->get_inventory($id);
            $datavalues[3] = array('name' => "3", 'values' => json_encode($_inventory), 'total_records' => count($_inventory), 'edit_action' => "''", 'is_paginator' => 1, 'footer' => 1);
            $myColumnDefs[3] = array('name' => "3", 'values' => json_encode(array(array('key' => 'where', 'label' => lang('where'), 'sortable' => false, 'resizeable' => true), array('key' => 'edit', 'label' => lang('edit'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterEdit'), array('key' => 'unit', 'label' => lang('unit'), 'sortable' => false, 'resizeable' => true), array('key' => 'inventory', 'label' => lang('count'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'allocated', 'label' => lang('allocated'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'bookable', 'label' => lang('bookable'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter'), array('key' => 'calendar', 'label' => lang('calendar'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCalendar'), array('key' => 'remark', 'label' => lang('remark'), 'sortable' => false, 'resizeable' => true), array('key' => 'location_id', 'hidden' => true), array('key' => 'id', 'hidden' => true), array('key' => 'inventory_id', 'hidden' => true))));
        }
        if (isset($GLOBALS['phpgw_info']['user']['apps']['controller'])) {
            $myButtons[4] = array('name' => "4", 'values' => json_encode(array(array('id' => 'add_serie', 'type' => 'buttons', 'value' => 'add', 'label' => lang('add'), 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""), array('id' => 'enable_serie', 'type' => 'buttons', 'value' => 'enable', 'label' => lang('enable'), 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""), array('id' => 'disable_serie', 'type' => 'buttons', 'value' => 'disable', 'label' => lang('disable'), 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""), array('id' => 'edit_serie', 'type' => 'buttons', 'value' => 'edit', 'label' => lang('edit'), 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""))));
            $location_id = $GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
            $_controls = $this->get_controls_at_component($location_id, $id);
            $datavalues[4] = array('name' => "4", 'values' => json_encode($_controls), 'total_records' => count($_controls), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 1);
            $myColumnDefs[4] = array('name' => "4", 'values' => json_encode(array(array('key' => 'serie_id', 'label' => 'serie', 'sortable' => false, 'resizeable' => true), array('key' => 'control_id', 'label' => lang('controller'), 'sortable' => false, 'resizeable' => true), array('key' => 'title', 'label' => lang('title'), 'sortable' => false, 'resizeable' => true), array('key' => 'assigned_to_name', 'label' => lang('user'), 'sortable' => false, 'resizeable' => true), array('key' => 'start_date', 'label' => lang('start date'), 'sortable' => false, 'resizeable' => true), array('key' => 'repeat_type', 'label' => lang('repeat type'), 'sortable' => false, 'resizeable' => true), array('key' => 'repeat_interval', 'label' => lang('interval'), 'sortable' => false, 'resizeable' => true), array('key' => 'controle_time', 'label' => lang('controle time'), 'sortable' => false, 'resizeable' => true), array('key' => 'service_time', 'label' => lang('service time'), 'sortable' => false, 'resizeable' => true), array('key' => 'total_time', 'label' => lang('total time'), 'sortable' => false, 'resizeable' => true), array('key' => 'serie_enabled', 'label' => lang('enabled'), 'sortable' => false, 'resizeable' => true), array('key' => 'select', 'label' => lang('select'), 'sortable' => false, 'resizeable' => true), array('key' => 'location_id', 'hidden' => true), array('key' => 'component_id', 'hidden' => true), array('key' => 'id', 'hidden' => true), array('key' => 'assigned_to', 'hidden' => true))));
            //				$lang_controller = $GLOBALS['phpgw']->translation->translate('controller', array(),false , 'controller');
            $_cases = $this->get_cases($location_id, $id, date('Y'));
            $cases_time_span = $this->cases_time_span;
            $datavalues[5] = array('name' => "5", 'values' => json_encode($_cases), 'total_records' => count($_cases), 'edit_action' => "''", 'rows_per_page' => 10, 'is_paginator' => 1, 'footer' => 0);
            $myColumnDefs[5] = array('name' => "5", 'values' => json_encode(array(array('key' => 'url', 'label' => lang('id'), 'sortable' => false, 'resizeable' => true), array('key' => 'type', 'label' => lang('type'), 'sortable' => true, 'resizeable' => true), array('key' => 'title', 'label' => lang('title'), 'sortable' => false, 'resizeable' => true), array('key' => 'value', 'label' => lang('value'), 'sortable' => false, 'resizeable' => true), array('key' => 'status', 'label' => lang('status'), 'sortable' => false, 'resizeable' => true), array('key' => 'user', 'label' => lang('user'), 'sortable' => true, 'resizeable' => true), array('key' => 'entry_date', 'label' => lang('entry date'), 'sortable' => false, 'resizeable' => true))));
        }
        $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, '/'));
        }
        if ($category['org_unit'] && $mode == 'edit') {
            $_autocomplete = <<<JS

\t\t\t\t\tYAHOO.util.Event.addListener(window, "load", function()
\t\t\t\t\t{
\t\t\t\t\t\tvar oArgs = {menuaction:'property.bogeneric.get_autocomplete', type:'org_unit'};
\t\t\t\t\t\tvar strURL = phpGWLink('index.php', oArgs, true);

\t\t\t\t\t    YAHOO.portico.autocompleteHelper(strURL,
                               'org_unit_name', 'org_unit_id', 'org_unit_container');

\t\t\t\t\t});
JS;
            $GLOBALS['phpgw']->js->add_code('', $_autocomplete);
        }
        $repeat_types = array();
        //		$repeat_types[] = array('id'=> -1, 'name' => lang('day'));
        //		$repeat_types[] = array('id'=> 1, 'name' => lang('weekly'));
        $repeat_types[] = array('id' => 2, 'name' => lang('month'));
        $repeat_types[] = array('id' => 3, 'name' => lang('year'));
        $entity_group_name = '';
        $entity_group_list = execMethod('property.bogeneric.get_list', array('type' => 'entity_group', 'selected' => $values['entity_group_id'], 'add_empty' => true));
        foreach ($entity_group_list as $entity_group) {
            if ($category['entity_group_id'] && $entity_group['id'] == $category['entity_group_id']) {
                $entity_group_name = $entity_group['name'];
            }
        }
        $data = array('repeat_types' => array('options' => $repeat_types), 'controller' => $_enable_controller, 'cases_time_span' => array('options' => $cases_time_span), 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'enable_bulk' => $category['enable_bulk'], 'org_unit' => $category['org_unit'], 'value_org_unit_id' => $values['org_unit_id'], 'value_org_unit_name' => $values['org_unit_name'], 'value_org_unit_name_path' => $values['org_unit_name_path'], 'value_location_id' => $GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], $this->acl_location), 'link_pdf' => $GLOBALS['phpgw']->link('/index.php', $pdf_data), 'start_project' => $category['start_project'], 'lang_start_project' => lang('start project'), 'project_link' => $GLOBALS['phpgw']->link('/index.php', $project_link_data), 'add_to_project_link' => $GLOBALS['phpgw']->link('/index.php', $add_to_project_link_data), 'start_ticket' => $category['start_ticket'], 'lang_start_ticket' => lang('start ticket'), 'ticket_link' => $GLOBALS['phpgw']->link('/index.php', $ticket_link_data), 'fileupload' => $category['fileupload'], 'link_view_file' => $GLOBALS['phpgw']->link('/index.php', $link_file_data), 'files' => isset($values['files']) ? $values['files'] : '', 'multiple_uploader' => $id ? true : '', 'fileuploader_action' => "{menuaction:'property.fileuploader.add'," . "upload_target:'property.uientity.addfiles'," . "id:'{$id}'," . "_entity_id:'{$this->entity_id}'," . "_cat_id:'{$this->cat_id}'," . "_type:'{$this->type}'}", 'value_origin' => isset($values['origin']) ? $values['origin'] : '', 'value_origin_type' => isset($origin) ? $origin : '', 'value_origin_id' => isset($origin_id) ? $origin_id : '', 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the category. To do not use a category select NO CATEGORY'), 'select_name' => 'cat_id', 'cat_list' => isset($cat_list) ? $cat_list : '', 'location_code' => isset($location_code) ? $location_code : '', 'lookup_tenant' => $lookup_tenant, 'lang_entity' => lang('entity'), 'entity_name' => $entity['name'], 'lang_category' => lang('category'), 'category_name' => $category['name'], 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'attributes_group' => $attributes, 'attributes_general' => array('attributes' => $attributes_general), 'lookup_functions' => isset($values['lookup_functions']) ? $values['lookup_functions'] : '', 'lang_none' => lang('None'), 'location_data' => $location_data, 'lookup_type' => $lookup_type, 'mode' => $mode, 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uientity.index', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'type' => $this->type)), 'lang_id' => lang('ID'), 'value_id' => $values['id'], 'value_num' => $values['num'], 'error_flag' => isset($error_id) ? $error_id : '', 'lang_history' => lang('history'), 'lang_history_help' => lang('history of this attribute'), 'lang_history_date_statustext' => lang('Enter the date for this reading'), 'lang_date' => lang('date'), '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, $active_tab), 'active_tab' => $active_tab, 'integration' => $integration, 'base_java_url' => "{menuaction:'property.uientity.get_files'," . "id:'{$id}'," . "entity_id:'{$this->entity_id}'," . "cat_id:'{$this->cat_id}'," . "type:'{$this->type}'}", 'documents' => $documents, 'lean' => $_lean ? 1 : 0, 'entity_group_list' => array('options' => $entity_group_list), 'entity_group_name' => $entity_group_name);
        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('calendar');
        phpgwapi_yui::load_widget('autocomplete');
        $GLOBALS['phpgw']->js->validate_file('yahoo', 'common', 'phpgwapi');
        $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/examples/treeview/assets/css/folders/tree.css');
        phpgwapi_yui::load_widget('treeview');
        $appname = $entity['name'];
        $GLOBALS['phpgw_info']['flags']['app_header'] = lang($this->type_app[$this->type]) . ' - ' . $appname . ': ' . $function_msg;
        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
        $GLOBALS['phpgw']->css->validate_file('datatable');
        $GLOBALS['phpgw']->css->validate_file('property');
        $GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
        $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', 'entity.edit', 'property');
        $GLOBALS['phpgw']->js->validate_file('tinybox2', 'packed', 'phpgwapi');
        $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
        phpgw::import_class('phpgwapi.jquery');
        phpgwapi_jquery::load_widget('core');
        $criteria = array('appname' => $this->type_app[$this->type], 'location' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'allrows' => true);
        $custom_functions = $GLOBALS['phpgw']->custom_functions->find($criteria);
        foreach ($custom_functions as $entry) {
            // prevent path traversal
            if (preg_match('/\\.\\./', $entry['file_name'])) {
                continue;
            }
            $file = PHPGW_SERVER_ROOT . "/{$this->type_app[$this->type]}/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
            if ($entry['active'] && $entry['client_side'] && is_file($file)) {
                $GLOBALS['phpgw']->js->add_external_file("{$this->type_app[$this->type]}/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}");
            }
        }
    }
 public function reporting()
 {
     $acl_location = '.demo_location';
     if (!$this->acl_read) {
         $this->bocommon->no_access();
         return;
     }
     $type = phpgw::get_var('type', 'string', 'GET', 'deposition');
     $GLOBALS['phpgw_info']['flags']['menu_selection'] .= "::{$type}";
     $values = phpgw::get_var('values');
     $receipt = array();
     if ($values) {
         //		_debug_array($values);die();
         if (isset($values['export_reconciliation']) && $values['export_reconciliation']) {
             if (!isset($values['periods'])) {
                 $type = 'reconciliation';
                 $receipt['error'][] = array('msg' => lang('missing values'));
             } else {
                 $this->bo->export_historical_transactions_at_periods($values['periods']);
             }
         } else {
             if (isset($values['export_deposition']) && $values['export_deposition']) {
                 if (!isset($values['deposition'])) {
                     $type = 'deposition';
                     $receipt['error'][] = array('msg' => lang('nothing to do'));
                 } else {
                     $this->bo->export_deposition();
                 }
             }
         }
     }
     $tab_info = array('deposition' => array('label' => lang('deposition'), 'link' => '#deposition'), 'reconciliation' => array('label' => lang('reconciliation'), 'link' => '#reconciliation'));
     phpgwapi_yui::tabview_setup('reporting_tabview');
     $msgbox_data = isset($receipt) ? $GLOBALS['phpgw']->common->msgbox_data($receipt) : '';
     $data = array('msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.reporting')), 'accounting_periods' => array('options' => $this->bo->get_historical_accounting_periods()), 'tabs' => phpgwapi_yui::tabview_generate($tab_info, $type));
     $function_msg = lang('reporting');
     $appname = lang('invoice');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
     $GLOBALS['phpgw']->xslttpl->add_file(array('invoice_reporting', 'attributes_form'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('reporting' => $data));
 }
 protected function _generate_tabs()
 {
     $tabs = array('general' => array('label' => lang('general'), 'link' => '#general'), 'list' => array('label' => lang('list'), 'link' => '#list'), 'tables' => array('label' => lang('inline tables'), 'link' => '#tables'), 'dates' => array('label' => lang('dates'), 'link' => '#dates'), 'custom' => array('label' => lang('custom attributes'), 'link' => '#custom'));
     phpgwapi_yui::tabview_setup('demo_tabview');
     return phpgwapi_yui::tabview_generate($tabs, 'general');
 }
 function edit()
 {
     if (!$this->acl_add) {
         $this->bocommon->no_access();
         return;
     }
     $id = phpgw::get_var($this->location_info['id']['name']);
     $values = phpgw::get_var('values');
     $values_attribute = phpgw::get_var('values_attribute');
     $GLOBALS['phpgw_info']['apps']['manual']['section'] = 'general.edit.' . $this->type;
     $GLOBALS['phpgw']->xslttpl->add_file(array('generic', 'attributes_form'));
     $receipt = array();
     if (is_array($values)) {
         $insert_record_attributes = $GLOBALS['phpgw']->session->appsession("insert_record_values{$this->acl_location}", $this->location_info['acl_app']);
         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');
                     }
                 }
             }
         }
         //				$values = $this->bocommon->collect_locationdata($values,$insert_record_values);
         if (isset($values['save']) && $values['save'] || isset($values['apply']) && $values['apply']) {
             if ($GLOBALS['phpgw']->session->is_repost()) {
                 $receipt['error'][] = array('msg' => lang('Hmm... looks like a repost!'));
             }
             if (!$id && !$values[$this->location_info['id']['name']] && $this->location_info['id']['type'] != 'auto') {
                 $receipt['error'][] = array('msg' => lang('missing value for %1', lang('id')));
             }
             foreach ($this->location_info['fields'] as $field_info) {
                 if (isset($field_info['nullable']) && $field_info['nullable'] != true) {
                     if (!$values[$field_info['name']]) {
                         $receipt['error'][] = array('msg' => lang('missing value for %1', $field_info['descr']));
                     }
                 }
                 if ($field_info['type'] == 'int') {
                     if ($values[$field_info['name']] && !ctype_digit($values[$field_info['name']])) {
                         $receipt['error'][] = array('msg' => "{$field_info['descr']}: " . lang('Please enter an integer !'));
                     }
                 } else {
                     if ($field_info['type'] == 'numeric') {
                         $values[$field_info['name']] = str_replace(',', '.', $values[$field_info['name']]);
                         if ($values[$field_info['name']] && !is_numeric($values[$field_info['name']])) {
                             $receipt['error'][] = array('msg' => "{$field_info['descr']}: " . lang('Please enter a numeric value !'));
                         }
                     }
                 }
             }
             if ($values['id'] && $this->location_info['id']['type'] == 'int' && !ctype_digit($values['id'])) {
                 $receipt['error'][] = array('msg' => lang('Please enter an integer !'));
                 unset($values['id']);
             }
             if (isset($values_attribute) && is_array($values_attribute)) {
                 foreach ($values_attribute as $attribute) {
                     if ($attribute['nullable'] != 1 && (!$attribute['value'] && !$values['extra'][$attribute['name']])) {
                         $receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text']));
                     }
                     if (isset($attribute['value']) && $attribute['value'] && $attribute['datatype'] == 'I' && !ctype_digit($attribute['value'])) {
                         $receipt['error'][] = array('msg' => lang('Please enter integer for attribute %1', $attribute['input_text']));
                     }
                 }
             }
             if ($id) {
                 $values['id'] = $id;
                 $action = 'edit';
             } else {
                 $id = $values['id'];
             }
             if (!$receipt['error']) {
                 $receipt = $this->bo->save($values, $action, $values_attribute);
                 if (isset($values['save']) && $values['save']) {
                     $GLOBALS['phpgw']->session->appsession('session_data', "general_receipt_{$this->type}_{$this->type_id}", $receipt);
                     $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uigeneric.index', 'appname' => $this->appname, 'type' => $this->type, 'type_id' => $this->type_id));
                 }
                 $id = $receipt['id'];
             }
         } else {
             $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uigeneric.index', 'appname' => $this->appname, 'type' => $this->type, 'type_id' => $this->type_id));
         }
     }
     if ($id) {
         $values = $this->bo->read_single(array('id' => $id));
         $function_msg = $this->location_info['edit_msg'];
         $action = 'edit';
     } else {
         $values = $this->bo->read_single();
         $function_msg = $this->location_info['add_msg'];
         $action = 'add';
     }
     /* Preserve attribute values from post */
     if (isset($receipt['error'])) {
         foreach ($this->location_info['fields'] as $field) {
             $values[$field['name']] = phpgw::clean_value($_POST['values'][$field['name']]);
         }
         if (isset($values_attribute) && is_array($values_attribute)) {
             $values = $this->custom->preserve_attribute_values($values, $values_attribute);
         }
     }
     $link_data = array('menuaction' => 'property.uigeneric.edit', 'id' => $id, 'appname' => $this->appname, 'type' => $this->type, 'type_id' => $this->type_id);
     $tabs = array();
     if (isset($values['attributes']) && is_array($values['attributes'])) {
         foreach ($values['attributes'] as &$attribute) {
             if ($attribute['history'] == true) {
                 $link_history_data = array('menuaction' => 'property.uigeneric.attrib_history', 'appname' => $this->appname, 'attrib_id' => $attribute['id'], 'actor_id' => $actor_id, 'role' => $this->role, 'acl_location' => $this->acl_location, 'edit' => true);
                 $attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php', $link_history_data);
             }
         }
         phpgwapi_yui::tabview_setup('general_edit_tabview');
         $attributes_groups = $this->custom->get_attribute_groups($this->location_info['acl_app'], $this->acl_location, $values['attributes']);
         //_debug_array($attributes_groups);die();
         if (isset($attributes_groups[0]['id']) && $attributes_groups[0]['id'] > 0 || count($attributes_groups) > 1) {
             //					$tabs['general']	= array('label' => lang('general'), 'link' => '#general');
         }
         $attributes = array();
         foreach ($attributes_groups as $group) {
             if (isset($group['attributes']) && isset($tabs['general'])) {
                 //						$tabs[str_replace(' ', '_', $group['name'])] = array('label' => $group['name'], 'link' => '#' . str_replace(' ', '_', $group['name']));
                 //						$group['link'] = str_replace(' ', '_', $group['name']);
             }
             $attributes[] = $group;
         }
         unset($attributes_groups);
         unset($values['attributes']);
     }
     foreach ($this->location_info['fields'] as &$field) {
         $field['value'] = isset($values[$field['name']]) ? $values[$field['name']] : '';
         if (isset($field['values_def'])) {
             if ($field['values_def']['valueset'] && is_array($field['values_def']['valueset'])) {
                 $field['valueset'] = $field['values_def']['valueset'];
                 foreach ($field['valueset'] as &$_entry) {
                     $_entry['selected'] = $_entry['id'] == $field['value'] ? 1 : 0;
                 }
             } else {
                 if (isset($field['values_def']['method'])) {
                     foreach ($field['values_def']['method_input'] as $_argument => $_argument_value) {
                         if (preg_match('/^##/', $_argument_value)) {
                             $_argument_value_name = trim($_argument_value, '#');
                             $_argument_value = $values[$_argument_value_name];
                         }
                         if (preg_match('/^\\$this->/', $_argument_value)) {
                             $_argument_value_name = ltrim($_argument_value, '$this->');
                             $_argument_value = $this->{$_argument_value_name};
                         }
                         $method_input[$_argument] = $_argument_value;
                     }
                     $field['valueset'] = execMethod($field['values_def']['method'], $method_input);
                 }
             }
             if (isset($values['id']) && $values['id'] && isset($field['role']) && $field['role'] == 'parent') {
                 // can not select it self as parent.
                 $exclude = array($values['id']);
                 $children = $this->bo->get_children2($values['id'], 0, true);
                 foreach ($children as $child) {
                     $exclude[] = $child['id'];
                 }
                 $k = count($field['valueset']);
                 for ($i = 0; $i < $k; $i++) {
                     if (in_array($field['valueset'][$i]['id'], $exclude)) {
                         unset($field['valueset'][$i]);
                     }
                 }
             }
         }
     }
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     $data = array('msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uigeneric.index', 'type' => $this->type, 'type_id' => $this->type_id)), 'lang_descr' => lang('Descr'), 'lang_save' => lang('save'), 'lang_cancel' => lang('cancel'), 'lang_apply' => lang('apply'), 'value_id' => isset($values['id']) ? $values['id'] : '', 'value_descr' => $values['descr'], 'attributes_group' => $attributes, 'lookup_functions' => isset($values['lookup_functions']) ? $values['lookup_functions'] : '', 'textareacols' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 60, 'textarearows' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 10, 'tabs' => phpgwapi_yui::tabview_generate($tabs, 'general'), 'id_name' => $this->location_info['id']['name'], 'id_type' => $this->location_info['id']['type'], 'fields' => $this->location_info['fields']);
     $appname = $this->location_info['name'];
     $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw']->translation->translate($this->location_info['acl_app'], array(), false, $this->location_info['acl_app']) . "::{$appname}::{$function_msg}";
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
 }
 function edit()
 {
     $id = phpgw::get_var('id');
     // in case of bigint
     if (!$this->acl_add && !$this->acl_edit) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uis_agreement.view', 'id' => $id));
     }
     phpgwapi_jquery::load_widget('core');
     $values = phpgw::get_var('values');
     $delete_item = phpgw::get_var('delete_item');
     $item_id = phpgw::get_var('item_id');
     $active_tab = phpgw::get_var('tab', 'string', 'REQUEST', 'general');
     $config = CreateObject('phpgwapi.config', 'property');
     $boalarm = CreateObject('property.boalarm');
     $get_items = false;
     if ($delete_item && $id && $item_id) {
         $this->bo->delete_item($id, $item_id);
         $get_items = true;
     }
     $values_attribute = phpgw::get_var('values_attribute');
     $insert_record_s_agreement = $GLOBALS['phpgw']->session->appsession('insert_record_values.s_agreement', 'property');
     for ($j = 0; $j < count($insert_record_s_agreement); $j++) {
         $insert_record['extra'][$insert_record_s_agreement[$j]] = $insert_record_s_agreement[$j];
     }
     $GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement', 'attributes_form', 'files'));
     if (is_array($values)) {
         $values['ecodimb'] = phpgw::get_var('ecodimb');
         while (is_array($insert_record['extra']) && (list($key, $column) = each($insert_record['extra']))) {
             if ($_POST[$key]) {
                 $values['extra'][$column] = phpgw::get_var($key, 'string', 'POST');
             }
         }
         if ($values['save'] || $values['apply']) {
             $values['vendor_id'] = phpgw::get_var('vendor_id', 'int', 'POST');
             $values['vendor_name'] = phpgw::get_var('vendor_name', 'string', 'POST');
             $values['b_account_id'] = phpgw::get_var('b_account_id', 'int', 'POST');
             $values['b_account_name'] = phpgw::get_var('b_account_name', 'string', 'POST');
             if (!$values['cat_id']) {
                 $receipt['error'][] = array('msg' => lang('Please select a category !'));
             }
             if (($values['ecodimb'] || $values['b_account_id']) && (!isset($values['budget']) || !$values['budget'])) {
                 $receipt['error'][] = array('msg' => lang('Missing budget value'));
             }
             if (!$values['last_name']) {
                 //						$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
             }
             if (isset($values['budget']) && $values['budget'] && !ctype_digit($values['budget'])) {
                 $receipt['error'][] = array('msg' => lang('budget') . ': ' . lang('Please enter an integer !'));
             }
             if ($id) {
                 $values['s_agreement_id'] = $id;
                 $action = 'edit';
             } else {
                 $values['s_agreement_id'] = $this->bo->request_next_id();
             }
             if (isset($values['delete_b_year']) && is_array($values['delete_b_year'])) {
                 $this->bo->delete_year_from_budget($values['delete_b_year'], $id);
             }
             $bofiles = CreateObject('property.bofiles');
             if (isset($values['file_action']) && is_array($values['file_action'])) {
                 $bofiles->delete_file("/service_agreement/{$id}/", $values);
             }
             $values['file_name'] = str_replace(' ', '_', $_FILES['file']['name']);
             $to_file = "{$bofiles->fakebase}/service_agreement/{$values['s_agreement_id']}/{$values['file_name']}";
             if (!$values['document_name_orig'] && $bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
                 $receipt['error'][] = array('msg' => lang('This file already exists !'));
             }
             if (!$receipt['error']) {
                 //						$values['s_agreement_id']	= $id;
                 $receipt = $this->bo->save($values, $values_attribute, $action);
                 $id = $receipt['s_agreement_id'];
                 $this->cat_id = $values['cat_id'] ? $values['cat_id'] : $this->cat_id;
                 if ($values['file_name']) {
                     $bofiles->create_document_dir("service_agreement/{$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)))) {
                         $receipt['error'][] = array('msg' => lang('Failed to upload file !'));
                     }
                     $bofiles->vfs->override_acl = 0;
                 }
                 if ($values['save']) {
                     $GLOBALS['phpgw']->session->appsession('session_data', 's_agreement_receipt', $receipt);
                     $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uis_agreement.index', 'role' => $this->role));
                 }
             }
         } else {
             if ($values['update']) {
                 if (!$values['date']) {
                     $receipt['error'][] = array('msg' => lang('Please select a date !'));
                 }
                 if (!$values['new_index']) {
                     $receipt['error'][] = array('msg' => lang('Please enter a index !'));
                 }
                 if (!$receipt['error']) {
                     $receipt = $this->bo->update($values);
                 }
                 $get_items = true;
             } else {
                 if ($values['delete_alarm'] && count($values['alarm'])) {
                     if (!$receipt['error']) {
                         $receipt = $boalarm->delete_alarm('s_agreement', $values['alarm']);
                     }
                 } else {
                     if (($values['enable_alarm'] || $values['disable_alarm']) && count($values['alarm'])) {
                         if (!$receipt['error']) {
                             $receipt = $boalarm->enable_alarm('s_agreement', $values['alarm'], $values['enable_alarm']);
                         }
                     } else {
                         if ($values['add_alarm']) {
                             $time = intval($values['time']['days']) * 24 * 3600 + intval($values['time']['hours']) * 3600 + intval($values['time']['mins']) * 60;
                             if ($time > 0) {
                                 $receipt = $boalarm->add_alarm('s_agreement', $this->bo->read_event(array('s_agreement_id' => $id)), $time, $values['user_id']);
                             }
                         } else {
                             if (!$values['save'] && !$values['apply'] && !$values['update']) {
                                 $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uis_agreement.index', 'role' => $this->role));
                             }
                         }
                     }
                 }
             }
         }
     }
     /* 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);
     }
     $GLOBALS['phpgw']->jqcal->add_listener('values_start_date');
     $GLOBALS['phpgw']->jqcal->add_listener('values_end_date');
     $GLOBALS['phpgw']->jqcal->add_listener('values_termination_date');
     $this->member_id = $values['member_of'] ? $values['member_of'] : $this->member_id;
     if ($id) {
         $values = $this->bo->read_single(array('s_agreement_id' => $id));
         $this->cat_id = $values['cat_id'] ? $values['cat_id'] : $this->cat_id;
         $this->member_id = $values['member_of'] ? $values['member_of'] : $this->member_id;
         $list = $this->bo->read_details($id);
         $uicols = $this->bo->uicols;
         $list = $this->list_content($list, $uicols);
         $content = $list['content'];
         $table_header = $list['table_header'];
         for ($i = 0; $i < count($list['content'][0]['row']); $i++) {
             $set_column[] = true;
         }
         if (isset($content) && is_array($content)) {
             $GLOBALS['phpgw']->jqcal->add_listener('values_date');
             $table_update[] = array('lang_new_index' => lang('New index'), 'lang_new_index_statustext' => lang('Enter a new index'), 'lang_date_statustext' => lang('Select the date for the update'), 'lang_update' => lang('Update'), 'lang_update_statustext' => lang('update selected investments'));
         }
     }
     $link_data = array('menuaction' => 'property.uis_agreement.edit', 'id' => $id, 'role' => $this->role);
     $vendor_data = $this->bocommon->initiate_ui_vendorlookup(array('vendor_id' => $values['vendor_id'], 'vendor_name' => $values['vendor_name']));
     $b_account_data = $this->bocommon->initiate_ui_budget_account_lookup(array('b_account_id' => $values['b_account_id'], 'b_account_name' => $values['b_account_name']));
     $ecodimb_data = $this->bocommon->initiate_ecodimb_lookup(array('ecodimb' => $values['ecodimb'], 'ecodimb_descr' => $values['ecodimb_descr']));
     $alarm_data = $this->bocommon->initiate_ui_alarm(array('acl_location' => $this->acl_location, 'alarm_type' => 's_agreement', 'type' => 'form', 'text' => 'Email notification', 'times' => $times, 'id' => $id, 'method' => $method, 'data' => $data, 'account_id' => $account_id));
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     if ($values['vendor_id']) {
         $member_of_list = $this->get_vendor_member_info($values['vendor_id']);
     } else {
         $member_of_list = array();
     }
     $table_add[] = array('lang_add' => lang('add detail'), 'lang_add_standardtext' => lang('add an item to the details'), 'add_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.edit_item', 's_agreement_id' => $id)));
     $link_file_data = array('menuaction' => 'property.uis_agreement.view_file', 'id' => $id);
     $config->read();
     $link_to_files = $config->config_data['files_url'];
     $j = count($values['files']);
     for ($i = 0; $i < $j; $i++) {
         $values['files'][$i]['file_name'] = urlencode($values['files'][$i]['name']);
     }
     $link_download = array('menuaction' => 'property.uis_agreement.download', 'id' => $id);
     $GLOBALS['phpgw']->js->validate_file('overlib', 'overlib', 'property');
     $GLOBALS['phpgw']->js->validate_file('core', 'check', 'property');
     $tabs = array();
     if (isset($values['attributes']) && is_array($values['attributes'])) {
         /*		foreach ($values['attributes'] as & $attribute)
         				{
         					if($attribute['history'] == true)
         					{
         						$link_history_data = array
         						(
         							'menuaction'	=> 'property.uis_agreement.attrib_history',
         							'attrib_id'	=> $attribute['id'],
         							'id'		=> $id,
         							'edit'		=> true
         						);
         
         						$attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php',$link_history_data);
         					}
         				}
         		 */
         phpgwapi_yui::tabview_setup('edit_tabview');
         $tabs['general'] = array('label' => lang('general'), 'link' => '#general');
         $location = $this->acl_location;
         $attributes_groups = $this->bo->get_attribute_groups($location, $values['attributes']);
         $attributes = array();
         foreach ($attributes_groups as $group) {
             if (isset($group['attributes'])) {
                 $attributes[] = $group;
             }
         }
         unset($attributes_groups);
         unset($values['attributes']);
         $tabs['items'] = array('label' => lang('items'), 'link' => '#items');
     }
     //----------JSON CODE ----------------------------------------------
     //---GET ITEMS
     if (phpgw::get_var('phpgw_return_as') == 'json' && $get_items) {
         //$this->bo->delete_item($id,$item_id);
         $list = $this->bo->read_details($id);
         $list = $this->list_content($list, $uicols);
         $content = $list['content'];
         $content_values = array();
         for ($y = 0; $y < count($content); $y++) {
             for ($z = 0; $z < count($content[$y]['row']); $z++) {
                 if ($content[$y]['row'][$z + 1]['name'] != '') {
                     $content_values[$y][$content[$y]['row'][$z + 1]['name']] = $content[$y]['row'][$z + 1]['value'];
                 }
             }
         }
         /*$datavalues[0] = array
         		(
         				'name'					=> "0",
         				'values' 				=> json_encode($content_values),
         				'total_records'			=> count($content_values),
         				'edit_action'			=> "''",
         				'is_paginator'			=> 0,
         				'permission'			=> json_encode($permissions['rowactions']),
         				'footer'				=> 0
         		);*/
         if (count($content_values)) {
             return json_encode($content_values);
         } else {
             return "";
         }
     } else {
         if (phpgw::get_var('phpgw_return_as') == 'json' && !$get_items) {
             $alarm_data = $this->bocommon->initiate_ui_alarm(array('acl_location' => $this->acl_location, 'alarm_type' => 's_agreement', 'type' => 'form', 'text' => 'Email notification', 'times' => isset($times) ? $times : '', 'id' => $id, 'method' => isset($method) ? $method : '', 'data' => isset($data) ? $data : '', 'account_id' => isset($account_id) ? $account_id : ''));
             //$alarm_data['values'] = array();
             if (count($alarm_data['values'])) {
                 return json_encode($alarm_data['values']);
             } else {
                 return "";
             }
         }
     }
     //--------------------JSON code-----
     //_debug_array($id);die;
     $parameters = array('parameter' => array(array('name' => 's_agreement_id', 'source' => $id, 'ready' => 1), array('name' => 'id', 'source' => 'item_id'), array('name' => 'from', 'source' => $view_only ? 'view' : 'edit', 'ready' => 1)));
     $parameters2 = array('parameter' => array(array('name' => 's_agreement_id', 'source' => $id, 'ready' => 1), array('name' => 'id', 'source' => 'item_id')));
     $parameters3 = array('parameter' => array(array('name' => 'id', 'source' => $id, 'ready' => 1), array('name' => 'item_id', 'source' => 'item_id'), array('name' => 'delete_item', 'source' => 1, 'ready' => 1)));
     //_debug_array($parameters3);die;
     /*REQUIRES VALIDATION OF PERMISSIONS*/
     $permissions['rowactions'][] = array('text' => lang('View'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.view_item')), 'parameters' => $parameters);
     $permissions['rowactions'][] = array('text' => lang('Edit'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.edit_item')), 'parameters' => $parameters2);
     $permissions['rowactions'][] = array('text' => lang('Delete'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.edit')), 'confirm_msg' => lang('do you really want to delete this entry'), 'parameters' => $parameters3);
     $content_values = array();
     for ($y = 0; $y < count($content); $y++) {
         for ($z = 0; $z < count($content[$y]['row']); $z++) {
             if ($content[$y]['row'][$z + 1]['name'] != '') {
                 $content_values[$y][$content[$y]['row'][$z + 1]['name']] = $content[$y]['row'][$z + 1]['value'];
             }
         }
     }
     //------- alarm--------
     $datavalues[0] = array('name' => "0", 'values' => json_encode($alarm_data['values']), 'total_records' => count($alarm_data['values']), 'is_paginator' => 0, 'permission' => '""', 'footer' => 0);
     $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'time', 'label' => $alarm_data['header'][0]['lang_time'], 'sortable' => true, 'resizeable' => true, 'width' => 140), array('key' => 'text', 'label' => $alarm_data['header'][0]['lang_text'], 'sortable' => true, 'resizeable' => true, 'width' => 340), array('key' => 'user', 'label' => $alarm_data['header'][0]['lang_user'], 'sortable' => true, 'resizeable' => true, 'width' => 200), array('key' => 'enabled', 'label' => $alarm_data['header'][0]['lang_enabled'], 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterCenter', 'width' => 60), array('key' => 'alarm_id', 'label' => "dummy", 'sortable' => true, 'resizeable' => true, 'hidden' => true), array('key' => 'select', 'label' => $alarm_data['header'][0]['lang_select'], 'sortable' => false, 'resizeable' => false, 'formatter' => 'myFormatterCheck', 'width' => 60))));
     $myButtons[0] = array('name' => "0", 'values' => json_encode(array(array('id' => 'values[enable_alarm]', 'type' => 'buttons', 'value' => 'Enable', 'label' => $alarm_data[alter_alarm][0][lang_enable], 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""), array('id' => 'values[disable_alarm]', 'type' => 'buttons', 'value' => 'Disable', 'label' => $alarm_data[alter_alarm][0][lang_disable], 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""), array('id' => 'values[delete_alarm]', 'type' => 'buttons', 'value' => 'Delete', 'label' => $alarm_data[alter_alarm][0][lang_delete], 'funct' => 'onActionsClick', 'classname' => 'actionButton', 'value_hidden' => ""))));
     $myButtons[1] = array('name' => "1", 'values' => json_encode(array(array('id' => 'values[time][days]', 'type' => 'menu', 'value' => $this->bocommon->make_menu_date($alarm_data['add_alarm']['day_list'], "1_0", 'values[time][days]'), 'label' => "0", 'classname' => 'actionsFilter', 'value_hidden' => "0"), array('id' => 'values[time][hours]', 'type' => 'menu', 'value' => $this->bocommon->make_menu_date($alarm_data['add_alarm']['hour_list'], "1_1", 'values[time][hours]'), 'label' => "0", 'classname' => 'actionsFilter', 'value_hidden' => "0"), array('id' => 'values[time][mins]', 'type' => 'menu', 'value' => $this->bocommon->make_menu_date($alarm_data['add_alarm']['minute_list'], "1_2", 'values[time][mins]'), 'label' => "0", 'classname' => 'actionsFilter', 'value_hidden' => "0"), array('id' => 'values[user_id]', 'type' => 'menu', 'value' => $this->bocommon->make_menu_user($alarm_data['add_alarm']['user_list'], "1_3", 'values[user_id]'), 'label' => $this->bocommon->choose_select($alarm_data['add_alarm']['user_list'], "name"), 'classname' => 'actionsFilter', 'value_hidden' => $this->bocommon->choose_select($alarm_data['add_alarm']['user_list'], "id")), array('id' => 'values[add_alarm]', 'type' => 'buttons', 'value' => 'Add', 'label' => $alarm_data['add_alarm']['lang_add'], 'funct' => 'onAddClick', 'classname' => 'actionButton', 'value_hidden' => ""))));
     /*
     _debug_array(array( array('id' =>'values[time][days]', 'type'=>'menu',  'value'=>$this->bocommon->make_menu_date($alarm_data['add_alarm']['day_list'],"1_0",'values[time][days]' ), 'label'=>"0", 'classname'=> 'actionsFilter', 'value_hidden'=>"0"),
     													array('id' =>'values[time][hours]', 'type'=>'menu',  'value'=>$this->bocommon->make_menu_date($alarm_data['add_alarm']['hour_list'],"1_1",'values[time][hours]'), 'label'=>"0", 'classname'=> 'actionsFilter', 'value_hidden'=>"0"),
     													array('id' =>'values[time][mins]', 'type'=>'menu',  'value'=>$this->bocommon->make_menu_date($alarm_data['add_alarm']['minute_list'],"1_2",'values[time][mins]'), 'label'=>"0", 'classname'=> 'actionsFilter', 'value_hidden'=>"0"),
     													array('id' =>'values[user_id]',  'type'=>'menu',  'value'=>$this->bocommon->make_menu_user($alarm_data['add_alarm']['user_list'],"1_3",'values[user_id]'), 'label'=>$this->bocommon->choose_select($alarm_data['add_alarm']['user_list'],"name"),'classname'=> 'actionsFilter', 'value_hidden'=>$this->bocommon->choose_select($alarm_data['add_alarm']['user_list'],"id")),
     													array('id' =>'values[add_alarm]',  'type'=>'buttons', 'value'=>'Add',  'label'=>$alarm_data['add_alarm']['lang_add'],   'funct'=> 'onAddClick' , 'classname'=> 'actionButton', 'value_hidden'=>"")));
     die();
     */
     //---------items------------------------------------
     $datavalues[1] = array('name' => "1", 'values' => json_encode($content_values), 'total_records' => count($content_values), 'is_paginator' => 0, 'permission' => json_encode($permissions['rowactions']), 'footer' => 0);
     $td_count = 0;
     $ColumnDefs_data = array();
     if (isset($uicols['input_type']) && $uicols['input_type']) {
         foreach ($uicols['input_type'] as $key => $input_type) {
             if ($input_type != 'hidden') {
                 $ColumnDefs_data[] = array('key' => $uicols['name'][$key], 'label' => $uicols['descr'][$key], 'sortable' => true, 'resizeable' => true);
                 $td_count++;
             }
         }
     }
     $ColumnDefs_data[] = array('key' => 'update', 'label' => lang('Update'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'myFormatterCheckUpdate');
     //_debug_array($ColumnDefs_data);
     $myColumnDefs[1] = array('name' => "1", 'values' => json_encode($ColumnDefs_data));
     unset($ColumnDefs_data);
     $myButtons[2] = array('name' => "2", 'values' => json_encode(array(array('type' => 'text', 'label' => ' New index:', 'classname' => 'index-opt'), array('id' => 'values[new_index]', 'type' => 'inputText', 'size' => 12, 'classname' => 'index-opt'), array('id' => 'values[update]', 'type' => 'buttons', 'value' => 'Update', 'label' => 'Update', 'funct' => 'onUpdateClick', 'classname' => ''))));
     $link_view_file = $GLOBALS['phpgw']->link('/index.php', $link_file_data);
     for ($z = 0; $z < count($values['files']); $z++) {
         if ($link_to_files != '') {
             $content_files[$z]['file_name'] = '<a href="' . $link_to_files . '/' . $values['files'][$z]['directory'] . '/' . $values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click to view file') . '">' . $values['files'][$z]['name'] . '</a>';
         } else {
             $content_files[$z]['file_name'] = '<a href="' . $link_view_file . '&amp;file_name=' . $values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click to view file') . '">' . $values['files'][$z]['name'] . '</a>';
         }
         $content_files[$z]['delete_file'] = '<input type="checkbox" name="values[file_action][]" value="' . $values['files'][$z]['name'] . '" title="' . lang('Check to delete file') . '">';
     }
     $datavalues[2] = array('name' => "2", 'values' => json_encode($content_files), 'total_records' => count($content_files), 'permission' => "''", 'is_paginator' => 0, 'footer' => 0);
     $myColumnDefs[2] = array('name' => "2", 'values' => json_encode(array(array('key' => 'file_name', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'delete_file', 'label' => lang('Delete file'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter'))));
     if ($id) {
         $content_budget = $this->bo->get_budget($id);
         $lang_delete = lang('Check to delete year');
         foreach ($content_budget as &$b_entry) {
             $b_entry['delete_year'] = "<input type='checkbox' name='values[delete_b_year][]' value='{$b_entry['year']}' title='{$lang_delete}'>";
         }
     }
     $datavalues[3] = array('name' => "3", 'values' => json_encode($content_budget), 'total_records' => count($content_budget), 'permission' => "''", 'is_paginator' => 0, 'footer' => 1);
     $myColumnDefs[3] = array('name' => "3", 'values' => json_encode(array(array('key' => 'year', 'label' => lang('year'), 'sortable' => false, 'resizeable' => true), array('key' => 'category', 'label' => lang('category'), 'sortable' => false, 'resizeable' => true), array('key' => 'ecodimb', 'label' => lang('dimb'), 'sortable' => false, 'resizeable' => true), array('key' => 'budget_account', 'label' => lang('budget account'), 'sortable' => false, 'resizeable' => true), array('key' => 'budget', 'label' => lang('budget'), 'sortable' => false, 'resizeable' => true), array('key' => 'actual_cost', 'label' => lang('actual cost'), 'sortable' => false, 'resizeable' => true), array('key' => 'delete_year', 'label' => lang('Delete'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter'))));
     //--------------------------------------------JSON CODE------------
     $this->cats->set_appname('property', '.project');
     $data = array('td_count' => $td_count, 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'base_java_url' => json_encode(array('menuaction' => "property.uis_agreement.edit", 'id' => $id)), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'link_import' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.import', 'tab' => 'items')), 'alarm_data' => $alarm_data, 'lang_alarm' => lang('Alarm'), 'lang_download' => 'download', 'link_download' => $GLOBALS['phpgw']->link('/index.php', $link_download), 'lang_download_help' => lang('Download table to your browser'), 'fileupload' => true, 'link_view_file' => $GLOBALS['phpgw']->link('/index.php', $link_file_data), 'link_to_files' => $link_to_files, 'files' => $values['files'], 'lang_files' => lang('files'), 'lang_filename' => lang('Filename'), 'lang_file_action' => lang('Delete file'), 'lang_view_file_statustext' => lang('click to view file'), 'lang_file_action_statustext' => lang('Check to delete file'), 'lang_upload_file' => lang('Upload file'), 'lang_file_statustext' => lang('Select file to upload'), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'edit_url' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'lang_id' => lang('ID'), 'value_s_agreement_id' => $id, 'lang_category' => lang('category'), 'lang_save' => lang('save'), 'lang_cancel' => lang('cancel'), 'lang_apply' => lang('apply'), 'value_cat' => $values['cat'], 'lang_apply_statustext' => lang('Apply the values'), 'lang_cancel_statustext' => lang('Leave the service agreement untouched and return back to the list'), 'lang_save_statustext' => lang('Save the service agreement and return back to the list'), 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the category the s_agreement belongs to. To do not use a category select NO CATEGORY'), 'select_name' => 'values[cat_id]', 'cat_list' => $this->bocommon->select_category_list(array('format' => 'select', 'selected' => $this->cat_id, 'type' => 's_agreement', 'order' => 'descr')), 'member_of_list2' => $member_of_list, 'attributes_group' => $attributes, 'lookup_functions' => $values['lookup_functions'], 'dateformat' => $dateformat, 'lang_start_date_statustext' => lang('Select the estimated end date for the Project'), 'lang_start_date' => lang('start date'), 'value_start_date' => $values['start_date'], 'lang_end_date_statustext' => lang('Select the estimated end date for the Project'), 'lang_end_date' => lang('end date'), 'value_end_date' => $values['end_date'], 'lang_termination_date_statustext' => lang('Select the estimated termination date'), 'lang_termination_date' => lang('termination date'), 'value_termination_date' => $values['termination_date'], 'vendor_data' => $vendor_data, 'lang_budget' => lang('Budget'), 'lang_budget_statustext' => lang('Budget for selected year'), 'value_budget' => $values['budget'], 'currency' => $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'], 'lang_year' => lang('year'), 'lang_year_statustext' => lang('Budget year'), 'year' => $this->bocommon->select_list($values['year'], $this->bo->get_year_list($id)), 'b_account_data' => $b_account_data, 'ecodimb_data' => $ecodimb_data, 'lang_category' => lang('category'), 'lang_no_cat' => lang('Select category'), 'cat_select' => $this->cats->formatted_xslt_list(array('select_name' => 'values[order_category]', 'selected' => $values['order_category'])), 'lang_name' => lang('name'), 'lang_name_statustext' => lang('name'), 'value_name' => $values['name'], 'lang_descr' => lang('descr'), 'lang_descr_statustext' => lang('descr'), 'value_descr' => $values['descr'], 'table_add' => $table_add, 'values' => $content, 'table_header' => $table_header, 'acl_manage' => $this->acl_manage, 'table_update' => $table_update, 'update_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uis_agreement.edit', 'id' => $id)), 'lang_select_all' => lang('Select All'), 'img_check' => $GLOBALS['phpgw']->common->get_image_path('property') . '/check.png', 'set_column' => $set_column, 'lang_import_detail' => lang('import detail'), 'lang_detail_import_statustext' => lang('import details to this agreement from spreadsheet'), 'lang_import' => lang('import'), '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, $active_tab));
     //_debug_array($data);die;
     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');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('service agreement') . ': ' . ($id ? lang('edit') . ' ' . lang($this->role) : lang('add') . ' ' . lang($this->role));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
     $GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
     $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', 'uis_agreement.edit', 'property');
 }
Exemple #12
0
<?php

include "common.php";
phpgwapi_yui::load_widget('tabview');
phpgwapi_yui::tabview_setup('contract_tabview');
$config = CreateObject('phpgwapi.config', 'rental');
$config->read();
?>

<?php 
echo rental_uicommon::get_page_error($error);
echo rental_uicommon::get_page_warning($contract->get_validation_warnings());
echo rental_uicommon::get_page_message($message);
if ($contract->get_id() > 0) {
    if ($contract->get_consistency_warnings()) {
        ?>
<div class="warning" style="width: 50%;">
<?php 
        $list_form = false;
        $list_id = 'get_contract_warnings';
        unset($related);
        $url_add_on = '&amp;contract_id=' . $contract->get_id();
        unset($extra_cols);
        include 'contract_warnings_partial.php';
        ?>
</div>
<?php 
    }
}
?>
 function edit()
 {
     if (!$this->acl_add) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uilocation.stop', 'perm' => 2, 'acl_location' => $this->acl_location));
     }
     $id = phpgw::get_var('id', 'int');
     $values = phpgw::get_var('values');
     //return _debug_array($values);
     $delete_item = phpgw::get_var('delete_item', 'bool');
     $activity_id = phpgw::get_var('activity_id', 'int');
     $active_tab = phpgw::get_var('tab', 'string', 'REQUEST', 'general');
     $config = CreateObject('phpgwapi.config', 'property');
     $boalarm = CreateObject('property.boalarm');
     $receipt = array();
     $get_items = false;
     if ($delete_item && $id && $activity_id) {
         $this->bo->delete_item($id, $activity_id);
         $get_items = true;
     }
     $values_attribute = phpgw::get_var('values_attribute');
     $insert_record_agreement = $GLOBALS['phpgw']->session->appsession('insert_record_values.agreement', 'property');
     if (isset($insert_record_agreement) && is_array($insert_record_agreement)) {
         for ($j = 0; $j < count($insert_record_agreement); $j++) {
             $insert_record['extra'][$insert_record_agreement[$j]] = $insert_record_agreement[$j];
         }
     }
     $GLOBALS['phpgw']->xslttpl->add_file(array('agreement', 'nextmatchs', 'attributes_form', 'files'));
     $receipt = array();
     if (is_array($values)) {
         if (isset($insert_record['extra']) && is_array($insert_record['extra'])) {
             foreach ($insert_record['extra'] as $key => $column) {
                 if ($_POST[$key]) {
                     $values['extra'][$column] = phpgw::get_var($key, 'string', 'POST');
                 }
             }
         }
         //_debug_array($values);
         if (isset($values['save']) && $values['save'] || isset($values['apply']) && $values['apply']) {
             $values['vendor_id'] = phpgw::get_var('vendor_id', 'int', 'POST');
             $values['vendor_name'] = phpgw::get_var('vendor_name', 'string', 'POST');
             if (!$values['cat_id']) {
                 $receipt['error'][] = array('msg' => lang('Please select a category !'));
             }
             if (!$values['last_name']) {
                 //						$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
             }
             if ($id) {
                 $values['agreement_id'] = $id;
                 $action = 'edit';
             } else {
                 $values['agreement_id'] = $this->bo->request_next_id();
             }
             $bofiles = CreateObject('property.bofiles');
             if (isset($id) && $id && isset($values['file_action']) && is_array($values['file_action'])) {
                 $bofiles->delete_file("/agreement/{$id}/", $values);
             }
             $values['file_name'] = str_replace(' ', '_', $_FILES['file']['name']);
             $to_file = "{$bofiles->fakebase}/agreement/{$values['agreement_id']}/{$values['file_name']}";
             if (!$values['document_name_orig'] && $bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
                 $receipt['error'][] = array('msg' => lang('This file already exists !'));
             }
             if (!$receipt['error']) {
                 //						$values['agreement_id']	= $id;
                 $receipt = $this->bo->save($values, $values_attribute, $action);
                 $id = $receipt['agreement_id'];
                 $this->cat_id = $values['cat_id'] ? $values['cat_id'] : $this->cat_id;
                 if ($values['file_name']) {
                     $bofiles->create_document_dir("agreement/{$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)))) {
                         $receipt['error'][] = array('msg' => lang('Failed to upload file !'));
                     }
                     $bofiles->vfs->override_acl = 0;
                 }
                 if ($values['save']) {
                     $GLOBALS['phpgw']->session->appsession('session_data', 'agreement_receipt', $receipt);
                     $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiagreement.index', 'role' => $this->role));
                 }
             }
         } else {
             if (isset($values['update']) && $values['update']) {
                 if (!$values['date']) {
                     $receipt['error'][] = array('msg' => lang('Please select a date !'));
                 }
                 if (!$values['new_index']) {
                     $receipt['error'][] = array('msg' => lang('Please enter a index !'));
                 }
                 if (!$receipt['error']) {
                     $receipt = $this->bo->update($values);
                     $get_items = true;
                 }
             } else {
                 if (isset($values['delete_alarm']) && $values['delete_alarm'] && count($values['alarm'])) {
                     if (!isset($receipt['error']) || !$receipt['error']) {
                         $receipt = $boalarm->delete_alarm('agreement', $values['alarm']);
                     }
                 } else {
                     if ((isset($values['enable_alarm']) && $values['enable_alarm'] || isset($values['disable_alarm']) && $values['disable_alarm']) && count($values['alarm'])) {
                         if (!isset($receipt['error']) || !$receipt['error']) {
                             $receipt = $boalarm->enable_alarm('agreement', $values['alarm'], isset($values['enable_alarm']) ? $values['enable_alarm'] : '');
                         }
                     } else {
                         if (isset($values['add_alarm']) && $values['add_alarm']) {
                             $time = intval($values['time']['days']) * 24 * 3600 + intval($values['time']['hours']) * 3600 + intval($values['time']['mins']) * 60;
                             if ($time > 0) {
                                 $receipt = $boalarm->add_alarm('agreement', $this->bo->read_event(array('agreement_id' => $id)), $time, $values['user_id']);
                             }
                         } else {
                             if ((!isset($values['save']) || !$values['save']) && (!isset($values['apply']) || !$values['apply']) && (!isset($values['update']) || !$values['update'])) {
                                 $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiagreement.index', 'role' => $this->role));
                             }
                         }
                     }
                 }
             }
         }
     }
     $agreement = $this->bo->read_single(array('agreement_id' => $id));
     /* Preserve attribute values from post */
     if (isset($receipt['error']) && (isset($values_attribute) && is_array($values_attribute))) {
         $agreement = $this->bocommon->preserve_attribute_values($agreement, $values_attribute);
     }
     $GLOBALS['phpgw']->jqcal->add_listener('values_start_date');
     $GLOBALS['phpgw']->jqcal->add_listener('values_end_date');
     $GLOBALS['phpgw']->jqcal->add_listener('values_termination_date');
     if ($id) {
         $this->cat_id = $agreement['cat_id'] ? $agreement['cat_id'] : $this->cat_id;
         $this->member_id = $agreement['member_of'] ? $agreement['member_of'] : $this->member_id;
         $list = $this->bo->read_details($id);
         $content = $list;
         //_debug_array($list);
         if (isset($list) and is_array($list)) {
             $k = count($list);
             for ($j = 0; $j < $k; $j++) {
                 if ($this->acl_read && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
                     $content[$j]['lang_view_statustext'] = lang('view the entity');
                     $content[$j]['text_view'] = lang('view');
                     $content[$j]['link_view'] = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.view_item', 'agreement_id' => $id, 'id' => $content[$j]['activity_id']));
                 }
                 if ($this->acl_edit && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
                     $content[$j]['lang_edit_statustext'] = lang('edit the agreement');
                     $content[$j]['text_edit'] = lang('edit');
                     $content[$j]['link_edit'] = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.edit_item', 'agreement_id' => $id, 'id' => $content[$j]['activity_id']));
                 }
                 if ($this->acl_delete && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
                     $content[$j]['lang_delete_statustext'] = lang('delete this item');
                     $content[$j]['text_delete'] = lang('delete');
                     $content[$j]['link_delete'] = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.edit', 'delete_item' => 1, 'id' => $id, 'activity_id' => $content[$j]['activity_id']));
                 }
                 $content[$j]['acl_manage'] = $this->acl_manage;
                 $content[$j]['acl_read'] = $this->acl_read;
                 $content[$j]['acl_edit'] = $this->acl_edit;
                 $content[$j]['acl_delete'] = $this->acl_delete;
             }
         }
         $uicols = $this->bo->uicols;
         for ($i = 0; $i < count($uicols['descr']); $i++) {
             if ($uicols['input_type'][$i] != 'hidden') {
                 $table_header[$i]['header'] = $uicols['descr'][$i];
                 $table_header[$i]['width'] = '5%';
                 $table_header[$i]['align'] = 'center';
             }
         }
         if ($this->acl_read && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
             $table_header[$i]['width'] = '5%';
             $table_header[$i]['align'] = 'center';
             $table_header[$i]['header'] = lang('view');
             $i++;
             $set_column[] = true;
         }
         if ($this->acl_edit && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
             $table_header[$i]['width'] = '5%';
             $table_header[$i]['align'] = 'center';
             $table_header[$i]['header'] = lang('edit');
             $i++;
             $set_column[] = true;
         }
         if ($this->acl_delete && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
             $table_header[$i]['width'] = '5%';
             $table_header[$i]['align'] = 'center';
             $table_header[$i]['header'] = lang('delete');
             $i++;
             $set_column[] = true;
         }
         if ($this->acl_manage && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
             $table_header[$i]['width'] = '5%';
             $table_header[$i]['align'] = 'center';
             $table_header[$i]['header'] = lang('Update');
             $i++;
             $set_column[] = true;
         }
         //				$table_header=$list['table_header'];
         for ($i = 0; $i < 9; $i++) {
             $set_column[] = true;
         }
         if (isset($content) && is_array($content)) {
             $GLOBALS['phpgw']->jqcal->add_listener('values_date');
             $table_update[] = array('lang_new_index' => lang('New index'), 'lang_new_index_statustext' => lang('Enter a new index'), 'lang_date_statustext' => lang('Select the date for the update'), 'lang_update' => lang('Update'), 'lang_update_statustext' => lang('update selected investments'));
         }
     }
     $link_data = array('menuaction' => 'property.uiagreement.edit', 'sort' => $this->sort, 'order' => $this->order, 'id' => $id, 'role' => $this->role);
     $vendor_data = $this->bocommon->initiate_ui_vendorlookup(array('vendor_id' => $agreement['vendor_id'], 'vendor_name' => isset($agreement['vendor_name']) ? $agreement['vendor_name'] : ''));
     if ($agreement['vendor_id']) {
         $member_of_data = $this->cats->formatted_xslt_list(array('selected' => $this->member_id, 'globals' => true, 'link_data' => array()));
     }
     $alarm_data = $this->bocommon->initiate_ui_alarm(array('acl_location' => $this->acl_location, 'alarm_type' => 'agreement', 'type' => 'form', 'text' => 'Email notification', 'times' => isset($times) ? $times : '', 'id' => $id, 'method' => isset($method) ? $method : '', 'data' => isset($data) ? $data : '', 'account_id' => isset($account_id) ? $account_id : ''));
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     $table_add[] = array('lang_add' => lang('add detail'), 'lang_add_standardtext' => lang('add an item to the details'), 'add_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.add_activity', 'agreement_id' => $id, 'group_id' => $agreement['group_id'])));
     $link_file_data = array('menuaction' => 'property.uiagreement.view_file', 'id' => $id);
     if (isset($agreement['files']) && is_array($agreement['files'])) {
         $j = count($agreement['files']);
         for ($i = 0; $i < $j; $i++) {
             $agreement['files'][$i]['file_name'] = urlencode($agreement['files'][$i]['name']);
         }
     }
     $link_download = array('menuaction' => 'property.uiagreement.download', 'id' => $id, 'allrows' => $this->allrows);
     if (!$this->allrows) {
         $record_limit = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
     } else {
         $record_limit = $this->bo->total_records;
     }
     $GLOBALS['phpgw']->js->validate_file('overlib', 'overlib', 'property');
     $GLOBALS['phpgw']->js->validate_file('core', 'check', 'property');
     if (isset($agreement['attributes']) && is_array($agreement['attributes'])) {
         /*		foreach ($values['attributes'] as & $attribute)
         				{
         					if($attribute['history'] == true)
         					{
         						$link_history_data = array
         						(
         							'menuaction'	=> 'property.uis_agreement.attrib_history',
         							'attrib_id'	=> $attribute['id'],
         							'id'		=> $id,
         							'edit'		=> true
         						);
         
         						$attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php',$link_history_data);
         					}
         				}
         		 */
         phpgwapi_yui::tabview_setup('edit_tabview');
         $tabs['general'] = array('label' => lang('general'), 'link' => '#general');
         $location = $this->acl_location;
         $attributes_groups = $this->bo->get_attribute_groups($location, $agreement['attributes']);
         $attributes = array();
         foreach ($attributes_groups as $group) {
             if (isset($group['attributes'])) {
                 $attributes[] = $group;
             }
         }
         unset($attributes_groups);
         unset($agreement['attributes']);
         $tabs['items'] = array('label' => lang('items'), 'link' => '#items');
     }
     //------JSON code-------------------
     //---GET ITEMS
     if (phpgw::get_var('phpgw_return_as') == 'json' && $get_items) {
         if (count($content)) {
             return json_encode($content);
         } else {
             return "";
         }
     } else {
         if (phpgw::get_var('phpgw_return_as') == 'json' && !$get_items) {
             $alarm_data = $this->bocommon->initiate_ui_alarm(array('acl_location' => $this->acl_location, 'alarm_type' => 'agreement', 'type' => 'form', 'text' => 'Email notification', 'times' => isset($times) ? $times : '', 'id' => $id, 'method' => isset($method) ? $method : '', 'data' => isset($data) ? $data : '', 'account_id' => isset($account_id) ? $account_id : ''));
             //$alarm_data['values'] = array();
             if (count($alarm_data['values'])) {
                 return json_encode($alarm_data['values']);
             } else {
                 return "";
             }
         }
     }
     //---datatable0 settings---------------------------------------------------
     $datavalues[0] = array('name' => "0", 'values' => json_encode($alarm_data['values']), 'total_records' => count($alarm_data['values']), 'permission' => "''", 'is_paginator' => 0, 'footer' => 0);
     $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array(key => time, label => $alarm_data['header'][0]['lang_time'], sortable => true, resizeable => true, width => 140), array(key => text, label => $alarm_data['header'][0]['lang_text'], sortable => true, resizeable => true, width => 340), array(key => user, label => $alarm_data['header'][0]['lang_user'], sortable => true, resizeable => true, width => 200), array(key => enabled, label => $alarm_data['header'][0]['lang_enabled'], sortable => true, resizeable => true, formatter => FormatterCenter, width => 60), array(key => alarm_id, label => "dummy", sortable => true, resizeable => true, hidden => true), array(key => select, label => $alarm_data['header'][0]['lang_select'], sortable => false, resizeable => false, formatter => myFormatterCheck, width => 60))));
     $myButtons[0] = array('name' => "0", 'values' => json_encode(array(array(id => 'values[enable_alarm]', type => buttons, value => Enable, label => $alarm_data[alter_alarm][0][lang_enable], funct => onActionsClick, classname => actionButton, value_hidden => ""), array(id => 'values[disable_alarm]', type => buttons, value => Disable, label => $alarm_data[alter_alarm][0][lang_disable], funct => onActionsClick, classname => actionButton, value_hidden => ""), array(id => 'values[delete_alarm]', type => buttons, value => Delete, label => $alarm_data[alter_alarm][0][lang_delete], funct => onActionsClick, classname => actionButton, value_hidden => ""))));
     $myButtons[1] = array('name' => "1", 'values' => json_encode(array(array(id => 'values[time][days]', type => menu, value => $this->bocommon->make_menu_date($alarm_data['add_alarm']['day_list'], "1_0", 'values[time][days]'), label => "0", classname => actionsFilter, value_hidden => "0"), array(id => 'values[time][hours]', type => menu, value => $this->bocommon->make_menu_date($alarm_data['add_alarm']['hour_list'], "1_1", 'values[time][hours]'), label => "0", classname => actionsFilter, value_hidden => "0"), array(id => 'values[time][mins]', type => menu, value => $this->bocommon->make_menu_date($alarm_data['add_alarm']['minute_list'], "1_2", 'values[time][mins]'), label => "0", classname => actionsFilter, value_hidden => "0"), array(id => 'values[user_id]', type => menu, value => $this->bocommon->make_menu_user($alarm_data['add_alarm']['user_list'], "1_3", 'values[user_id]'), label => $this->bocommon->choose_select($alarm_data['add_alarm']['user_list'], "name"), classname => actionsFilter, value_hidden => $this->bocommon->choose_select($alarm_data['add_alarm']['user_list'], "id")), array(id => 'values[add_alarm]', type => buttons, value => Add, label => $alarm_data[add_alarm][lang_add], funct => onAddClick, classname => actionButton, value_hidden => ""))));
     //_debug_array($alarm_data['add_alarm']['user_list']);die;
     //---datatable1 settings---------------------------------------------------
     $parameters['view'] = array('parameter' => array(array('name' => 'agreement_id', 'source' => 'agreement_id'), array('name' => 'id', 'source' => 'id')));
     $parameters['edit'] = array('parameter' => array(array('name' => 'agreement_id', 'source' => 'agreement_id'), array('name' => 'id', 'source' => 'id')));
     $parameters['delete'] = array('parameter' => array(array('name' => 'delete_item', 'source' => 1, 'ready' => 1), array('name' => 'id', 'source' => 'agreement_id'), array('name' => 'activity_id', 'source' => 'activity_id')));
     $permission_update = false;
     if ($this->acl_read && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
         $permissions['rowactions'][] = array('text' => lang('view'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.view_item')), 'parameters' => $parameters['view']);
     }
     if ($this->acl_edit && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
         $permissions['rowactions'][] = array('text' => lang('edit'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.edit_item')), 'parameters' => $parameters['edit']);
     }
     if ($this->acl_delete && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
         $permissions['rowactions'][] = array('text' => lang('delete'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.edit')), 'confirm_msg' => lang('do you really want to delete this entry'), 'parameters' => $parameters['delete']);
     }
     if ($this->acl_manage && (!isset($edit_item) || !$edit_item) && (!isset($view_only) || !$view_only)) {
         $permission_update = true;
     }
     $datavalues[1] = array('name' => "1", 'values' => json_encode($content), 'total_records' => count($content), 'permission' => json_encode($permissions['rowactions']), 'is_paginator' => 0, 'footer' => 1);
     $myColumnDefs[1] = array('name' => "1", 'values' => json_encode(array(array(key => id, label => $table_header[0]['header'], sortable => true, resizeable => true), array(key => num, label => $table_header[1]['header'], sortable => true, resizeable => true), array(key => descr, label => $table_header[2]['header'], sortable => true, resizeable => true), array(key => unit_name, label => $table_header[3]['header'], sortable => true, resizeable => true, formatter => FormatterCenter), array(key => m_cost, label => $table_header[4]['header'], sortable => true, resizeable => true, formatter => FormatterRight), array(key => w_cost, label => $table_header[5]['header'], sortable => true, resizeable => true, formatter => FormatterRight), array(key => total_cost, label => $table_header[6]['header'], sortable => true, resizeable => true, formatter => FormatterRight), array(key => this_index, label => $table_header[7]['header'], sortable => true, resizeable => true), array(key => index_count, label => $table_header[8]['header'], sortable => true, resizeable => true, formatter => FormatterCenter), array(key => index_date, label => $table_header[9]['header'], sortable => true, resizeable => true), $permission_update ? array(key => select, label => $table_header[13]['header'], sortable => false, resizeable => false, formatter => FormatterCheckItems) : "", array(key => activity_id, hidden => true), array(key => agreement_id, hidden => true))));
     $myButtons[2] = array('name' => "2", 'values' => json_encode(array(array(type => text, label => ' New index:', classname => 'index-opt'), array(id => 'values[new_index]', type => inputText, size => 12, classname => 'mybottonsUpdates'), array(id => 'values[update]', type => buttons, value => Update, label => lang('update'), funct => onUpdateClick, classname => ''))));
     $link_view_file = $GLOBALS['phpgw']->link('/index.php', $link_file_data);
     for ($z = 0; $z < count($agreement['files']); $z++) {
         $content_files[$z]['file_name'] = '<a href="' . $link_view_file . '&amp;file_name=' . $agreement['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click to view file') . '">' . $agreement['files'][$z]['name'] . '</a>';
         $content_files[$z]['delete_file'] = '<input type="checkbox" name="values[file_action][]" value="' . $agreement['files'][$z]['name'] . '" title="' . lang('Check to delete file') . '">';
     }
     $datavalues[2] = array('name' => "2", 'values' => json_encode($content_files), 'total_records' => count($content_files), 'permission' => "''", 'is_paginator' => 0, 'footer' => 0);
     $myColumnDefs[2] = array('name' => "2", 'values' => json_encode(array(array(key => file_name, label => lang('Filename'), sortable => false, resizeable => true), array(key => delete_file, label => lang('Delete file'), sortable => false, resizeable => true, formatter => FormatterCenter))));
     //----------------------------------------------datatable settings--------
     $data = array('property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'base_java_url' => json_encode(array(menuaction => "property.uiagreement.edit", id => $id)), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'allow_allrows' => true, 'allrows' => $this->allrows, 'start_record' => $this->start, 'record_limit' => $record_limit, 'num_records' => count($list), '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'), 'alarm_data' => $alarm_data, 'lang_alarm' => lang('Alarm'), 'lang_download' => 'download', 'link_download' => $GLOBALS['phpgw']->link('/index.php', $link_download), 'lang_download_help' => lang('Download table to your browser'), 'fileupload' => true, 'link_view_file' => $GLOBALS['phpgw']->link('/index.php', $link_file_data), 'files' => isset($agreement['files']) ? $agreement['files'] : '', 'lang_files' => lang('files'), 'lang_filename' => lang('Filename'), 'lang_file_action' => lang('Delete file'), 'lang_view_file_statustext' => lang('click to view file'), 'lang_file_action_statustext' => lang('Check to delete file'), 'lang_upload_file' => lang('Upload file'), 'lang_file_statustext' => lang('Select file to upload'), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'edit_url' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'lang_id' => lang('ID'), 'value_agreement_id' => $id, 'lang_category' => lang('category'), 'lang_save' => lang('save'), 'lang_cancel' => lang('cancel'), 'lang_apply' => lang('apply'), 'value_cat' => isset($agreement['cat']) ? $agreement['cat'] : '', 'lang_apply_statustext' => lang('Apply the values'), 'lang_cancel_statustext' => lang('Leave the agreement untouched and return back to the list'), 'lang_save_statustext' => lang('Save the agreement and return back to the list'), 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the category the agreement belongs to. To do not use a category select NO CATEGORY'), 'select_name' => 'values[cat_id]', 'cat_list' => $this->bocommon->select_category_list(array('format' => 'select', 'selected' => $this->cat_id, 'type' => 'branch', 'order' => 'descr')), 'lang_member_of' => lang('member of'), 'member_of_name' => 'member_id', 'member_of_list' => $member_of_data['cat_list'], 'attributes_group' => $attributes, 'lookup_functions' => isset($agreement['lookup_functions']) ? $agreement['lookup_functions'] : '', 'dateformat' => $dateformat, 'lang_datetitle' => lang('Select date'), 'lang_start_date_statustext' => lang('Select the estimated end date for the agreement'), 'lang_start_date' => lang('start date'), 'value_start_date' => $agreement['start_date'], 'lang_end_date_statustext' => lang('Select the estimated end date for the agreement'), 'lang_end_date' => lang('end date'), 'value_end_date' => $agreement['end_date'], 'lang_termination_date_statustext' => lang('Select the estimated termination date'), 'lang_termination_date' => lang('termination date'), 'value_termination_date' => $agreement['termination_date'], 'vendor_data' => $vendor_data, 'lang_name' => lang('name'), 'lang_name_statustext' => lang('name'), 'value_name' => $agreement['name'], 'lang_descr' => lang('descr'), 'lang_descr_statustext' => lang('descr'), 'value_descr' => $agreement['descr'], 'table_add' => $table_add, 'values' => $content, 'table_header' => $table_header, 'table_update' => $table_update, 'update_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiagreement.edit', 'id' => $id)), 'lang_select_all' => lang('Select All'), 'img_check' => $GLOBALS['phpgw']->common->get_image_path('property') . '/check.png', 'set_column' => $set_column, 'lang_agreement_group' => lang('Agreement group'), 'lang_no_agreement_group' => lang('Select agreement group'), 'agreement_group_list' => $this->bo->get_agreement_group_list($agreement['group_id']), 'lang_status' => lang('Status'), 'status_list' => $this->bo->select_status_list('select', $agreement['status']), 'status_name' => 'values[status]', 'lang_no_status' => lang('Select status'), '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, $active_tab));
     //_debug_array($data);die;
     //---datatable settings--------------------
     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');
     $GLOBALS['phpgw']->css->validate_file('datatable');
     $GLOBALS['phpgw']->css->validate_file('property');
     $GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
     $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', 'agreement.edit', 'property');
     //-----------------------datatable settings---
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('agreement') . ': ' . ($id ? lang('edit') . ' ' . lang($this->role) : lang('add') . ' ' . lang($this->role));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data));
 }
 /**
  * Prepare data for view and edit - depending on mode
  *
  * @param array  $values  populated object in case of retry
  * @param string $mode    edit or view
  * @param int    $id      entity id - no id means 'new'
  *
  * @return void
  */
 public function edit($values = array(), $mode = 'edit')
 {
     $id = (int) phpgw::get_var('id');
     if (!$this->acl_add && !$this->acl_edit) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uicondition_survey.view', 'id' => $id));
     }
     if ($mode == 'view') {
         if (!$this->acl_read) {
             $this->bocommon->no_access();
             return;
         }
     } else {
         if (!$this->acl_add && !$this->acl_edit) {
             $this->bocommon->no_access();
             return;
         }
     }
     phpgwapi_cache::session_clear('property.request', 'session_data');
     phpgwapi_yui::tabview_setup('survey_edit_tabview');
     $tabs = array();
     $tabs['generic'] = array('label' => lang('generic'), 'link' => '#generic');
     $active_tab = 'generic';
     $tabs['documents'] = array('label' => lang('documents'), 'link' => null);
     $tabs['request'] = array('label' => lang('request'), 'link' => null);
     $tabs['summation'] = array('label' => lang('summation'), 'link' => null);
     $tabs['import'] = array('label' => lang('import'), 'link' => null);
     if ($id) {
         if ($mode == 'edit') {
             $tabs['import']['link'] = '#import';
         }
         $tabs['documents']['link'] = '#documents';
         $tabs['request']['link'] = '#request';
         $tabs['summation']['link'] = '#summation';
         if (!$values) {
             $values = $this->bo->read_single(array('id' => $id, 'view' => $mode == 'view'));
         }
     }
     if (isset($values['location_code']) && $values['location_code']) {
         $values['location_data'] = execMethod('property.solocation.read_single', $values['location_code']);
     }
     $categories = $this->_get_categories($values['cat_id']);
     $bolocation = CreateObject('property.bolocation');
     $location_data = $bolocation->initiate_ui_location(array('values' => $values['location_data'], 'type_id' => 2, 'required_level' => 1, 'no_link' => $_no_link, 'lookup_type' => $mode == 'edit' ? 'form2' : 'view2', 'tenant' => false, 'lookup_entity' => array(), 'entity_data' => isset($values['p']) ? $values['p'] : ''));
     $msgbox_data = $this->bocommon->msgbox_data($this->receipt);
     $file_def = array(array('key' => 'file_name', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'delete_file', 'label' => lang('Delete file'), 'sortable' => false, 'resizeable' => true));
     $datatable_def = array();
     $datatable_def[] = array('container' => 'datatable-container_0', 'requestUrl' => json_encode(self::link(array('menuaction' => 'property.uicondition_survey.get_files', 'id' => $id, 'phpgw_return_as' => 'json'))), 'ColumnDefs' => $file_def);
     $related_def = array(array('key' => 'url', 'label' => lang('id'), 'sortable' => true, 'resizeable' => true), array('key' => 'title', 'label' => lang('title'), 'sortable' => false, 'resizeable' => true, 'width' => '100'), array('key' => 'status', 'label' => lang('status'), 'sortable' => true, 'resizeable' => true), array('key' => 'condition_degree', 'label' => lang('condition degree'), 'sortable' => false, 'resizeable' => true), array('key' => 'score', 'label' => lang('score'), 'sortable' => true, 'resizeable' => true), array('key' => 'amount_investment', 'label' => lang('investment'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'amount_operation', 'label' => lang('operation'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'amount_potential_grants', 'label' => lang('potential grants'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'recommended_year', 'label' => lang('recommended year'), 'sortable' => true, 'resizeable' => true), array('key' => 'planned_year', 'label' => lang('planned year'), 'sortable' => true, 'resizeable' => true), array('key' => 'related', 'label' => lang('related'), 'sortable' => false, 'resizeable' => true));
     $datatable_def[] = array('container' => 'datatable-container_1', 'requestUrl' => json_encode(self::link(array('menuaction' => 'property.uicondition_survey.get_request', 'id' => $id, 'phpgw_return_as' => 'json'))), 'ColumnDefs' => $related_def);
     $summation_def = array(array('key' => 'building_part', 'label' => lang('building part'), 'sortable' => false, 'resizeable' => true), array('key' => 'category', 'label' => lang('category'), 'sortable' => true, 'resizeable' => true), array('key' => 'period_1', 'label' => lang('year') . ':: < 1', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'period_2', 'label' => lang('year') . ':: 1 - 5', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'period_3', 'label' => lang('year') . ':: 6 - 10', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'period_4', 'label' => lang('year') . ':: 11 - 15', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'period_5', 'label' => lang('year') . ':: 16 - 20', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'period_6', 'label' => lang('year') . ':: 21 +', 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'), array('key' => 'sum', 'label' => lang('sum'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'YAHOO.portico.FormatterAmount0'));
     $datatable_def[] = array('container' => 'datatable-container_2', 'requestUrl' => json_encode(self::link(array('menuaction' => 'property.uicondition_survey.get_summation', 'id' => $id, 'phpgw_return_as' => 'json'))), 'ColumnDefs' => $summation_def);
     $this->config = CreateObject('phpgwapi.config', 'property');
     $this->config->read();
     $data = array('datatable_def' => $datatable_def, 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'survey' => $values, 'location_data2' => $location_data, 'lang_coordinator' => isset($this->config->config_data['lang_request_coordinator']) && $this->config->config_data['lang_request_coordinator'] ? $this->config->config_data['lang_request_coordinator'] : lang('coordinator'), 'categories' => array('options' => $categories), 'status_list' => array('options' => execMethod('property.bogeneric.get_list', array('type' => 'condition_survey_status', 'selected' => $values['status_id'], 'add_empty' => true))), 'editable' => $mode == 'edit', 'tabs' => phpgwapi_yui::tabview_generate($tabs, $active_tab), 'multiple_uploader' => $mode == 'edit' ? true : '');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . '::' . lang('condition survey');
     if ($mode == 'edit') {
         $GLOBALS['phpgw']->jqcal->add_listener('report_date');
         phpgwapi_jquery::load_widget('core');
         self::add_javascript('property', 'portico', 'condition_survey_edit.js');
         self::add_javascript('phpgwapi', 'yui3', 'yui/yui-min.js');
         self::add_javascript('phpgwapi', 'yui3-gallery', 'gallery-formvalidator/gallery-formvalidator-min.js');
         $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yui3-gallery/gallery-formvalidator/validatorCss.css');
     }
     self::add_javascript('property', 'portico', 'condition_survey.js');
     self::add_javascript('phpgwapi', 'tinybox2', 'packed.js');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
     //			$GLOBALS['phpgw_info']['server']['no_jscombine'] = true;
     self::render_template_xsl(array('condition_survey'), $data);
 }
Exemple #15
0
<?php

//include common logic for all templates
include "common.php";
phpgwapi_yui::load_widget('tabview');
phpgwapi_yui::tabview_setup('party_edit_tabview');
?>

<?php 
echo rental_uicommon::get_page_error($error);
echo rental_uicommon::get_page_message($message);
?>

<div class="identifier-header">
	<h1><img src="<?php 
echo RENTAL_TEMPLATE_PATH;
?>
images/32x32/custom/contact.png" /><?php 
echo lang('party');
?>
</h1>
	<div>
		<button onclick="javascript: window.location.href='<?php 
echo $cancel_link;
?>
;'">&laquo;&nbsp;<?php 
echo lang('party_back');
?>
</button><br/>
		<label><?php 
echo lang('name');
 /**
  * Generate a user edit form
  *
  * @param object $user   the user account object to be edited
  * @param array  $errors any error messages that should be shown to the user
  *
  * @return null
  */
 protected function _user_form($user, $errors = array())
 {
     $account_id = $user->id;
     $user_data = $user->toArray();
     $account = createObject('phpgwapi.accounts', $account_id, 'u');
     $sbox = CreateObject('phpgwapi.sbox');
     $GLOBALS['phpgw']->xslttpl->add_file('users');
     // no point in wasting loops
     $GLOBALS['phpgw']->xslttpl->add_file('msgbox', PHPGW_TEMPLATE_DIR, 3);
     $acl = createObject('phpgwapi.acl', $account_id);
     $user_data['status'] = 'A';
     $user_data['anonymous'] = false;
     $user_data['changepassword'] = true;
     $user_data['account_permissions'] = array();
     $user_groups = array();
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('administration') . ': ';
     if ($account_id) {
         $user_data['anonymous'] = $acl->check('anonymous', 1, 'phpgwapi');
         $user_data['changepassword'] = $acl->check('changepassword', 1, 'preferences');
         $user_data['account_permissions'] = $this->_bo->load_apps($account_id);
         $user_groups = $account->membership($account_id);
         $GLOBALS['phpgw_info']['flags']['app_header'] .= lang('edit user account');
     } else {
         $GLOBALS['phpgw_info']['flags']['app_header'] .= lang('add user account');
     }
     if (!$user_data['expires']) {
         // we assume this is a sane value
         $user_data['expires'] = time() + $GLOBALS['phpgw_info']['server']['auto_create_expire'];
     }
     if ($user_data['expires'] == -1) {
         $user_data['account_expires_month'] = 0;
         $user_data['account_expires_day'] = 0;
         $user_data['account_expires_year'] = 0;
     } else {
         $user_data['account_expires_month'] = date('m', $user_data['expires']);
         $user_data['account_expires_day'] = date('d', $user_data['expires']);
         $user_data['account_expires_year'] = date('Y', $user_data['expires']);
     }
     $homedirectory = '';
     $loginshell = '';
     $lang_homedir = '';
     $lang_shell = '';
     if ($this->_ldap_extended) {
         $server =& $GLOBALS['phpgw_info']['server'];
         if (!$account_id) {
             $user_data['homedirectory'] = "{$server['ldap_account_home']}/{$account_lid}";
             $user_data['loginshell'] = $server['ldap_account_shell'];
         }
         $lang_homedir = lang('home directory');
         $lang_shell = lang('login shell');
         $homedirectory = "<input name=\"homedirectory\" value=\"{$user_data['homedirectory']}\">";
         $loginshell = "<input name=\"loginshell\" value=\"{$user_data['loginshell']}\">";
     }
     $add_masters = $GLOBALS['phpgw']->acl->get_ids_for_location('addressmaster', 7, 'addressbook');
     $add_users = $GLOBALS['phpgw']->accounts->return_members($add_masters);
     $masters = $add_users['users'];
     if (is_array($masters) && in_array($GLOBALS['phpgw_info']['user']['account_id'], $masters)) {
         if ($user_data['person_id']) {
             $url_contacts_text = lang('Edit entry');
             $url_contacts = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.edit_person', 'ab_id' => $user_data['person_id'], 'referer' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.edit_user', 'account_id' => $account_id))));
         } else {
             $url_contacts_text = lang('This account has no contact entry yet');
             $url_contacts = '#';
         }
     } else {
         $url_contacts_text = lang('You do not have edit access to addressmaster contacts');
         $url_contacts = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaclmanager.edit_addressmasters', 'account_id' => $GLOBALS['phpgw_info']['user']['account_id'], 'referer' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.edit_user', 'account_id' => $account_id))));
     }
     $_y = $sbox->getyears('account_expires_year', $user_data['account_expires_year'], date('Y'), date('Y') + 10);
     $_m = $sbox->getmonthtext('account_expires_month', $user_data['account_expires_month']);
     $_d = $sbox->getdays('account_expires_day', $user_data['account_expires_day']);
     $group_list = array();
     $all_groups = $account->get_list('groups');
     if (!$GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin')) {
         $available_apps = $GLOBALS['phpgw_info']['apps'];
         $valid_groups = array();
         foreach ($available_apps as $_app => $dummy) {
             if ($GLOBALS['phpgw']->acl->check('admin', phpgwapi_acl::ADD, $_app)) {
                 $valid_groups = array_merge($valid_groups, $GLOBALS['phpgw']->acl->get_ids_for_location('run', phpgwapi_acl::READ, $_app));
             }
         }
         $valid_groups = array_unique($valid_groups);
     } else {
         $valid_groups = array_keys($all_groups);
     }
     foreach ($all_groups as $group) {
         $group_list[$group->id] = array('account_id' => $group->id, 'account_lid' => $group->__toString(), 'i_am_admin' => in_array($group->id, $valid_groups));
     }
     $group_ids = array_keys($group_list);
     foreach ($user_groups as $group) {
         $group_list[$group->id]['selected'] = in_array($group->id, $group_ids);
     }
     $_group_list = array();
     foreach ($group_list as $group) {
         $_group_list[] = $group;
     }
     unset($group_list);
     unset($group_ids);
     /* create list of available apps */
     $apps = createObject('phpgwapi.applications', $account_id ? $account_id : -1);
     $db_perms = $apps->read_account_specific();
     $apps_admin = $GLOBALS['phpgw']->acl->get_app_list_for_id('admin', phpgwapi_acl::ADD, $account_id ? $account_id : -1);
     $available_apps = $GLOBALS['phpgw_info']['apps'];
     asort($available_apps);
     if (!$GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin')) {
         $valid_apps = $GLOBALS['phpgw']->acl->get_app_list_for_id('admin', phpgwapi_acl::ADD, $GLOBALS['phpgw_info']['user']['account_id']);
     } else {
         $valid_apps = array_keys($available_apps);
     }
     foreach ($available_apps as $key => $application) {
         if ($application['enabled'] && $application['status'] != 3) {
             $perm_display[] = array('app_name' => $key, 'translated_name' => lang($key));
         }
     }
     asort($perm_display);
     $app_list = array();
     foreach ($perm_display as $perm) {
         $checked = false;
         if (isset($user_data['account_permissions'][$perm['app_name']]) && $user_data['account_permissions'][$perm['app_name']] || isset($db_perms[$perm['app_name']]) && $db_perms[$perm['app_name']]) {
             $checked = true;
         }
         $app_list[] = array('app_title' => $perm['translated_name'], 'checkbox_name' => "account_permissions[{$perm['app_name']}]", 'checked' => $checked, 'checkbox_name_admin' => "account_permissions_admin[{$perm['app_name']}]", 'checked_admin' => in_array($perm['app_name'], $apps_admin), 'i_am_admin' => in_array($perm['app_name'], $valid_apps));
     }
     $tabs = array('data' => array('label' => lang('user data'), 'link' => '#user'), 'groups' => array('label' => lang('groups'), 'link' => '#groups'), 'apps' => array('label' => lang('applications'), 'link' => '#apps'));
     phpgwapi_yui::tabview_setup('account_edit_tabview');
     $data = array('page_title' => $account_id ? lang('edit user') : lang('add user'), 'msgbox_data' => array('msgbox_text' => $GLOBALS['phpgw']->common->error_list($errors)), 'edit_url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiaccounts.edit_user')), 'lang_lid' => lang('loginid'), 'lang_account_active' => lang('account active'), 'lang_anonymous' => lang('Anonymous User (not shown in list sessions)'), 'lang_changepassword' => lang('Can change password'), 'lang_contact' => lang('contact'), 'lang_password' => lang('password'), 'lang_reenter_password' => lang('Re-Enter Password'), 'lang_lastname' => lang('lastname'), 'lang_groups' => lang('groups'), 'lang_expires' => lang('expires'), 'lang_firstname' => lang('firstname'), 'lang_applications' => lang('applications'), 'lang_quota' => lang('quota'), 'lang_save' => lang('save'), 'lang_cancel' => lang('cancel'), 'select_expires' => $GLOBALS['phpgw']->common->dateformatorder($_y, $_m, $_d, true), 'lang_never' => lang('Never'), 'account_id' => $account_id, 'account_lid' => $user_data['lid'], 'lang_homedir' => $lang_homedir, 'lang_shell' => $lang_shell, 'homedirectory' => $homedirectory, 'loginshell' => $loginshell, 'account_enabled' => (int) $user_data['enabled'], 'account_firstname' => $user_data['firstname'], 'account_lastname' => $user_data['lastname'], 'account_passwd' => '', 'account_passwd_2' => '', 'account_quota' => $user_data['quota'], 'anonymous' => (int) $user_data['anonymous'], 'changepassword' => (int) $user_data['changepassword'], 'expires_never' => $user_data['expires'] == -1, 'group_list' => $_group_list, 'app_list' => $app_list, 'url_contacts' => $url_contacts, 'url_contacts_text' => $url_contacts_text, 'tabs' => phpgwapi_yui::tabview_generate($tabs, 'data'));
     /*
     	create the menu on the left, if needed
     	$menuClass = CreateObject('admin.uimenuclass');
     	This is now using ExecMethod()
     	$t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_user'));
     */
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('account_edit' => $data));
 }
 /**
  * Public method. Called when a user wants to view information about a control group.
  * @param HTTP::id	the control_group ID
  */
 public function view()
 {
     $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . lang('view');
     $entity_so = CreateObject('property.soadmin_entity');
     $tabs = array('control_group' => array('label' => lang('Control_group'), 'link' => '#control_group'), 'control_items' => array('label' => lang('Control_items'), 'link' => '#control_items'));
     //Retrieve the control_group object
     $control_group_id = (int) phpgw::get_var('id');
     if (isset($_POST['edit_control_group'])) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uicontrol_group.edit', 'id' => $control_group_id));
     } else {
         if (isset($control_group_id) && $control_group_id > 0) {
             $control_group = $this->so->get_single($control_group_id);
             //var_dump($control_group);
         } else {
             $this->render('permission_denied.php', array('error' => lang('invalid_request')));
             return;
         }
         //var_dump($control_group);
         if ($this->flash_msgs) {
             $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
             $msgbox_data = $GLOBALS['phpgw']->common->msgbox($msgbox_data);
         }
         $control_group_array = $control_group->toArray();
         //var_dump($control_group_array);
         $loc_arr = $GLOBALS['phpgw']->locations->get_name($control_group->get_component_location_id());
         $entity_arr = explode('.', $loc_arr['location']);
         $entity = $entity_so->read_single($entity_arr[2]);
         $category = $entity_so->read_single_category($entity_arr[2], $entity_arr[3]);
         $custom = createObject('phpgwapi.custom_fields');
         $attributes = $custom->find('property', ".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0, '', '', '', true, true);
         $operator1 = array(array('id' => 'eq', 'name' => '='));
         $operator2 = array(array('id' => 'eq', 'name' => '='), array('id' => 'lt', 'name' => '<'), array('id' => 'gt', 'name' => '>'));
         $component_criteria = $control_group->get_component_criteria();
         foreach ($attributes as $key => &$a) {
             switch ($a['datatype']) {
                 case 'LB':
                 case 'R':
                 case 'CH':
                     $a['operator'] = array('options' => $operator1);
                     break;
                 default:
                     $a['operator'] = array('options' => $operator2);
             }
             if (isset($component_criteria[$key]['value']) && $component_criteria[$key]['value']) {
                 $a['value'] = $component_criteria[$key]['value'];
                 if (isset($a['choice']) && $a['choice']) {
                     foreach ($a['choice'] as &$choise) {
                         $choise['selected'] = $choise['id'] == $component_criteria[$key]['value'] ? 1 : 0;
                     }
                 }
             }
             if (isset($component_criteria[$key]['operator']) && $component_criteria[$key]['operator']) {
                 if (isset($a['operator']) && $a['operator']) {
                     foreach ($a['operator']['options'] as &$_operator) {
                         $_operator['selected'] = $_operator['id'] == $component_criteria[$key]['operator'] ? 1 : 0;
                     }
                 }
             }
         }
         $control_items_array = $this->so_control_item_list->get_control_items($control_group_id);
         $control_items = array();
         foreach ($control_items_array as $control_item) {
             $control_items[] = $control_item->serialize();
         }
         phpgwapi_yui::tabview_setup('control_group_tabview');
         $data = array('tabs' => phpgwapi_yui::tabview_generate($tabs, 'control_group'), 'value_id' => !empty($control_group) ? $control_group->get_id() : 0, 'control_group' => $control_group_array, 'entity' => $entity, 'category' => $category, 'attributes' => $attributes, 'selected_control_items' => $control_items);
         $GLOBALS['phpgw_info']['flags']['app_header'] = lang('controller') . '::' . lang('Control group');
         self::add_javascript('controller', 'yahoo', 'control_tabs.js');
         self::render_template_xsl(array('control_group/control_group_tabs', 'control_group/control_group', 'control_group/control_group_items'), $data);
     }
 }
 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));
 }
Exemple #19
0
<?php

include "common.php";
phpgwapi_yui::load_widget('tabview');
phpgwapi_yui::tabview_setup('result_unit_tabview');
$config = CreateObject('phpgwapi.config', 'rental');
$config->read();
?>

<?php 
echo rental_uicommon::get_page_error($error);
echo rental_uicommon::get_page_message($message);
?>

<!-- HOPPET OVER WARNINGS FORELØPIG -->

<div class="identifier-header">
	<h1><img src="<?php 
echo RENTAL_TEMPLATE_PATH;
?>
images/32x32/apps/system-users.png" /> <?php 
echo lang('result_unit');
?>
</h1>
	<div style="float: left; width: 50%;">
		<button onclick="javascript:window.location.href ='<?php 
echo $cancel_link;
?>
;'">&laquo;&nbsp;<?php 
echo lang('result_unit_back');
?>