| Current Path : /var/www/html/dyna-crm/controllers/ |
| Current File : /var/www/html/dyna-crm/controllers/BankreconciliationController.php |
<?php
namespace app\controllers;
use Yii;
use app\models\BankReconciliation;
use app\models\BankReconciliationSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* BankreconciliationController implements the CRUD actions for BankReconciliation model.
*/
class BankreconciliationController extends Controller {
/**
* {@inheritdoc}
*/
public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionSave() {
$id = $_POST['id'];
$table_name = $_POST['table_name'];
$data_id = $_POST['data_id'];
$status = $_POST['status'];
$statement_dt = $_POST['statement_dt'];
$ref_no = $_POST['ref_no'];
$remarks = $_POST['remarks'];
$output = 'failed';
if (empty($id)) {
$model = new BankReconciliation();
$model->table_name = $table_name;
$model->data_id = $data_id;
$model->status = $status;
$model->statement_dt = $statement_dt;
$model->ref_no = $ref_no;
$model->remarks = $remarks;
$model->created_dt = date("Y-m-d H:i:s");
$model->created_by = Yii::$app->user->identity->id;
$model->updated_dt = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 'success';
} else if (($model = BankReconciliation::findOne($id)) !== null) {
$model->status = $status;
$model->statement_dt = $statement_dt;
$model->ref_no = $ref_no;
$model->remarks = $remarks;
$model->updated_dt = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 'success';
}
return $output;
}
/**
* Lists all BankReconciliation models.
* @return mixed
*/
public function actionIndex() {
$searchModel = new BankReconciliationSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single BankReconciliation model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new BankReconciliation model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new BankReconciliation();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing BankReconciliation model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing BankReconciliation model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id) {
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the BankReconciliation model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return BankReconciliation the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = BankReconciliation::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}