コード例 #1
0
ファイル: Filters_0.php プロジェクト: 62BRAINS/EPESI
 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();
 }
コード例 #2
0
ファイル: Roundcube_0.php プロジェクト: 62BRAINS/EPESI
 public function reload_mails($id)
 {
     $contact = CRM_ContactsCommon::get_contact($id);
     $emails = array($contact['email']);
     $multiple = Utils_RecordBrowserCommon::get_records('rc_multiple_emails', array('record_type' => 'contact', 'record_id' => $id));
     foreach ($multiple as $multi) {
         $emails[] = $multi['email'];
     }
     $emails = array_unique($emails);
     foreach ($emails as $email) {
         $cc = Utils_RecordBrowserCommon::get_records('rc_mails', array('(~from' => '%' . $email . '%', '|~to' => '%' . $email . '%'));
         foreach ($cc as $mail) {
             if ($mail['employee'] == $id || in_array('P:' . $id, $mail['contacts'])) {
                 continue;
             }
             $mail['contacts'][] = 'P:' . $id;
             Utils_RecordBrowserCommon::update_record('rc_mails', $mail['id'], array('contacts' => $mail['contacts']));
             CRM_RoundcubeCommon::create_thread($mail['id']);
         }
     }
 }
コード例 #3
0
ファイル: update_phones.php プロジェクト: cretzu89/EPESI
 */
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);
}
コード例 #4
0
ファイル: MeetingCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function submit_meeting($values, $mode)
 {
     $me = CRM_ContactsCommon::get_my_record();
     switch ($mode) {
         case 'delete':
             Utils_MessengerCommon::delete_by_id('CRM_Calendar_Event:' . $values['id']);
             break;
         case 'display':
             $pdf = Utils_RecordBrowser::$rb_obj->pack_module('Libs/TCPDF', 'L');
             if ($pdf->prepare()) {
                 $pdf->set_title($values['title']);
                 $pdf->set_subject('');
                 $pdf->prepare_header();
                 $pdf->AddPage();
                 $v = CRM_Calendar_EventCommon::get(DB::GetOne('SELECT id FROM crm_calendar_custom_events_handlers WHERE group_name=%s', array('Meetings')) . '#' . $values['id']);
                 $ev_mod = Utils_RecordBrowser::$rb_obj->init_module('CRM/Calendar/Event');
                 $ev_mod->make_event_PDF($pdf, $v, true, 'view');
             }
             $pdf->add_actionbar_icon('Print');
             if (isset($_REQUEST['day'])) {
                 $values['date'] = $_REQUEST['day'];
             }
             $ret = array();
             if ($values['time']) {
                 // normal event
                 $start = $values['time'];
                 // time in unix timestamp UTC
                 $start_disp = strtotime(Base_RegionalSettingsCommon::time2reg($start, true, true, true, false));
             } else {
                 // when event is timeless - all day event
                 $time = $values['date'] . ' 00:00:01';
                 $start = Base_RegionalSettingsCommon::reg2time($time);
                 $start_disp = strtotime($time);
             }
             $end = strtotime('+' . $values['duration'] . ' seconds', $start);
             $ret['day_details'] = array('start' => array('day' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'day', 'default_date' => strtotime($values['date']))), array()) . '>' . date('j', $start_disp) . '</a>', 'month' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'month', 'default_date' => strtotime($values['date']))), array()) . '>' . __date('F', $start_disp) . '</a>', 'year' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'year', 'default_date' => strtotime($values['date']))), array()) . '>' . date('Y', $start_disp) . '</a>', 'weekday' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'week', 'default_date' => strtotime($values['date']))), array()) . '>' . __date('l', $start_disp) . '</a>'));
             if (!isset($values['timeless']) || !$values['timeless']) {
                 $ret['event_info'] = array('start_time' => Base_RegionalSettingsCommon::time2reg($start, 2, false), 'end_time' => Base_RegionalSettingsCommon::time2reg($end, 2, false), 'duration' => Base_RegionalSettingsCommon::seconds_to_words($values['duration']), 'start_date' => '-', 'end_date' => '-');
             }
             $ret['form_data']['timeless'] = array('label' => __('Timeless'), 'html' => 'value');
             $ret['toggle_duration'] = 'tog';
             $ret['duration_block_id'] = '1';
             $ret['event_end_block_id'] = '2';
             $values['title'] = __('Follow-up') . ': ' . $values['title'];
             $values['status'] = 0;
             $cus = reset($values['customers']);
             if (ModuleManager::is_installed('CRM/Meeting') >= 0) {
                 $ret['new']['event'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Meeting')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('crm_meeting', array('title' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'date' => date('Y-m-d'), 'time' => date('H:i:s'), 'duration' => 3600, 'employees' => $values['employees'], 'customers' => $values['customers'], 'status' => 0), 'none', false) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Calendar', 'icon-small.png') . '" /></a>';
             }
             if (ModuleManager::is_installed('CRM/Tasks') >= 0) {
                 $ret['new']['task'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Task')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('task', array('title' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'employees' => $values['employees'], 'customers' => $values['customers'], 'status' => 0, 'deadline' => date('Y-m-d', strtotime('+1 day')))) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon-small.png') . '"></a>';
             }
             if (ModuleManager::is_installed('CRM/PhoneCall') >= 0) {
                 $ret['new']['phonecall'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Phonecall')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('phonecall', array('subject' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'date_and_time' => date('Y-m-d H:i:s'), 'employees' => $values['employees'], 'customer' => $cus, 'status' => 0), 'none', false) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_PhoneCall', 'icon-small.png') . '" /></a>';
             }
             $ret['new']['note'] = Utils_RecordBrowser::$rb_obj->add_note_button('crm_meeting/' . $values['id']);
             return $ret;
         case 'edit':
             self::subscribed_employees($values);
             $alarms = Utils_MessengerCommon::get_alarms('CRM_Calendar_Event:' . $values['id']);
             $old = Utils_RecordBrowserCommon::get_record('crm_meeting', $values['id']);
             $old_time = strtotime($old['date'] . ' ' . date('H:i:s', strtotime($old['time'])));
             $new_time = strtotime($values['date'] . ' ' . date('H:i:s', strtotime($values['time'])));
             foreach ($alarms as $id => $time) {
                 $time = strtotime($time);
                 $diff = $old_time - $time;
                 Utils_MessengerCommon::update_time($id, $new_time - $diff);
             }
         case 'add':
             if (isset($values['duration_switch']) && !$values['duration_switch']) {
                 $values['duration'] = strtotime($values['end_time']) - strtotime($values['time']);
                 if ($values['duration'] < 0) {
                     $values['duration'] += 60 * 60 * 24;
                 }
                 // failsafe
             }
             if (isset($values['timeless']) && $values['timeless']) {
                 $values['duration'] = -1;
             }
             $new = '';
             foreach (array(0 => 'Mon', 1 => 'Tue', 2 => 'Wed', 3 => 'Thu', 4 => 'Fri', 5 => 'Sat', 6 => 'Sun') as $k => $v) {
                 if (isset($values['recurrence_hash_' . $k]) && $values['recurrence_hash_' . $k]) {
                     $new .= '1';
                 } else {
                     $new .= '0';
                 }
             }
             if ($new != '0000000') {
                 $values['recurrence_hash'] = $new;
             }
             if ($values['duration'] != -1) {
                 if (isset($values['modded'])) {
                     $time = Base_RegionalSettingsCommon::time2reg($values['time'], true, true, true, false);
                     $reg_timestamp = $values['date'] . ' ' . date('H:i:s', strtotime($time));
                     $timestamp = Base_RegionalSettingsCommon::reg2time($reg_timestamp);
                     $values['date'] = date('Y-m-d', $timestamp);
                     $values['time'] = date('Y-m-d H:i:s', $timestamp);
                     if (isset($values['recurrence_end']) && $values['recurrence_end']) {
                         $values['recurrence_end'] = date('Y-m-d', Base_RegionalSettingsCommon::reg2time($values['recurrence_end'] . ' ' . date('H:i:s', strtotime($time))));
                         if ($values['recurrence_end'] < $values['date']) {
                             $values['recurrence_end'] = $values['date'];
                         }
                         if ($values['recurrence_type'] == 8) {
                             $date = date('Y-m-d', strtotime('+6 days', strtotime($values['date'])));
                             if ($values['recurrence_end'] < $date) {
                                 $values['recurrence_end'] = $date;
                             }
                         }
                     }
                 }
             } else {
                 $values['time'] = '';
             }
             break;
         case 'adding':
             $values['permission'] = Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission');
         case 'editing':
         case 'view':
             $values['modded'] = 1;
             if (!isset($values['date'])) {
                 $values['date'] = date('Y-m-d');
             }
             if (!isset($values['time'])) {
                 $values['time'] = time();
             }
             if (!isset($values['duration'])) {
                 $values['duration'] = 3600;
             }
             if (!is_numeric($values['time'])) {
                 $values['time'] = strtotime($values['time']);
             }
             if ($values['duration'] != -1) {
                 if (isset($values['date']) && $values['date']) {
                     $values['date'] = Base_RegionalSettingsCommon::time2reg($values['date'] . ' ' . date('H:i:s', $values['time']), false, true, true, false);
                     $values['time'] = Base_RegionalSettingsCommon::time2reg($values['date'] . ' ' . date('H:i:s', $values['time']), true, false, true, false);
                     $values['time'] = Base_RegionalSettingsCommon::reg2time($values['date'] . ' ' . $values['time']);
                 }
                 if (isset($values['recurrence_end']) && $values['recurrence_end']) {
                     $values['recurrence_end'] = Base_RegionalSettingsCommon::time2reg($values['recurrence_end'] . ' ' . date('H:i:s', $values['time']), false, true, true, false);
                 }
             }
             break;
         case 'added':
             if (isset($values['follow_up'])) {
                 CRM_FollowupCommon::add_tracing_notes($values['follow_up'][0], $values['follow_up'][1], $values['follow_up'][2], 'meeting', $values['id'], $values['title']);
             }
             self::subscribed_employees($values);
             $related = array_merge($values['employees'], $values['customers']);
             foreach ($related as $v) {
                 if ($mode === 'edit' && in_array($v, $old_related)) {
                     continue;
                 }
                 if (!is_numeric($v)) {
                     list($t, $id) = explode(':', $v);
                 } else {
                     $t = 'P';
                     $id = $v;
                 }
                 if ($t == 'P') {
                     $t = 'contact';
                 } else {
                     $t = 'company';
                 }
                 $subs = Utils_WatchdogCommon::get_subscribers($t, $id);
                 foreach ($subs as $s) {
                     Utils_WatchdogCommon::user_subscribe($s, 'crm_meeting', $values['id']);
                 }
             }
             if (isset($values['messenger_on']) && $values['messenger_on'] != 'none') {
                 $start = strtotime($values['date'] . ' ' . date('H:i:s', strtotime($values['time'])));
                 if ($values['messenger_on'] == 'me') {
                     Utils_MessengerCommon::add('CRM_Calendar_Event:' . $values['id'], 'CRM_Meeting', $values['messenger_message'], $start - $values['messenger_before'], array('CRM_MeetingCommon', 'get_alarm'), array($values['id']));
                 } else {
                     $eee = array();
                     foreach ($values['employees'] as $v) {
                         $c = CRM_ContactsCommon::get_contact($v);
                         if (isset($c['login'])) {
                             $eee[] = $c['login'];
                         }
                     }
                     Utils_MessengerCommon::add('CRM_Calendar_Event:' . $values['id'], 'CRM_Meeting', $values['messenger_message'], $start - $values['messenger_before'], array('CRM_MeetingCommon', 'get_alarm'), array($values['id']), $eee);
                 }
             }
             break;
     }
     return $values;
 }
