/**
  * load controller model
  * @param int $id
  * @return PfOrderItemNotes
  * @throws CHttpException|
  */
 public function loadModel($id)
 {
     $m = CucpUserCompanyPosition::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('D2companyModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }
    }
    $model = new CcucUserCompany();
    $model->ccuc_person_id = $modelMain->primaryKey;
    $model->ccuc_status = CcucUserCompany::CCUC_STATUS_PERSON;
    // render grid view
    $can_edit_ccuc = Yii::app()->user->checkAccess("D2company.CcucUserCompany.Update");
    $bft = !$can_edit_ccuc ? 'false' : 'true';
    if (Yii::app()->getModule('d2person')->ccucCompanyList == D2personModule::ALL_COMPANIES) {
        $comapniesSource = CHtml::listData(CcmpCompany::model()->findAll(array('limit' => 1000, 'order' => 'ccmp_name')), 'ccmp_id', 'itemLabel');
    } else {
        /**
         * actual person syscompanies
         */
        $comapniesSource = CHtml::listData(Yii::app()->sysCompany->getClientCompanies(), 'ccmp_id', 'ccmp_name');
    }
    $this->widget('TbGridView', array('id' => 'ccuc-user-company-grid', 'dataProvider' => $model->searchPersonsForRel(), 'template' => '{summary}{items}', 'summaryText' => ' ', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'ccuc_ccmp_id', 'value' => '$data->ccmp_name', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2company/ccucUserCompany/editableSaver'), 'source' => $comapniesSource, 'apply' => $can_edit_ccuc)), array('class' => 'editable.EditableColumn', 'name' => 'ccuc_cucp_id', 'value' => '(!' . $bft . ' && !empty($data->ccuc_cucp_id))?$data->ccucCucp->cucp_name:""', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2company/ccucUserCompany/editableSaver'), 'source' => CHtml::listData(CucpUserCompanyPosition::model()->findAll(array('limit' => 1000)), 'cucp_id', 'itemLabel'), 'apply' => $can_edit_ccuc)), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'TRUE')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/d2company/ccucUserCompany/delete", array("ccuc_id" => $data->ccuc_id))', 'deleteConfirmation' => Yii::t('D2personModule.crud_static', 'Do you want to delete this item?'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'), 'visible' => Yii::app()->user->checkAccess("D2company.CcucUserCompany.Delete")))));
    Yii::endProfile('ccuc_person_id.view.grid');
}
if ((!$ajax || $ajax == 'ppcn-person-contact-grid') && Yii::app()->user->checkAccess("D2person.PpcnPersonContact.View")) {
    $can_edit_ppcn = (bool) Yii::app()->user->checkAccess("D2person.PpcnPersonContact.Update");
    Yii::beginProfile('ppcn_pprs_id.view.grid');
    ?>

<div class="table-header">
    <?php 
    echo Yii::t('D2personModule.model', 'Ppcn Person Contact');
    ?>
    <?php 
    if (Yii::app()->user->checkAccess("D2person.PpcnPersonContact.Create")) {
        $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array('//d2person/ppcnPersonContact/ajaxCreate', 'field' => 'ppcn_pprs_id', 'value' => $modelMain->primaryKey, 'ajax' => 'ppcn-person-contact-grid'), 'ajaxOptions' => array('success' => 'function (html) {$.fn.yiiGridView.update(\'ppcn-person-contact-grid\');}'), 'htmlOptions' => array('title' => Yii::t('D2personModule.crud_static', 'Add new record'), 'data-toggle' => 'tooltip')));
    }