public function save() { //create Match $match = new ExtCorrelation(); $match->account_id = $this->account_id; $match->owner = Yii::app()->user->id; $match->save(); //bankbooks //print_r($this->Bankbooks); //print_r($this->Transactions); foreach ($this->Bankbooks['match'] as $bankbook => $true) { Yii::log("bank:" . $bankbook, 'info', 'app'); $bankbook = Bankbook::model()->findByPk($bankbook); if ($bankbook !== null) { $bankbook->extCorrelation = $match->id; $bankbook->save(); } } //transaction foreach ($this->Transactions['match'] as $transaction => $true) { Yii::log("trans:" . $transaction, 'info', 'app'); $transaction = Transactions::model()->findByPk($transaction); if ($transaction !== null) { $transaction->extCorrelation = $match->id; $transaction->save(); } } return $match->id; }
public function actionMatchDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = ExtCorrelation::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.'); } }