コード例 #1
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;
 }
コード例 #2
0
ファイル: update_phones.php プロジェクト: cretzu89/EPESI
 */
defined("_VALID_ACCESS") || die('Direct access forbidden');
$ret = '';
$values = $_POST['values'];
foreach ($values as $v) {
    if ($ret != '') {
        $ret = $v;
        break;
    }
    $ret = $v;
}
if ($ret === '') {
    print json_encode(array());
} else {
    list($r, $id) = explode(':', $ret);
    if ($r == 'P') {
        $contact = CRM_ContactsCommon::get_contact($id);
        $res = array();
        $i = 1;
        foreach (array('mobile_phone' => __('Mobile Phone'), 'work_phone' => __('Work Phone'), 'home_phone' => __('Home Phone')) as $id => $v) {
            if (isset($contact[$id]) && $contact[$id]) {
                $res[$i] = $v . ': ' . $contact[$id];
            }
            $i++;
        }
    } else {
        $company = CRM_ContactsCommon::get_company($id);
        $res = array(4 => __('Phone') . ': ' . $company['phone']);
    }
    print json_encode($res);
}
コード例 #3
0
ファイル: Event_0.php プロジェクト: 62BRAINS/EPESI
 public function make_event_PDF($pdf, $id, $no_details = false, $type = 'Event')
 {
     $custom_event = false;
     if (!is_array($id)) {
         $check = explode('#', $id);
         if (isset($check[1])) {
             $callback = DB::GetOne('SELECT handler_callback FROM crm_calendar_custom_events_handlers WHERE id=%d', $check[0]);
             $callback = explode('::', $callback);
             $ev = call_user_func($callback, 'get', $check[1]);
             $no_details = true;
             $custom_event = true;
         } else {
             trigger_error('Invalid event id: ' . $id, E_USER_ERROR);
         }
     } else {
         $ev = $id;
         $id = $ev['id'];
         $id = explode('_', $id);
         $id = $id[0];
         /*			$ev_details = DB::GetRow('SELECT *, starts AS start, ends AS end FROM crm_calendar_event WHERE id=%d', array($id));
         			foreach ($ev_details as $k=>$v)
         				if (!isset($ev[$k])) $ev[$k] = $v;*/
         $ev['title'] = strip_tags($ev['title']);
         $check = explode('#', $id);
         if (isset($check[1])) {
             $no_details = true;
             $custom_event = true;
         }
     }
     $pdf_theme = $this->pack_module('Base/Theme');
     $pdf_theme->assign('description', array('label' => __('Description'), 'value' => str_replace("\n", '<br/>', htmlspecialchars($ev['description']))));
     if (!$no_details) {
         $ev['status'] = Utils_CommonDataCommon::get_value('CRM/Status/' . $ev['status'], true);
         $ev['access'] = self::$access[$ev['access']];
         $ev['priority'] = self::$priority[$ev['priority']];
         foreach (array('access' => __('Access'), 'priority' => __('Priority'), 'status' => __('Status')) as $v => $label) {
             $pdf_theme->assign($v, array('label' => $label, 'value' => $ev[$v]));
         }
         $created_by = CRM_ContactsCommon::get_contact_by_user_id($ev['created_by']);
         if ($created_by !== null) {
             $created_by = $created_by['last_name'] . ' ' . $created_by['first_name'];
         } else {
             $created_by = Base_UserCommon::get_user_login($ev['created_by']);
         }
         $created_on = Base_RegionalSettingsCommon::time2reg($ev['created_on'], false);
         $pdf_theme->assign('created_on', array('label' => __('Created on'), 'value' => $created_on));
         $pdf_theme->assign('created_by', array('label' => __('Created by'), 'value' => $created_by));
         if ($ev['edited_by'] != null) {
             $edited_by = CRM_ContactsCommon::get_contact_by_user_id($ev['edited_by']);
             if ($edited_by !== null) {
                 $edited_by = $edited_by['last_name'] . ' ' . $edited_by['first_name'];
             } else {
                 $edited_by = Base_UserCommon::get_user_login($ev['edited_by']);
             }
             $edited_on = Base_RegionalSettingsCommon::time2reg($ev['edited_on'], false);
         } else {
             $edited_by = '--';
             $edited_on = '--';
         }
         $pdf_theme->assign('edited_on', array('label' => __('Edited on'), 'value' => $edited_on));
         $pdf_theme->assign('edited_by', array('label' => __('Edited by'), 'value' => $edited_by));
         $pdf_theme->assign('printed_on', array('label' => __('Printed on'), 'value' => Base_RegionalSettingsCommon::time2reg(time())));
     }
     $emps = array();
     $cuss = array();
     $cus_cmps = array();
     if (isset($ev['employees']) && !empty($ev['employees'])) {
         foreach ($ev['employees'] as $v) {
             $c = CRM_ContactsCommon::get_contact($v);
             $emps[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone']);
         }
     }
     if (isset($ev['customers']) && !empty($ev['customers'])) {
         foreach ($ev['customers'] as $v) {
             $det = explode(':', $v);
             if (isset($det[1])) {
                 $v = $det[1];
             } else {
                 $v = $det[0];
                 $det[0] = 'P';
             }
             if ($det[0] == 'P') {
                 $c = CRM_ContactsCommon::get_contact($v);
                 $company_name = isset($c['company_name']) && is_numeric($c['company_name']) ? array(Utils_RecordBrowserCommon::get_value('company', $c['company_name'], 'Company Name')) : '---';
                 $cuss[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone'], 'company_name' => $company_name);
             }
             if ($det[0] == 'C') {
                 $c = array('company_name' => array($v));
             }
             if (is_array($c['company_name'])) {
                 foreach ($c['company_name'] as $v2) {
                     if (!isset($cus_cmps[$v2])) {
                         $cus_cmps[$v2] = CRM_ContactsCommon::get_company($v2);
                     }
                 }
             }
         }
     }
     $pdf_theme->assign('employees', array('main_label' => __('Employees'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'lp_label' => __('Lp'), 'data' => $emps));
     $pdf_theme->assign('customers', array('main_label' => __('Customers'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'company_name' => __('Company Name'), 'lp_label' => __('Lp'), 'data' => $cuss));
     $pdf_theme->assign('customers_companies', array('main_label' => __('Customers Companies'), 'name_label' => __('Company Name'), 'phone_label' => __('Phone'), 'fax_label' => __('Fax'), 'address_label' => __('Address'), 'city_label' => __('City'), 'lp_label' => __('Lp'), 'data' => $cus_cmps));
     $pdf_theme->assign('title', array('label' => __('Title'), 'value' => $ev['title']));
     $start = Base_RegionalSettingsCommon::time2reg($ev['start'], false);
     $pdf_theme->assign('start_date', array('label' => __('Start Date'), 'value' => $start, 'details' => array('weekday' => __date('l', strtotime($start)))));
     if (!isset($ev['timeless'])) {
         $pdf_theme->assign('start_time', array('label' => __('Start Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['start'], true, false)));
         if (!isset($ev['end'])) {
             trigger_error(print_r($ev, true));
         }
         $pdf_theme->assign('end_time', array('label' => __('End Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], true, false)));
         $hours = floor(($ev['end'] - $ev['start']) / 3600);
         $format = __('%d hours', array($hours));
         $minutes = ($ev['end'] - $ev['start']) % 3600;
         if ($minutes != 0) {
             if ($hours == 0) {
                 $format = '';
             } else {
                 $format .= ', ';
             }
             $format .= __('%d minutes', array($minutes / 60));
         }
         $pdf_theme->assign('duration', array('label' => __('Duration'), 'value' => $format));
         if (date('Y-m-d', $ev['start']) != date('Y-m-d', $ev['end'])) {
             $pdf_theme->assign('end_date', array('label' => __('End Date'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], false)));
         }
     } else {
         $pdf_theme->assign('timeless', array('label' => __('Timeless'), 'value' => __('Yes')));
     }
     $pdf_theme->assign('type', $type);
     ob_start();
     $pdf_theme->display('pdf_version');
     $cont = ob_get_clean();
     $pdf->writeHTML($cont);
 }
コード例 #4
0
ファイル: ContactsCommon_0.php プロジェクト: 62BRAINS/EPESI
 private static function copy_company_data_subroutine($values)
 {
     $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values);
     if (!$access) {
         return;
     }
     /* First click should generate html code for leightbox and show it.
      * This function is rarely used and we don't want to increase page size.
      * To do this we use REQUEST variable UCD.
      *
      * We use module variable UCD to indicate that form was shown and we
      * must check if it was submitted. If yes - do action. If it wasn't
      * we should come back to initial state - do not print LB.
      */
     if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0))) {
         if (isset($values['company_name']) && $values['company_name']) {
             Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true)));
         }
     }
     if (isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0)) {
         $ucd = Module::static_get_module_variable('CRM/Contacts', 'UCD', 0);
         $ucd++;
         if ($ucd > 1) {
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
         } else {
             Module::static_set_module_variable('CRM/Contacts', 'UCD', $ucd);
         }
         $lid = 'UCDprompt';
         $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt');
         $form->construct();
         $sel_val = array();
         foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) {
             $sel_val[$id] = self::company_format_default(self::get_company($id), true);
         }
         $form->addElement('select', 'company', __('Select company:'), $sel_val);
         unset($sel_val);
         $form->addElement('html', __('Select which fields should be copied:'));
         $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false));
         foreach ($data as $row) {
             if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) {
                 $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array());
             }
         }
         $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $form->addGroup(array($ok, $cancel));
         if ($form->validate()) {
             $Uvalues = $form->exportValues();
             $fields = array();
             foreach ($data as $row) {
                 if (array_key_exists($row['sid'], $Uvalues)) {
                     $fields[$row['tid']] = $row['sid'];
                 }
             }
             if (isset($Uvalues['company'])) {
                 $company = CRM_ContactsCommon::get_company($Uvalues['company']);
                 $new_data = array();
                 foreach ($fields as $k => $v) {
                     $new_data[$k] = $company[$v];
                 }
                 Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data);
             }
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
             location(array());
         }
         // set default to main company
         if ($mc = self::get_main_company()) {
             $form->setDefaults(array('company' => $mc));
         }
         $html = $form->toHtml();
         Libs_LeightboxCommon::display($lid, $html);
         Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid));
         if (isset($_REQUEST['UCD'])) {
             eval_js('leightbox_activate(\'' . $lid . '\')');
         }
         unset($_REQUEST['UCD']);
     }
 }
コード例 #5
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;
	}
コード例 #6
0
ファイル: PhoneCallCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function get_alarm($id)
 {
     $a = Utils_RecordBrowserCommon::get_record('phonecall', $id);
     if (!$a) {
         return __('Private record');
     }
     $ret = __('Date: %s', array(Base_RegionalSettingsCommon::time2reg($a['date_and_time'], 2))) . "\n";
     if ($a['other_customer']) {
         $contact = $a['other_customer_name'];
     } else {
         list($r, $id) = explode(':', $a['customer']);
         if ($r == 'P') {
             $contact = CRM_ContactsCommon::contact_format_default($id, true);
         } else {
             $contact = CRM_ContactsCommon::get_company($id);
             $contact = $contact['company_name'];
         }
     }
     $ret .= __('Contact: %s', array($contact)) . "\n";
     $ret .= __('Phone: %s', array(self::display_phone($a, true, array('id' => 'phone')))) . "\n";
     return $ret . __('Subject: %s', array($a['subject']));
 }