Exemplo n.º 1
0
 public function uninstall()
 {
     CRM_CalendarCommon::delete_event_handler('Phonecalls');
     CRM_RoundcubeCommon::delete_addon('phonecall');
     Base_ThemeCommon::uninstall_default_theme(CRM_PhoneCallInstall::module_name());
     Utils_AttachmentCommon::delete_addon('phonecall');
     Utils_AttachmentCommon::persistent_mass_delete('phonecall/');
     Utils_RecordBrowserCommon::unregister_processing_callback('phonecall', array('CRM_PhoneCallCommon', 'submit_phonecall'));
     Utils_RecordBrowserCommon::uninstall_recordset('phonecall');
     return true;
 }
Exemplo n.º 2
0
 public static function drawLeightbox($prefix)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     $meetings = CRM_MeetingInstall::is_installed();
     $tasks = CRM_TasksInstall::is_installed();
     $phonecall = CRM_PhoneCallInstall::is_installed();
     self::check_location();
     if (!isset(self::$leightbox_ready[$prefix])) {
         self::$leightbox_ready[$prefix] = true;
         $theme = Base_ThemeCommon::init_smarty();
         eval_js_once($prefix . '_followups_deactivate = function(){leightbox_deactivate(\'' . $prefix . '_followups_leightbox\');}');
         if ($meetings) {
             $theme->assign('new_meeting', array('open' => '<a id="' . $prefix . '_new_meeting_button" onclick="' . $prefix . '_set_action(\'new_meeting\');' . $prefix . '_submit_form();">', 'text' => __('New Meeting'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_meeting_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($tasks) {
             $theme->assign('new_task', array('open' => '<a id="' . $prefix . '_new_task_button" onclick="' . $prefix . '_set_action(\'new_task\');' . $prefix . '_submit_form();">', 'text' => __('New Task'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_task_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($phonecall) {
             $theme->assign('new_phonecall', array('open' => '<a id="' . $prefix . '_new_phonecall_button" onclick="' . $prefix . '_set_action(\'new_phonecall\');' . $prefix . '_submit_form();">', 'text' => __('New Phonecall'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_phonecall_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         $theme->assign('just_close', array('open' => '<a id="' . $prefix . '_just_close_button" onclick="' . $prefix . '_set_action(\'none\');' . $prefix . '_submit_form();">', 'text' => __('Save'), 'close' => '</a>'));
         eval_js('Event.observe(\'' . $prefix . '_just_close_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         eval_js($prefix . '_submit_form = function () {' . '$(\'' . $prefix . '_follow_up_form\').submited.value=1;Epesi.href($(\'' . $prefix . '_follow_up_form\').serialize(), \'processing...\');$(\'' . $prefix . '_follow_up_form\').submited.value=0;' . '}');
         eval_js($prefix . '_set_action = function (arg) {' . 'document.forms["' . $prefix . '_follow_up_form"].action.value = arg;' . '}');
         eval_js($prefix . '_set_id = function (id) {' . 'document.forms["' . $prefix . '_follow_up_form"].id.value = id;' . '$("' . $prefix . '_closecancel").value=3;' . '$("' . $prefix . '_note").value="";' . '}');
         $theme->assign('form_open', '<form id="' . $prefix . '_follow_up_form" name="' . $prefix . '_follow_up_form" method="POST">' . '<input type="hidden" name="submited" value="0" />' . '<input type="hidden" name="form_name" value="' . $prefix . '_follow_up_form" />' . '<input type="hidden" name="id" value="" />' . '<input type="hidden" name="action" value="" />');
         $status_select_options = '';
         $statuses = Utils_CommonDataCommon::get_translated_array('CRM/Status');
         foreach ($statuses as $key => $value) {
             $status_select_options .= '<option value="' . htmlspecialchars($key) . '"' . ($key == 3 ? ' selected="1"' : '') . '>' . htmlspecialchars($value) . '</option>';
         }
         $theme->assign('form_closecancel', array('label' => __('Status'), 'html' => '<select name="closecancel" id="' . $prefix . '_closecancel" value="0">' . $status_select_options . '</select>'));
         $theme->assign('form_note', array('label' => __('Note'), 'html' => '<textarea name="note" id="' . $prefix . '_note"></textarea>'));
         $theme->assign('form_close', '</form>');
         ob_start();
         Base_ThemeCommon::display_smarty($theme, 'CRM_Followup', 'leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($prefix . '_followups_leightbox', $profiles_out, __('Follow-up'));
     }
 }
Exemplo n.º 3
0
 public function filters()
 {
     $form = $this->init_module(Libs_QuickForm::module_name());
     $form->addElement('header', 'display', __('Show'));
     if (CRM_MeetingInstall::is_installed()) {
         $form->addElement('checkbox', 'events', __('Meetings'), null, array('onchange' => $form->get_submit_form_js()));
     }
     if (CRM_TasksInstall::is_installed()) {
         $form->addElement('checkbox', 'tasks', __('Tasks'), null, array('onchange' => $form->get_submit_form_js()));
     }
     if (CRM_PhoneCallInstall::is_installed()) {
         $form->addElement('checkbox', 'phonecalls', __('Phonecalls'), null, array('onchange' => $form->get_submit_form_js()));
     }
     $form->addElement('select', 'activities_date', str_replace(' ', '&nbsp;', __('Activities date')), array(0 => __('Future'), 1 => __('Past'), 2 => __('All time')), array('onchange' => $form->get_submit_form_js()));
     $form->addElement('checkbox', 'closed', __('Closed'), null, array('onchange' => $form->get_submit_form_js()));
     $old_display = $this->get_module_variable('display_options', array('events' => CRM_MeetingInstall::is_installed(), 'tasks' => CRM_TasksInstall::is_installed(), 'phonecalls' => CRM_PhoneCallInstall::is_installed(), 'closed' => 1, 'activities_date' => 2));
     $form->setDefaults($old_display);
     $form->assign_theme('form', $this->theme);
     if ($form->validate()) {
         $this->display = $form->exportValues();
         foreach (array('events', 'tasks', 'phonecalls', 'closed', 'activities_date') as $v) {
             if (!isset($this->display[$v])) {
                 $this->display[$v] = false;
             }
         }
     } else {
         $this->display = $old_display;
     }
     $this->activities_date = isset($this->display['activities_date']) ? $this->display['activities_date'] : 0;
     $this->set_module_variable('display_options', $this->display);
 }
Exemplo n.º 4
0
 public static function submit_task($values, $mode)
 {
     $me = CRM_ContactsCommon::get_my_record();
     switch ($mode) {
         case 'display':
             $values['title'] = __('Follow-up') . ': ' . $values['title'];
             $values['status'] = 0;
             $values['deadline'] = date('Y-m-d', strtotime('+1 day'));
             $ret = array();
             $cus = reset($values['customers']);
             if (CRM_MeetingInstall::is_installed()) {
                 $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>';
             }
             $ret['new']['task'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Task')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('task', $values) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon-small.png') . '" /></a>';
             if (CRM_PhoneCallInstall::is_installed()) {
                 $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('task/' . $values['id']);
             return $ret;
         case 'adding':
             if (!isset($values['deadline'])) {
                 $values['deadline'] = strtotime(date('Y-m-d') . ' 23:59:59');
             }
             $values['permission'] = Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission');
             break;
         case 'editing':
             if (isset($values['timeless']) && $values['timeless']) {
                 // if it is timeless event then adjust time to show it properly
                 // in GUI - timestamp field translates time.
                 $values['deadline'] = Base_RegionalSettingsCommon::reg2time($values['deadline']);
             }
             break;
         case 'add':
         case 'edit':
             if (isset($values['timeless']) && $values['timeless']) {
                 // if we set timeless event then, set certain time to database
                 $values['deadline'] = Base_RegionalSettingsCommon::time2reg($values['deadline'], false, true, true, false) . ' 12:00:00';
             }
             break;
         case 'edited':
             $old_values = Utils_RecordBrowserCommon::get_record('task', $values['id']);
             $old_related = array_merge($old_values['employees'], $old_values['customers']);
         case 'added':
             if (isset($values['follow_up'])) {
                 CRM_FollowupCommon::add_tracing_notes($values['follow_up'][0], $values['follow_up'][1], $values['follow_up'][2], 'task', $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, 'task', $values['id']);
                 }
             }
             break;
     }
     return $values;
 }
Exemplo n.º 5
0
 public function requires($v)
 {
     return array(array('name' => Base_ThemeInstall::module_name(), 'version' => 0), array('name' => Base_LangInstall::module_name(), 'version' => 0), array('name' => Utils_WizardInstall::module_name(), 'version' => 0), array('name' => CRM_CalendarInstall::module_name(), 'version' => 0), array('name' => CRM_ContactsInstall::module_name(), 'version' => 0), array('name' => CRM_PhoneCallInstall::module_name(), 'version' => 0));
 }
Exemplo n.º 6
0
 public function companies_actions($r, $gb_row)
 {
     $me = CRM_ContactsCommon::get_my_record();
     $emp = array($me['id']);
     $cus = array();
     $cus[] = 'C:' . $r['id'];
     if (CRM_MeetingInstall::is_installed() && Utils_RecordBrowserCommon::get_access('crm_meeting', 'add')) {
         $gb_row->add_action(Utils_RecordBrowserCommon::create_new_record_href('crm_meeting', array('employees' => $emp, 'customers' => $cus, 'status' => 0, 'priority' => 1, 'permission' => 0)), __('New Meeting'), null, Base_ThemeCommon::get_template_file('CRM_Calendar', 'icon-small.png'));
     }
     if (CRM_TasksInstall::is_installed() && Utils_RecordBrowserCommon::get_access('task', 'add')) {
         $gb_row->add_action(Utils_RecordBrowserCommon::create_new_record_href('task', array('employees' => $emp, 'customers' => $cus, 'status' => 0, 'priority' => 1, 'permission' => 0)), __('New Task'), null, Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon-small.png'));
     }
     if (CRM_PhoneCallInstall::is_installed() && Utils_RecordBrowserCommon::get_access('phonecall', 'add')) {
         $gb_row->add_action(Utils_RecordBrowserCommon::create_new_record_href('phonecall', array('date_and_time' => date('Y-m-d H:i:s'), 'customer' => 'C:' . $r['id'], 'employees' => $me['id'], 'status' => 0, 'permission' => 0, 'priority' => 1), 'none', array('date_and_time')), __('New Phonecall'), null, Base_ThemeCommon::get_template_file('CRM_PhoneCall', 'icon-small.png'));
     }
     $gb_row->add_action(Utils_RecordBrowser::$rb_obj->add_note_button_href('company/' . $r['id']), __('New Note'), null, Base_ThemeCommon::get_template_file('Utils_Attachment', 'icon_small.png'));
 }
Exemplo n.º 7
0
 public static function submit_contact($values, $mode)
 {
     switch ($mode) {
         case 'cloning':
             $values['login'] = '';
             return $values;
         case 'display':
             // display copy company data button and do update if needed
             self::copy_company_data_subroutine($values);
             $is_employee = false;
             if (isset($values['related_companies']) && is_array($values['related_companies']) && in_array(CRM_ContactsCommon::get_main_company(), $values['related_companies'])) {
                 $is_employee = true;
             }
             if (isset($values['company_name']) && $values['company_name'] == CRM_ContactsCommon::get_main_company()) {
                 $is_employee = true;
             }
             $me = CRM_ContactsCommon::get_my_record();
             $emp = array($me['id']);
             $cus = array();
             if ($is_employee) {
                 $emp[] = $values['id'];
             } else {
                 $cus[] = 'P:' . $values['id'];
             }
             $ret = array();
             $ret['new'] = array();
             $ret['new']['crm_filter'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('Set CRM Filter')) . ' ' . Module::create_href(array('set_crm_filter' => 1)) . '>F</a>';
             if (isset($_REQUEST['set_crm_filter'])) {
                 CRM_FiltersCommon::set_profile('c' . $values['id']);
             }
             if (CRM_MeetingInstall::is_installed() && Utils_RecordBrowserCommon::get_access('crm_meeting', 'add')) {
                 $ret['new']['event'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Meeting')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('crm_meeting', array('employees' => $emp, 'customers' => $cus, 'status' => 0, 'priority' => 1, 'permission' => 0)) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Calendar', 'icon-small.png') . '"></a>';
             }
             if (CRM_TasksInstall::is_installed() && Utils_RecordBrowserCommon::get_access('task', 'add')) {
                 $ret['new']['task'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Task')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('task', array('employees' => $emp, 'customers' => $cus, 'status' => 0, 'priority' => 1, 'permission' => 0)) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon-small.png') . '"></a>';
             }
             if (CRM_PhoneCallInstall::is_installed() && Utils_RecordBrowserCommon::get_access('phonecall', 'add')) {
                 $ret['new']['phonecall'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Phonecall')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('phonecall', array('date_and_time' => date('Y-m-d H:i:s'), 'customer' => 'P:' . $values['id'], 'employees' => $me['id'], 'status' => 0, 'permission' => 0, 'priority' => 1), '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('contact/' . $values['id']);
             return $ret;
         case 'adding':
             $values['permission'] = Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission');
             break;
         case 'add':
             if (isset($values['email']) && $values['email'] == '' && $values['login'] != 0 && $mode == 'add') {
                 $values['email'] = DB::GetOne('SELECT mail FROM user_password WHERE user_login_id=%d', array($values['login']));
             }
         case 'edit':
             if (isset($values['create_company'])) {
                 $comp_id = Utils_RecordBrowserCommon::new_record('company', array('company_name' => $values['create_company_name'], 'address_1' => $values['address_1'], 'address_2' => $values['address_2'], 'country' => $values['country'], 'city' => $values['city'], 'zone' => isset($values['zone']) ? $values['zone'] : '', 'postal_code' => $values['postal_code'], 'phone' => $values['work_phone'], 'fax' => $values['fax'], 'web_address' => $values['web_address'], 'permission' => $values['permission']));
                 if (!isset($values['company_name'])) {
                     $values['company_name'] = null;
                 }
                 if (!isset($values['related_companies'])) {
                     $values['related_companies'] = array();
                 }
                 if (!is_array($values['related_companies'])) {
                     $values['related_companies'] = array($values['related_companies']);
                 }
                 if (!$values['company_name']) {
                     $values['company_name'] = $comp_id;
                 } else {
                     $values['related_companies'][] = $comp_id;
                 }
             }
             if (Base_AclCommon::i_am_admin()) {
                 if ($values['login'] == 'new') {
                     if (!$values['set_password']) {
                         $values['set_password'] = null;
                     }
                     Base_User_LoginCommon::add_user($values['username'], $values['email'], $values['set_password']);
                     $values['login'] = Base_UserCommon::get_user_id($values['username']);
                 } else {
                     if ($values['login']) {
                         Base_User_LoginCommon::change_user_preferences($values['login'], isset($values['email']) ? $values['email'] : '', isset($values['set_password']) ? $values['set_password'] : null);
                         if (isset($values['username']) && $values['username']) {
                             Base_UserCommon::rename_user($values['login'], $values['username']);
                         }
                     }
                 }
                 if (Base_AclCommon::i_am_sa() && $values['login'] && isset($values['admin']) && $values['admin'] !== '') {
                     $old_admin = Base_AclCommon::get_admin_level($values['login']);
                     if ($old_admin != $values['admin']) {
                         $admin_arr = array(0 => 'No', 1 => 'Administrator', 2 => 'Super Administrator');
                         if (Base_UserCommon::change_admin($values['login'], $values['admin']) !== true && isset($values['id']) && $values['id']) {
                             Utils_RecordBrowserCommon::new_record_history('contact', $values['id'], 'Admin set from "' . $admin_arr[$old_admin] . '" to "' . $admin_arr[$values['admin']]);
                         }
                     }
                 }
             }
             unset($values['admin']);
             unset($values['username']);
             unset($values['set_password']);
             unset($values['confirm_password']);
             break;
         case 'delete':
             if (isset($values['login']) && $values['login']) {
                 $ret = Base_UserCommon::change_active_state($values['login'], false);
                 if (!$ret) {
                     $values = false;
                 }
             }
             break;
     }
     return $values;
 }
Exemplo n.º 8
0
 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::module_name(), '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::module_name());
                 $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::module_name(), '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::module_name(), '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::module_name(), '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::module_name(), '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 (CRM_MeetingInstall::is_installed()) {
                 $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 (CRM_TasksInstall::is_installed()) {
                 $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 (CRM_PhoneCallInstall::is_installed()) {
                 $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;
 }