static function getAllWebpageTypesInfo()
 {
     $types = WebpageTypes::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");
}
 /**
 * 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, 'WebpageTypes')) {
     return parent::paginate($arguments, $items_per_page, $current_page);
   } else {
     return WebpageTypes::instance()->paginate($arguments, $items_per_page, $current_page);
   } // if
 } // paginate
 /**
  * Return Webpage type
  *
  * @access public
  * @param void
  * @return WebpageType
  */
 function getWebpageType()
 {
     return WebpageTypes::findById($this->getWebTypeId());
 }
 function hasWebpage($url, $web_type)
 {
     $type_id = WebpageTypes::getWebpageTypeId($web_type);
     $obj = ContactWebpages::instance()->findOne(array('conditions' => array('contact_id=? AND web_type_id=? AND url=?', $this->getId(), $type_id, $url)));
     return $obj instanceof ContactWebpage;
 }
<?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){
 		$webpage_type = WebpageTypes::findOne(array('conditions' => array("`name` = ?",$type)));
 		if (!is_null($webpage_type)) return $webpage_type->getId();
 		else return null;
   }
 /**
  * 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
 }
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return WebpageTypes 
 */
 function manager() {
   if(!($this->manager instanceof WebpageTypes)) $this->manager = WebpageTypes::instance();
   return $this->manager;
 } // manager
Example #10
0
 /**
  * 
  * Add webpage to the contact
  * @param string $url
  * @param int $web_type
  * @author Seba
  */
 function addWebpage($url, $web_type)
 {
     $web = new ContactWebpage();
     $web->setUrl($url);
     $web->setWebTypeId(WebpageTypes::getWebpageTypeId($web_type));
     $web->setContactId($this->getId());
     $web->save();
 }
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return WebpageTypes 
  */
 function manager()
 {
     if (!$this->manager instanceof WebpageTypes) {
         $this->manager = WebpageTypes::instance();
     }
     return $this->manager;
 }