Example #1
0
 public static function user_suggestbox($str)
 {
     $wild = DB::Concat(DB::qstr('%'), DB::qstr($str), DB::qstr('%'));
     $contacts_raw = CRM_ContactsCommon::get_contacts(array('!login' => '', '(~"first_name' => $wild, '|~"last_name' => $wild));
     $contacts = array();
     $contacts_login_ids = array();
     foreach ($contacts_raw as $c) {
         $contacts_login_ids[] = $c['login'];
         $contacts[$c['login']] = $c;
     }
     if (!empty($contacts_login_ids)) {
         $qry_ids = ' OR id IN (' . implode(',', $contacts_login_ids) . ')';
     } else {
         $qry_ids = '';
     }
     $ret = DB::SelectLimit('SELECT id, active FROM user_login WHERE login ' . DB::like() . ' ' . $wild . $qry_ids . ' ORDER BY active DESC', 10);
     $result = array();
     while ($row = $ret->FetchRow()) {
         $result[$row['id']] = self::user_label($row['id']);
         if (!$row['active']) {
             $result[$row['id']] .= ' (' . __('Inactive') . ')';
         }
     }
     asort($result);
     return $result;
 }
Example #2
0
 public function applet($conf, &$opts)
 {
     $opts['go'] = false;
     $this->date = $this->get_module_variable_or_unique_href_variable('date');
     if ($this->date == null) {
         $this->date = date('Y-m-15');
     }
     $this->set_module_variable('date', $this->date);
     $this->date = strtotime($this->date);
     $theme = $this->pack_module('Base/Theme');
     $theme->assign('nextyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date + 30 * 24 * 60 * 60))));
     $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d'))));
     $theme->assign('prevyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date - 30 * 24 * 60 * 60))));
     $link_text = $this->create_unique_href_js(array('date' => '__YEAR__-__MONTH__-__DAY__'));
     $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'month', null, null, ''));
     $day_headers = array();
     $day = strtotime('Sun');
     $day = strtotime('+' . Utils_PopupCalendarCommon::get_first_day_of_week() . ' days', $day);
     for ($i = 0; $i < 7; $i++) {
         $day_headers[] = __date('D', $day);
         $day = strtotime('+1 day', $day);
     }
     $year = array();
     $me = CRM_ContactsCommon::get_my_record();
     CRM_Calendar_EventCommon::$filter = '(' . $me['id'] . ')';
     $ret = call_user_func(array('CRM_Calendar_EventCommon', 'get_event_days'), date('Y-m-01', $this->date), date('Y-m-d', strtotime(date('Y-m-t', $this->date)) + 86400));
     $month = $this->month_array($this->date, $ret);
     $year[] = array('month' => $month, 'month_link' => Base_BoxCommon::create_href($this, 'CRM_Calendar', null, null, null, array('jump_to_date' => $this->date, 'switch_to_tab' => 'Month')), 'month_label' => __date('F', $this->date), 'year_label' => date('Y', $this->date));
     $theme->assign('year', $year);
     $theme->assign('day_headers', $day_headers);
     $theme->display('year');
 }
Example #3
0
 public function applet($v, $o)
 {
     $all = Tools_WhoIsOnlineCommon::get();
     $map = array();
     foreach ($all as $id => $x) {
         $c = CRM_ContactsCommon::get_contact_by_user_id(Base_UserCommon::get_user_id($x));
         if ($c) {
             $all[$id] = CRM_ContactsCommon::contact_format_no_company($c);
             $map[$id] = $c['last_name'];
         } else {
             $map[$id] = $x;
         }
     }
     asort($map);
     $c = count($all);
     if ($c == 1) {
         $o['title'] = __('%d user online', array($c));
     } else {
         $o['title'] = __('%d users online', array($c));
     }
     print '<ul>';
     foreach ($map as $id => $x) {
         print '<li>' . $all[$id] . '</li>';
     }
     print '</ul>';
 }
Example #4
0
 public function browse_mode_details($form, $filters, $vals, $crits, $rb_obj)
 {
     $me = CRM_ContactsCommon::get_my_record();
     $rb_obj->custom_defaults['account_manager'] = $me['id'];
     if (!$this->isset_module_variable('def_filter') && Base_User_SettingsCommon::get('CRM_Contacts_AccountManager', 'set_default')) {
         $form->setDefaults(array('filter__account_manager' => '__PERSPECTIVE__'));
         $this->set_module_variable('def_filter', true);
     }
 }
Example #5
0
 function lookup_user_name($args)
 {
     global $account;
     $rec = CRM_ContactsCommon::get_contact_by_user_id($account['f_epesi_user']);
     if ($rec) {
         $args['user_name'] = $rec['first_name'] . ' ' . $rec['last_name'];
     }
     $args['user_email'] = $account['f_email'];
     return $args;
 }
Example #6
0
 public static function get_all($start, $end, $filter = null)
 {
     if ($filter === null) {
         $filter = self::$filter;
     }
     $custom_handlers = DB::GetAssoc('SELECT id, handler_callback FROM crm_calendar_custom_events_handlers');
     $result = array();
     if (self::$events_handlers === null) {
         self::$events_handlers = array_keys($custom_handlers);
     }
     $count = 0;
     foreach (self::$events_handlers as $handler) {
         $callback = explode('::', $custom_handlers[$handler]);
         $result_ext = call_user_func($callback, 'get_all', $start, $end, $filter);
         foreach ($result_ext as $v) {
             if ($v !== null) {
                 $v['id'] = $handler . '#' . $v['id'];
                 $v['custom_agenda_col_0'] = isset($v['type']) ? $v['type'] : '---';
                 if (isset($v['description'])) {
                     $v['custom_agenda_col_1'] = $v['description'];
                 }
                 if (isset($v['employees'])) {
                     $emps = array();
                     if (is_array($v['employees'])) {
                         foreach ($v['employees'] as $e) {
                             $emps[] = CRM_ContactsCommon::contact_format_no_company($e);
                         }
                     }
                     $v['custom_agenda_col_2'] = implode('<br>', $emps);
                 }
                 if (isset($v['customers'])) {
                     $cuss = array();
                     if (is_array($v['customers'])) {
                         foreach ($v['customers'] as $c) {
                             $cuss[] = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers'));
                         }
                     }
                     $v['custom_agenda_col_3'] = implode('<br>', $cuss);
                 }
                 $result[] = $v;
                 $count++;
                 if ($count == CRM_CalendarCommon::$events_limit) {
                     break;
                 }
             }
         }
         if ($count == CRM_CalendarCommon::$events_limit) {
             break;
         }
     }
     if ($count == CRM_CalendarCommon::$events_limit) {
         print '<b>There were too many events to display on the Calendar, please change CRM Filter</b>';
     }
     return $result;
 }
Example #7
0
 /**
  * For internal use only.
  */
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name());
     //defaults
     $defaults = array();
     $defaults['mail_method'] = Variable::get('mail_method');
     $defaults['mail_use_replyto'] = Variable::get('mail_use_replyto');
     $defaults['mail_user'] = Variable::get('mail_user');
     $defaults['mail_from_addr'] = Variable::get('mail_from_addr');
     $defaults['mail_from_name'] = Variable::get('mail_from_name');
     $defaults['mail_host'] = Variable::get('mail_host');
     $defaults['mail_security'] = Variable::get('mail_security', false);
     $defaults['mail_auth'] = Variable::get('mail_auth');
     $defaults['mail_password'] = Variable::get('mail_password');
     $form->setDefaults($defaults);
     //form
     $form->addElement('header', null, __('Mail settings'));
     $form->addElement('select', 'mail_method', __('Choose method'), array('smtp' => __('remote smtp server'), 'mail' => __('local php.ini settings')), 'onChange="' . $form->get_submit_form_js(false) . '"');
     $form->addElement('text', 'mail_from_addr', __('Administrator e-mail address'));
     $form->addRule('mail_from_addr', __('Invalid e-mail address'), 'email');
     $form->addRule('mail_from_addr', __('Field required'), 'required');
     $form->addElement('text', 'mail_from_name', __('Send e-mails from name'));
     $form->addElement('text', 'mail_use_replyto', __('Set "Reply-To" email address'));
     $form->addRule('mail_use_replyto', __('Invalid e-mail address'), 'email');
     $method = $form->getElement('mail_method')->getSelected();
     if ($method[0] == 'smtp') {
         $form->addElement('text', 'mail_host', __('SMTP host address'));
         $form->addRule('mail_host', __('Field required'), 'required');
         $form->addElement('select', 'mail_security', __('Security'), array('' => __('None'), 'ssl' => 'SSL', 'ssl_ssc' => 'SSL (self signed certificate)', 'tls' => 'TLS', 'tls_ssc' => 'TLS (self signed certificate)'));
         $form->addElement('checkbox', 'mail_auth', __('SMTP authorization'), '', 'onChange="' . $form->get_submit_form_js(false) . '"');
         $auth = $form->getElement('mail_auth')->getValue();
         if ($auth) {
             $form->addElement('text', 'mail_user', __('Login'));
             $form->addElement('password', 'mail_password', __('Password'));
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $me = CRM_ContactsCommon::get_my_record();
         $email = $me['email'];
         Base_ActionBarCommon::add('search', __('Test'), $this->create_callback_href(array($this, 'test_mail_config'), array($email)), __('E-mail will be sent to %s to test the configuration', array('<b>' . $email . '</b>')));
     }
     if ($form->getSubmitValue('submited') && $form->validate() && $form->process(array(&$this, 'submit_admin'))) {
         Base_StatusBarCommon::message(__('Settings saved'));
     }
     $form->display();
 }
