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


PHP Companies::getVisibleCompanies方法代码示例

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


在下文中一共展示了Companies::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 = Companies::findAll(array('order' => 'client_of_id ASC, name ASC'));
    } else {
        $companies = Companies::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->getName();
            //if($company->isOwner()) $company_name .= ' (' . lang('owner company') . ')';
            $options[] = option_tag($company_name, $company->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:35,代码来源:application.php

示例2: get_ext_values

 private function get_ext_values($field, $manager = null)
 {
     $values = array(array('id' => '', 'name' => '-- ' . lang('select') . ' --'));
     if ($field == 'company_id' || $field == 'assigned_to_company_id') {
         $companies = Companies::getVisibleCompanies(logged_user());
         foreach ($companies as $company) {
             $values[] = array('id' => $company->getId(), 'name' => $company->getName());
         }
     } else {
         if ($field == 'user_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_user_id' || $field == 'completed_by_id') {
             $users = Users::getVisibleUsers(logged_user());
             foreach ($users as $user) {
                 $values[] = array('id' => $user->getId(), 'name' => $user->getDisplayName());
             }
         } else {
             if ($field == 'milestone_id') {
                 $milestones = ProjectMilestones::getActiveMilestonesByUser(logged_user());
                 foreach ($milestones as $milestone) {
                     $values[] = array('id' => $milestone->getId(), 'name' => $milestone->getName());
                 }
             } else {
                 if ($field == 'workspace') {
                     $workspaces = logged_user()->getWorkspaces(false, 0);
                     foreach ($workspaces as $ws) {
                         $values[] = array('id' => $ws->getId(), 'name' => $ws->getName());
                     }
                 } else {
                     if ($field == 'tag') {
                         $tags = Tags::getTagNames();
                         foreach ($tags as $tag) {
                             $values[] = array('id' => $tag['name'], 'name' => $tag['name']);
                         }
                     } else {
                         if ($field == 'object_subtype') {
                             $object_types = ProjectCoTypes::findAll(array('conditions' => !is_null($manager) ? "`object_manager`='{$manager}'" : ""));
                             foreach ($object_types as $object_type) {
                                 $values[] = array('id' => $object_type->getId(), 'name' => $object_type->getName());
                             }
                         }
                     }
                 }
             }
         }
     }
     return $values;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:46,代码来源:ReportingController.class.php

示例3: export_to_csv_file

 function export_to_csv_file()
 {
     $this->setTemplate('csv_export');
     $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;
     }
     if ($type == 'contact') {
         $checked_fields = array_var($_POST, 'check_contact');
     } else {
         $checked_fields = 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 = Companies::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);
         $project = active_project();
         if ($project instanceof Project) {
             $pids = $project->getAllSubWorkspacesQuery(true);
         }
         $wsConditions = null;
         $tag_str = null;
         $tag = array_var($_GET, 'active_tag');
         if (array_var($_SESSION, 'import_type', 'contact') == 'contact') {
             if (isset($pids)) {
                 $wsConditions = Contacts::getWorkspaceString($pids);
             }
             if (isset($tag) && $tag && $tag != '') {
                 $tag_str = " EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` = " . DB::escape($tag) . " AND `co`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = 'Contacts') ";
             }
             $conditions = $wsConditions ? $wsConditions . ($tag_str ? " AND {$tag_str}" : '') : $tag_str;
             $conditions .= ($conditions == "" ? "" : " AND ") . "`archived_by_id` = 0" . ($conditions ? " AND {$conditions}" : "");
             $contacts = Contacts::instance()->getAllowedContacts($conditions);
             foreach ($contacts as $contact) {
                 fwrite($handle, $this->build_csv_from_contact($contact, $checked_fields) . "\n");
             }
         } else {
             if (isset($pids)) {
                 $wsConditions = Companies::getWorkspaceString($pids);
             }
             if (isset($tag) && $tag && $tag != '') {
                 $tag_str = " EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` = " . DB::escape($tag) . " AND `" . TABLE_PREFIX . "companies`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = 'Companies') ";
             }
             $conditions = $wsConditions ? $wsConditions . ($tag_str ? " AND {$tag_str}" : '') : $tag_str;
             $conditions .= ($conditions == "" ? "" : " AND ") . "`archived_by_id` = 0" . ($conditions ? " AND {$conditions}" : "");
             $companies = Companies::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:pnagaraju25,项目名称:fengoffice,代码行数:79,代码来源:ContactController.class.php


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