public function edit($row) { if($this->is_back()) $this->pop_box0(); $f = $this->init_module('Libs/QuickForm'); if($row) { $a = Base_RegionalSettingsCommon::time2reg($row['alert_on'],true,true,true,false); $f->setDefaults(array_merge($row,array('alert_date'=>$a,'alert_time'=>$a))); } else { $tt = $this->def_date; $tt = $tt-$tt%300; $f->setDefaults(array('alert_date'=>$tt,'alert_time'=>$tt)); } $f->addElement('textarea', 'message', __('Message')); $f->addElement('datepicker', 'alert_date', __('Alert date')); $lang_code = Base_LangCommon::get_lang_code(); $time_format = Base_RegionalSettingsCommon::time_12h()?'h:i a':'H:i'; $f->addElement('date', 'alert_time', __('Alert time'), array('format'=>$time_format, 'optionIncrement' => array('i' => 5), 'language'=>$lang_code)); if(is_array($this->users)) { foreach($this->users as $k=>$r) { if(!Base_User_SettingsCommon::get($this->get_type(),'allow_other',$k) && Acl::get_user()!=$k) unset($this->users[$k]); } $f->addElement('multiselect', 'users', __('Assigned users'), $this->users); $f->addRule('users', __('At least one user must be assigned to an alarm.'), 'required'); $f->setDefaults(array('users'=>array_keys($this->users))); } if($f->validate()) { $ret = $f->exportValues(); if($row) $ret = array_merge($row,$ret); if(Base_RegionalSettingsCommon::time_12h()) $ret['alert_on'] = strtotime($ret['alert_date'])+($ret['alert_time']['h']%12)*3600+(($ret['alert_time']['a']=='pm')?(3600*12):0)+$ret['alert_time']['i']*60; else $ret['alert_on'] = strtotime($ret['alert_date'])+$ret['alert_time']['H']*3600+$ret['alert_time']['i']*60; $ret['alert_on'] = Base_RegionalSettingsCommon::reg2time(date('Y-m-d H:i:s',$ret['alert_on'])); if($row) { DB::Execute('UPDATE utils_messenger_message SET message=%s,alert_on=%T WHERE page_id=\''.$this->mid.'\' AND id=%d',array($ret['message'],$ret['alert_on'],$row['id'])); $id = $row['id']; DB::Execute('DELETE FROM utils_messenger_users WHERE message_id=%d',array($id)); } else { DB::Execute('INSERT INTO utils_messenger_message(page_id,parent_module,message,callback_method,callback_args,created_on,created_by,alert_on) VALUES(%s,%s,%s,%s,%s,%T,%d,%T)',array($this->mid,$this->parent_type,$ret['message'],serialize($this->callback_method),serialize($this->callback_args),time(),Acl::get_user(),$ret['alert_on'])); $id = DB::Insert_ID('utils_messenger_message','id'); } if(is_array($this->users)) { foreach($ret['users'] as $r) DB::Execute('INSERT INTO utils_messenger_users(message_id,user_login_id) VALUES (%d,%d)',array($id,$r)); } else DB::Execute('INSERT INTO utils_messenger_users(message_id,user_login_id) VALUES (%d,%d)',array($id,$this->users)); $this->pop_box0(); } Base_ActionBarCommon::add('save',__('Save'),$f->get_submit_form_href()); Base_ActionBarCommon::add('back',__('Back'),$this->create_back_href()); $f->display_as_column(); }
public function install() { // Setting default AB icons and launchpad Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '465e51c2b6eba36161f0115442e7406c_d', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '465e51c2b6eba36161f0115442e7406c_l', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '4fe4700ae455ac705d9d5efa1292298b_d', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '4fe4700ae455ac705d9d5efa1292298b_l', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '5ee46bef4c047bd8816ac3810270cc73_d', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '5ee46bef4c047bd8816ac3810270cc73_l', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '7b3558122283d2a14051c96a7da1fb1b_d', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), '7b3558122283d2a14051c96a7da1fb1b_l', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), 'b34db58caa3e6a8b933deca655640047_d', '1'); Base_User_SettingsCommon::save_admin(Base_Menu_QuickAccessInstall::module_name(), 'b34db58caa3e6a8b933deca655640047_l', '1'); // default applets DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(1, 'Applets_Clock', 2, 0, 1, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(2, 'CRM_Tasks', 1, 0, 6, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(3, 'CRM_PhoneCall', 1, 1, 8, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(4, 'Applets_Note', 2, 0, 10, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(5, 'CRM_Calendar', 1, 2, 0, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(6, 'Apps_Shoutbox', 0, 1, 0, 1)); DB::Execute('INSERT INTO base_dashboard_default_applets (id, module_name, col, pos, color, tab) VALUES (%d, %s, %d, %d, %d, %d)', array(7, 'Utils_Watchdog', 0, 0, 6, 1)); //default note DB::Execute('INSERT INTO base_dashboard_default_settings (applet_id,name,value) VALUES (%d, %s, %s)', array(4, 'bcolor', 'nice-yellow')); DB::Execute('INSERT INTO base_dashboard_default_settings (applet_id,name,value) VALUES (%d, %s, %s)', array(4, 'text', '<div><strong>' . __('Congratulations!') . '</strong><br />' . __('You\'ve just installed EPESI!') . '</div><div>' . __('For more information, help and support please visit %sEPESI website %s', array('<a href="http://epe.si" target="_blank">', '</a></div>')))); DB::Execute('INSERT INTO base_dashboard_default_settings (applet_id,name,value) VALUES (%d, %s, %s)', array(4, 'title', __('Welcome'))); // default favorites and subscriptions Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'company_auto_fav', '1'); Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'company_auto_subs', '1'); Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'contact_auto_fav', '1'); Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'contact_auto_subs', '1'); Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'phonecall_auto_subs', '1'); Base_User_SettingsCommon::save_admin('Utils_RecordBrowser', 'task_auto_subs', '1'); return true; }
public static function new_pdf($orientation='P',$unit='mm',$format=null) { ini_set('memory_limit', '512M'); require_once(TCPDF_DIR.'tcpdf.php'); if ($format===null) $format = Base_User_SettingsCommon::get('Libs/TCPDF','page_format'); $tcpdf = new TCPDF($orientation, $unit, $format, true); $tcpdf->SetCreator(PDF_CREATOR); $tcpdf->SetAuthor("Powered by epesi"); $tcpdf->SetKeywords("PDF"); // set header and footer fonts $tcpdf->setHeaderFont(Array(self::$default_font, '', PDF_FONT_SIZE_MAIN)); $tcpdf->setFooterFont(Array(self::$default_font, '', PDF_FONT_SIZE_DATA)); //set margins $tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER); $tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO); return $tcpdf; }
public static function post_install_process($val) { Base_User_SettingsCommon::save_admin('Base_RegionalSettings', 'date', $val['date']); Base_User_SettingsCommon::save_admin('Base_RegionalSettings', 'time', $val['time']); Base_User_SettingsCommon::save_admin('Base_RegionalSettings', 'tz', $val['tz']); Base_User_SettingsCommon::save_admin('Base_RegionalSettings', 'default_country', $val['default_country']); Base_User_SettingsCommon::save_admin('Base_RegionalSettings', 'default_state', isset($val['default_state']) ? $val['default_state'] : ''); }
function HTML_QuickForm_currency($elementName = null, $elementLabel = null, $filterCurrencies = array(), $attributes = null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); $this->currency = Base_User_SettingsCommon::get('Utils_CurrencyField', 'default_currency'); $this->filterCurrencies = is_array($filterCurrencies) ? $filterCurrencies : array(); }
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); } }
public static function get_available_colors() { static $color = null; if ($color === null) { $color = array(0 => '', 1 => array('class' => 'black', 'label' => __('Black')), 2 => array('class' => 'blue', 'label' => __('Blue')), 3 => array('class' => 'dark-blue', 'label' => __('Dark blue')), 4 => array('class' => 'dark-gray', 'label' => __('Dark gray')), 5 => array('class' => 'green', 'label' => __('Green')), 6 => array('class' => 'dark-green', 'label' => __('Dark green')), 7 => array('class' => 'red', 'label' => __('Red')), 8 => array('class' => 'dark-red', 'label' => __('Dark red')), 9 => array('class' => 'yellow', 'label' => __('Yellow')), 10 => array('class' => 'dark-yellow', 'label' => __('Dark yellow'))); } $color[0] = $color[Base_User_SettingsCommon::get('Base_Dashboard', 'default_color')]; return $color; }
public function body($arg = null, $rb = null, $uid = null) { if (isset($arg) && isset($rb)) { $this->group = $rb->tab . '/' . $arg['id']; if (Utils_WatchdogCommon::get_category_id($rb->tab) !== null) { $this->watchdog_category = $rb->tab; $this->watchdog_id = $arg['id']; } $this->set_view_func(array('Utils_RecordBrowserCommon', 'create_default_linked_label'), array($rb->tab, $arg['id'])); } if (!isset($this->group) && !$uid) { trigger_error('Key not given to attachment module', E_USER_ERROR); } $_SESSION['client']['utils_attachment_group'] = $this->group; load_js('modules/Utils/Attachment/attachments.js'); Base_ThemeCommon::load_css('Utils_Attachment', 'browse'); $this->rb = $this->init_module(Utils_RecordBrowser::module_name(), 'utils_attachment', 'utils_attachment'); $defaults = array('permission' => Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission'), 'func' => serialize($this->func), 'args' => serialize($this->args)); $rb_cols = array(); $single_group = is_string($this->group) || count($this->group) == 1; if ($this->force_multiple) { $single_group = false; } if ($single_group) { $group = is_string($this->group) ? $this->group : reset($this->group); $defaults['local'] = $group; } else { // force attached to display $rb_cols['attached_to'] = true; $this->rb->set_button(false); } $this->rb->set_defaults($defaults); $this->rb->set_additional_actions_method(array($this, 'add_actions')); $this->rb->set_header_properties(array('sticky' => array('width' => 1, 'display' => false), 'attached_to' => array('width' => "16em"), 'edited_on' => array('width' => "12em"), 'title' => array('width' => "20em"))); if ($uid) { $this->rb->set_button(false); $this->rb->disable_actions(array('delete')); $this->display_module($this->rb, array(array(':Created_by' => $uid), $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } else { $crits = array(); if (!is_array($this->group)) { $this->group = array($this->group); } if (isset($_SESSION['attachment_copy']) && count($this->group) == 1 && $_SESSION['attachment_copy']['group'] != $this->group) { $this->rb->new_button(Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'link.png'), __('Paste'), Utils_TooltipCommon::open_tag_attrs($_SESSION['attachment_copy']['text']) . ' ' . $this->create_callback_href(array($this, 'paste'))); } if ($this->group) { $g = array_map(array('DB', 'qstr'), $this->group); $crits['id'] = DB::GetCol('SELECT attachment FROM utils_attachment_local WHERE local IN (' . implode(',', $g) . ')'); } else { $crits['id'] = 0; } $this->display_module($this->rb, array($crits, $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } }
public static function display_info($r, $nolink) { /* computer */ if ($r['category'] < 3) { /* structure: variable_name => display_label */ $k = array('host_name' => __('Host Name'), 'processor' => __('CPU'), 'ram' => __('RAM'), 'hdd' => __('HDD'), 'operating_system' => __('OS'), 'optical_devices' => __('DRIVES'), 'audio' => __('Audio'), 'software' => __('SOFT')); foreach ($k as $var => $label) { $pos = Base_User_SettingsCommon::get('CRM/Assets', $var . '_pos'); if ($r[$var] && Base_User_SettingsCommon::get('CRM/Assets', $var)) { $arr[$pos] = '[' . $label . '] ' . $r[$var]; } } /* laptop screen */ if ($r['category'] == 2) { $pos = Base_User_SettingsCommon::get('CRM/Assets', 'laptop_screen_pos'); if ($r['screen_size'] && Base_User_SettingsCommon::get('CRM/Assets', 'laptop_screen')) { $arr[$pos] = '[' . __('Screen') . '] ' . $r['screen_size']; } } } /* monitor */ if ($r['category'] == 3) { if (Base_User_SettingsCommon::get('CRM/Assets', 'display_type')) { $type = Utils_CommonDataCommon::get_translated_array('crm_assets_monitor_type'); $pos = Base_User_SettingsCommon::get('CRM/Assets', 'display_type_pos'); $arr[$pos] = '[' . __('Display Type') . '] ' . ($r['display_type'] != null ? $type[$r['display_type']] : __('Undefined')); } $pos = Base_User_SettingsCommon::get('CRM/Assets', 'screen_size_pos'); if ($r['screen_size'] && Base_User_SettingsCommon::get('CRM/Assets', 'screen_size')) { $arr[$pos] = '[' . __('Screen Size') . '] ' . $r['screen_size']; } } /* printer */ if ($r['category'] == 4) { if (Base_User_SettingsCommon::get('CRM/Assets', 'printer_type')) { $type = Utils_CommonDataCommon::get_translated_array('crm_assets_printer_type'); $pos = Base_User_SettingsCommon::get('CRM/Assets', 'printer_type_pos'); $arr[$pos] = '[' . __('Printer Type') . '] ' . ($r['printer_type'] != null ? $type[$r['printer_type']] : __('Undefined')); } if (Base_User_SettingsCommon::get('CRM/Assets', 'color_printing')) { $color = $r['color_printing'] ? __('Yes') : __('No'); $pos = Base_User_SettingsCommon::get('CRM/Assets', 'color_printing_pos'); $arr[$pos] = '[' . __('Color Printing') . '] ' . $color; } } if ($r['category'] <= 4) { if (isset($arr)) { ksort($arr); } return isset($arr) ? implode(' ', $arr) : __('No info'); } return __('This is non-categorized asset.'); }
public static function get_dial_code($title) { $method = Base_User_SettingsCommon::get('CRM_Common', 'method'); switch ($method) { case 'none': return $title; case 'callto': return '<a href="callto:' . $title . '">' . $title . '</a>'; default: $dialer = array($method . 'Common', 'dialer'); if (is_callable($dialer)) { return call_user_func($dialer, $title); } return $title; } }
public static function quick_access_menu() { if (!Base_AclCommon::i_am_user()) { return array(); } self::get_options(); $qa_menu = array('__submenu__' => 1); foreach (self::$options as $v) { if (Base_User_SettingsCommon::get('Base_Menu_QuickAccess', $v['name'] . '_m')) { $qa_menu[$v['label']] = $v['link']; } } if ($qa_menu == array('__submenu__' => 1)) { return array(); } return array(__('Quick Access') => $qa_menu); }
public static function user_search($search = null) { $myid = Base_AclCommon::get_user(); if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) { $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im'); if (ModuleManager::is_installed('CRM_Contacts') >= 0) { $emps = DB::GetAssoc('SELECT l.id,' . DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name'), 'l.login') . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND (cd.f_first_name ' . DB::like() . ' ' . DB::concat(DB::qstr("%%"), "%s", DB::qstr("%%")) . ' OR cd.f_last_name ' . DB::like() . ' ' . DB::concat(DB::qstr("%%"), "%s", DB::qstr("%%")) . ') ORDER BY name', array($myid, serialize(1), $search, $search)); } else { $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.login ' . DB::like() . ' ' . DB::concat(DB::qstr("%%"), "%s", DB::qstr("%%")) . ' ORDER BY l.login', array($myid, serialize(1), $search)); } } else { $emps = array(); } if (ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) { $online = Tools_WhoIsOnlineCommon::get_ids(); foreach ($online as $id) { if (isset($emps[$id])) { $emps[$id] = '* ' . $emps[$id]; } } } return $emps; }
public static function new_record($tab, $values = array()) { self::init($tab); $user = Acl::get_user(); $for_processing = $values; foreach (self::$table_rows as $field => $args) { if ($args['type'] === 'multiselect') { if (!isset($for_processing[$args['id']]) || !$for_processing[$args['id']]) { $for_processing[$args['id']] = array(); } } elseif (!isset($for_processing[$args['id']])) { $for_processing[$args['id']] = ''; } } $values = self::record_processing($tab, $for_processing, 'add'); if ($values === false) { return; } self::init($tab); $fields = 'created_on,created_by,active'; $fields_types = '%T,%d,%d'; $vals = array(date('Y-m-d H:i:s'), $user, 1); foreach (self::$table_rows as $field => $args) { if ($args['type'] == 'calculated' && preg_match('/^[a-z]+(\\([0-9]+\\))?$/i', $args['param']) === 0) { continue; } // FIXME move DB definiton to *_field table if (!isset($values[$args['id']]) || $values[$args['id']] === '') { continue; } if (!is_array($values[$args['id']])) { $values[$args['id']] = trim($values[$args['id']]); } if ($args['type'] == 'long text') { $values[$args['id']] = Utils_BBCodeCommon::optimize($values[$args['id']]); } if ($args['type'] == 'multiselect' && empty($values[$args['id']])) { continue; } if ($args['type'] == 'multiselect') { $values[$args['id']] = self::encode_multi($values[$args['id']]); } $fields_types .= ',' . self::get_sql_type($args['type']); $fields .= ',f_' . $args['id']; if (is_bool($values[$args['id']])) { $values[$args['id']] = $values[$args['id']] ? 1 : 0; } $vals[] = $values[$args['id']]; } DB::Execute('INSERT INTO ' . $tab . '_data_1 (' . $fields . ') VALUES (' . $fields_types . ')', $vals); $id = DB::Insert_ID($tab . '_data_1', 'id'); if ($user) { self::add_recent_entry($tab, $user, $id); } if (Base_User_SettingsCommon::get('Utils_RecordBrowser', $tab . '_auto_fav')) { DB::Execute('INSERT INTO ' . $tab . '_favorite (user_id, ' . $tab . '_id) VALUES (%d, %d)', array($user, $id)); } self::init($tab); foreach (self::$table_rows as $field => $args) { if ($args['type'] === 'multiselect') { if (!isset($values[$args['id']])) { $values[$args['id']] = array(); } elseif (!is_array($values[$args['id']])) { $values[$args['id']] = self::decode_multi($values[$args['id']]); } } if ($args['type'] === 'autonumber') { $autonumber_value = self::format_autonumber_str($args['param'], $id); self::update_record($tab, $id, array($args['id'] => $autonumber_value), false, null, true); $values[$args['id']] = $autonumber_value; } } $values['id'] = $id; self::record_processing($tab, $values, 'added'); if (Base_User_SettingsCommon::get('Utils_RecordBrowser', $tab . '_auto_subs') == 1) { Utils_WatchdogCommon::subscribe($tab, $id); } Utils_WatchdogCommon::new_event($tab, $id, 'C'); return $id; }
$def = array('default' => __('default server time (%s minutes)', array($time / 60))); if ($time < 1800) { $def['1800'] = __('30 minutes'); } if ($time < 3600) { $def['3600'] = __('1 hour'); } if ($time < 7200) { $def['7200'] = __('2 hours'); } if ($time < 14400) { $def['14400'] = __('4 hours'); } if ($time < 28800) { $def['28800'] = __('8 hours'); } return array(__('Misc') => array(array('name' => 'time', 'label' => __('Keep session at least'), 'type' => 'select', 'values' => $def, 'default' => 28800, 'reload' => true))); } } load_js('modules/Tools/SessionKeeper/sk.js'); $sys_time = ini_get("session.gc_maxlifetime"); $interval = $sys_time / 3; if (Acl::is_user()) { $time = Base_User_SettingsCommon::get('Tools/SessionKeeper', 'time'); if ($time == 'default') { $time = $sys_time; } eval_js_once('SessionKeeper.maxtime=' . $time . ';' . 'SessionKeeper.interval=' . $interval . ';' . 'SessionKeeper.load()'); } else { eval_js_once('SessionKeeper.maxtime=201600;' . 'SessionKeeper.interval=' . $interval . ';' . 'SessionKeeper.load()'); }
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; }
public function format_cell($format, $val, $type = 'none') { if (!is_array($format)) { $format = array($format => ''); } else { $format = array_flip($format); } $ret = array(); if (!is_array($val)) { $val = array($val); } if (isset($format['currency']) || isset($format['numeric']) || isset($format['percent'])) { $format['fade_out_zero'] = 1; } if (isset($format['currency']) && empty($val)) { $val = array(Base_User_SettingsCommon::get('Utils_CurrencyField', 'default_currency') => 0); } $css_class = ''; $style = ''; $attrs = ''; foreach ($val as $k => $v) { $next = $v; if ((double) $v == 0 && strlen($v) > 0 && $v != (string) (double) $v) { unset($format['fade_out_zero']); } else { if (isset($format['currency'])) { $v = strip_tags($v); $next = Utils_CurrencyFieldCommon::format($v, $k); } if (isset($format['currency']) || isset($format['numeric'])) { if ((double) $v != 0) { unset($format['fade_out_zero']); } } } if (isset($format['percent'])) { if ($type == 'row_total' || $type == 'total_all') { $cols = count($this->gb_captions) - 2; if (!empty($this->categories)) { $cols--; } if (!$v) { $v = '--'; } } if ($type == 'col_total' || $type == 'total_all') { $rows = count($this->ref_records); if (!$v) { $v = '--'; } } if (is_numeric($v)) { $v = number_format($v, 2); } $next = $v . ' %'; if ($v != 0) { unset($format['fade_out_zero']); } } $ret[] = $next; } if (isset($format['currency'])) { foreach ($ret as $k => $v) { if (count($ret) == 1) { break; } $value = Utils_CurrencyFieldCommon::parse_currency($v); if ($value[0] == 0) { unset($ret[$k]); } } } if (isset($format['currency']) || isset($format['numeric']) || isset($format['percent'])) { $css_class .= ' number'; if (isset($format['fade_out_zero'])) { $css_class .= ' fade-out-zero'; } } if ($this->first) { $css_class .= ' top-row'; } if (isset($format['total-row_desc'])) { $css_class .= ' total-row_desc'; } if (isset($format['row_desc'])) { $css_class .= ' row-desc'; } if (isset($format['total_all'])) { $css_class .= ' total-all'; } elseif (isset($format['total'])) { $css_class .= ' total'; } $ret = implode('<br>', $ret); if ($this->pdf) { $ret = array('value' => $ret, 'style' => $format, 'attrs' => '', 'class' => ''); } else { $ret = array('value' => $ret, 'style' => $style, 'attrs' => $attrs, 'class' => $css_class); } return $ret; }
public static function get_lang_code() { if (defined('FORCE_LANG_CODE')) { return FORCE_LANG_CODE; } if (!isset(self::$lang_code)) { if (!Base_AclCommon::is_user() || Base_User_SettingsInstall::is_installed() == false || !Variable::get('allow_lang_change', false)) { return Variable::get('default_lang'); } if (class_exists('Base_User_SettingsCommon')) { self::$lang_code = Base_User_SettingsCommon::get('Base_Lang_Administrator', 'language'); } } return self::$lang_code; }
public function enable_quick_new_records($button = true, $force_show = null) { $this->add_in_table = true; $href = 'href="javascript:void(0);" onclick="$(\'add_in_table_row\').style.display=($(\'add_in_table_row\').style.display==\'none\'?\'\':\'none\');if(focus_on_field)if($(focus_on_field))focus_by_id(focus_on_field);"'; if ($button) $this->add_button = $href; if ($force_show===null) $this->show_add_in_table = Base_User_SettingsCommon::get('Utils_RecordBrowser','add_in_table_shown'); else $this->show_add_in_table = $force_show; if ($this->get_module_variable('force_add_in_table_after_submit', false)) { $this->show_add_in_table = true; $this->set_module_variable('force_add_in_table_after_submit', false); } return $href; }
public static function get_payment_credentials() { $keys = self::get_payment_data_keys(); $ret = array(); foreach ($keys as $k) { $ret[$k] = Base_User_SettingsCommon::get('Base_EpesiStore', $k); } return $ret; }
public static function QFfield_note(&$form, $field, $label, $mode, $default, $desc, $rb_obj) { load_js('modules/Utils/Attachment/attachments.js'); if($rb_obj->record['crypted']) { if(!(isset($rb_obj->record['id']) && isset($_SESSION['client']['cp'.$rb_obj->record['id']])) && !(isset($rb_obj->record['clone_id']) && isset($_SESSION['client']['cp'.$rb_obj->record['clone_id']]))) { /*Epesi::alert(__('Note encrypted.')); $x = ModuleManager::get_instance('/Base_Box|0'); if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR); return $x->pop_main();*/ $form->addElement('static', $field, $label); $txt = '<div id="note_value_'.$rb_obj->record['id'].'"><a href="javascript:void(0);" onclick="utils_attachment_password(\''.Epesi::escapeJS(__('Password').':').'\',\''.Epesi::escapeJS(__('OK')).'\','.$rb_obj->record['id'].',1)" style="color:red">'.__('Note encrypted').'</a></div>'; $form->setDefaults(array($field=>$txt)); return; } else { if(isset($rb_obj->record['id']) && isset($_SESSION['client']['cp'.$rb_obj->record['id']])) $note_pass = $_SESSION['client']['cp'.$rb_obj->record['id']]; else $note_pass = $_SESSION['client']['cp'.$rb_obj->record['clone_id']]; $decoded = Utils_AttachmentCommon::decrypt($default,$note_pass); if($decoded!==false) $default = $decoded; else { Epesi::alert(__('Note encrypted.')); $x = ModuleManager::get_instance('/Base_Box|0'); if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR); return $x->pop_main(); } } } if ($mode=='add' || $mode=='edit') { $fck = $form->addElement('ckeditor', $field, $label); $fck->setFCKProps('99%','300',Base_User_SettingsCommon::get(self::Instance()->get_type(),'editor')); load_js('modules/Utils/Attachment/js/lib/plupload.js'); load_js('modules/Utils/Attachment/js/lib/plupload.flash.js'); load_js('modules/Utils/Attachment/js/lib/plupload.browserplus.js'); load_js('modules/Utils/Attachment/js/lib/plupload.html4.js'); load_js('modules/Utils/Attachment/js/lib/plupload.html5.js'); if (!isset($_SESSION['client']['utils_attachment'][CID])) $_SESSION['client']['utils_attachment'][CID] = array('files'=>array()); eval_js('Utils_Attachment__init_uploader("'.floor(self::max_upload_size()/1024/1024).'mb")'); // eval_js('alert("'.self::max_upload_size().'")'); eval_js_once('var Utils_Attachment__delete_button = "'.Base_ThemeCommon::get_template_file('Utils_Attachment', 'delete.png').'";'); eval_js_once('var Utils_Attachment__restore_button = "'.Base_ThemeCommon::get_template_file('Utils_Attachment', 'restore.png').'";'); eval_js('Utils_Attachment__submit_note = function() {'.$form->get_submit_form_js().'}'); $del = $form->addElement('hidden', 'delete_files', null, array('id'=>'delete_files')); $add = $form->addElement('hidden', 'clipboard_files', null, array('id'=>'clipboard_files')); Libs_QuickFormCommon::add_on_submit_action('if(uploader.files.length){uploader.start();return;}'); if(isset($rb_obj->record['id'])) $files = DB::GetAssoc('SELECT id, original FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['id'])); elseif(isset($rb_obj->record['clone_id'])) $files = DB::GetAssoc('SELECT id, original FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['clone_id'])); else $files = array(); foreach($files as $id=>$name) { eval_js('Utils_Attachment__add_file_to_list("'.Epesi::escapeJS($name,true,false).'", null, '.$id.');'); } $form->setDefaults(array($field=>$default)); } else { $form->addElement('static', $field, $label); $form->setDefaults(array($field=>self::display_note($rb_obj->record,false,null,true))); if(class_exists('ZipArchive')) { $files = DB::GetOne('SELECT 1 FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['id'])); if($files) Base_ActionBarCommon::add('download','Download all attachments','href="'.self::Instance()->get_module_dir().'get_all.php?id='.$rb_obj->record['id'].'&cid='.CID.'" target="_blank"'); } } }
public function chat($big = false, $uid = null) { $to =& $this->get_module_variable('to', "all"); eval_js('shoutbox_uid="' . $to . '"'); if (Base_AclCommon::is_user()) { //initialize HTML_QuickForm $qf = $this->init_module(Libs_QuickForm::module_name()); /* $myid = Base_AclCommon::get_user(); if(Base_User_SettingsCommon::get('Apps_Shoutbox','enable_im')) { $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox','enable_im'); if(ModuleManager::is_installed('CRM_Contacts')>=0) { $emps = DB::GetAssoc('SELECT l.id,IF(cd.f_last_name!=\'\',CONCAT(cd.f_last_name,\' \',cd.f_first_name,\' (\',l.login,\')\'),l.login) as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY name',array($myid,serialize(1))); } else $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY l.login',array($myid,serialize(1))); } else $emps = array(); if(ModuleManager::is_installed('Tools_WhoIsOnline')>=0) { $online = Tools_WhoIsOnlineCommon::get_ids(); foreach($online as $id) { if(isset($emps[$id])) $emps[$id] = '* '.$emps[$id] ; } } $qf->addElement('select','to',__('To'),array('all'=>'['.__('All').']')+$emps,array('id'=>'shoutbox_to'.($big?'_big':''),'onChange'=>'shoutbox_uid=this.value;shoutbox_refresh'.($big?'_big':'').'()'));*/ $myid = Base_AclCommon::get_user(); if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im') && ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) { $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im'); $online = Tools_WhoIsOnlineCommon::get_ids(); if ($online) { if (ModuleManager::is_installed('CRM_Contacts') >= 0) { $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name', DB::qstr(' ('), 'l.login', DB::qstr(')')), 'l.login')) . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY name', array($myid, serialize(1))); } else { $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), 'l.login') . ' FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY l.login', array($myid, serialize(1))); } } else { $emps = array(); } } else { $emps = array(); } $e = $qf->addElement('autoselect', 'shoutbox_to', __('To'), array('all' => '[' . __('All') . ']') + $emps, array(array($this->get_type() . 'Common', 'user_search'), array()), array($this->get_type() . 'Common', 'user_format')); $e->setAttribute('id', 'shoutbox_to' . ($big ? '_big' : '')); $e->setAttribute('onChange', 'shoutbox_uid=this.value;shoutbox_refresh' . ($big ? '_big' : '') . '()'); if (!Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) { $qf->freeze(array('shoutbox_to')); } //create text box $qf->addElement($big ? 'textarea' : 'textarea', 'post', __('Message'), 'class="border_radius_6px" id="shoutbox_text' . ($big ? '_big' : '') . '"'); $qf->addRule('post', __('Field required'), 'required'); //create submit button $qf->addElement('submit', 'submit_button', __('Send'), 'id="shoutbox_button' . ($big ? '_big' : '') . '"'); //add it $qf->setRequiredNote(null); $qf->setDefaults(array('shoutbox_to' => $to)); $theme = $this->init_module(Base_Theme::module_name()); $qf->assign_theme('form', $theme); //confirm when sending messages to all eval_js("jq('#shoutbox_button, #shoutbox_button_big').click(function() {\n \t\t\t\t\tvar submit = true;\n\t\t \t\t\tif (jq('#shoutbox_to').val() == 'all' && !confirm('" . __('Send message to all?') . "')) {\n \t\t\t\t\tsubmit = false;\n \t\t\t\t\t}\n\t\t \n\t\t \t\t\treturn submit;\t\t \t\t\t\n\t\t\t\t\t});"); //if submited if ($qf->validate()) { //get post group $msg = $qf->exportValue('post'); $to = $qf->exportValue('shoutbox_to'); //get msg from post group $msg = Utils_BBCodeCommon::optimize($msg); //get logged user id $user_id = Base_AclCommon::get_user(); //clear text box and focus it eval_js('$(\'shoutbox_text' . ($big ? '_big' : '') . '\').value=\'\';focus_by_id(\'shoutbox_text' . ($big ? '_big' : '') . '\');shoutbox_uid="' . $to . '"'); //insert to db DB::Execute('INSERT INTO apps_shoutbox_messages(message,base_user_login_id,to_user_login_id) VALUES(%s,%d,%d)', array(htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'), $user_id, is_numeric($to) ? $to : null)); } } else { print __('Please log in to post message') . '<br>'; return; } $theme->assign('board', '<div id=\'shoutbox_board' . ($big ? '_big' : '') . '\'></div>'); $theme->assign('header', __('Shoutbox')); $theme->display('chat_form' . ($big ? '_big' : '')); //if shoutbox is diplayed, call myFunctions->refresh from refresh.php file every 5s eval_js_once('shoutbox_refresh' . ($big ? '_big' : '') . ' = function(){if(!$(\'shoutbox_board' . ($big ? '_big' : '') . '\')) return;' . 'new Ajax.Updater(\'shoutbox_board' . ($big ? '_big' : '') . '\',\'modules/Apps/Shoutbox/refresh.php\',{method:\'get\', parameters: { uid: shoutbox_uid }});' . '};setInterval(\'shoutbox_refresh' . ($big ? '_big' : '') . '()\',' . ($big ? '10000' : '30000') . ')'); eval_js('shoutbox_refresh' . ($big ? '_big' : '') . '()'); }
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 (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>'; } $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 (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('task/' . $values['id']); return $ret; case 'adding': $values['deadline_time'] = strtotime(date('Y-m-d') . ' 23:59:59'); $values['permission'] = Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission'); break; case 'add': break; case 'edit': $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; }
public static function mobile_companies() { $info = array('phone' => 1); $sort = array('company_name' => 'ASC'); $defaults = array('country' => Base_User_SettingsCommon::get('Base_RegionalSettings', 'default_country'), 'zone' => Base_User_SettingsCommon::get('Base_RegionalSettings', 'default_state'), 'permission' => '0'); Utils_RecordBrowserCommon::mobile_rb('company', array(), $sort, $info, $defaults); }
public static function send_email_notifications($event_id) { $event = DB::GetRow('SELECT * FROM utils_watchdog_event WHERE id=%d', array($event_id)); if (!$event) { return; } $category_id = $event['category_id']; $id = $event['internal_id']; $message = $event['message']; $subscribers = self::get_subscribers($category_id, $id); $c_user = Acl::get_user(); self::email_mode(true); foreach ($subscribers as $user_id) { $wants_email = Base_User_SettingsCommon::get('Utils_Watchdog', 'email', $user_id); if (!$wants_email) { continue; } Acl::set_user($user_id); Base_LangCommon::load(); $email_data = self::display_events($category_id, array($event_id => $message), $id, true); if (!$email_data) { continue; } $contact = Utils_RecordBrowserCommon::get_id('contact', 'login', $user_id); if (!$contact) { continue; } $email = Utils_RecordBrowserCommon::get_value('contact', $contact, 'email'); if (!$email) { continue; } $title = __('%s notification - %s - %s', array(EPESI, $email_data['category'], strip_tags($email_data['title']))); Base_MailCommon::send($email, $title, $email_data['events'], null, null, true); } Acl::set_user($c_user); Base_LangCommon::load(); self::email_mode(false); }
private static function show_help() { if(!isset(self::$help_tooltips)) self::$help_tooltips = Base_User_SettingsCommon::get('Utils/Tooltip','help_tooltips'); }
private function add_elem_to_form(array &$v, array &$defaults, $module, $admin_settings) { $old_name = $v['name']; $v['name'] = $module . self::$sep . $v['name']; $this->settings_fields[] = $v['name']; if (isset($v['rule'])) { if (isset($v['rule']['message']) && isset($v['rule']['type'])) { $v['rule'] = array($v['rule']); } } if ($admin_settings) { $value = Base_User_SettingsCommon::get_admin($module, $old_name); } else { $value = Base_User_SettingsCommon::get($module, $old_name); } $defaults = array_merge($defaults, array($v['name'] => $value)); }
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(); }
/** * Displays action bar. */ public function body() { $this->help('ActionBar basics', 'main'); $icons = Base_ActionBarCommon::get(); //sort usort($icons, array($this, 'compare')); //translate foreach ($icons as &$i) { $description = $i['description']; if ($i['description']) { $t = Utils_TooltipCommon::open_tag_attrs($description); } else { $t = ''; } $i['open'] = '<a ' . $i['action'] . ' ' . $t . '>'; $i['close'] = '</a>'; $i['helpID'] = 'ActionBar_' . $i['icon']; if (strpos($i['icon'], '/') !== false && file_exists($i['icon'])) { $i['icon_url'] = $i['icon']; unset($i['icon']); } //if (isset(Base_ActionBarCommon::$available_icons[$i['icon']])) // $i['icon'] = Base_ThemeCommon::get_template_file('Base_ActionBar','icons/'.$i['icon'].'.png'); } $launcher = array(); if (Base_AclCommon::is_user()) { $opts = Base_Menu_QuickAccessCommon::get_options(); if (!empty($opts)) { self::$launchpad = array(); foreach ($opts as $k => $v) { if (Base_ActionBarCommon::$quick_access_shortcuts && Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')) { $ii = array(); $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1)); $ii['label'] = $trimmed_label ? $trimmed_label : $v['label']; $ii['description'] = $v['label']; $arr = $v['link']; if (isset($arr['__url__'])) { $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank">'; } else { $ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . '>'; } $ii['close'] = '</a>'; if (isset($v['link']['__icon__'])) { $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']); } else { $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png'); } if (!$icon) { $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png'); } $ii['icon'] = $icon; $launcher[] = $ii; } if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) { $ii = array(); $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1)); $ii['label'] = $trimmed_label ? $trimmed_label : $v['label']; $ii['description'] = $v['label']; $arr = $v['link']; if (isset($arr['__url__'])) { $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" onClick="actionbar_launchpad_deactivate()">'; } else { $ii['open'] = '<a onClick="actionbar_launchpad_deactivate();' . Base_MenuCommon::create_href_js($this, $arr) . '" href="javascript:void(0)">'; } $ii['close'] = '</a>'; if (isset($v['link']['__icon__'])) { $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']); } else { $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png'); } if (!$icon) { $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png'); } $ii['icon'] = $icon; self::$launchpad[] = $ii; } } } } //display $th = $this->pack_module(Base_Theme::module_name()); $th->assign('icons', $icons); $th->assign('launcher', array_reverse($launcher)); $th->display(); }
public function get_tray_layout() { $tray_layout = Base_User_SettingsCommon::get('Utils/Tray','tray_layout'); if (!isset(Utils_TrayCommon::$tray_layout[$tray_layout])) { $tray_layout = 'checkered'; Base_User_SettingsCommon::save('Utils/Tray','tray_layout', 'checkered'); } return $tray_layout; }
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); } } }