Example #8
0
 /**
  * Get first(by id) user that is super administrator and get it's first
  * and last name from crm_contacts
  *
  * This function uses DB query to get users and generally it should be
  * easier way to get super admin.
  *
  * @return array with keys admin_email, admin_first_name, admin_last_name
  */
 public static function get_possible_admin()
 {
     $users = DB::GetAll('select id, mail from user_login inner join user_password on user_login_id = id where admin=2');
     foreach ($users as $u) {
         $x = array('admin_email' => $u['mail']);
         if (ModuleManager::is_installed('CRM_Contacts') > -1) {
             $contact = CRM_ContactsCommon::get_contact_by_user_id($u['id']);
             if ($contact) {
                 $x['admin_first_name'] = $contact['first_name'];
                 $x['admin_last_name'] = $contact['last_name'];
             }
         }
         return $x;
     }
     return null;
 }
 public static function has_access_to_report($contact_record = null)
 {
     $has_permission = Base_AclCommon::check_permission('View Activity Report');
     if ($contact_record === null && $has_permission) {
         return true;
     }
     if (isset($contact_record['login']) && $contact_record['login']) {
         if ($has_permission) {
             return true;
         }
         $id = isset($contact_record['id']) ? $contact_record['id'] : false;
         if (!$id) {
             return false;
         }
         $my_record = CRM_ContactsCommon::get_my_record();
         return $id == $my_record['id'];
     }
 }
Example #10
0
 public function applet($conf, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     $opts['go'] = false;
     // enable/disable full screen
     $opts['title'] = $conf['title'];
     // initialize the recordset
     $rb = $this->init_module('Utils/RecordBrowser', 'contact', 'contact');
     $me = CRM_ContactsCommon::get_my_record();
     // $conds - parameters for the applet
     // 1st - table field names, width, truncate
     // 2nd - criteria (filter)
     // 3rd - sorting
     // 4th - function to return tooltip
     // 5th - limit how many records are returned, null = no limit
     // 6th - Actions icons - default are view + info (with tooltip)
     // 1st - table field names
     $cols = array(array('field' => 'last_name', 'width' => 15), array('field' => 'first_name', 'width' => 15), array('field' => 'birth_date', 'width' => 15));
     // 2nd - criteria (filter)
     // TO DO - filter date - today through today+2 weeks
     $dates = array();
     for ($i = 0; $i < $conf['no_of_days']; $i++) {
         $dates[] = DB::Concat(DB::qstr('%'), DB::qstr(date('-m-d', strtotime(Base_RegionalSettingsCommon::time2reg(strtotime('+' . $i . ' days'), false, true, true, false)))));
     }
     if (isset($conf['cont_type']) && $conf['cont_type'] == 'f') {
         $crits = array(':Fav' => true, '"~birth_date' => $dates);
     } else {
         $crits = array('"~birth_date' => $dates);
     }
     // 3rd - sorting
     $sorting = array('last_name' => 'ASC');
     // 4th - function to return tooltip
     $tooltip = 'test';
     // 5th - limit how many records are returned, null = no limit
     $limit = null;
     // 6th - Actions icons - default are view + info (with tooltip)
     $conds = array($cols, $crits, $sorting, $tooltip, $limit, $conf, &$opts);
     // initialize miniview
     print __('Birthdays upcoming in the next: %d days.', array($conf['no_of_days']));
     $this->display_module($rb, $conds, 'mini_view');
 }
Example #11
0
 public function company_addon($company)
 {
     $attachment_groups = array();
     $ids = array('C:' . $company['id']);
     $crits = array('(company_name' => $company['id'], '|related_companies' => array($company['id']));
     $cont = CRM_ContactsCommon::get_contacts($crits);
     foreach ($cont as $k => $v) {
         $ids[] = 'P:' . $v['id'];
         $attachment_groups[] = 'contact/' . $v['id'];
     }
     if (ModuleManager::is_installed('CRM_Meeting') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('crm_meeting', array('customers' => $ids), array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'crm_meeting/' . $rec['id'];
         }
     }
     if (ModuleManager::is_installed('CRM_Tasks') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('task', array('customers' => $ids), array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'task/' . $rec['id'];
         }
     }
     if (ModuleManager::is_installed('CRM_PhoneCall') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('phonecall', array('customer' => $ids), array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'phonecall/' . $rec['id'];
         }
     }
     if (ModuleManager::is_installed('Premium_SalesOpportunity') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('premium_salesopportunity', array('customers' => $ids), array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'premium_salesopportunity/' . $rec['id'];
         }
     }
     if (Base_User_SettingsCommon::get('CRM/Contacts/NotesAggregate', 'show_all_notes')) {
         $attachment_groups[] = 'company/' . $company['id'];
     }
     $a = $this->init_module('Utils/Attachment', array($attachment_groups));
     $a->set_multiple_group_mode();
     $this->display_module($a);
 }
Example #12
0
 public function get_data($user, $pass, $newer_then = 0)
 {
     global $namespace;
     $error = $this->auth($user, $pass);
     $contacts = array();
     $companies = array();
     if ($error === '') {
         $c = CRM_ContactsCommon::get_contacts(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then)));
         foreach ($c as $row) {
             foreach ($row['company_name'] as &$v) {
                 $v = (int) $v;
             }
             $contacts[] = new SOAP_Value('item', '{urn:' . $namespace . '}Contact', array('id' => new SOAP_Value("id", "int", (int) $row['id']), 'first' => new SOAP_Value("first", "string", $row['first_name']), 'last' => new SOAP_Value("last", "string", $row['last_name']), 'title' => new SOAP_Value("title", "string", $row['title']), 'work_phone' => new SOAP_Value("work_phone", "string", $row['work_phone']), 'mobile_phone' => new SOAP_Value("mobile_phone", "string", $row['mobile_phone']), 'fax' => new SOAP_Value("fax", "string", $row['fax']), 'mail' => new SOAP_Value("mail", "string", $row['email']), 'web_address' => new SOAP_Value("web_address", "string", $row['web_address']), 'address1' => new SOAP_Value("address1", "string", $row['address_1']), 'address2' => new SOAP_Value("address2", "string", $row['address_2']), 'city' => new SOAP_Value("city", "string", $row['city']), 'country' => new SOAP_Value("country", "string", $row['country']), 'zone' => new SOAP_Value("zone", "string", $row['zone']), 'postal' => new SOAP_Value("postal", "string", $row['postal_code']), 'home_phone' => new SOAP_Value("home_phone", "string", $row['home_phone']), 'home_address1' => new SOAP_Value("home_address1", "string", $row['home_address_1']), 'home_address2' => new SOAP_Value("home_address2", "string", $row['home_address_2']), 'home_city' => new SOAP_Value("home_city", "string", $row['home_city']), 'home_zone' => new SOAP_Value("home_zone", "string", $row['home_zone']), 'home_country' => new SOAP_Value("home_country", "string", $row['home_country']), 'home_postal' => new SOAP_Value("home_postal", "string", $row['home_postal_code']), 'birth' => new SOAP_Value("birth", "string", $row['birth_date']), 'company' => new SOAP_Value("company", '{urn:' . $namespace . '}ArrayOfInt', $row['company_name'])));
         }
         $c = CRM_ContactsCommon::get_companies(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then)));
         foreach ($c as $row) {
             $companies[] = new SOAP_Value('item', '{urn:' . $namespace . '}Company', array('id' => new SOAP_Value("id", 'int', (int) $row['id']), 'name' => new SOAP_Value("name", 'string', $row['company_name']), 'short_name' => new SOAP_Value("short_name", 'string', $row['short_name']), 'phone' => new SOAP_Value("phone", 'string', $row['phone']), 'fax' => new SOAP_Value("fax", 'string', $row['fax']), 'web_address' => new SOAP_Value("web_address", 'string', $row['web_address']), 'address1' => new SOAP_Value("address1", 'string', $row['address_1']), 'address2' => new SOAP_Value("address2", 'string', $row['address_2']), 'city' => new SOAP_Value("city", 'string', $row['city']), 'country' => new SOAP_Value("country", 'string', $row['country']), 'zone' => new SOAP_Value("zone", 'string', $row['zone']), 'postal' => new SOAP_Value("postal", 'string', $row['postal_code'])));
         }
     }
     return new SOAP_Value('return', '{urn:' . $namespace . '}GetDataResult', array('companies' => new SOAP_Value('companies', '{urn:' . $namespace . '}ArrayOfCompanies', $companies), 'contacts' => new SOAP_Value('contacts', '{urn:' . $namespace . '}ArrayOfContacts', $contacts), 'error' => new SOAP_Value('error', 'string', $error)));
 }
