public function __construct()
 {
     parent::__construct();
     $read = $GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');
     //1
     $add = $GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');
     //2
     $edit = $GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');
     //4
     $delete = $GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');
     //8
     $manage = $GLOBALS['phpgw']->acl->check('.control', 16, 'controller');
     //16
     $this->so = CreateObject('controller.socheck_list');
     $this->so_control = CreateObject('controller.socontrol');
     $this->so_control_group = CreateObject('controller.socontrol_group');
     $this->so_control_group_list = CreateObject('controller.socontrol_group_list');
     $this->so_control_item = CreateObject('controller.socontrol_item');
     $this->so_check_list = CreateObject('controller.socheck_list');
     $this->so_check_item = CreateObject('controller.socheck_item');
     $this->location_finder = new location_finder();
     self::set_active_menu('controller::location_check_list');
     if (phpgw::get_var('noframework', 'bool')) {
         $GLOBALS['phpgw_info']['flags']['noframework'] = true;
         phpgwapi_cache::session_set('controller', 'noframework', true);
     } else {
         if (phpgwapi_cache::session_get('controller', 'noframework')) {
             $GLOBALS['phpgw_info']['flags']['noframework'] = true;
         }
     }
 }
 public function index()
 {
     if (!$this->acl_read) {
         echo lang('no access');
         $GLOBALS['phpgw']->common->phpgw_exit();
     }
     $app = phpgw::get_var('app', 'string', 'GET');
     //get session's values
     $data = phpgwapi_cache::session_get($app, 'id_debug');
     if (isset($data)) {
         //clear session
         phpgwapi_cache::session_clear($app, 'id_debug');
         //replace '<' and '>'
         if (is_array($data)) {
             self::_my_print_rec($data, 0);
         } else {
             $data = htmlspecialchars($data);
         }
         _debug_array($data);
     } else {
         echo "empty session's value";
     }
     $GLOBALS['phpgw']->common->phpgw_exit();
 }
Exemplo n.º 3
0
function parse_navbar($force = False)
{
    $navbar = array();
    $navbar = execMethod('phpgwapi.menu.get', 'navbar');
    $user = $GLOBALS['phpgw']->accounts->get($GLOBALS['phpgw_info']['user']['id']);
    $var = array('print_url' => strpos($_SERVER['REQUEST_URI'], '?') ? "{$_SERVER['REQUEST_URI']}&phpgw_return_as=noframes" : "{$_SERVER['REQUEST_URI']}?phpgw_return_as=noframes", 'print_text' => lang('print'), 'home_url' => $GLOBALS['phpgw']->link('/home.php'), 'home_text' => lang('home'), 'home_icon' => 'icon icon-home', 'about_url' => $GLOBALS['phpgw']->link('/about.php', array('app' => $GLOBALS['phpgw_info']['flags']['currentapp'])), 'about_text' => lang('about'), 'logout_url' => $GLOBALS['phpgw']->link('/logout.php'), 'logout_text' => lang('logout'), 'user_fullname' => $user->__toString());
    if ($GLOBALS['phpgw']->acl->check('run', PHPGW_ACL_READ, 'preferences')) {
        $var['preferences_url'] = $GLOBALS['phpgw']->link('/preferences/index.php');
        $var['preferences_text'] = lang('preferences');
    }
    if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) {
        $var['help_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')";
        $var['help_text'] = lang('help');
        $var['help_icon'] = 'icon icon-help';
    }
    if (isset($GLOBALS['phpgw_info']['server']['support_address']) && $GLOBALS['phpgw_info']['server']['support_address']) {
        $var['support_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uisupport.send', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'])) . "','700','600')";
        $var['support_text'] = lang('support');
        $var['support_icon'] = 'icon icon-help';
    }
    if (isset($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
        $var['debug_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uidebug_json.index', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'])) . "','','')";
        $var['debug_text'] = lang('debug');
        $var['debug_icon'] = 'icon icon-debug';
    }
    $GLOBALS['phpgw']->template->set_root(PHPGW_TEMPLATE_DIR);
    $GLOBALS['phpgw']->template->set_file('navbar', 'navbar.tpl');
    $flags =& $GLOBALS['phpgw_info']['flags'];
    $var['current_app_title'] = isset($flags['app_header']) ? $flags['app_header'] : lang($GLOBALS['phpgw_info']['flags']['currentapp']);
    $flags['menu_selection'] = isset($flags['menu_selection']) ? $flags['menu_selection'] : '';
    // breadcrumbs
    $current_url = array('id' => $flags['menu_selection'], 'url' => phpgw::get_var('REQUEST_URI', 'string', 'SERVER'), 'name' => $var['current_app_title']);
    $breadcrumbs = phpgwapi_cache::session_get('phpgwapi', 'breadcrumbs');
    $breadcrumbs = $breadcrumbs ? $breadcrumbs : array();
    // first one
    if ($breadcrumbs[0]['id'] != $flags['menu_selection']) {
        array_unshift($breadcrumbs, $current_url);
    }
    if (count($breadcrumbs) >= 5) {
        array_pop($breadcrumbs);
    }
    phpgwapi_cache::session_set('phpgwapi', 'breadcrumbs', $breadcrumbs);
    $breadcrumbs = array_reverse($breadcrumbs);
    $navigation = array();
    if (!isset($GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar']) || $GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar'] != 'yes') {
        prepare_navbar($navbar);
    } else {
        foreach ($navbar as &$app_tmp) {
            $app_tmp['text'] = ' ...';
        }
    }
    if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent'] == 'ajax_menu') {
        $exclude = array('logout', 'about', 'preferences');
        $i = 1;
        foreach ($navbar as $app => $app_data) {
            if (in_array($app, $exclude)) {
                continue;
            }
            $applications[] = array('value' => array('id' => $i, 'app' => $app, 'label' => $app_data['text'], 'href' => str_replace('&amp;', '&', $app_data['url'])), 'children' => array());
            $mapping[$i] = array('id' => $i, 'name' => $app, 'expanded' => false, 'highlight' => $app == $currentapp ? true : false, 'is_leaf' => false);
            $i++;
        }
        $applications = json_encode($applications);
        $mapping = json_encode($mapping);
        $_menu_selection = str_replace('::', '|', $GLOBALS['phpgw_info']['flags']['menu_selection']);
        $var['treemenu'] = <<<HTML
\t\t\t\t<div id="MenutreeDiv1"></div>
\t\t\t\t<script type="text/javascript">
\t\t \t\t\tvar apps = {$applications};
\t\t\t\t\tvar mapping = {$mapping};
\t\t\t\t\tvar proxy_data = ['first_element_is_dummy'];
\t\t\t\t\tvar menu_selection = '{$_menu_selection}';
\t\t\t\t</script>
HTML;
    } else {
        //			prepare_navbar($navbar);
        $navigation = execMethod('phpgwapi.menu.get', 'navigation');
        $treemenu = '';
        foreach ($navbar as $app => $app_data) {
            if (!in_array($app, array('logout', 'about', 'preferences'))) {
                $submenu = isset($navigation[$app]) ? render_submenu($app, $navigation[$app]) : '';
                $treemenu .= render_item($app_data, "navbar::{$app}", $submenu);
            }
        }
        $var['treemenu'] = <<<HTML
\t\t\t<ul id="navbar">
{$treemenu}
\t\t\t</ul>

HTML;
    }
    if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent'] == 'jsmenu') {
        $var['treemenu'] .= <<<JS
\t\t\t\t<script type="text/javascript">
\t\t\t\t\$(function() {
\t\t\t\t\$("#navbar").menu();
\t\t\t});
\t\t\t</script>
JS;
    }
    $GLOBALS['phpgw']->template->set_var($var);
    $GLOBALS['phpgw']->template->pfp('out', 'navbar');
    if (phpgw::get_var('phpgw_return_as') != 'json' && ($global_message = phpgwapi_cache::system_get('phpgwapi', 'phpgw_global_message'))) {
        echo "<div class='msg_good'>";
        echo nl2br($global_message);
        echo '</div>';
    }
    if (phpgw::get_var('phpgw_return_as') != 'json' && $breadcrumbs && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_breadcrumbs']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_breadcrumbs']) {
        $history_url = array();
        foreach ($breadcrumbs as $breadcrumb) {
            $history_url[] = "<a href='{$breadcrumb['url']}'>{$breadcrumb['name']}</a>";
        }
        $breadcrumbs = '<div class="breadcrumbs"><h4>' . implode(' >> ', $history_url) . '</h4></div>';
        echo $breadcrumbs;
    }
    if (phpgw::get_var('phpgw_return_as') != 'json' && ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))) {
        phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
        $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt);
        $msgbox_data = $GLOBALS['phpgw']->common->msgbox($msgbox_data);
        foreach ($msgbox_data as &$message) {
            echo "<div class='{$message['msgbox_class']}'>";
            echo $message['msgbox_text'];
            echo '</div>';
        }
    }
    $GLOBALS['phpgw']->hooks->process('after_navbar');
    register_shutdown_function('parse_footer_end');
}
Exemplo n.º 4
0
 /**
  * Check to see if a session is still current and valid
  *
  * @param string $sessionid session id to be verfied
  *
  * @return bool is the session valid?
  */
 public function verify($sessionid = '')
 {
     if (empty($sessionid) || !$sessionid) {
         $sessionid = phpgw::get_var(session_name());
     }
     if (!$sessionid) {
         return false;
     }
     $this->_sessionid = $sessionid;
     $session = $this->read_session($sessionid);
     $this->_session_flags = $session['session_flags'];
     $lid_data = explode('#', $session['session_lid']);
     $this->_account_lid = $lid_data[0];
     if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ntlm') {
         $timeout = time() - $GLOBALS['phpgw_info']['server']['sessions_timeout'];
         if (!isset($session['session_dla']) || $session['session_dla'] <= $timeout) {
             if (isset($session['session_dla'])) {
                 if (is_object($GLOBALS['phpgw']->log)) {
                     $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, session for %1 is expired by %2 sec, inactive for %3 sec', 'p1' => $this->_account_lid, 'p2' => $timeout - $session['session_dla'], 'p3' => time() - $session['session_dla'], 'line' => __LINE__, 'file' => __FILE__));
                     $GLOBALS['phpgw']->log->commit();
                 }
                 if (is_object($GLOBALS['phpgw']->crypto)) {
                     $GLOBALS['phpgw']->crypto->cleanup();
                     unset($GLOBALS['phpgw']->crypto);
                 }
                 $this->cd_reason = 10;
             }
             return false;
         }
     }
     if (isset($lid_data[1])) {
         $this->_account_domain = $lid_data[1];
     } else {
         $this->_account_domain = $GLOBALS['phpgw_info']['server']['default_domain'];
     }
     unset($lid_data);
     $this->update_dla();
     $this->_account_id = $GLOBALS['phpgw']->accounts->name2id($this->_account_lid);
     if (!$this->_account_id) {
         $this->cd_reason = 5;
         return false;
     }
     $GLOBALS['phpgw_info']['user']['account_id'] = $this->_account_id;
     /* init the crypto object before appsession call below */
     //$this->_key = md5($this->_sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']); //Sigurd: not good for permanent data
     $this->_key = $GLOBALS['phpgw_info']['server']['encryptkey'];
     $this->_iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
     $GLOBALS['phpgw']->crypto->init(array($this->_key, $this->_iv));
     $use_cache = false;
     if (isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info'])) {
         $use_cache = !!$GLOBALS['phpgw_info']['server']['cache_phpgw_info'];
     }
     $this->read_repositories($use_cache);
     if ($this->_data['expires'] != -1 && $this->_data['expires'] < time()) {
         if (is_object($GLOBALS['phpgw']->log)) {
             $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, account loginid %1 is expired', 'p1' => $this->_account_lid, 'line' => __LINE__, 'file' => __FILE__));
             $GLOBALS['phpgw']->log->commit();
         }
         if (is_object($GLOBALS['phpgw']->crypto)) {
             $GLOBALS['phpgw']->crypto->cleanup();
             unset($GLOBALS['phpgw']->crypto);
         }
         $this->cd_reason = 2;
         return false;
     }
     $GLOBALS['phpgw_info']['user'] = $this->_data;
     //		$GLOBALS['phpgw_info']['hooks'] = $this->hooks;
     $GLOBALS['phpgw_info']['user']['session_ip'] = $session['session_ip'];
     $GLOBALS['phpgw_info']['user']['passwd'] = phpgwapi_cache::session_get('phpgwapi', 'password');
     if ($this->_account_domain != $GLOBALS['phpgw_info']['user']['domain']) {
         if (is_object($GLOBALS['phpgw']->log)) {
             $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, the domains %1 and %2 don\'t match', 'p1' => $this->_account_domain, 'p2' => $GLOBALS['phpgw_info']['user']['domain'], 'line' => __LINE__, 'file' => __FILE__));
             $GLOBALS['phpgw']->log->commit();
         }
         if (is_object($GLOBALS['phpgw']->crypto)) {
             $GLOBALS['phpgw']->crypto->cleanup();
             unset($GLOBALS['phpgw']->crypto);
         }
         $this->cd_reason = 5;
         return false;
     }
     // verify the user agent in an attempt to stop session hijacking
     if ($_SESSION['phpgw_session']['user_agent'] != md5(phpgw::get_var('USER_AGENT', 'string', 'SERVER'))) {
         if (is_object($GLOBALS['phpgw']->log)) {
             // This needs some better wording
             $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, User agent hash %1 doesn\'t match user agent hash %2 in session', 'p1' => $_SESSION['phpgw_session']['user_agent'], 'p2' => md5(phpgw::get_var('USER_AGENT', 'string', 'SERVER')), 'line' => __LINE__, 'file' => __FILE__));
             $GLOBALS['phpgw']->log->commit();
         }
         if (is_object($GLOBALS['phpgw']->crypto)) {
             $GLOBALS['phpgw']->crypto->cleanup();
             unset($GLOBALS['phpgw']->crypto);
         }
         // generic session can't be verified error - don't be specific about the problem
         $this->cd_reason = 2;
         return false;
     }
     $check_ip = false;
     if (isset($GLOBALS['phpgw_info']['server']['sessions_checkip'])) {
         $check_ip = !!$GLOBALS['phpgw_info']['server']['sessions_checkip'];
     }
     if ($check_ip) {
         if (PHP_OS != 'Windows' && (!$GLOBALS['phpgw_info']['user']['session_ip'] || $GLOBALS['phpgw_info']['user']['session_ip'] != $this->_get_user_ip())) {
             if (is_object($GLOBALS['phpgw']->log)) {
                 // This needs some better wording
                 $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, IP %1 doesn\'t match IP %2 in session', 'p1' => $this->_get_user_ip(), 'p2' => $GLOBALS['phpgw_info']['user']['session_ip'], 'line' => __LINE__, 'file' => __FILE__));
                 $GLOBALS['phpgw']->log->commit();
             }
             if (is_object($GLOBALS['phpgw']->crypto)) {
                 $GLOBALS['phpgw']->crypto->cleanup();
                 unset($GLOBALS['phpgw']->crypto);
             }
             $this->cd_reason = 2;
             return false;
         }
     }
     /*
     			$GLOBALS['phpgw']->acl->set_account_id($this->_account_id);
     			$GLOBALS['phpgw']->accounts->set_account($this->_account_id);
     			$GLOBALS['phpgw']->preferences->set_account_id($this->_account_id);
     			$GLOBALS['phpgw']->applications->set_account_id($this->_account_id);
     */
     $GLOBALS['phpgw']->translation->populate_cache();
     if (!$this->_account_lid) {
         if (is_object($GLOBALS['phpgw']->log)) {
             // This needs some better wording
             $GLOBALS['phpgw']->log->message(array('text' => 'W-VerifySession, account_id is empty', 'line' => __LINE__, 'file' => __FILE__));
             $GLOBALS['phpgw']->log->commit();
         }
         if (is_object($GLOBALS['phpgw']->crypto)) {
             $GLOBALS['phpgw']->crypto->cleanup();
             unset($GLOBALS['phpgw']->crypto);
         }
         return false;
     }
     return true;
 }
Exemplo n.º 5
0
 public function get_local_menu_ajax()
 {
     $node = phpgw::get_var('node');
     $selection = explode('|', $node);
     $app = $selection[0];
     if (!isset($GLOBALS['phpgw_info']['user']['apps'][$app])) {
         return array();
     }
     $menu = array();
     $_section = 'navigation';
     if ($app == 'admin') {
         if (!isset($selection[1])) {
             $navbar = $this->get('navbar');
             $navigation = $this->get('admin');
             foreach ($GLOBALS['phpgw_info']['user']['apps'] as $_app => $app_info) {
                 if (!in_array($_app, array('logout', 'about', 'preferences')) && isset($navbar[$_app])) {
                     if (isset($navigation[$_app])) {
                         $menu[] = array('key' => $_app, 'is_leaf' => count($navigation[$_app]) > 1 ? false : true, 'text' => $GLOBALS['phpgw']->translation->translate($_app, array(), true), 'url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiconfig.index', 'appname' => $_app)));
                     }
                 }
             }
             return $menu;
         } else {
             $_section = 'admin';
             $app = $selection[1];
             array_shift($selection);
         }
     }
     if (!($menu_gross = phpgwapi_cache::session_get('phpgwapi', "menu_{$app}"))) {
         $menu_gross = execMethod("{$app}.menu.get_menu");
         phpgwapi_cache::session_set('phpgwapi', "menu_{$app}", $menu_gross);
     }
     $menu_gross = $menu_gross[$_section];
     $count_selection = count($selection);
     if ($count_selection > 1) {
         for ($i = 1; $i < count($selection); $i++) {
             if (isset($menu_gross[$selection[$i]])) {
                 $menu_gross = $menu_gross[$selection[$i]];
             } else {
                 if (isset($menu_gross['children'][$selection[$i]])) {
                     $menu_gross = $menu_gross['children'][$selection[$i]];
                 } else {
                     $menu_gross = array();
                 }
             }
         }
         $children = isset($menu_gross['children']) ? $menu_gross['children'] : array();
     } else {
         $children = $menu_gross;
     }
     $i = 0;
     foreach ($children as $key => $vals) {
         $vals['url'] = str_replace('&amp;', '&', $vals['url']);
         $menu[$i] = $vals;
         $menu[$i]['key'] = $key;
         $menu[$i]['is_leaf'] = true;
         if (isset($menu[$i]['children'])) {
             $menu[$i]['is_leaf'] = false;
             unset($menu[$i]['children']);
         }
         $i++;
     }
     return $menu;
 }
