} $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'))); }
<?php if (!$ajax) { Yii::app()->clientScript->registerCss('rel_grid', ' .rel-grid-view {margin-top:-60px;} .rel-grid-view div.summary {height: 60px;} '); Yii::app()->clientScript->registerScript('hide_user_company_grid_header', ' $("#ccuc-user-company-grid thead").hide(); '); ?> <div class="table-header"> <?php echo UserModule::t("Customer companies "); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array("{$this->id}/customerAjaxCompanyAdd", 'id' => $model->id, 'pprs_id' => $model->profile->person_id, 'ajax' => 'ccuc-user-company-grid'), 'ajaxOptions' => array('success' => 'function (html) { $.fn.yiiGridView.update(\'ccuc-user-company-grid\'); }'), 'htmlOptions' => array('title' => UserModule::t('Add company'), 'data-toggle' => 'tooltip'))); ?> </div> <?php } $ccuc = new CcucUserCompany(); $ccuc->ccuc_person_id = $model->profile->person_id; // render grid view $this->widget('TbGridView', array('id' => 'ccuc-user-company-grid', 'dataProvider' => $ccuc->searchPersonsForRel(), 'template' => '{summary}{items}', 'summaryText' => ' ', 'enableSorting' => false, 'htmlOptions' => array('class' => 'rel-grid-view'), 'afterAjaxUpdate' => 'function(){$("#ccuc-user-company-grid thead").hide()}', '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' => CHtml::listData(CcmpCompany::model()->findAll(array('order' => 'ccmp_name')), 'ccmp_id', 'itemLabel'))), 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' => UserModule::t('Do you want to delete this item?'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip')))));