Example #13
0
 public static function set_profile($prof)
 {
     if (preg_match('/^c([0-9,]+)$/', $prof, $reqs)) {
         $ret = $reqs[1];
         if (strpos($ret, ',') === false) {
             $desc = CRM_ContactsCommon::contact_format_no_company($ret, true);
         } else {
             $desc = __('Custom filter');
         }
     } elseif (is_numeric($prof)) {
         $cids = DB::GetAssoc('SELECT contact_id, contact_id FROM crm_filters_contacts');
         $c = DB::GetCol('SELECT p.contact_id FROM crm_filters_contacts p WHERE p.group_id=%d', array($prof));
         if ($c) {
             $ret = implode(',', $c);
         } else {
             $ret = '-1';
         }
         $desc = DB::GetOne('SELECT name FROM crm_filters_group WHERE id=%d', array($prof));
     } elseif ($prof == 'my') {
         $ret = CRM_FiltersCommon::get_my_profile();
         $desc = __('My records');
     } else {
         //all and undefined
         $ret = '';
         /*$contacts = Utils_RecordBrowserCommon::get_records('contact', array(), array(), array('last_name'=>'ASC'));
         		$contacts_select = array();
         		foreach($contacts as $v)
         			$contacts_select[] = $v['id'];
         		if($contacts_select)
         			$ret = implode(',',$contacts_select);
         		else
         			$ret = '-1';*/
         $desc = __('All records');
     }
     //		$this->set_module_variable('profile',$ret);
     $_SESSION['client']['filter_' . Acl::get_user()]['value'] = $ret;
     $_SESSION['client']['filter_' . Acl::get_user()]['desc'] = $desc;
     location(array());
 }
Example #14
0
 public function body($args = array())
 {
     $ev_mod = $this->init_module(CRM_Calendar_Event::module_name());
     $ev_mod->help('Calendar Help', 'main');
     if (isset($_REQUEST['search_date']) && is_numeric($_REQUEST['search_date']) && isset($_REQUEST['ev_id']) && is_numeric($_REQUEST['ev_id'])) {
         $default_date = intval($_REQUEST['search_date']);
         $this->view_event(intval($_REQUEST['ev_id']));
     } else {
         $default_date = null;
     }
     $handlers = DB::GetAll('SELECT id, group_name, handler_callback FROM crm_calendar_custom_events_handlers');
     $this->lp = $this->init_module('Utils_LeightboxPrompt');
     $count = 0;
     foreach ($handlers as $v) {
         $callback = explode('::', $v['handler_callback']);
         if (!is_callable($callback)) {
             continue;
         }
         $new_events = call_user_func($callback, 'new_event_types');
         if ($new_events !== null) {
             foreach ($new_events as $k => $w) {
                 if (!is_array($w)) {
                     $w = array('label' => $w, 'icon' => null);
                 }
                 $this->lp->add_option('new_event__' . $v['id'] . '__' . $k, $w['label'], $w['icon'], null);
                 $count++;
             }
         }
     }
     if ($count < 2) {
         $this->lp = null;
     } else {
         $this->display_module($this->lp, array(__('New Event'), array('timestamp', 'timeless'), '', false));
         $vals = $this->lp->export_values();
         if ($vals) {
             $this->jump_to_new_event($vals['option'], $vals['params']['timestamp'], $vals['params']['timeless']);
             return;
         }
     }
     CRM_Calendar_EventCommon::$filter = CRM_FiltersCommon::get();
     $args_defaults = array('default_view' => Base_User_SettingsCommon::get('CRM_Calendar', 'default_view'), 'first_day_of_week' => Utils_PopupCalendarCommon::get_first_day_of_week(), 'start_day' => Base_User_SettingsCommon::get('CRM_Calendar', 'start_day'), 'end_day' => Base_User_SettingsCommon::get('CRM_Calendar', 'end_day'), 'interval' => Base_User_SettingsCommon::get('CRM_Calendar', 'interval'), 'default_date' => $default_date, 'custom_agenda_cols' => array(array('name' => __('Type'), 'order' => 'cus_col_0', 'width' => 6, 'wrapmode' => 'nowrap'), __('Description'), __('Assigned to'), __('Related with')));
     foreach ($args_defaults as $k => $v) {
         if (!isset($args[$k])) {
             $args[$k] = $args_defaults[$k];
         }
     }
     if (isset($_REQUEST['jump_to_date']) && is_numeric($_REQUEST['jump_to_date']) && isset($_REQUEST['switch_to_tab']) && is_string($_REQUEST['switch_to_tab'])) {
         $args['default_date'] = $_REQUEST['jump_to_date'];
         $args['default_view'] = $_REQUEST['switch_to_tab'];
     }
     $theme = $this->init_module(Base_Theme::module_name());
     $c = $this->init_module(Utils_Calendar::module_name(), array(CRM_Calendar_Event::module_name(), $args, array($this, 'get_new_event_href_js')));
     $view_type = $c->get_current_view();
     CRM_CalendarCommon::$mode = $view_type;
     $theme->assign('calendar', $this->get_html_of_module($c));
     $theme->display();
     $events = $c->get_displayed_events();
     if (!empty($events['events'])) {
         switch ($view_type) {
             case 'Day':
                 $view = __('Daily agenda');
                 break;
             case 'Month':
                 $view = __('Monthly agenda');
                 break;
             case 'Week':
                 $view = __('Weekly agenda');
                 break;
             case 'Agenda':
                 $view = __('Agenda');
                 break;
         }
         if (isset($view)) {
             $pdf = $this->pack_module(Libs_TCPDF::module_name(), null, null, 'L');
             if ($pdf->prepare()) {
                 set_time_limit(0);
                 $start = date('d F Y', Base_RegionalSettingsCommon::reg2time($events['start']));
                 $end = date('d F Y', Base_RegionalSettingsCommon::reg2time($events['end']));
                 $pdf->set_title($view . ', ' . $start . ($view_type != 'Day' ? ' - ' . $end : ''));
                 $filter = CRM_FiltersCommon::get();
                 $me = CRM_ContactsCommon::get_my_record();
                 if (trim($filter, '()') == $me['id']) {
                     $desc = $me['last_name'] . ' ' . $me['first_name'];
                 } else {
                     $desc = CRM_FiltersCommon::get_profile_desc();
                 }
                 $pdf->set_subject(__('CRM Filters: %s', array($desc)));
                 $pdf->prepare_header();
                 $pdf->AddPage();
                 foreach ($events['events'] as $v) {
                     $ev_mod->make_event_PDF($pdf, $v, true, $view_type);
                 }
             }
             $pdf->add_actionbar_icon($view);
         }
     }
 }
Example #15
0
 public static function mobile_meetings()
 {
     $me = CRM_ContactsCommon::get_my_record();
     $defaults = array('employees' => array($me['id']), 'status' => 0, 'permission' => 0, 'priority' => CRM_CommonCommon::get_default_priority());
     Utils_RecordBrowserCommon::mobile_rb('crm_meeting', array('employees' => array($me['id'])), array('date' => 'ASC', 'time' => 'ASC', 'priority' => 'DESC', 'title' => 'ASC'), array('date' => 1, 'time' => 1, 'priority' => 1, 'longterm' => 1), $defaults);
 }
