コード例 #1
0
 protected function afterDelete()
 {
     tAccountProperties::model()->deleteAll('parent_id =' . $this->id);
     $log = new zArLog();
     $log->description = 'User ' . Yii::app()->user->Name . ' deleted ' . get_class($this->Owner) . '[' . $this->account_no . ' ' . $this->account_name . '].';
     $log->action = 'DELETE';
     $log->model = get_class($this->Owner);
     $log->idModel = $this->Owner->getPrimaryKey();
     $log->field = '';
     $log->creationdate = new CDbExpression('NOW()');
     $log->userid = Yii::app()->user->id;
     $log->save();
     return true;
 }
コード例 #2
0
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if ($model->parent_id == 0) {
         $this->forward('updateRoot');
     }
     // $this->performAjaxValidation($model);
     if (isset($_POST['tAccount'])) {
         $model->attributes = $_POST['tAccount'];
         if ($model->save()) {
             $model->account_properties = $_POST['account_properties'];
             $model->value = $_POST['value'];
             $model->text = $_POST['text'];
             tAccountProperties::model()->deleteAll('parent_id = ' . $id);
             //delete All Related Properties
             for ($i = 0; $i < sizeof($model->account_properties); ++$i) {
                 $modelProp = new tAccountProperties();
                 $modelProp->parent_id = $id;
                 $modelProp->mkey = $model->account_properties[$i];
                 $modelProp->mvalue = $model->value[$i];
                 $modelProp->mtext = $model->text[$i];
                 $modelProp->save();
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (isset($model->haschild)) {
         $model->haschild_id = $model->haschild->mvalue;
     }
     if (isset($model->currency)) {
         $model->currency_id = $model->currency->mvalue;
     }
     if (isset($model->state)) {
         $model->state_id = $model->state->mvalue;
     }
     if (!isset($_POST['account_properties'])) {
         $modelDetail = tAccountProperties::model()->findAll('parent_id =' . $model->id);
         foreach ($modelDetail as $mm) {
             $model->account_properties[] = $mm->mkey;
             $model->value[] = $mm->mvalue;
             $model->text[] = $mm->mtext;
         }
     }
     $this->render('update', array('model' => $model));
 }