merge app api

This commit is contained in:
Schneider Roland
2023-01-19 17:43:10 +01:00
570 changed files with 81491 additions and 1263 deletions

View File

@@ -25,7 +25,7 @@ class CustomerAsset extends AssetBundle
public $depends = [
'frontend\assets\AppAsset',
'common\assets\MomentAsset',
'common\assets\WebcamjsAsset',
// 'common\assets\WebcamjsAsset',
'yii\jui\JuiAsset',
];
}

View File

@@ -6,7 +6,7 @@ use common\models\AccountState;
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\grid\GridView;
use yii\base\Object;
use yii\base\BaseObject;
use yii\data\ArrayDataProvider;
use yii\helpers\Url;
use common\components\total\TotalDifferenceWidget;
@@ -226,4 +226,4 @@ class AccountStateBanknoteCountWidget extends Widget{
}
}

View File

@@ -8,7 +8,7 @@ use common\models\MoneyMovement;
use yii\db\Query;
use common\models\AccountState;
use yii\web\Controller;
use yii\base\Object;
use yii\base\BaseObject;
use frontend\models\ReceptionForm;
use common\models\UserSoldItem;
use common\models\ShoppingCart;
@@ -59,4 +59,4 @@ class FrontendController extends Controller{
return true;
}
}
}

View File

@@ -1,6 +1,7 @@
<?php
namespace frontend\components;
use common\models\MobileDevice;
use yii\base\Widget;
/**
* This is the model class for table "customer".
@@ -15,8 +16,13 @@ class ReceptionCustomerWidget extends Widget{
public $model;
public function run(){
echo $this->render($this->viewFile,[ 'model' => $this->model ]);
$showLinkDevices = MobileDevice::find()
->andWhere(['status' => MobileDevice::STATUS_INACTIVE])
->count() > 0;
echo $this->render($this->viewFile,[ 'model' => $this->model,
'showLinkDevices' => $showLinkDevices
]);
}
}
}

View File

@@ -9,7 +9,6 @@ use frontend\models\AccountSelect;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use common\models\Log;
use common\models\User;
@@ -30,7 +29,7 @@ class AccountController extends Controller
];
}
/**
* Lists all Account models.
* @return mixed
@@ -40,12 +39,12 @@ class AccountController extends Controller
$model = new AccountSelect();
$model->id_account = Account::readDefault();
$accounts = Account::read();
if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default account is set!') );
$user = User::findOne(\Yii::$app->user->id);
Log::log([ 'type' => Log::$TYPE_DEFAULT_ACCOUNT,
'message' => "Alapértelmezett kassza - Felhasználó: " . $user->username . " - Kassza: " . Account::readDefaultObject()->name,
@@ -58,7 +57,7 @@ class AccountController extends Controller
'accounts' => $accounts
]);
}
/**
* Lists all Account models.
* @return mixed

View File

@@ -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,

View File

@@ -8,7 +8,7 @@ use backend\models\CardSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\base\BaseObject;
use yii\db\Query;
use common\models\Customer;
use yii\helpers\Json;

View File

@@ -8,7 +8,7 @@ use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\base\BaseObject;
use yii\db\Query;
use yii\helpers\Json;

View File

@@ -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
*/

View File

@@ -7,7 +7,7 @@ use common\models\Key;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\base\BaseObject;
use yii\db\Query;
use yii\helpers\Json;
use frontend\models\KeySearch;

View File

