add contraint , that everybody expect admin is limited to 3 days, Add card package
This commit is contained in:
parent
556bdc3066
commit
70f43468af
@ -78,6 +78,8 @@ class AdminMenuStructure{
|
|||||||
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
||||||
$items[] = ['label' => 'Bérletek', 'url' => ['/ticket/index' , 'TicketSearch[start]' =>$today,'TicketSearch[end]' => $tomorrow ] ];
|
$items[] = ['label' => 'Bérletek', 'url' => ['/ticket/index' , 'TicketSearch[start]' =>$today,'TicketSearch[end]' => $tomorrow ] ];
|
||||||
$items[] = ['label' => 'Statisztika', 'url' => ['/ticket/statistics' , 'TicketSearchStatisitcs[start]' =>$today,'TicketSearchStatisitcs[end]' => $tomorrow ] ];
|
$items[] = ['label' => 'Statisztika', 'url' => ['/ticket/statistics' , 'TicketSearchStatisitcs[start]' =>$today,'TicketSearchStatisitcs[end]' => $tomorrow ] ];
|
||||||
|
$items[] = ['label' => 'Kártya létrehozás', 'url' => ['/card-package/index' , ] ];
|
||||||
|
$items[] = ['label' => 'Kártya csomag RFId hozzárendelés', 'url' => ['/card-package/import' , ] ];
|
||||||
$this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl,
|
$this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
];
|
];
|
||||||
@ -119,7 +121,7 @@ class AdminMenuStructure{
|
|||||||
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
|
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
|
||||||
// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
|
// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
|
||||||
// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
||||||
if ( RoleDefinition::isAdmin() || RoleDefinition::isEmployee() ){
|
if ( RoleDefinition::isAdmin() ){
|
||||||
$this->menuItems[] = ['label' => 'Tartós megbízások', 'url' => $this->emptyUrl,
|
$this->menuItems[] = ['label' => 'Tartós megbízások', 'url' => $this->emptyUrl,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
];
|
];
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use yii\helpers\Json;
|
|||||||
use backend\models\CardImportRfidForm;
|
use backend\models\CardImportRfidForm;
|
||||||
use yii\web\UploadedFile;
|
use yii\web\UploadedFile;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
|
use backend\models\CardInsertForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CardController implements the CRUD actions for Card model.
|
* CardController implements the CRUD actions for Card model.
|
||||||
@ -30,7 +31,8 @@ class CardController extends \backend\controllers\BackendController {
|
|||||||
'view',
|
'view',
|
||||||
'update',
|
'update',
|
||||||
'list' ,
|
'list' ,
|
||||||
'import-rfid'
|
'import-rfid',
|
||||||
|
'insert'
|
||||||
],
|
],
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => [
|
'roles' => [
|
||||||
@ -224,6 +226,7 @@ class CardController extends \backend\controllers\BackendController {
|
|||||||
|
|
||||||
$failed = [];
|
$failed = [];
|
||||||
$sqls = [];
|
$sqls = [];
|
||||||
|
$inserts = [];
|
||||||
foreach ($arr as $item ){
|
foreach ($arr as $item ){
|
||||||
$card = Card::find()->andWhere(['number' => $item['number']])->one();
|
$card = Card::find()->andWhere(['number' => $item['number']])->one();
|
||||||
if ( $card != null ){
|
if ( $card != null ){
|
||||||
@ -232,7 +235,17 @@ class CardController extends \backend\controllers\BackendController {
|
|||||||
$sqls[] = $sql;
|
$sqls[] = $sql;
|
||||||
$i++;
|
$i++;
|
||||||
}else{
|
}else{
|
||||||
$failed [] = $item;
|
// $failed [] = $item;
|
||||||
|
$sql = "insert into card (number,status,type,created_at,updated_at, rfid_key) values(";
|
||||||
|
$sql .= " '" .$item['number'] . "'" ;
|
||||||
|
$sql .= " ," . Card::STATUS_ACTIVE ;
|
||||||
|
$sql .= " ," . Card::TYPE_RFID;
|
||||||
|
$sql .= " ,'" . date("Y-m-d H:i:s") ."'" ;
|
||||||
|
$sql .= " ,'" . date("Y-m-d H:i:s") ."'" ;
|
||||||
|
$sql .=" ,'" .$item['key'] ."'";
|
||||||
|
$sql .= " );";
|
||||||
|
$inserts[] = $sql;
|
||||||
|
// rfid_key = '" . strtolower( $item['key'] )."' where id_card = " .$card->id_card .";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +254,8 @@ class CardController extends \backend\controllers\BackendController {
|
|||||||
$model->message .= "<br> failed: " . print_r($failed,true);
|
$model->message .= "<br> failed: " . print_r($failed,true);
|
||||||
$model->message .= "<br>sql:";
|
$model->message .= "<br>sql:";
|
||||||
$model->message .= "<br>". implode("<br>", $sqls);
|
$model->message .= "<br>". implode("<br>", $sqls);
|
||||||
|
$model->message .= "<br><br><br>Inserts<br><br><br>";
|
||||||
|
$model->message .= "<br>". implode("<br>", $inserts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,4 +263,90 @@ class CardController extends \backend\controllers\BackendController {
|
|||||||
'model' => $model
|
'model' => $model
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function actionInsert() {
|
||||||
|
$model = new CardInsertForm();
|
||||||
|
$arr = [];
|
||||||
|
|
||||||
|
if (Yii::$app->request->isPost) {
|
||||||
|
$model->file = UploadedFile::getInstance($model, 'file');
|
||||||
|
|
||||||
|
// print_r($model->file);
|
||||||
|
// $model->message = "ok";
|
||||||
|
$file = $model->file->tempName;
|
||||||
|
|
||||||
|
$file = fopen ( $file , "r" );
|
||||||
|
|
||||||
|
$trans = null;
|
||||||
|
$i = 0;
|
||||||
|
$j = 0;
|
||||||
|
while ( ($data = fgetcsv ( $file, 0, "," )) != null ) {
|
||||||
|
// if ($i == 0) {
|
||||||
|
// $i ++;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
$j++;
|
||||||
|
$number = $key = false;
|
||||||
|
if ( isset($data[0]) ){
|
||||||
|
$number = $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($data[1]) ){
|
||||||
|
$key = $data[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($number) && isset($key) && !strpos($key, "E+") && strlen($key) > 7 ){
|
||||||
|
$item = [];
|
||||||
|
$item['number'] = $number;
|
||||||
|
$item['key'] = Helper::fixAsciiChars( $key);
|
||||||
|
$arr[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$failed = [];
|
||||||
|
$sqls = [];
|
||||||
|
$inserts = [];
|
||||||
|
foreach ($arr as $item ){
|
||||||
|
// $failed [] = $item;
|
||||||
|
$sql = "insert into card (number,status,type,created_at,updated_at, rfid_key) values(";
|
||||||
|
$sql .= " '" .$item['number'] . "'" ;
|
||||||
|
$sql .= " ," . Card::STATUS_ACTIVE ;
|
||||||
|
$sql .= " ," . Card::TYPE_RFID;
|
||||||
|
$sql .= " ,'" . date("Y-m-d H:i:s") ."'" ;
|
||||||
|
$sql .= " ,'" . date("Y-m-d H:i:s") ."'" ;
|
||||||
|
$sql .=" ,'" .$item['key'] ."'";
|
||||||
|
$sql .= " );";
|
||||||
|
$inserts[] = $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->message = "rows read: " .$j ." / ". "updated cards: " .$i;
|
||||||
|
$model->message .= "<br> array size: " . count($arr);
|
||||||
|
$model->message .= "<br> failed: " . print_r($failed,true);
|
||||||
|
$model->message .= "<br>sql:";
|
||||||
|
$model->message .= "<br>". implode("<br>", $sqls);
|
||||||
|
$model->message .= "<br><br><br>Inserts<br><br><br>";
|
||||||
|
$model->message .= "<br>". implode("<br>", $inserts);
|
||||||
|
|
||||||
|
|
||||||
|
$inserts = implode("\n", $inserts);
|
||||||
|
header("Content-type:text/plain"); //for pdf file
|
||||||
|
//header('Content-Type:text/plain; charset=ISO-8859-15');
|
||||||
|
//if you want to read text file using text/plain header
|
||||||
|
header('Content-Disposition: attachment; filename="insert.sql"');
|
||||||
|
header('Content-Length: ' . strlen($inserts));
|
||||||
|
echo $inserts;
|
||||||
|
exit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render ( 'insert.php', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
315
backend/controllers/CardPackageController.php
Normal file
315
backend/controllers/CardPackageController.php
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\CardPackage;
|
||||||
|
use backend\models\CardPackageSearch;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use common\components\Helper;
|
||||||
|
use common\components\FreeUniqueCardNumberGenerator;
|
||||||
|
use common\models\Card;
|
||||||
|
use common\models\CardCardPackageAssignment;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use backend\models\CardPackageImportForm;
|
||||||
|
use common\components\XLSUtil;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
use common\components\Upload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CardPackageController implements the CRUD actions for CardPackage model.
|
||||||
|
*/
|
||||||
|
class CardPackageController extends Controller {
|
||||||
|
public function behaviors() {
|
||||||
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::className (),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => [
|
||||||
|
'post'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all CardPackage models.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndex() {
|
||||||
|
$searchModel = new CardPackageSearch ();
|
||||||
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
|
return $this->render ( 'index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a single CardPackage model.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionView($id) {
|
||||||
|
$model = $this->findModel ( $id );
|
||||||
|
|
||||||
|
$query = Card::find ();
|
||||||
|
$query->innerJoin ( "card_card_package_assignment", "card_card_package_assignment.id_card = card.id_card " );
|
||||||
|
$query->andWhere ( [
|
||||||
|
'card_card_package_assignment.id_card_package' => $id
|
||||||
|
] );
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider ( [
|
||||||
|
'query' => $query
|
||||||
|
] );
|
||||||
|
|
||||||
|
return $this->render ( 'view', [
|
||||||
|
'model' => $model,
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
public function actionDownload($id) {
|
||||||
|
$model = $this->findModel ( $id );
|
||||||
|
|
||||||
|
$model->updateCounters ( [
|
||||||
|
'printed' => 1
|
||||||
|
] );
|
||||||
|
|
||||||
|
$query = Card::find ();
|
||||||
|
$query->innerJoin ( "card_card_package_assignment", "card_card_package_assignment.id_card = card.id_card " );
|
||||||
|
$query->andWhere ( [
|
||||||
|
'card_card_package_assignment.id_card_package' => $id
|
||||||
|
] );
|
||||||
|
|
||||||
|
$cards = $query->all ();
|
||||||
|
|
||||||
|
$numbers = [ ];
|
||||||
|
foreach ( $cards as $card ) {
|
||||||
|
$numbers [] = $card->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->generateXLS ( $model, $numbers );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CardPackage model.
|
||||||
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionCreate() {
|
||||||
|
$model = new CardPackage ();
|
||||||
|
$model->id_user = \Yii::$app->user->id;
|
||||||
|
$model->printed = 0;
|
||||||
|
|
||||||
|
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||||
|
$conn = \Yii::$app->db;
|
||||||
|
$tx = $conn->beginTransaction ();
|
||||||
|
|
||||||
|
$model->save ( false );
|
||||||
|
|
||||||
|
$count = $model->count;
|
||||||
|
|
||||||
|
$numGen = new FreeUniqueCardNumberGenerator ( [
|
||||||
|
'count' => $model->count,
|
||||||
|
'prefix' => '10'
|
||||||
|
] );
|
||||||
|
|
||||||
|
$numGen->generate ();
|
||||||
|
|
||||||
|
$numbers = $numGen->cache;
|
||||||
|
|
||||||
|
try {
|
||||||
|
foreach ( $numbers as $number ) {
|
||||||
|
|
||||||
|
$card = new Card ();
|
||||||
|
$card->number = $number;
|
||||||
|
$card->type = Card::TYPE_RFID;
|
||||||
|
$card->status = Card::STATUS_ACTIVE;
|
||||||
|
$card->save ( false );
|
||||||
|
|
||||||
|
$cardAssignment = new CardCardPackageAssignment ();
|
||||||
|
$cardAssignment->id_card = $card->id_card;
|
||||||
|
$cardAssignment->id_card_package = $model->id_card_package;
|
||||||
|
$cardAssignment->save ( false );
|
||||||
|
}
|
||||||
|
$tx->commit ();
|
||||||
|
|
||||||
|
return $this->redirect ( [
|
||||||
|
'index'
|
||||||
|
] );
|
||||||
|
} catch ( \Exception $e ) {
|
||||||
|
$tx->rollBack ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render ( 'create', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
} else {
|
||||||
|
return $this->render ( 'create', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function generateXLS($model, $numbers) {
|
||||||
|
$objPHPExcel = new \PHPExcel ();
|
||||||
|
|
||||||
|
$sheet = $objPHPExcel->setActiveSheetIndex ( 0 );
|
||||||
|
|
||||||
|
// $row = 1;
|
||||||
|
// $sheet->setCellValue('A'.$row, "Termék név")
|
||||||
|
// ->setCellValue('B'.$row, "Eladási ár")
|
||||||
|
// ->setCellValue('C'.$row, "Kassza")
|
||||||
|
// ->setCellValue('D'.$row, "Eladott mennyiség")
|
||||||
|
// ->setCellValue('E'.$row, "Eladás összege");
|
||||||
|
$row = 0;
|
||||||
|
|
||||||
|
foreach ( $numbers as $number ) {
|
||||||
|
$row ++;
|
||||||
|
$sheet->setCellValue ( 'A' . $row, $number );
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = "kartya_csomag";
|
||||||
|
$fileName .= "_" . $model->id_card_package;
|
||||||
|
$fileName .= "_" . date ( "Ymd_His" );
|
||||||
|
$fileName .= ".xls";
|
||||||
|
|
||||||
|
// Redirect output to a client’s web browser (Excel5)
|
||||||
|
header ( 'Content-Type: application/vnd.ms-excel' );
|
||||||
|
header ( 'Content-Disposition: attachment;filename="' . $fileName . '"' );
|
||||||
|
header ( 'Cache-Control: max-age=0' );
|
||||||
|
// If you're serving to IE 9, then the following may be needed
|
||||||
|
header ( 'Cache-Control: max-age=1' );
|
||||||
|
// If you're serving to IE over SSL, then the following may be needed
|
||||||
|
header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past
|
||||||
|
header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified
|
||||||
|
header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1
|
||||||
|
header ( 'Pragma: public' ); // HTTP/1.0
|
||||||
|
$objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' );
|
||||||
|
$objWriter->save ( 'php://output' );
|
||||||
|
exit ();
|
||||||
|
}
|
||||||
|
public function actionImport() {
|
||||||
|
$model = new CardPackageImportForm ();
|
||||||
|
|
||||||
|
if (Yii::$app->request->isPost) {
|
||||||
|
$model->file = UploadedFile::getInstance ( $model, 'file' );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($model->validate ()) {
|
||||||
|
|
||||||
|
|
||||||
|
// print_r($model->file);
|
||||||
|
// $model->message = "ok";
|
||||||
|
$file = $model->file->tempName;
|
||||||
|
$xlsUtil = new XLSUtil ();
|
||||||
|
$xlsUtil->loadFromFileName ( $file );
|
||||||
|
$array = $xlsUtil->toArray ();
|
||||||
|
|
||||||
|
// print_r($array);
|
||||||
|
// print_r( array_column($array, 2));
|
||||||
|
|
||||||
|
// foreach ($array as $item ){
|
||||||
|
// echo $item[2];
|
||||||
|
// }
|
||||||
|
|
||||||
|
foreach ( $array as $row ) {
|
||||||
|
try {
|
||||||
|
$tx = \Yii::$app->db->beginTransaction ();
|
||||||
|
|
||||||
|
$card = Card::find ()->andWhere ( [
|
||||||
|
'number' => $row [0]
|
||||||
|
] )->one ();
|
||||||
|
|
||||||
|
if ( isset( $card )) {
|
||||||
|
$card->rfid_key = Helper::fixAsciiChars( $row [2 ] );
|
||||||
|
$card->save(false);
|
||||||
|
}else{
|
||||||
|
throw new \Exception("Card not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$tx->commit ();
|
||||||
|
|
||||||
|
$model->done = $model->done + 1;
|
||||||
|
} catch ( \Exception $e ) {
|
||||||
|
$tx->rollBack ();
|
||||||
|
$model->failed = $model->failed + 1;
|
||||||
|
\Yii::error ( "Failed to import card rfid: " . print_r ( $row, true ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
\Yii::$app->session->setFlash ( 'success', "Az importálás eredménye: sikeres:" . $model->done . "; Sikertelen: " . $model->failed );
|
||||||
|
|
||||||
|
\Yii::info('Importálás: sikeres: ' .$model->done . " , sikertelen: " . $model->failed);
|
||||||
|
return $this->redirect ( [
|
||||||
|
'card-package/import'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render ( "import", [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing CardPackage model.
|
||||||
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionUpdate($id) {
|
||||||
|
$model = $this->findModel ( $id );
|
||||||
|
|
||||||
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
|
return $this->redirect ( [
|
||||||
|
'view',
|
||||||
|
'id' => $model->id_card_package
|
||||||
|
] );
|
||||||
|
} else {
|
||||||
|
return $this->render ( 'update', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing CardPackage model.
|
||||||
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionDelete($id) {
|
||||||
|
$this->findModel ( $id )->delete ();
|
||||||
|
|
||||||
|
return $this->redirect ( [
|
||||||
|
'index'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the CardPackage model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return CardPackage the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id) {
|
||||||
|
if (($model = CardPackage::findOne ( $id )) !== null) {
|
||||||
|
return $model;
|
||||||
|
} else {
|
||||||
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ use yii\data\ActiveDataProvider;
|
|||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use common\components\RoleDefinition;
|
use common\components\RoleDefinition;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountStateSearch represents the model behind the search form about `common\models\AccountState`.
|
* AccountStateSearch represents the model behind the search form about `common\models\AccountState`.
|
||||||
@ -65,6 +66,8 @@ class AccountStateSearch extends AccountState
|
|||||||
if ( RoleDefinition::isReception()){
|
if ( RoleDefinition::isReception()){
|
||||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['account_state.created_at'],"date" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
|||||||
30
backend/models/CardInsertForm.php
Normal file
30
backend/models/CardInsertForm.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use common\models\Card;
|
||||||
|
use common\models\Customer;
|
||||||
|
use common\models\Ticket;
|
||||||
|
use common\models\Account;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContactForm is the model behind the contact form.
|
||||||
|
* @property \Yii\web\UploadedFile $file
|
||||||
|
*/
|
||||||
|
class CardInsertForm extends Model{
|
||||||
|
|
||||||
|
public $file;
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
public function rules(){
|
||||||
|
return [
|
||||||
|
[['file'], 'file']
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
32
backend/models/CardPackageImportForm.php
Normal file
32
backend/models/CardPackageImportForm.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use common\models\Card;
|
||||||
|
use common\models\Customer;
|
||||||
|
use common\models\Ticket;
|
||||||
|
use common\models\Account;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContactForm is the model behind the contact form.
|
||||||
|
* @property \Yii\web\UploadedFile $file
|
||||||
|
*/
|
||||||
|
class CardPackageImportForm extends Model{
|
||||||
|
|
||||||
|
public $file;
|
||||||
|
public $failed = 0;
|
||||||
|
public $done = 0;
|
||||||
|
|
||||||
|
public function rules(){
|
||||||
|
return [
|
||||||
|
[['file'], 'file' ],
|
||||||
|
[['file'], 'required' ],
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
92
backend/models/CardPackageSearch.php
Normal file
92
backend/models/CardPackageSearch.php
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\CardPackage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CardPackageSearch represents the model behind the search form about `common\models\CardPackage`.
|
||||||
|
*/
|
||||||
|
class CardPackageSearch extends CardPackage
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
public static $STATUS_NOT_PRINTED = 10;
|
||||||
|
public static $STATUS_PRINTED = 20;
|
||||||
|
|
||||||
|
public $printStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id_card_package', 'id_user', 'printed','printStatus'], 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 = CardPackage::find();
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
'sort' =>[
|
||||||
|
'defaultOrder' => ['created_at' => SORT_DESC]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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([
|
||||||
|
'id_card_package' => $this->id_card_package,
|
||||||
|
'id_user' => $this->id_user,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ( isset($this->printStatus)){
|
||||||
|
switch ($this->printStatus){
|
||||||
|
case self::$STATUS_NOT_PRINTED:
|
||||||
|
$query->andWhere( ['or' ,['card_package.printed' => null], [ "card_package.printed" => 0 ] ]);
|
||||||
|
break;
|
||||||
|
case self::$STATUS_PRINTED:
|
||||||
|
$query->andWhere( [">" ,"card_package.printed" , 0 ]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPrintStatuses(){
|
||||||
|
return [
|
||||||
|
self::$STATUS_NOT_PRINTED => "Nincs letöltve",
|
||||||
|
self::$STATUS_PRINTED => "Letöltve",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -97,6 +97,8 @@ class TransferSearch extends Transfer
|
|||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "start date:" .$this->timestampStart;
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'transfer.id_account' => $this->id_account,
|
'transfer.id_account' => $this->id_account,
|
||||||
'transfer.type' => $this->type,
|
'transfer.type' => $this->type,
|
||||||
@ -111,6 +113,10 @@ class TransferSearch extends Transfer
|
|||||||
|
|
||||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||||
|
|
||||||
|
if (!RoleDefinition::isAdmin()){
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['transfer.created_at','transfer.paid_at'],'date');
|
||||||
|
}
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +133,14 @@ class TransferSearch extends Transfer
|
|||||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
||||||
$idUser = $this->id_user;
|
$idUser = $this->id_user;
|
||||||
|
|
||||||
|
/**mk totals need date time format*/
|
||||||
|
$start = $this->timestampStart;
|
||||||
|
if ( isset($start) && !empty($start)){
|
||||||
|
$start .= " 00:00";
|
||||||
|
}
|
||||||
|
|
||||||
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
|
||||||
|
$this->totals = Transfer::mkTotals($start, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
28
backend/views/card-package/_form.php
Normal file
28
backend/views/card-package/_form.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\CardPackage */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="card-package-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'count')->textInput()->label("Hány új kártyát szerentnél?") ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton( Yii::t('common/card_package', 'Kártyák létrehozása') , ['class' => 'btn btn-success' ]) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
49
backend/views/card-package/_search.php
Normal file
49
backend/views/card-package/_search.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use common\models\User;
|
||||||
|
use common\components\Helper;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
use backend\models\CardPackageSearch;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\models\CardPackageSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions( User::read() ,'id','username');
|
||||||
|
$statusOptions = ['' => 'Mind'] + CardPackageSearch::getPrintStatuses();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="card-package-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?= $form->field($model, 'id_card_package') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?= $form->field($model, 'id_user')->dropDownList( $userOptions ) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?= $form->field($model, 'printStatus')->dropDownList($statusOptions)->label("Letöltve") ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('common/card_package', 'Keresés'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
21
backend/views/card-package/create.php
Normal file
21
backend/views/card-package/create.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\CardPackage */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/card_package', 'Új kártya csomag');
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card_package', 'Kártya csomagok'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="card-package-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
38
backend/views/card-package/import.php
Normal file
38
backend/views/card-package/import.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Kártya csomag rfid hozzárendelés feltöltés</h1>
|
||||||
|
|
||||||
|
<p>Itt van lehetőséged a kártyás cégtől kapott kártya-rfid hozzárendelés fájl feltöltésére</p>
|
||||||
|
|
||||||
|
<div class="card-package-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'file')->fileInput([''])->label("Excel fájl kiválasztása") ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton( Yii::t('common/card_package', 'Kártyához tartozó RFID kódok importálása') , ['class' => 'btn btn-success' ]) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
Az excel fájlnak a következő formátumban kell lennie:
|
||||||
|
<ul>
|
||||||
|
<li>Első oszlop: Kártya azonosító</li>
|
||||||
|
<li>Második oszlop: Vonalkód azonosító</li>
|
||||||
|
<li>Harmadik oszlop: RFID azonosító</li>
|
||||||
|
</ul>
|
||||||
|
Az importálás során csak az első és harmadik oszlopot olvassuk be.
|
||||||
|
<p>
|
||||||
|
<?php echo Html::img(Url::base() ."/images/card_package.jpg")?>
|
||||||
81
backend/views/card-package/index.php
Normal file
81
backend/views/card-package/index.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\models\CardPackageSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/card_package', 'Kártyacsomagok');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="card-package-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Itt generálhatunk a rendszerbe új beléptető kártyákat.<br>
|
||||||
|
A kártyak generálása úgynevezett csomagonként történik.
|
||||||
|
A művelet során az új kártyákat egy csomagba rendezzük,
|
||||||
|
majd letölthetjük a csomaghoz tartozó excel fájlt, ami az elkészítendő kártyák
|
||||||
|
kártya azonosítóit tartalmazzák.
|
||||||
|
A letöltött fájlt továbbküldhetjük a kártya készítő cégnek.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Miután a kártya készítő cég végzett, a kártyák mellé mellékel egy excel fájlt, amit
|
||||||
|
a <a href='<?php echo Url::toRoute(['card-package/import'])?>'>
|
||||||
|
Kártya csomag RFID hozzárendelés
|
||||||
|
</a>
|
||||||
|
menüpont alatt importálhatunk be.
|
||||||
|
Ezután lesz használható a kártya az rfid olvasóval
|
||||||
|
</p>
|
||||||
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/card_package', 'Új kártyák létrehozása'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
|
||||||
|
'id_card_package',
|
||||||
|
[
|
||||||
|
'attribute' => 'id_user',
|
||||||
|
'value' => 'userName'
|
||||||
|
],
|
||||||
|
'count',
|
||||||
|
'printed',
|
||||||
|
'created_at:datetime',
|
||||||
|
['attribute'=> 'updated_at','value' => 'printedDate', 'label' =>'Utolsó letöltés ideje','format' => 'datetime'],
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn',
|
||||||
|
|
||||||
|
'template' => '{view}, {download}',
|
||||||
|
|
||||||
|
'urlCreator' => function ($action, $model, $key, $index){
|
||||||
|
$result = "";
|
||||||
|
if ( 'view' == $action ){
|
||||||
|
$result = Url::toRoute(['card-package/view' , 'id' => $model->id_card_package ]);
|
||||||
|
}else if ( 'download' == $action ){
|
||||||
|
$result = Url::toRoute(['card-package/download' , 'id' => $model->id_card_package ]);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
},
|
||||||
|
'buttons' =>[
|
||||||
|
'view' => function ($url, $model, $key) {
|
||||||
|
return Html::a("Részletek" ,$url,['class' =>'btn btn-primary btn-xs']);
|
||||||
|
},
|
||||||
|
'download' => function ($url, $model, $key) {
|
||||||
|
return Html::a("Excel letöltés" ,$url,['class' =>'btn btn-primary btn-xs']);
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
23
backend/views/card-package/update.php
Normal file
23
backend/views/card-package/update.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\CardPackage */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/card_package', 'Update {modelClass}: ', [
|
||||||
|
'modelClass' => 'Card Package',
|
||||||
|
]) . ' ' . $model->id_card_package;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card_package', 'Card Packages'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => $model->id_card_package, 'url' => ['view', 'id' => $model->id_card_package]];
|
||||||
|
$this->params['breadcrumbs'][] = Yii::t('common/card_package', 'Update');
|
||||||
|
?>
|
||||||
|
<div class="card-package-update">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
59
backend/views/card-package/view.php
Normal file
59
backend/views/card-package/view.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\CardPackage */
|
||||||
|
|
||||||
|
$this->title = "Kártya csomag: "+$model->id_card_package;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card_package', 'Kártya csomagok'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="card-package-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/card_package', 'Excel letöltés'), ['download', 'id' => $model->id_card_package], ['class' => 'btn btn-primary']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= DetailView::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attributes' => [
|
||||||
|
'id_card_package',
|
||||||
|
['attribute' => 'user','value' => $model->userName],
|
||||||
|
'id_user',
|
||||||
|
'count',
|
||||||
|
'printed',
|
||||||
|
'created_at:datetime',
|
||||||
|
'printedDate:datetime',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'id_card',
|
||||||
|
'label' => "Kártya azonosító"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'number',
|
||||||
|
'label' => "Kártyaszám"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'rfid_key',
|
||||||
|
'label' => "RFID szám"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'created_at',
|
||||||
|
'label' => "Létrehozva",
|
||||||
|
'format' => 'datetime'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
?>
|
||||||
|
|
||||||
|
</div>
|
||||||
16
backend/views/card/insert.php
Normal file
16
backend/views/card/insert.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'file')->fileInput() ?>
|
||||||
|
|
||||||
|
<button>Submit</button>
|
||||||
|
<?php
|
||||||
|
echo ($model->message);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php ActiveForm::end() ?>
|
||||||
BIN
backend/web/images/card_package.jpg
Normal file
BIN
backend/web/images/card_package.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
@ -1,3 +1,5 @@
|
|||||||
|
-0.0.33
|
||||||
|
- Az adminon kívül mindenki csak max 3 napot lát visszamenőleg mindenből
|
||||||
-0.0.32
|
-0.0.32
|
||||||
- Add product inventory to reception
|
- Add product inventory to reception
|
||||||
-0.0.31
|
-0.0.31
|
||||||
|
|||||||
40
common/components/FreeUniqueCardNumberGenerator.php
Normal file
40
common/components/FreeUniqueCardNumberGenerator.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\components;
|
||||||
|
|
||||||
|
use common\models\Card;
|
||||||
|
|
||||||
|
class FreeUniqueCardNumberGenerator extends \yii\base\Object {
|
||||||
|
public $count;
|
||||||
|
public $keyset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
public $length = 6;
|
||||||
|
public $cache = [ ];
|
||||||
|
public $prefix = "";
|
||||||
|
public function generate() {
|
||||||
|
if ($this->count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < $this->count; $i ++) {
|
||||||
|
|
||||||
|
$unique = false;
|
||||||
|
$number = null;
|
||||||
|
while ( $unique == false ) {
|
||||||
|
$number = Helper::generateRandomString($this->length, $this->keyset);
|
||||||
|
$number = $this->prefix . $number;
|
||||||
|
$unique = $this->checkCacheUnique ( $number ) && $this->checkDBUniqu ( $number );
|
||||||
|
}
|
||||||
|
$this->cache [] = $number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function checkDBUniqu($number) {
|
||||||
|
$query = Card::find ();
|
||||||
|
Card::addCardNumberCondition ( $query, $number );
|
||||||
|
$found = $query->all ();
|
||||||
|
$result = count ( $found ) == 0;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
protected function checkCacheUnique($number) {
|
||||||
|
return array_search ( $number, $this->cache ) === false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,6 +6,88 @@ use \Yii;
|
|||||||
|
|
||||||
class Helper {
|
class Helper {
|
||||||
|
|
||||||
|
public static function isStartDateToEarly($days_between){
|
||||||
|
$days_visiblity = Helper::getReceptionVisibilityDays();
|
||||||
|
// $days_between = $this->calcStartDaysSinceToday();
|
||||||
|
return $days_between > $days_visiblity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $start the date string, format "datetime => "Y-m-d H:i", "date => "Y-m-d"
|
||||||
|
* */
|
||||||
|
public static function calcStartDatimeDaysSinceToday($start, $format = "datetime" ){
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
if ( $format == "datetime"){
|
||||||
|
$format = "Y-m-d H:i";
|
||||||
|
}else if ( $format == "date") {
|
||||||
|
$format = "Y-m-d";
|
||||||
|
}else{
|
||||||
|
//use format
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = \DateTime::createFromFormat( $format , $start)->getTimeStamp();
|
||||||
|
$days_between = ceil(abs( $now - $d) / 86400 );
|
||||||
|
|
||||||
|
return $days_between;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leellenőriz egy dátumot. Ha az aktuális felhasználó nem admin,
|
||||||
|
* akkor a params[reception_visibility_days] napnál korábbi , vagy null
|
||||||
|
* dátumot e params-ban megadott dátumra állítjuk
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
public static function restrictIfNotAdminTheStartDate($query,$date, $fields = ['transfer.paid_at','transfer.created_at'], $format = 'datetime'){
|
||||||
|
$result = null;
|
||||||
|
|
||||||
|
|
||||||
|
$needFix = false;
|
||||||
|
if ( !isset($date) || empty($date)){
|
||||||
|
$needFix = true;
|
||||||
|
}else {
|
||||||
|
$days = Helper::calcStartDatimeDaysSinceToday($date,$format);
|
||||||
|
if ( Helper::isStartDateToEarly($days)){
|
||||||
|
$needFix = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $needFix == true ){
|
||||||
|
$d = Helper::getReceptionVisibilityDays();
|
||||||
|
|
||||||
|
$time = date( "Y-m-d H:i:s", strtotime("today -$d day") );
|
||||||
|
|
||||||
|
$conditions = [];
|
||||||
|
|
||||||
|
foreach ($fields as $f ){
|
||||||
|
$conditions[] = ['>=', $f, $time];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( count($conditions) > 1 ){
|
||||||
|
$andWhereCond = [];
|
||||||
|
$andWhereCond[0] = "or";
|
||||||
|
$i = 1;
|
||||||
|
foreach ($conditions as $c){
|
||||||
|
$andWhereCond[$i] = $c;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}else if ( count($conditions) == 1 ){
|
||||||
|
$andWhereCond = $conditions[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// $start_date_condition = ['or',[ '>=', 'transfer.created_at', $time ] ,[ '>=', 'transfer.paid_at', $time] ];
|
||||||
|
if ( isset($andWhereCond)){
|
||||||
|
$query->andWhere( $andWhereCond );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getDateTimeString( ){
|
public static function getDateTimeString( ){
|
||||||
|
|
||||||
return date("Y-m-d H:i:s");
|
return date("Y-m-d H:i:s");
|
||||||
@ -173,16 +255,27 @@ class Helper {
|
|||||||
public static function isUserCartVisibilityUser() {
|
public static function isUserCartVisibilityUser() {
|
||||||
return \Yii::$app->params ['user_cart_item_visibility'] == 'user';
|
return \Yii::$app->params ['user_cart_item_visibility'] == 'user';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isCompanyMovar() {
|
public static function isCompanyMovar() {
|
||||||
return \Yii::$app->params ['company'] == 'movar';
|
return \Yii::$app->params ['company'] == 'movar';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isProductVisibilityAccount() {
|
public static function isProductVisibilityAccount() {
|
||||||
return \Yii::$app->params ['product_visiblity'] == 'account';
|
return \Yii::$app->params ['product_visiblity'] == 'account';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isAccountStateClosePreloadMoney() {
|
public static function isAccountStateClosePreloadMoney() {
|
||||||
return \Yii::$app->params ['account_state_close_preload_money'] == true;
|
return \Yii::$app->params ['account_state_close_preload_money'] == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isAccountStateOpenSendMail() {
|
||||||
|
return \Yii::$app->params ['mail_account_state_open'] == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isAccountStateCloseSendMail() {
|
||||||
|
return \Yii::$app->params ['mail_account_state_close'] == true;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getReceptionVisibilityDays() {
|
public static function getReceptionVisibilityDays() {
|
||||||
return \Yii::$app->params ['reception_visibility_days'] ;
|
return \Yii::$app->params ['reception_visibility_days'] ;
|
||||||
}
|
}
|
||||||
@ -238,4 +331,14 @@ class Helper {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function generateRandomString($length = 6,$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ) {
|
||||||
|
$charactersLength = strlen($characters);
|
||||||
|
$randomString = '';
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||||
|
}
|
||||||
|
return $randomString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
44
common/components/XLSUtil.php
Normal file
44
common/components/XLSUtil.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\components;
|
||||||
|
|
||||||
|
class XLSUtil {
|
||||||
|
|
||||||
|
public $objPHPExcel;
|
||||||
|
|
||||||
|
public function loadFromFileName($inputFileName) {
|
||||||
|
// Read your Excel workbook
|
||||||
|
try {
|
||||||
|
$inputFileType = \PHPExcel_IOFactory::identify ( $inputFileName );
|
||||||
|
$objReader = \PHPExcel_IOFactory::createReader ( $inputFileType );
|
||||||
|
$this->objPHPExcel = $objReader->load ( $inputFileName );
|
||||||
|
echo "type is: " . $inputFileType;
|
||||||
|
} catch ( Exception $e ) {
|
||||||
|
\Yii::error ( "failed to read xls" );
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* first sheet to array
|
||||||
|
*/
|
||||||
|
public function toArray( ) {
|
||||||
|
$objPHPExcel = $this->objPHPExcel;
|
||||||
|
$array = [ ];
|
||||||
|
// Get worksheet dimensions
|
||||||
|
$sheet = $objPHPExcel->getActiveSheet();
|
||||||
|
//$highestColumn = $sheet->getHighestColumn();
|
||||||
|
$hr = $sheet->getHighestRow();
|
||||||
|
foreach ( $sheet->getRowIterator () as $row ) {
|
||||||
|
$arrayRow = [];
|
||||||
|
$cellIterator = $row->getCellIterator ();
|
||||||
|
$cellIterator->setIterateOnlyExistingCells ( false ); // Loop all cells, even if it is not set
|
||||||
|
foreach ( $cellIterator as $cell ) {
|
||||||
|
$arrayRow [] = $cell->getCalculatedValue();
|
||||||
|
}
|
||||||
|
$array[] = $arrayRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -63,10 +63,14 @@ class AccountStateMail extends Object {
|
|||||||
|
|
||||||
$this->attachPdf();
|
$this->attachPdf();
|
||||||
|
|
||||||
$this->message->setFrom(\Yii::$app->params['infoEmail'])
|
try{
|
||||||
->setTo( \Yii::$app->params['notify_mail'] )
|
$this->message->setFrom(\Yii::$app->params['infoEmail'])
|
||||||
->setSubject($subject )
|
->setTo( \Yii::$app->params['notify_mail'] )
|
||||||
->send();
|
->setSubject($subject )
|
||||||
|
->send();
|
||||||
|
}catch (\Exception $e){
|
||||||
|
\Yii::error("Nem sikerült elküldeni a kassza müvelet emailt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,15 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.32',
|
'version' => 'v0.0.33',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
'notify_mail' => ['rocho02@gmail.com' ],
|
'notify_mail' => ['rocho02@gmail.com' ],
|
||||||
|
/**Kassza nyitáskor küldjünk email-t?*/
|
||||||
'mail_account_state_open' => true,
|
'mail_account_state_open' => true,
|
||||||
|
/**Kassza záráskor küldjünk email-t?*/
|
||||||
|
'mail_account_state_close' => true,
|
||||||
'login_reception_email' => true, //if reception login should send email
|
'login_reception_email' => true, //if reception login should send email
|
||||||
'login_admin_email' => true, //if admin login should send email
|
'login_admin_email' => true, //if admin login should send email
|
||||||
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
|
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
|
||||||
|
|||||||
50
common/models/CardCardPackageAssignment.php
Normal file
50
common/models/CardCardPackageAssignment.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "card_card_package_assignment".
|
||||||
|
*
|
||||||
|
* @property integer $id_card_card_package_assignment
|
||||||
|
* @property integer $id_card_package
|
||||||
|
* @property integer $id_card
|
||||||
|
* @property integer $printed
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
*/
|
||||||
|
class CardCardPackageAssignment extends \common\models\BaseFitnessActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'card_card_package_assignment';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id_card_package', 'id_card'], 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id_card_card_package_assignment' => Yii::t('common/card_package', 'Id Card Card Package Assignment'),
|
||||||
|
'id_card_package' => Yii::t('common/card_package', 'Id Card Package'),
|
||||||
|
'id_card' => Yii::t('common/card_package', 'Id Card'),
|
||||||
|
'created_at' => Yii::t('common/card_package', 'Created At'),
|
||||||
|
'updated_at' => Yii::t('common/card_package', 'Updated At'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
80
common/models/CardPackage.php
Normal file
80
common/models/CardPackage.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\behaviors\TimestampBehavior;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "card_package".
|
||||||
|
*
|
||||||
|
* @property integer $id_card_package
|
||||||
|
* @property integer $id_user
|
||||||
|
* @property integer $count
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
*/
|
||||||
|
class CardPackage extends \common\models\BaseFitnessActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'card_package';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUser(){
|
||||||
|
return $this->hasOne(User::className(), ['id' => 'id_user' ]);
|
||||||
|
}
|
||||||
|
public function getCardAssignments(){
|
||||||
|
return $this->hasMany(CardCardPackageAssignment::className(), ['id_card_package' => 'id_card_package' ]);
|
||||||
|
}
|
||||||
|
public function getCards(){
|
||||||
|
return $this->hasMany(Card::className(), ['id_card' => 'id_card' ])->via('cardAssignments');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserName(){
|
||||||
|
$user = $this->user;
|
||||||
|
$result = "";
|
||||||
|
if ( isset($user) ){
|
||||||
|
$result = $this->user->username;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['count'], 'integer',"min" => 1 , "max" => 3000],
|
||||||
|
[['count'], 'required'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrintedDate(){
|
||||||
|
if ( $this->printed > 0 ){
|
||||||
|
return $this->updated_at;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id_card_package' => Yii::t('common/card_package', 'Kártya csomag azonosító'),
|
||||||
|
'id_user' => Yii::t('common/card_package', 'Felhasználó'),
|
||||||
|
'count' => Yii::t('common/card_package', 'Mennyiség'),
|
||||||
|
'printed' => Yii::t('common/card_package', 'Letöltve'),
|
||||||
|
'printedDate' => Yii::t('common/card_package', 'Utolsó letöltés ideje'),
|
||||||
|
'count' => Yii::t('common/card_package', 'Mennyiség'),
|
||||||
|
'created_at' => Yii::t('common/card_package', 'Létrehozva'),
|
||||||
|
'updated_at' => Yii::t('common/card_package', 'Nyomtatva'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -671,6 +671,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
self::notInInterval ( $query, 'transfer.created_at', $start, $end );
|
self::notInInterval ( $query, 'transfer.created_at', $start, $end );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "start date is: ". $start;
|
||||||
|
echo "start date is: " . gettype( $start );
|
||||||
|
|
||||||
|
if ( !RoleDefinition::isAdmin() ){
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $start);
|
||||||
|
}
|
||||||
|
|
||||||
$query->groupBy ( 'transfer.id_account' );
|
$query->groupBy ( 'transfer.id_account' );
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
@ -837,6 +844,16 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ezt a függvényt használjuk a zárások összegének kiszámolására!
|
||||||
|
* A számolás csak a következő feltételekkel bíró tranzakciókat
|
||||||
|
* tartalmazza:
|
||||||
|
* - trazakció típus: common\models\Account::TYPE_ALL
|
||||||
|
* - tranzakció fizetési módja: készpénz
|
||||||
|
* - tranzakció státusza: fizetve
|
||||||
|
* -
|
||||||
|
* */
|
||||||
public static function readPaid($start, $end, $idUser) {
|
public static function readPaid($start, $end, $idUser) {
|
||||||
$query = (new \yii\db\Query ());
|
$query = (new \yii\db\Query ());
|
||||||
$query->select ( [
|
$query->select ( [
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use common\models\Account;
|
|||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
use common\components\RoleDefinition;
|
use common\components\RoleDefinition;
|
||||||
|
use common\components\Helper;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
@ -169,6 +170,16 @@ class TransferSaleSearch extends Transfer
|
|||||||
|
|
||||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||||
|
|
||||||
|
$needRestirct = false;
|
||||||
|
if ( $this->isModeAdmin() ){
|
||||||
|
$needRestirct = !RoleDefinition::isAdmin();
|
||||||
|
}else{
|
||||||
|
$needRestirct = true;
|
||||||
|
}
|
||||||
|
if ( $needRestirct ){
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart);
|
||||||
|
}
|
||||||
|
|
||||||
// $query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
// $query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,12 +14,19 @@ use common\models\Account;
|
|||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
use common\components\RoleDefinition;
|
use common\components\RoleDefinition;
|
||||||
|
use common\components\Helper;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
class TransferTicketSearch extends Transfer
|
class TransferTicketSearch extends Transfer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if mode is recepion, date restriction will be used
|
||||||
|
* if mode is admin, date restriction will be used based on user role
|
||||||
|
* */
|
||||||
|
public $mode = 'reception';
|
||||||
|
|
||||||
public $start;
|
public $start;
|
||||||
public $end;
|
public $end;
|
||||||
|
|
||||||
@ -126,6 +133,8 @@ class TransferTicketSearch extends Transfer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function calcTotal(){
|
protected function calcTotal(){
|
||||||
$this->total = 0;
|
$this->total = 0;
|
||||||
$this->total += $this->ticketMoney;
|
$this->total += $this->ticketMoney;
|
||||||
@ -166,9 +175,24 @@ class TransferTicketSearch extends Transfer
|
|||||||
|
|
||||||
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
||||||
|
|
||||||
|
$this->restrictStartDate($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function restrictStartDate($query){
|
||||||
|
$needRestriction = false;
|
||||||
|
if ( $this->mode == 'admin'){
|
||||||
|
$needRestriction = !RoleDefinition::isAdmin( ) ;
|
||||||
|
}else{
|
||||||
|
$needRestriction = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $needRestriction ){
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected function readTicketStas(){
|
protected function readTicketStas(){
|
||||||
|
|
||||||
$query = (new \yii\db\Query());
|
$query = (new \yii\db\Query());
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160211_111418_create__table__card_package extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$tableOptions = null;
|
||||||
|
if ($this->db->driverName === 'mysql') {
|
||||||
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||||
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->createTable('{{%card_package}}', [
|
||||||
|
'id_card_package' => $this->primaryKey(),
|
||||||
|
'id_user' => $this->integer(11),
|
||||||
|
'count' => $this->integer(11),
|
||||||
|
'created_at' => $this->dateTime()->notNull(),
|
||||||
|
'updated_at' => $this->dateTime()->notNull(),
|
||||||
|
], $tableOptions);
|
||||||
|
|
||||||
|
$this->createTable('{{%card_card_package_assignment}}', [
|
||||||
|
'id_card_card_package_assignment' => $this->primaryKey(),
|
||||||
|
'id_card_package' => $this->integer(11),
|
||||||
|
'id_card' => $this->integer(11),
|
||||||
|
'created_at' => $this->dateTime()->notNull(),
|
||||||
|
'updated_at' => $this->dateTime()->notNull(),
|
||||||
|
], $tableOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160211_111418_create__table__card_package cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160212_051248_alter__table__card_package__add_column_printed extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("card_package", "printed", "int");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160212_051248_alter__table__card_package__add_column_printed cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -82,10 +82,10 @@ class FrontendMenuStructure{
|
|||||||
$items[] = ['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets','TransferTicketSearch[id_user]' =>\Yii::$app->user->id, 'TransferTicketSearch[id_account]' => Account::readDefault(), 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets','TransferTicketSearch[id_user]' =>\Yii::$app->user->id, 'TransferTicketSearch[id_account]' => Account::readDefault(), 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
// if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
||||||
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
||||||
//$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
//$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
||||||
}
|
// }
|
||||||
|
|
||||||
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
|
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
|
||||||
$items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
$items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
||||||
|
|||||||
@ -86,8 +86,10 @@ class AccountStateController extends Controller {
|
|||||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||||
|
|
||||||
|
|
||||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
if ( Helper::isAccountStateOpenSendMail() ){
|
||||||
$mail->sednMail();
|
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||||
|
$mail->sednMail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
@ -132,9 +134,10 @@ class AccountStateController extends Controller {
|
|||||||
|
|
||||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
|
|
||||||
|
if ( Helper::isAccountStateCloseSendMail()){
|
||||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||||
$mail->sednMail();
|
$mail->sednMail();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
'index'
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use Yii;
|
|||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountstateSearch represents the model behind the search form about `common\models\AccountState`.
|
* AccountstateSearch represents the model behind the search form about `common\models\AccountState`.
|
||||||
@ -80,6 +81,8 @@ class AccountstateSearch extends AccountState
|
|||||||
$query->andFilterWhere([ '>=', 'account_state.created_at', $this->timestampStart ] );
|
$query->andFilterWhere([ '>=', 'account_state.created_at', $this->timestampStart ] );
|
||||||
$query->andFilterWhere([ '<', 'account_state.created_at', $this->timestampEnd ] );
|
$query->andFilterWhere([ '<', 'account_state.created_at', $this->timestampEnd ] );
|
||||||
|
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart, ['account_state.created_at']);
|
||||||
|
|
||||||
$query->orderBy( 'created_at desc' );
|
$query->orderBy( 'created_at desc' );
|
||||||
|
|
||||||
$query->limit = 20;
|
$query->limit = 20;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use yii\base\Model;
|
|||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MoneyMovementSearch represents the model behind the search form about `common\models\MoneyMovement`.
|
* MoneyMovementSearch represents the model behind the search form about `common\models\MoneyMovement`.
|
||||||
@ -68,6 +69,8 @@ class MoneyMovementSearch extends MoneyMovement
|
|||||||
$query->andFilterWhere([ '>=', 'money_movement.created_at', $this->timestampStart ] );
|
$query->andFilterWhere([ '>=', 'money_movement.created_at', $this->timestampStart ] );
|
||||||
$query->andFilterWhere([ '<', 'money_movement.created_at', $this->timestampEnd ] );
|
$query->andFilterWhere([ '<', 'money_movement.created_at', $this->timestampEnd ] );
|
||||||
|
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['money_movement.created_at']);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use yii\db\Expression;
|
|||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
use common\components\Helper;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
@ -91,6 +92,8 @@ class TransferSearch extends Transfer
|
|||||||
|
|
||||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||||
|
|
||||||
|
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +109,7 @@ class TransferSearch extends Transfer
|
|||||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
||||||
$idUser = Yii::$app->user->id;
|
$idUser = Yii::$app->user->id;
|
||||||
|
|
||||||
|
|
||||||
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
var enterPressed;
|
var enterPressed;
|
||||||
var keyDate;
|
var keyDate;
|
||||||
var seq = '';
|
var seq = '';
|
||||||
|
var socket;
|
||||||
$(document).ready(
|
$(document).ready(
|
||||||
function(){
|
function(){
|
||||||
|
|
||||||
@ -69,3 +70,28 @@ function addDocumentKeypressedListener(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function startServer(){
|
||||||
|
try{
|
||||||
|
socket = new WebSocket("ws://localhost:8025/websockets/qrcode");
|
||||||
|
console.info('socket created');
|
||||||
|
socket.onmessage = function (event) {
|
||||||
|
console.log(event.data);
|
||||||
|
var msg = JSON.stringify(event.data);
|
||||||
|
if ( msg.msg == 'qrcode'){
|
||||||
|
console.info('qrcode rcvd');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//startServer();
|
||||||
|
|
||||||
|
function sendMessage(){
|
||||||
|
socket.send("Here's some text that the server is urgently awaiting!");
|
||||||
|
}
|
||||||
@ -576,18 +576,18 @@ function ProductSell(o){
|
|||||||
// Some item from your model is active!
|
// Some item from your model is active!
|
||||||
if (current.name == $input.val()) {
|
if (current.name == $input.val()) {
|
||||||
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||||
console.info(current);
|
// console.info(current);
|
||||||
_findProduct(current.id_product);
|
_findProduct(current.id_product);
|
||||||
} else {
|
} else {
|
||||||
// This means it is only a partial match, you can either add a new item
|
// This means it is only a partial match, you can either add a new item
|
||||||
// or take the active if you don't want new items
|
// or take the active if you don't want new items
|
||||||
console.info('partial');
|
// console.info('partial');
|
||||||
app.product = null;
|
app.product = null;
|
||||||
productChanged();
|
productChanged();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Nothing is active so it is a new value (or maybe empty value)
|
// Nothing is active so it is a new value (or maybe empty value)
|
||||||
console.info('incactive');
|
// console.info('incactive');
|
||||||
app.product = null;
|
app.product = null;
|
||||||
productChanged();
|
productChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user