예제 #1
0
 /**
  * Validates that the specified model can be updated.
  * If the model is a new record this method always returns true.
  *
  * @param yii\db\ActiveRecord $model a model to validate.
  * @return bool true if model can be updated, false if not.
  */
 public function onBeforeSave($model)
 {
     if (!$model->getIsNewRecord() && in_array($model->id, $this->lockedFields) && !$this->changeLockedFields) {
         $this->message = Yii::t('big', 'Config "{name}" is locked and cannot be changed.', ['name' => $model->id]);
         return false;
     } else {
         return true;
     }
 }
예제 #2
0
 /**
  * Moves a nested set node up or down.
  *
  * @param yii\db\ActiveRecord $model a model to move in the tree.
  * @param string $direction the direction to move the model. Can be "up" or "down".
  * @return array status array with the keys "status" and "message".
  */
 public function moveNode($model, $direction)
 {
     $message = '';
     $status = 'success';
     if ($direction === 'up') {
         if (($prev = $model->prev()->one()) !== null) {
             if ($model->insertBefore($prev)) {
                 $message = Yii::t('big', 'Menu item moved up.');
             } else {
                 $status = 'error';
                 $message = Yii::t('big', 'An error occured. Please try again.');
             }
         } else {
             $status = 'info';
             $message = Yii::t('big', 'Menu item not moved. It is the first item.');
         }
     } elseif ($direction === 'down') {
         if (($next = $model->next()->one()) !== null) {
             if ($model->insertAfter($next)) {
                 $message = Yii::t('big', 'Menu item moved down.');
             } else {
                 $status = 'error';
                 $message = Yii::t('big', 'An error occured. Please try again.');
             }
         } else {
             $status = 'info';
             $message = Yii::t('big', 'Menu item not moved. It is the last item.');
         }
     } else {
         $message = Yii::t('big', 'Direction can only be "up" or "down"');
         $status = 'error';
     }
     return ['status' => $status, 'message' => $message];
 }
예제 #3
0
 private function _setupStatusColumns()
 {
     if ($this->searchModel->hasAttribute('status') && $this->displayStatusColumn) {
         $this->_columns[] = ['label' => 'Status', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
             $inactive = (int) $model['status'] == 0 ? TRUE : FALSE;
             return \humanized\user\components\GUIHelper::getStatusOutput($inactive);
         }];
     }
 }
예제 #4
0
 private function _setupStatusAttributes()
 {
     if ($this->displayStatusFields && $this->model->hasAttribute('status')) {
         $this->_attributes[] = ['label' => 'Status', 'format' => 'html', 'value' => \humanized\user\components\GUIHelper::getStatusOutput((int) $this->model->status == 0)];
     }
 }
예제 #5
0
 private function _setupStatusFields()
 {
     if ($this->model->hasAttribute('status') && $this->enableStatusDropdown) {
         echo $this->form->field($this->model, 'status')->dropDownList($this->statusDropdownData, ['prompt' => 'Select Status Value']);
     }
 }
예제 #6
0
파일: Work.php 프로젝트: vtdat/time_sheet
 public function attributes()
 {
     return array_merge(yii\db\ActiveRecord::attributes(), ['timesheet.date', 'process.process_name', 'timesheet.point', 'timesheet.director_comment']);
 }