add hidden account support add delete/payout buttons to carts add backend product sales with pdf export add frontend product sales with pdf export add frontend ticket sales with pdf export
194 lines
5.0 KiB
PHP
194 lines
5.0 KiB
PHP
<?php
|
|
namespace backend\controllers;
|
|
|
|
use Yii;
|
|
use common\models\Transfer;
|
|
use backend\models\TransferSearch;
|
|
use yii\web\Controller;
|
|
use yii\web\NotFoundHttpException;
|
|
use yii\filters\VerbFilter;
|
|
use common\models\Account;
|
|
use common\models\User;
|
|
use backend\models\TransferSummarySearch;
|
|
use backend\models\TransferListSearch;
|
|
use backend\models\TransferSaleSearch;
|
|
use common\models\ProductCategory;
|
|
use common\models\Product;
|
|
|
|
/**
|
|
* TransferController implements the CRUD actions for Transfer model.
|
|
*/
|
|
class TransferController extends \backend\controllers\BackendController
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
'access' => [
|
|
'class' => \yii\filters\AccessControl::className(),
|
|
'rules' => [
|
|
// allow authenticated users
|
|
[
|
|
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ],
|
|
'allow' => true,
|
|
'roles' => ['admin','employee','reception'],
|
|
],
|
|
// everything else is denied
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* Lists all Transfer models.
|
|
* @return mixed
|
|
*/
|
|
public function actionIndex()
|
|
{
|
|
$searchModel = new TransferSearch();
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
$accounts = Account::read();
|
|
|
|
$searchModel->totalsTransfers();
|
|
|
|
$users = User::read();
|
|
|
|
return $this->render('index', [
|
|
'searchModel' => $searchModel,
|
|
'dataProvider' => $dataProvider,
|
|
'accounts' => $accounts,
|
|
'users' => $users,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Lists all Transfer models.
|
|
* @return mixed
|
|
*/
|
|
public function actionList()
|
|
{
|
|
$searchModel = new TransferListSearch();
|
|
$searchModel->accounts = Account::read();
|
|
$searchModel->users = User::read();
|
|
|
|
$searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
|
|
return $this->render('list', [
|
|
'searchModel' => $searchModel,
|
|
]);
|
|
|
|
}
|
|
|
|
/**
|
|
* Lists all Transfer models.
|
|
* @return mixed
|
|
*/
|
|
public function actionSale()
|
|
{
|
|
$searchModel = new TransferSaleSearch();
|
|
$searchModel->accounts = Account::read();
|
|
$searchModel->users = User::read();
|
|
$searchModel->productCategories = ProductCategory::read();
|
|
$searchModel->productOptions = Product::read();
|
|
|
|
$searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
|
|
return $this->render('sale', [
|
|
'searchModel' => $searchModel,
|
|
]);
|
|
|
|
}
|
|
|
|
public function actionSalePdf(){
|
|
$searchModel = new TransferSaleSearch();
|
|
$searchModel->accounts = Account::read();
|
|
$searchModel->users = User::read();
|
|
$searchModel->productCategories = ProductCategory::read();
|
|
$searchModel->productOptions = Product::read();
|
|
|
|
$searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
|
|
$mpdf=new \mPDF('utf-8', 'A4-L');
|
|
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
|
|
'searchModel' => $searchModel,
|
|
]));
|
|
$mpdf->Output('MyPDF.pdf', 'D');
|
|
exit;
|
|
|
|
}
|
|
|
|
/**
|
|
* Lists all Transfer models.
|
|
* @return mixed
|
|
*/
|
|
public function actionSummary()
|
|
{
|
|
$searchModel = new TransferSummarySearch();
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
$accounts = Account::read();
|
|
|
|
$users = User::read();
|
|
|
|
return $this->render('summary', [
|
|
'searchModel' => $searchModel,
|
|
'dataProvider' => $dataProvider,
|
|
'accounts' => $accounts,
|
|
'users' => $users,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Displays a single Transfer model.
|
|
* @param integer $id
|
|
* @return mixed
|
|
*/
|
|
public function actionView($id)
|
|
{
|
|
return $this->render('view', [
|
|
'model' => $this->findModel($id),
|
|
]);
|
|
}
|
|
|
|
|
|
/**
|
|
* Updates an existing Transfer model.
|
|
* If update is successful, the browser will be redirected to the 'view' page.
|
|
* @param integer $id
|
|
* @return mixed
|
|
public function actionUpdate($id)
|
|
{
|
|
$model = $this->findModel($id);
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
return $this->redirect(['view', 'id' => $model->id_transfer]);
|
|
} else {
|
|
return $this->render('update', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
}
|
|
|
|
*/
|
|
|
|
/**
|
|
* Finds the Transfer model based on its primary key value.
|
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
|
* @param integer $id
|
|
* @return Transfer the loaded model
|
|
* @throws NotFoundHttpException if the model cannot be found
|
|
*/
|
|
protected function findModel($id)
|
|
{
|
|
if (($model = Transfer::findOne($id)) !== null) {
|
|
return $model;
|
|
} else {
|
|
throw new NotFoundHttpException('The requested page does not exist.');
|
|
}
|
|
}
|
|
}
|