@@ -0,0 +1,108 @@
<?php
namespace frontend\controllers;
use common\models\Card;
use common\models\MobileDevice;
use frontend\models\MobileDeviceSearch;
use frontend\models\MobileStatusForm;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\BaseObject;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class MobileDeviceController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all City models.
* @return mixed
*/
public function actionIndex($id_card)
{
$card = $this->findModel($id_card);
$searchModel = new MobileDeviceSearch();
$searchModel->id_card = $card->id_card;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'card' => $card
]);
}
public function actionStatus($id_device, $status)
{
$device = $this->findDevice($id_device);
\Yii::info(print_r($device,true));
if ( $device == null ){
throw new NotFoundHttpException();
}
if (\Yii::$app->request->isPost) {
$form = new MobileStatusForm();
$form->status = $status;
$form->id_device = $id_device;
if ($form->validate()) {
$form->save();
return $this->redirect(['mobile-device/index', 'id_card' => $device->id_card]);
}
}
return $this->render( 'mobile-device/index',[ 'id_card' => $device->id_card]);
}
/**
* Finds the Card model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Card the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Card::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* @param $id
* @return MobileDevice|null
* @throws NotFoundHttpException
*/
protected function findDevice($id)
{
if (($model = MobileDevice::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@@ -13,7 +13,7 @@ use frontend\models\ProductLookupForm;
use common\models\Card;
use common\models\Customer;
use yii\base\DynamicModel;
use yii\base\Object;
use yii\base\BaseObject;
use common\models\Currency;
use common\models\Account;
use common\models\Discount;

View File

@@ -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;

View File

@@ -8,7 +8,7 @@ use common\models\Card;
use common\models\Customer;
use common\models\Product;
use common\models\Transfer;
use yii\base\Object;
use yii\base\BaseObject;
use common\models\Account;
use common\models\Discount;
use common\models\Currency;

View File

@@ -4,6 +4,7 @@ namespace frontend\models;
use common\models\DoorLog;
use common\models\Log;
use common\models\VirtualKey;
use /** @noinspection PhpUndefinedClassInspection */
yii\base\Model;
use common\models\CardKeyAssignment;
@@ -31,8 +32,8 @@ class KeyToggleForm extends Model
public $action;
public $keyCard;
/**
* @inheritdoc
*/
@@ -52,20 +53,24 @@ class KeyToggleForm extends Model
];
}
public function readKey($keyNumber){
$query= Key::find();
$fixedKeyNumber = Helper::fixAsciiChars($keyNumber);
// add condition rfid key or number
$query->andWhere(['or',
['and',[ 'in','key.number' , [$fixedKeyNumber]],"trim(coalesce(key.number, '')) <>'' " ],
['and', ['in','key.rfid_key' ,[ $fixedKeyNumber ] ],"trim(coalesce(key.rfid_key, '')) <>'' "],
]);
return $query->one();
}
/**
*
*/
public function toggleKey(){
$query= Key::find();
$this->key = Helper::fixAsciiChars($this->key);
// add condition rfid key or number
$query->andWhere(['or',
['and',[ 'in','key.number' , [$this->key]],"trim(coalesce(key.number, '')) <>'' " ],
['and', ['in','key.rfid_key' ,[ $this->key ] ],"trim(coalesce(key.rfid_key, '')) <>'' "],
]);
$this->keyModel = $query->one();
$this->keyModel = $this->readKey($this->key);
//ha van ilyen kulcs
if ( isset($this->keyModel) ){
//find card - key assignments
@@ -74,27 +79,7 @@ class KeyToggleForm extends Model
$assignments = CardKeyAssignment::find()->andWhere(['id_key' => $this->keyModel->id_key])->all();
//if assignment found - we will unassign it
if ( count($assignments) > 0){
if ( isset( $this->keyCard ) ){
CardKeyAssignment::deleteAll(['id_key' => $this->keyModel->id_key]);
$this->keyCard->setFlagsHasKey(false);
$this->keyCard->save(false);
/** @noinspection PhpUndefinedClassInspection */
\Yii::$app->session->setFlash ( 'success', 'Kulcs visszaadva!' );
$this->action = 'unassign';
Log::log([
'type' =>Log::$TYPE_KEY_ASSIGN,
'message' => 'Kulcs visszaadás - Kártya/Kulcs/Vendég:' .$this->keyCard->number ."/" .$this->keyModel->number . "/".$this->keyCard->customer->name,
'id_key' => $this->keyModel->id_key,
'id_customer' => $this->keyCard->customer->id_customer
]);
DoorLog::mkDoorLog(-1,$this->keyCard,$this->keyCard->customer,$this->keyModel );
}else{
/** @noinspection PhpUndefinedClassInspection */
\Yii::error("Key for assignment not found");
/** @noinspection PhpUndefinedClassInspection */
\Yii::$app->session->setFlash ( 'danger', 'Kulcs visszaadás hiba: kulcs nem található!' );
}
$this->revoke();
}else{
// if there is no assignment - assign it to the customer
$this->assign();
@@ -105,6 +90,27 @@ class KeyToggleForm extends Model
}
}
public function revoke(){
if ( isset( $this->keyCard ) ){
CardKeyAssignment::deleteAll(['id_key' => $this->keyModel->id_key]);
$this->keyCard->setFlagsHasKey(false);
$this->keyCard->save(false);
\Yii::$app->session->setFlash ( 'success', 'Kulcs visszaadva!' );
$this->action = 'unassign';
Log::log([
'type' =>Log::$TYPE_KEY_ASSIGN,
'message' => 'Kulcs visszaadás - Kártya/Kulcs/Vendég:' .$this->keyCard->number ."/" .$this->keyModel->number . "/".$this->keyCard->customer->name,
'id_key' => $this->keyModel->id_key,
'id_customer' => $this->keyCard->customer->id_customer
]);
DoorLog::mkDoorLog(-1,$this->keyCard,$this->keyCard->customer,$this->keyModel );
}else{
\Yii::error("Key for assignment not found");
\Yii::$app->session->setFlash ( 'danger', 'Kulcs visszaadás hiba: kulcs nem található!' );
}
}
public function assign(){
if ( isset($this->card) && isset($this->customer) ){
$assignments = CardKeyAssignment::find()->andWhere(['id_card' => $this->card->id_card])->all();
@@ -117,6 +123,7 @@ class KeyToggleForm extends Model
$assignment->id_key = $this->keyModel->id_key;
/** @noinspection PhpUndefinedClassInspection */
$assignment->id_user = \Yii::$app->user->id;
$assignment->virtual_key = uniqid(null,true);
$assignment->save(false);
/** @noinspection PhpUndefinedClassInspection */
\Yii::$app->session->setFlash ( 'success', 'Kulcs kiadva!' );
@@ -132,12 +139,23 @@ class KeyToggleForm extends Model
]);
DoorLog::mkDoorLog(-2,$this->card,$this->customer,$this->keyModel );
// delete all virtual key for this card
VirtualKey::deleteAll(['id_card' => $this->card->id_card]);
// create a new virtual key
$virtualKey = new VirtualKey();
$virtualKey->id_card = $this->card->id_card;
$virtualKey->id_key = $this->keyModel->id_key;
$virtualKey->number = uniqid(null,true);
$virtualKey->save(false);
}
}else{
/** @noinspection PhpUndefinedClassInspection */
\Yii::$app->session->setFlash ( 'danger', 'Nincs vendég kiválasztva vagy érvénytelen kártya!' );
}
}
}