<form id="<?php 
    echo $list_id;
    ?>
_form" method="GET">
<?php 
    $populate = phpgw::get_var('populate_form');
    //Avoid Notices
    $q = false;
    $s_type = false;
    $status = false;
    $status_contract = false;
    if (isset($populate)) {
        $q = phpgwapi_cache::session_get('rental', 'composite_query');
        $s_type = phpgwapi_cache::session_get('rental', 'composite_search_type');
        $status = phpgwapi_cache::session_get('rental', 'composite_status');
        $status_contract = phpgwapi_cache::session_get('rental', 'composite_status_contract');
    }
    ?>
	<fieldset>
		<!-- Search -->
		<h3><?php 
    echo lang('search_options');
    ?>
</h3>
		<label for="ctrl_search_query"><?php 
    echo lang('search_for');
    ?>
</label>
		<input id="<?php 
    echo $list_id;
    ?>
 private function get_location_filter()
 {
     $entity_group_id = phpgw::get_var('entity_group_id', 'int');
     $location_id = phpgw::get_var('location_id', 'int');
     $location_filter = phpgwapi_cache::session_get('controller', "location_filter_{$entity_group_id}");
     if (!$location_filter) {
         $this->soadmin_entity = CreateObject('property.soadmin_entity');
         $entity_list = $this->soadmin_entity->read(array('allrows' => true));
         $location_filter = array();
         foreach ($entity_list as $entry) {
             $categories = $this->soadmin_entity->read_category(array('entity_id' => $entry['id'], 'order' => 'name', 'sort' => 'asc', 'enable_controller' => true, 'allrows' => true));
             foreach ($categories as $category) {
                 if ($category['enable_controller']) {
                     if ($entity_group_id && $category['entity_group_id'] != $entity_group_id) {
                         continue;
                     }
                     $sort_arr = explode(' ', $category['name']);
                     $location_filter[] = array('id' => $category['location_id'], 'name' => "{$entry['name']}::{$category['name']}", 'sort_key' => trim($sort_arr[0]));
                 }
             }
         }
         // Obtain a list of columns
         foreach ($location_filter as $key => $row) {
             $id[$key] = $row['sort_key'];
         }
         array_multisort($id, SORT_ASC, SORT_STRING, $location_filter);
         phpgwapi_cache::session_set('controller', "location_filter_{$entity_group_id}", $location_filter);
     }
     foreach ($location_filter as &$location) {
         $location['selected'] = $location['id'] == $location_id ? 1 : 0;
     }
     return $location_filter;
 }
 private function get_contracts_per_location()
 {
     $org_unit = $this->header_state['selected_org_unit'];
     if ($org_unit == 'all' || $org_unit == 'none') {
         phpgwapi_cache::message_set('Velg organisasjon', 'error');
         return array();
     }
     $values = phpgwapi_cache::session_get('frontend', $this->contracts_per_location_identifier);
     if (isset($values[$org_unit])) {
         return $values[$org_unit];
     }
     $parties = rental_soparty::get_instance()->get(null, null, null, null, null, null, array('org_unit_id' => $org_unit));
     $types = rental_socontract::get_instance()->get_fields_of_responsibility();
     $location_id_internal = array_search('contract_type_internleie', $types);
     $location_id_in = array_search('contract_type_innleie', $types);
     $location_id_ex = array_search('contract_type_eksternleie', $types);
     $contracts_per_location = array();
     $contracts_in_per_location = array();
     $contracts_ex_per_location = array();
     //For all parties connected to the internal organization unit
     foreach ($parties as $party) {
         //... get the contracts
         $contracts = rental_socontract::get_instance()->get(null, null, null, null, null, null, array('party_id' => $party->get_id()));
         //... and for each contract connected to this contract part
         foreach ($contracts as $id => $contract) {
             //... get the composites
             $composites = rental_socomposite::get_instance()->get(null, null, null, null, null, null, array('contract_id' => $contracts[$id]->get_id()));
             //...and for each composite in the contract in which this contract part is connected
             foreach ($composites as $composite) {
                 //... get the units
                 $units = $composite->get_units();
                 //... and for each unit retrieve the property locations we are after
                 foreach ($units as $unit) {
                     $property_location = $unit->get_location();
                     $property_locations[$property_location->get_location_code()] = $property_location;
                     // Contract holders: contracts_per_location (internal) and contracts_in_per_location (in)
                     // Internal contract should have impact on total price
                     if ($contract->get_location_id() == $location_id_internal) {
                         $total_price = rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
                         $contract->set_total_price($total_price);
                         if (!is_array($contracts_per_location[$org_unit][$property_location->get_location_code()])) {
                             $contracts_per_location[$org_unit][$property_location->get_location_code()] = array();
                         }
                         array_push($contracts_per_location[$org_unit][$property_location->get_location_code()], $contract);
                     } else {
                         if ($contract->get_location_id() == $location_id_in) {
                             $total_price = rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
                             $contract->set_total_price($total_price);
                             if (!is_array($contracts_in_per_location[$org_unit][$property_location->get_location_code()])) {
                                 $contracts_in_per_location[$org_unit][$property_location->get_location_code()] = array();
                             }
                             array_push($contracts_in_per_location[$org_unit][$property_location->get_location_code()], $contract);
                         } else {
                             if ($contract->get_location_id() == $location_id_ex) {
                                 $total_price = rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
                                 $contract->set_total_price($total_price);
                                 if (!is_array($contracts_ex_per_location[$org_unit][$property_location->get_location_code()])) {
                                     $contracts_ex_per_location[$org_unit][$property_location->get_location_code()] = array();
                                 }
                                 array_push($contracts_ex_per_location[$org_unit][$property_location->get_location_code()], $contract);
                             }
                         }
                     }
                 }
             }
         }
     }
     phpgwapi_cache::session_set('frontend', 'contracts_per_location', $contracts_per_location);
     phpgwapi_cache::session_set('frontend', 'contracts_in_per_location', $contracts_in_per_location);
     phpgwapi_cache::session_set('frontend', 'contracts_ex_per_location', $contracts_ex_per_location);
     return ${$this}->contracts_per_location_identifier[$org_unit];
 }
 private function _populate($data = array())
 {
     $insert_record = phpgwapi_cache::session_get('property', 'insert_record');
     $values = phpgw::get_var('values');
     $_fields = array(array('name' => 'title', 'type' => 'string', 'required' => true), array('name' => 'descr', 'type' => 'string', 'required' => true), array('name' => 'cat_id', 'type' => 'integer', 'required' => true), array('name' => 'report_date', 'type' => 'string', 'required' => true), array('name' => 'status_id', 'type' => 'integer', 'required' => true), array('name' => 'vendor_id', 'type' => 'integer', 'required' => false), array('name' => 'vendor_name', 'type' => 'string', 'required' => false), array('name' => 'coordinator_id', 'type' => 'integer', 'required' => false), array('name' => 'coordinator_name', 'type' => 'string', 'required' => false), array('name' => 'multiplier', 'type' => 'float', 'required' => false));
     foreach ($_fields as $_field) {
         if ($data[$_field['name']] = $_POST['values'][$_field['name']]) {
             $data[$_field['name']] = phpgw::clean_value($data[$_field['name']], $_field['type']);
         }
         if ($_field['required'] && !$data[$_field['name']]) {
             $this->receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $_field['name']));
         }
     }
     //_debug_array($data);die();
     $values = $this->bocommon->collect_locationdata($data, $insert_record);
     if (!isset($values['location_code']) || !$values['location_code']) {
         $this->receipt['error'][] = array('msg' => lang('Please select a location !'));
     }
     /*
      * Extra data from custom fields
      */
     $values['attributes'] = phpgw::get_var('values_attribute');
     if (is_array($values['attributes'])) {
         foreach ($values['attributes'] as $attribute) {
             if ($attribute['nullable'] != 1 && (!$attribute['value'] && !$values['extra'][$attribute['name']])) {
                 $this->receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text']));
             }
         }
     }
     if (!isset($values['cat_id']) || !$values['cat_id']) {
         $this->receipt['error'][] = array('msg' => lang('Please select a category !'));
     }
     if (!isset($values['title']) || !$values['title']) {
         $this->receipt['error'][] = array('msg' => lang('Please give a title !'));
     }
     if (!isset($values['report_date']) || !$values['report_date']) {
         $this->receipt['error'][] = array('msg' => lang('Please select a date!'));
     }
     return $values;
 }
 public function edit()
 {
     $user_id = phpgw::get_var('user_id', 'int');
     $dimb_id = phpgw::get_var('dimb_id', 'int');
     $role_id = phpgw::get_var('role_id', 'int');
     $query = phpgw::get_var('query');
     if ($values = phpgw::get_var('values')) {
         if (!$GLOBALS['phpgw']->acl->check('.admin', PHPGW_ACL_EDIT, 'property')) {
             $receipt['error'][] = true;
             phpgwapi_cache::message_set(lang('you are not approved for this task'), 'error');
         }
         if (!$receipt['error']) {
             if ($this->bo->edit($values)) {
                 $result = array('status' => 'updated');
             } else {
                 $result = array('status' => 'error');
             }
         }
     }
     if (phpgw::get_var('phpgw_return_as') == 'json') {
         if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) {
             phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
             $result['receipt'] = $receipt;
         } else {
             $result['receipt'] = array();
         }
         return $result;
     } else {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uidimb_role_user.index', 'user_id' => $user_id, 'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query' => $query));
     }
 }
Exemplo n.º 11
0
 /**
  * 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')
 {
     $bo =& $this->bo;
     $id = phpgw::get_var('id');
     $values = $bo->read_single(array('id' => $id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'view' => true));
     //_debug_array($values);
     $entity = $this->soadmin_entity->read_single($this->entity_id);
     $category = $this->soadmin_entity->read_single_category($this->entity_id, $this->cat_id);
     $location_data = array();
     if ($entity['location_form'] && $category['location_level'] > 0) {
         $bolocation = CreateObject('property.bolocation');
         $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'] : ''));
     }
     // ---- 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
     */
     $tabs = array();
     $tabs['info'] = array('label' => 'Info', 'link' => '#info');
     $active_tab = $active_tab ? $active_tab : 'info';
     $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));
             $_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) {
                 $_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);
             //					_debug_array($output);
             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}';");
             $integration[] = array('section' => $_config_section, 'height' => isset($_config_section_data['height']) && $_config_section_data['height'] ? $_config_section_data['height'] : 500, 'src' => $integration_src);
         }
     }
     //_debug_array($integration);die();
     // ---- END INTEGRATION -------------------------
     $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);
     $img_types = array('image/jpeg', 'image/png', 'image/gif');
     $content_files = array();
     for ($z = 0; $z < count($values['files']); $z++) {
         $content_files[$z]['url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $link_file_data) . '&amp;file_name=' . $values['files'][$z]['name'] . '" target="_blank" title="' . lang('click to view file') . '">' . $values['files'][$z]['name'] . '</a>';
         $content_files[$z]['file_name'] = $values['files'][$z]['name'];
         if (in_array($values['files'][$z]['mime_type'], $img_types)) {
             $content_files[$z]['file_name'] = urlencode($values['files'][$z]['name']);
             $content_files[$z]['directory'] = urlencode($values['files'][$z]['directory']);
             $content_files[$z]['img_id'] = $values['files'][$z]['file_id'];
         }
     }
     $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' => 'url', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'file_name', 'hidden' => true), array('key' => 'img_id', 'hidden' => true), array('key' => 'directory', 'hidden' => true), array('key' => 'picture', 'label' => 'picture', 'sortable' => false, 'resizeable' => false, 'visible' => true, 'formatter' => 'show_picture'))));
     $msglog = phpgwapi_cache::session_get('frontend', 'msgbox');
     phpgwapi_cache::session_clear('frontend', 'msgbox');
     $data = array('header' => $this->header_state, 'msgbox_data' => isset($msglog) ? $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog)) : array(), 'tabs' => $this->tabs, 'entityinfo' => array('entitylist' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uientity.index', 'location_id' => $this->location_id)), 'entityedit' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uientity.edit', 'location_id' => $this->location_id, 'id' => $id)), 'start_ticket' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uihelpdesk.add_ticket', 'noframework' => 1, 'p_entity_id' => $this->entity_id, 'p_cat_id' => $this->cat_id, 'type' => $this->type, 'bypass' => true, 'origin' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'location_code' => $this->location_code, 'origin_id' => $id, 'p_num' => $id)), 'location_id' => $this->location_id, 'id' => $id, 'entity' => $entity, 'entityhistory' => $entityhistory2, 'custom_attributes' => array('attributes' => $values['attributes']), 'location_data' => $location_data, 'files' => isset($values['files']) ? $values['files'] : '', 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'base_java_url' => "{menuaction:'property.uientity.get_files'," . "id:'{$id}'," . "entity_id:'{$this->entity_id}'," . "cat_id:'{$this->cat_id}'," . "type:'{$this->type}'}", 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'tabs' => phpgwapi_yui::tabview_generate($tabs, $active_tab), 'active_tab' => $active_tab, 'integration' => $integration));
     phpgwapi_yui::load_widget('dragdrop');
     phpgwapi_yui::load_widget('datatable');
     phpgwapi_yui::load_widget('connection');
     phpgwapi_yui::load_widget('loader');
     phpgwapi_yui::load_widget('animation');
     $GLOBALS['phpgw']->js->validate_file('yahoo', 'entity.view', 'frontend');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
     $GLOBALS['phpgw']->js->validate_file('tinybox2', 'packed', 'phpgwapi');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
     $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 'entityview', 'attributes_view'));
     $GLOBALS['phpgw']->xslttpl->add_file(array('location_view', 'files'), PHPGW_SERVER_ROOT . '/property/templates/base');
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('app_data' => $data));
 }
 protected function session_get($key)
 {
     return phpgwapi_cache::session_get($this->get_ui_session_key(), $key);
 }
Exemplo n.º 13
0
</script>
<?php 
if ($list_form) {
    ?>

<form id="<?php 
    echo $list_id;
    ?>
_form" method="GET">
<?php 
    $populate = phpgw::get_var('populate_form');
    if (isset($populate)) {
        $q = phpgwapi_cache::session_get('rental', 'party_query');
        $s_type = phpgwapi_cache::session_get('rental', 'party_search_type');
        $p_type = phpgwapi_cache::session_get('rental', 'party_type');
        $status = phpgwapi_cache::session_get('rental', 'party_status');
    }
    ?>
	<fieldset>
		<!-- Search -->
		<label for="ctrl_search_query"><?php 
    echo lang('search_for');
    ?>
</label>
		<input id="<?php 
    echo $list_id;
    ?>
_ctrl_search_query" type="text" name="query" autocomplete="off" value="<?php 
    echo isset($q) ? $q : '';
    ?>
"/>
Exemplo n.º 14
0
 function get_tabs()
 {
     // Get tabs from location hierarchy
     // tabs [location identidier] = {label => ..., link => ...}
     $locations = frontend_bofrontend::get_sections();
     $tabs = array();
     foreach ($locations as $key => $entry) {
         $name = $entry['name'];
         $location = $entry['location'];
         if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'frontend')) {
             $location_id = $GLOBALS['phpgw']->locations->get_id('frontend', $location);
             $tabs[$location_id] = array('label' => lang($name), 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.ui{$name}.index", 'location_id' => $location_id, 'noframework' => $noframework)));
         }
         unset($location);
     }
     // this one is for generic entitysupport from the app 'property'
     $entity_frontend = isset($this->config->config_data['entity_frontend']) && $this->config->config_data['entity_frontend'] ? $this->config->config_data['entity_frontend'] : array();
     if ($entity_frontend) {
         $entity = CreateObject('property.soadmin_entity');
     }
     foreach ($entity_frontend as $location) {
         if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'property')) {
             $location_id = $GLOBALS['phpgw']->locations->get_id('property', $location);
             $location_arr = explode('.', $location);
             $category = $entity->read_single_category($location_arr[2], $location_arr[3]);
             $tabs[$location_id] = array('label' => $category['name'], 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.uientity.index", 'location_id' => $location_id, 'noframework' => $noframework)));
         }
     }
     $extra_tabs = phpgwapi_cache::session_get('frontend', 'extra_tabs');
     if (isset($extra_tabs)) {
         $tabs = array_merge($extra_tabs, $tabs);
     }
     phpgwapi_cache::session_clear('frontend', 'extra_tabs');
     return $tabs;
 }
