update mpdf lib version from 6 to 8

This commit is contained in:
Schneider Roland 2022-12-27 14:42:55 +01:00
parent ac21048f95
commit f848b34245
13 changed files with 901 additions and 489 deletions

View File

@ -2,6 +2,7 @@
namespace backend\controllers; namespace backend\controllers;
use Mpdf\Mpdf;
use Yii; use Yii;
use common\models\AccountState; use common\models\AccountState;
use backend\models\AccountStateSearch; use backend\models\AccountStateSearch;
@ -11,6 +12,7 @@ use yii\filters\VerbFilter;
use common\models\Account; use common\models\Account;
use common\models\User; use common\models\User;
use common\components\DailyListing; use common\components\DailyListing;
use common\components\MpdfUtil;
/** /**
* AccountStateController implements the CRUD actions for AccountState model. * AccountStateController implements the CRUD actions for AccountState model.
@ -35,7 +37,7 @@ class AccountStateController extends \backend\controllers\BackendController
], ],
]; ];
} }
/** /**
* Lists all AccountState models. * Lists all AccountState models.
* @return mixed * @return mixed
@ -47,8 +49,8 @@ class AccountStateController extends \backend\controllers\BackendController
$accounts = Account::read(); $accounts = Account::read();
$users = User::read(); $users = User::read();
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
@ -73,7 +75,7 @@ class AccountStateController extends \backend\controllers\BackendController
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' ); $output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
$details = null; $details = null;
if ($accountState->isTypeClose ()) { if ($accountState->isTypeClose ()) {
$prev; $prev;
if ($accountState->type == AccountState::TYPE_CLOSE) { if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) { if (isset ( $accountState->prev_state )) {
@ -85,38 +87,38 @@ class AccountStateController extends \backend\controllers\BackendController
} }
$details = new DailyListing(); $details = new DailyListing();
$details->loadAccountState ( $accountState ); $details->loadAccountState ( $accountState );
$details->readTotalEasy (); $details->readTotalEasy ();
$details->readTotalDetailed (); $details->readTotalDetailed ();
$details->readTotalMedium (); $details->readTotalMedium ();
} }
if ($output == 'pdf') { if ($output == 'pdf') {
$user = User::findOne(\Yii::$app->user->id); $user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->useSubstitutions=false; $mpdf->useSubstitutions=false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) ); $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
$mpdf->setFooter('{PAGENO} / {nb}'); $mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [ $mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
'model' => $accountState, 'model' => $accountState,
'details' => $details 'details' => $details
])); ]));
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras"; $type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username; $dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$fn= $type .$dt.".pdf"; $fn= $type .$dt.".pdf";
$mpdf->Output($fn, 'D'); $mpdf->Output($fn, 'D');
} else { } else {
return $this->render ( 'view', [ return $this->render ( 'view', [
'model' => $accountState, 'model' => $accountState,
'details' => $details 'details' => $details
] ); ] );
} }
} }
@ -158,7 +160,7 @@ class AccountStateController extends \backend\controllers\BackendController
} }
} }
/** /**
* Deletes an existing AccountState model. * Deletes an existing AccountState model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
@ -168,27 +170,27 @@ class AccountStateController extends \backend\controllers\BackendController
*/ */
public function actionDelete($id) { public function actionDelete($id) {
$model = $this->findModel ( $id ); $model = $this->findModel ( $id );
$delete = true; $delete = true;
if ( $model->isTypeOpen() ){ if ( $model->isTypeOpen() ){
$closeStates = AccountState::find()->andWhere( ['prev_state' => $model->id_account_state] )->all(); $closeStates = AccountState::find()->andWhere( ['prev_state' => $model->id_account_state] )->all();
if ( count($closeStates) > 0){ if ( count($closeStates) > 0){
$delete = false; $delete = false;
\Yii::$app->session->setFlash('error', ['Nem lehet törölni a nyitást, mert van kapcsolódó zárás!']); \Yii::$app->session->setFlash('error', ['Nem lehet törölni a nyitást, mert van kapcsolódó zárás!']);
throw new \Exception('Nem lehet törölni a nyitást, mert van kapcsolódó zárás!'); throw new \Exception('Nem lehet törölni a nyitást, mert van kapcsolódó zárás!');
} }
} }
if ( $delete == true ){ if ( $delete == true ){
$model->delete(); $model->delete();
\Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' ); \Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
} }
return $this->redirect ( ["index"] ); return $this->redirect ( ["index"] );
} }
/** /**
* Deletes an existing AccountState model. * Deletes an existing AccountState model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.

View File

@ -4,6 +4,7 @@ namespace backend\controllers;
use common\models\Log; use common\models\Log;
use common\models\Transfer; use common\models\Transfer;
use Mpdf\Mpdf;
use Yii; use Yii;
use common\models\Ticket; use common\models\Ticket;
use backend\models\TicketSearch; use backend\models\TicketSearch;
@ -27,19 +28,20 @@ use yii\helpers\VarDumper;
use backend\models\TicketUpdate; use backend\models\TicketUpdate;
use yii\helpers\Url; use yii\helpers\Url;
use common\components\Helper; use common\components\Helper;
use common\components\MpdfUtil;
/** /**
* TicketController implements the CRUD actions for Ticket model. * TicketController implements the CRUD actions for Ticket model.
*/ */
class TicketController extends \backend\controllers\BackendController { class TicketController extends \backend\controllers\BackendController {
public function behaviors() { public function behaviors() {
return [ return [
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className (), 'class' => \yii\filters\AccessControl::className (),
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'actions' => [ 'actions' => [
'create', 'create',
'index', 'index',
'view', 'view',
@ -49,22 +51,22 @@ class TicketController extends \backend\controllers\BackendController {
'test' 'test'
], ],
'allow' => true, 'allow' => true,
'roles' => [ 'roles' => [
'admin', 'admin',
'employee', 'employee',
'reception' 'reception'
] ]
] ]
] ]
// everything else is denied // everything else is denied
] ]
]; ];
} }
/** /**
* Lists all Ticket models. * Lists all Ticket models.
* *
* @return mixed * @return mixed
*/ */
public function actionIndex() { public function actionIndex() {
@ -82,10 +84,10 @@ class TicketController extends \backend\controllers\BackendController {
}else if ( $searchModel->output == 'xls'){ }else if ( $searchModel->output == 'xls'){
return $this->downloadIndexXls($searchModel,$dataProvider); return $this->downloadIndexXls($searchModel,$dataProvider);
} }
return $this->render ( 'index', [ return $this->render ( 'index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ); ] );
} }
@ -292,7 +294,7 @@ class TicketController extends \backend\controllers\BackendController {
$fileName = "berletek"; $fileName = "berletek";
$fileName .= "_" . date ( "Ymd_His" ); $fileName .= "_" . date ( "Ymd_His" );
$fileName .= ".pdf"; $fileName .= ".pdf";
$mpdf = new \mPDF ( 'utf-8', 'A4' ); $mpdf = MpdfUtil::createMpdfWith6XConstructor( 'utf-8', 'A4' );
$mpdf->useSubstitutions = false; $mpdf->useSubstitutions = false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
@ -316,24 +318,24 @@ class TicketController extends \backend\controllers\BackendController {
] ); ] );
*/ */
} }
/** /**
* Lists all Ticket models. * Lists all Ticket models.
* *
* @return mixed * @return mixed
*/ */
public function actionStatistics() { public function actionStatistics() {
$searchModel = new TicketSearchStatisitcs(); $searchModel = new TicketSearchStatisitcs();
$searchModel->search ( Yii::$app->request->queryParams ); $searchModel->search ( Yii::$app->request->queryParams );
$searchModel->searchTotals (); $searchModel->searchTotals ();
$searchModel->users = User::read (); $searchModel->users = User::read ();
$searchModel->accounts = Account::read (); $searchModel->accounts = Account::read ();
$searchModel->ticketTypes = TicketType::read (); $searchModel->ticketTypes = TicketType::read ();
if ($searchModel->output == 'pdf') { if ($searchModel->output == 'pdf') {
$user = User::findOne ( \Yii::$app->user->id ); $user = User::findOne ( \Yii::$app->user->id );
$mpdf = new \mPDF ( 'utf-8', 'A4-L' ); $mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = ""; $fn = "";
$ov = '_total_content_pdf'; $ov = '_total_content_pdf';
$dt = "_letrehozva_" . date ( "Ymd_His" ) . "_" . $user->username; $dt = "_letrehozva_" . date ( "Ymd_His" ) . "_" . $user->username;
@ -341,24 +343,24 @@ class TicketController extends \backend\controllers\BackendController {
$account = ""; $account = "";
$currentUser = ""; $currentUser = "";
$fn = $fn . $interval . $dt . $account . $currentUser . ".pdf"; $fn = $fn . $interval . $dt . $account . $currentUser . ".pdf";
$mpdf->useSubstitutions = false; $mpdf->useSubstitutions = false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader ( \Yii::$app->params ["company_name"] . " - Létrehozva: " . $user->username . ", " . \Yii::$app->formatter->asDatetime ( time () ) ); $mpdf->SetHeader ( \Yii::$app->params ["company_name"] . " - Létrehozva: " . $user->username . ", " . \Yii::$app->formatter->asDatetime ( time () ) );
$mpdf->setFooter ( '{PAGENO} / {nb}' ); $mpdf->setFooter ( '{PAGENO} / {nb}' );
$stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css $stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css
$mpdf->WriteHTML ( $stylesheet, 1 ); $mpdf->WriteHTML ( $stylesheet, 1 );
$mpdf->WriteHTML ( $this->renderPartial ( 'statistics_pdf', [ $mpdf->WriteHTML ( $this->renderPartial ( 'statistics_pdf', [
'searchModel' => $searchModel 'searchModel' => $searchModel
] ) ); ] ) );
$mpdf->Output ( $fn, 'D' ); $mpdf->Output ( $fn, 'D' );
exit (); exit ();
} else { } else {
return $this->render ( 'statistics', [ return $this->render ( 'statistics', [
'searchModel' => $searchModel 'searchModel' => $searchModel
] ); ] );
} }
} }
@ -373,91 +375,91 @@ class TicketController extends \backend\controllers\BackendController {
public function actionIndexCustomer($id) { public function actionIndexCustomer($id) {
$customer = Customer::findOne ( $id ); $customer = Customer::findOne ( $id );
$card = Card::findOne ( $id ); $card = Card::findOne ( $id );
if ($customer == null) { if ($customer == null) {
throw new NotFoundHttpException ( 'The requested page does not exist.' ); throw new NotFoundHttpException ( 'The requested page does not exist.' );
} }
$searchModel = new TicketSearchCustomer(['customer' => $customer]); $searchModel = new TicketSearchCustomer(['customer' => $customer]);
$searchModel->id_card = $customer->id_customer_card; $searchModel->id_card = $customer->id_customer_card;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
//$searchModel->searchTotals (); //$searchModel->searchTotals ();
$searchModel->users = User::read (); $searchModel->users = User::read ();
$searchModel->accounts = Account::read (); $searchModel->accounts = Account::read ();
$searchModel->ticketTypes = TicketType::read (); $searchModel->ticketTypes = TicketType::read ();
Url::remember(Url::current(),"ticket_index_customer"); Url::remember(Url::current(),"ticket_index_customer");
return $this->render ( 'index_customer', [ return $this->render ( 'index_customer', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'customer' => $customer, 'customer' => $customer,
'card' => $card 'card' => $card
] ); ] );
} }
/** /**
* Displays a single Ticket model. * Displays a single Ticket model.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionView($id) { public function actionView($id) {
return $this->render ( 'view', [ return $this->render ( 'view', [
'model' => $this->findModel ( $id ) 'model' => $this->findModel ( $id )
] ); ] );
} }
/** /**
* Creates a new Ticket model. * Creates a new Ticket model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
* *
* @return mixed * @return mixed
*/ */
public function actionCreate() { public function actionCreate() {
$model = new Ticket (); $model = new Ticket ();
$discounts = Discount::read (); $discounts = Discount::read ();
$ticketTypes = TicketType::read (); $ticketTypes = TicketType::read ();
$accounts = Account::readAccounts (); $accounts = Account::readAccounts ();
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_ticket 'id' => $model->id_ticket
] ); ] );
} else { } else {
return $this->render ( 'create', [ return $this->render ( 'create', [
'model' => $model, 'model' => $model,
'discounts' => $discounts, 'discounts' => $discounts,
'ticketTypes' => $ticketTypes, 'ticketTypes' => $ticketTypes,
'accounts' => $accounts 'accounts' => $accounts
] ); ] );
} }
} }
/** /**
* Updates an existing Ticket model. * Updates an existing Ticket model.
* If update is successful, the browser will be redirected to the 'view' page. * If update is successful, the browser will be redirected to the 'view' page.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionUpdate($id) { public function actionUpdate($id) {
$model = TicketUpdate::findOne( $id ); $model = TicketUpdate::findOne( $id );
$model->startDate = substr( $model->start ,0 ,10 ); $model->startDate = substr( $model->start ,0 ,10 );
$model->endDate = substr( $model->end ,0 ,10 ); $model->endDate = substr( $model->end ,0 ,10 );
$model->startDate = \Yii::$app->formatter->asDate($model->startDate); $model->startDate = \Yii::$app->formatter->asDate($model->startDate);
$model->endDate = \Yii::$app->formatter->asDate($model->endDate); $model->endDate = \Yii::$app->formatter->asDate($model->endDate);
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
@ -468,66 +470,66 @@ class TicketController extends \backend\controllers\BackendController {
]); ]);
Helper::flash("success", "Bérlet sikeresen módosítva"); Helper::flash("success", "Bérlet sikeresen módosítva");
$url = Url::previous("ticket_index_customer"); $url = Url::previous("ticket_index_customer");
if ( isset($url) ){ if ( isset($url) ){
return $this->redirect($url); return $this->redirect($url);
} }
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_ticket 'id' => $model->id_ticket
] ); ] );
} else { } else {
return $this->render ( 'update', [ return $this->render ( 'update', [
'model' => $model 'model' => $model
] ); ] );
} }
} }
/** /**
* Deletes an existing Ticket model. * Deletes an existing Ticket model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionDelete($id) { public function actionDelete($id) {
$this->findModel ( $id )->delete (); $this->findModel ( $id )->delete ();
return $this->redirect ( [ return $this->redirect ( [
'index' 'index'
] ); ] );
} }
public function actionTest(){ public function actionTest(){
// $this->doTestTicketSale(); // $this->doTestTicketSale();
$this->doTestDetstaProcess(); $this->doTestDetstaProcess();
return $this->render('test'); return $this->render('test');
} }
protected function doTestDetstaProcess(){ protected function doTestDetstaProcess(){
$contract = Contract::findOne(19); $contract = Contract::findOne(19);
$megbizas = $contract->requests[0]; $megbizas = $contract->requests[0];
$tetel = new GiroDETSTATetel(); $tetel = new GiroDETSTATetel();
$tetel->visszajelzesInformacio = "02"; $tetel->visszajelzesInformacio = "02";
$tp = new DetStatTetelProcessor([ $tp = new DetStatTetelProcessor([
'megbizas' => $megbizas, 'megbizas' => $megbizas,
'tetel' => $tetel 'tetel' => $tetel
]); ]);
$tp->run(); $tp->run();
} }
protected function doTestTicketSale(){ protected function doTestTicketSale(){
$ticketType = TicketType::findOne(1); $ticketType = TicketType::findOne(1);
$customer = Customer::findOne(1); $customer = Customer::findOne(1);
@ -536,9 +538,9 @@ class TicketController extends \backend\controllers\BackendController {
$discount = null; $discount = null;
$contract = Contract::findOne(19); $contract = Contract::findOne(19);
$megbizas = $contract->requests[0]; $megbizas = $contract->requests[0];
$ticketSale = new TicketSale( $ticketSale = new TicketSale(
[ [
'ticketType'=> $ticketType, 'ticketType'=> $ticketType,
@ -550,15 +552,15 @@ class TicketController extends \backend\controllers\BackendController {
'ticketInstallmentRequest' => $megbizas 'ticketInstallmentRequest' => $megbizas
] ]
); );
$ticketSale->doSale(); $ticketSale->doSale();
} }
/** /**
* Finds the Ticket model based on its primary key value. * Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
* *
* @param integer $id * @param integer $id
* @return Ticket the loaded model * @return Ticket the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */

