static function getAllTelephoneTypesInfo() { $types = TelephoneTypes::findAll(); $result = array(); foreach ($types as $type) { $result[] = array('id' => $type->getId(), 'code' => $type->getName(), 'name' => lang($type->getName())); } return $result; }
function render_company_data_tab($genid, $company, $renderContext, $company_data) { $object = $company; if ($company instanceof Contact && !$company->isNew()) { $address = $company->getAddress('work'); $street = ""; $city = ""; $state = ""; $zipcode = ""; if ($address) { $street = $address->getStreet(); $city = $address->getCity(); $state = $address->getState(); $zipcode = $address->getZipCode(); $country = $address->getCountry(); } $company_data = array('first_name' => $company->getFirstName(), 'timezone' => $company->getTimezone(), 'email' => $company->getEmailAddress(), 'comments' => $company->getCommentsField()); // array // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); tpl_assign('all_telephone_types', $all_telephone_types); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); tpl_assign('all_address_types', $all_address_types); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); tpl_assign('all_webpage_types', $all_webpage_types); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); tpl_assign('all_email_types', $all_email_types); $all_phones = ContactTelephones::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_phones'] = $all_phones; $all_addresses = ContactAddresses::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_addresses'] = $all_addresses; $all_webpages = ContactWebpages::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_webpages'] = $all_webpages; $all_emails = $company->getNonMainEmails(); $company_data['all_emails'] = $all_emails; } // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); include get_template_path("tabs/company_data", "contact"); }
public function initialize() { $this->add(new Text("name")); $this->add(new Text("telephone")); $this->add(new Select("telephoneType", TelephoneTypes::find(), array('using' => array('id', 'name')))); }
function hasPhone($number, $phone_type, $isMain = false, $name = "") { $type_id = TelephoneTypes::getTelephoneTypeId($phone_type); $obj = ContactTelephones::instance()->findOne(array('conditions' => array('contact_id=? AND telephone_type_id=? AND number=?', $this->getId(), $type_id, $number))); return $obj instanceof ContactTelephone; }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if(isset($this) && instance_of($this, 'TelephoneTypes')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return TelephoneTypes::instance()->paginate($arguments, $items_per_page, $current_page); } // if } // paginate
<?php // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); // instant messenger types $im_types = ImTypes::findAll(array('order' => '`id`')); if (!isset($id_prefix)) { $id_prefix = ''; } ?> <div id="<?php echo $genid; ?> _additional_data" class="additional-data"> <div class="information-block no-border-bottom"> <div class="input-container"> <?php echo label_tag(lang('birthday'), $genid . 'profileFormBirthday'); ?> <span style="float:left;"><?php echo pick_date_widget2('contact[birthday]', array_var($contact_data, 'birthday'), $genid, 265); ?> </span> </div>
static function getTypeId($type){ $telephone_type = TelephoneTypes::findOne(array('conditions' => array("`name` = ?",$type))); if (!is_null($telephone_type)) return $telephone_type->getId(); else return null; }
/** * Return manager instance * * @access protected * @param void * @return TelephoneTypes */ function manager() { if (!$this->manager instanceof TelephoneTypes) { $this->manager = TelephoneTypes::instance(); } return $this->manager; }
/** * Return Telephone type * * @access public * @param void * @return TelephoneType */ function getTelephoneType() { return TelephoneTypes::findById($this->getTelephoneTypeId()); } // getTelephoneType
/** * Add company * * @param void * @return null */ function add_company() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $notAllowedMember = ''; if (!Contact::canAdd(logged_user(), active_context(), $notAllowedMember)) { if (str_starts_with($notAllowedMember, '-- req dim --')) { flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in))); } else { trim($notAllowedMember) == "" ? flash_error(lang('you must select where to keep', lang('the contact'))) : flash_error(lang('no context permissions to add', lang("contacts"), $notAllowedMember)); } ajx_current("empty"); return; } // if $company = new Contact(); $company->setIsCompany(1); $company_data = array_var($_POST, 'company'); if (!is_array($company_data)) { // set layout for modal form if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); tpl_assign('modal', true); } $company_data = array('timezone' => logged_user()->getTimezone()); // array } // if tpl_assign('company', $company); tpl_assign('company_data', $company_data); // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); tpl_assign('all_telephone_types', $all_telephone_types); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); tpl_assign('all_address_types', $all_address_types); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); tpl_assign('all_webpage_types', $all_webpage_types); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); tpl_assign('all_email_types', $all_email_types); $company_data['all_phones'] = array(); $company_data['all_addresses'] = array(); $company_data['all_webpages'] = array(); if (is_array(array_var($_POST, 'company'))) { foreach ($company_data as $k => &$v) { $v = remove_scripts($v); } $company->setFromAttributes($company_data); $company->setObjectName(); try { $company_data['contact_type'] = 'company'; Contacts::validate($company_data); DB::beginWork(); if (isset($_SESSION['new_contact_picture']) && $_SESSION['new_contact_picture']) { $company->setPictureFile($_SESSION['new_contact_picture']); $_SESSION['new_contact_picture'] = null; } $company->save(); // save phones, addresses and webpages $this->save_phones_addresses_webpages($company_data, $company); if ($company_data['email'] != "") { $company->addEmail($company_data['email'], 'work', true); } // save additional emails $this->save_non_main_emails($company_data, $company); $object_controller = new ObjectController(); $object_controller->add_subscribers($company); $member_ids = json_decode(array_var($_POST, 'members')); if (!is_null($member_ids)) { $object_controller->add_to_members($company, $member_ids); } $object_controller->link_to_new_object($company); $object_controller->add_custom_properties($company); DB::commit(); ApplicationLogs::createLog($company, ApplicationLogs::ACTION_ADD); flash_success(lang('success add client', $company->getObjectName())); evt_add("company added", array("id" => $company->getObjectId(), "name" => $company->getObjectName())); ajx_current("back"); if (array_var($_REQUEST, 'modal')) { evt_add("reload current panel"); } } catch (Exception $e) { DB::rollback(); ajx_current("empty"); if (array_var($_REQUEST, 'modal')) { ajx_extra_data(array('error' => $e->getMessage())); } else { flash_error($e->getMessage()); } } // try } // if }
/** * * Add phone to the contact * @param string $number * @param int $phone_type * @param boolean $isMain * @author Seba */ function addPhone($number, $phone_type, $isMain = false) { $phone = new ContactTelephone(); $phone->setNumber($number); $phone->setTelephoneTypeId(TelephoneTypes::getTelephoneTypeId($phone_type)); $phone->setContactId($this->getId()); $phone->setIsMain($isMain); $phone->save(); }
/** * Return manager instance * * @access protected * @param void * @return TelephoneTypes */ function manager() { if(!($this->manager instanceof TelephoneTypes)) $this->manager = TelephoneTypes::instance(); return $this->manager; } // manager