Example #1
0
 public function get_data($user, $pass, $newer_then = 0)
 {
     global $namespace;
     $error = $this->auth($user, $pass);
     $contacts = array();
     $companies = array();
     if ($error === '') {
         $c = CRM_ContactsCommon::get_contacts(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then)));
         foreach ($c as $row) {
             foreach ($row['company_name'] as &$v) {
                 $v = (int) $v;
             }
             $contacts[] = new SOAP_Value('item', '{urn:' . $namespace . '}Contact', array('id' => new SOAP_Value("id", "int", (int) $row['id']), 'first' => new SOAP_Value("first", "string", $row['first_name']), 'last' => new SOAP_Value("last", "string", $row['last_name']), 'title' => new SOAP_Value("title", "string", $row['title']), 'work_phone' => new SOAP_Value("work_phone", "string", $row['work_phone']), 'mobile_phone' => new SOAP_Value("mobile_phone", "string", $row['mobile_phone']), 'fax' => new SOAP_Value("fax", "string", $row['fax']), 'mail' => new SOAP_Value("mail", "string", $row['email']), 'web_address' => new SOAP_Value("web_address", "string", $row['web_address']), 'address1' => new SOAP_Value("address1", "string", $row['address_1']), 'address2' => new SOAP_Value("address2", "string", $row['address_2']), 'city' => new SOAP_Value("city", "string", $row['city']), 'country' => new SOAP_Value("country", "string", $row['country']), 'zone' => new SOAP_Value("zone", "string", $row['zone']), 'postal' => new SOAP_Value("postal", "string", $row['postal_code']), 'home_phone' => new SOAP_Value("home_phone", "string", $row['home_phone']), 'home_address1' => new SOAP_Value("home_address1", "string", $row['home_address_1']), 'home_address2' => new SOAP_Value("home_address2", "string", $row['home_address_2']), 'home_city' => new SOAP_Value("home_city", "string", $row['home_city']), 'home_zone' => new SOAP_Value("home_zone", "string", $row['home_zone']), 'home_country' => new SOAP_Value("home_country", "string", $row['home_country']), 'home_postal' => new SOAP_Value("home_postal", "string", $row['home_postal_code']), 'birth' => new SOAP_Value("birth", "string", $row['birth_date']), 'company' => new SOAP_Value("company", '{urn:' . $namespace . '}ArrayOfInt', $row['company_name'])));
         }
         $c = CRM_ContactsCommon::get_companies(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then)));
         foreach ($c as $row) {
             $companies[] = new SOAP_Value('item', '{urn:' . $namespace . '}Company', array('id' => new SOAP_Value("id", 'int', (int) $row['id']), 'name' => new SOAP_Value("name", 'string', $row['company_name']), 'short_name' => new SOAP_Value("short_name", 'string', $row['short_name']), 'phone' => new SOAP_Value("phone", 'string', $row['phone']), 'fax' => new SOAP_Value("fax", 'string', $row['fax']), 'web_address' => new SOAP_Value("web_address", 'string', $row['web_address']), 'address1' => new SOAP_Value("address1", 'string', $row['address_1']), 'address2' => new SOAP_Value("address2", 'string', $row['address_2']), 'city' => new SOAP_Value("city", 'string', $row['city']), 'country' => new SOAP_Value("country", 'string', $row['country']), 'zone' => new SOAP_Value("zone", 'string', $row['zone']), 'postal' => new SOAP_Value("postal", 'string', $row['postal_code'])));
         }
     }
     return new SOAP_Value('return', '{urn:' . $namespace . '}GetDataResult', array('companies' => new SOAP_Value('companies', '{urn:' . $namespace . '}ArrayOfCompanies', $companies), 'contacts' => new SOAP_Value('contacts', '{urn:' . $namespace . '}ArrayOfContacts', $contacts), 'error' => new SOAP_Value('error', 'string', $error)));
 }
Example #2
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());
 }