Example #16
0
 public static function employee_crits()
 {
     $my_company = CRM_ContactsCommon::get_main_company();
     return array('(company_name' => $my_company, '|related_companies' => array($my_company));
 }
Example #17
0
 public static function get_change_subscription_icon_tags($category_name, $id)
 {
     $category_id = self::get_category_id($category_name);
     if (!$category_id) {
         return;
     }
     $last_seen = self::check_if_notified($category_name, $id);
     load_js('modules/Utils/Watchdog/subscribe.js');
     $tag_id = 'watchdog_sub_button_' . $category_name . '_' . $id;
     $href = ' onclick="utils_watchdog_set_subscribe(' . ($last_seen === null ? 1 : 0) . ',\'' . $category_name . '\',' . $id . ',\'' . $tag_id . '\')" href="javascript:void(0);"';
     if ($last_seen === null) {
         $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png');
         $tooltip = __('Click to watch this record for changes.');
     } else {
         if ($last_seen === true) {
             $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png');
             $tooltip = __('You are watching this record, click to stop watching this record for changes.');
         } else {
             $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png');
             $ev = self::display_events($category_id, $last_seen, $id);
             $tooltip = __('You are watching this record, click to stop watching this record for changes.') . ($ev ? '<br>' . __('The following changes were made since the last time you were viewing this record:') . '<br><br>' . $ev['events'] : '');
         }
     }
     $subscribers = self::get_subscribers($category_name, $id);
     $my_user = Base_AclCommon::get_user();
     if ($subscribers) {
         $icon_on = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"';
         $icon_off = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"';
         $other_subscribers = array();
         foreach ($subscribers as $subscriber) {
             if ($subscriber == $my_user) {
                 continue;
             }
             if (class_exists('CRM_ContactsCommon')) {
                 $contact = CRM_ContactsCommon::get_user_label($subscriber, true);
             } else {
                 $contact = Base_UserCommon::get_user_login($subscriber);
             }
             $notified = self::user_check_if_notified($subscriber, $category_name, $id);
             $icon2 = $notified === true ? $icon_on : $icon_off;
             $other_subscribers[] = '<img style="margin-right:4px;" ' . $icon2 . ' /><a>' . Utils_RecordBrowserCommon::no_wrap($contact) . '</a>';
         }
         if ($other_subscribers) {
             $tooltip .= '<hr />' . implode('<br>', $other_subscribers);
         }
     }
     $tooltip = Utils_TooltipCommon::open_tag_attrs($tooltip);
     return '<a ' . $href . ' ' . $tooltip . '><img border="0" src="' . $icon . '"></a>';
 }