View File

@@ -0,0 +1,89 @@
<?php
namespace frontend\models;
use common\components\Helper;
use common\models\MobileDevice;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\db\Query;
/**
* EventSearch represents the model behind the search form about `common\models\Event`.
*/
class MobileDeviceSearch extends MobileDevice
{
/**
* @inheritdoc
*/
public function rules()
{
return [
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = new Query();
$query->select([
'card.id_card as card_id',
'card.number as card_number',
'mobile_device.id as device_id',
'mobile_device.device_name as device_name',
'mobile_device.status as device_status',
'mobile_device.created_at as device_created_at',
]);
$query->from("mobile_device");
$query->innerJoin('customer', 'customer.id_customer_card = mobile_device.id_card');
$query->innerJoin('card', 'card.id_card = mobile_device.id_card');
$query->andWhere(['card.id_card' => $this->id_card]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'device_created_at' => SORT_DESC
],
'attributes' => Helper::mkYiiSortItems([
['device_created_at'],
['device_status'],
]),
]
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// $query->andFilterWhere([
// 'event.id' => $this->id,
// ]);
return $dataProvider;
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace frontend\models;
use common\components\Helper;
use common\models\Card;
use common\models\Customer;
use common\models\Log;
use common\models\MobileDevice;
use Yii;
use yii\base\Model;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;
/**
* ContactForm is the model behind the contact form.
*/
class MobileStatusForm extends Model
{
public $id_device;
public $status;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_device', 'status'], 'required'],
];
}
public function save()
{
$tx = null;
try {
$tx = \Yii::$app->db->beginTransaction();
$device = MobileDevice::findOne(['id' => $this->id_device]);
if ($device === null) {
throw new NotFoundHttpException();
}
$card = Card::findOne(['id_card' => $device->id_card]);
if ($card === null) {
throw new NotFoundHttpException();
}
\Yii::info("MobileStatusForm: changing status from $device->status to $this->status");
$origStatus = $device->status;
$device->status = $this->status;
if ( $this->status === MobileDevice::STATUS_ACTIVE ){
// only one card can be active at the same time
MobileDevice::updateAll([
'activated_at' => null,
'status' => MobileDevice::STATUS_DELETED_SYSTEM
],
[
'id_card' => $device->id_card
]
);
}
if ($this->status === MobileDevice::STATUS_ACTIVE) {
if (!isset($device->activated_at)) {
$device->activated_at = Helper::getDateTimeString();
}
} else {
$device->activated_at = null;
}
$device->save(false);
$customer = Customer::find()->andWhere(['id_customer_card' => $device->id_card])->one();
Log::log([
'type' => Log::$TYPE_MOBILE_DEVICE_STATUS,
'message' => "Eszkösz $device->id; Kártya: $card->number; előző státusz: $origStatus; új státusz: $this->status",
'id_customer' => $customer->id_customer
]);
$tx->commit();
}catch ( \Exception $e){
\Yii::error("Failed to save status for device $this->id_device :".$e->getMessage());
if ( $tx != null ){
$tx->rollBack();
}
throw $e;
}
}
}

