add hidden account, cart insert/delete
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
This commit is contained in:
@@ -11,6 +11,14 @@ use yii\filters\VerbFilter;
|
||||
use frontend\models\TransferMoneyMovementSearch;
|
||||
use common\models\Account;
|
||||
use frontend\models\TransferListSearch;
|
||||
use common\models\ShoppingCart;
|
||||
use common\models\UserSoldItem;
|
||||
use common\models\TransferSaleSearch;
|
||||
use common\models\User;
|
||||
use common\models\ProductCategory;
|
||||
use common\models\Product;
|
||||
use common\models\TransferTicketSearch;
|
||||
use common\models\TicketType;
|
||||
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
@@ -24,8 +32,21 @@ class TransferController extends Controller
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
'payout' => ['post'],
|
||||
],
|
||||
],
|
||||
'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
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -154,6 +175,38 @@ class TransferController extends Controller
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Deletes an existing Transfer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionPayout($id)
|
||||
{
|
||||
$transfer = $this->findModel($id);
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction();
|
||||
try {
|
||||
$transfer->status = Transfer::STATUS_PAID;
|
||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
if ( $transfer->save() ){
|
||||
\Yii::$app->session->setFlash( 'success','Tranzakció kifizetve' );
|
||||
$transaction->commit();
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
\Yii::$app->session->setFlash( 'danger','Tranzakció kifizetése nem sikerült' );
|
||||
}
|
||||
|
||||
|
||||
return $this->redirect(Yii::$app->request->referrer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Transfer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
@@ -166,6 +219,8 @@ class TransferController extends Controller
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction();
|
||||
try {
|
||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
if ( $transfer->delete() ){
|
||||
\Yii::$app->session->setFlash( 'success','Tranzakció törölve' );
|
||||
$transaction->commit();
|
||||
@@ -181,4 +236,103 @@ class TransferController extends Controller
|
||||
|
||||
return $this->redirect(Yii::$app->request->referrer);
|
||||
}
|
||||
|
||||
|
||||
protected function delete($id){
|
||||
$transfer = $this->findModel($id);
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction();
|
||||
try {
|
||||
if ( $transfer->delete() ){
|
||||
\Yii::$app->session->setFlash( 'success','Tranzakció törölve' );
|
||||
$transaction->commit();
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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('eladasaim.pdf', 'D');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionTickets()
|
||||
{
|
||||
$searchModel = new TransferTicketSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
return $this->render('tickets', [
|
||||
'searchModel' => $searchModel,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function actionTicketsPdf(){
|
||||
$searchModel = new TransferTicketSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||
$mpdf->WriteHTML($this->renderPartial('_result_ticket', [
|
||||
'searchModel' => $searchModel,
|
||||
]));
|
||||
$mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D');
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user