Example #18
0
 public function send($file)
 {
     if ($this->is_back()) {
         return $this->go_back($file);
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'send_fax');
     list($providers, $providers_arr) = self::get_providers($file);
     if (empty($providers)) {
         $this->go_back($file);
         Epesi::alert(__('No fax providers installed or configured for this type of file.'));
         return;
     }
     $qf->addElement('header', null, __('Faxing file: %s', array(basename($file))));
     $qf->addElement('select', 'provider', __('Provider'), $providers);
     $qf->addElement('header', null, __('Contact'));
     $fav_contact = CRM_ContactsCommon::get_contacts(array(':Fav' => true, '!fax' => ''));
     $fav_contact2 = array();
     foreach ($fav_contact as $v) {
         $fav_contact2[$v['id']] = CRM_ContactsCommon::contact_format_default($v, true);
     }
     $rb_contact = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_contact, array('contact', 'dest_contact', array('CRM_FaxCommon', 'rpicker_contact_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_contact', '', $fav_contact2);
     $qf->addElement('static', null, $rb_contact->create_open_link('Add contact'));
     $qf->addElement('header', null, __('Company'));
     $fav_company = CRM_ContactsCommon::get_companies(array(':Fav' => true, '!fax' => ''), array('id', 'company_name'));
     $fav_company2 = array();
     foreach ($fav_company as $v) {
         $fav_company2[$v['id']] = $v['company_name'];
     }
     $rb_company = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_company, array('company', 'dest_company', array('CRM_FaxCommon', 'rpicker_company_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_company', '', $fav_company2);
     $qf->addElement('static', null, $rb_company->create_open_link('Add company'));
     $qf->addElement('header', null, __('Other'));
     $qf->addElement('text', 'dest_other', __('Other fax numbers (comma separated)'));
     $qf->addFormRule(array($this, 'check_numbers'));
     if ($qf->validate()) {
         $data = $qf->exportValues();
         if (!isset($providers_arr[$data['provider']]['send_func'])) {
             Epesi::alert(__('Invalid fax provider.'));
         } else {
             $fax_func = array($data['provider'] . 'Common', $providers_arr[$data['provider']]['send_func']);
             $numbers = array();
             $contacts = Utils_RecordBrowserCommon::get_records('contact', array('id' => $data['dest_contact']), array('fax'));
             foreach ($contacts as $row) {
                 $numbers[] = $row['fax'];
             }
             $companies = Utils_RecordBrowserCommon::get_records('company', array('id' => $data['dest_company']), array('fax'));
             foreach ($companies as $row) {
                 $numbers[] = $row['fax'];
             }
             $numbers += explode(',', $data['dest_other']);
             $ret = call_user_func($fax_func, $file, $numbers);
             if ($ret) {
                 return $this->go_back($file);
             }
         }
     }
     $qf->display();
     Base_ActionBarCommon::add('send', __('Send'), $qf->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Example #19
0
 public static function display_contacts_with_notification($recordset, $record, $nolink, $desc)
 {
     $icon_on = Utils_TooltipCommon::open_tag_attrs(__('This person is up to date with all changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"';
     $icon_off = Utils_TooltipCommon::open_tag_attrs(__('This person has notifications pending about changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"';
     $icon_none = Utils_TooltipCommon::open_tag_attrs(__('This person is not watching this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png') . '"';
     $v = $record[$desc['id']];
     $def = '';
     $first = true;
     $param = explode(';', $desc['param']);
     if (!is_array($v) && !is_numeric($v)) {
         return $v;
     }
     if ($param[1] == '::') {
         $callback = array('CRM_ContactsCommon', 'contact_format_default');
     } else {
         $callback = explode('::', $param[1]);
     }
     if (!is_array($v)) {
         $v = array($v);
     }
     foreach ($v as $k => $w) {
         if ($w == '') {
             break;
         }
         if ($first) {
             $first = false;
         } else {
             $def .= '<br>';
         }
         $contact = CRM_ContactsCommon::get_contact($w);
         if (!$nolink) {
             if ($contact['login'] == '') {
                 $icon = $icon_none;
             } else {
                 $icon = Utils_WatchdogCommon::user_check_if_notified($contact['login'], $recordset, $record['id']);
                 if ($icon === null) {
                     $icon = $icon_none;
                 } elseif ($icon === true) {
                     $icon = $icon_on;
                 } else {
                     $icon = $icon_off;
                 }
             }
             $def .= '<img style="margin-right:4px;" ' . $icon . ' />';
         }
         $def .= Utils_RecordBrowserCommon::no_wrap(call_user_func($callback, $contact, $nolink));
     }
     if (!$def) {
         $def = '---';
     }
     return $def;
 }
Example #20
0
 public static function user_settings()
 {
     if (!Base_EpesiStoreCommon::admin_access()) {
         return array();
     }
     set_time_limit(0);
     // get default data from user contact
     $my_contact = ModuleManager::is_installed('CRM_Contacts') > -1 ? CRM_ContactsCommon::get_my_record() : array();
     // key = field name from contact => value = field name in settings
     $keys = self::get_payment_data_keys();
     $values = array();
     // do user setting entries from data
     foreach ($keys as $k => $v) {
         $x = array('name' => $v, 'label' => _V(ucwords(str_replace('_', ' ', $v))), 'type' => 'text', 'default' => isset($my_contact[$k]) ? $my_contact[$k] : '');
         if ($k == 'country') {
             $x['type'] = 'select';
             $x['values'] = Utils_CommonDataCommon::get_translated_array('Countries');
         }
         $values[] = $x;
     }
     return array(__('EPESI Store') => array_merge(array(array('name' => 'payments_header', 'label' => '', 'type' => 'header', 'default' => __('Payment credentials'))), $values));
 }
Example #21
0
 public function sample_data()
 {
     $ret = array();
     $me = CRM_ContactsCommon::get_my_record();
     if ($me) {
         $ret[] = array('tab' => 'contact', 'record_id' => $me['id']);
         if ($me['company_name']) {
             $ret[] = array('tab' => 'company', 'record_id' => $me['company_name']);
         }
     }
     return $ret;
 }
Example #22
0
 public function register_form($data = null)
 {
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $f = $this->init_module(Libs_QuickForm::module_name());
     $admin_email_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('This email will be used to send registation link and to contact Administator directly.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> ';
     $tax_id_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('Your company Tax ID for invoices.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> ';
     $f->addElement('text', 'company_name', __('Company Name'), array('maxlength' => 128));
     $f->addRule('company_name', __('Field required'), 'required');
     $f->addRule('company_name', __('Max length exceeded'), 'maxlength', 128);
     $f->addElement('text', 'short_name', __('Short Name'), array('maxlength' => 64));
     $f->addRule('short_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'phone', __('Phone'), array('maxlength' => 64));
     $f->addRule('phone', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'fax', __('Fax'), array('maxlength' => 64));
     $f->addRule('fax', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'email', __('Company email'), array('maxlength' => 128));
     $f->addRule('email', __('Max length exceeded'), 'maxlength', 128);
     $f->addRule('email', __('Invalid e-mail address'), 'email');
     $f->addElement('text', 'web_address', __('Web address'), array('maxlength' => 64));
     $f->addRule('web_address', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'address_1', __('Address 1'), array('maxlength' => 64));
     $f->addRule('address_1', __('Field required'), 'required');
     $f->addRule('address_1', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'address_2', __('Address 2'), array('maxlength' => 64));
     $f->addRule('address_2', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'city', __('City'), array('maxlength' => 64));
     $f->addRule('city', __('Field required'), 'required');
     $f->addRule('city', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('commondata', 'country', __('Country'), 'Countries');
     $f->addRule('country', __('Field required'), 'required');
     $f->addElement('commondata', 'zone', __('Zone'), array('Countries', 'country'), array('empty_option' => true));
     $f->addElement('text', 'postal_code', __('Postal Code'), array('maxlength' => 64));
     $f->addRule('postal_code', __('Field required'), 'required');
     $f->addRule('postal_code', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'tax_id', $tax_id_tooltip . __('Tax ID'), array('maxlength' => 64));
     $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_first_name', __('Administrator\'s first name'), array('maxlength' => 64));
     $f->addRule('admin_first_name', __('Field required'), 'required');
     $f->addRule('admin_first_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_last_name', __('Administrator\'s last name'), array('maxlength' => 64));
     $f->addRule('admin_last_name', __('Field required'), 'required');
     $f->addRule('admin_last_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_email', $admin_email_tooltip . __('Administrator\'s email'), array('maxlength' => 128));
     $f->addRule('admin_email', __('Field required'), 'required');
     $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 128);
     $f->addRule('admin_email', __('Invalid e-mail address'), 'email');
     if ($f->validate()) {
         $ret = $f->exportValues();
         $ret = Base_EssClientCommon::server()->register_installation_request($ret);
         if ($ret) {
             if (is_string($ret)) {
                 Base_EssClientCommon::set_license_key($ret);
             }
             location(array());
             return false;
         }
     }
     // set defaults
     print '<div class="important_notice">';
     print __('Enter Company and Administrator details. This data will be sent to EPESI Store Server to provide us with contact information. The data sent to EPESI Store Server is limited only to the data you enter using this form and what modules are being purchased and downloaded.');
     print '<br>';
     if ($data) {
         $f->setDefaults($data);
     } else {
         if (ModuleManager::is_installed('CRM_Contacts') > -1) {
             print '<span style="color:gray;font-size:10px;">' . __('Data below was auto-filled based on Main Company and first Super administrator. Make sure that the data is correct and change it if necessary.') . '</span>';
             $defaults = Base_EssClientCommon::get_possible_admin();
             $mc = CRM_ContactsCommon::get_main_company();
             if ($mc > 0) {
                 $company = CRM_ContactsCommon::get_company($mc);
                 if ($company) {
                     $defaults = array_merge($company, $defaults);
                 }
             }
             $f->setDefaults($defaults);
         }
     }
     if ($data) {
         if (isset($data['status']) && strcasecmp($data['status'], 'Confirmed') == 0) {
             print '<div style="color:gray;font-size:10px;">' . __('Updating Company data will require re-validation by our representative.') . '</div>';
         }
         print '<div style="color:red;font-size:10px;">' . __('Changing Administrator e-mail address will require e-mail confirmation.') . '</div>';
     }
     print '<center>';
     $f->addElement('submit', 'submit', $data ? __('Update') : __('Register'));
     $f->display_as_column();
     print '</center>';
     print '</div>';
     return true;
 }
Example #23
0
 public function display_activities($events, $tasks, $phonecalls)
 {
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'activities', 'activities');
     $gb->set_table_columns(array(array('name' => __('Type'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Subject'), 'width' => 20), array('name' => __('Date/Deadline'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Employees'), 'width' => 11), array('name' => __('Customers'), 'width' => 11), array('name' => __('Attachments'), 'width' => 4)));
     $amount = 0;
     if ($this->display['events']) {
         $amount += count($events);
     }
     if ($this->display['tasks']) {
         $amount += count($tasks);
     }
     if ($this->display['phonecalls']) {
         $amount += count($phonecalls);
     }
     $limit = $gb->get_limit($amount);
     for ($i = 0; $i < $limit['offset'] + $limit['numrows'] && $i < $amount; $i++) {
         if ($this->display['events'] && count($events)) {
             $ev = current($events);
         } else {
             $ev = array('start' => -1);
         }
         if ($this->display['tasks'] && count($tasks)) {
             $t = current($tasks);
             if (!$t['deadline']) {
                 $t['deadline'] = 0;
             } else {
                 $t['deadline'] = strtotime($t['deadline']);
             }
         } else {
             $t = array('deadline' => -1);
         }
         if ($this->display['phonecalls'] && count($phonecalls)) {
             $ph = current($phonecalls);
             $ph['date_and_time'] = strtotime($ph['date_and_time']);
         } else {
             $ph = array('date_and_time' => -1);
         }
         $maxt = max($ev['start'], $t['deadline'], $ph['date_and_time']);
         $gb_row = $gb->get_new_row();
         if ($ev['start'] == $maxt) {
             $v = array_shift($events);
             if ($i >= $limit['offset'] && $v) {
                 if (isset($v['view_action'])) {
                     $view_href = $v['view_action'];
                 } else {
                     $view_href = $this->create_callback_href(array($this, 'view_event'), array($v['id']));
                 }
                 $title = '<a ' . $view_href . '>' . $v['title'] . '</a>';
                 if (isset($v['description']) && $v['description'] != '') {
                     $title = '<span ' . Utils_TooltipCommon::open_tag_attrs($v['description'], false) . '>' . $title . '</span>';
                 }
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('crm_meeting', $v['id']));
                 $gb_row->add_data(__('Meeting'), $title, Base_RegionalSettingsCommon::time2reg($v['start'], $v['duration'] == -1 ? false : 2), CRM_ContactsCommon::display_contact(array('employees' => $v['employees']), false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact(array('customers' => $v['customers']), false, array('id' => 'customers', 'param' => ';::')), Utils_AttachmentCommon::count('crm_meeting/' . $v['id']));
             }
         } elseif ($t['deadline'] == $maxt) {
             $v = array_shift($tasks);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('task', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('task', $v['id']));
                 $gb_row->add_data(__('Task'), CRM_TasksCommon::display_title($v, false), !isset($v['deadline']) || !$v['deadline'] ? __('No deadline') : Base_RegionalSettingsCommon::time2reg($v['deadline'], false, true, false), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact($v, false, array('id' => 'customers')), Utils_AttachmentCommon::count('task/' . $v['id']));
             }
         } else {
             $v = array_shift($phonecalls);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('phonecall', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('phonecall', $v['id']));
                 $gb_row->add_data(__('Phonecall'), CRM_PhoneCallCommon::display_subject($v), Base_RegionalSettingsCommon::time2reg($v['date_and_time'], 2), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_PhoneCallCommon::display_contact_name($v, false), Utils_AttachmentCommon::count('phonecall/' . $v['id']));
             }
         }
     }
     $this->display_module($gb);
 }
Example #24
0
 public function edit($user_settings_nav = true)
 {
     if ($user_settings_nav) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('add', __('Add preset'), $this->create_callback_href(array($this, 'edit_group')));
     $gb = $this->init_module('Utils/GenericBrowser', null, 'edit');
     $gb->set_table_columns(array(array('name' => __('Name'), 'width' => 20, 'order' => 'g.name'), array('name' => __('Description'), 'width' => 30, 'order' => 'g.description'), array('name' => __('Users in category'), 'width' => 50, 'order' => '')));
     $ret = DB::Execute('SELECT g.name,g.id,g.description FROM crm_filters_group g WHERE g.user_login_id=' . Acl::get_user());
     while ($row = $ret->FetchRow()) {
         $gb_row =& $gb->get_new_row();
         $gb_row->add_action($this->create_confirm_callback_href(__('Delete this group?'), array('CRM_Filters', 'delete_group'), $row['id']), 'Delete');
         $gb_row->add_action($this->create_callback_href(array($this, 'edit_group'), $row['id']), 'Edit');
         $cids = DB::GetAssoc('SELECT c.contact_id, c.contact_id FROM crm_filters_contacts c WHERE c.group_id=%d', array($row['id']));
         $users = array();
         foreach ($cids as $v) {
             $users[] = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact($v), true);
         }
         $gb_row->add_data($row['name'], $row['description'], implode(', ', $users));
     }
     $this->display_module($gb);
     $qf = $this->init_module('Libs/QuickForm', null, 'default_filter');
     $qf->addElement('checkbox', 'show_all_contacts_in_filters', __('Show all contacts in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('checkbox', 'show_only_users_in_filters', __('Show only users in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->setDefaults(array('show_all_contacts_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters'), 'show_only_users_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')));
     if ($qf->validate()) {
         $vals = $qf->exportValues();
         if (!isset($vals['show_all_contacts_in_filters'])) {
             $vals['show_all_contacts_in_filters'] = 0;
         }
         if (!isset($vals['show_only_users_in_filters'])) {
             $vals['show_only_users_in_filters'] = 0;
         }
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_all_contacts_in_filters', $vals['show_all_contacts_in_filters']);
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_only_users_in_filters', $vals['show_only_users_in_filters']);
     }
     $qf->display();
 }
Example #25
0
 public function addon($r, $rb_parent)
 {
     $rb = $this->init_module('Utils/RecordBrowser', 'phonecall');
     $params = array(array('related' => $rb_parent->tab . '/' . $r['id']), array('related' => false), array('date_and_time' => 'DESC'));
     //look for customers
     $customers = array();
     if (isset($r['customers'])) {
         $customers = $r['customers'];
     } elseif (isset($r['customer'])) {
         $customers = $r['customer'];
     }
     if (!is_array($customers)) {
         $customers = array($customers);
     }
     foreach ($customers as $i => &$customer) {
         if (preg_match('/^(C\\:|company\\/)([0-9]+)$/', $customer, $req)) {
             $customer = $req[2];
         } elseif (is_numeric($customer)) {
             $customer = $customer;
         } else {
             unset($customers[$i]);
         }
     }
     $me = CRM_ContactsCommon::get_my_record();
     $rb->set_defaults(array('related' => $rb_parent->tab . '/' . $r['id'], 'employees' => array($me['id']), 'status' => 0, 'permission' => 0, 'priority' => CRM_CommonCommon::get_default_priority(), 'date_and_time' => date('Y-m-d H:i:s'), 'customer' => array_shift($customers)));
     $this->display_module($rb, $params, 'show_data');
 }
Example #26
0
 public function translations()
 {
     global $translations;
     global $custom_translations;
     load_js('modules/Base/Lang/Administrator/js/main.js');
     eval_js('translate_init();');
     $lp = $this->init_module('Utils/LeightboxPrompt');
     $form = $this->init_module('Libs/QuickForm', null, 'translations_sending');
     $desc = '<div id="trans_sett_info" style="line-height:17px;">';
     $desc .= __('You have now option to contribute with your translations to help us deliver EPESI in various languages. You can opt in to send your translations to EPESI central database, allowing to deliver EPESI in your language to other users.') . '<br>';
     $desc .= __('Please note that the translations you submit aren\'t subject to copyright. EPESI Team will distribute the translations free of charge to the end users.') . '<br>';
     $desc .= __('The only data being sent is the values of the fields presented below and the translated strings, we do not receive any other information contained in EPESI.') . '<br>';
     $desc .= __('You can also change your Translations Contribution settings at later time.') . '<br>';
     $desc .= '</div>';
     eval_js('$("trans_sett_info").up("td").setAttribute("colspan",2);');
     eval_js('$("trans_sett_info").up("td").style.borderRadius="0";');
     // Not really nice, but will have to do for now
     eval_js('$("decription_label").up("td").hide();');
     eval_js('function update_credits(){$("contact_email").disabled=$("credits_website").disabled=!$("include_credits").checked||!$("allow").checked;}');
     eval_js('update_credits();');
     $ip = gethostbyname($_SERVER['SERVER_NAME']);
     $me = CRM_ContactsCommon::get_my_record();
     $form->addElement('static', 'header', '<div id="decription_label" />', $desc);
     $form->addElement('checkbox', 'allow', __('Enable sending translations'), null, array('id' => 'allow', 'onchange' => '$("include_credits").disabled=$("first_name").disabled=$("last_name").disabled=!this.checked;update_credits();'));
     $form->addElement('text', 'first_name', __('First Name'), array('id' => 'first_name'));
     $form->addElement('text', 'last_name', __('Last Name'), array('id' => 'last_name'));
     $form->addElement('checkbox', 'include_credits', __('Include in credits'), null, array('id' => 'include_credits', 'onchange' => 'update_credits();'));
     $form->addElement('text', 'credits_website', __('Credits website'), array('id' => 'credits_website'));
     $form->addElement('text', 'contact_email', __('Contact e-mail'), array('id' => 'contact_email'));
     $form->addElement('static', 'IP', __('IP'), $ip);
     $lp->add_option(null, null, null, $form);
     eval_js('$("first_name").disabled=$("last_name").disabled=!$("allow").checked;');
     $vals = $lp->export_values();
     if ($vals) {
         $values = $vals['form'];
         if (!isset($values['allow'])) {
             $values['allow'] = 0;
         }
         if (!isset($values['first_name'])) {
             $values['first_name'] = '';
         }
         if (!isset($values['last_name'])) {
             $values['last_name'] = '';
         }
         if (!isset($values['include_credits'])) {
             $values['include_credits'] = 0;
         }
         if (!isset($values['credits_website'])) {
             $values['credits_website'] = '';
         }
         if (!isset($values['contact_email'])) {
             $values['contact_email'] = '';
         }
         DB::Execute('DELETE FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         DB::Execute('INSERT INTO base_lang_trans_contrib (user_id, allow, first_name, last_name, credits, credits_website, contact_email) VALUES (%d, %d, %s, %s, %d, %s, %s)', array(Acl::get_user(), $values['allow'], $values['first_name'], $values['last_name'], $values['include_credits'], $values['credits_website'], $values['contact_email']));
     }
     $allow_sending = Base_Lang_AdministratorCommon::allow_sending(true);
     if ($allow_sending === null || $allow_sending === false) {
         $form->setDefaults(array('allow' => 0, 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'contact_email' => $me['email']));
     } else {
         $r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         if (!$r['first_name']) {
             $r['first_name'] = $me['first_name'];
         }
         if (!$r['last_name']) {
             $r['last_name'] = $me['last_name'];
         }
         if (!$r['contact_email']) {
             $r['contact_email'] = $me['email'];
         }
         $form->setDefaults(array('allow' => $r['allow'], 'first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'contact_email' => $r['contact_email'], 'credits_website' => $r['credits_website'], 'include_credits' => $r['credits']));
     }
     Base_ActionBarCommon::add('settings', __('Translations Contributions'), $lp->get_href());
     $this->display_module($lp, array(__('Translations Contributions settings')));
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'new_langpack')) {
         Base_ActionBarCommon::add('add', __('New langpack'), $this->create_callback_href(array($this, 'new_lang_pack')));
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'select_language')) {
         Base_ActionBarCommon::add('refresh', __('Refresh languages'), $this->create_callback_href(array('Base_LangCommon', 'refresh_cache')));
     }
     $form2 = $this->init_module('Libs/QuickForm', null, 'translaction_filter');
     $form2->addElement('select', 'lang_filter', __('Filter'), array(__('Show all'), __('Show with custom translation'), __('Show with translation'), __('Show without translation')), array('onchange' => $form2->get_submit_form_js()));
     if ($form2->validate()) {
         $vals = $form2->exportValues();
         $this->set_module_variable('filter', $vals['lang_filter']);
     }
     $filter = $this->get_module_variable('filter', 0);
     $form2->setDefaults(array('lang_filter' => $filter));
     ob_start();
     $form2->display_as_row();
     $trans_filter = ob_get_clean();
     if (!isset($_SESSION['client']['base_lang_administrator']['currently_translating'])) {
         $_SESSION['client']['base_lang_administrator']['currently_translating'] = Base_LangCommon::get_lang_code();
     }
     if (!isset($_SESSION['client']['base_lang_administrator']['notice'])) {
         print '<span class="important_notice">' . __('Please make sure the correct language is selected in the box below before you start translating') . ' <a style="float:right;" ' . $this->create_callback_href(array($this, 'hide_notice')) . '>' . __('Discard') . '</a>' . '</span>';
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
         $langs = Base_LangCommon::get_installed_langs();
         $form = $this->init_module('Libs/QuickForm', null, 'language_selected');
         $form->addElement('select', 'lang_code', __('Currently Translating'), $langs, array('onchange' => $form->get_submit_form_js()));
         $currently_translating = $_SESSION['client']['base_lang_administrator']['currently_translating'];
         $form->setDefaults(array('lang_code' => $currently_translating));
         if ($form->validate()) {
             $form->process(array($this, 'submit_language_select'));
         }
         if ($allow_sending) {
             $warning_mgs = __('All custom translations will be sent to our server right after you will input them. Use this mode only, if you wish to contribute your translations. If you are going to change meaning of any string, then please disable sending translations.');
             print "<h1 style=\"color:red; width: 70%\">{$warning_mgs}</h1>";
         } else {
             $contribution_mgs = __('If you wish to help us with translating EPESI to your language, then click Translation Contribution in the Action Bar.');
             print "<h3>{$contribution_mgs}</h3>";
         }
         $form->display_as_column();
         if ($allow_sending) {
             $href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'send_lang_ajax'), array($currently_translating));
             print "<h4><a {$href}>" . __('Send all your custom translations for language %s', array($langs[$currently_translating])) . "</a></h4>";
         }
         $help_msg = __('You can open next string to translate with space button');
         print "<p>{$help_msg}</p>";
     }
     Base_LangCommon::load($_SESSION['client']['base_lang_administrator']['currently_translating']);
     $data = array();
     foreach ($custom_translations as $o => $t) {
         if ($t || !isset($translations[$o])) {
             $translations[$o] = $t;
         }
     }
     foreach ($translations as $o => $t) {
         if (isset($custom_translations[$o]) && $custom_translations[$o]) {
             $t = $custom_translations[$o];
         } else {
             if ($filter == 1) {
                 continue;
             }
         }
         if ($filter == 2 && !$t) {
             continue;
         }
         if ($filter == 3 && $t) {
             continue;
         }
         $span_id = 'trans__' . md5($o);
         if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
             $org = '<a href="javascript:void(0);" onclick="lang_translate(\'' . Epesi::escapeJS(htmlspecialchars($o)) . '\',\'' . $span_id . '\');">' . $o . '</a>';
             $t = '<span id="' . $span_id . '">' . $t . '</span>';
         }
         eval_js('translate_add_id("' . $span_id . '","' . Epesi::escapeJS($o) . '");');
         $data[] = array($org, $t);
     }
     $gb = $this->init_module('Utils/GenericBrowser', null, 'lang_translations');
     $gb->set_custom_label($trans_filter);
     $gb->set_table_columns(array(array('name' => __('Original'), 'order_preg' => '/^<[^>]+>([^<]*)<[^>]+>$/i', 'search' => 'original'), array('name' => __('Translated'), 'search' => 'translated')));
     //$limit = $gb->get_limit(count($data));
     $id = 0;
     foreach ($data as $v) {
         //if ($id>=$limit['offset'] && $id<$limit['offset']+$limit['numrows'])
         $gb->add_row_array($v);
         $id++;
     }
     Base_LangCommon::load();
     $this->display_module($gb, array(true), 'automatic_display');
     Utils_ShortcutCommon::add(array(' '), 'translate_first_on_the_list', array('disable_in_input' => 1));
 }
Example #27
0
 public static function crm_event_get($id)
 {
     if (!is_array($id)) {
         $r = Utils_RecordBrowserCommon::get_record('task', $id);
     } else {
         $r = $id;
         $id = $r['id'];
     }
     $r = Utils_RecordBrowserCommon::filter_record_by_access('task', $r);
     if (!$r) {
         return null;
     }
     $next = array('type' => __('Task'));
     $day = $r['deadline'];
     $iday = strtotime($day);
     $next['id'] = $r['id'];
     $base_unix_time = strtotime(date('1970-01-01 00:00:00'));
     $next['start'] = $iday;
     $next['timeless'] = $day;
     $next['duration'] = -1;
     $next['title'] = (string) $r['title'];
     $next['description'] = (string) $r['description'];
     $next['color'] = 'gray';
     if ($r['status'] == 0 || $r['status'] == 1) {
         switch ($r['priority']) {
             case 0:
                 $next['color'] = 'green';
                 break;
             case 1:
                 $next['color'] = 'yellow';
                 break;
             case 2:
                 $next['color'] = 'red';
                 break;
         }
     }
     if ($r['status'] == 2) {
         $next['color'] = 'blue';
     }
     if ($r['status'] == 3) {
         $next['color'] = 'gray';
     }
     $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'view');
     if (Utils_RecordBrowserCommon::get_access('task', 'edit', $r) !== false) {
         $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'edit');
     } else {
         $next['edit_action'] = false;
         $next['move_action'] = false;
     }
     if (Utils_RecordBrowserCommon::get_access('task', 'delete', $r) == false) {
         $next['delete_action'] = false;
     }
     /*		$r_new = $r;
     		if ($r['status']==0) $r_new['status'] = 1;
     		if ($r['status']<=1) $next['actions'] = array(
     			array('icon'=>Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href'=>self::get_status_change_leightbox_href($r_new, false, array('id'=>'status')))
     		);*/
     $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, false);
     $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, false);
     $inf2 = array(__('Date') => '<b>' . $event_date . '</b>');
     $emps = array();
     foreach ($r['employees'] as $e) {
         $e = CRM_ContactsCommon::contact_format_no_company($e, true);
         $e = str_replace('&nbsp;', ' ', $e);
         if (mb_strlen($e, 'UTF-8') > 33) {
             $e = mb_substr($e, 0, 30, 'UTF-8') . '...';
         }
         $emps[] = $e;
     }
     $next['busy_label'] = $r['employees'];
     $cuss = array();
     foreach ($r['customers'] as $c) {
         $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers'));
         $cuss[] = str_replace('&nbsp;', ' ', $c);
     }
     $inf2 += array(__('Task') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('task/' . $r['id']));
     $next['employees'] = $r['employees'];
     $next['customers'] = $r['customers'];
     $next['status'] = $r['status'] <= 2 ? 'active' : 'closed';
     $next['custom_tooltip'] = '<center><b>' . __('Task') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null);
     return $next;
 }