コード例 #5
0
ファイル: Event_0.php プロジェクト: 62BRAINS/EPESI
 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);
 }
コード例 #6
0
ファイル: ContactsCommon_0.php プロジェクト: 62BRAINS/EPESI
 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;
 }
コード例 #7
0
ファイル: ActivityReport_0.php プロジェクト: 62BRAINS/EPESI
 public function body()
 {
     if (!Base_AclCommon::check_permission('View Activity Report')) {
         return;
     }
     $rb_tabs = DB::GetAssoc('SELECT tab, caption FROM recordbrowser_table_properties ORDER BY caption');
     foreach ($rb_tabs as $k => $v) {
         $rb_tabs[$k] = Utils_RecordBrowserCommon::get_caption($k);
     }
     $form = $this->init_module('Libs/QuickForm');
     $users_count = DB::GetOne('SELECT COUNT(id) FROM user_login') > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete');
     if ($users_count) {
         $crits = array('!login' => '');
         $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company');
         $form->addElement('autoselect', 'user', __('User'), array(), array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback)), $fcallback);
     } else {
         $users = DB::GetAssoc('SELECT id, id FROM user_login');
         foreach ($users as $k => $u) {
             $users[$k] = Base_UserCommon::get_user_label($u, true);
         }
         asort($users);
         $users = array('' => '[' . __('All') . ']') + $users;
         $form->addElement('select', 'user', __('User'), $users);
     }
     $form->addElement('multiselect', 'recordsets', __('Record Type'), $rb_tabs);
     $form->addElement('checkbox', 'new', __('New record'));
     $form->addElement('checkbox', 'edit', __('Record edit'));
     $form->addElement('checkbox', 'delete_restore', __('Record Delete/restore'));
     $form->addElement('checkbox', 'file', __('Files'));
     $form->addElement('datepicker', 'start_date', __('Start Date'));
     $form->addElement('datepicker', 'end_date', __('End Date'));
     //$form->addElement('submit', 'submit', __('Show'));
     Base_ActionBarCommon::add('search', __('Show'), $form->get_submit_form_href());
     $filters = $this->get_module_variable('filters', array('user' => '', 'new' => 1, 'edit' => 1, 'delete_restore' => 1, 'recordsets' => array_keys($rb_tabs), 'start_date' => date('Y-m-01'), 'end_date' => date('Y-m-d')));
     if ($form->validate()) {
         $filters = $form->exportValues();
         $this->set_module_variable('filters', $filters);
     }
     $form->setDefaults($filters);
     $theme = $this->init_module('Base/Theme');
     $form->assign_theme('form', $theme);
     $theme->display();
     $filters['recordsets'] = array_flip($filters['recordsets']);
     foreach ($rb_tabs as $k => $v) {
         if (!isset($filters['recordsets'][$k])) {
             unset($rb_tabs[$k]);
         }
     }
     $gb = $this->init_module('Utils/GenericBrowser', null, 'activity_report');
     $gb->set_table_columns(array(array('name' => __('Date'), 'width' => 40), array('name' => __('User'), 'width' => 40), array('name' => __('Type'), 'width' => 40), array('name' => __('Label')), array('name' => __('Actions taken'), 'width' => 40)));
     $tables = array();
     if ($users_count) {
         $filters['user'] = CRM_ContactsCommon::get_contact($filters['user']);
         $filters['user'] = $filters['user']['login'];
     }
     $af_where = array();
     foreach ($rb_tabs as $k => $t) {
         $af_where[] = 'ual.local ' . DB::like() . ' ' . DB::Concat(DB::qstr($k . '/'), DB::qstr('%'));
     }
     $af_where = count($af_where) ? ' (' . implode(' OR ', $af_where) . ')' : 'TRUE ';
     $e_where = array();
     $c_where = '';
     if ($filters['user']) {
         $e_where[] = ' edited_by = ' . $filters['user'];
         $c_where = ' created_by = ' . $filters['user'];
         $af_where .= ' AND uaf.created_by = ' . $filters['user'];
     }
     if (isset($filters['edit'])) {
         if (!isset($filters['delete_restore'])) {
             $e_where[] = ' ehd.field!=' . DB::qstr('id');
         }
     } else {
         if (isset($filters['delete_restore'])) {
             $e_where[] = ' ehd.field=' . DB::qstr('id');
         }
     }
     if ($filters['start_date']) {
         $date = DB::qstr(date('Y-m-d', strtotime($filters['start_date'])));
         $af_where .= ' AND uaf.created_on >= ' . $date;
         $c_where .= ($c_where ? ' AND' : '') . ' created_on >= ' . $date;
         $e_where[] = ' edited_on >= ' . $date;
     }
     if ($filters['end_date']) {
         $date = DB::qstr(date('Y-m-d 23:59:59', strtotime($filters['end_date'])));
         $af_where .= ' AND uaf.created_on <= ' . $date;
         $c_where .= ($c_where ? ' AND' : '') . ' created_on <= ' . $date;
         $e_where[] = ' edited_on <= ' . $date;
     }
     if (!empty($e_where)) {
         $e_where = ' WHERE' . implode(' AND', $e_where);
     } else {
         $e_where = '';
     }
     if ($c_where) {
         $c_where = ' WHERE' . $c_where;
     }
     $postgre_cast_type = DB::is_postgresql() ? '::varchar' : '';
     // **** files ****
     if (isset($filters['file'])) {
         $tables[] = 'SELECT uaf.id AS id,uaf.created_on AS edited_on,uaf.created_by AS edited_by, ual.local AS r_id, ' . DB::qstr('') . ' AS tab, ' . DB::qstr('file') . ' AS action FROM utils_attachment_file uaf INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local ual ON ua.id=ual.attachment WHERE original!=' . DB::qstr('') . ' AND ' . $af_where;
     }
     // **** edit ****
     if (isset($filters['edit']) || isset($filters['delete_restore'])) {
         foreach ($rb_tabs as $k => $t) {
             $tables[] = 'SELECT id, edited_on, edited_by, ' . $k . '_id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('edit') . ' as action FROM ' . $k . '_edit_history eh LEFT JOIN ' . $k . '_edit_history_data ehd ON ehd.edit_id=eh.id' . $e_where;
         }
     }
     // **** create ****
     if (isset($filters['new'])) {
         foreach ($rb_tabs as $k => $t) {
             $tables[] = 'SELECT 0 AS id, created_on AS edited_on, created_by AS edited_by, id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('create') . ' as action FROM ' . $k . '_data_1' . $c_where;
         }
     }
     if (!empty($tables)) {
         $tables = implode(' UNION ', $tables);
         $limit = DB::GetOne('SELECT COUNT(*) FROM (' . $tables . ') AS tmp');
         $limit = $gb->get_limit($limit);
         $ret = DB::SelectLimit('SELECT * FROM (' . $tables . ') AS tmp ORDER BY edited_on DESC', $limit['numrows'], $limit['offset']);
         while ($row = $ret->FetchRow()) {
             $user = Base_UserCommon::get_user_label($row['edited_by']);
             $action = '';
             $link = '';
             switch ($row['action']) {
                 case 'edit':
                     $details = DB::GetAssoc('SELECT field, old_value FROM ' . $row['tab'] . '_edit_history_data WHERE edit_id=%d', array($row['id']));
                     if (isset($details['id'])) {
                         $action = $details['id'] == 'DELETED' ? __('Deleted') : __('Restored');
                     } else {
                         $action = __('Edited');
                         $action = '<a ' . Utils_TooltipCommon::tooltip_leightbox_mode() . ' ' . Utils_TooltipCommon::ajax_open_tag_attrs(array('Utils_RecordBrowserCommon', 'get_edit_details_label'), array($row['tab'], $row['r_id'], $row['id']), 500) . '>' . $action . '</a>';
                     }
                     $r_id = $row['r_id'];
                     break;
                 case 'create':
                     $action = __('Created');
                     $r_id = $row['r_id'];
                     break;
                 case 'file':
                     $action = __('Attachment') . ': ';
                     $action .= $row['id'] == 0 ? __('New') : __('Updated');
                     $id = explode('/', $row['r_id']);
                     $row['tab'] = $id[0];
                     $r_id = $id[1];
                     break;
                 case 'note':
                     $action = __('Note') . ': ';
                     $action .= $row['id'] == 0 ? __('New') : __('Updated');
                     $id = explode('/', $row['r_id']);
                     $row['tab'] = $id[0];
                     $r_id = $id[1];
                     break;
             }
             if (!Utils_RecordBrowserCommon::get_access($row['tab'], 'view', Utils_RecordBrowserCommon::get_record($row['tab'], $r_id))) {
                 $link = __('Access restricted');
                 $action = strip_tags($action);
             } else {
                 $link = Utils_TooltipCommon::create('<img src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'info.png') . '">', Utils_RecordBrowserCommon::get_html_record_info($row['tab'], $r_id), false);
                 $link .= '&nbsp;';
                 $link .= Utils_RecordBrowserCommon::create_default_linked_label($row['tab'], $r_id, false, false);
             }
             $gb->add_row(Base_RegionalSettingsCommon::time2reg($row['edited_on']), $user, $rb_tabs[$row['tab']], $link, $action);
         }
     }
     Base_ThemeCommon::load_css('Utils_RecordBrowser', 'changes_list');
     $this->display_module($gb);
 }
