本文整理汇总了PHP中Companies类的典型用法代码示例。如果您正苦于以下问题:PHP Companies类的具体用法?PHP Companies怎么用?PHP Companies使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Companies类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCompaniesByProjects
/**
* Return all companies that are on specific projects, determined by a CVS list of project ids.
*
* @access public
* @param string $projects_csv CSV list of projects
* @param string $additional_conditions Additional SQL conditions
* @param bool $include_owner Include the owner company
* @return array Array of Companies
*/
static function getCompaniesByProjects($projects_csv, $additional_conditions = null, $include_owner = true)
{
$companies = array();
$companies_table = Companies::instance()->getTableName(true);
$project_companies_table = ProjectCompanies::instance()->getTableName(true);
// Restrict result only on owner company
$ownerCond = '';
if (!$include_owner) {
$owner_id = owner_company()->getId();
$ownerCond = "{$companies_table}.`client_of_id` = '{$owner_id}' AND ";
}
$sql = "SELECT {$companies_table}.* FROM {$companies_table}, {$project_companies_table} WHERE {$ownerCond} ({$companies_table}.`id` = {$project_companies_table}.`company_id` AND {$project_companies_table}.`project_id` IN ( " . $projects_csv . '))';
if (trim($additional_conditions) != '') {
$sql .= " AND ({$additional_conditions}) ORDER BY {$companies_table}.`name`";
}
$rows = DB::executeAll($sql);
if (is_array($rows)) {
foreach ($rows as $row) {
$companies[] = Companies::instance()->loadFromRow($row);
}
// foreach
}
// if
return count($companies) ? $companies : null;
}
示例2: __construct
/**
* Constructor
*
* @param Request $request
* @return CompanyProfileController
*/
function __construct($request)
{
parent::__construct($request);
$company_id = $this->request->getId('company_id');
if ($company_id) {
$this->active_company = Companies::findById($company_id);
}
// if
if (instance_of($this->active_company, 'Company')) {
$this->wireframe->page_actions = array();
if (!$this->active_company->canView($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
if ($this->active_company->getIsArchived() && $this->logged_user->isPeopleManager()) {
$this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive'));
}
// if
$this->wireframe->addBreadCrumb($this->active_company->getName(), $this->active_company->getViewUrl());
// Collect company tabs
$tabs = new NamedList();
$tabs->add('overview', array('text' => str_excerpt($this->active_company->getName(), 25), 'url' => $this->active_company->getViewUrl()));
$tabs->add('people', array('text' => lang('People'), 'url' => $this->active_company->getViewUrl()));
$tabs->add('projects', array('text' => lang('Projects'), 'url' => $this->active_company->getViewUrl()));
event_trigger('on_company_tabs', array(&$tabs, &$this->logged_user, &$this->active_company));
$this->smarty->assign(array('company_tabs' => $tabs, 'company_tab' => 'overview'));
} else {
$this->active_company = new Company();
}
// if
$this->smarty->assign(array('active_company' => $this->active_company));
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id = NULL)
{
$currUser = Auth::user();
$oCategories = Category::all();
$oCity = Cities::all();
$oVacancy = null;
if ($id > 0) {
$oVacancy = Vacancy::find($id);
}
foreach ($oCategories as $item) {
$aCategories[$item->id] = $item->name;
}
if (Auth::user()->is_admin == 0) {
$aCompanies = Companies::where('user_id', '=', $currUser->id)->get();
} else {
$aCompanies = Companies::all();
}
foreach ($aCompanies as $item) {
$aCompany[$item->id] = $item->name;
}
$oQuery = Regions::join('country', 'country.id', '=', 'country_id')->select('regions.id as id', 'regions.name', 'country.name as country_name', 'country.id as country_id');
if ($oRegions = $oQuery->get()) {
}
foreach ($oRegions as $item) {
$aRegions[$item->country_name] = array();
$aCity = Cities::where('region_id', '=', $item->id)->get();
foreach ($aCity as $city) {
$aRegions[$item->name][$city->id] = $city->name;
}
}
if ($currUser->is_admin == 0 && (empty($oVacancy) === false && $oVacancy->user_id != $currUser->id)) {
return Redirect::route('vacancy-list', array('user_id' => $currUser->id));
}
return View::make('/vacancy/edit', array('currUser' => $currUser, 'aCategories' => $aCategories, 'aCompany' => $aCompany, 'aRegions' => $aRegions, 'oVacancy' => $oVacancy, 'id' => $id));
}
示例4: initCompany
/**
* Init company based on subdomain
*
* @access public
* @param string
* @return null
* @throws Error
*/
private function initCompany()
{
$company = Companies::getOwnerCompany();
if (!$company instanceof Company) {
throw new OwnerCompanyDnxError();
}
// if
// check the cache if available
$owner = null;
if (GlobalCache::isAvailable()) {
$owner = GlobalCache::get('owner_company_creator', $success);
}
if (!$owner instanceof User) {
$owner = $company->getCreatedBy();
// Update cache if available
if ($owner instanceof User && GlobalCache::isAvailable()) {
GlobalCache::update('owner_company_creator', $owner);
}
}
if (!$owner instanceof User) {
throw new AdministratorDnxError();
}
// if
$this->setCompany($company);
}
示例5: getCompany
/**
* Return invoice company
*
* @param void
* @return Company
*/
function getCompany()
{
if ($this->company === false) {
$this->company = Companies::findById($this->getCompanyId());
}
// if
return $this->company;
}
示例6: getCompany
/**
* Return relation company
*
* @param void
* @return Company
*/
function getCompany()
{
if (is_null($this->company)) {
$this->company = Companies::findById($this->getCompanyId());
}
// if
return $this->company;
}
示例7: check_fed_id
/**
* Check Fed ID rule
*/
public function check_fed_id() {
$company = Companies::model()->find('Company_Fed_ID=:Fed_ID',
array(':Fed_ID'=>$this->Fed_ID));
if($company != null) {
$this->addError('Fed_ID','Company with this Fed ID already exists');
} else if (!preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})$/', $this->Fed_ID)) {
$this->addError('Fed_ID','Invalid Fed ID, correct formatting: xx-xxxxxxx');
}
}
示例8: smarty_function_select_company
/**
* Render select company box
*
* Parameters:
*
* - value - Value of selected company
* - optional - Is value of this field optional or not
* - exclude - Array of company ID-s that will be excluded
* - can_create_new - Should this select box offer option to create a new
* company from within the list
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_company($params, &$smarty)
{
static $ids = array();
$companies = Companies::getIdNameMap(array_var($params, 'companies'));
$value = array_var($params, 'value', null, true);
$id = array_var($params, 'id', null, true);
if (empty($id)) {
$counter = 1;
do {
$id = "select_company_dropdown_{$counter}";
$counter++;
} while (in_array($id, $ids));
}
// if
$ids[] = $id;
$params['id'] = $id;
$optional = array_var($params, 'optional', false, true);
$exclude = array_var($params, 'exclude', array(), true);
if (!is_array($exclude)) {
$exclude = array();
}
// if
$can_create_new = array_var($params, 'can_create_new', true, true);
if ($optional) {
$options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
} else {
$options = array();
}
// if
foreach ($companies as $company_id => $company_name) {
if (in_array($company_id, $exclude)) {
continue;
}
// if
$option_attributes = array('class' => 'object_option');
if ($value == $company_id) {
$option_attributes['selected'] = true;
}
// if
$options[] = option_tag($company_name, $company_id, $option_attributes);
}
// if
if ($can_create_new) {
$logged_user = get_logged_user();
if (instance_of($logged_user, 'User') && Company::canAdd($logged_user)) {
$params['add_object_url'] = assemble_url('people_companies_quick_add');
$params['object_name'] = 'company';
$params['add_object_message'] = lang('Please insert new company name');
$options[] = option_tag('', '');
$options[] = option_tag(lang('New Company...'), '', array('class' => 'new_object_option'));
}
// if
}
// if
return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
示例9: run
public function run()
{
// Uncomment the below to wipe the table clean before populating
// DB::table('companies')->truncate();
Eloquent::unguard();
DB::table('companies')->delete();
Companies::create(array('id' => 1, 'name' => 'АТБ', 'description' => 'Продуктовый супермаркет', 'phone' => 123456789, 'email' => 'atb@ua.ua', 'web_site' => 'web.site.ua', 'city_id' => 3, 'user_id' => 1, 'cover_image' => '', 'logo' => ''));
Companies::create(array('id' => 2, 'name' => 'Фокстрот', 'description' => 'Супермаркет електронной техники', 'phone' => 0516155555, 'email' => 'fokstroy@ua', 'web_site' => 'fokstrot.ua', 'city_id' => 2, 'user_id' => 1, 'cover_image' => '', 'logo' => ''));
Companies::create(array('id' => 3, 'name' => 'Web-studio', 'description' => 'Web-studio, создание и продвижение сайтов', 'phone' => 0656565655, 'email' => 'web@web.ua', 'web_site' => 'web.ua', 'city_id' => 1, 'user_id' => 1, 'cover_image' => '', 'logo' => ''));
$this->command->info('Companies table seeded!');
}
示例10: check_auth
/**
* Check Auth_Code rule
*/
public function check_auth() {
$client = Clients::model()->findByPk($this->Client_ID);
if($client) {
$company = Companies::model()->findByPk($client->Company_ID);
if ($company->Auth_Code != $this->Auth_Code) {
$this->addError('Auth_Code','Invalid Authorization Code');
}
} else {
$this->addError('Auth_Code',"Company with this Authorization Code doesn't exists");
}
}
示例11: initCompany
/**
* Init company based on subdomain
*
* @access public
* @param string
* @return null
* @throws Error
*/
private function initCompany()
{
$company = Companies::getOwnerCompany();
if (!$company instanceof Company) {
throw new OwnerCompanyDnxError();
}
// if
if (!$company->getCreatedBy() instanceof User) {
throw new AdministratorDnxError();
}
// if
$this->setCompany($company);
}
示例12: get_owner_company
/**
* Return owner company instance
*
* @param void
* @return Company
*/
function get_owner_company()
{
static $instance = null;
if ($instance === null) {
$instance = cache_get('owner_company');
if (!$instance) {
$instance = Companies::findOwnerCompany();
}
// if
}
// if
return $instance;
}
示例13: archive
/**
* Show archive page
*
* @param void
* @return null
*/
function archive()
{
if ($this->logged_user->isPeopleManager()) {
$this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive'));
$page = (int) $this->request->get('page');
if ($page < 1) {
$page = 1;
}
// if
list($companies, $pagination) = Companies::paginateArchived($this->logged_user, $page, 30);
$this->smarty->assign(array('companies' => $companies, 'pagination' => $pagination));
} else {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
}
示例14: initCompany
/**
* Init company based on subdomain
*
* @access public
* @param string
* @return null
* @throws Error
*/
private function initCompany()
{
trace(__FILE__, 'initCompany()');
$company = Companies::getOwnerCompany();
trace(__FILE__, 'initCompany() - company check');
if (!$company instanceof Company) {
throw new OwnerCompanyDnxError();
}
// if
trace(__FILE__, 'initCompany() - admin check');
if (!$company->getCreatedBy() instanceof User) {
throw new AdministratorDnxError();
}
// if
trace(__FILE__, 'initCompany() - setCompany()');
$this->setCompany($company);
}
示例15: company
/**
* Display company details
*
*/
function company()
{
$current_company = Companies::findById($this->request->get('object_id'));
if (!instance_of($current_company, 'Company')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$current_company->isOwner() && !in_array($current_company->getId(), $this->logged_user->visibleCompanyIds())) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$users = $current_company->getUsers($this->logged_user->visibleUserIds());
if (!$current_company->isOwner()) {
$projects = Projects::findByUserAndCompany($this->logged_user, $current_company);
}
$this->smarty->assign(array('current_company' => $current_company, 'current_company_users' => $users, 'current_company_projects' => $projects, "page_title" => $current_company->getName(), "page_back_url" => assemble_url('mobile_access_people')));
}