Exemplo n.º 15
0
 function read($data)
 {
     $start = isset($data['start']) && $data['start'] ? $data['start'] : 0;
     $filter = isset($data['filter']) && $data['filter'] ? $data['filter'] : 0;
     $query = isset($data['query']) ? $data['query'] : '';
     $sort = isset($data['sort']) && $data['sort'] ? $data['sort'] : 'ASC';
     $order = isset($data['order']) ? $data['order'] : '';
     $cat_id = isset($data['cat_id']) && $data['cat_id'] ? $data['cat_id'] : '';
     $type_id = isset($data['type_id']) ? $data['type_id'] : '';
     $lookup_tenant = isset($data['lookup_tenant']) ? $data['lookup_tenant'] : '';
     $district_id = isset($data['district_id']) ? $data['district_id'] : '';
     $allrows = isset($data['allrows']) ? $data['allrows'] : '';
     $lookup = isset($data['lookup']) ? $data['lookup'] : '';
     $status = isset($data['status']) ? $data['status'] : '';
     $part_of_town_id = isset($data['part_of_town_id']) ? $data['part_of_town_id'] : '';
     $dry_run = isset($data['dry_run']) ? $data['dry_run'] : '';
     $location_code = isset($data['location_code']) ? $data['location_code'] : '';
     $filter_role_on_contact = $data['filter_role_on_contact'] ? (int) $data['filter_role_on_contact'] : 0;
     $role_id = $data['role_id'] ? (int) $data['role_id'] : 0;
     $results = $data['results'] ? (int) $data['results'] : 0;
     $control_registered = isset($data['control_registered']) ? $data['control_registered'] : '';
     $control_id = isset($data['control_id']) && $data['control_id'] ? $data['control_id'] : 0;
     if (!$type_id) {
         return;
     }
     if ($order == 'undefined') {
         $order = '';
     }
     switch ($order) {
         case 'undefined':
             $order = '';
             break;
         case 'loc1':
             $order = 'fm_location1.loc1';
             break;
         default:
     }
     $sql = $this->socommon->fm_cache('sql_' . $type_id . '_lt' . $lookup_tenant . '_l' . $lookup . '_f' . !!$filter_role_on_contact);
     $location_id = $GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
     //			$choice_table = 'phpgw_cust_choice';
     $attribute_table = 'phpgw_cust_attribute';
     //			$attribute_filter = " custom = 1 AND location_id = {$location_id}";
     $attribute_filter = " location_id = {$location_id}";
     //			$attribute_choice_filter = " location_id = {$location_id}";
     if (!$sql) {
         $location_types = $this->soadmin_location->select_location_type();
         $cols = "fm_location{$type_id}.*";
         $cols_return[] = 'location_code';
         $uicols['input_type'][] = 'hidden';
         $uicols['name'][] = 'location_code';
         $uicols['descr'][] = 'dummy';
         $uicols['statustext'][] = 'dummy';
         $uicols['exchange'][] = false;
         $uicols['align'][] = '';
         $uicols['datatype'][] = '';
         $uicols['formatter'][] = '';
         for ($i = 0; $i < $type_id; $i++) {
             $uicols['input_type'][] = 'text';
             $uicols['name'][] = "loc{$location_types[$i]['id']}";
             $uicols['descr'][] = $location_types[$i]['name'];
             $uicols['statustext'][] = $location_types[$i]['descr'];
             $uicols['exchange'][] = true;
             $uicols['align'][] = 'center';
             $uicols['datatype'][] = 'link';
             $uicols['formatter'][] = '';
             $cols .= ",fm_location{$type_id}.loc{$location_types[$i]['id']}";
             $cols_return[] = "loc{$location_types[$i]['id']}";
         }
         $uicols['datatype'][$type_id] = 'I';
         // correct the last one
         $list_info = $location_types[$type_id - 1]['list_info'];
         for ($i = 1; $i < $type_id + 1; $i++) {
             if (isset($list_info[$i]) && $list_info[$i]) {
                 $cols .= ",fm_location{$i}.loc{$i}_name";
                 $cols_return[] = "loc{$i}_name";
                 $uicols['input_type'][] = 'text';
                 $uicols['name'][] = "loc{$i}_name";
                 $uicols['descr'][] = $location_types[$i - 1]['name'] . ' ' . lang('name');
                 $uicols['statustext'][] = $location_types[$i - 1]['name'] . ' ' . lang('name');
                 $uicols['exchange'][] = true;
                 $uicols['align'][] = 'left';
                 $uicols['datatype'][] = 'V';
                 $uicols['formatter'][] = '';
             }
         }
         $joinmethod = '';
         $paranthesis = '';
         for ($j = $type_id - 1; $j > 0; $j--) {
             $joinmethod .= " {$this->join} fm_location{$j}";
             $paranthesis .= '(';
             $on = 'ON';
             for ($i = $j; $i > 0; $i--) {
                 $joinmethod .= " {$on} (fm_location" . ($j + 1) . ".loc{$i} = fm_location{$j}.loc{$i})";
                 $on = 'AND';
                 if ($i == 1) {
                     $joinmethod .= ")";
                 }
             }
         }
         //			$paranthesis .='(';
         //			$joinmethod .= " {$this->join} fm_part_of_town ON (fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
         $config = $this->soadmin_location->read_config('');
         //_debug_array($config);
         if ($lookup_tenant) {
             $cols .= ',fm_tenant.id as tenant_id';
             $cols_return[] = 'tenant_id';
             $uicols['input_type'][] = 'hidden';
             $uicols['name'][] = 'tenant_id';
             $uicols['descr'][] = 'dummy';
             $uicols['statustext'][] = 'dummy';
             $uicols['exchange'][] = true;
             $uicols['align'][] = '';
             $uicols['datatype'][] = '';
             $uicols['formatter'][] = '';
             $cols .= ',fm_tenant.last_name';
             $cols_return[] = 'last_name';
             $uicols['input_type'][] = 'text';
             $uicols['name'][] = 'last_name';
             $uicols['datatype'][] = 'V';
             $uicols['descr'][] = lang('last name');
             $uicols['statustext'][] = lang('last name');
             $uicols['exchange'][] = true;
             $uicols['align'][] = 'left';
             $uicols['datatype'][] = 'V';
             $uicols['formatter'][] = '';
             $cols .= ',fm_tenant.first_name';
             $cols_return[] = 'first_name';
             $uicols['input_type'][] = 'text';
             $uicols['name'][] = 'first_name';
             $uicols['datatype'][] = 'V';
             $uicols['descr'][] = lang('first name');
             $uicols['statustext'][] = lang('first name');
             $uicols['exchange'][] = true;
             $uicols['align'][] = 'left';
             $uicols['datatype'][] = 'V';
             $uicols['formatter'][] = '';
             $cols .= ',fm_tenant.contact_phone';
             $cols_return[] = 'contact_phone';
             $uicols['input_type'][] = 'text';
             $uicols['name'][] = 'contact_phone';
             $uicols['datatype'][] = 'V';
             $uicols['descr'][] = lang('contact phone');
             $uicols['statustext'][] = lang('contact phone');
             $uicols['exchange'][] = true;
             $uicols['align'][] = 'left';
             $uicols['datatype'][] = 'V';
             $uicols['formatter'][] = '';
             $sub_query_tenant = 1;
             $this->socommon->fm_cache('sub_query_tenant_' . $type_id . '_' . $lookup_tenant . '_' . $lookup, $sub_query_tenant);
         }
         $config_count = count($config);
         for ($i = 0; $i < $config_count; $i++) {
             if ($config[$i]['location_type'] <= $type_id && $config[$i]['f_key'] == 1) {
                 if (!$lookup_tenant && $config[$i]['column_name'] == 'tenant_id') {
                 } else {
                     $joinmethod .= " {$this->left_join} {$config[$i]['reference_table']} ON ( fm_location{$config[$i]['location_type']}.{$config[$i]['column_name']} = {$config[$i]['reference_table']}.{$config[$i]['reference_id']}))";
                     $paranthesis .= '(';
                 }
             }
             if ($config[$i]['location_type'] <= $type_id && $config[$i]['query_value'] == 1) {
                 if ($config[$i]['column_name'] == 'street_id') {
                     $sub_query_street = 1;
                     $this->socommon->fm_cache('sub_query_street_' . $type_id . '_' . $lookup_tenant . '_' . $lookup, $sub_query_street);
                     //list address at sublevels beneath address-level
                     if ($location_types[$type_id - 1]['list_address']) {
                         $cols .= ',fm_streetaddress.descr as street_name';
                         $cols_return[] = 'street_name';
                         $uicols['input_type'][] = 'text';
                         $uicols['name'][] = 'street_name';
                         $uicols['descr'][] = lang('street name');
                         $uicols['statustext'][] = lang('street name');
                         $uicols['exchange'][] = true;
                         $uicols['align'][] = 'left';
                         $uicols['datatype'][] = 'V';
                         $uicols['formatter'][] = '';
                         $cols .= ',street_number';
                         $cols_return[] = 'street_number';
                         $uicols['input_type'][] = 'text';
                         $uicols['name'][] = 'street_number';
                         $uicols['descr'][] = lang('street number');
                         $uicols['statustext'][] = lang('street number');
                         $uicols['exchange'][] = true;
                         $uicols['align'][] = 'left';
                         $uicols['datatype'][] = 'V';
                         $uicols['formatter'][] = '';
                         $cols .= ',fm_location' . $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
                         $cols_return[] = $config[$i]['column_name'];
                         $uicols['input_type'][] = 'hidden';
                         $uicols['name'][] = $config[$i]['column_name'];
                         $uicols['descr'][] = lang($config[$i]['input_text']);
                         $uicols['statustext'][] = lang($config[$i]['input_text']);
                         $uicols['exchange'][] = true;
                         $uicols['align'][] = '';
                         $uicols['datatype'][] = '';
                         $uicols['formatter'][] = '';
                     }
                 } else {
                     $cols .= ',fm_location' . $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
                     $cols_return[] = $config[$i]['column_name'];
                     $uicols['input_type'][] = 'hidden';
                     $uicols['name'][] = $config[$i]['column_name'];
                     $uicols['descr'][] = $config[$i]['input_text'];
                     $uicols['statustext'][] = $config[$i]['input_text'];
                     $uicols['exchange'][] = true;
                     $uicols['align'][] = '';
                     $uicols['datatype'][] = '';
                     $uicols['formatter'][] = '';
                 }
             }
         }
         $this->db->query("SELECT * FROM {$attribute_table} WHERE (list=1 OR lookup_form=1) AND {$attribute_filter}");
         while ($this->db->next_record()) {
             $cols .= ",fm_location{$type_id}." . $this->db->f('column_name');
         }
         $cols .= ",fm_location{$type_id}_category.descr as category_text";
         $joinmethod .= " {$this->left_join} fm_location{$type_id}_category ON ( fm_location{$type_id}.category = fm_location{$type_id}_category.id))";
         $paranthesis .= '(';
         if ($filter_role_on_contact) {
             $joinmethod .= " {$this->join} fm_responsibility_contact ON ( fm_location{$type_id}.location_code = fm_responsibility_contact.location_code))";
             $paranthesis .= '(';
             $joinmethod .= " {$this->join} fm_responsibility_role ON ( fm_responsibility_contact.responsibility_role_id = fm_responsibility_role.id))";
             $paranthesis .= '(';
             $cols .= ',fm_responsibility_role.id as role_id';
             $cols_return[] = 'role_id';
             $uicols['input_type'][] = 'hidden';
             $uicols['name'][] = 'role_id';
             $uicols['descr'][] = 'dummy';
             $uicols['statustext'][] = 'dummy';
             $uicols['exchange'][] = false;
             $uicols['align'][] = '';
             $uicols['datatype'][] = '';
             $uicols['formatter'][] = '';
         }
         $from = " FROM {$paranthesis} fm_location{$type_id} ";
         $sql = "SELECT {$cols} {$from} {$joinmethod}";
         $this->socommon->fm_cache('sql_' . $type_id . '_lt' . $lookup_tenant . '_l' . $lookup . '_f' . !!$filter_role_on_contact, $sql);
         $this->socommon->fm_cache('uicols_' . $type_id . '_' . $lookup_tenant . '_' . $lookup . '_f' . !!$filter_role_on_contact, $uicols);
         $this->socommon->fm_cache('cols_return_' . $type_id . '_' . $lookup_tenant . '_' . $lookup . '_f' . !!$filter_role_on_contact, $cols_return);
     } else {
         $uicols = $this->socommon->fm_cache('uicols_' . $type_id . '_' . $lookup_tenant . '_' . $lookup . '_f' . !!$filter_role_on_contact);
         $cols_return = $this->socommon->fm_cache('cols_return_' . $type_id . '_' . $lookup_tenant . '_' . $lookup . '_f' . !!$filter_role_on_contact);
         $sub_query_tenant = $this->socommon->fm_cache('sub_query_tenant_' . $type_id . '_' . $lookup_tenant . '_' . $lookup);
         $sub_query_street = $this->socommon->fm_cache('sub_query_street_' . $type_id . '_' . $lookup_tenant . '_' . $lookup);
     }
     $filtermethod = '';
     $where = 'WHERE';
     if ($control_registered) {
         $sql .= "{$this->join} controller_control_location_list ON (fm_location{$type_id}.location_code = controller_control_location_list.location_code )";
         $filtermethod .= " {$where}  controller_control_location_list.control_id = {$control_id}";
         $where = 'AND';
     }
     //---------------------start custom user cols
     $user_columns = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_' . $type_id . !!$lookup]) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_' . $type_id . !!$lookup] : '';
     $user_column_filter = '';
     if (isset($user_columns) and is_array($user_columns) and $user_columns[0]) {
         $user_column_filter = " OR ({$attribute_filter} AND id IN (" . implode(',', $user_columns) . '))';
     }
     $this->db->query("SELECT DISTINCT * FROM {$attribute_table} WHERE (list=1 OR lookup_form=1) AND {$attribute_filter} {$user_column_filter} ORDER BY attrib_sort ASC");
     $i = count($uicols['name']);
     while ($this->db->next_record()) {
         $input_type = 'text';
         if ($this->db->f('lookup_form') == 1 && $this->db->f('list') != 1) {
             $input_type = 'hidden';
             $exchange = true;
         } else {
             if ($this->db->f('lookup_form') == 1) {
                 $exchange = true;
             } else {
                 $input_type = 'text';
                 $exchange = false;
             }
         }
         $uicols['input_type'][] = $input_type;
         $uicols['name'][] = $this->db->f('column_name');
         $uicols['descr'][] = $this->db->f('input_text');
         $uicols['statustext'][] = $this->db->f('statustext');
         $uicols['datatype'][$i] = $this->db->f('datatype');
         $uicols['formatter'][] = '';
         $uicols['exchange'][] = $exchange;
         $uicols['cols_return_extra'][$i] = array('name' => $this->db->f('column_name'), 'datatype' => $this->db->f('datatype'), 'attrib_id' => $this->db->f('id'));
         //TODO: move alignment to ui
         switch ($this->db->f('datatype')) {
             case 'V':
             case 'C':
             case 'N':
                 $uicols['align'][] = 'left';
                 break;
             case 'D':
             case 'I':
                 $uicols['align'][] = 'right';
                 break;
             default:
                 $uicols['align'][] = 'center';
         }
         if ($this->db->f('column_name') == 'category') {
             $i++;
             $cols .= ",fm_location{$type_id}_category.descr as category_text";
             $uicols['input_type'][] = 'text';
             $uicols['name'][] = 'category_text';
             $uicols['descr'][] = $this->db->f('input_text') . ' ' . lang('name');
             $uicols['statustext'][] = '';
             $uicols['datatype'][$i] = 'V';
             $uicols['formatter'][] = '';
             $uicols['exchange'][] = false;
             $uicols['align'][] = 'right';
             $uicols['cols_return_extra'][$i] = array();
         }
         $i++;
     }
     //---------------------end custom user cols
     $this->uicols = $uicols;
     if ($order && !$order == 'fm_location1.loc1') {
         $ordermethod = " ORDER BY {$order} {$sort}";
     } else {
         $ordermethod = " ORDER BY fm_location{$type_id}.loc1 {$sort}";
         if ($type_id > 1) {
             for ($i = 2; $i < $type_id + 1; $i++) {
                 $ordermethod .= ",fm_location{$type_id}.loc{$i} ASC";
             }
         }
     }
     $GLOBALS['phpgw']->config->read();
     if (isset($GLOBALS['phpgw']->config->config_data['acl_at_location']) && $GLOBALS['phpgw']->config->config_data['acl_at_location']) {
         $access_location = $this->bocommon->get_location_list(PHPGW_ACL_READ);
         $filtermethod = " WHERE fm_location{$type_id}.loc1 in ('" . implode("','", $access_location) . "')";
         $where = 'AND';
     }
     if ($cat_id) {
         $cat_id = $this->db->db_addslashes($cat_id);
         $filtermethod .= " {$where} fm_location{$type_id}.category='{$cat_id}'";
         $where = 'AND';
     } else {
         $filtermethod .= " {$where}  (fm_location{$type_id}.category !='99' OR fm_location{$type_id}.category IS NULL)";
         $where = 'AND';
     }
     if ($filter > 0) {
         //cramirez.r@ccfirst.com 16/09/08 	validacion is added to avoid notice
         if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter'] == 'owner') {
             $filtermethod .= " {$where} fm_owner.id='{$filter}' ";
         } else {
             $filtermethod .= " {$where} fm_owner.category='{$filter}' ";
         }
         $where = 'AND';
     }
     if ($status > 0) {
         $filtermethod .= " {$where} fm_location{$type_id}.status = {$status} ";
         $where = 'AND';
     } else {
         //				$filtermethod .= " $where fm_location" . ($type_id). ".status IS NULL ";
         //				$filtermethod .= " $where fm_location" . ($type_id). ".status !=2 ";
         //				$where= 'AND';
     }
     if ($district_id > 0) {
         $filtermethod .= " {$where} fm_part_of_town.district_id='{$district_id}' ";
         $where = 'AND';
     }
     if ($part_of_town_id > 0) {
         $filtermethod .= " {$where} fm_part_of_town.part_of_town_id='{$part_of_town_id}' ";
         $where = 'AND';
     }
     if ($location_code) {
         $filtermethod .= " {$where} fm_location{$type_id}.location_code {$this->like} '{$location_code}%'";
         $where = 'AND';
     }
     if ($filter_role_on_contact && $role_id) {
         $time = time() + 1;
         $filtermethod .= " {$where} active_from < {$time} AND (active_to > {$time} OR active_to = 0)" . " AND expired_on IS NULL AND fm_responsibility_role.id ={$role_id} AND contact_id = {$filter_role_on_contact}";
         $where = 'AND';
     } else {
         if ($filter_role_on_contact) {
             $time = time() + 1;
             $filtermethod .= " {$where} active_from < {$time} AND (active_to > {$time} OR active_to = 0)" . " AND expired_on IS NULL AND contact_id = {$filter_role_on_contact}";
             $where = 'AND';
         }
     }
     $_querymethod = array();
     $__querymethod = array();
     $_joinmethod_datatype = array();
     if ($query) {
         $query = $this->db->db_addslashes($query);
         $query = str_replace(",", '.', $query);
         if (stristr($query, '.')) {
             $query_part = explode(".", $query);
             $_querymethod[] = "(fm_location{$type_id}.loc1='{$query_part[0]}' AND fm_location{$type_id}.loc{$type_id}='{$query_part[1]}')";
         }
         $sub_query = '';
         if ($sub_query_tenant) {
             $sub_query = "OR fm_tenant.last_name {$this->like} '%{$query}%' OR fm_tenant.first_name {$this->like} '%{$query}%' OR fm_tenant.contact_phone {$this->like} '%{$query}%'";
         }
         if ($sub_query_street) {
             $sub_query .= "OR fm_streetaddress.descr {$this->like} '%{$query}%'";
         }
         $query_name = '';
         for ($i = 1; $i < $type_id + 1; $i++) {
             $query_name .= "OR loc{$i}_name {$this->like} '%{$query}%'";
         }
         if (!$criteria_id) {
             $_querymethod[] = " (fm_location{$type_id}.loc1 {$this->like} '%{$query}%' {$sub_query} OR fm_location{$type_id}.location_code {$this->like} '%{$query}%' {$query_name})";
         } else {
             $__querymethod = array("fm_location{$type_id}.loc1 = '-1'");
             // block query waiting for criteria
         }
         $this->db->query("SELECT * FROM {$attribute_table} WHERE {$attribute_filter} AND search='1'");
         while ($this->db->next_record()) {
             switch ($this->db->f('datatype')) {
                 case 'V':
                 case 'email':
                 case 'CH':
                     if (!$criteria_id) {
                         $_querymethod[] = "fm_location{$type_id}." . $this->db->f('column_name') . " {$this->like} '%{$query}%'";
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 case 'R':
                 case 'LB':
                     if (!$criteria_id) {
                         $_joinmethod_datatype[] = "{$this->join} phpgw_cust_choice ON (fm_location{$type_id}." . $this->db->f('column_name') . " = phpgw_cust_choice.id" . " AND phpgw_cust_choice.location_id =" . (int) $this->db->f('location_id') . " AND phpgw_cust_choice.attrib_id =" . (int) $this->db->f('id') . ')';
                         $_querymethod[] = "(phpgw_cust_choice.location_id =" . (int) $this->db->f('location_id') . " AND phpgw_cust_choice.attrib_id =" . (int) $this->db->f('id') . " AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 case 'I':
                     if (ctype_digit($query) && !$criteria_id) {
                         $_querymethod[] = "fm_location{$type_id}." . $this->db->f('column_name') . " = " . (int) $query;
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 case 'VENDOR':
                     if ($criteria_id == 'vendor') {
                         $_joinmethod_datatype[] = "{$this->join} fm_vendor ON (fm_location{$type_id}." . $this->db->f('column_name') . " = fm_vendor.id AND fm_vendor.org_name {$this->like} '%{$query}%') ";
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 case 'AB':
                     if ($criteria_id == 'ab') {
                         $_joinmethod_datatype[] = "{$this->join} phpgw_contact_person ON (fm_location{$type_id}." . $this->db->f('column_name') . " = pphpgw_contact_person.person_id AND (phpgw_contact_person.first_name {$this->like} '%{$query}%' OR phpgw_contact_person.last_name {$this->like} '%{$query}%'))";
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 case 'ABO':
                     if ($criteria_id == 'abo') {
                         $_joinmethod_datatype[] = "{$this->join} phpgw_contact_org ON (fm_location{$type_id}." . $this->db->f('column_name') . " = phpgw_contact_org.org_id AND phpgw_contact_org.name {$this->like} '%{$query}%')";
                         $__querymethod = array();
                         // remove block
                     }
                     break;
                 default:
                     if (!$criteria_id) {
                         $_querymethod[] = "fm_location{$type_id}." . $this->db->f('column_name') . " = '{$query}'";
                         $__querymethod = array();
                         // remove block
                     }
             }
         }
         $where = 'AND';
     }
     foreach ($_joinmethod_datatype as $_joinmethod) {
         $sql .= $_joinmethod;
     }
     $querymethod = '';
     $_querymethod = array_merge($__querymethod, $_querymethod);
     if ($_querymethod) {
         $querymethod = " {$where} (" . implode(' OR ', $_querymethod) . ')';
         unset($_querymethod);
     }
     $sql .= "{$filtermethod} {$querymethod}";
     $values = array();
     //			$this->db->query('SELECT count(*) AS cnt ' . substr($sql,strripos($sql,' from')),__LINE__,__FILE__);
     //			$this->db->next_record();
     //			$this->total_records = $this->db->f('cnt');
     $cache_info = phpgwapi_cache::session_get('property', "location{$type_id}_listing_metadata");
     if (!isset($cache_info['sql_hash']) || $cache_info['sql_hash'] != md5($sql)) {
         $cache_info = array();
     }
     if (!$cache_info) {
         $this->db->query('SELECT count(*) AS cnt ' . substr($sql, strripos($sql, ' from')), __LINE__, __FILE__);
         $this->db->next_record();
         $cache_info = array('total_records' => $this->db->f('cnt'), 'sql_hash' => md5($sql));
         phpgwapi_cache::session_set('property', "location{$type_id}_listing_metadata", $cache_info);
     }
     $this->total_records = $cache_info['total_records'];
     //cramirez.r@ccfirst.com 23/07/08 avoid retrieve data in first time, only render definition for headers (var myColumnDefs)
     if ($dry_run) {
         return array();
     }
     if (!$allrows) {
         $this->db->limit_query($sql . $ordermethod, $start, __LINE__, __FILE__, $results);
     } else {
         $_fetch_single = false;
         /*
         				if($this->total_records > 200)
         				{
         					$_fetch_single = true;
         				}
         				else
         				{
         					$_fetch_single = false;
         				}
         */
         $this->db->query($sql . $ordermethod, __LINE__, __FILE__, false, $_fetch_single);
         unset($_fetch_single);
     }
     $j = 0;
     $location_count = $type_id - 1;
     $cols_return = $uicols['name'];
     $dataset = array();
     while ($this->db->next_record()) {
         foreach ($cols_return as $key => $field) {
             $dataset[$j][$field] = array('value' => $this->db->f($field), 'datatype' => $uicols['datatype'][$key], 'attrib_id' => isset($uicols['cols_return_extra'][$key]['attrib_id']) ? $uicols['cols_return_extra'][$key]['attrib_id'] : '');
         }
         $j++;
     }
     $this->db->set_fetch_single(false);
     $values = $this->custom->translate_value($dataset, $location_id, $location_count);
     return $values;
 }
Exemplo n.º 16
0
 protected function get_user_orgnr_from_session()
 {
     try {
         return createObject('booking.sfValidatorNorwegianOrganizationNumber')->clean(phpgwapi_cache::session_get($this->get_module(), self::ORGNR_SESSION_KEY));
     } catch (sfValidatorError $e) {
         return null;
     }
 }
Exemplo n.º 17
0
 function index()
 {
     $receipt = array();
     $voucher_id = phpgw::get_var('voucher_id', 'int');
     $line_id = phpgw::get_var('line_id', 'int');
     if (phpgw::get_var('phpgw_return_as') == 'json') {
         return $this->query();
     }
     if (isset($this->config->config_data['invoice_acl']) && $this->config->config_data['invoice_acl'] == 'dimb') {
         $janitor_list = $this->bo->get_dimb_role_user(1, '', $janitor);
         $supervisor_list = $this->bo->get_dimb_role_user(2, '', $supervisor);
         $budget_responsible_list = $this->bo->get_dimb_role_user(3, '', $budget_responsible);
     } else {
         $janitor_list = $this->bocommon->get_user_list_right(32, $janitor, '.invoice');
         $supervisor_list = $this->bocommon->get_user_list_right(64, $supervisor, '.invoice');
         $budget_responsible_list = $this->bocommon->get_user_list_right(128, $budget_responsible, '.invoice');
     }
     $userlist_default = array();
     $userlist_default[] = array('id' => '*' . $GLOBALS['phpgw']->accounts->get($this->account_id)->lid, 'name' => lang('mine vouchers'));
     $userlist_default[] = array('id' => '', 'name' => lang('no user'));
     $voucher_list = array();
     if ($voucher_id) {
         $voucher_list = $this->bo->get_vouchers(array('query' => $voucher_id));
     }
     if (!$voucher_list) {
         $voucher_list = array('id' => '', 'name' => lang('select'));
     }
     foreach ($userlist_default as $default) {
         $janitor_list = array_merge(array($default), $janitor_list);
         $supervisor_list = array_merge(array($default), $supervisor_list);
         $budget_responsible_list = array_merge(array($default), $budget_responsible_list);
     }
     $msgbox_data = array();
     if (phpgw::get_var('phpgw_return_as') != 'json' && ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))) {
         phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
         $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt);
         $msgbox_data = $GLOBALS['phpgw']->common->msgbox($msgbox_data);
     }
     $user = $GLOBALS['phpgw']->accounts->get($GLOBALS['phpgw_info']['user']['id']);
     $myColumnDefs = array();
     $datavalues = array();
     $myButtons = array();
     $datavalues[] = array('name' => "0", 'values' => $this->query(), 'total_records' => 0, 'permission' => "''", 'is_paginator' => 1, 'edit_action' => "''", 'footer' => 0);
     $datatable = array(array('key' => 'id', 'hidden' => true), array('key' => 'approve_line', 'label' => lang('select'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'status_line', 'label' => lang('status'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'amount', 'label' => lang('amount'), 'formatter' => 'FormatterRight', 'sortable' => true), array('key' => 'approved_amount', 'label' => lang('approved amount'), 'sortable' => true, 'formatter' => 'FormatterRight'), array('key' => 'split', 'label' => lang('split line'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'budget_account', 'label' => lang('budget account'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'dima', 'label' => lang('dim a'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'dimb', 'label' => lang('dim b'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'order_id', 'label' => lang('order'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'dime', 'label' => lang('dime'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'project_group', 'label' => lang('project group'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'line_text', 'label' => lang('invoice line text'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'approved_amount_hidden', 'hidden' => true));
     $myColumnDefs[0] = array('name' => "0", 'values' => json_encode($datatable));
     $criteria_list = array(array('id' => 'voucher_id', 'name' => lang('voucher id')), array('id' => 'invoice_id', 'name' => lang('invoice number')), array('id' => 'vendor_id', 'name' => lang('vendor')), array('id' => 'order_id', 'name' => lang('order id')), array('id' => 'b_account', 'name' => lang('budget account')), array('id' => 'dimb', 'name' => lang('dimb')));
     $data = array('td_count' => '""', 'base_java_url' => "{menuaction:'property.uiinvoice2.query'}", 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'email_base_url' => json_encode($GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice2.index'), true, true)), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'msgbox_data' => $msgbox_data, 'invoice_layout_config' => json_encode(execMethod('phpgwapi.template_portico.retrieve_local', 'invoice_layout_config')), 'preferences_url' => $GLOBALS['phpgw']->link('/preferences/index.php'), 'preferences_text' => lang('preferences'), 'home_url' => $GLOBALS['phpgw']->link('/home.php'), 'home_text' => lang('home'), 'home_icon' => 'icon icon-home', 'about_url' => $GLOBALS['phpgw']->link('/about.php', array('app' => $GLOBALS['phpgw_info']['flags']['currentapp'])), 'about_text' => lang('about'), 'logout_url' => $GLOBALS['phpgw']->link('/logout.php'), 'logout_text' => lang('logout'), 'user_fullname' => $user->__toString(), 'site_title' => "{$GLOBALS['phpgw_info']['server']['site_title']}", 'filter_form' => array('janitor_list' => array('options' => $janitor_list), 'supervisor_list' => array('options' => $supervisor_list), 'budget_responsible_list' => array('options' => $budget_responsible_list), 'criteria_list' => array('options' => $criteria_list)), 'filter_invoice' => array('voucher_list' => array('options' => $voucher_list)), 'voucher_info' => $this->get_single_line($line_id), 'update_action' => self::link(array('menuaction' => 'property.uiinvoice2.update_voucher')));
     //_debug_array($data);die();
     $GLOBALS['phpgw_info']['flags']['noframework'] = true;
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/layout/assets/skins/sam/layout.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');
     phpgwapi_yui::load_widget('layout');
     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_jquery::load_widget('core');
     self::add_javascript('property', 'portico', 'ajax_invoice.js');
     self::add_javascript('property', 'yahoo', 'invoice2.index.js');
     self::add_javascript('phpgwapi', 'tinybox2', 'packed.js');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
     $GLOBALS['phpgw']->xslttpl->add_file(array('invoice2'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('data' => $data));
 }
Exemplo n.º 18
0
 function entity()
 {
     $bocommon = CreateObject('property.bocommon');
     $boentity = CreateObject('property.boentity');
     $boadmin_entity = CreateObject('property.boadmin_entity');
     $this->start = $boentity->start;
     $this->query = $boentity->query;
     $this->sort = $boentity->sort;
     $this->order = $boentity->order;
     $this->filter = $boentity->filter;
     $this->cat_id = $boentity->cat_id;
     $this->part_of_town_id = $boentity->part_of_town_id;
     $this->district_id = $boentity->district_id;
     $this->entity_id = $boentity->entity_id;
     $this->location_code = $boentity->location_code;
     $this->criteria_id = $boentity->criteria_id;
     $second_display = phpgw::get_var('second_display', 'bool');
     $default_district = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'] : '';
     if ($default_district && !$second_display && !$this->district_id) {
         $this->bo->district_id = $default_district;
         $this->district_id = $default_district;
     }
     if (phpgw::get_var('phpgw_return_as') != 'json') {
         $datatable['config']['base_url'] = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilookup.entity', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'district_id' => $this->district_id, 'query' => $this->query, 'filter' => $this->filter, 'location_code' => $this->location_code, 'criteria_id' => $this->criteria_id));
         $datatable['config']['allow_allrows'] = true;
         $datatable['config']['base_java_url'] = "menuaction:'property.uilookup.entity'," . "second_display:1," . "entity_id:'{$this->entity_id}'," . "cat_id:'{$this->cat_id}'," . "district_id:'{$this->district_id}'," . "query:'{$this->query}'," . "filter:'{$this->filter}'," . "criteria_id:'{$this->criteria_id}'," . "location_code:'{$this->location_code}'";
         $values_combo_box[0] = $boentity->select_category_list('filter', $this->cat_id);
         $default_value = array('id' => '', 'name' => lang('no category'));
         array_unshift($values_combo_box[0], $default_value);
         $values_combo_box[1] = $bocommon->select_district_list('filter', $this->district_id);
         $default_value = array('id' => '', 'name' => lang('no district'));
         array_unshift($values_combo_box[1], $default_value);
         $values_combo_box[2] = $boentity->get_criteria_list($this->criteria_id);
         $default_value = array('id' => '', 'name' => lang('no criteria'));
         array_unshift($values_combo_box[2], $default_value);
         $datatable['actions']['form'] = array(array('action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilookup.entity', 'second_display' => $second_display, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'district_id' => $this->district_id, 'query' => $this->query, 'filter' => $this->filter)), 'fields' => array('field' => array(array('id' => 'sel_cat_id', 'name' => 'cat_id', 'value' => lang('Category'), 'type' => 'select', 'style' => 'filter', 'values' => $values_combo_box[0], 'onchange' => 'onChangeSelect("cat_id");', 'tab_index' => 1), array('id' => 'btn_district_id', 'name' => 'district_id', 'value' => lang('District'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 2), array('id' => 'btn_criteria_id', 'name' => 'criteria_id', 'value' => lang('search criteria'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 3), array('id' => 'btn_search', 'name' => 'search', 'value' => lang('search'), 'type' => 'button', 'tab_index' => 5), array('name' => 'query', 'id' => 'txt_query', 'value' => '', 'type' => 'text', 'size' => 28, 'onkeypress' => 'return pulsar(event)', 'tab_index' => 4)), 'hidden_value' => array(array('id' => 'values_combo_box_1', 'value' => $bocommon->select2String($values_combo_box[1])), array('id' => 'values_combo_box_2', 'value' => $bocommon->select2String($values_combo_box[2]))))));
     }
     $entity_list = $boentity->read(array('lookup' => true));
     $input_name = phpgwapi_cache::session_get('property', 'lookup_fields');
     $input_name_entity = phpgwapi_cache::session_get('property', 'lookup_fields_entity');
     $input_name = $input_name ? $input_name : array();
     $input_name_entity = $input_name_entity ? $input_name_entity : array();
     $input_name = array_merge($input_name, $input_name_entity);
     $uicols = $boentity->uicols;
     if (count($uicols['name']) > 0) {
         for ($m = 0; $m < count($input_name); $m++) {
             if (!array_search($input_name[$m], $uicols['name'])) {
                 $uicols['name'][] = $input_name[$m];
                 $uicols['descr'][] = '';
                 $uicols['input_type'][] = 'hidden';
             }
         }
     } else {
         $uicols['name'][] = 'num';
         $uicols['descr'][] = 'ID';
         $uicols['input_type'][] = 'text';
     }
     $content = array();
     $j = 0;
     if (isset($entity_list) && is_array($entity_list)) {
         foreach ($entity_list as $entity_entry) {
             for ($i = 0; $i < count($uicols['name']); $i++) {
                 $datatable['rows']['row'][$j]['column'][$i]['value'] = $entity_entry[$uicols['name'][$i]] == null ? '' : $entity_entry[$uicols['name'][$i]];
                 $datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
                 if (isset($uicols['datatype']) && isset($uicols['datatype'][$i]) && $uicols['datatype'][$i] == 'link' && $entity_entry[$uicols['name'][$i]]) {
                     $datatable['rows']['row'][$j]['column'][$i]['format'] = 'link';
                     $datatable['rows']['row'][$j]['column'][$i]['value'] = lang('link');
                     $datatable['rows']['row'][$j]['column'][$i]['link'] = $entity_entry[$uicols['name'][$i]];
                     $datatable['rows']['row'][$j]['column'][$i]['target'] = '_blank';
                 }
             }
             /*for ($i=0;$i<count($input_name);$i++)
             		{
             			$datatable['rows']['row'][$j]['hidden'][$i]['value'] 	= $entity_entry[$input_name[$i]];
             			$datatable['rows']['row'][$j]['hidden'][$i]['name'] 	= $input_name[$i];
             		}*/
             $j++;
         }
     }
     $uicols_count = count($uicols['descr']);
     $datatable['rowactions']['action'] = array();
     for ($i = 0; $i < $uicols_count; $i++) {
         //all colums should be have formatter
         $datatable['headers']['header'][$i]['formatter'] = $uicols['formatter'][$i] == '' ? '""' : $uicols['formatter'][$i];
         if ($uicols['input_type'][$i] != 'hidden') {
             $datatable['headers']['header'][$i]['name'] = $uicols['name'][$i];
             $datatable['headers']['header'][$i]['text'] = $uicols['descr'][$i];
             $datatable['headers']['header'][$i]['visible'] = true;
             $datatable['headers']['header'][$i]['sortable'] = false;
             if ($uicols['name'][$i] == 'loc1' || $uicols['name'][$i] == 'num') {
                 $datatable['headers']['header'][$i]['sortable'] = true;
                 $datatable['headers']['header'][$i]['sort_field'] = $uicols['name'][$i];
             }
         } else {
             $datatable['headers']['header'][$i]['name'] = $uicols['name'][$i];
             $datatable['headers']['header'][$i]['text'] = $uicols['descr'][$i];
             $datatable['headers']['header'][$i]['visible'] = false;
             $datatable['headers']['header'][$i]['sortable'] = false;
             $datatable['headers']['header'][$i]['format'] = 'hidden';
         }
     }
     $function_exchange_values = '';
     for ($i = 0; $i < count($input_name); $i++) {
         $function_exchange_values .= "opener.document.getElementsByName('{$input_name[$i]}')[0].value = '';\r\n";
     }
     for ($i = 0; $i < count($input_name); $i++) {
         $function_exchange_values .= "opener.document.getElementsByName('{$input_name[$i]}')[0].value = data.getData('{$input_name[$i]}');\r\n";
     }
     $function_exchange_values .= 'window.close()';
     $datatable['exchange_values'] = $function_exchange_values;
     $datatable['valida'] = '';
     // path for property.js
     $property_js = "/property/js/yahoo/property.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, '/'));
     }
     $datatable['property_js'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js;
     // Pagination and sort values
     $datatable['pagination']['records_start'] = (int) $this->start;
     $datatable['pagination']['records_limit'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
     $datatable['pagination']['records_returned'] = count($entity_list);
     $datatable['pagination']['records_total'] = $boentity->total_records;
     if (phpgw::get_var("start") == "" && phpgw::get_var("order", 'string') == "") {
         $datatable['sorting']['order'] = 'num';
         // name key Column in myColumnDef
         $datatable['sorting']['sort'] = 'desc';
         // ASC / DESC
     } else {
         $datatable['sorting']['order'] = phpgw::get_var('order', 'string');
         // name of column of Database
         $datatable['sorting']['sort'] = phpgw::get_var('sort', 'string');
         // ASC / DESC
     }
     //-- BEGIN----------------------------- JSON CODE ------------------------------
     //values for Pagination
     $json = array('recordsReturned' => $datatable['pagination']['records_returned'], 'totalRecords' => (int) $datatable['pagination']['records_total'], 'startIndex' => $datatable['pagination']['records_start'], 'sort' => $datatable['sorting']['order'], 'dir' => $datatable['sorting']['sort'], 'records' => array(), 'headers' => $uicols);
     // values for datatable
     if (isset($datatable['rows']['row']) && is_array($datatable['rows']['row'])) {
         foreach ($datatable['rows']['row'] as $row) {
             $json_row = array();
             foreach ($row['column'] as $column) {
                 if (isset($column['format']) && $column['format'] == "link" && $column['java_link'] == true) {
                     $json_row[$column['name']] = "<a href='#' id='{$column['link']}' onclick='javascript:filter_data(this.id);'>{$column['value']}</a>";
                 } else {
                     if (isset($column['format']) && $column['format'] == "link") {
                         $json_row[$column['name']] = "<a href='{$column['link']}' target='_blank'>{$column['value']}</a>";
                     } else {
                         $json_row[$column['name']] = $column['value'];
                     }
                 }
             }
             $json['records'][] = $json_row;
         }
     }
     // right in datatable
     if (isset($datatable['rowactions']['action']) && is_array($datatable['rowactions']['action'])) {
         $json['rights'] = $datatable['rowactions']['action'];
     }
     if (phpgw::get_var('phpgw_return_as') == 'json') {
         return $json;
     }
     $datatable['json_data'] = json_encode($json);
     //-------------------- JSON CODE ----------------------
     // Prepare template variables and process XSLT
     $template_vars = array();
     $template_vars['datatable'] = $datatable;
     $GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', $template_vars);
     if ($this->entity_id) {
         $entity = $boadmin_entity->read_single($this->entity_id, false);
         $appname = $entity['name'];
     }
     if ($this->cat_id) {
         $category = $boadmin_entity->read_single_category($this->entity_id, $this->cat_id);
         $function_msg = lang('lookup') . ' ' . $category['name'];
     }
     //Title of Page
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
     // Prepare YUI Library
     $GLOBALS['phpgw']->js->validate_file('yahoo', 'lookup.entity.index', 'property');
     $this->save_sessiondata();
 }
 function __construct()
 {
     parent::__construct();
     $this->so_control = CreateObject('controller.socontrol');
     $this->so = CreateObject('controller.socheck_list');
     $this->so_control_item = CreateObject('controller.socontrol_item');
     $this->so_check_item = CreateObject('controller.socheck_item');
     $this->so_procedure = CreateObject('controller.soprocedure');
     $this->so_control_group_list = CreateObject('controller.socontrol_group_list');
     $this->so_control_group = CreateObject('controller.socontrol_group');
     $this->so_control_item_list = CreateObject('controller.socontrol_item_list');
     $this->so_case = CreateObject('controller.socase');
     $this->location_finder = new location_finder();
     $this->acl_location = '.checklist';
     $this->read = $GLOBALS['phpgw']->acl->check('.checklist', PHPGW_ACL_READ, 'controller');
     //1
     $this->add = $GLOBALS['phpgw']->acl->check('.checklist', PHPGW_ACL_ADD, 'controller');
     //2
     $this->edit = $GLOBALS['phpgw']->acl->check('.checklist', PHPGW_ACL_EDIT, 'controller');
     //4
     $this->delete = $GLOBALS['phpgw']->acl->check('.checklist', PHPGW_ACL_DELETE, 'controller');
     //8
     self::set_active_menu('controller::control::check_list');
     if (phpgw::get_var('noframework', 'bool')) {
         $GLOBALS['phpgw_info']['flags']['noframework'] = true;
         phpgwapi_cache::session_set('controller', 'noframework', true);
     } else {
         if (phpgwapi_cache::session_get('controller', 'noframework')) {
             $GLOBALS['phpgw_info']['flags']['noframework'] = true;
         }
     }
 }
 public function edit_location()
 {
     if ($values = phpgw::get_var('values')) {
         if (!$GLOBALS['phpgw']->acl->check('.admin', PHPGW_ACL_EDIT, 'property')) {
             $receipt['error'][] = true;
             phpgwapi_cache::message_set(lang('you are not approved for this task'), 'error');
         }
         if (!$receipt['error']) {
             if ($this->so_control->register_control_to_location($values)) {
                 $result = array('status' => 'updated');
             } else {
                 $result = array('status' => 'error');
             }
         }
     }
     if (phpgw::get_var('phpgw_return_as') == 'json') {
         if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) {
             phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
             $result['receipt'] = $receipt;
         } else {
             $result['receipt'] = array();
         }
         return $result;
     } else {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uicontrol_register_to_location.index'));
     }
 }
Exemplo n.º 21
0
 function read($data)
 {
     $start = isset($data['start']) && $data['start'] ? $data['start'] : 0;
     $results = isset($data['results']) && $data['results'] ? $data['results'] : 0;
     $filter = isset($data['filter']) && $data['filter'] ? $data['filter'] : 'all';
     $query = isset($data['query']) ? $data['query'] : '';
     $sort = isset($data['sort']) && $data['sort'] ? $data['sort'] : 'DESC';
     $order = isset($data['order']) ? $data['order'] : '';
     $cat_id = isset($data['cat_id']) && $data['cat_id'] ? $data['cat_id'] : 0;
     $district_id = isset($data['district_id']) && $data['district_id'] ? $data['district_id'] : 0;
     $part_of_town_id = isset($data['part_of_town_id']) && $data['part_of_town_id'] ? $data['part_of_town_id'] : 0;
     $lookup = isset($data['lookup']) ? $data['lookup'] : '';
     $allrows = isset($data['allrows']) ? $data['allrows'] : '';
     $entity_id = isset($data['entity_id']) ? $data['entity_id'] : '';
     $cat_id = isset($data['cat_id']) ? $data['cat_id'] : '';
     $status = isset($data['status']) ? $data['status'] : '';
     $start_date = isset($data['start_date']) ? $data['start_date'] : '';
     $end_date = isset($data['end_date']) ? $data['end_date'] : '';
     $dry_run = isset($data['dry_run']) ? $data['dry_run'] : '';
     $this->type = isset($data['type']) && $data['type'] ? $data['type'] : $this->type;
     $location_code = isset($data['location_code']) ? $data['location_code'] : '';
     $criteria_id = isset($data['criteria_id']) ? $data['criteria_id'] : '';
     $attrib_filter = $data['attrib_filter'] ? $data['attrib_filter'] : array();
     $p_num = isset($data['p_num']) ? $data['p_num'] : '';
     $custom_condition = isset($data['custom_condition']) ? $data['custom_condition'] : '';
     $org_units = isset($data['org_units']) && is_array($data['org_units']) ? $data['org_units'] : array();
     $location_id = isset($data['location_id']) && $data['location_id'] ? (int) $data['location_id'] : 0;
     $entity_group_id = isset($data['entity_group_id']) && $data['entity_group_id'] ? (int) $data['entity_group_id'] : 0;
     $filter_entity_group = isset($data['filter_entity_group']) && $data['filter_entity_group'] ? (int) $data['filter_entity_group'] : 0;
     $filter_item = isset($data['filter_item']) && $data['filter_item'] ? $data['filter_item'] : array();
     if ($location_id) {
         $loc_arr = $GLOBALS['phpgw']->locations->get_name($location_id);
         $type_arr = explode('.', $loc_arr['location']);
         if (count($type_arr) != 4) {
             return array();
         }
         $this->type = $type_arr[1];
         $entity_id = $type_arr[2];
         $cat_id = $type_arr[3];
     }
     if (!$entity_id || !$cat_id) {
         return array();
     }
     if (!$location_id) {
         $location_id = $GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}");
     }
     $admin_entity = CreateObject('property.soadmin_entity');
     $admin_entity->type = $this->type;
     $category = $admin_entity->read_single_category($entity_id, $cat_id);
     $this->get_cols($category, $entity_id, $cat_id, $lookup, $location_id);
     if ($category['is_eav']) {
         return $this->read_eav($data);
     }
     $entity_table = "fm_{$this->type}_{$entity_id}_{$cat_id}";
     $choice_table = 'phpgw_cust_choice';
     $attribute_table = 'phpgw_cust_attribute';
     $attribute_filter = " location_id = {$location_id}";
     $sql = $this->sql;
     if (!$cat_id > 0) {
         return;
     }
     $grants = $GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", $this->type_app[$this->type]);
     if (!$grants) {
         $this->acl =& $GLOBALS['phpgw']->acl;
         $this->acl->set_account_id($this->account);
         $grants = $this->acl->get_grants($this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$cat_id}");
         $GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", $this->type_app[$this->type], $grants);
     }
     //_debug_array($cols_return_extra);
     if ($order) {
         switch ($order) {
             case 'user_id':
                 //				$ordermethod = " ORDER BY phpgw_accounts.account_lastname {$sort}";  // Don't work with LDAP.
                 break;
             case 'loc1_name':
                 $ordermethod = " ORDER BY fm_location1.loc1_name {$sort}";
                 // Don't work with LDAP.
                 break;
             default:
                 $metadata = $this->db->metadata($entity_table);
                 if (isset($metadata[$order])) {
                     $ordermethod = " ORDER BY {$entity_table}.{$order} {$sort}";
                 }
         }
     } else {
         $ordermethod = " order by {$entity_table}.id DESC";
     }
     $where = 'WHERE';
     $filtermethod = '';
     $_config = CreateObject('phpgwapi.config', $this->type_app[$this->type]);
     $_config->read();
     if (isset($_config->config_data['acl_at_location']) && $_config->config_data['acl_at_location'] && $category['location_level'] > 0) {
         $access_location = $this->bocommon->get_location_list(PHPGW_ACL_READ);
         $filtermethod = " WHERE {$entity_table}.loc1 in ('" . implode("','", $access_location) . "')";
         $where = 'AND';
     }
     $bypass_acl_at_entity = false;
     if (isset($_config->config_data['bypass_acl_at_entity']) && is_array($_config->config_data['bypass_acl_at_entity']) && in_array($entity_id, $_config->config_data['bypass_acl_at_entity'])) {
         $bypass_acl_at_entity = true;
     }
     unset($_config);
     if ($org_units) {
         $filtermethod .= " {$where} ( {$entity_table}.org_unit_id IN(" . implode(',', $org_units) . "))";
         $where = 'AND';
     }
     if ($filter == 'all') {
         if (is_array($grants) && !$bypass_acl_at_entity) {
             foreach ($grants as $user => $right) {
                 $public_user_list[] = $user;
             }
             reset($public_user_list);
             $filtermethod .= " {$where} ( {$entity_table}.user_id IN(" . implode(',', $public_user_list) . "))";
             $where = 'AND';
         }
     } else {
         $filtermethod = " {$where} {$entity_table}.user_id={$filter} ";
         $where = 'AND';
     }
     if ($status) {
         $filtermethod .= " {$where} {$entity_table}.status='{$status}' ";
         $where = 'AND';
     }
     if ($district_id > 0 && $category['location_level'] && !$part_of_town_id) {
         $filtermethod .= " {$where}  fm_part_of_town.district_id='{$district_id}' ";
         $where = 'AND';
     } else {
         if ($part_of_town_id > 0 && $category['location_level']) {
             $filtermethod .= " {$where}  fm_part_of_town.part_of_town_id='{$part_of_town_id}' ";
             $where = 'AND';
         }
     }
     if ($start_date) {
         $filtermethod .= " {$where} {$entity_table}.entry_date >= {$start_date} AND {$entity_table}.entry_date <= {$end_date} ";
         $where = 'AND';
     }
     if ($location_code) {
         $filtermethod .= " {$where} {$entity_table}.location_code {$this->like} '{$location_code}%'";
         $where = 'AND';
         $query = '';
     }
     if ($attrib_filter) {
         $filtermethod .= " {$where} " . implode(' AND ', $attrib_filter);
         $where = 'AND';
     }
     if ($custom_condition) {
         $filtermethod .= " {$where} {$custom_condition}";
         $where = 'AND';
     }
     if ($p_num) {
         $filtermethod .= " {$where} {$entity_table}.p_num='{$p_num}'";
         $where = 'AND';
     }
     if ($entity_group_id) {
         $filtermethod .= " {$where} {$entity_table}.entity_group_id = {$entity_group_id}";
         $where = 'AND';
     }
     if ($filter_entity_group) {
         $filtermethod .= " {$where} {$entity_table}.entity_group_id IS NULL";
         $where = 'AND';
     }
     if (is_array($filter_item) && count($filter_item)) {
         $filtermethod .= " {$where} {$entity_table}.id IN (" . implode(',', $filter_item) . ')';
         $where = 'AND';
     }
     $_querymethod = array();
     $__querymethod = array();
     $_joinmethod_datatype = array();
     $_joinmethod_datatype_custom = array();
     if ($query) {
         $query = $this->db->db_addslashes($query);
         $query = str_replace(",", '.', $query);
         if (stristr($query, '.')) {
             $query = explode(".", $query);
             $_querymethod[] = "({$entity_table}.location_code {$this->like} '" . $query[0] . "%' AND {$entity_table}.location_code {$this->like} '%" . $query[1] . "')";
         } else {
             if (!$criteria_id) {
                 $_querymethod[] .= "( {$entity_table}.location_code {$this->like} '%{$query}%' OR {$entity_table}.num {$this->like} '%{$query}%' OR address {$this->like} '%{$query}%')";
                 //						$where= 'OR';
             } else {
                 $__querymethod = array("{$entity_table}.id = -1");
                 // block query waiting for criteria
             }
             //_debug_array($__querymethod);
             $this->db->query("SELECT * FROM {$attribute_table} WHERE {$attribute_filter} AND search='1'");
             while ($this->db->next_record()) {
                 switch ($this->db->f('datatype')) {
                     case 'V':
                     case 'email':
                     case 'T':
                         if (!$criteria_id) {
                             $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . " {$this->like} '%{$query}%'";
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     case 'CH':
                         if (!$criteria_id) {
                             // from filter
                             $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . " {$this->like} '%,{$query},%'";
                             $__querymethod = array();
                             // remove block
                             // from text-search
                             $_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . (int) $this->db->f('location_id') . " AND phpgw_cust_choice.attrib_id =" . (int) $this->db->f('id') . " AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
                             $this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice {$_filter_choise}", __LINE__, __FILE__);
                             while ($this->db2->next_record()) {
                                 $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . " {$this->like} '%," . $this->db2->f('id') . ",%'";
                             }
                         }
                         break;
                     case 'R':
                     case 'LB':
                         if (!$criteria_id) {
                             $_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . (int) $this->db->f('location_id') . " AND phpgw_cust_choice.attrib_id =" . (int) $this->db->f('id') . " AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
                             $this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice {$_filter_choise}", __LINE__, __FILE__);
                             $__filter_choise = array();
                             while ($this->db2->next_record()) {
                                 $__filter_choise[] = $this->db2->f('id');
                             }
                             if ($__filter_choise) {
                                 $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . ' IN (' . implode(',', $__filter_choise) . ')';
                             }
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     case 'I':
                         if (ctype_digit($query) && !$criteria_id) {
                             $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . " = " . (int) $query;
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     case 'VENDOR':
                         if ($criteria_id == 'vendor') {
                             $_joinmethod_datatype[] = "{$this->join} fm_vendor ON ({$entity_table}." . $this->db->f('column_name') . " = fm_vendor.id AND fm_vendor.org_name {$this->like} '%{$query}%') ";
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     case 'AB':
                         if ($criteria_id == 'ab') {
                             $_joinmethod_datatype[] = "{$this->join} phpgw_contact_person ON ({$entity_table}." . $this->db->f('column_name') . " = pphpgw_contact_person.person_id AND (phpgw_contact_person.first_name {$this->like} '%{$query}%' OR phpgw_contact_person.last_name {$this->like} '%{$query}%'))";
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     case 'ABO':
                         if ($criteria_id == 'abo') {
                             $_joinmethod_datatype[] = "{$this->join} phpgw_contact_org ON ({$entity_table}." . $this->db->f('column_name') . " = phpgw_contact_org.org_id AND phpgw_contact_org.name {$this->like} '%{$query}%')";
                             $__querymethod = array();
                             // remove block
                         }
                         break;
                     default:
                         if (!$criteria_id) {
                             $_querymethod[] = "{$entity_table}." . $this->db->f('column_name') . " = '{$query}'";
                             $__querymethod = array();
                             // remove block
                         }
                 }
             }
         }
     }
     $_joinmethod_datatype = array_merge($_joinmethod_datatype, $_joinmethod_datatype_custom);
     foreach ($_joinmethod_datatype as $_joinmethod) {
         $sql .= $_joinmethod;
     }
     $querymethod = '';
     $_querymethod = array_merge($__querymethod, $_querymethod);
     if ($_querymethod) {
         $querymethod = " {$where} (" . implode(' OR ', $_querymethod) . ')';
         unset($_querymethod);
     }
     $sql .= " {$filtermethod} {$querymethod}";
     $cache_info = phpgwapi_cache::session_get($this->type_app[$this->type], "{$entity_table}_listing_metadata");
     if (!isset($cache_info['sql_hash']) || $cache_info['sql_hash'] != md5($sql)) {
         $cache_info = array();
     }
     if (!$cache_info) {
         $sql_cnt = "SELECT DISTINCT {$entity_table}.id " . substr($sql, strripos($sql, 'FROM'));
         $sql2 = "SELECT count(*) as cnt FROM ({$sql_cnt}) as t";
         $this->db->query($sql2, __LINE__, __FILE__);
         $this->db->next_record();
         unset($sql2);
         unset($sql_cnt);
         $cache_info = array('total_records' => $this->db->f('cnt'), 'sql_hash' => md5($sql));
         phpgwapi_cache::session_set($this->type_app[$this->type], "{$entity_table}_listing_metadata", $cache_info);
     }
     $this->total_records = $cache_info['total_records'];
     if ($dry_run) {
         return array();
     }
     if (!$allrows) {
         $this->db->limit_query($sql . $ordermethod, $start, __LINE__, __FILE__, $results);
     } else {
         $this->db->query($sql . $ordermethod, __LINE__, __FILE__);
     }
     $j = 0;
     $uicols = $this->uicols;
     $cols_return = $uicols['name'];
     //			$cols_return = $this->cols_return;
     $dataset = array();
     while ($this->db->next_record()) {
         foreach ($cols_return as $key => $field) {
             $dataset[$j][$field] = array('value' => $this->db->f($field), 'datatype' => $uicols['datatype'][$key], 'attrib_id' => $uicols['cols_return_extra'][$key]['attrib_id'], 'get_list_function' => $uicols['get_list_function'][$key], 'get_list_function_input' => $uicols['get_list_function_input'][$key], 'get_single_function' => $uicols['get_single_function'][$key], 'get_single_function_input' => $uicols['get_single_function_input'][$key]);
         }
         $dataset[$j]['location_id'] = array('value' => $location_id, 'datatype' => false, 'attrib_id' => false);
         $dataset[$j]['entity_id'] = array('value' => $entity_id, 'datatype' => false, 'attrib_id' => false);
         $dataset[$j]['cat_id'] = array('value' => $cat_id, 'datatype' => false, 'attrib_id' => false);
         $dataset[$j]['_type'] = array('value' => $this->type, 'datatype' => false, 'attrib_id' => false);
         if ($lookup) {
             $dataset[$j]["entity_cat_name_{$entity_id}"] = array('value' => $category['name'], 'datatype' => false, 'attrib_id' => false);
             $dataset[$j]["entity_id_{$entity_id}"] = array('value' => $entity_id, 'datatype' => false, 'attrib_id' => false);
             $dataset[$j]["cat_id_{$entity_id}"] = array('value' => $cat_id, 'datatype' => false, 'attrib_id' => false);
         }
         $j++;
     }
     $values = $this->custom->translate_value($dataset, $location_id);
     return $values;
 }
 public function add()
 {
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     $orgnr = phpgwapi_cache::session_get($this->module, self::ORGNR_SESSION_KEY);
     $application_text = $config->config_data;
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $building = $this->building_bo->so->read(array('filters' => array('id' => phpgw::get_var('building_id', 'GET'))));
         array_set_default($_POST, 'resources', array());
         array_set_default($_POST, 'accepted_documents', array());
         array_set_default($_POST, 'from_', array());
         array_set_default($_POST, 'to_', array());
         $application = $this->extract_form_data();
         foreach ($_POST['from_'] as &$from) {
             $timestamp = strtotime($from);
             $from = date("Y-m-d H:i:s", $timestamp);
         }
         foreach ($_POST['to_'] as &$to) {
             $timestamp = strtotime($to);
             $to = date("Y-m-d H:i:s", $timestamp);
         }
         $application['dates'] = array_map(array(self, '_combine_dates'), $_POST['from_'], $_POST['to_']);
         $application['active'] = '1';
         $application['status'] = 'NEW';
         $application['created'] = 'now';
         $application['modified'] = 'now';
         $application['secret'] = $this->generate_secret();
         $application['owner_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
         $errors = $this->validate($application);
         if ($_POST['contact_email'] != $_POST['contact_email2']) {
             $errors['email'] = lang('The e-mail addresses you entered do not match');
             $application['contact_email2'] = $_POST['contact_email2'];
         } else {
             $application['contact_email2'] = $_POST['contact_email2'];
         }
         foreach ($application['agegroups'] as $ag) {
             if ($ag['male'] > 9999 || $ag['female'] > 9999) {
                 $errors['agegroups'] = lang('Agegroups can not be larger than 9999 peoples');
             }
         }
         if ($building['results'][0]['deactivate_application']) {
             $errors['application_deactivated'] = lang('Application on this building is not possible.');
         }
         if (!$errors) {
             $comment_text = $this->create_accepted_documents_comment_text($application);
             if ($comment_text) {
                 $this->add_comment($application, $comment_text);
             }
             $receipt = $this->bo->add($application);
             $application['id'] = $receipt['id'];
             $this->bo->send_notification($application, true);
             $this->bo->so->update_id_string();
             $this->flash(lang("Your application has now been registered and a confirmation email has been sent to you.") . "<br />" . lang("A Case officer will review your application as soon as possible.") . "<br />" . lang("Please check your Spam Filter if you are missing mail."));
             $this->redirect(array('menuaction' => $this->url_prefix . '.show', 'id' => $receipt['id'], 'secret' => $application['secret']));
         }
     }
     if (phpgw::get_var('resource', 'GET') == 'null') {
         array_set_default($application, 'resources', array());
     } else {
         $resources = explode(",", phpgw::get_var('resource', 'GET'));
         array_set_default($application, 'resources', $resources);
     }
     array_set_default($application, 'building_id', phpgw::get_var('building_id', 'GET'));
     array_set_default($application, 'building_name', phpgw::get_var('building_name', 'GET'));
     if (strstr($application['building_name'], "%")) {
         $search = array('%C3%85', '%C3%A5', '%C3%98', '%C3%B8', '%C3%86', '%C3%A6');
         $replace = array('Å', 'å', 'Ø', 'ø', 'Æ', 'æ');
         $application['building_name'] = str_replace($search, $replace, $application['building_name']);
     }
     if (phpgw::get_var('from_', 'GET')) {
         $default_dates = array_map(array(self, '_combine_dates'), phpgw::get_var('from_', 'GET'), phpgw::get_var('to_', 'GET'));
     } else {
         $default_dates = array_map(array(self, '_combine_dates'), '', '');
     }
     array_set_default($application, 'dates', $default_dates);
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'application.js');
     $application['resources_json'] = json_encode(array_map('intval', $application['resources']));
     $application['accepted_documents_json'] = json_encode($application['accepted_documents']);
     if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'booking') {
         $application['cancel_link'] = self::link(array('menuaction' => 'booking.uiapplication.index'));
     } else {
         if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'bookingfrontend') {
             $application['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => phpgw::get_var('building_id', 'GET')));
         }
     }
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $application['audience_json'] = json_encode(array_map('intval', $application['audience']));
     $audience = $audience['results'];
     $this->install_customer_identifier_ui($application);
     $application['customer_identifier_types']['ssn'] = 'Date of birth or SSN';
     if ($orgnr) {
         $application['customer_identifier_type'] = 'organization_number';
         $application['customer_organization_number'] = $orgnr;
         $orgid = $this->organization_bo->so->get_orgid($orgnr);
         $organization = $this->organization_bo->read_single($orgid);
         if ($organization['contacts'][0]['name'] != '') {
             $application['contact_name'] = $organization['contacts'][0]['name'];
             $application['contact_email'] = $organization['contacts'][0]['email'];
             $application['contact_phone'] = $organization['contacts'][0]['phone'];
         } else {
             $application['contact_name'] = $organization['contacts'][1]['name'];
             $application['contact_email'] = $organization['contacts'][1]['email'];
             $application['contact_phone'] = $organization['contacts'][1]['phone'];
         }
     }
     self::render_template('application_new', array('application' => $application, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience, 'config' => $application_text));
 }
Exemplo n.º 23
0
    /**
     * Public method. 
     * 
     * @return unknown_type
     */
    public function index()
    {
        // Set the submit button label to its initial state
        $this->import_button_label = "Start import";
        $this->download_template_button_label = 'Download template';
        $check_method = 0;
        $get_identificator = false;
        if ($this->conv_type = phpgw::get_var('conv_type')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($this->location_id = phpgw::get_var('location_id', 'int')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($table = phpgw::get_var('table')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($check_method > 1) {
            phpgwapi_cache::session_set('property', 'import_message', 'choose only one target!');
            $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
        }
        phpgwapi_cache::session_set('property', 'import_settings', $_POST);
        $download_template = phpgw::get_var('download_template');
        if ($download_template) {
            $this->get_template($this->location_id);
        }
        // If the parameter 'importsubmit' exist (submit button in import form), set path
        if (phpgw::get_var("importsubmit")) {
            if ($GLOBALS['phpgw']->session->is_repost() && !phpgw::get_var('debug', 'bool')) {
                phpgwapi_cache::session_set('property', 'import_message', 'Hmm... looks like a repost!');
                $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
            }
            $start_time = time();
            // Start time of import
            $start = date("G:i:s", $start_time);
            echo "<h3>Import started at: {$start}</h3>";
            echo "<ul>";
            if ($this->conv_type) {
                if (preg_match('/\\.\\./', $this->conv_type)) {
                    throw new Exception("Not a valid file: {$this->conv_type}");
                }
                $file = PHPGW_SERVER_ROOT . "/property/inc/import/{$GLOBALS['phpgw_info']['user']['domain']}/{$this->conv_type}";
                if (is_file($file)) {
                    require_once $file;
                }
            } else {
                require_once PHPGW_SERVER_ROOT . "/property/inc/import/import_update_generic.php";
            }
            $this->debug = phpgw::get_var('debug', 'bool');
            $this->import_conversion = new import_conversion($this->location_id, $this->debug);
            // Get the path for user input or use a default path
            $files = array();
            if (isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name']) {
                $files[] = array('name' => $_FILES['file']['tmp_name'], 'type' => $_FILES['file']['type']);
            } else {
                $path = phpgw::get_var('path', 'string');
                $files = $this->get_files($path);
            }
            if (!$files) {
                phpgwapi_cache::session_set('property', 'import_message', 'Ingen filer er valgt');
                $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
            }
            foreach ($files as $file) {
                $valid_type = false;
                switch ($file['type']) {
                    case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
                    case 'application/vnd.oasis.opendocument.spreadsheet':
                    case 'application/vnd.ms-excel':
                        $this->csvdata = $this->getexceldata($file['name'], $get_identificator);
                        $valid_type = true;
                        break;
                    case 'text/csv':
                    case 'text/comma-separated-values':
                        $this->csvdata = $this->getcsvdata($file['name'], $get_identificator);
                        $valid_type = true;
                        break;
                    default:
                        throw new Exception("Not a valid filetype: {$file['type']}");
                }
                if ($valid_type) {
                    $result = $this->import();
                    $this->messages = array_merge($this->messages, $this->import_conversion->messages);
                    $this->warnings = array_merge($this->warnings, $this->import_conversion->warnings);
                    $this->errors = array_merge($this->errors, $this->import_conversion->errors);
                    $this->csvdata = array();
                    echo '<li class="info">Import: finished step ' . $result . '</li>';
                }
            }
            echo "</ul>";
            $end_time = time();
            $difference = ($end_time - $start_time) / 60;
            $end = date("G:i:s", $end_time);
            echo "<h3>Import ended at: {$end}. Import lasted {$difference} minutes.";
            if ($this->errors) {
                echo "<ul>";
                foreach ($this->errors as $error) {
                    echo '<li class="error">Error: ' . $error . '</li>';
                }
                echo "</ul>";
            }
            if ($this->warnings) {
                echo "<ul>";
                foreach ($this->warnings as $warning) {
                    echo '<li class="warning">Warning: ' . $warning . '</li>';
                }
                echo "</ul>";
            }
            if ($this->messages) {
                echo "<ul>";
                foreach ($this->messages as $message) {
                    echo '<li class="info">Message: ' . $message . '</li>';
                }
                echo "</ul>";
            }
            echo '<a href="' . $GLOBALS['phpgw']->link('/home.php') . '">Home</a>';
            echo '</br><a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiimport.index')) . '">Import</a>';
        } else {
            $import_settings = phpgwapi_cache::session_get('property', 'import_settings');
            $import_message = phpgwapi_cache::session_get('property', 'import_message');
            phpgwapi_cache::session_clear('property', 'import_message');
            $conv_list = $this->get_import_conv($import_settings['conv_type']);
            $conv_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($conv_list as $conv) {
                $selected = '';
                if ($conv['selected']) {
                    $selected = 'selected =  "selected"';
                }
                $conv_option .= <<<HTML
\t\t\t\t\t<option value='{$conv['id']}'{$selected}>{$conv['name']}</option>
HTML;
            }
            $tables = $this->valid_tables;
            ksort($tables);
            $table_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($tables as $table => $table_info) {
                $selected = $import_settings['table'] == $table ? 'selected =  "selected"' : '';
                $table_option .= <<<HTML
\t\t\t\t\t<option value='{$table}'{$selected}>{$table_info['name']}::{$table_info['permission']}</option>
HTML;
            }
            $entity = CreateObject('property.soadmin_entity');
            $entity_list = $entity->read(array('allrows' => true));
            $category_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($entity_list as $entry) {
                $category_list = $entity->read_category_tree2($entry['id']);
                foreach ($category_list as $category) {
                    $selected = $import_settings['location_id'] == $category['location_id'] ? 'selected =  "selected"' : '';
                    $category_option .= <<<HTML
\t\t\t\t\t\t<option value="{$category['location_id']}"{$selected}>{$category['name']}</option>
HTML;
                }
            }
            $home = $GLOBALS['phpgw']->link('/home.php');
            $action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiimport.index'));
            $debug_checked = isset($import_settings['debug']) && $import_settings['debug'] ? 'checked =  "checked"' : '';
            $html = <<<HTML
\t\t\t\t<h1><img src="rental/templates/base/images/32x32/actions/document-save.png" /> Importer ( MsExcel / CSV )</h1>
\t\t\t\t<div id="messageHolder">{$import_message}</div>
\t\t\t\t<form action="{$action}" method="post" enctype="multipart/form-data">
\t\t\t\t\t<fieldset>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="file">Choose file:</label>
\t\t\t\t\t\t\t<input type="file" name="file" id="file" title = 'Single file'/>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="path">Local path:</label>
\t\t\t\t\t\t\t<input type="text" name="path" id="path" value = '{$import_settings['path']}' title = 'Alle filer i katalogen'/>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="conv_type">Choose conversion:</label>
\t\t\t\t\t\t\t<select name="conv_type" id="conv_type">
\t\t\t\t\t\t\t{$conv_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="table">Choose Table:</label>
\t\t\t\t\t\t\t<select name="table" id="table">
\t\t\t\t\t\t\t{$table_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="category">Choose category:</label>
\t\t\t\t\t\t\t<select name="location_id" id="category">
\t\t\t\t\t\t\t{$category_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>

\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="debug">Debug:</label>
\t\t\t\t\t\t\t<input type="checkbox" name="debug" id="debug" {$debug_checked} value ='1' />
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<input type="submit" name="download_template" value="{$this->download_template_button_label}"  />
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<input type="submit" name="importsubmit" value="{$this->import_button_label}"  />
\t\t\t\t\t\t</p>
\t\t \t\t\t</fieldset>
\t\t\t\t</form>
\t\t\t\t<br><a href='{$home}'>Home</a>
HTML;
            echo $html;
        }
    }
Exemplo n.º 24
0
 /**
  * Get a list of users that have grants rights to their records at a location within an app
  *
  * @param string $app      Application name
  *				if emptry string, value of $GLOBALS['phpgw_info']['flags']['currentapp'] is used
  * @param string $location location within application
  *
  * @return array Array with account ids and corresponding rights
  */
 public function get_grants($app = '', $location = '')
 {
     $grant_rights = phpgwapi_cache::session_get('phpgwapi', "get_grants_{$app}_{$location}");
     if (!is_null($grant_rights)) {
         return $grant_rights;
         // nothing more to do
     }
     $grant_rights = $this->get_grants_type($app, $location, 0);
     $grant_mask = $this->get_grants_type($app, $location, 1);
     if (is_array($grant_mask)) {
         foreach ($grant_mask as $user_id => $mask) {
             if ($grant_rights[$user_id]) {
                 $grant_rights[$user_id] &= ~$mask;
                 if ($grant_rights[$user_id] <= 0) {
                     unset($grant_rights[$user_id]);
                 }
             }
         }
     }
     phpgwapi_cache::session_set('phpgwapi', "get_grants_{$app}_{$location}", $grant_rights);
     return $grant_rights;
 }
<?php 
if ($list_form) {
    ?>
<form id="<?php 
    echo $list_id;
    ?>
_form" method="GET">
<?php 
    $populate = phpgw::get_var('populate_form');
    //Avoid Notices
    $q = false;
    $s_type = false;
    if (isset($populate)) {
        $q = phpgwapi_cache::session_get('rental', 'resultunit_query');
        $s_type = phpgwapi_cache::session_get('rental', 'resultunit_search_type');
    }
    ?>
	<fieldset>
		<!-- Search -->
		<h3><?php 
    echo lang('search_options');
    ?>
</h3>
		<label for="ctrl_search_query"><?php 
    echo lang('search_for');
    ?>
</label>
		<input id="<?php 
    echo $list_id;
    ?>
Exemplo n.º 26
0
 /**
  * Import Facilit data to Portico Estate's rental module
  * The function assumes CSV files have been uploaded to a location on the server reachable by the
  * web server user.  The CSV files must correspond to the table names from Facilit, as exported
  * from Access. Field should be enclosed in single quotes and separated by comma.  The CSV files
  * must contain the column headers on the first line.
  * 
  * @return unknown_type
  */
 public function import()
 {
     $steps = 7;
     /* Import logic:
      * 
      * 1. Do step logic if the session variable is not set
      * 2. Set step result on session
      * 3. Set label for import button
      * 4. Log messages for this step
      *  
      */
     $this->messages = array();
     $this->warnings = array();
     $this->errors = array();
     // Import contract parties if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_parties')) {
         phpgwapi_cache::session_set('rental', 'facilit_parties', $this->import_parties());
         $this->log_messages(1);
         return '1';
     }
     // Import composites if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_composites')) {
         phpgwapi_cache::session_set('rental', 'facilit_composites', $this->import_composites());
         $this->log_messages(2);
         return '2';
     }
     // Load composite to contract link table if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_rentalobject_to_contract')) {
         phpgwapi_cache::session_set('rental', 'facilit_rentalobject_to_contract', $this->import_rentalobject_to_contract());
         $this->log_messages(3);
         return '3';
     }
     // Import contracts if not done before and put them on the users session
     // Prerequisites: Composites, parties, contract to composite bindings, and default values for accounts/project number for
     if (!phpgwapi_cache::session_get('rental', 'facilit_contracts')) {
         $composites = phpgwapi_cache::session_get('rental', 'facilit_composites');
         $rentalobject_to_contract = phpgwapi_cache::session_get('rental', 'facilit_rentalobject_to_contract');
         $parties = phpgwapi_cache::session_get('rental', 'facilit_parties');
         $location_id = $this->location_id;
         $defalt_values['account_in'] = rental_socontract::get_instance()->get_default_account($location_id, true);
         //IN
         $defalt_values['account_out'] = rental_socontract::get_instance()->get_default_account($location_id, false);
         //OUT
         $defalt_values['project_number'] = rental_socontract::get_instance()->get_default_project_number($location_id);
         //PROJECTNUMBER
         phpgwapi_cache::session_set('rental', 'facilit_contracts', $this->import_contracts($composites, $rentalobject_to_contract, $parties, $defalt_values));
         $this->log_messages(4);
         return '4';
     }
     // Import price items if not done before and put them on the users session
     // Prerequisites: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_contract_price_items')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         phpgwapi_cache::session_set('rental', 'facilit_contract_price_items', $this->import_contract_price_items($contracts));
         $this->log_messages(5);
         return '5';
     }
     // Import events if not done before and put them on the users session
     // Prerequistes: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_events')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         $event_data = phpgwapi_cache::session_get('rental', 'facilit_events');
         $regulation_id_location_id = isset($event_data) ? $event_data : array();
         phpgwapi_cache::session_set('rental', 'facilit_events', $this->import_events($contracts, $regulation_id_location_id));
         $this->log_messages(6);
         return '6';
     }
     // Import adjustments
     // Prerequistes: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_adjustments')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         $event_data = phpgwapi_cache::session_get('rental', 'facilit_events');
         $regulation_id_location_id = isset($event_data) ? $event_data : array();
         $this->import_adjustments($contracts, $regulation_id_location_id);
         $this->log_messages(7);
         $this->clean_up();
     }
     // We're done with the import, so clear all session variables so we're ready for a new one
     // We do not clear parties (same for all responsibility areas)
     // We do not clear event data, the array is just added for each
     phpgwapi_cache::session_clear('rental', 'facilit_composites');
     phpgwapi_cache::session_clear('rental', 'facilit_rentalobject_to_contract');
     phpgwapi_cache::session_clear('rental', 'facilit_contracts');
     phpgwapi_cache::session_clear('rental', 'facilit_contract_price_items');
     phpgwapi_cache::session_clear('rental', 'facilit_events');
     phpgwapi_cache::session_clear('rental', 'facilit_adjustments');
     return '7';
 }
Exemplo n.º 27
0
 public function view()
 {
     $GLOBALS['phpgw']->translation->add_app('property');
     $bo = CreateObject('property.botts');
     $ticketid = phpgw::get_var('id');
     $ticket = $bo->read_single($ticketid);
     $assignedto = $ticket['assignedto'];
     if (isset($assignedto) && $assignedto != '') {
         $assignedto_account = $GLOBALS['phpgw']->accounts->get($assignedto);
         //var_dump($assignedto_account);
         if ($assignedto_account) {
             $ticket['assigned_to_name'] = $assignedto_account->__toString();
         }
     }
     $contact_id = $ticket['contact_id'];
     if (isset($contact_id) && $contact_id != '') {
         $contacts = CreateObject('phpgwapi.contacts');
         $contact_data = $contacts->read_single_entry($contact_id, array('fn', 'tel_work', 'email'));
         $ticket['value_contact_name'] = $contact_data[0]['fn'];
         $ticket['value_contact_email'] = $contact_data[0]['email'];
         $ticket['value_contact_tel'] = $contact_data[0]['tel_work'];
     }
     $vendor_id = $ticket['vendor_id'];
     if (isset($vendor_id) && $vendor_id != '') {
         $contacts = CreateObject('property.sogeneric');
         $contacts->get_location_info('vendor', false);
         $custom = createObject('property.custom_fields');
         $vendor_data['attributes'] = $custom->find('property', '.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
         $vendor_data = $contacts->read_single(array('id' => $vendor_id), $vendor_data);
         if (is_array($vendor_data)) {
             foreach ($vendor_data['attributes'] as $attribute) {
                 if ($attribute['name'] == 'org_name') {
                     $ticket['value_vendor_name'] = $attribute['value'];
                     break;
                 }
             }
         }
     }
     $notes = $bo->read_additional_notes($ticketid);
     //$history = $bo->read_record_history($ticketid);
     $tickethistory = array();
     foreach ($notes as $note) {
         if ($note['value_publish']) {
             $tickethistory[] = array('date' => $note['value_date'], 'user' => $note['value_user'], 'note' => $note['value_note']);
         }
     }
     /*
     			foreach($history as $story)
     			{
     				
     				 // String search for filtering out ticket history. If the status contains e.g. "Budget changed"
     				 // the history bullet will not be incuded in the ticket history shown to frontend users.
     				 
     				if(
     					(	
     						strpos($story['value_action'],'Budget changed') === false && 
     						strpos($story['value_action'],'Priority changed') === false &&
     						strpos($story['value_action'],'actual cost changed') === false &&
     						strpos($story['value_action'],'Billable hours changed') === false
     					)
     				)
     				{
     					$tickethistory[] = array(
     						'date' => $story['value_date'],
     						'user' => $story['value_user'],
     						'action'=> $story['value_action'],
     						'new_value' => $story['value_new_value'],
     						'old_value' => $story['value_old_value']
     					);
     				}
     			}*/
     usort($tickethistory, array($this, "cmp"));
     $i = 0;
     foreach ($tickethistory as $foo) {
         $tickethistory2['record' . $i] = $foo;
         $i++;
     }
     $msglog = phpgwapi_cache::session_get('frontend', 'msgbox');
     phpgwapi_cache::session_clear('frontend', 'msgbox');
     $data = array('header' => $this->header_state, 'msgbox_data' => isset($msglog) ? $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog)) : array(), 'tabs' => $this->tabs, 'ticketinfo' => array('ticket' => $ticket, 'tickethistory' => $tickethistory2));
     $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 'ticketview'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('app_data' => $data));
 }
Exemplo n.º 28
0
 function import_calculation()
 {
     $GLOBALS['phpgw_info']['flags']['noframework'] = true;
     $workorder_id = phpgw::get_var('workorder_id');
     if ($_FILES) {
         $this->_import_calculation($workorder_id);
         $bofiles = CreateObject('property.bofiles');
         $file_name = @str_replace(' ', '_', $_FILES['file']['name']);
         $to_file = "{$bofiles->fakebase}/workorder/{$workorder_id}/{$file_name}";
         if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
             phpgwapi_cache::message_set(lang('This file already exists !'), 'error');
         } else {
             $bofiles->create_document_dir("workorder/{$workorder_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)))) {
                 phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
             }
             $bofiles->vfs->override_acl = 0;
         }
     }
     if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) {
         phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
     }
     $data = array('redirect' => $redirect ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.list_sub', 'user_lid' => $user_lid, 'voucher_id' => $voucher_id, 'paid' => $paid)) : null, 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)), 'form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiwo_hour.import_calculation')), 'workorder_id' => $workorder_id);
     $GLOBALS['phpgw']->xslttpl->add_file('wo_hour');
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('import_calculation' => $data));
 }
Exemplo n.º 29
0
    function index()
    {
        $type_id = $this->type_id;
        // $lookup use for pop-up
        $lookup = $this->lookup;
        // $lookup_name use in pop-up option "project"
        $lookup_name = phpgw::get_var('lookup_name');
        // use in option menu TENANT
        $lookup_tenant = phpgw::get_var('lookup_tenant', 'bool');
        $block_query = phpgw::get_var('block_query', 'bool');
        $dry_run = false;
        if (!$type_id) {
            $type_id = 1;
        }
        if ($lookup) {
            $GLOBALS['phpgw_info']['flags']['noframework'] = true;
        }
        if ($type_id && !$lookup_tenant) {
            $GLOBALS['phpgw_info']['flags']['menu_selection'] .= "::loc_{$type_id}";
        } else {
            $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::tenant';
        }
        if (!$this->acl_read) {
            $this->bocommon->no_access();
            return;
        }
        $second_display = phpgw::get_var('second_display', 'bool');
        $default_district = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'] : '';
        if ($default_district && !$second_display && !$this->district_id) {
            $this->bo->district_id = $default_district;
            $this->district_id = $default_district;
        }
        $datatable = array();
        $values_combo_box = array();
        $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();
        $_integration_set = array();
        foreach ($_config as $_config_section => $_config_section_data) {
            $integrationurl = '';
            if (isset($_config_section_data['url']) && !isset($_config_section_data['tab'])) {
                if (isset($_config_section_data['auth_hash_name']) && $_config_section_data['auth_hash_name'] && isset($_config_section_data['auth_url']) && $_config_section_data['auth_url']) {
                    //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_data['url'] = htmlspecialchars_decode($_config_section_data['url']);
                $_config_section_data['parametres'] = htmlspecialchars_decode($_config_section_data['parametres']);
                $integration_name = isset($_config_section_data['name']) && $_config_section_data['name'] ? $_config_section_data['name'] : lang('integration');
                parse_str($_config_section_data['parametres'], $output);
                foreach ($output as $_dummy => $_substitute) {
                    $_keys[] = $_substitute;
                    $__substitute = trim($_substitute, '_');
                    $_values[] = $this->{$__substitute};
                }
                unset($output);
                $_sep = '?';
                if (stripos($_config_section_data['url'], '?')) {
                    $_sep = '&';
                }
                $_param = str_replace($_keys, $_values, $_config_section_data['parametres']);
                $integrationurl = "{$_config_section_data['url']}{$_sep}{$_param}";
                $integrationurl .= "&{$_config_section_data['auth_key_name']}={$response}";
                //in the form: sakstittel=__loc1__.__loc4__
                $_config_section_data['location_data'] = htmlspecialchars_decode($_config_section_data['location_data']);
                $parameters_integration = array();
                if ($_config_section_data['location_data']) {
                    parse_str($_config_section_data['location_data'], $output);
                    foreach ($output as $_name => $_substitute) {
                        if ($_substitute == '__loc1__') {
                            $_substitute = '__location_code__';
                        }
                        $parameters_integration['parameter'][] = array('name' => $_name, 'source' => trim($_substitute, '_'));
                    }
                }
                $_integration_set[] = array('name' => $integration_name, 'parameters' => $parameters_integration, 'url' => $integrationurl);
            }
        }
        if (phpgw::get_var('phpgw_return_as') != 'json') {
            if (!$lookup) {
                $datatable['menu'] = $this->bocommon->get_menu();
            }
            $datatable['config']['base_url'] = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $type_id, 'query' => $this->query, 'district_id' => $this->district_id, 'part_of_town_id' => $this->part_of_town_id, 'lookup' => $lookup, 'lookup_tenant' => $lookup_tenant, 'lookup_name' => $lookup_name, 'cat_id' => $this->cat_id, 'status' => $this->status, 'location_code' => $this->location_code));
            $datatable['config']['allow_allrows'] = true;
            $datatable['config']['base_java_url'] = "menuaction:'property.uilocation.index'," . "type_id:'{$type_id}'," . "query:'{$this->query}'," . "district_id: '{$this->district_id}'," . "part_of_town_id:'{$this->part_of_town_id}'," . "lookup:'{$lookup}'," . "second_display:1," . "lookup_tenant:'{$lookup_tenant}'," . "lookup_name:'{$lookup_name}'," . "cat_id:'{$this->cat_id}'," . "status:'{$this->status}'," . "location_code:'{$this->location_code}'," . "block_query:'{$block_query}'";
            // $values_combo_box  se usar� para escribir en el HTML, usando el XSLT
            $values_combo_box[0] = $this->bocommon->select_category_list(array('format' => 'filter', 'selected' => $this->cat_id, 'type' => 'location', 'type_id' => $type_id, 'order' => 'descr'));
            $default_value = array('id' => '', 'name' => lang('no category'));
            array_unshift($values_combo_box[0], $default_value);
            $values_combo_box[1] = $this->bocommon->select_district_list('filter', $this->district_id);
            $default_value = array('id' => '', 'name' => lang('no district'));
            array_unshift($values_combo_box[1], $default_value);
            $values_combo_box[2] = $this->bocommon->select_part_of_town('filter', $this->part_of_town_id, $this->district_id);
            $default_value = array('id' => '', 'name' => lang('no part of town'));
            array_unshift($values_combo_box[2], $default_value);
            if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter'] == 'owner') {
                $values_combo_box[3] = $this->bo->get_owner_list('filter', $this->filter);
            } else {
                $values_combo_box[3] = $this->bo->get_owner_type_list('filter', $this->filter);
            }
            $default_value = array('id' => '', 'name' => lang('show all'));
            array_unshift($values_combo_box[3], $default_value);
            $datatable['actions']['form'] = array(array('action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $type_id, 'district_id' => $this->district_id, 'part_of_town_id' => $this->part_of_town_id, 'lookup' => $lookup, 'lookup_tenant' => $lookup_tenant, 'lookup_name' => $lookup_name, 'cat_id' => $this->cat_id)), 'fields' => array('field' => array(array('id' => 'btn_cat_id', 'name' => 'cat_id', 'value' => lang('Category'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 1), array('id' => 'btn_district_id', 'name' => 'district_id', 'value' => lang('District'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 2), array('id' => 'btn_part_of_town_id', 'name' => 'part_of_town_id', 'value' => lang('Part of Town'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 3), array('id' => 'btn_owner_id', 'name' => 'owner_id', 'value' => lang('Filter'), 'type' => 'button', 'style' => 'filter', 'tab_index' => 4), array('type' => 'link', 'id' => 'btn_columns', 'url' => "Javascript:window.open('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.columns', 'type_id' => $type_id, 'lookup' => $this->lookup)) . "','','width=300,height=600,scrollbars=1')", 'value' => lang('columns'), 'tab_index' => 9), array('type' => 'button', 'id' => 'btn_export', 'value' => lang('download'), 'tab_index' => 8), array('type' => 'hidden', 'id' => 'type_id', 'value' => $type_id)), 'hidden_value' => array(array('id' => 'values_combo_box_0', 'value' => $this->bocommon->select2String($values_combo_box[0])), array('id' => 'values_combo_box_1', 'value' => $this->bocommon->select2String($values_combo_box[1])), array('id' => 'values_combo_box_2', 'value' => $this->bocommon->select2String($values_combo_box[2])), array('id' => 'values_combo_box_3', 'value' => $this->bocommon->select2String($values_combo_box[3]))))));
            $button_def[] = "oNormalButton_0";
            $button_def[] = "oNormalButton_1";
            $button_def[] = "oNormalButton_2";
            $code_inner[] = "{order:0, name:'btn_search',funct:'onSearchClick'}";
            $code_inner[] = "{order:1, name:'btn_new',\tfunct:'onNewClick'}";
            $code_inner[] = "{order:2, name:'btn_export',funct:'onDownloadClick'}";
            $_js_functions = '';
            foreach ($_integration_set as $i => $_integration) {
                $button_def[] = 'oNormalButton_' . ($i + 3);
                $code_inner[] = "{order:" . ($i + 3) . ", name:'btn_integration_{$i}',funct:'onIntegrationClick_{$i}'}";
                $datatable['actions']['form'][0]['fields']['field'][] = array('type' => 'button', 'id' => "btn_integration_{$i}", 'value' => $_integration['name'], 'tab_index' => 10 + $i);
                $_js_functions .= <<<JS
\t\t\t\t\t\tthis.onIntegrationClick_{$i} = function()
\t\t\t\t\t\t{
\t\t\t\t\t\t\twindow.open(values_ds.integrationurl_{$i},'window');
\t\t\t\t\t\t}
JS;
            }
            $code = 'var ' . implode(',', $button_def) . ";\n";
            $code .= 'var normalButtons = [' . "\n" . implode(",\n", $code_inner) . "\n];";
            $code .= $_js_functions;
            $GLOBALS['phpgw']->js->add_code('', $code);
            if (!$block_query) {
                $datatable['actions']['form'][0]['fields']['field'][] = array('id' => 'btn_search', 'name' => 'search', 'value' => lang('search'), 'type' => 'button', 'tab_index' => 6);
                $datatable['actions']['form'][0]['fields']['field'][] = array('name' => 'query', 'id' => 'txt_query', 'value' => $this->query, 'type' => 'text', 'size' => 28, 'onkeypress' => 'return pulsar(event)', 'tab_index' => 5);
            }
            if (!$lookup) {
                $datatable['actions']['form'][0]['fields']['field'][] = array('type' => 'button', 'id' => 'btn_new', 'value' => lang('add'), 'tab_index' => 7);
            }
            $dry_run = true;
        }
        $location_list = array();
        //cramirez: $dry_run avoid to load all data the first time
        $location_list = $this->bo->read(array('type_id' => $type_id, 'lookup_tenant' => $lookup_tenant, 'lookup' => $lookup, 'allrows' => $this->allrows, 'dry_run' => $dry_run));
        $uicols = $this->bo->uicols;
        $content = array();
        $j = 0;
        if (isset($location_list) && is_array($location_list)) {
            foreach ($location_list as $location) {
                for ($i = 0; $i < count($uicols['name']); $i++) {
                    if ($uicols['input_type'][$i] != 'hidden') {
                        if (isset($location['query_location'][$uicols['name'][$i]])) {
                            $datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
                            $datatable['rows']['row'][$j]['column'][$i]['statustext'] = lang('search');
                            $datatable['rows']['row'][$j]['column'][$i]['value'] = $location[$uicols['name'][$i]];
                            $datatable['rows']['row'][$j]['column'][$i]['format'] = 'link';
                            $datatable['rows']['row'][$j]['column'][$i]['java_link'] = true;
                            $datatable['rows']['row'][$j]['column'][$i]['link'] = $location['query_location'][$uicols['name'][$i]];
                        } else {
                            $datatable['rows']['row'][$j]['column'][$i]['value'] = $location[$uicols['name'][$i]];
                            //$datatable['rows']['row'][$j]['column'][$i]['value'] 			= $i;
                            $datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
                            $datatable['rows']['row'][$j]['column'][$i]['lookup'] = $lookup;
                            $datatable['rows']['row'][$j]['column'][$i]['align'] = isset($uicols['align'][$i]) ? $uicols['align'][$i] : 'center';
                            if (isset($uicols['datatype']) && isset($uicols['datatype'][$i]) && $uicols['datatype'][$i] == 'link' && $location[$uicols['name'][$i]]) {
                                $datatable['rows']['row'][$j]['column'][$i]['format'] = 'link';
                                $datatable['rows']['row'][$j]['column'][$i]['value'] = lang('link');
                                $datatable['rows']['row'][$j]['column'][$i]['link'] = $location[$uicols['name'][$i]];
                                $datatable['rows']['row'][$j]['column'][$i]['target'] = '_blank';
                            }
                        }
                    } else {
                        $datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
                        $datatable['rows']['row'][$j]['column'][$i]['value'] = $location[$uicols['name'][$i]];
                    }
                    $datatable['rows']['row'][$j]['hidden'][$i]['value'] = $location[$uicols['name'][$i]];
                    $datatable['rows']['row'][$j]['hidden'][$i]['name'] = $uicols['name'][$i];
                }
                $j++;
            }
        }
        // NO pop-up
        $datatable['rowactions']['action'] = array();
        if (!$lookup) {
            $parameters = array('parameter' => array(array('name' => 'location_code', 'source' => 'location_code')));
            $parameters2 = array('parameter' => array(array('name' => 'sibling', 'source' => 'location_code')));
            $parameters3 = array('parameter' => array(array('name' => 'search_for', 'source' => 'location_code')));
            if ($this->acl->check('run', PHPGW_ACL_READ, 'rental')) {
                $datatable['rowactions']['action'][] = array('my_name' => 'view', 'text' => lang('contracts'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'rental.uicontract.index', 'search_type' => 'location_id', 'contract_status' => 'all', 'populate_form' => 'yes')), 'parameters' => $parameters3);
                $datatable['rowactions']['action'][] = array('my_name' => 'view', 'text' => lang('composites'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'rental.uicomposite.index', 'search_type' => 'location_id', 'populate_form' => 'yes')), 'parameters' => $parameters3);
            }
            if ($this->acl_read) {
                $datatable['rowactions']['action'][] = array('my_name' => 'view', 'text' => lang('view'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.view', 'lookup_tenant' => $lookup_tenant)), 'parameters' => $parameters);
                $datatable['rowactions']['action'][] = array('my_name' => 'view', 'text' => lang('open view in new window'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.view', 'lookup_tenant' => $lookup_tenant, 'target' => '_blank')), 'parameters' => $parameters);
            }
            if ($this->acl_add) {
                $datatable['rowactions']['action'][] = array('my_name' => 'edit', 'text' => lang('add'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.edit', 'lookup_tenant' => $lookup_tenant)), 'parameters' => $parameters2);
            }
            if ($this->acl_edit) {
                $datatable['rowactions']['action'][] = array('my_name' => 'edit', 'text' => lang('edit'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.edit', 'lookup_tenant' => $lookup_tenant)), 'parameters' => $parameters);
                $datatable['rowactions']['action'][] = array('my_name' => 'edit', 'text' => lang('open edit in new window'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.edit', 'lookup_tenant' => $lookup_tenant, 'target' => '_blank')), 'parameters' => $parameters);
            }
            $jasper = execMethod('property.sojasper.read', array('location_id' => $GLOBALS['phpgw']->locations->get_id('property', $this->acl_location)));
            foreach ($jasper as $report) {
                $datatable['rowactions']['action'][] = array('my_name' => 'edit', 'text' => lang('open JasperReport %1 in new window', $report['title']), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uijasper.view', 'jasper_id' => $report['id'], 'target' => '_blank')), 'parameters' => $parameters);
            }
            foreach ($_integration_set as $_integration) {
                $datatable['rowactions']['action'][] = array('my_name' => 'integration', 'text' => $_integration['name'], 'action' => $_integration['url'] . '&target=_blank', 'parameters' => $_integration['parameters']);
            }
            if ($this->acl_delete) {
                $datatable['rowactions']['action'][] = array('my_name' => 'delete', 'text' => lang('delete'), 'confirm_msg' => lang('do you really want to delete this entry'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.delete', 'lookup_tenant' => $lookup_tenant)), 'parameters' => $parameters);
            }
            if ($this->acl_add) {
                $datatable['rowactions']['action'][] = array('my_name' => 'add', 'text' => lang('add'), 'action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.edit', 'type_id' => $type_id, 'parent' => $this->location_code)));
            }
            unset($parameters);
        }
        //$uicols_count indicates the number of columns to display in actuall option-menu. this variable was set in $this->bo->read()
        $uicols_count = count($uicols['descr']);
        for ($i = 0; $i < $uicols_count; $i++) {
            //all colums should be have formatter
            $datatable['headers']['header'][$i]['formatter'] = !isset($uicols['formatter'][$i]) || !$uicols['formatter'][$i] ? '""' : $uicols['formatter'][$i];
            if ($uicols['input_type'][$i] != 'hidden') {
                $datatable['headers']['header'][$i]['name'] = $uicols['name'][$i];
                $datatable['headers']['header'][$i]['text'] = $uicols['descr'][$i];
                $datatable['headers']['header'][$i]['visible'] = true;
                $datatable['headers']['header'][$i]['format'] = $this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
                $datatable['headers']['header'][$i]['sortable'] = false;
                //$datatable['headers']['header'][$i]['formatter']		= (isset($uicols['formatter'][$i])? $uicols['formatter'][$i]:"");
                if ($uicols['name'][$i] == 'loc1') {
                    $datatable['headers']['header'][$i]['sortable'] = true;
                    $datatable['headers']['header'][$i]['sort_field'] = 'fm_location1.loc1';
                } else {
                    if ($uicols['name'][$i] == 'street_name') {
                        $datatable['headers']['header'][$i]['sortable'] = true;
                        $datatable['headers']['header'][$i]['sort_field'] = 'street_name';
                    } else {
                        if (isset($uicols['cols_return_extra'][$i]) && ($uicols['cols_return_extra'][$i] != 'T' || $uicols['cols_return_extra'][$i] != 'CH')) {
                            $datatable['headers']['header'][$i]['sortable'] = true;
                            $datatable['headers']['header'][$i]['sort_field'] = $uicols['name'][$i];
                        }
                    }
                }
            } else {
                $datatable['headers']['header'][$i]['name'] = $uicols['name'][$i];
                $datatable['headers']['header'][$i]['text'] = $uicols['descr'][$i];
                $datatable['headers']['header'][$i]['visible'] = false;
                $datatable['headers']['header'][$i]['sortable'] = false;
                $datatable['headers']['header'][$i]['format'] = 'hidden';
            }
        }
        // for POP-UPs
        if ($lookup) {
            $input_name = phpgwapi_cache::session_get('property', 'lookup_fields');
            $function_exchange_values = '';
            if (is_array($input_name)) {
                for ($k = 0; $k < count($input_name); $k++) {
                    $function_exchange_values .= 'opener.document.getElementsByName("' . $input_name[$k] . '")[0].value = "";' . "\r\n";
                }
            }
            for ($i = 0; $i < count($uicols['name']); $i++) {
                if (isset($uicols['exchange'][$i]) && $uicols['exchange'][$i]) {
                    $function_exchange_values .= 'opener.document.getElementsByName("' . $uicols['name'][$i] . '")[0].value = "";' . "\r\n";
                    $function_exchange_values .= 'opener.document.getElementsByName("' . $uicols['name'][$i] . '")[0].value = valida(data.getData("' . $uicols['name'][$i] . '"));' . "\r\n";
                }
            }
            $function_exchange_values .= 'window.close()';
            $datatable['exchange_values'] = $function_exchange_values;
            $function_valida = <<<JS
\t\t\t\t\tvar pos = data.indexOf('</a>');
\t\t\t\t\t\tif(pos==-1)
\t\t\t\t\t\t{
\t\t\t\t\t\t\treturn data;
\t\t\t\t\t\t}
\t\t\t\t\t\telse
\t\t\t\t\t\t{
\t\t\t\t\t\t\tpos = data.indexOf('>');
\t\t\t\t\t\t\tvar valor = data.slice(pos+1);
\t\t\t\t\t\t\tpos = valor.indexOf('<');
\t\t\t\t\t\t\tvalor = valor.slice(0,pos);
\t\t\t\t\t\t\treturn valor;
\t\t\t\t\t\t}
JS;
            $datatable['valida'] = $function_valida;
        }
        // path for property.js
        $property_js = "/property/js/yahoo/property.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, '/'));
        }
        $datatable['property_js'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js;
        // Pagination and sort values
        $datatable['pagination']['records_start'] = (int) $this->bo->start;
        $datatable['pagination']['records_limit'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
        if ($dry_run) {
            $datatable['pagination']['records_returned'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
        } else {
            $datatable['pagination']['records_returned'] = count($location_list);
        }
        $datatable['pagination']['records_total'] = $this->bo->total_records;
        if (phpgw::get_var("start") == "" && phpgw::get_var("order", 'string') == "") {
            $datatable['sorting']['order'] = 'loc1';
            // name key Column in myColumnDef
            $datatable['sorting']['sort'] = 'asc';
            // ASC / DESC
        } else {
            $datatable['sorting']['order'] = phpgw::get_var('order', 'string');
            // name of column of Database
            $datatable['sorting']['sort'] = phpgw::get_var('sort', 'string');
            // ASC / DESC
        }
        $appname = lang('location');
        if ($lookup) {
            $lookup_list = $GLOBALS['phpgw']->session->appsession('lookup_name', 'property');
            $function_msg = $lookup_list[$lookup_name];
        } else {
            if ($lookup_tenant) {
                $function_msg = lang('Tenant');
            } else {
                $function_msg = $uicols['descr'][$type_id];
            }
        }
        //-- BEGIN----------------------------- JSON CODE ------------------------------
        //values for Pagination
        $json = array('recordsReturned' => $datatable['pagination']['records_returned'], 'totalRecords' => (int) $datatable['pagination']['records_total'], 'startIndex' => $datatable['pagination']['records_start'], 'sort' => $datatable['sorting']['order'], 'dir' => $datatable['sorting']['sort'], 'records' => array());
        foreach ($_integration_set as $i => $_integration) {
            $json["integrationurl_{$i}"] = $_integration['url'];
        }
        // values for datatable
        if (isset($datatable['rows']['row']) && is_array($datatable['rows']['row'])) {
            foreach ($datatable['rows']['row'] as $row) {
                $json_row = array();
                foreach ($row['column'] as $column) {
                    if (isset($column['format']) && $column['format'] == "link" && isset($column['java_link']) && $column['java_link'] == true) {
                        $json_row[$column['name']] = "<a href='#' id='" . $column['link'] . "' onclick='javascript:filter_data(this.id);'>" . $column['value'] . "</a>";
                    } else {
                        if (isset($column['format']) && $column['format'] == "link") {
                            $json_row[$column['name']] = "<a href='" . $column['link'] . "' target='_blank'>" . $column['value'] . "</a>";
                        } else {
                            $json_row[$column['name']] = $column['value'];
                        }
                    }
                }
                $json['records'][] = $json_row;
            }
        }
        // values for control select
        //cr@ccfirst.com 10/09/08 values passed for update select in YUI
        $opt_cb_depend = $this->bocommon->select_part_of_town('filter', $this->part_of_town_id, $this->district_id);
        $default_value = array('id' => '', 'name' => '!no part of town');
        array_unshift($opt_cb_depend, $default_value);
        $json['hidden']['dependent'][] = array('id' => $this->part_of_town_id, 'value' => $this->bocommon->select2String($opt_cb_depend));
        // right in datatable
        if (isset($datatable['rowactions']['action']) && is_array($datatable['rowactions']['action'])) {
            $json['rights'] = $datatable['rowactions']['action'];
        }
        if (phpgw::get_var('phpgw_return_as') == 'json') {
            return $json;
        }
        $datatable['json_data'] = json_encode($json);
        //-------------------- JSON CODE ----------------------
        // Prepare template variables and process XSLT
        $template_vars = array();
        $template_vars['datatable'] = $datatable;
        $GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', $template_vars);
        phpgwapi_yui::load_widget('dragdrop');
        phpgwapi_yui::load_widget('datatable');
        phpgwapi_yui::load_widget('menu');
        phpgwapi_yui::load_widget('connection');
        //// cramirez: necesary for include a partucular js
        phpgwapi_yui::load_widget('loader');
        //cramirez: necesary for use opener . Avoid error JS
        phpgwapi_yui::load_widget('tabview');
        phpgwapi_yui::load_widget('paginator');
        //FIXME this one is only needed when $lookup==true - so there is probably an error
        phpgwapi_yui::load_widget('animation');
        if (!isset($GLOBALS['phpgw']->css) || !is_object($GLOBALS['phpgw']->css)) {
            $GLOBALS['phpgw']->css = createObject('phpgwapi.css');
        }
        // Prepare CSS Style
        $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/container/assets/skins/sam/container.css');
        $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
        //Title of Page
        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
        // Prepare YUI Library
        $GLOBALS['phpgw']->js->validate_file('yahoo', 'location.index', 'property');
        //$this->save_sessiondata();
    }
Exemplo n.º 30
0
 function read_sessiondata()
 {
     $data = phpgwapi_cache::session_get('property.request', 'session_data', $data);
     $this->start = $data['start'];
     $this->query = $data['query'];
     $this->filter = $data['filter'];
     $this->sort = $data['sort'];
     $this->order = $data['order'];
     $this->district_id = $data['district_id'];
     $this->cat_id = $data['cat_id'];
     $this->property_cat_id = $data['property_cat_id'];
     $this->status_id = $data['status_id'];
     $this->degree_id = $data['degree_id'];
     $this->building_part = $data['building_part'];
     $this->responsible_unit = $data['responsible_unit'];
     $this->recommended_year = $data['recommended_year'];
     $this->start_date = isset($data['start_date']) ? $data['start_date'] : '';
     $this->end_date = isset($data['end_date']) ? $data['end_date'] : '';
 }