update mpdf lib version from 6 to 8
This commit is contained in:
@@ -16,16 +16,17 @@ use common\models\User;
|
||||
use common\components\accountstate\AccountStateMail;
|
||||
use common\models\Transfer;
|
||||
use common\components\Helper;
|
||||
use common\components\MpdfUtil;
|
||||
|
||||
/**
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
*/
|
||||
class AccountStateController extends Controller {
|
||||
public function behaviors() {
|
||||
return [
|
||||
'access' => [
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className (),
|
||||
'only' => [
|
||||
'only' => [
|
||||
'index',
|
||||
'open',
|
||||
'close',
|
||||
@@ -34,17 +35,17 @@ class AccountStateController extends Controller {
|
||||
],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => [
|
||||
'@'
|
||||
]
|
||||
]
|
||||
]
|
||||
'roles' => [
|
||||
'@'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
// everything else is denied
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,15 +61,15 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
|
||||
$searchModel = new AccountstateSearch ();
|
||||
|
||||
|
||||
$searchModel->accounts = Account::read ();
|
||||
$searchModel->users = User::read ();
|
||||
|
||||
|
||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||
|
||||
return $this->render ( 'index', [
|
||||
|
||||
return $this->render ( 'index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider
|
||||
'dataProvider' => $dataProvider
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -98,38 +99,38 @@ class AccountStateController extends Controller {
|
||||
public function actionOpen() {
|
||||
$lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE );
|
||||
$lastStates = AccountState::modelsToArray ( $lastStates );
|
||||
|
||||
|
||||
|
||||
|
||||
$model = new AccountState ();
|
||||
$model->type = AccountState::TYPE_OPEN;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
|
||||
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
|
||||
|
||||
|
||||
|
||||
if ( Helper::isAccountStateOpenSendMail() ){
|
||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||
$mail->sednMail();
|
||||
}
|
||||
|
||||
|
||||
$redirectTo = 'index';
|
||||
|
||||
if ( Helper::isReceptionAccountStateIndexToday() ){
|
||||
$redirectTo = 'today';
|
||||
}
|
||||
|
||||
return $this->redirect ( [
|
||||
return $this->redirect ( [
|
||||
$redirectTo
|
||||
] );
|
||||
} else {
|
||||
|
||||
|
||||
$accounts = Account::read ();
|
||||
|
||||
return $this->render ( 'open', [
|
||||
|
||||
return $this->render ( 'open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates,
|
||||
@@ -151,19 +152,19 @@ class AccountStateController extends Controller {
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
|
||||
|
||||
|
||||
|
||||
|
||||
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
|
||||
|
||||
|
||||
|
||||
|
||||
if ( Helper::isAccountStateClosePreloadMoney()){
|
||||
$model->money = $this->readCassaClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
|
||||
|
||||
if ( Helper::isAccountStateCloseSendMail()){
|
||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||
$mail->sednMail();
|
||||
@@ -181,10 +182,10 @@ class AccountStateController extends Controller {
|
||||
] );
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
} else {
|
||||
|
||||
|
||||
$accounts = Account::read ();
|
||||
|
||||
return $this->render ( 'close', [
|
||||
|
||||
return $this->render ( 'close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'account' => $account,
|
||||
@@ -193,7 +194,7 @@ class AccountStateController extends Controller {
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function readCassaClose(){
|
||||
$total = 0;
|
||||
$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);
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the AccountState model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param integer $id
|
||||
* @return AccountState the loaded model
|
||||
* @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.' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes an existing AccountState model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id) {
|
||||
@@ -264,7 +265,7 @@ class AccountStateController extends Controller {
|
||||
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||
$details = null;
|
||||
if ($accountState->isTypeClose ()) {
|
||||
|
||||
|
||||
$prev = null;
|
||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||
if (isset ( $accountState->prev_state )) {
|
||||
@@ -276,53 +277,53 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
$details = new DailyListing ();
|
||||
$details->loadAccountState ( $accountState );
|
||||
|
||||
|
||||
$details->readTotalEasy ();
|
||||
$details->readTotalDetailed ();
|
||||
$details->readTotalMedium ();
|
||||
}
|
||||
|
||||
|
||||
if ($output == 'pdf') {
|
||||
$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->simpleTables = true;
|
||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||
|
||||
|
||||
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||
$mpdf->WriteHTML($stylesheet,1);
|
||||
|
||||
|
||||
|
||||
|
||||
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
|
||||
'model' => $accountState,
|
||||
'details' => $details
|
||||
'details' => $details
|
||||
]));
|
||||
/** @noinspection SpellCheckingInspection */
|
||||
$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";
|
||||
$mpdf->Output($fn, 'D');
|
||||
exit(0);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
return $this->render ( 'view', [
|
||||
|
||||
return $this->render ( 'view', [
|
||||
'model' => $accountState,
|
||||
'details' => $details
|
||||
'details' => $details
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionMixed($id){
|
||||
$accountState = $this->findModel ( $id );
|
||||
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||
$details = null;
|
||||
|
||||
|
||||
if ($accountState->isTypeClose ()) {
|
||||
|
||||
|
||||
$prev = null;
|
||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||
if (isset ( $accountState->prev_state )) {
|
||||
@@ -334,30 +335,30 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
$details = new DailyListing ();
|
||||
$details->loadAccountState ( $accountState );
|
||||
|
||||
|
||||
$details->readTotalEasy ();
|
||||
$details->readTotalDetailed ();
|
||||
$details->readTotalMedium ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($output == 'pdf') {
|
||||
$user = User::findOne(\Yii::$app->user->id);
|
||||
$mpdf=new \mPDF('utf-8', 'A4');
|
||||
$mpdf=new Mpdf('utf-8', 'A4');
|
||||
$mpdf->useSubstitutions=false;
|
||||
$mpdf->simpleTables = true;
|
||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||
|
||||
|
||||
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||
$mpdf->WriteHTML($stylesheet,1);
|
||||
|
||||
|
||||
$stylesheet = file_get_contents( \Yii::getAlias('@frontend'.'/web/css/account_close.css')); // external css
|
||||
$mpdf->WriteHTML($stylesheet,1);
|
||||
|
||||
|
||||
|
||||
|
||||
$mpdf->WriteHTML($this->renderPartial("@frontend/views/account-state/mixed_pdf", [
|
||||
'model' => $accountState,
|
||||
'details' => $details
|
||||
@@ -367,8 +368,8 @@ class AccountStateController extends Controller {
|
||||
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||
$fn= $type .$dt.".pdf";
|
||||
$mpdf->Output($fn, 'D');
|
||||
exit();
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
return $this->render ( 'mixed', [
|
||||
'model' => $accountState,
|
||||
|
||||
@@ -19,27 +19,28 @@ use common\models\Product;
|
||||
use common\models\ShoppingCart;
|
||||
use common\models\Customer;
|
||||
use frontend\models\ContractForm;
|
||||
use common\components\MpdfUtil;
|
||||
|
||||
/**
|
||||
* ContractController implements the CRUD actions for Contract model.
|
||||
*/
|
||||
class ContractController extends Controller {
|
||||
public function behaviors() {
|
||||
return [
|
||||
'verbs' => [
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className (),
|
||||
'actions' => [
|
||||
'delete' => [
|
||||
'post'
|
||||
'actions' => [
|
||||
'delete' => [
|
||||
'post'
|
||||
],
|
||||
'payout' => [
|
||||
'post'
|
||||
'payout' => [
|
||||
'post'
|
||||
],
|
||||
'cancel' => [
|
||||
'post'
|
||||
]
|
||||
]
|
||||
]
|
||||
'cancel' => [
|
||||
'post'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -51,18 +52,18 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionIndex($id_card) {
|
||||
$card = Card::findOne ( $id_card );
|
||||
|
||||
|
||||
if (! isset ( $card ))
|
||||
throw new NotFoundHttpException ( 'A bérlet nem található' );
|
||||
|
||||
|
||||
$searchModel = new ContractSearch ();
|
||||
$searchModel->card = $card;
|
||||
$searchModel->customer = $card->customer;
|
||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||
|
||||
return $this->render ( 'index', [
|
||||
|
||||
return $this->render ( 'index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider
|
||||
'dataProvider' => $dataProvider
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -77,20 +78,20 @@ class ContractController extends Controller {
|
||||
$model = $this->findModel ( $id );
|
||||
$customer = $model->customer;
|
||||
$card = $customer->card;
|
||||
|
||||
$installments = TicketInstallmentRequest::find ()->andWhere ( [
|
||||
'id_contract' => $model->id_contract
|
||||
] )->orderBy ( [
|
||||
'ticket_installment_request.priority' => SORT_ASC
|
||||
|
||||
$installments = TicketInstallmentRequest::find ()->andWhere ( [
|
||||
'id_contract' => $model->id_contract
|
||||
] )->orderBy ( [
|
||||
'ticket_installment_request.priority' => SORT_ASC
|
||||
] )->all ();
|
||||
|
||||
return $this->render ( 'view', [
|
||||
|
||||
return $this->render ( 'view', [
|
||||
'model' => $model,
|
||||
'intstallments' => $installments,
|
||||
'card' => $card
|
||||
'card' => $card
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Contract model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
@@ -99,15 +100,15 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionCreate() {
|
||||
$model = new Contract ();
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
return $this->redirect ( [
|
||||
return $this->redirect ( [
|
||||
'view',
|
||||
'id' => $model->id_contract
|
||||
'id' => $model->id_contract
|
||||
] );
|
||||
} else {
|
||||
return $this->render ( 'create', [
|
||||
'model' => $model
|
||||
return $this->render ( 'create', [
|
||||
'model' => $model
|
||||
] );
|
||||
}
|
||||
}
|
||||
@@ -122,15 +123,15 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionUpdate($id) {
|
||||
$model = $this->findModel ( $id );
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
return $this->redirect ( [
|
||||
return $this->redirect ( [
|
||||
'view',
|
||||
'id' => $model->id_contract
|
||||
'id' => $model->id_contract
|
||||
] );
|
||||
} else {
|
||||
return $this->render ( 'update', [
|
||||
'model' => $model
|
||||
return $this->render ( 'update', [
|
||||
'model' => $model
|
||||
] );
|
||||
}
|
||||
}
|
||||
@@ -146,12 +147,12 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionDelete($id) {
|
||||
$this->findModel ( $id )->delete ();
|
||||
|
||||
return $this->redirect ( [
|
||||
'index'
|
||||
|
||||
return $this->redirect ( [
|
||||
'index'
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EGY RÉSZLET KIFIZETÉSE
|
||||
*/
|
||||
@@ -160,33 +161,33 @@ class ContractController extends Controller {
|
||||
$contract = $part->contract;
|
||||
$customer = $contract->customer;
|
||||
$card = $customer->card;
|
||||
|
||||
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
|
||||
|
||||
$result = Transfer::sellContractTicket ( $contract, $part, Account::readDefaultObject (), Transfer::STATUS_NOT_PAID, Transfer::PAYMENT_METHOD_CASH, true );
|
||||
$transfer = $result [0];
|
||||
$ticket = $result [1];
|
||||
if ($part->status != TicketInstallmentRequest::$STATUS_REJECTED) {
|
||||
$contract->part_required = $contract->part_required + 1;
|
||||
}
|
||||
|
||||
|
||||
$contract->part_paid = $contract->part_paid + 1;
|
||||
|
||||
|
||||
if ($contract->part_paid >= $contract->part_required) {
|
||||
$contract->status = Contract::$STATUS_PAID;
|
||||
} else {
|
||||
$contract->status = Contract::$STATUS_NOT_PAID;
|
||||
}
|
||||
|
||||
|
||||
$contract->save ( false );
|
||||
|
||||
|
||||
$part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
|
||||
$part->id_transfer = $transfer->id_transfer;
|
||||
$part->request_processed_at = Helper::getDateTimeString ();
|
||||
$part->id_ticket = $ticket->id_ticket;
|
||||
|
||||
|
||||
$part->save ( false );
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', "Részlet a bevásárló kosárba helyezve!" );
|
||||
@@ -194,10 +195,10 @@ class ContractController extends Controller {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "Nem sikerült a kifizetés." );
|
||||
}
|
||||
|
||||
return $this->redirect ( [
|
||||
|
||||
return $this->redirect ( [
|
||||
'view',
|
||||
'id' => $contract->id_contract
|
||||
'id' => $contract->id_contract
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -211,26 +212,26 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionCancel($id,$flag) {
|
||||
$contract = $this->findModel ( $id );
|
||||
|
||||
|
||||
if ( $flag != Contract::$FLAG_CANCELED && $flag != Contract::$FLAG_CANCELED_2){
|
||||
\Yii::error("A felmondási státusz nem található! ($flag)");
|
||||
throw new NotFoundHttpException("Az oldal nem található!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$customer = $contract->customer;
|
||||
$card = $customer->card;
|
||||
|
||||
|
||||
if ($contract->canCancel ()) {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
|
||||
|
||||
$contract->flag = $flag;
|
||||
$contract->save ();
|
||||
$requests = $contract->requests;
|
||||
$buntetes = 0;
|
||||
|
||||
|
||||
foreach ( $requests as $request ) {
|
||||
/** @var \common\models\TicketInstallmentRequest $request*/
|
||||
if ($request->isStatusAccepted ()) {
|
||||
@@ -240,15 +241,15 @@ class ContractController extends Controller {
|
||||
$request->save ( false );
|
||||
}
|
||||
}
|
||||
|
||||
$productBuntetes = Product::find ()->andWhere ( [
|
||||
'product_number' => Product::$BUNTETES
|
||||
|
||||
$productBuntetes = Product::find ()->andWhere ( [
|
||||
'product_number' => Product::$BUNTETES
|
||||
] )->one ();
|
||||
|
||||
// if there is a fee , generate fee and put it to the shopping cart
|
||||
if (isset ( $productBuntetes )) {
|
||||
if ($buntetes > 0) {
|
||||
|
||||
|
||||
$sale = new Sale ();
|
||||
$sale->id_account = Account::readDefault ();
|
||||
$sale->id_product = $productBuntetes->id_product;
|
||||
@@ -258,29 +259,29 @@ class ContractController extends Controller {
|
||||
$sale->count = $buntetes;
|
||||
$sale->money = $buntetes * $sale->item_price;
|
||||
$sale->id_user = \Yii::$app->user->id;
|
||||
|
||||
|
||||
$sale->save ( false );
|
||||
|
||||
|
||||
$transfer = Transfer::createProductTransfer ( $sale, Account::readDefaultObject (), null, null, $sale->count, $productBuntetes, Transfer::STATUS_NOT_PAID, $customer );
|
||||
$transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
|
||||
|
||||
|
||||
$transfer->id_user = Yii::$app->user->id;
|
||||
|
||||
|
||||
$transfer->save ( false );
|
||||
|
||||
|
||||
$cart = new ShoppingCart ();
|
||||
$cart->id_customer = $customer->id_customer;
|
||||
$cart->id_transfer = $transfer->id_transfer;
|
||||
$cart->save ( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" );
|
||||
|
||||
return $this->redirect ( [
|
||||
|
||||
return $this->redirect ( [
|
||||
'product/sale',
|
||||
'number' => $card->number
|
||||
'number' => $card->number
|
||||
] );
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
@@ -289,10 +290,10 @@ class ContractController extends Controller {
|
||||
} else {
|
||||
\Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" );
|
||||
}
|
||||
|
||||
return $this->redirect ( [
|
||||
|
||||
return $this->redirect ( [
|
||||
'view',
|
||||
'id' => $contract->id_contract
|
||||
'id' => $contract->id_contract
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -303,31 +304,31 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionMake($id) {
|
||||
$customer = Customer::findOne ( $id );
|
||||
|
||||
|
||||
if (! isset ( $customer )) {
|
||||
throw new Exception ( "Az oldal nem található" );
|
||||
}
|
||||
|
||||
|
||||
$model = new ContractForm ( [
|
||||
|
||||
|
||||
$model = new ContractForm ( [
|
||||
'customer' => $customer ,
|
||||
'idUser' => \Yii::$app->user->id,
|
||||
'idAccount' => Account::readDefault ()
|
||||
] );
|
||||
|
||||
|
||||
$model->started_at = date(date('Y.m.d'));
|
||||
|
||||
|
||||
$model->fillOut ();
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||
|
||||
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
|
||||
|
||||
$model->make ();
|
||||
$transaction->commit();
|
||||
return $this->redirect ( [
|
||||
return $this->redirect ( [
|
||||
'contract/view',
|
||||
'id' => $model->contract->id_contract
|
||||
] );
|
||||
@@ -336,9 +337,9 @@ class ContractController extends Controller {
|
||||
\Yii::$app->session->setFlash('danger', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render ( '_make_contract', [
|
||||
'model' => $model
|
||||
|
||||
return $this->render ( '_make_contract', [
|
||||
'model' => $model
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -349,16 +350,18 @@ class ContractController extends Controller {
|
||||
*/
|
||||
public function actionContract($id){
|
||||
$model = $this->findModel($id);
|
||||
|
||||
|
||||
// print_r($model);
|
||||
|
||||
//$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->setFooter('{PAGENO} / {nb}');
|
||||
$mpdf->WriteHTML($this->renderPartial('_contract', [
|
||||
'model' => $model,
|
||||
]));
|
||||
|
||||
|
||||
$fileName = "szerzodes";
|
||||
$fileName .= "." . $model->customer->name;
|
||||
$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
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the Contract model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param integer $id
|
||||
* @return Contract the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@ use common\models\Customer;
|
||||
use frontend\models\CustomerCartForm;
|
||||
use common\models\Card;
|
||||
use common\components\Helper;
|
||||
use common\components\MpdfUtil;
|
||||
use yii\base\Exception;
|
||||
use common\components\TransferPayout;
|
||||
|
||||
@@ -83,20 +84,20 @@ class TransferController extends Controller
|
||||
if ( !Helper::isReceptionTransferIndexEnabled()){
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
|
||||
$searchModel = new TransferSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->load(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$searchModel->totalsTransfers(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +120,7 @@ class TransferController extends Controller
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
* @return mixed
|
||||
@@ -129,14 +130,14 @@ class TransferController extends Controller
|
||||
$searchModel = new TransferListSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->load(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('list', [
|
||||
'searchModel' => $searchModel,
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +152,7 @@ class TransferController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Transfer model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
@@ -160,10 +161,10 @@ class TransferController extends Controller
|
||||
public function actionMoneyMovementCreate()
|
||||
{
|
||||
$model = new Transfer();
|
||||
|
||||
|
||||
$model->type = Transfer::TYPE_MONEY_MOVEMENT_OUT;
|
||||
$model->direction = Transfer::DIRECTION_OUT;
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_transfer]);
|
||||
} else {
|
||||
@@ -189,8 +190,8 @@ class TransferController extends Controller
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates an existing Transfer model.
|
||||
* 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);
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction();
|
||||
|
||||
|
||||
try {
|
||||
$tp = new TransferPayout( [
|
||||
'idUser' => \Yii::$app->user->id,
|
||||
'idTransfers' => [$transfer->id_transfer ],
|
||||
'idTransfers' => [$transfer->id_transfer ],
|
||||
'idAccount' => Account::readDefault (),
|
||||
] );
|
||||
|
||||
|
||||
$tp->payout ();
|
||||
|
||||
|
||||
// UserSoldItem::payout ( $user, $model->transfers );
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Tranzakció fizetve: ' . $transfer->count ." db " . $transfer->getObjectName() . " - " . $transfer->money);
|
||||
@@ -241,10 +242,10 @@ class TransferController extends Controller
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
}
|
||||
|
||||
|
||||
return $this->redirect(Yii::$app->request->referrer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes an existing Transfer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
@@ -266,17 +267,17 @@ class TransferController extends Controller
|
||||
// }else{
|
||||
// throw new \Exception("Failed to save");
|
||||
// }
|
||||
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->redirect(Yii::$app->request->referrer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected function delete($id){
|
||||
$transfer = $this->findModel($id);
|
||||
$connection = \Yii::$app->db;
|
||||
@@ -288,14 +289,14 @@ class TransferController extends Controller
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
* @return mixed
|
||||
@@ -307,35 +308,35 @@ class TransferController extends Controller
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->productCategories = ProductCategory::read();
|
||||
$searchModel->productOptions = Product::read();
|
||||
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('sale', [
|
||||
'searchModel' => $searchModel,
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function actionSalePdf(){
|
||||
$searchModel = new TransferSaleSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->productCategories = ProductCategory::read();
|
||||
$searchModel->productOptions = Product::read();
|
||||
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||
|
||||
|
||||
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
|
||||
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
|
||||
'searchModel' => $searchModel,
|
||||
]));
|
||||
$mpdf->Output('eladasaim.pdf', 'D');
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
@@ -347,43 +348,43 @@ class TransferController extends Controller
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
|
||||
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('tickets', [
|
||||
'searchModel' => $searchModel,
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function actionTicketsPdf(){
|
||||
$searchModel = new TransferTicketSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
|
||||
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||
|
||||
|
||||
$mpdf=new Mpdf('utf-8', 'A4-L');
|
||||
$mpdf->WriteHTML($this->renderPartial('_result_ticket', [
|
||||
'searchModel' => $searchModel,
|
||||
]));
|
||||
$mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D');
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionUserCart(){
|
||||
|
||||
|
||||
$defaultAccount = Account::readDefault();
|
||||
|
||||
|
||||
if ( !isset($defaultAccount)){
|
||||
return $this->redirect(['account/select']);
|
||||
}
|
||||
|
||||
|
||||
$model = new UserCartForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
|
||||
return $this->redirect(['user-cart']);
|
||||
@@ -391,31 +392,31 @@ class TransferController extends Controller
|
||||
$model->run();
|
||||
return $this->render("usercart",[ 'model' => $model]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionCustomerCart($id_card){
|
||||
|
||||
|
||||
$defaultAccount = Account::readDefault();
|
||||
|
||||
|
||||
if ( !isset($defaultAccount)){
|
||||
return $this->redirect(['account/select']);
|
||||
}
|
||||
|
||||
|
||||
$hiddenAccounts = Account::find()
|
||||
->andWhere(['type' => Account::TYPE_VALUE_HIDDEN])
|
||||
->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
|
||||
|
||||
|
||||
$customer = null;
|
||||
$card = Card::findOne($id_card);
|
||||
if ($card != null )
|
||||
$customer = $card->customer;
|
||||
|
||||
|
||||
|
||||
|
||||
if ( !isset($customer) ){
|
||||
throw new NotFoundHttpException ( 'Az oldal nem található' );
|
||||
}
|
||||
|
||||
|
||||
$model = new CustomerCartForm();
|
||||
$model->customer = $customer;
|
||||
$model->hiddenAccounts = $hiddenAccounts;
|
||||
|
||||
Reference in New Issue
Block a user