Example #28
0
 public function make_event_PDF($pdf, $id, $no_details = false, $type = 'Event')
 {
     $custom_event = false;
     if (!is_array($id)) {
         $check = explode('#', $id);
         if (isset($check[1])) {
             $callback = DB::GetOne('SELECT handler_callback FROM crm_calendar_custom_events_handlers WHERE id=%d', $check[0]);
             $callback = explode('::', $callback);
             $ev = call_user_func($callback, 'get', $check[1]);
             $no_details = true;
             $custom_event = true;
         } else {
             trigger_error('Invalid event id: ' . $id, E_USER_ERROR);
         }
     } else {
         $ev = $id;
         $id = $ev['id'];
         $id = explode('_', $id);
         $id = $id[0];
         /*			$ev_details = DB::GetRow('SELECT *, starts AS start, ends AS end FROM crm_calendar_event WHERE id=%d', array($id));
         			foreach ($ev_details as $k=>$v)
         				if (!isset($ev[$k])) $ev[$k] = $v;*/
         $ev['title'] = strip_tags($ev['title']);
         $check = explode('#', $id);
         if (isset($check[1])) {
             $no_details = true;
             $custom_event = true;
         }
     }
     $pdf_theme = $this->pack_module('Base/Theme');
     $pdf_theme->assign('description', array('label' => __('Description'), 'value' => str_replace("\n", '<br/>', htmlspecialchars($ev['description']))));
     if (!$no_details) {
         $ev['status'] = Utils_CommonDataCommon::get_value('CRM/Status/' . $ev['status'], true);
         $ev['access'] = self::$access[$ev['access']];
         $ev['priority'] = self::$priority[$ev['priority']];
         foreach (array('access' => __('Access'), 'priority' => __('Priority'), 'status' => __('Status')) as $v => $label) {
             $pdf_theme->assign($v, array('label' => $label, 'value' => $ev[$v]));
         }
         $created_by = CRM_ContactsCommon::get_contact_by_user_id($ev['created_by']);
         if ($created_by !== null) {
             $created_by = $created_by['last_name'] . ' ' . $created_by['first_name'];
         } else {
             $created_by = Base_UserCommon::get_user_login($ev['created_by']);
         }
         $created_on = Base_RegionalSettingsCommon::time2reg($ev['created_on'], false);
         $pdf_theme->assign('created_on', array('label' => __('Created on'), 'value' => $created_on));
         $pdf_theme->assign('created_by', array('label' => __('Created by'), 'value' => $created_by));
         if ($ev['edited_by'] != null) {
             $edited_by = CRM_ContactsCommon::get_contact_by_user_id($ev['edited_by']);
             if ($edited_by !== null) {
                 $edited_by = $edited_by['last_name'] . ' ' . $edited_by['first_name'];
             } else {
                 $edited_by = Base_UserCommon::get_user_login($ev['edited_by']);
             }
             $edited_on = Base_RegionalSettingsCommon::time2reg($ev['edited_on'], false);
         } else {
             $edited_by = '--';
             $edited_on = '--';
         }
         $pdf_theme->assign('edited_on', array('label' => __('Edited on'), 'value' => $edited_on));
         $pdf_theme->assign('edited_by', array('label' => __('Edited by'), 'value' => $edited_by));
         $pdf_theme->assign('printed_on', array('label' => __('Printed on'), 'value' => Base_RegionalSettingsCommon::time2reg(time())));
     }
     $emps = array();
     $cuss = array();
     $cus_cmps = array();
     if (isset($ev['employees']) && !empty($ev['employees'])) {
         foreach ($ev['employees'] as $v) {
             $c = CRM_ContactsCommon::get_contact($v);
             $emps[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone']);
         }
     }
     if (isset($ev['customers']) && !empty($ev['customers'])) {
         foreach ($ev['customers'] as $v) {
             $det = explode(':', $v);
             if (isset($det[1])) {
                 $v = $det[1];
             } else {
                 $v = $det[0];
                 $det[0] = 'P';
             }
             if ($det[0] == 'P') {
                 $c = CRM_ContactsCommon::get_contact($v);
                 $company_name = isset($c['company_name']) && is_numeric($c['company_name']) ? array(Utils_RecordBrowserCommon::get_value('company', $c['company_name'], 'Company Name')) : '---';
                 $cuss[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone'], 'company_name' => $company_name);
             }
             if ($det[0] == 'C') {
                 $c = array('company_name' => array($v));
             }
             if (is_array($c['company_name'])) {
                 foreach ($c['company_name'] as $v2) {
                     if (!isset($cus_cmps[$v2])) {
                         $cus_cmps[$v2] = CRM_ContactsCommon::get_company($v2);
                     }
                 }
             }
         }
     }
     $pdf_theme->assign('employees', array('main_label' => __('Employees'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'lp_label' => __('Lp'), 'data' => $emps));
     $pdf_theme->assign('customers', array('main_label' => __('Customers'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'company_name' => __('Company Name'), 'lp_label' => __('Lp'), 'data' => $cuss));
     $pdf_theme->assign('customers_companies', array('main_label' => __('Customers Companies'), 'name_label' => __('Company Name'), 'phone_label' => __('Phone'), 'fax_label' => __('Fax'), 'address_label' => __('Address'), 'city_label' => __('City'), 'lp_label' => __('Lp'), 'data' => $cus_cmps));
     $pdf_theme->assign('title', array('label' => __('Title'), 'value' => $ev['title']));
     $start = Base_RegionalSettingsCommon::time2reg($ev['start'], false);
     $pdf_theme->assign('start_date', array('label' => __('Start Date'), 'value' => $start, 'details' => array('weekday' => __date('l', strtotime($start)))));
     if (!isset($ev['timeless'])) {
         $pdf_theme->assign('start_time', array('label' => __('Start Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['start'], true, false)));
         if (!isset($ev['end'])) {
             trigger_error(print_r($ev, true));
         }
         $pdf_theme->assign('end_time', array('label' => __('End Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], true, false)));
         $hours = floor(($ev['end'] - $ev['start']) / 3600);
         $format = __('%d hours', array($hours));
         $minutes = ($ev['end'] - $ev['start']) % 3600;
         if ($minutes != 0) {
             if ($hours == 0) {
                 $format = '';
             } else {
                 $format .= ', ';
             }
             $format .= __('%d minutes', array($minutes / 60));
         }
         $pdf_theme->assign('duration', array('label' => __('Duration'), 'value' => $format));
         if (date('Y-m-d', $ev['start']) != date('Y-m-d', $ev['end'])) {
             $pdf_theme->assign('end_date', array('label' => __('End Date'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], false)));
         }
     } else {
         $pdf_theme->assign('timeless', array('label' => __('Timeless'), 'value' => __('Yes')));
     }
     $pdf_theme->assign('type', $type);
     ob_start();
     $pdf_theme->display('pdf_version');
     $cont = ob_get_clean();
     $pdf->writeHTML($cont);
 }
Example #29
0
 public function addon_flat($rs, $id)
 {
     $rb = $this->init_module('Utils/RecordBrowser', 'rc_mails', 'rc_mails_flat');
     $rb->set_header_properties(array('date' => array('width' => 10), 'employee' => array('name' => __('Archived by'), 'width' => 20), 'contacts' => array('name' => __('Involved contacts'), 'width' => 20), 'subject' => array('name' => __('Message'), 'width' => 40), 'attachments' => array('width' => 5)));
     $rb->set_additional_actions_method(array($this, 'actions_for_mails'));
     if ($rs == 'contact') {
         $this->display_module($rb, array(array('(employee' => $id, '|contacts' => array('P:' . $id), '|related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data');
     } elseif ($rs == 'company') {
         $form = $this->init_module('Libs/QuickForm');
         $form->addElement('checkbox', 'include_related', __('Include related e-mails'), null, array('onchange' => $form->get_submit_form_js()));
         if ($form->validate()) {
             $show_related = $form->exportValue('include_related');
             $this->set_module_variable('include_related', $show_related);
         }
         $show_related = $this->get_module_variable('include_related');
         $form->setDefaults(array('include_related' => $show_related));
         ob_start();
         $form->display_as_row();
         $html = ob_get_clean();
         $rb->set_button(false, $html);
         $customers = array('C:' . $id);
         if ($show_related) {
             $conts = CRM_ContactsCommon::get_contacts(array('company_name' => $id));
             foreach ($conts as $c) {
                 $customers[] = 'P:' . $c['id'];
             }
         }
         $this->display_module($rb, array(array('(contacts' => $customers, '|related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data');
     } else {
         $this->display_module($rb, array(array('related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data');
     }
 }
Example #30
0
 */
defined("_VALID_ACCESS") || die('Direct access forbidden');
$ret = '';
$values = $_POST['values'];
foreach ($values as $v) {
    if ($ret != '') {
        $ret = $v;
        break;
    }
    $ret = $v;
}
if ($ret === '') {
    print json_encode(array());
} else {
    list($r, $id) = explode(':', $ret);
    if ($r == 'P') {
        $contact = CRM_ContactsCommon::get_contact($id);
        $res = array();
        $i = 1;
        foreach (array('mobile_phone' => __('Mobile Phone'), 'work_phone' => __('Work Phone'), 'home_phone' => __('Home Phone')) as $id => $v) {
            if (isset($contact[$id]) && $contact[$id]) {
                $res[$i] = $v . ': ' . $contact[$id];
            }
            $i++;
        }
    } else {
        $company = CRM_ContactsCommon::get_company($id);
        $res = array(4 => __('Phone') . ': ' . $company['phone']);
    }
    print json_encode($res);
}