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");
}
Esempio n. 2
0
<?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>
 /**
  * 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
 }