View File

@@ -8,7 +8,7 @@ use common\models\Card;
use common\models\Customer;
use common\models\Product;
use common\models\Transfer;
use yii\base\Object;
use yii\base\BaseObject;
use common\models\Account;
use common\models\Discount;
use common\models\Currency;

View File

@@ -6,7 +6,7 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
use yii\base\Object;
use yii\base\BaseObject;
use yii\db\Query;
use yii\db\Expression;
use common\models\Account;

View File

@@ -1,5 +1,5 @@
<?php
use yii\base\Object;
use yii\base\BaseObject;
use common\models\Ticket;
?>
<style>
@@ -38,4 +38,4 @@ use common\models\Ticket;
<?php }?>
</table>
</div>
</div>

View File

@@ -1,57 +1,85 @@
<?php
use yii\helpers\Url;
?>
<?php
$route = Yii::$app->controller->id .'/'. Yii::$app->controller->action->id;
$route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
/** @noinspection PhpUnhandledExceptionInspection */
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
$items = [
[ 'Recepció', ['customer/reception', 'number' => $card->number ]],
[ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
[ 'Adatlap', ['customer/update', 'number' => $card->number ]],
[ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
[ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
[ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
[ 'Kártya', ['card/info', 'id_card' => $card->id_card ]],
[ 'Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card , 'LogSearch[start]' => $todayDateTime ]],
[ 'Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card ]],
[ 'Jelszó küldése', ['customer/password-change', 'id_card' => $card->id_card ]],
['Recepció', ['customer/reception', 'number' => $card->number]],
['Termék eladás', ['product/sale', 'number' => $card->number]],
['Adatlap', ['customer/update', 'number' => $card->number]],
['Befizetések', ['ticket/index', 'number' => $card->number]],
['Kulcsok', ['key/index', 'id_card' => $card->id_card]],
['Szerződések', ['contract/index', 'id_card' => $card->id_card]],
['Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card]],
['Kártya', ['card/info', 'id_card' => $card->id_card]],
['Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card, 'LogSearch[start]' => $todayDateTime]],
['Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card]],
['Jelszó küldése', ['customer/password-change', 'id_card' => $card->id_card]],
['Mobil Eszközök', ['mobile-device/index', 'id_card' => $card->id_card]],
];
?>
<style>
.fitness-nav {
}
.fitness-nav-item.active a, .fitness-nav-item a:hover {
background: #0b93d5;
}
.fitness-nav-item > a {
padding: 8px 16px;
display: block;
margin-bottom: 8px;
background: #204d74;
color: #ffffff;
border-radius: 4px;
text-align: center;
}
.fitness-nav-container{
background: #e2e2e2;
padding: 8px 8px 0 8px;
border-radius: 4px;
}
</style>
<div class="fitness-nav-container">
<ul class="nav nav-tabs">
<?php foreach ($items as $item){?>
<?php
if ( empty($title)){
if ( $item[1][0] == $route) {
$title = $item[0];
}
}
?>
<li role="presentation" class="<?php echo $item[1][0] == $route ? 'active' : '' ?>"><a href="<?php echo Url::toRoute($item[1])?>"><?php echo $item[0] ?></a></li>
<?php }?>
</ul>
<div class="row fitness-nav">
<?php foreach ($items as $item) { ?>
<?php
if (empty($title)) {
if ($item[1][0] == $route) {
$title = $item[0];
}
}
?>
<div role="presentation"
class="col-xs-12 col-md-3 col-lg-2 fitness-nav-item <?php echo $item[1][0] == $route ? 'active' : '' ?>"><a
href="<?php echo Url::toRoute($item[1]) ?>"><?php echo $item[0] ?></a></div>
<?php } ?>
</div>
</div>
<?php if ( !empty($title)) {?>
<h1><?php echo $title?></h1>
<?php if (!empty($title)) { ?>
<h1><?php echo $title ?></h1>
<p>Vendég: <?php echo $card->customer->name ?></p>
<p>Kártyaszám: <?php echo $card->number ?></p>
<?php }?>
<?php } ?>

View File

@@ -13,57 +13,69 @@ use yii\helpers\Url;
<?php
if ( $model->isCardWithCustomer() ){
$attributes = [
[
'label' => 'Kártyaszám',
'value' => $model->card->number
],
[
'label' => 'Vendég',
'value' => $model->customer->name
],
[
'label' => 'E-Mail',
'value' => $model->customer->email
],
[
'label' => 'Telefon',
'value' => $model->customer->phone
],
[
'label' => 'Kiadott törölközők',
'value' => $model->customer->towel_count
],
[
'label' => 'Kulcsok',
'value' =>
empty($model->keysText) ? '' : (
"<form method='POST' action='". Url::toRoute(['key/toggle', "number" => $model->card->number])."'>"
.$model->keysText
.Html::hiddenInput("KeyToggleForm[key]", $model->keysText)
.Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs'])
."</form>")
,
'format' => 'raw'
],
[
'label' => 'Fénykép',
'value' => $model->customer->image1 ? Html::img( Url::base( ) . Image::thumb( $model->customer->image1->path,160,120 )) : 'Nincs kép',
'format' => 'raw'
],
];
?>
<div class="row">
<div class="col-md-12">
<?php
echo DetailView::widget([
'model' => $model,
'attributes' =>[
[
'label' => 'Kártyaszám',
'value' => $model->card->number
],
[
'label' => 'Vendég',
'value' => $model->customer->name
],
[
'label' => 'E-Mail',
'value' => $model->customer->email
],
[
'label' => 'Telefon',
'value' => $model->customer->phone
],
[
'label' => 'Kiadott törölközők',
'value' => $model->customer->towel_count
],
[
'label' => 'Kulcsok',
'value' =>
empty($model->keysText) ? '' : (
"<form method='POST' action='". Url::toRoute(['key/toggle', "number" => $model->card->number])."'>"
.$model->keysText
.Html::hiddenInput("KeyToggleForm[key]", $model->keysText)
.Html::submitButton("Visszaad", [ 'style' => 'float: right;', 'class' => 'btn btn-primary btn-xs'])
."</form>")
,
'format' => 'raw'
],
[
'label' => 'Fénykép',
'value' => $model->customer->image1 ? Html::img( Url::base( ) . Image::thumb( $model->customer->image1->path,160,120 )) : 'Nincs kép',
'format' => 'raw'
],
]
'attributes' => $attributes
])
?>
<div>
<?php
echo Html::a('Menü',['customer/update', 'number' => $model->card->number],['class' => 'btn btn-success me-3']);
if ( isset($showLinkDevices) && $showLinkDevices === true ) {
echo Html::a('Eszköz aktiválása', ['mobile-device/index', 'id_card' => $model->card->id_card], ['class' => 'btn btn-success']);
}?>
</div>
</div>
</div>
<?php
}
?>
?>

View File

@@ -13,7 +13,7 @@ use yii\helpers\Url;
<?php
/** @var \common\models\Ticket $ticket */
$ticket = null;
if (count($model->tickets) > 0) {
if ( isset($model->tickets) && count($model->tickets) > 0) {
$ticket = $model->tickets[0];
}

View File

@@ -7,7 +7,6 @@ $options = [];
if ( $model instanceof frontend\models\CustomerCreate){
$options['image_data' ] = 'customercreate-photo_data';
}else{
}
$this->registerJs ( 'new Customer( '. json_encode($options).');' );
?>
@@ -16,14 +15,59 @@ $this->registerJs ( 'new Customer( '. json_encode($options).');' );
.photo{
border: 1px solid gray;
}
#video {
border: 1px solid black;
box-shadow: 2px 2px 3px black;
width: 160px;
height: 120px;
}
#photo {
border: 1px solid black;
box-shadow: 2px 2px 3px black;
width: 160px;
height: 120px;
}
#canvas {
display: none;
}
.camera {
width: 160px;
display: inline-block;
}
.output {
width: 340px;
display: inline-block;
vertical-align: top;
}
.contentarea {
font-size: 16px;
font-family: "Lucida Grande", "Arial", sans-serif;
width: 760px;
}
</style>
<div class="row" style='margin-top: 12px;' >
<div class="col-md-4">
<div id="my_camera" class='photo pull-left' style="width: 160px; height: 120px; margin-right: 12px;"></div>
<div id="my_result" class='photo pull-left' style="width: 160px; height: 120px;"></div>
</div>
<div class="col-md-4">
</div>
<!--<div class="row" style='margin-top: 12px;' >-->
<!-- <div class="col-md-4">-->
<!-- <div id="my_camera" class='photo pull-left' style="width: 160px; height: 120px; margin-right: 12px;"></div>-->
<!-- <div id="my_result" class='photo pull-left' style="width: 160px; height: 120px;"></div>-->
<!-- </div>-->
<!-- <div class="col-md-4">-->
<!-- </div>-->
<!--</div>-->
<div class="camera">
<video id="video">Video stream not available.</video>
<!-- <button id="startbutton">Take photo</button>-->
</div>
<canvas id="canvas"> </canvas>
<div class="output">
<img id="photo" alt="The screen capture will appear in this box." />
</div>
<a id="snap" class="btn btn-primary" style="margin-top: 6px;" >Fénykép</a>

View File

@@ -0,0 +1,86 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use common\models\MobileDevice;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\CollectionSearch */
/* @var $card \common\models\Card */
/* @var $dataProvider \frontend\controllers\MobileDeviceController */
$this->title = "Vendég - mobil eszközök";
$this->params['breadcrumbs'][] = "Vendég";
$this->params['breadcrumbs'][] = "Mobil eszközök";
echo \frontend\components\CustomerTabWidget::widget(['card' => $card]);
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'card_number',
'label' => 'Kártyaszám',
],
[
'attribute' => 'device_name',
'label' => 'Eszköz neve',
],
[
'attribute' => 'device_created_at',
'label' => 'Létrehozva',
'format' => 'datetime'
],
[
'attribute' => 'device_status',
'label' => 'Státusz',
'value' => function ($model, $key, $index, $column) {
return MobileDevice::toStatusHumanReadable($model['device_status']);
}
],
['class' => 'yii\grid\ActionColumn',
'header' => 'Műveletek',
'template' => '{activate} {delete}',
'buttons' => [
'activate' => function ($url, $model, $key) {
$status = $model['device_status'];
if ($status == MobileDevice::STATUS_ACTIVE) {
return null;
}
$options = [
'title' => 'Az aktuális eszköz aktiválása',
'data-confirm' => "Biztosan aktiválni szerenté ezt az eszközt?",
'data-method' => 'post',
'class' => 'btn btn-xs btn-success'
];
return Html::a('Aktivál', $url, $options);
},
'delete' => function ($url, $model, $key) {
$status = $model['device_status'];
if ($status !== MobileDevice::STATUS_ACTIVE) {
return null;
}
$options = [
'title' => 'Az aktuális eszköz törlése',
'data-confirm' => "Biztosan törölni szerenté ezt az eszközt?",
'data-method' => 'post',
'class' => 'btn btn-xs btn-danger'
];
return Html::a('Töröl', $url, $options);
},
],
'urlCreator' => function ($action, $model, $key, $index) {
$status = MobileDevice::STATUS_DELETED_MANUAL;
if ($action === 'activate') {
$status = MobileDevice::STATUS_ACTIVE;
}
$url = Url::to(['mobile-device/status', 'id_device' => $model['device_id'], 'status' => $status]);
return $url;
}
],
],
]); ?>

View File

@@ -24,7 +24,7 @@ $this->params['breadcrumbs'][] = $this->title;
$dt->sub( new DateInterval( 'P2D') );
echo \common\components\DateUtil::formatUtc($dt);
echo \common\components\DateUtil::formatDateTimeUtc($dt);
echo " - ";
@@ -33,7 +33,7 @@ $this->params['breadcrumbs'][] = $this->title;
$ticketType->time_unit_count = 3;
$dt2 = \common\components\Helper::getTicketExpirationDate($dt, $ticketType);
echo \common\components\DateUtil::formatUtc($dt2);
echo \common\components\DateUtil::formatDateTimeUtc($dt2);
// $dt2 = \common\components\Helper::getTicketExpirationDate($dt, $ticketType);
// echo \common\components\DateUtil::formatUtc($dt2);

View File

@@ -97,6 +97,141 @@ a.desc:after {
border-color: #faebcc;
}
:root{
--spacer-1: 0.25rem;
--spacer-2: 0.5rem;
--spacer-3: 1rem;
--spacer-4: 1.5rem;
--spacer-5: 3rem;
}
.px-1{
padding-left: var(--spacer-1);
padding-right: var(--spacer-1);
}
.px-2{
padding-left: var(--spacer-2);
padding-right: var(--spacer-2);
}
.px-3{
padding-left: var(--spacer-3);
padding-right: var(--spacer-3);
}
.px-4{
padding-left: var(--spacer-4);
padding-right: var(--spacer-4);
}
.py-1{
padding-top: var(--spacer-1);
padding-bottom: var(--spacer-1);
}
.py-2{
padding-top: var(--spacer-2);
padding-bottom: var(--spacer-2);
}
.py-3{
padding-top: var(--spacer-3);
padding-bottom: var(--spacer-3);
}
.py-4{
padding-top: var(--spacer-4);
padding-bottom: var(--spacer-4);
}
.ps-1{
padding-left: var(--spacer-1);
}
.ps-2{
padding-left: var(--spacer-2);
}
.ps-3{
padding-left: var(--spacer-3);
}
.ps-4{
padding-left: var(--spacer-4);
}
.pe-1{
padding-right: var(--spacer-1);
}
.pe-2{
padding-right: var(--spacer-2);
}
.pe-3{
padding-right: var(--spacer-3);
}
.pe-4{
padding-right: var(--spacer-4);
}
/**
margins
*/
.mx-1{
margin-left: var(--spacer-1);
margin-right: var(--spacer-1);
}
.mx-2{
margin-left: var(--spacer-2);
margin-right: var(--spacer-2);
}
.mx-3{
margin-left: var(--spacer-3);
margin-right: var(--spacer-3);
}
.mx-4{
margin-left: var(--spacer-4);
margin-right: var(--spacer-4);
}
.my-1{
margin-top: var(--spacer-1);
margin-bottom: var(--spacer-1);
}
.my-2{
margin-top: var(--spacer-2);
margin-bottom: var(--spacer-2);
}
.my-3{
margin-top: var(--spacer-3);
margin-bottom: var(--spacer-3);
}
.my-4{
margin-top: var(--spacer-4);
margin-bottom: var(--spacer-4);
}
.ms-1{
margin-left: var(--spacer-1);
}
.ms-2{
margin-left: var(--spacer-2);
}
.ms-3{
margin-left: var(--spacer-3);
}
.ms-4{
margin-left: var(--spacer-4);
}
.me-1{
margin-right: var(--spacer-1);
}
.me-2{
margin-right: var(--spacer-2);
}
.me-3{
margin-right: var(--spacer-3);
}
.me-4{
margin-right: var(--spacer-4);
}
.event-theme-active-0 {

View File

@@ -11,15 +11,15 @@ function Customer(o){
defaults = $.extend(defaults,o);
var url = location.href;
var initCamera;
// var initCamera;
console.info(url);
if ( url.indexOf("https") >= 0){
initCamera = true;
}else if ( url.indexOf("localhost") >= 0 ){
initCamera = true;
}
if ( initCamera ){
Webcam.set({
// if ( url.indexOf("https") >= 0){
// initCamera = true;
// }else if ( url.indexOf("localhost") >= 0 ){
// initCamera = true;
// }
// if ( initCamera ){
/* Webcam.set({
width: 160,
height: 120,
dest_width: 320,
@@ -28,10 +28,10 @@ function Customer(o){
jpeg_quality: 90
});
Webcam.attach( '#my_camera' );
$("#snap").click(snap);
}else{
$("#snap").hide();
}
$("#snap").click(snap);*/
// }else{
//$("#snap").hide();
// }
@@ -69,15 +69,164 @@ function Customer(o){
});
}
function snap(){
Webcam.snap( function(data_uri) {
document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>';
var raw_image_data = data_uri.replace(/^data\:image\/\w+\;base64\,/, '');
// function snap(){
// Webcam.snap( function(data_uri) {
// document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>';
//
// var raw_image_data = data_uri.replace(/^data\:image\/\w+\;base64\,/, '');
//
// document.getElementById(defaults.image_data ).value = raw_image_data;
//
// } );
// }
(() => {
// The width and height of the captured photo. We will set the
// width to the value defined here, but the height will be
// calculated based on the aspect ratio of the input stream.
const width = 320; // We will scale the photo width to this
let height = 0; // This will be computed based on the input stream
// |streaming| indicates whether or not we're currently streaming
// video from the camera. Obviously, we start at false.
let streaming = false;
// The various HTML elements we need to configure or control. These
// will be set by the startup() function.
let video = null;
let canvas = null;
let photo = null;
// let startbutton = null;
let snapButton = null;
function showViewLiveResultButton() {
if (window.self !== window.top) {
// Ensure that if our document is in a frame, we get the user
// to first open it in its own tab or window. Otherwise, it
// won't be able to request permission for camera access.
document.querySelector(".contentarea").remove();
const button = document.createElement("button");
button.textContent = "View live result of the example code above";
document.body.append(button);
button.addEventListener("click", () => window.open(location.href));
return true;
}
return false;
}
function startup() {
if (showViewLiveResultButton()) {
return;
}
video = document.getElementById("video");
canvas = document.getElementById("canvas");
photo = document.getElementById("photo");
// startbutton = document.getElementById("startbutton");
snapButton = document.getElementById("snap");
navigator.mediaDevices
.getUserMedia({ video: true, audio: false })
.then((stream) => {
video.srcObject = stream;
video.play();
})
.catch((err) => {
console.error(`An error occurred: ${err}`);
});
video.addEventListener(
"canplay",
(ev) => {
if (!streaming) {
height = video.videoHeight / (video.videoWidth / width);
// Firefox currently has a bug where the height can't be read from
// the video, so we will make assumptions if this happens.
if (isNaN(height)) {
height = width / (4 / 3);
}
video.setAttribute("width", width);
video.setAttribute("height", height);
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
streaming = true;
}
},
false
);
// startbutton.addEventListener(
// "click",
// (ev) => {
// takepicture();
// ev.preventDefault();
// },
// false
// );
snapButton.addEventListener(
"click",
(ev) => {
takepicture();
ev.preventDefault();
},
false
);
clearphoto();
}
// Fill the photo with an indication that none has been
// captured.
function clearphoto() {
const context = canvas.getContext("2d");
context.fillStyle = "#AAA";
context.fillRect(0, 0, canvas.width, canvas.height);
const data = canvas.toDataURL("image/png");
photo.setAttribute("src", data);
}
// Capture a photo by fetching the current contents of the video
// and drawing it into a canvas, then converting that to a PNG
// format data URL. By drawing it on an offscreen canvas and then
// drawing that to the screen, we can change its size and/or apply
// other changes before drawing it.
function takepicture() {
const context = canvas.getContext("2d");
if (width && height) {
canvas.width = width;
canvas.height = height;
context.drawImage(video, 0, 0, width, height);
const dataURL = canvas.toDataURL("image/jpg");
photo.setAttribute("src", dataURL);
// console.info("datauri",dataURL);
// document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>';
var raw_image_data = dataURL.replace(/^data\:image\/\w+\;base64\,/, '');
document.getElementById(defaults.image_data ).value = raw_image_data;
} else {
clearphoto();
}
}
// Set up our event listener to run the startup process
// once loading is complete.
window.addEventListener("load", startup, false);
})();
document.getElementById(defaults.image_data ).value = raw_image_data;
} );
}
}