예제 #1
0
 public function save()
 {
     //create Match
     $match = new IntCorrelation();
     $match->account_id = $this->account_id;
     $match->owner = Yii::app()->user->id;
     $match->save();
     //bankbooks
     foreach ($this->in as $transaction => $true) {
         $transaction = Transactions::model()->findByPk($transaction);
         if ($transaction !== null) {
             $transaction->intCorrelation = $match->id;
             $transaction->intType = true;
             $transaction->save();
         }
     }
     //transaction
     foreach ($this->out as $transaction => $true) {
         $transaction = Transactions::model()->findByPk($transaction);
         if ($transaction !== null) {
             $transaction->intCorrelation = $match->id;
             $transaction->intType = false;
             $transaction->save();
         }
     }
     return $match->id;
 }
예제 #2
0
 public function actionMatchDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = IntCorrelation::model()->findByPk($id);
         if ($model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         $model->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }