Пример #1
0
 public function getTable($pkey = '')
 {
     _has_user_access_permission(TRUE, array('admin', 'management_company'));
     $params = ($params = unserialize_object($pkey)) && is_array($params) ? $params : array();
     $company_id = $this->current_user->group_id == 1 ? array_key_exists(SYS_COMPANY_ID, $params) && gtzero_integer($params[SYS_COMPANY_ID]) ? to_int($params[SYS_COMPANY_ID]) : 0 : $this->current_user->company_id;
     $input = array('iDisplayStart' => $this->_post_args('iDisplayStart', ARGS_TYPE_INT), 'iDisplayLength' => $this->_post_args('iDisplayLength', ARGS_TYPE_INT, 0, array('gtzero' => FALSE)), 'iSortCol_0' => $this->_post_args('iSortCol_0', ARGS_TYPE_STRING), 'iSortingCols' => $this->_post_args('iSortingCols', ARGS_TYPE_INT), 'sSearch' => $this->_post_args('sSearch', ARGS_TYPE_STRING), 'sEcho' => $this->_post_args('sEcho', ARGS_TYPE_STRING), 'company_id' => $this->current_user->group_id == 1 ? $this->_post_args('company_id', ARGS_TYPE_INT, $company_id, array('override' => TRUE)) : $this->current_user->company_id, 'group_id' => $this->_post_args('group_id', ARGS_TYPE_INT));
     $qrows = $this->user_m->ajax_gets($input);
     foreach ($qrows['aaData'] as &$qrow) {
         $actions = array('view' => array('href' => site_url('users/show/' . serialize_object(array(SYS_USER_ID => $qrow->user_id))), 'title' => 'User Detail (<small>' . $qrow->full_name . '</small>)', 'text' => 'User Detail', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "User Detail <small>' . $qrow->full_name . '</small>", "modal" : {"buttons" : false, "size" : ""}, "params" : "echo"}\'', 'class' => array()), 'edit' => array('href' => site_url('users/edit/' . serialize_object(array(SYS_USER_ID => $qrow->user_id))), 'title' => 'User Detail (<small>' . $qrow->full_name . '</small>)', 'text' => 'Edit User', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "User Detail <small>' . $qrow->full_name . '</small>", "modal" : {"buttons" : true, "override" : true, "size" : "", "modal_success_callback" : "gl.user.listing.load_grid(g);"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => array()), 'delete' => array('href' => site_url('users/delete/' . serialize_object(array(SYS_USER_ID => $qrow->user_id))), 'title' => 'User <small>' . $qrow->full_name . '</small>', 'text' => 'Delete User', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "User Detail <small>' . $qrow->full_name . '</small>", "modal" : {"buttons" : true, "override" : true, "modal_success_callback" : "gl.user.listing.load_grid(g);"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => array()));
         $qrow = array($qrow->company_name, $qrow->full_name, $qrow->email, $qrow->phone, $qrow->group_description, $qrow->user_id == $this->current_user->user_id ? gtzero_integer($qrow->active) ? 'Active' : 'Inactive' : theme_anchor_button(array('type' => BUTTON_TYPE_ANCHOR, 'href' => gtzero_integer($qrow->active) ? site_url("users/deactivate/" . serialize_object(array(SYS_USER_ID => $qrow->user_id))) : site_url("users/activate/" . serialize_object(array(SYS_USER_ID => $qrow->user_id))), 'title' => gtzero_integer($qrow->active) ? 'De-activate User' : 'Activate User', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "' . (gtzero_integer($qrow->active) ? 'Deactivate' : 'Activate') . ' User <small>' . $qrow->full_name . '</small>", "modal" : {"buttons" : true, "override" : true, "modal_success_callback" : "gl.user.listing.load_grid(g);"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => implode(' ', array(NOICON_BUTTON, gtzero_integer($qrow->active) ? 'btn-success' : 'btn-danger', 'btn-xs btip')), 'icon' => ICON_STATUS_CHANGE . ' mr5', 'text' => gtzero_integer($qrow->active) ? 'Active' : 'Inactive')), local_time($qrow->created_on, 'M d, Y @ h:ia'), $qrow->user_id == $this->current_user->user_id ? '' : theme_button_dropdown($actions));
         if (_check_company_user_access()) {
             unset($qrow[0]);
             $qrow = array_values($qrow);
         }
     }
     echo json_encode($qrows);
 }
Пример #2
0
 public function getTable($pkey = '')
 {
     _has_user_access_permission(TRUE, array('admin', 'staff'));
     $params = ($params = unserialize_object($pkey)) && is_array($params) ? $params : array();
     $input = array('iDisplayStart' => $this->_post_args('iDisplayStart', ARGS_TYPE_INT), 'iDisplayLength' => $this->_post_args('iDisplayLength', ARGS_TYPE_INT, 0, array('gtzero' => FALSE)), 'iSortCol_0' => $this->_post_args('iSortCol_0', ARGS_TYPE_STRING), 'iSortingCols' => $this->_post_args('iSortingCols', ARGS_TYPE_INT), 'sSearch' => $this->_post_args('sSearch', ARGS_TYPE_STRING), 'sEcho' => $this->_post_args('sEcho', ARGS_TYPE_STRING));
     $listing = $this->company_m->ajax_get_parts($input);
     foreach ($listing['aaData'] as &$qrow) {
         $company_id = $qrow->company_id;
         $company_name = $qrow->company_name;
         $actions = array();
         $actions['view'] = array('href' => site_url('agencies/show/' . serialize_object(array(SYS_COMPANY_ID => $qrow->company_id))), 'title' => 'Agency Detail (<small>' . $company_name . '</small>)', 'text' => 'Agency Detail', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "Agency Detail <small>' . $company_name . '</small>", "modal" : {"buttons" : false}, "params" : "echo"}\'', 'class' => array());
         if ($this->current_user->group_id == GROUP_ADMIN) {
             $actions['edit'] = array('href' => site_url('agencies/edit/' . serialize_object(array(SYS_COMPANY_ID => $qrow->company_id))), 'title' => 'Agency Detail (<small>' . $company_name . '</small>)', 'text' => 'Edit Agency', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "Agency Detail <small>' . $company_name . '</small>", "modal" : {"buttons" : true, "override" : true, "modal_success_callback" : "updateData();"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => array());
             $actions['delete'] = array('href' => site_url('agencies/delete/' . serialize_object(array(SYS_COMPANY_ID => $qrow->company_id))), 'title' => 'Agency <small>' . $company_name . '</small>', 'text' => 'Delete Agency', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "Agency Detail <small>' . $company_name . '</small>", "modal" : {"buttons" : true, "override" : true, "modal_success_callback" : "updateData();"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => array());
         }
         /*
         if( in_array($this->current_user->group_id, array(GROUP_ADMIN)) ) {
         	$actions['contacts'] = array(
         				'href' 		=> site_url('contacts/index/'.serialize_object(array( SYS_REF_ID => $qrow->company_id, SYS_CONTACT_TYPE_ID => CONTACT_TYPE_COMPANY) )),
         				'title'		=> 'Contacts <small>(Client: '.$company_name.')</small>',
         				'text'		=> 'Contacts',
         				'params'	=> 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "Contacts <small>(Agency: '.$company_name.')</small>", "modal" : {"buttons" : false, "footer" : false, "size" : "modal-lg", "wizard" : true, "override" : true, "nopadd" : false, "modal_before_close_callback" : "gl.contact.listing.close_grid(g);", "callback" : "gl.contact.listing.load_grid(g);"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "next"}}\'',
         				'class'		=> array()
         			);
         
         }
         
         if( in_array($this->current_user->group_id, array(GROUP_ADMIN)) ) {
         	$actions['new_contact'] = array(
         				'href' 		=> site_url('contacts/create/'.serialize_object(array( SYS_REF_ID => $qrow->company_id, SYS_CONTACT_TYPE_ID => CONTACT_TYPE_COMPANY))),
         				'title'		=> 'Contact Detail <small>(Client: '.$company_name.')</small>',
         				'text'		=> 'New Contact',
         				'params'	=> 'data-ajax="wdpajax" data-options=\'{"form_method" : "POST", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "Contact Detail <small>(Agency: '.$company_name.')</small>", "modal" : {"buttons" : true}, "params" : "echo"}\'',
         				'class'		=> array()
         			);
         
         }
         */
         $qrow = array($qrow->company_name, $qrow->address, !empty($qrow->gmt_offset) ? _date_lang_shorttag($qrow->gmt_offset) : '', $this->current_user->group_id == GROUP_ADMIN ? theme_anchor_button(array('type' => BUTTON_TYPE_ANCHOR, 'href' => gtzero_integer($qrow->active) ? site_url("agencies/deactivate/" . serialize_object(array(SYS_COMPANY_ID => $qrow->company_id))) : site_url("agencies/activate/" . serialize_object(array(SYS_COMPANY_ID => $qrow->company_id))), 'title' => gtzero_integer($qrow->active) ? 'De-activate Agency' : 'Activate Agency', 'params' => 'data-ajax="wdpajax" data-options=\'{"form_method" : "GET", "data_type" : "HTML", "role" : "modal", "created_new" : true, "title" : "' . (gtzero_integer($qrow->active) ? 'Deactivate' : 'Activate') . ' Agency <small>' . $company_name . '</small>", "modal" : {"buttons" : true, "override" : true, "modal_success_callback" : "updateData();"}, "params" : "echo", "grid" : {"_init" : true, "gType" : "default"}}\'', 'class' => implode(' ', array(NOICON_BUTTON, gtzero_integer($qrow->active) ? 'btn-success' : 'btn-danger', 'btn-xs btip')), 'icon' => ICON_STATUS_CHANGE . ' mr5', 'text' => gtzero_integer($qrow->active) ? 'Active' : 'Inactive')) : (gtzero_integer($qrow->active) ? 'Active' : 'Inactive'), local_time($qrow->created_on, 'M d, Y @ h:ia'), $qrow->created_by_name, theme_button_dropdown($actions));
     }
     echo json_encode($listing);
 }