コード例 #1
0
ファイル: TasksCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function employees_crits()
 {
     return array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
 }
コード例 #2
0
ファイル: Filters_0.php プロジェクト: 62BRAINS/EPESI
 public function body()
 {
     if (!Acl::is_user()) {
         return;
     }
     $th = $this->init_module('Base/Theme');
     eval_js_once('crm_filters_deactivate = function(){leightbox_deactivate(\'crm_filters\');}');
     $th->assign('my', '<a ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), 'my') . ' id="crm_filters_my">' . __('My records') . '</a>');
     eval_js('Event.observe(\'crm_filters_my\',\'click\', crm_filters_deactivate)');
     /*$th->assign('all','<a '.$this->create_callback_href(array('CRM_FiltersCommon','set_profile'),'all').' id="crm_filters_all">'.__('All records').'</a>');
     		eval_js('Event.observe(\'crm_filters_all\',\'click\', crm_filters_deactivate)');*/
     $th->assign('manage', '<a ' . $this->create_callback_href(array($this, 'manage_filters')) . ' id="crm_filters_manage">' . __('Manage presets') . '</a>');
     eval_js('Event.observe(\'crm_filters_manage\',\'click\', crm_filters_deactivate)');
     $ret = DB::Execute('SELECT id,name,description FROM crm_filters_group WHERE user_login_id=%d', array(Acl::get_user()));
     $filters = array();
     while ($row = $ret->FetchRow()) {
         $filters[] = array('title' => $row['name'], 'description' => '', 'open' => '<a ' . Utils_TooltipCommon::open_tag_attrs($row['description'], false) . ' ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), $row['id']) . ' id="crm_filters_' . $row['id'] . '">', 'close' => '</a>');
         eval_js('Event.observe(\'crm_filters_' . $row['id'] . '\',\'click\', crm_filters_deactivate)');
     }
     $th->assign('filters', $filters);
     $qf = $this->init_module('Libs/QuickForm');
     $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company');
     $recent_crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $recent_crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     if (Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')) {
         $recent_crits['!login'] = '';
     }
     $contacts = CRM_ContactsCommon::get_contacts($recent_crits, array(), array(), 15);
     $cont = array();
     foreach ($contacts as $v) {
         $cont[$v['id']] = call_user_func($fcallback, $v, true);
     }
     asort($cont);
     $crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     $qf->addElement('autoselect', 'crm_filter_contact', __('Records of'), $cont, array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback, false)), $fcallback);
     if (isset($_SESSION['client']['filter_' . Acl::get_user()]['value'])) {
         $qf->setDefaults(array('crm_filter_contact' => explode(',', $_SESSION['client']['filter_' . Acl::get_user()]['value'])));
     }
     $qf->addElement('submit', 'submit', __('Show'), array('onclick' => 'crm_filters_deactivate()'));
     if ($qf->validate()) {
         $c = $qf->exportValue('crm_filter_contact');
         CRM_FiltersCommon::set_profile('c' . $c);
         location(array());
     }
     $th->assign('saved_filters', __('Saved Presets'));
     $qf->assign_theme('contacts', $th);
     //$th->assign('contacts',$qf->toHtml());
     ob_start();
     $th->display();
     $profiles_out = ob_get_clean();
     Libs_LeightboxCommon::display('crm_filters', $profiles_out, __('Perspective'), true);
     if (!isset($_SESSION['client']['filter_' . Acl::get_user()]['desc'])) {
         CRM_FiltersCommon::set_profile('my');
     }
     //Base_ActionBarCommon::add('folder',__('Filters'),'class="lbOn" rel="crm_filters"',$this->get_module_variable('profile_desc',__('My records')));
     if (isset($_REQUEST['__location'])) {
         $in_use = CRM_FiltersCommon::$in_use === $_REQUEST['__location'];
     } else {
         $in_use = CRM_FiltersCommon::$in_use;
     }
     print '<a class="lbOn' . ($in_use ? '' : ' disabled') . ' button" rel="crm_filters">' . __('Perspective') . ': ' . '<b>' . $_SESSION['client']['filter_' . Acl::get_user()]['desc'] . '</b><div class="filter_icon_img"></div></a>';
 }
