/** * atgrie pirmo aktivas personas prasito settingu * @param int $type settinga tips * @return boolean */ public static function getActivePersonSetingValue($type) { $personId = Yii::app()->getModule('user')->user()->profile->person_id; $criteria = ['ppxs_pprs_id' => $personId, 'ppxs_psty_id' => $type]; $model = PpxsPersonXSetting::model()->findByAttributes($criteria); if (!$model) { return false; } return $model->ppxs_value; }
} if ((!$ajax || $ajax == 'ppxs-person-xsetting-grid') && Yii::app()->user->checkAccess("D2person.PpxsPersonXSetting.View")) { Yii::beginProfile('ppxs_pprs_id.view.grid'); ?> <div class="table-header"> <?php echo Yii::t('D2personModule.model', 'Ppxs Person Xsetting'); ?> <?php if (Yii::app()->user->checkAccess("D2person.PpxsPersonXSetting.Create")) { $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'ajaxButton', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => array('//d2person/ppxsPersonXSetting/ajaxCreate', 'field' => 'ppxs_pprs_id', 'value' => $modelMain->primaryKey, 'ajax' => 'ppxs-person-xsetting-grid'), 'ajaxOptions' => array('success' => 'function (html) {$.fn.yiiGridView.update(\'ppxs-person-xsetting-grid\');}'), 'htmlOptions' => array('title' => Yii::t('D2personModule.crud_static', 'Add new record'), 'data-toggle' => 'tooltip'))); } ?> </div> <?php if (empty($modelMain->ppxsPersonXSettings)) { $model = new PpxsPersonXSetting(); $model->ppxs_pprs_id = $modelMain->primaryKey; $model->save(); unset($model); } $model = new PpxsPersonXSetting(); $model->ppxs_pprs_id = $modelMain->primaryKey; // render grid view $can_edit_ppxs = Yii::app()->user->checkAccess("D2person.PpxsPersonXSetting.Update"); $bft = !$can_edit_ppxs ? 'false' : 'true'; $this->widget('TbGridView', array('id' => 'ppxs-person-xsetting-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => ' ', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'ppxs_psty_id', 'value' => '(!' . $bft . ' && !empty($data->ppxs_psty_id))?$data->ppxsPsty->itemLabel:""', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2person/ppxsPersonXSetting/editableSaver'), 'source' => CHtml::listData(PstySettingType::model()->findAll(array('limit' => 1000)), 'psty_id', 'itemLabel'), 'apply' => $can_edit_ppxs)), array('class' => 'editable.EditableColumn', 'name' => 'ppxs_value', 'editable' => array('url' => $this->createUrl('//d2person/ppxsPersonXSetting/editableSaver'), 'apply' => $can_edit_ppxs)), array('class' => 'editable.EditableColumn', 'name' => 'ppxs_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//d2person/ppxsPersonXSetting/editableSaver'), 'apply' => $can_edit_ppxs)), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'TRUE')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/d2person/ppxsPersonXSetting/delete", array("ppxs_id" => $data->ppxs_id))', 'deleteConfirmation' => Yii::t('D2personModule.crud_static', 'Do you want to delete this item?'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'), 'visible' => Yii::app()->user->checkAccess("D2person.PpxsPersonXSetting.Delete"))))); Yii::endProfile('ppxs_pprs_id.view.grid'); }
public function loadModel($id) { $m = PpxsPersonXSetting::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('D2personModule.crud_static', 'The requested page does not exist.')); } return $model; }