View File

@ -21,6 +21,7 @@ use backend\models\TransferListUserGroupedSearch;
use backend\models\TransferLaterSearch; use backend\models\TransferLaterSearch;
use yii\helpers\Url; use yii\helpers\Url;
use common\components\Helper; use common\components\Helper;
use common\components\MpdfUtil;
/** /**
* TransferController implements the CRUD actions for Transfer model. * TransferController implements the CRUD actions for Transfer model.
@ -66,23 +67,23 @@ class TransferController extends \backend\controllers\BackendController
], ],
]; ];
} }
public function actionPaymentLater(){ public function actionPaymentLater(){
$searchModel = new TransferLaterSearch(); $searchModel = new TransferLaterSearch();
if ( \Yii::$app->request->isPost){ if ( \Yii::$app->request->isPost){
$searchModel->load(Yii::$app->request->post()); $searchModel->load(Yii::$app->request->post());
if ( $searchModel->doPayout()) { if ( $searchModel->doPayout()) {
return $this->redirect(['transfer/payment-later' ]); return $this->redirect(['transfer/payment-later' ]);
} }
} }
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if ( $searchModel->output =='pdf'){ if ( $searchModel->output =='pdf'){
$this->downloadPaymentLaterPDF($dataProvider); $this->downloadPaymentLaterPDF($dataProvider);
}else if ( $searchModel->output =='xls'){ }else if ( $searchModel->output =='xls'){
@ -91,9 +92,9 @@ class TransferController extends \backend\controllers\BackendController
$accounts = Account::read(); $accounts = Account::read();
$users = User::read(); $users = User::read();
Url::remember("payment_later",Url::current()); Url::remember("payment_later",Url::current());
return $this->render('payment_later', [ return $this->render('payment_later', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
@ -245,31 +246,31 @@ class TransferController extends \backend\controllers\BackendController
exit (); exit ();
} }
protected function downloadPaymentLaterPDF($dataProvider) { protected function downloadPaymentLaterPDF($dataProvider) {
// $mpdf = new \mPDF ( 'utf-8', 'A4' ); // $mpdf = new \mPDF ( 'utf-8', 'A4' );
$mpdf = new \mPDF ( 'utf-8', 'A4-L' ); $mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = "utolagos_fizetesek.pdf"; $fn = "utolagos_fizetesek.pdf";
$mpdf->useSubstitutions = false; $mpdf->useSubstitutions = false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader ( "" ); $mpdf->SetHeader ( "" );
$mpdf->setFooter ( '{PAGENO} / {nb}' ); $mpdf->setFooter ( '{PAGENO} / {nb}' );
$stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css $stylesheet = file_get_contents ( \Yii::getAlias ( '@vendor' . '/bower/bootstrap/dist/css/bootstrap.css' ) ); // external css
$mpdf->WriteHTML ( $stylesheet, 1 ); $mpdf->WriteHTML ( $stylesheet, 1 );
$mpdf->WriteHTML ( $this->renderPartial ( '_pdf_payment_later.php', [ $mpdf->WriteHTML ( $this->renderPartial ( '_pdf_payment_later.php', [
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ) ); ] ) );
$mpdf->Output ( $fn, 'D' ); $mpdf->Output ( $fn, 'D' );
exit (); exit ();
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -278,7 +279,7 @@ class TransferController extends \backend\controllers\BackendController
{ {
$searchModel = new TransferSearch(); $searchModel = new TransferSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$accounts = Account::read(); $accounts = Account::read();
$searchModel->totalsTransfers(); $searchModel->totalsTransfers();
$users = User::read(); $users = User::read();
@ -293,7 +294,7 @@ class TransferController extends \backend\controllers\BackendController
'accounts' => $accounts, 'accounts' => $accounts,
'users' => $users, 'users' => $users,
]); ]);
} }
/** /**
@ -446,23 +447,23 @@ class TransferController extends \backend\controllers\BackendController
$searchModel = new TransferListSearch(); $searchModel = new TransferListSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
if ( $searchModel->output === 'pdf'){ if ( $searchModel->output === 'pdf'){
$user = User::findOne(\Yii::$app->user->id); $user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$fn = ""; $fn = "";
$ov = '_total_content_pdf'; $ov = '_total_content_pdf';
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username; $dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$interval=""; $interval="";
$account = ""; $account = "";
$currentUser= ""; $currentUser= "";
if ( isset($searchModel->currentAccount) ){ if ( isset($searchModel->currentAccount) ){
$account =( "_kassza_".$searchModel->currentAccount->name); $account =( "_kassza_".$searchModel->currentAccount->name);
} }
if ( isset($searchModel->currentUser) ){ if ( isset($searchModel->currentUser) ){
$currentUser = ( "_felhasznalo_".$searchModel->currentUser->username); $currentUser = ( "_felhasznalo_".$searchModel->currentUser->username);
} }
@ -486,15 +487,15 @@ class TransferController extends \backend\controllers\BackendController
$fn="napi_bevetelek.teljes"; $fn="napi_bevetelek.teljes";
} }
$fn = $fn. $interval . $dt .$account .$currentUser. ".pdf"; $fn = $fn. $interval . $dt .$account .$currentUser. ".pdf";
$mpdf->useSubstitutions=false; $mpdf->useSubstitutions=false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) ); $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
$mpdf->setFooter('{PAGENO} / {nb}'); $mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial($ov, [ $mpdf->WriteHTML($this->renderPartial($ov, [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
])); ]));
@ -505,10 +506,10 @@ class TransferController extends \backend\controllers\BackendController
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -518,16 +519,16 @@ class TransferController extends \backend\controllers\BackendController
$searchModel = new TransferListUserGroupedSearch(); $searchModel = new TransferListUserGroupedSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
return $this->render('list_user_grouped', [ return $this->render('list_user_grouped', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -540,16 +541,16 @@ class TransferController extends \backend\controllers\BackendController
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read(); $searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read(); $searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
return $this->render('sale', [ return $this->render('sale', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
public function actionSalePdf(){ public function actionSalePdf(){
$searchModel = new TransferSaleSearch(); $searchModel = new TransferSaleSearch();
$searchModel->mode = 'admin'; $searchModel->mode = 'admin';
@ -557,11 +558,11 @@ class TransferController extends \backend\controllers\BackendController
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read(); $searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read(); $searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial('_result_sale', [ $mpdf->WriteHTML($this->renderPartial('_result_sale', [
@ -569,9 +570,9 @@ class TransferController extends \backend\controllers\BackendController
])); ]));
$mpdf->Output('MyPDF.pdf', 'D'); $mpdf->Output('MyPDF.pdf', 'D');
exit; exit;
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -580,11 +581,11 @@ class TransferController extends \backend\controllers\BackendController
{ {
$searchModel = new TransferSummarySearch(); $searchModel = new TransferSummarySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$accounts = Account::read(); $accounts = Account::read();
$users = User::read(); $users = User::read();
return $this->render('summary', [ return $this->render('summary', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
@ -592,7 +593,7 @@ class TransferController extends \backend\controllers\BackendController
'users' => $users, 'users' => $users,
]); ]);
} }
/** /**
* Displays a single Transfer model. * Displays a single Transfer model.
* @param integer $id * @param integer $id
@ -604,16 +605,16 @@ class TransferController extends \backend\controllers\BackendController
'model' => $this->findModel($id), 'model' => $this->findModel($id),
]); ]);
} }
public function actionUnstorno($id) public function actionUnstorno($id)
{ {
$model = $this->findModel($id); $model = $this->findModel($id);
$model->unstorono(); $model->unstorono();
Helper::flash("success", "Bérlet visszaállítva"); Helper::flash("success", "Bérlet visszaállítva");
return $this->redirect( ['view' ,'id' => $model->id_transfer]); return $this->redirect( ['view' ,'id' => $model->id_transfer]);
} }

View File

@ -10,6 +10,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use common\components\DetStatProcessor; use common\components\DetStatProcessor;
use common\components\MpdfUtil;
use backend\models\DestaUploadForm; use backend\models\DestaUploadForm;
use yii\web\UploadedFile; use yii\web\UploadedFile;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;
@ -23,71 +24,71 @@ use common\models\MessageDetsta;
*/ */
class UgiroController extends Controller { class UgiroController extends Controller {
public function behaviors() { public function behaviors() {
return [ return [
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className (), 'class' => VerbFilter::className (),
'actions' => [ 'actions' => [
'delete' => [ 'delete' => [
'post' 'post'
] ]
] ]
], ],
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className (), 'class' => \yii\filters\AccessControl::className (),
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'actions' => [ ], 'actions' => [ ],
'allow' => true, 'allow' => true,
'roles' => [ 'roles' => [
'admin', 'admin',
'employee', 'employee',
'reception' 'reception'
] ]
] ]
] ]
] ]
// everything else is denied // everything else is denied
]; ];
} }
/** /**
* Lists all Ugiro models. * Lists all Ugiro models.
* *
* @return mixed * @return mixed
*/ */
public function actionIndex() { public function actionIndex() {
$searchModel = new UgiroSearch (); $searchModel = new UgiroSearch ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render ( 'index', [ return $this->render ( 'index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ); ] );
} }
/** /**
* Lists all Ugiro models. * Lists all Ugiro models.
* *
* @return mixed * @return mixed
*/ */
public function actionItems($id) { public function actionItems($id) {
$searchModel = new UgiroSearch (); $searchModel = new UgiroSearch ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render ( 'index', [ return $this->render ( 'index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ); ] );
} }
public function actionActivate() { public function actionActivate() {
} }
/** /**
* Displays a single Ugiro model. * Displays a single Ugiro model.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionView($id) { public function actionView($id) {
@ -95,8 +96,8 @@ class UgiroController extends Controller {
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
if ($model->status == Ugiro::$STATUS_RECIEVED) { if ($model->status == Ugiro::$STATUS_RECIEVED) {
set_time_limit ( 1200 ); // 20 perc set_time_limit ( 1200 ); // 20 perc
$processor = new DetStatProcessor ( [ $processor = new DetStatProcessor ( [
'koteg' => $model 'koteg' => $model
] ); ] );
$processor->run (); $processor->run ();
$this->redirect(['view', 'id' => $model->id_ugiro]); $this->redirect(['view', 'id' => $model->id_ugiro]);
@ -107,7 +108,7 @@ class UgiroController extends Controller {
} else { } else {
if (isset ( $_GET ['output'] )) { if (isset ( $_GET ['output'] )) {
$output = $_GET ['output']; $output = $_GET ['output'];
if ($output == 'pdf') { if ($output == 'pdf') {
$this->downloadUgiroPdf ( $model ); $this->downloadUgiroPdf ( $model );
}else if ($output == 'xls') { }else if ($output == 'xls') {
@ -115,18 +116,18 @@ class UgiroController extends Controller {
} }
} }
} }
$query = MessageDetsta::find(); $query = MessageDetsta::find();
$query->andWhere(['id_ugiro' => $model->id_ugiro]); $query->andWhere(['id_ugiro' => $model->id_ugiro]);
$query->orderBy([ 'created_at' => SORT_ASC ]); $query->orderBy([ 'created_at' => SORT_ASC ]);
$detstaDp = new ActiveDataProvider([ $detstaDp = new ActiveDataProvider([
'query' => $query, 'query' => $query,
'pagination' => false, 'pagination' => false,
'sort' => false 'sort' => false
]); ]);
return $this->render ( 'view', [ return $this->render ( 'view', [
'model' => $this->findModel ( $id ) , 'model' => $this->findModel ( $id ) ,
'detstaDp' => $detstaDp 'detstaDp' => $detstaDp
] ); ] );
@ -136,7 +137,7 @@ class UgiroController extends Controller {
* @param \common\models\Ugiro $model * @param \common\models\Ugiro $model
*/ */
protected function downloadUgiroXls($model) { protected function downloadUgiroXls($model) {
$fn = "köteg.". $model->id_ugiro . ".xls"; $fn = "köteg.". $model->id_ugiro . ".xls";
$query = new Query(); $query = new Query();
@ -159,7 +160,7 @@ class UgiroController extends Controller {
$dataProvider = new ActiveDataProvider( $dataProvider = new ActiveDataProvider(
[ [
'query' => $query, 'query' => $query,
'sort' => false, 'sort' => false,
'pagination' => false 'pagination' => false
] ]
@ -278,11 +279,11 @@ class UgiroController extends Controller {
exit (); exit ();
} }
protected function downloadUgiroPdf($model) { protected function downloadUgiroPdf($model) {
$mpdf = new \mPDF ( 'utf-8', 'A4-L' ); $mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = "köteg.". $model->id_ugiro . ".pdf"; $fn = "köteg.". $model->id_ugiro . ".pdf";
$mpdf->useSubstitutions = false; $mpdf->useSubstitutions = false;
@ -325,99 +326,99 @@ class UgiroController extends Controller {
/** /**
* Creates a new Ugiro model. * Creates a new Ugiro model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
* *
* @return mixed * @return mixed
*/ */
public function actionCreate() { public function actionCreate() {
$model = new Ugiro (); $model = new Ugiro ();
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_ugiro 'id' => $model->id_ugiro
] ); ] );
} else { } else {
return $this->render ( 'create', [ return $this->render ( 'create', [
'model' => $model 'model' => $model
] ); ] );
} }
} }
/** /**
* Updates an existing Ugiro model. * Updates an existing Ugiro model.
* If update is successful, the browser will be redirected to the 'view' page. * If update is successful, the browser will be redirected to the 'view' page.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionUpdate($id) { public function actionUpdate($id) {
$model = $this->findModel ( $id ); $model = $this->findModel ( $id );
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_ugiro 'id' => $model->id_ugiro
] ); ] );
} else { } else {
return $this->render ( 'update', [ return $this->render ( 'update', [
'model' => $model 'model' => $model
] ); ] );
} }
} }
/** /**
* Deletes an existing Ugiro model. * Deletes an existing Ugiro model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionDelete($id) { public function actionDelete($id) {
$this->findModel ( $id )->delete (); $this->findModel ( $id )->delete ();
return $this->redirect ( [ return $this->redirect ( [
'index' 'index'
] ); ] );
} }
public function actionDetsta() { public function actionDetsta() {
$ugiro = Ugiro::findOne ( 31 ); $ugiro = Ugiro::findOne ( 31 );
$model = new DetStatProcessor ( [ $model = new DetStatProcessor ( [
'koteg' => $ugiro 'koteg' => $ugiro
] ); ] );
return $this->render ( 'detsta', [ return $this->render ( 'detsta', [
'model' => $model 'model' => $model
] ); ] );
} }
public function actionUpload() { public function actionUpload() {
$model = new DestaUploadForm (); $model = new DestaUploadForm ();
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
$model->destaFile = UploadedFile::getInstance ( $model, 'destaFile' ); $model->destaFile = UploadedFile::getInstance ( $model, 'destaFile' );
if ($model->upload ()) { if ($model->upload ()) {
// file is uploaded successfully // file is uploaded successfully
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->koteg->id_ugiro 'id' => $model->koteg->id_ugiro
] ); ] );
} }
} }
return $this->render ( 'upload', [ return $this->render ( 'upload', [
'model' => $model 'model' => $model
] ); ] );
} }
public function actionGenerateDetsta() { public function actionGenerateDetsta() {
} }
/** /**
* Finds the Ugiro model based on its primary key value. * Finds the Ugiro model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
* *
* @param integer $id * @param integer $id
* @return Ugiro the loaded model * @return Ugiro the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */

View File

@ -0,0 +1,41 @@
<?php
namespace common\components;
use Mpdf\Mpdf;
use yii\base\BaseObject;
class MpdfUtil extends BaseObject
{
// mpdf version 6 constructor
//function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
public static function createMpdfWith6XConstructor($mode = '', $format = 'A4', $default_font_size = 0, $default_font = '', $mgl = 15, $mgr = 15, $mgt = 16, $mgb = 16, $mgh = 9, $mgf = 9, $orientation = 'P')
{
return self::createMpdf([
'mode' => $mode,
'format' => $format,
'default_font_size' => $default_font_size,
'default_font' => $default_font,
'margin_left' => $mgl,
'margin_right' => $mgr,
'margin_top' => $mgt,
'margin_bottom' => $mgb,
'margin_header' => $mgh,
'margin_footer' => $mgf,
'orientation' => $orientation
]);
}
public static function createMpdf($options = [])
{
$mpdf = new Mpdf(
array_merge([
'mode' => 'utf-8',
'format' => 'A4'
], $options)
);
return $mpdf;
}
}

View File

@ -6,6 +6,7 @@ use common\models\User;
use common\models\Account; use common\models\Account;
use common\models\AccountState; use common\models\AccountState;
use common\components\DailyListing; use common\components\DailyListing;
use common\components\MpdfUtil;
use yii\base\BaseObject; use yii\base\BaseObject;
/** /**
@ -76,7 +77,7 @@ class AccountStateMail extends BaseObject {
protected function attachPdf(){ protected function attachPdf(){
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->useSubstitutions=false; $mpdf->useSubstitutions=false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) ); $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );

View File

@ -27,7 +27,7 @@
"dmstr/yii2-adminlte-asset": "2.*", "dmstr/yii2-adminlte-asset": "2.*",
"bassjobsen/bootstrap-3-typeahead": "^4.0", "bassjobsen/bootstrap-3-typeahead": "^4.0",
"bower-asset/webcamjs": "^1.0", "bower-asset/webcamjs": "^1.0",
"mpdf/mpdf": "^6.0", "mpdf/mpdf": "^8.1",
"os/php-excel": "^2.1", "os/php-excel": "^2.1",
"phpoffice/phpexcel": "^1.8", "phpoffice/phpexcel": "^1.8",
"2amigos/yii2-tinymce-widget": "~1.1", "2amigos/yii2-tinymce-widget": "~1.1",

356
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d1d630cf85ac72b3cb7d161afee070fe", "content-hash": "138d862466e8a155a65957524deabe0f",
"packages": [ "packages": [
{ {
"name": "2amigos/yii2-tinymce-widget", "name": "2amigos/yii2-tinymce-widget",
@ -2200,46 +2200,69 @@
}, },
{ {
"name": "mpdf/mpdf", "name": "mpdf/mpdf",
"version": "v6.0.0", "version": "v8.1.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mpdf/mpdf.git", "url": "https://github.com/mpdf/mpdf.git",
"reference": "a15743d030ce3b5b7be36c6e83f76589b27c3f2c" "reference": "add590e93b7502efafd9839a68cff99f3497b318"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/a15743d030ce3b5b7be36c6e83f76589b27c3f2c", "url": "https://api.github.com/repos/mpdf/mpdf/zipball/add590e93b7502efafd9839a68cff99f3497b318",
"reference": "a15743d030ce3b5b7be36c6e83f76589b27c3f2c", "reference": "add590e93b7502efafd9839a68cff99f3497b318",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-gd": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"php": ">=4.3.10" "myclabs/deep-copy": "^1.7",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"php-http/message-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0",
"setasign/fpdi": "^2.1"
},
"require-dev": {
"mockery/mockery": "^1.3.0",
"mpdf/qrcode": "^1.1.0",
"squizlabs/php_codesniffer": "^3.5.0",
"tracy/tracy": "~2.5",
"yoast/phpunit-polyfills": "^1.0"
},
"suggest": {
"ext-bcmath": "Needed for generation of some types of barcodes",
"ext-xml": "Needed mainly for SVG manipulation",
"ext-zlib": "Needed for compression of embedded resources, such as fonts"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"classmap": [ "psr-4": {
"mpdf.php", "Mpdf\\": "src/"
"classes" }
]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"GPL-1.0+" "GPL-2.0-only"
], ],
"authors": [ "authors": [
{ {
"name": "Ian Back" "name": "Matěj Humpál",
"role": "Developer, maintainer"
},
{
"name": "Ian Back",
"role": "Developer (retired)"
} }
], ],
"description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support", "description": "PHP library generating PDF files from UTF-8 encoded HTML",
"homepage": "http://www.mpdf1.com/mpdf/index.php", "homepage": "https://mpdf.github.io",
"keywords": [ "keywords": [
"pdf", "pdf",
"php", "php",
"utf-8" "utf-8"
], ],
"time": "2015-03-01T10:27:49+00:00" "time": "2022-12-15T11:24:39+00:00"
}, },
{ {
"name": "mrclay/minify", "name": "mrclay/minify",
@ -2286,6 +2309,55 @@
"homepage": "http://code.google.com/p/minify/", "homepage": "http://code.google.com/p/minify/",
"time": "2016-03-08T11:49:57+00:00" "time": "2016-03-08T11:49:57+00:00"
}, },
{
"name": "myclabs/deep-copy",
"version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/collections": "<1.6.8",
"doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": {
"doctrine/collections": "^1.6.8",
"doctrine/common": "^2.13.3 || ^3.2.2",
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
"autoload": {
"files": [
"src/DeepCopy/deep_copy.php"
],
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"time": "2022-03-03T13:19:32+00:00"
},
{ {
"name": "myclabs/php-enum", "name": "myclabs/php-enum",
"version": "1.6.6", "version": "1.6.6",
@ -2415,6 +2487,101 @@
], ],
"time": "2012-05-02T20:42:37+00:00" "time": "2012-05-02T20:42:37+00:00"
}, },
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "php-http/message-factory",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-http/message-factory.git",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"shasum": ""
},
"require": {
"php": ">=5.4",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Factory interfaces for PSR-7 HTTP Message",
"homepage": "http://php-http.org",
"keywords": [
"factory",
"http",
"message",
"stream",
"uri"
],
"time": "2015-12-19T14:08:53+00:00"
},
{ {
"name": "phpoffice/phpexcel", "name": "phpoffice/phpexcel",
"version": "1.8.1", "version": "1.8.1",
@ -2473,6 +2640,103 @@
"abandoned": "phpoffice/phpspreadsheet", "abandoned": "phpoffice/phpspreadsheet",
"time": "2015-05-01T07:00:55+00:00" "time": "2015-05-01T07:00:55+00:00"
}, },
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2021-05-03T11:20:27+00:00"
},
{ {
"name": "rmrevin/yii2-fontawesome", "name": "rmrevin/yii2-fontawesome",
"version": "2.12.2", "version": "2.12.2",
@ -2525,6 +2789,68 @@
], ],
"time": "2015-11-20T09:17:45+00:00" "time": "2015-11-20T09:17:45+00:00"
}, },
{
"name": "setasign/fpdi",
"version": "v2.3.6",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDI.git",
"reference": "6231e315f73e4f62d72b73f3d6d78ff0eed93c31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDI/zipball/6231e315f73e4f62d72b73f3d6d78ff0eed93c31",
"reference": "6231e315f73e4f62d72b73f3d6d78ff0eed93c31",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": "^5.6 || ^7.0 || ^8.0"
},
"conflict": {
"setasign/tfpdf": "<1.31"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"setasign/fpdf": "~1.8",
"setasign/tfpdf": "1.31",
"squizlabs/php_codesniffer": "^3.5",
"tecnickcom/tcpdf": "~6.2"
},
"suggest": {
"setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured."
},
"type": "library",
"autoload": {
"psr-4": {
"setasign\\Fpdi\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Slabon",
"email": "jan.slabon@setasign.com",
"homepage": "https://www.setasign.com"
},
{
"name": "Maximilian Kresse",
"email": "maximilian.kresse@setasign.com",
"homepage": "https://www.setasign.com"
}
],
"description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.",
"homepage": "https://www.setasign.com/fpdi",
"keywords": [
"fpdf",
"fpdi",
"pdf"
],
"time": "2021-02-11T11:37:01+00:00"
},
{ {
"name": "sizeg/yii2-jwt", "name": "sizeg/yii2-jwt",
"version": "v2.0.0", "version": "v2.0.0",

33
doc/composer.md Normal file
View File

@ -0,0 +1,33 @@
# Composer Knowledge base
## upgrade packages
[upgrade.txt](./upgrade.txt)
## use newer github tokens
Edit the composer authentication configuration file ~/.composer/auth.json.
```bash
nano ~/.composer/auth.json
```
Then replace the following.
```json
{
"github-oauth": {
"github.com": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
```
With this (basic auth):
```json
{
"http-basic": {
"github.com": {
"username": "[YOUR-GITHUB-USERNAME]",
"password": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
}
```

View File

@ -31,7 +31,7 @@ RUN pecl update-channels
RUN pecl install mcrypt RUN pecl install mcrypt
RUN apt-get -y install \ RUN apt-get -y install \
# Required by composer # Required by composr
git \ git \
zlib1g-dev \ zlib1g-dev \
--no-install-recommends --no-install-recommends

View File

@ -16,16 +16,17 @@ use common\models\User;
use common\components\accountstate\AccountStateMail; use common\components\accountstate\AccountStateMail;
use common\models\Transfer; use common\models\Transfer;
use common\components\Helper; use common\components\Helper;
use common\components\MpdfUtil;
/** /**
* AccountStateController implements the CRUD actions for AccountState model. * AccountStateController implements the CRUD actions for AccountState model.
*/ */
class AccountStateController extends Controller { class AccountStateController extends Controller {
public function behaviors() { public function behaviors() {
return [ return [
'access' => [ 'access' => [
'class' => \yii\filters\AccessControl::className (), 'class' => \yii\filters\AccessControl::className (),
'only' => [ 'only' => [
'index', 'index',
'open', 'open',
'close', 'close',
@ -34,17 +35,17 @@ class AccountStateController extends Controller {
], ],
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'allow' => true, 'allow' => true,
'roles' => [ 'roles' => [
'@' '@'
] ]
] ]
] ]
] ]
// everything else is denied // everything else is denied
]; ];
} }
@ -60,15 +61,15 @@ class AccountStateController extends Controller {
} }
$searchModel = new AccountstateSearch (); $searchModel = new AccountstateSearch ();
$searchModel->accounts = Account::read (); $searchModel->accounts = Account::read ();
$searchModel->users = User::read (); $searchModel->users = User::read ();
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render ( 'index', [ return $this->render ( 'index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ); ] );
} }
@ -98,38 +99,38 @@ class AccountStateController extends Controller {
public function actionOpen() { public function actionOpen() {
$lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE ); $lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE );
$lastStates = AccountState::modelsToArray ( $lastStates ); $lastStates = AccountState::modelsToArray ( $lastStates );
$model = new AccountState (); $model = new AccountState ();
$model->type = AccountState::TYPE_OPEN; $model->type = AccountState::TYPE_OPEN;
$model->id_user = Yii::$app->user->id; $model->id_user = Yii::$app->user->id;
$model->id_account = Account::readDefault (); $model->id_account = Account::readDefault ();
$account = Account::readDefaultObject(); $account = Account::readDefaultObject();
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
// return $this->redirect(['view', 'id' => $model->id_account_state]); // return $this->redirect(['view', 'id' => $model->id_account_state]);
if ( Helper::isAccountStateOpenSendMail() ){ if ( Helper::isAccountStateOpenSendMail() ){
$mail = new AccountStateMail(['model' => $model,'controller' => $this]); $mail = new AccountStateMail(['model' => $model,'controller' => $this]);
$mail->sednMail(); $mail->sednMail();
} }
$redirectTo = 'index'; $redirectTo = 'index';
if ( Helper::isReceptionAccountStateIndexToday() ){ if ( Helper::isReceptionAccountStateIndexToday() ){
$redirectTo = 'today'; $redirectTo = 'today';
} }
return $this->redirect ( [ return $this->redirect ( [
$redirectTo $redirectTo
] ); ] );
} else { } else {
$accounts = Account::read (); $accounts = Account::read ();
return $this->render ( 'open', [ return $this->render ( 'open', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, 'accounts' => $accounts,
'lastStates' => $lastStates, 'lastStates' => $lastStates,
@ -151,19 +152,19 @@ class AccountStateController extends Controller {
$model->id_user = Yii::$app->user->id; $model->id_user = Yii::$app->user->id;
$model->id_account = Account::readDefault (); $model->id_account = Account::readDefault ();
$account = Account::readDefaultObject(); $account = Account::readDefaultObject();
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
if ( Helper::isAccountStateClosePreloadMoney()){ if ( Helper::isAccountStateClosePreloadMoney()){
$model->money = $this->readCassaClose(); $model->money = $this->readCassaClose();
} }
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
if ( Helper::isAccountStateCloseSendMail()){ if ( Helper::isAccountStateCloseSendMail()){
$mail = new AccountStateMail(['model' => $model,'controller' => $this]); $mail = new AccountStateMail(['model' => $model,'controller' => $this]);
$mail->sednMail(); $mail->sednMail();
@ -181,10 +182,10 @@ class AccountStateController extends Controller {
] ); ] );
// return $this->redirect(['view', 'id' => $model->id_account_state]); // return $this->redirect(['view', 'id' => $model->id_account_state]);
} else { } else {
$accounts = Account::read (); $accounts = Account::read ();
return $this->render ( 'close', [ return $this->render ( 'close', [
'model' => $model, 'model' => $model,
'accounts' => $accounts, 'accounts' => $accounts,
'account' => $account, 'account' => $account,
@ -193,7 +194,7 @@ class AccountStateController extends Controller {
] ); ] );
} }
} }
protected function readCassaClose(){ protected function readCassaClose(){
$total = 0; $total = 0;
$openDate = null; $openDate = null;
@ -205,12 +206,12 @@ class AccountStateController extends Controller {
$total += Transfer::readPaidCash($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id); $total += Transfer::readPaidCash($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id);
return $total; return $total;
} }
/** /**
* Finds the AccountState model based on its primary key value. * Finds the AccountState model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
* *
* @param integer $id * @param integer $id
* @return AccountState the loaded model * @return AccountState the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */
@ -228,12 +229,12 @@ class AccountStateController extends Controller {
throw new NotFoundHttpException ( 'The requested page does not exist.' ); throw new NotFoundHttpException ( 'The requested page does not exist.' );
} }
} }
/** /**
* Deletes an existing AccountState model. * Deletes an existing AccountState model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
* *
* @param integer $id * @param integer $id
* @return mixed * @return mixed
*/ */
public function actionDelete($id) { public function actionDelete($id) {
@ -264,7 +265,7 @@ class AccountStateController extends Controller {
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' ); $output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
$details = null; $details = null;
if ($accountState->isTypeClose ()) { if ($accountState->isTypeClose ()) {
$prev = null; $prev = null;
if ($accountState->type == AccountState::TYPE_CLOSE) { if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) { if (isset ( $accountState->prev_state )) {
@ -276,53 +277,53 @@ class AccountStateController extends Controller {
} }
$details = new DailyListing (); $details = new DailyListing ();
$details->loadAccountState ( $accountState ); $details->loadAccountState ( $accountState );
$details->readTotalEasy (); $details->readTotalEasy ();
$details->readTotalDetailed (); $details->readTotalDetailed ();
$details->readTotalMedium (); $details->readTotalMedium ();
} }
if ($output == 'pdf') { if ($output == 'pdf') {
$user = User::findOne(\Yii::$app->user->id); $user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->useSubstitutions=false; $mpdf->useSubstitutions=false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) ); $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
$mpdf->setFooter('{PAGENO} / {nb}'); $mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [ $mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
'model' => $accountState, 'model' => $accountState,
'details' => $details 'details' => $details
])); ]));
/** @noinspection SpellCheckingInspection */ /** @noinspection SpellCheckingInspection */
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras"; $type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username; $dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$fn= $type .$dt.".pdf"; $fn= $type .$dt.".pdf";
$mpdf->Output($fn, 'D'); $mpdf->Output($fn, 'D');
exit(0); exit(0);
} else { } else {
return $this->render ( 'view', [ return $this->render ( 'view', [
'model' => $accountState, 'model' => $accountState,
'details' => $details 'details' => $details
] ); ] );
} }
} }
public function actionMixed($id){ public function actionMixed($id){
$accountState = $this->findModel ( $id ); $accountState = $this->findModel ( $id );
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' ); $output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
$details = null; $details = null;
if ($accountState->isTypeClose ()) { if ($accountState->isTypeClose ()) {
$prev = null; $prev = null;
if ($accountState->type == AccountState::TYPE_CLOSE) { if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) { if (isset ( $accountState->prev_state )) {
@ -334,30 +335,30 @@ class AccountStateController extends Controller {
} }
$details = new DailyListing (); $details = new DailyListing ();
$details->loadAccountState ( $accountState ); $details->loadAccountState ( $accountState );
$details->readTotalEasy (); $details->readTotalEasy ();
$details->readTotalDetailed (); $details->readTotalDetailed ();
$details->readTotalMedium (); $details->readTotalMedium ();
} }
if ($output == 'pdf') { if ($output == 'pdf') {
$user = User::findOne(\Yii::$app->user->id); $user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4'); $mpdf=new Mpdf('utf-8', 'A4');
$mpdf->useSubstitutions=false; $mpdf->useSubstitutions=false;
$mpdf->simpleTables = true; $mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) ); $mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
$mpdf->setFooter('{PAGENO} / {nb}'); $mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$stylesheet = file_get_contents( \Yii::getAlias('@frontend'.'/web/css/account_close.css')); // external css $stylesheet = file_get_contents( \Yii::getAlias('@frontend'.'/web/css/account_close.css')); // external css
$mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial("@frontend/views/account-state/mixed_pdf", [ $mpdf->WriteHTML($this->renderPartial("@frontend/views/account-state/mixed_pdf", [
'model' => $accountState, 'model' => $accountState,
'details' => $details 'details' => $details
@ -367,8 +368,8 @@ class AccountStateController extends Controller {
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username; $dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$fn= $type .$dt.".pdf"; $fn= $type .$dt.".pdf";
$mpdf->Output($fn, 'D'); $mpdf->Output($fn, 'D');
exit(); exit();
} }
return $this->render ( 'mixed', [ return $this->render ( 'mixed', [
'model' => $accountState, 'model' => $accountState,

View File

@ -19,27 +19,28 @@ use common\models\Product;
use common\models\ShoppingCart; use common\models\ShoppingCart;
use common\models\Customer; use common\models\Customer;
use frontend\models\ContractForm; use frontend\models\ContractForm;
use common\components\MpdfUtil;
/** /**
* ContractController implements the CRUD actions for Contract model. * ContractController implements the CRUD actions for Contract model.
*/ */
class ContractController extends Controller { class ContractController extends Controller {
public function behaviors() { public function behaviors() {
return [ return [
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className (), 'class' => VerbFilter::className (),
'actions' => [ 'actions' => [
'delete' => [ 'delete' => [
'post' 'post'
], ],
'payout' => [ 'payout' => [
'post' 'post'
], ],
'cancel' => [ 'cancel' => [
'post' 'post'
] ]
] ]
] ]
]; ];
} }
@ -51,18 +52,18 @@ class ContractController extends Controller {
*/ */
public function actionIndex($id_card) { public function actionIndex($id_card) {
$card = Card::findOne ( $id_card ); $card = Card::findOne ( $id_card );
if (! isset ( $card )) if (! isset ( $card ))
throw new NotFoundHttpException ( 'A bérlet nem található' ); throw new NotFoundHttpException ( 'A bérlet nem található' );
$searchModel = new ContractSearch (); $searchModel = new ContractSearch ();
$searchModel->card = $card; $searchModel->card = $card;
$searchModel->customer = $card->customer; $searchModel->customer = $card->customer;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render ( 'index', [ return $this->render ( 'index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider 'dataProvider' => $dataProvider
] ); ] );
} }
@ -77,20 +78,20 @@ class ContractController extends Controller {
$model = $this->findModel ( $id ); $model = $this->findModel ( $id );
$customer = $model->customer; $customer = $model->customer;
$card = $customer->card; $card = $customer->card;
$installments = TicketInstallmentRequest::find ()->andWhere ( [ $installments = TicketInstallmentRequest::find ()->andWhere ( [
'id_contract' => $model->id_contract 'id_contract' => $model->id_contract
] )->orderBy ( [ ] )->orderBy ( [
'ticket_installment_request.priority' => SORT_ASC 'ticket_installment_request.priority' => SORT_ASC
] )->all (); ] )->all ();
return $this->render ( 'view', [ return $this->render ( 'view', [
'model' => $model, 'model' => $model,
'intstallments' => $installments, 'intstallments' => $installments,
'card' => $card 'card' => $card
] ); ] );
} }
/** /**
* Creates a new Contract model. * Creates a new Contract model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
@ -99,15 +100,15 @@ class ContractController extends Controller {
*/ */
public function actionCreate() { public function actionCreate() {
$model = new Contract (); $model = new Contract ();
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_contract 'id' => $model->id_contract
] ); ] );
} else { } else {
return $this->render ( 'create', [ return $this->render ( 'create', [
'model' => $model 'model' => $model
] ); ] );
} }
} }
@ -122,15 +123,15 @@ class ContractController extends Controller {
*/ */
public function actionUpdate($id) { public function actionUpdate($id) {
$model = $this->findModel ( $id ); $model = $this->findModel ( $id );
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) { if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $model->id_contract 'id' => $model->id_contract
] ); ] );
} else { } else {
return $this->render ( 'update', [ return $this->render ( 'update', [
'model' => $model 'model' => $model
] ); ] );
} }
} }
@ -146,12 +147,12 @@ class ContractController extends Controller {
*/ */
public function actionDelete($id) { public function actionDelete($id) {
$this->findModel ( $id )->delete (); $this->findModel ( $id )->delete ();
return $this->redirect ( [ return $this->redirect ( [
'index' 'index'
] ); ] );
} }
/** /**
* EGY RÉSZLET KIFIZETÉSE * EGY RÉSZLET KIFIZETÉSE
*/ */
@ -160,33 +161,33 @@ class ContractController extends Controller {
$contract = $part->contract; $contract = $part->contract;
$customer = $contract->customer; $customer = $contract->customer;
$card = $customer->card; $card = $customer->card;
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
$transaction = $connection->beginTransaction (); $transaction = $connection->beginTransaction ();
try { try {
$result = Transfer::sellContractTicket ( $contract, $part, Account::readDefaultObject (), Transfer::STATUS_NOT_PAID, Transfer::PAYMENT_METHOD_CASH, true ); $result = Transfer::sellContractTicket ( $contract, $part, Account::readDefaultObject (), Transfer::STATUS_NOT_PAID, Transfer::PAYMENT_METHOD_CASH, true );
$transfer = $result [0]; $transfer = $result [0];
$ticket = $result [1]; $ticket = $result [1];
if ($part->status != TicketInstallmentRequest::$STATUS_REJECTED) { if ($part->status != TicketInstallmentRequest::$STATUS_REJECTED) {
$contract->part_required = $contract->part_required + 1; $contract->part_required = $contract->part_required + 1;
} }
$contract->part_paid = $contract->part_paid + 1; $contract->part_paid = $contract->part_paid + 1;
if ($contract->part_paid >= $contract->part_required) { if ($contract->part_paid >= $contract->part_required) {
$contract->status = Contract::$STATUS_PAID; $contract->status = Contract::$STATUS_PAID;
} else { } else {
$contract->status = Contract::$STATUS_NOT_PAID; $contract->status = Contract::$STATUS_NOT_PAID;
} }
$contract->save ( false ); $contract->save ( false );
$part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL; $part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
$part->id_transfer = $transfer->id_transfer; $part->id_transfer = $transfer->id_transfer;
$part->request_processed_at = Helper::getDateTimeString (); $part->request_processed_at = Helper::getDateTimeString ();
$part->id_ticket = $ticket->id_ticket; $part->id_ticket = $ticket->id_ticket;
$part->save ( false ); $part->save ( false );
$transaction->commit (); $transaction->commit ();
\Yii::$app->session->setFlash ( 'success', "Részlet a bevásárló kosárba helyezve!" ); \Yii::$app->session->setFlash ( 'success', "Részlet a bevásárló kosárba helyezve!" );
@ -194,10 +195,10 @@ class ContractController extends Controller {
$transaction->rollback (); $transaction->rollback ();
Yii::error ( "Nem sikerült a kifizetés." ); Yii::error ( "Nem sikerült a kifizetés." );
} }
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $contract->id_contract 'id' => $contract->id_contract
] ); ] );
} }
@ -211,26 +212,26 @@ class ContractController extends Controller {
*/ */
public function actionCancel($id,$flag) { public function actionCancel($id,$flag) {
$contract = $this->findModel ( $id ); $contract = $this->findModel ( $id );
if ( $flag != Contract::$FLAG_CANCELED && $flag != Contract::$FLAG_CANCELED_2){ if ( $flag != Contract::$FLAG_CANCELED && $flag != Contract::$FLAG_CANCELED_2){
\Yii::error("A felmondási státusz nem található! ($flag)"); \Yii::error("A felmondási státusz nem található! ($flag)");
throw new NotFoundHttpException("Az oldal nem található!"); throw new NotFoundHttpException("Az oldal nem található!");
} }
$customer = $contract->customer; $customer = $contract->customer;
$card = $customer->card; $card = $customer->card;
if ($contract->canCancel ()) { if ($contract->canCancel ()) {
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
$transaction = $connection->beginTransaction (); $transaction = $connection->beginTransaction ();
try { try {
$contract->flag = $flag; $contract->flag = $flag;
$contract->save (); $contract->save ();
$requests = $contract->requests; $requests = $contract->requests;
$buntetes = 0; $buntetes = 0;
foreach ( $requests as $request ) { foreach ( $requests as $request ) {
/** @var \common\models\TicketInstallmentRequest $request*/ /** @var \common\models\TicketInstallmentRequest $request*/
if ($request->isStatusAccepted ()) { if ($request->isStatusAccepted ()) {
@ -240,15 +241,15 @@ class ContractController extends Controller {
$request->save ( false ); $request->save ( false );
} }
} }
$productBuntetes = Product::find ()->andWhere ( [ $productBuntetes = Product::find ()->andWhere ( [
'product_number' => Product::$BUNTETES 'product_number' => Product::$BUNTETES
] )->one (); ] )->one ();
// if there is a fee , generate fee and put it to the shopping cart // if there is a fee , generate fee and put it to the shopping cart
if (isset ( $productBuntetes )) { if (isset ( $productBuntetes )) {
if ($buntetes > 0) { if ($buntetes > 0) {
$sale = new Sale (); $sale = new Sale ();
$sale->id_account = Account::readDefault (); $sale->id_account = Account::readDefault ();
$sale->id_product = $productBuntetes->id_product; $sale->id_product = $productBuntetes->id_product;
@ -258,29 +259,29 @@ class ContractController extends Controller {
$sale->count = $buntetes; $sale->count = $buntetes;
$sale->money = $buntetes * $sale->item_price; $sale->money = $buntetes * $sale->item_price;
$sale->id_user = \Yii::$app->user->id; $sale->id_user = \Yii::$app->user->id;
$sale->save ( false ); $sale->save ( false );
$transfer = Transfer::createProductTransfer ( $sale, Account::readDefaultObject (), null, null, $sale->count, $productBuntetes, Transfer::STATUS_NOT_PAID, $customer ); $transfer = Transfer::createProductTransfer ( $sale, Account::readDefaultObject (), null, null, $sale->count, $productBuntetes, Transfer::STATUS_NOT_PAID, $customer );
$transfer->payment_method = Transfer::PAYMENT_METHOD_CASH; $transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
$transfer->id_user = Yii::$app->user->id; $transfer->id_user = Yii::$app->user->id;
$transfer->save ( false ); $transfer->save ( false );
$cart = new ShoppingCart (); $cart = new ShoppingCart ();
$cart->id_customer = $customer->id_customer; $cart->id_customer = $customer->id_customer;
$cart->id_transfer = $transfer->id_transfer; $cart->id_transfer = $transfer->id_transfer;
$cart->save ( false ); $cart->save ( false );
} }
} }
$transaction->commit (); $transaction->commit ();
\Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" ); \Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" );
return $this->redirect ( [ return $this->redirect ( [
'product/sale', 'product/sale',
'number' => $card->number 'number' => $card->number
] ); ] );
} catch ( Exception $e ) { } catch ( Exception $e ) {
$transaction->rollback (); $transaction->rollback ();
@ -289,10 +290,10 @@ class ContractController extends Controller {
} else { } else {
\Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" ); \Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" );
} }
return $this->redirect ( [ return $this->redirect ( [
'view', 'view',
'id' => $contract->id_contract 'id' => $contract->id_contract
] ); ] );
} }
@ -303,31 +304,31 @@ class ContractController extends Controller {
*/ */
public function actionMake($id) { public function actionMake($id) {
$customer = Customer::findOne ( $id ); $customer = Customer::findOne ( $id );
if (! isset ( $customer )) { if (! isset ( $customer )) {
throw new Exception ( "Az oldal nem található" ); throw new Exception ( "Az oldal nem található" );
} }
$model = new ContractForm ( [ $model = new ContractForm ( [
'customer' => $customer , 'customer' => $customer ,
'idUser' => \Yii::$app->user->id, 'idUser' => \Yii::$app->user->id,
'idAccount' => Account::readDefault () 'idAccount' => Account::readDefault ()
] ); ] );
$model->started_at = date(date('Y.m.d')); $model->started_at = date(date('Y.m.d'));
$model->fillOut (); $model->fillOut ();
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) { if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
$transaction = $connection->beginTransaction (); $transaction = $connection->beginTransaction ();
try { try {
$model->make (); $model->make ();
$transaction->commit(); $transaction->commit();
return $this->redirect ( [ return $this->redirect ( [
'contract/view', 'contract/view',
'id' => $model->contract->id_contract 'id' => $model->contract->id_contract
] ); ] );
@ -336,9 +337,9 @@ class ContractController extends Controller {
\Yii::$app->session->setFlash('danger', $e->getMessage()); \Yii::$app->session->setFlash('danger', $e->getMessage());
} }
} }
return $this->render ( '_make_contract', [ return $this->render ( '_make_contract', [
'model' => $model 'model' => $model
] ); ] );
} }
@ -349,16 +350,18 @@ class ContractController extends Controller {
*/ */
public function actionContract($id){ public function actionContract($id){
$model = $this->findModel($id); $model = $this->findModel($id);
// print_r($model);
//$mpdf=new \mPDF('utf-8', 'A4'); //$mpdf=new \mPDF('utf-8', 'A4');
$mpdf=new \mPDF('utf-8','A4','','','15','15','26','18','3'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8','A4','','','15','15','26','18','3');
$mpdf->SetHTMLHeader("<div style='height: 80px; text-align: right; ' ><img height='80px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "cutler_contract_pdf_header.jpg'></div>"); $mpdf->SetHTMLHeader("<div style='height: 80px; text-align: right; ' ><img height='80px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "cutler_contract_pdf_header.jpg'></div>");
$mpdf->setFooter('{PAGENO} / {nb}'); $mpdf->setFooter('{PAGENO} / {nb}');
$mpdf->WriteHTML($this->renderPartial('_contract', [ $mpdf->WriteHTML($this->renderPartial('_contract', [
'model' => $model, 'model' => $model,
])); ]));
$fileName = "szerzodes"; $fileName = "szerzodes";
$fileName .= "." . $model->customer->name; $fileName .= "." . $model->customer->name;
$fileName .= "." .\Yii::$app->formatter->asDate( $model->created_at, "Y"); $fileName .= "." .\Yii::$app->formatter->asDate( $model->created_at, "Y");
@ -367,12 +370,12 @@ class ContractController extends Controller {
// $mpdf->Output('szerzodes.pdf', 'I');//open in new tab // $mpdf->Output('szerzodes.pdf', 'I');//open in new tab
exit; exit;
} }
/** /**
* Finds the Contract model based on its primary key value. * Finds the Contract model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
* *
* @param integer $id * @param integer $id
* @return Contract the loaded model * @return Contract the loaded model
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
*/ */

View File

@ -25,6 +25,7 @@ use common\models\Customer;
use frontend\models\CustomerCartForm; use frontend\models\CustomerCartForm;
use common\models\Card; use common\models\Card;
use common\components\Helper; use common\components\Helper;
use common\components\MpdfUtil;
use yii\base\Exception; use yii\base\Exception;
use common\components\TransferPayout; use common\components\TransferPayout;
@ -83,20 +84,20 @@ class TransferController extends Controller
if ( !Helper::isReceptionTransferIndexEnabled()){ if ( !Helper::isReceptionTransferIndexEnabled()){
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
$searchModel = new TransferSearch(); $searchModel = new TransferSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->load(Yii::$app->request->queryParams); $searchModel->load(Yii::$app->request->queryParams);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->totalsTransfers(Yii::$app->request->queryParams); $searchModel->totalsTransfers(Yii::$app->request->queryParams);
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
]); ]);
} }
/** /**
@ -119,7 +120,7 @@ class TransferController extends Controller
]); ]);
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -129,14 +130,14 @@ class TransferController extends Controller
$searchModel = new TransferListSearch(); $searchModel = new TransferListSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->load(Yii::$app->request->queryParams); $searchModel->load(Yii::$app->request->queryParams);
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
return $this->render('list', [ return $this->render('list', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
/** /**
@ -151,7 +152,7 @@ class TransferController extends Controller
]); ]);
} }
/** /**
* Creates a new Transfer model. * Creates a new Transfer model.
* If creation is successful, the browser will be redirected to the 'view' page. * If creation is successful, the browser will be redirected to the 'view' page.
@ -160,10 +161,10 @@ class TransferController extends Controller
public function actionMoneyMovementCreate() public function actionMoneyMovementCreate()
{ {
$model = new Transfer(); $model = new Transfer();
$model->type = Transfer::TYPE_MONEY_MOVEMENT_OUT; $model->type = Transfer::TYPE_MONEY_MOVEMENT_OUT;
$model->direction = Transfer::DIRECTION_OUT; $model->direction = Transfer::DIRECTION_OUT;
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_transfer]); return $this->redirect(['view', 'id' => $model->id_transfer]);
} else { } else {
@ -189,8 +190,8 @@ class TransferController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }
/** /**
* Updates an existing Transfer model. * Updates an existing Transfer model.
* If update is successful, the browser will be redirected to the 'view' page. * If update is successful, the browser will be redirected to the 'view' page.
@ -221,16 +222,16 @@ class TransferController extends Controller
$transfer = $this->findModel($id); $transfer = $this->findModel($id);
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
$transaction = $connection->beginTransaction(); $transaction = $connection->beginTransaction();
try { try {
$tp = new TransferPayout( [ $tp = new TransferPayout( [
'idUser' => \Yii::$app->user->id, 'idUser' => \Yii::$app->user->id,
'idTransfers' => [$transfer->id_transfer ], 'idTransfers' => [$transfer->id_transfer ],
'idAccount' => Account::readDefault (), 'idAccount' => Account::readDefault (),
] ); ] );
$tp->payout (); $tp->payout ();
// UserSoldItem::payout ( $user, $model->transfers ); // UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit (); $transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Tranzakció fizetve: ' . $transfer->count ." db " . $transfer->getObjectName() . " - " . $transfer->money); \Yii::$app->session->setFlash ( 'success', 'Tranzakció fizetve: ' . $transfer->count ." db " . $transfer->getObjectName() . " - " . $transfer->money);
@ -241,10 +242,10 @@ class TransferController extends Controller
$transaction->rollback (); $transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () ); Yii::error ( "faled to save :" . $e->getMessage () );
} }
return $this->redirect(Yii::$app->request->referrer); return $this->redirect(Yii::$app->request->referrer);
} }
/** /**
* Deletes an existing Transfer model. * Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page. * If deletion is successful, the browser will be redirected to the 'index' page.
@ -266,17 +267,17 @@ class TransferController extends Controller
// }else{ // }else{
// throw new \Exception("Failed to save"); // throw new \Exception("Failed to save");
// } // }
} catch(Exception $e) { } catch(Exception $e) {
$transaction->rollback(); $transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' ); \Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
} }
return $this->redirect(Yii::$app->request->referrer); return $this->redirect(Yii::$app->request->referrer);
} }
protected function delete($id){ protected function delete($id){
$transfer = $this->findModel($id); $transfer = $this->findModel($id);
$connection = \Yii::$app->db; $connection = \Yii::$app->db;
@ -288,14 +289,14 @@ class TransferController extends Controller
}else{ }else{
throw new \Exception("Failed to save"); throw new \Exception("Failed to save");
} }
} catch(Exception $e) { } catch(Exception $e) {
$transaction->rollback(); $transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' ); \Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
} }
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
* @return mixed * @return mixed
@ -307,35 +308,35 @@ class TransferController extends Controller
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read(); $searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read(); $searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
return $this->render('sale', [ return $this->render('sale', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
public function actionSalePdf(){ public function actionSalePdf(){
$searchModel = new TransferSaleSearch(); $searchModel = new TransferSaleSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read(); $searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read(); $searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->WriteHTML($this->renderPartial('_result_sale', [ $mpdf->WriteHTML($this->renderPartial('_result_sale', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
])); ]));
$mpdf->Output('eladasaim.pdf', 'D'); $mpdf->Output('eladasaim.pdf', 'D');
exit; exit;
} }
/** /**
* Lists all Transfer models. * Lists all Transfer models.
@ -347,43 +348,43 @@ class TransferController extends Controller
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault()); $searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
return $this->render('tickets', [ return $this->render('tickets', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
} }
public function actionTicketsPdf(){ public function actionTicketsPdf(){
$searchModel = new TransferTicketSearch(); $searchModel = new TransferTicketSearch();
$searchModel->accounts = Account::read(); $searchModel->accounts = Account::read();
$searchModel->users = User::read(); $searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault()); $searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams); $searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L'); $mpdf=new Mpdf('utf-8', 'A4-L');
$mpdf->WriteHTML($this->renderPartial('_result_ticket', [ $mpdf->WriteHTML($this->renderPartial('_result_ticket', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
])); ]));
$mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D'); $mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D');
exit; exit;
} }
public function actionUserCart(){ public function actionUserCart(){
$defaultAccount = Account::readDefault(); $defaultAccount = Account::readDefault();
if ( !isset($defaultAccount)){ if ( !isset($defaultAccount)){
return $this->redirect(['account/select']); return $this->redirect(['account/select']);
} }
$model = new UserCartForm(); $model = new UserCartForm();
if ($model->load(Yii::$app->request->post()) && $model->payout()) { if ($model->load(Yii::$app->request->post()) && $model->payout()) {
return $this->redirect(['user-cart']); return $this->redirect(['user-cart']);
@ -391,31 +392,31 @@ class TransferController extends Controller
$model->run(); $model->run();
return $this->render("usercart",[ 'model' => $model]); return $this->render("usercart",[ 'model' => $model]);
} }
public function actionCustomerCart($id_card){ public function actionCustomerCart($id_card){
$defaultAccount = Account::readDefault(); $defaultAccount = Account::readDefault();
if ( !isset($defaultAccount)){ if ( !isset($defaultAccount)){
return $this->redirect(['account/select']); return $this->redirect(['account/select']);
} }
$hiddenAccounts = Account::find() $hiddenAccounts = Account::find()
->andWhere(['type' => Account::TYPE_VALUE_HIDDEN]) ->andWhere(['type' => Account::TYPE_VALUE_HIDDEN])
->andWhere(['status' => Account::STATUS_ACTIVE])->all(); ->andWhere(['status' => Account::STATUS_ACTIVE])->all();
$customer = null; $customer = null;
$card = Card::findOne($id_card); $card = Card::findOne($id_card);
if ($card != null ) if ($card != null )
$customer = $card->customer; $customer = $card->customer;
if ( !isset($customer) ){ if ( !isset($customer) ){
throw new NotFoundHttpException ( 'Az oldal nem található' ); throw new NotFoundHttpException ( 'Az oldal nem található' );
} }
$model = new CustomerCartForm(); $model = new CustomerCartForm();
$model->customer = $customer; $model->customer = $customer;
$model->hiddenAccounts = $hiddenAccounts; $model->hiddenAccounts = $hiddenAccounts;