Exemplo n.º 1
0
 public function send($file)
 {
     if ($this->is_back()) {
         return $this->go_back($file);
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'send_fax');
     list($providers, $providers_arr) = self::get_providers($file);
     if (empty($providers)) {
         $this->go_back($file);
         Epesi::alert(__('No fax providers installed or configured for this type of file.'));
         return;
     }
     $qf->addElement('header', null, __('Faxing file: %s', array(basename($file))));
     $qf->addElement('select', 'provider', __('Provider'), $providers);
     $qf->addElement('header', null, __('Contact'));
     $fav_contact = CRM_ContactsCommon::get_contacts(array(':Fav' => true, '!fax' => ''));
     $fav_contact2 = array();
     foreach ($fav_contact as $v) {
         $fav_contact2[$v['id']] = CRM_ContactsCommon::contact_format_default($v, true);
     }
     $rb_contact = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_contact, array('contact', 'dest_contact', array('CRM_FaxCommon', 'rpicker_contact_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_contact', '', $fav_contact2);
     $qf->addElement('static', null, $rb_contact->create_open_link('Add contact'));
     $qf->addElement('header', null, __('Company'));
     $fav_company = CRM_ContactsCommon::get_companies(array(':Fav' => true, '!fax' => ''), array('id', 'company_name'));
     $fav_company2 = array();
     foreach ($fav_company as $v) {
         $fav_company2[$v['id']] = $v['company_name'];
     }
     $rb_company = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_company, array('company', 'dest_company', array('CRM_FaxCommon', 'rpicker_company_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_company', '', $fav_company2);
     $qf->addElement('static', null, $rb_company->create_open_link('Add company'));
     $qf->addElement('header', null, __('Other'));
     $qf->addElement('text', 'dest_other', __('Other fax numbers (comma separated)'));
     $qf->addFormRule(array($this, 'check_numbers'));
     if ($qf->validate()) {
         $data = $qf->exportValues();
         if (!isset($providers_arr[$data['provider']]['send_func'])) {
             Epesi::alert(__('Invalid fax provider.'));
         } else {
             $fax_func = array($data['provider'] . 'Common', $providers_arr[$data['provider']]['send_func']);
             $numbers = array();
             $contacts = Utils_RecordBrowserCommon::get_records('contact', array('id' => $data['dest_contact']), array('fax'));
             foreach ($contacts as $row) {
                 $numbers[] = $row['fax'];
             }
             $companies = Utils_RecordBrowserCommon::get_records('company', array('id' => $data['dest_company']), array('fax'));
             foreach ($companies as $row) {
                 $numbers[] = $row['fax'];
             }
             $numbers += explode(',', $data['dest_other']);
             $ret = call_user_func($fax_func, $file, $numbers);
             if ($ret) {
                 return $this->go_back($file);
             }
         }
     }
     $qf->display();
     Base_ActionBarCommon::add('send', __('Send'), $qf->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Exemplo n.º 2
0
 public function admin()
 {
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $this->pack_module('CRM_Contacts', array(), 'user_admin');
         $this->banning_form();
         return;
     }
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('edit', __('E-mail header'), $this->create_callback_href(array($this, 'change_email_header')));
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'user_list');
     //$gb->set_module_variable('adv_search',false);
     $cols = array();
     $cols[] = array('name' => __('ID'), 'order' => 'u.id', 'width' => 6, 'search' => 'id');
     $cols[] = array('name' => __('Login'), 'order' => 'u.login', 'width' => 20, 'search' => 'login');
     $is_contacts = CRM_ContactsInstall::is_installed();
     if ($is_contacts) {
         $cols[] = array('name' => __('Contact'), 'width' => 27);
     }
     $cols[] = array('name' => __('Active'), 'order' => 'u.active', 'width' => 5);
     $cols[] = array('name' => __('Mail'), 'order' => 'p.mail', 'width' => 20, 'search' => 'mail');
     $cols[] = array('name' => __('Access'), 'width' => '27');
     if (Base_AclCommon::i_am_sa()) {
         $cols[] = array('name' => __('Actions'), 'width' => '80px');
     }
     $gb->set_table_columns($cols);
     $gb->set_default_order(array(__('Login') => 'ASC'));
     $search = $gb->get_search_query();
     $query = 'SELECT u.login, p.mail, u.id, u.active, u.admin FROM user_login u INNER JOIN user_password p on p.user_login_id=u.id' . ($search ? ' WHERE ' . $search : '');
     $query_qty = 'SELECT count(u.id) FROM user_login u INNER JOIN user_password p on p.user_login_id=u.id' . ($search ? ' WHERE ' . $search : '');
     $ret = $gb->query_order_limit($query, $query_qty);
     $yes = '<span style="color:green;">' . __('Yes') . '</span>';
     $no = '<span style="color:red;">' . __('No') . '</span>';
     if ($ret) {
         while ($row = $ret->FetchRow()) {
             $gb_row = array();
             $gb_row[] = $row['id'];
             $gb_row[] = '<a ' . $this->create_callback_href(array($this, 'edit_user_form'), array($row['id'])) . '>' . $row['login'] . '</a>';
             if ($is_contacts) {
                 $c = CRM_ContactsCommon::get_contact_by_user_id($row['id']);
                 $gb_row[] = $c ? CRM_ContactsCommon::contact_format_default($c) : '---';
             }
             $gb_row[] = $row['active'] ? $yes : $no;
             $gb_row[] = $row['mail'];
             switch ($row['admin']) {
                 case 2:
                     $admin = __('Super Administrator');
                     break;
                 case 1:
                     $admin = __('Administrator');
                     break;
                 default:
                     $admin = __('User');
                     break;
             }
             $gb_row[] = $admin;
             if (Base_AclCommon::i_am_sa()) {
                 $gb_row[] = '<a ' . $this->create_callback_href(array($this, 'log_as_user'), $row['id']) . '>' . __('Log as user') . '</a>';
             }
             $gb->add_row_array($gb_row);
         }
     }
     $this->display_module($gb);
     $this->banning_form();
     Base_ActionBarCommon::add('add', __('New user'), $this->create_callback_href(array($this, 'edit_user_form'), array(-1)));
 }
Exemplo n.º 3
0
 public static function rpicker_contact_format($e)
 {
     return CRM_ContactsCommon::contact_format_default($e, true);
 }
Exemplo n.º 4
0
 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']));
 }