当前位置: 首页>>代码示例>>PHP>>正文


PHP Contacts::getVisibleCompanies方法代码示例

本文整理汇总了PHP中Contacts::getVisibleCompanies方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::getVisibleCompanies方法的具体用法?PHP Contacts::getVisibleCompanies怎么用?PHP Contacts::getVisibleCompanies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contacts的用法示例。


在下文中一共展示了Contacts::getVisibleCompanies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: select_company

/**
 * Render select company box
 *
 * @param integer $selected ID of selected company
 * @param array $attributes Additional attributes
 * @return string
 */
function select_company($name, $selected = null, $attributes = null, $allow_none = true, $check_permissions = false)
{
    if (!$check_permissions) {
        $companies = Contacts::findAll(array('conditions' => 'is_company = 1 AND trashed_by_id = 0 AND archived_by_id = 0 ', 'order' => 'first_name ASC'));
    } else {
        $companies = Contacts::getVisibleCompanies(logged_user(), "`id` <> " . owner_company()->getId());
        if (logged_user()->isMemberOfOwnerCompany() || owner_company()->canAddUser(logged_user())) {
            // add the owner company
            $companies = array_merge(array(owner_company()), $companies);
        }
    }
    if ($allow_none) {
        $options = array(option_tag(lang('none'), 0));
    } else {
        $options = array();
    }
    if (is_array($companies)) {
        foreach ($companies as $company) {
            $option_attributes = $company->getId() == $selected ? array('selected' => 'selected') : null;
            $company_name = $company->getObjectName();
            $options[] = option_tag($company_name, $company->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:34,代码来源:application.php

示例2: get_companies_json

	function get_companies_json() {
		$data = array();
		
		$check_permissions = array_var($_REQUEST, 'check_p');
		$allow_none = array_var($_REQUEST, 'allow_none', true);
		
		if (!$check_permissions) {
			$comp_rows = DB::executeAll("SELECT c.object_id, c.first_name FROM ".TABLE_PREFIX."contacts c INNER JOIN ".TABLE_PREFIX."objects o ON o.id=c.object_id
			WHERE c.is_company = 1 AND o.trashed_by_id = 0 AND o.archived_by_id = 0 ORDER BY c.first_name ASC");
		} else {
			$companies = Contacts::getVisibleCompanies(logged_user(), "`id` <> " . owner_company()->getId());
			if (logged_user()->isMemberOfOwnerCompany() || owner_company()->canAddUser(logged_user())) {
				// add the owner company
				$companies = array_merge(array(owner_company()), $companies);
			}
		}
		if ($allow_none) {
			$data[] = array('id' => 0, 'name' => lang('none'));
		}
		if (isset($comp_rows)) {
			foreach ($comp_rows as $row) {
				$data[] = array('id' => $row['object_id'], 'name' => $row['first_name']);
			}
		} else if (isset($companies)) {
			foreach ($companies as $company) {
				$data[] = array('id' => $company->getId(), 'name' => $company->getObjectName());
			}
		}
		
		$this->setAutoRender(false);
		echo json_encode($data);
		ajx_current("empty");
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:33,代码来源:ContactController.class.php

示例3: export_to_csv_file

 function export_to_csv_file()
 {
     $this->setTemplate('csv_export');
     $ids = array_var($_GET, 'ids');
     $type = array_var($_GET, 'type', array_var($_SESSION, 'import_type', 'contact'));
     //type of import (contact - company)
     tpl_assign('import_type', $type);
     if (!isset($_SESSION['import_type']) || $type != $_SESSION['import_type'] && $type != '') {
         $_SESSION['import_type'] = $type;
     }
     $checked_fields = $type == 'contact' ? array_var($_POST, 'check_contact') : array_var($_POST, 'check_company');
     if (is_array($checked_fields)) {
         $titles = '';
         $imp_type = array_var($_SESSION, 'import_type', 'contact');
         if ($imp_type == 'contact') {
             $field_names = Contacts::getContactFieldNames();
             foreach ($checked_fields as $k => $v) {
                 if (isset($field_names["contact[{$k}]"]) && $v == 'checked') {
                     $titles .= $field_names["contact[{$k}]"] . ',';
                 }
             }
             $titles = substr_utf($titles, 0, strlen_utf($titles) - 1) . "\n";
         } else {
             $field_names = Contacts::getCompanyFieldNames();
             foreach ($checked_fields as $k => $v) {
                 if (isset($field_names["company[{$k}]"]) && $v == 'checked') {
                     $titles .= $field_names["company[{$k}]"] . ',';
                 }
             }
             $titles = substr_utf($titles, 0, strlen_utf($titles) - 1) . "\n";
         }
         $filename = rand() . '.tmp';
         $handle = fopen(ROOT . '/tmp/' . $filename, 'wb');
         fwrite($handle, $titles);
         $ids_sql = $ids ? " AND id IN (" . $ids . ") " : "";
         if (array_var($_SESSION, 'import_type', 'contact') == 'contact') {
             $conditions .= ($conditions == "" ? "" : " AND ") . "`archived_by_id` = 0" . ($conditions ? " AND {$conditions}" : "");
             $conditions .= $ids_sql;
             $contacts = Contacts::instance()->getAllowedContacts($conditions);
             foreach ($contacts as $contact) {
                 fwrite($handle, $this->build_csv_from_contact($contact, $checked_fields) . "\n");
             }
         } else {
             $conditions .= ($conditions == "" ? "" : " AND ") . "`archived_by_id` = 0" . ($conditions ? " AND {$conditions}" : "");
             $conditions .= $ids_sql;
             $companies = Contacts::getVisibleCompanies(logged_user(), $conditions);
             foreach ($companies as $company) {
                 fwrite($handle, $this->build_csv_from_company($company, $checked_fields) . "\n");
             }
         }
         fclose($handle);
         $_SESSION['contact_export_filename'] = $filename;
         flash_success($imp_type == 'contact' ? lang('success export contacts') : lang('success export companies'));
     } else {
         unset($_SESSION['contact_export_filename']);
         return;
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:58,代码来源:ContactController.class.php


注:本文中的Contacts::getVisibleCompanies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。