コード例 #3
0
ファイル: Employee.php プロジェクト: cretzu89/EPESI
 public static function employee_crits()
 {
     $my_company = CRM_ContactsCommon::get_main_company();
     return array('(company_name' => $my_company, '|related_companies' => array($my_company));
 }
コード例 #4
0
ファイル: EssClient_0.php プロジェクト: cretzu89/EPESI
 public function register_form($data = null)
 {
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $f = $this->init_module(Libs_QuickForm::module_name());
     $admin_email_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('This email will be used to send registation link and to contact Administator directly.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> ';
     $tax_id_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('Your company Tax ID for invoices.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> ';
     $f->addElement('text', 'company_name', __('Company Name'), array('maxlength' => 128));
     $f->addRule('company_name', __('Field required'), 'required');
     $f->addRule('company_name', __('Max length exceeded'), 'maxlength', 128);
     $f->addElement('text', 'short_name', __('Short Name'), array('maxlength' => 64));
     $f->addRule('short_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'phone', __('Phone'), array('maxlength' => 64));
     $f->addRule('phone', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'fax', __('Fax'), array('maxlength' => 64));
     $f->addRule('fax', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'email', __('Company email'), array('maxlength' => 128));
     $f->addRule('email', __('Max length exceeded'), 'maxlength', 128);
     $f->addRule('email', __('Invalid e-mail address'), 'email');
     $f->addElement('text', 'web_address', __('Web address'), array('maxlength' => 64));
     $f->addRule('web_address', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'address_1', __('Address 1'), array('maxlength' => 64));
     $f->addRule('address_1', __('Field required'), 'required');
     $f->addRule('address_1', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'address_2', __('Address 2'), array('maxlength' => 64));
     $f->addRule('address_2', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'city', __('City'), array('maxlength' => 64));
     $f->addRule('city', __('Field required'), 'required');
     $f->addRule('city', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('commondata', 'country', __('Country'), 'Countries');
     $f->addRule('country', __('Field required'), 'required');
     $f->addElement('commondata', 'zone', __('Zone'), array('Countries', 'country'), array('empty_option' => true));
     $f->addElement('text', 'postal_code', __('Postal Code'), array('maxlength' => 64));
     $f->addRule('postal_code', __('Field required'), 'required');
     $f->addRule('postal_code', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'tax_id', $tax_id_tooltip . __('Tax ID'), array('maxlength' => 64));
     $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_first_name', __('Administrator\'s first name'), array('maxlength' => 64));
     $f->addRule('admin_first_name', __('Field required'), 'required');
     $f->addRule('admin_first_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_last_name', __('Administrator\'s last name'), array('maxlength' => 64));
     $f->addRule('admin_last_name', __('Field required'), 'required');
     $f->addRule('admin_last_name', __('Max length exceeded'), 'maxlength', 64);
     $f->addElement('text', 'admin_email', $admin_email_tooltip . __('Administrator\'s email'), array('maxlength' => 128));
     $f->addRule('admin_email', __('Field required'), 'required');
     $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 128);
     $f->addRule('admin_email', __('Invalid e-mail address'), 'email');
     if ($f->validate()) {
         $ret = $f->exportValues();
         $ret = Base_EssClientCommon::server()->register_installation_request($ret);
         if ($ret) {
             if (is_string($ret)) {
                 Base_EssClientCommon::set_license_key($ret);
             }
             location(array());
             return false;
         }
     }
     // set defaults
     print '<div class="important_notice">';
     print __('Enter Company and Administrator details. This data will be sent to EPESI Store Server to provide us with contact information. The data sent to EPESI Store Server is limited only to the data you enter using this form and what modules are being purchased and downloaded.');
     print '<br>';
     if ($data) {
         $f->setDefaults($data);
     } else {
         if (ModuleManager::is_installed('CRM_Contacts') > -1) {
             print '<span style="color:gray;font-size:10px;">' . __('Data below was auto-filled based on Main Company and first Super administrator. Make sure that the data is correct and change it if necessary.') . '</span>';
             $defaults = Base_EssClientCommon::get_possible_admin();
             $mc = CRM_ContactsCommon::get_main_company();
             if ($mc > 0) {
                 $company = CRM_ContactsCommon::get_company($mc);
                 if ($company) {
                     $defaults = array_merge($company, $defaults);
                 }
             }
             $f->setDefaults($defaults);
         }
     }
     if ($data) {
         if (isset($data['status']) && strcasecmp($data['status'], 'Confirmed') == 0) {
             print '<div style="color:gray;font-size:10px;">' . __('Updating Company data will require re-validation by our representative.') . '</div>';
         }
         print '<div style="color:red;font-size:10px;">' . __('Changing Administrator e-mail address will require e-mail confirmation.') . '</div>';
     }
     print '<center>';
     $f->addElement('submit', 'submit', $data ? __('Update') : __('Register'));
     $f->display_as_column();
     print '</center>';
     print '</div>';
     return true;
 }
コード例 #5
0
ファイル: ContactsCommon_0.php プロジェクト: 62BRAINS/EPESI
 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 (ModuleManager::is_installed('CRM/Meeting') !== -1 && 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 (ModuleManager::is_installed('CRM/Tasks') !== -1 && 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 (ModuleManager::is_installed('CRM/PhoneCall') !== -1 && 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) {
                             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']);
     }
     return $values;
 }
コード例 #6
0
ファイル: AttachmentCommon_0.php プロジェクト: 62BRAINS/EPESI
	public static function get_google_auth($user=null, $pass=null, $service="writely") {
		if ($user===null) {
			$user = Variable::get('utils_attachments_google_user', false);
			$pass = Variable::get('utils_attachments_google_pass', false);
			if (!$user) return false;
		}
		$company = CRM_ContactsCommon::get_company(CRM_ContactsCommon::get_main_company());

		$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
		$clientlogin_post = array(
			"accountType" => "HOSTED_OR_GOOGLE",
			"Email" => $user,
			"Passwd" => $pass,
			"service" => $service,
			"source" => $company['company_name'].'-EPESI-'.'1.0'
		);

		$curl = curl_init($clientlogin_url);
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
		curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		$response = curl_exec($curl);
		curl_close($curl);

		preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
		$g_auth = @$matches[1];
		return $g_auth;
	}
コード例 #7
0
ファイル: Contacts_0.php プロジェクト: 62BRAINS/EPESI
 public function contacts_actions($r, $gb_row)
 {
     $is_employee = false;
     if (!isset($r['company_name'])) {
         return;
     }
     if (is_array($r['company_name']) && in_array(CRM_ContactsCommon::get_main_company(), $r['company_name'])) {
         $is_employee = true;
     }
     $me = CRM_ContactsCommon::get_my_record();
     $emp = array($me['id']);
     $cus = array();
     if ($is_employee) {
         $emp[] = $r['id'];
     } else {
         $cus[] = 'P:' . $r['id'];
     }
     if (ModuleManager::is_installed('CRM/Meeting') !== -1 && 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 (ModuleManager::is_installed('CRM/Tasks') !== -1 && 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 (ModuleManager::is_installed('CRM/PhoneCall') !== -1 && 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' => 'P:' . $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('contact/' . $r['id']), __('New Note'), null, Base_ThemeCommon::get_template_file('Utils_Attachment', 'icon_small.png'));
 }
コード例 #8
0
 public static function crits_accountmanager()
 {
     return array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
 }
コード例 #9
0
ファイル: PhoneCallCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function employees_crits()
 {
     // Select only main company contacts and only office staff employees
     return array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
 }