コード例 #8
0
ファイル: PhoneCallCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function display_phone($record, $nolink, $desc)
 {
     if ($record[$desc['id']] == '') {
         return '';
     }
     $num = $record[$desc['id']];
     if (!isset($record['customer']) || !$record['customer']) {
         return '---';
     }
     list($r, $id) = explode(':', $record['customer']);
     if ($r == 'P') {
         $contact = CRM_ContactsCommon::get_contact($id);
     } else {
         $contact = CRM_ContactsCommon::get_company($id);
     }
     $nr = '';
     switch ($num) {
         case 1:
             $id = 'mobile_phone';
             $nr = 'Mobile Phone';
             break;
         case 2:
             $id = 'work_phone';
             $nr = 'Work Phone';
             break;
         case 3:
             $id = 'home_phone';
             $nr = 'Home Phone';
             break;
         case 4:
             $id = 'phone';
             $nr = 'Phone';
             break;
     }
     if (!$nr) {
         return '';
     }
     if (!isset($contact[$id])) {
         return '---';
     }
     $number = $contact[$id];
     if ($number && strpos($number, '+') === false) {
         if ($contact['country']) {
             $calling_code = Utils_CommonDataCommon::get_value('Calling_Codes/' . $contact['country']);
             if ($calling_code) {
                 $number = $calling_code . ' ' . $number;
             }
         }
     }
     if (MOBILE_DEVICE && IPHONE) {
         return $nr[0] . ': ' . '<a href="tel:' . $number . '">' . $number . '</a>';
     }
     if ($nolink) {
         return $nr[0] . ': ' . $number;
     }
     return $nr[0] . ': ' . CRM_CommonCommon::get_dial_code($number);
 }
コード例 #9
0
ファイル: update_contact.php プロジェクト: cretzu89/EPESI
    $params[$k] = $v;
}
if ($ret == '') {
    $contacts = array();
} else {
    $contacts = CRM_ContactsCommon::get_contacts(array('(company_name' => $ret, '|related_companies' => array($ret)), array(), array('last_name' => 'ASC'));
}
$res = array();
$callback = explode('::', $params['format']);
if (!is_array($_POST['defaults'])) {
    if ($_POST['defaults'] != '') {
        $_POST['defaults'] = array($_POST['defaults']);
    } else {
        $_POST['defaults'] = array();
    }
}
$ext_rec = array_flip($_POST['defaults']);
foreach ($contacts as $k => $v) {
    $res[$v['id']] = call_user_func($callback, $v, true);
    if (isset($_POST['defaults'])) {
        unset($ext_rec[$v['id']]);
    }
}
foreach ($ext_rec as $k => $v) {
    $c = CRM_ContactsCommon::get_contact($k);
    $res[$k] = call_user_func($callback, $c, true);
}
if (!isset($params['required']) || !$params['required']) {
    $res = array('' => '---') + $res;
}
print json_encode($res);