add id_account to door log, add key import to backend with no menu
This commit is contained in:
parent
6221945bb7
commit
0ce6958e0b
@ -10,137 +10,212 @@ use yii\web\NotFoundHttpException;
|
|||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
use backend\models\KeyCustomerSearch;
|
use backend\models\KeyCustomerSearch;
|
||||||
|
use backend\models\KeyImportForm;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KeyController implements the CRUD actions for Key model.
|
* KeyController implements the CRUD actions for Key model.
|
||||||
*/
|
*/
|
||||||
class KeyController extends Controller
|
class KeyController extends Controller {
|
||||||
{
|
public function behaviors() {
|
||||||
public function behaviors()
|
return [
|
||||||
{
|
'verbs' => [
|
||||||
return [
|
'class' => VerbFilter::className (),
|
||||||
'verbs' => [
|
'actions' => [
|
||||||
'class' => VerbFilter::className(),
|
'delete' => [
|
||||||
'actions' => [
|
'post'
|
||||||
'delete' => ['post'],
|
]
|
||||||
],
|
]
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all Key models.
|
* Lists all Key models.
|
||||||
* @return mixed
|
*
|
||||||
*/
|
* @return mixed
|
||||||
//http://localhost/fitness-web/backend/web/index.php?r=key/index erre ezt hívja meg elsőzör
|
*/
|
||||||
public function actionIndex()
|
// http://localhost/fitness-web/backend/web/index.php?r=key/index erre ezt hívja meg elsőzör
|
||||||
{
|
public function actionIndex() {
|
||||||
$searchModel = new KeySearch();
|
$searchModel = new KeySearch ();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
// backend/views/kex/index.php
|
// backend/views/kex/index.php
|
||||||
return $this->render('index', [
|
return $this->render ( 'index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider, //csomagoló osztály a queryhez
|
'dataProvider' => $dataProvider
|
||||||
]);
|
] // csomagoló osztály a queryhez
|
||||||
}
|
);
|
||||||
/**
|
}
|
||||||
* Lists all Key models.
|
/**
|
||||||
* @return mixed
|
* Lists all Key models.
|
||||||
*/
|
*
|
||||||
public function actionIndexCustomer($id)
|
* @return mixed
|
||||||
{
|
*/
|
||||||
|
public function actionIndexCustomer($id) {
|
||||||
|
$model = Customer::findOne ( $id );
|
||||||
|
|
||||||
$model = Customer::findOne($id);
|
if (! isset ( $model )) {
|
||||||
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !isset($model)){
|
$searchModel = new KeyCustomerSearch ( [
|
||||||
throw new NotFoundHttpException('The requested page does not exist.');
|
'customer' => $model
|
||||||
}
|
] );
|
||||||
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
$searchModel = new KeyCustomerSearch(['customer' => $model]);
|
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
||||||
// backend/views/kex/index.php
|
// backend/views/kex/index.php
|
||||||
return $this->render('index-customer', [
|
return $this->render ( 'index-customer', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider, //csomagoló osztály a queryhez
|
'dataProvider' => $dataProvider
|
||||||
]);
|
] // csomagoló osztály a queryhez
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a single Key model.
|
* Displays a single Key model.
|
||||||
* @param integer $id
|
*
|
||||||
* @return mixed
|
* @param integer $id
|
||||||
*/
|
* @return mixed
|
||||||
public function actionView($id)
|
*/
|
||||||
{
|
public function actionView($id) {
|
||||||
return $this->render('view', [
|
return $this->render ( 'view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel ( $id )
|
||||||
]);
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Key model.
|
* Creates a new Key model.
|
||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
* @return mixed
|
*
|
||||||
*/
|
* @return mixed
|
||||||
public function actionCreate()
|
*/
|
||||||
{
|
public function actionCreate() {
|
||||||
$model = new Key();
|
$model = new Key ();
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_key]);
|
return $this->redirect ( [
|
||||||
} else {
|
'view',
|
||||||
return $this->render('create', [
|
'id' => $model->id_key
|
||||||
'model' => $model,
|
] );
|
||||||
]);
|
} else {
|
||||||
}
|
return $this->render ( 'create', [
|
||||||
}
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an existing Key model.
|
* Updates an existing Key model.
|
||||||
* If update is successful, the browser will be redirected to the 'view' page.
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
* @param integer $id
|
*
|
||||||
* @return mixed
|
* @param integer $id
|
||||||
*/
|
* @return mixed
|
||||||
public function actionUpdate($id)
|
*/
|
||||||
{
|
public function actionUpdate($id) {
|
||||||
$model = $this->findModel($id);
|
$model = $this->findModel ( $id );
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_key]);
|
return $this->redirect ( [
|
||||||
} else {
|
'view',
|
||||||
return $this->render('update', [
|
'id' => $model->id_key
|
||||||
'model' => $model,
|
] );
|
||||||
]);
|
} else {
|
||||||
}
|
return $this->render ( 'update', [
|
||||||
}
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing Key model.
|
* Deletes an existing Key model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
* @param integer $id
|
*
|
||||||
* @return mixed
|
* @param integer $id
|
||||||
*/
|
* @return mixed
|
||||||
public function actionDelete($id)
|
*/
|
||||||
{
|
public function actionDelete($id) {
|
||||||
$this->findModel($id)->delete();
|
$this->findModel ( $id )->delete ();
|
||||||
|
|
||||||
return $this->redirect(['index']);
|
return $this->redirect ( [
|
||||||
}
|
'index'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public function actionImport() {
|
||||||
* Finds the Key model based on its primary key value.
|
$model = new KeyImportForm();
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
$arr = [ ];
|
||||||
* @param integer $id
|
|
||||||
* @return Key the loaded model
|
if (Yii::$app->request->isPost) {
|
||||||
* @throws NotFoundHttpException if the model cannot be found
|
$model->file = UploadedFile::getInstance ( $model, 'file' );
|
||||||
*/
|
|
||||||
protected function findModel($id)
|
// print_r($model->file);
|
||||||
{
|
// $model->message = "ok";
|
||||||
if (($model = Key::findOne($id)) !== null) {
|
$file = $model->file->tempName;
|
||||||
return $model;
|
|
||||||
} else {
|
$file = fopen ( $file, "r" );
|
||||||
throw new NotFoundHttpException('The requested page does not exist.');
|
|
||||||
}
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $arr as $item ) {
|
||||||
|
try {
|
||||||
|
$key = new Key ();
|
||||||
|
$key->number = $item ['number'];
|
||||||
|
$key->rfid_key = $item ['key'];
|
||||||
|
$key->status = Key::STATUS_ACTIVE;
|
||||||
|
$key->type = Key::TYPE_NORMAL;
|
||||||
|
$key->save ( false );
|
||||||
|
} catch ( \Exception $e ) {
|
||||||
|
\Yii::error ( "Failed to save key: " . $key->number );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirect ( [
|
||||||
|
'import'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render ( 'import', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the Key model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return Key the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id) {
|
||||||
|
if (($model = Key::findOne ( $id )) !== null) {
|
||||||
|
return $model;
|
||||||
|
} else {
|
||||||
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class DoorLogSearch extends DoorLog
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[[ 'direction', 'type'], 'integer'],
|
[[ 'direction', 'type' ,'id_customer','id_account'], 'integer'],
|
||||||
[['created_at'], 'safe'],
|
[['created_at'], 'safe'],
|
||||||
[['searchCardNumber','searchCustomerName','searchKeyName'], 'safe'],
|
[['searchCardNumber','searchCustomerName','searchKeyName'], 'safe'],
|
||||||
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
@ -81,11 +81,13 @@ class DoorLogSearch extends DoorLog
|
|||||||
'customer.id_customer as customer_id_customer',
|
'customer.id_customer as customer_id_customer',
|
||||||
'door_log.direction as door_log_direction',
|
'door_log.direction as door_log_direction',
|
||||||
'door_log.created_at as door_log_created_at',
|
'door_log.created_at as door_log_created_at',
|
||||||
'door_log.source_app as door_log_source_app'
|
'door_log.source_app as door_log_source_app',
|
||||||
|
'account.name as account_name'
|
||||||
]);
|
]);
|
||||||
$query->from('door_log');
|
$query->from('door_log');
|
||||||
$query->innerJoin('card','card.id_card = door_log.id_card');
|
$query->innerJoin('card','card.id_card = door_log.id_card');
|
||||||
$query->leftJoin('key','key.id_key = door_log.id_key');
|
$query->leftJoin('key','key.id_key = door_log.id_key');
|
||||||
|
$query->leftJoin('account','account.id_account = door_log.id_account');
|
||||||
$query->leftJoin('customer','customer.id_customer = door_log.id_customer');
|
$query->leftJoin('customer','customer.id_customer = door_log.id_customer');
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
@ -125,6 +127,10 @@ class DoorLogSearch extends DoorLog
|
|||||||
'door_log_type' =>[
|
'door_log_type' =>[
|
||||||
'asc' => ['door_log.type' => SORT_ASC ],
|
'asc' => ['door_log.type' => SORT_ASC ],
|
||||||
'desc' => ['door_log.type' => SORT_DESC],
|
'desc' => ['door_log.type' => SORT_DESC],
|
||||||
|
],
|
||||||
|
'account_name' =>[
|
||||||
|
'asc' => ['account.name' => SORT_ASC ],
|
||||||
|
'desc' => ['account.name' => SORT_DESC],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -139,15 +145,9 @@ class DoorLogSearch extends DoorLog
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
// 'id_door_log' => $this->id_door_log,
|
'door_log.direction' => $this->direction,
|
||||||
// 'id_card' => $this->id_card,
|
'door_log.id_customer' => $this->id_customer,
|
||||||
// 'id_customer' => $this->id_customer,
|
'account.id_account' => $this->id_account,
|
||||||
// 'id_key' => $this->id_key,
|
|
||||||
'direction' => $this->direction,
|
|
||||||
'id_customer' => $this->id_customer
|
|
||||||
|
|
||||||
// 'type' => $this->type,
|
|
||||||
// 'created_at' => $this->created_at,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['>=', 'door_log.created_at', $this->timestampStart]);
|
$query->andFilterWhere(['>=', 'door_log.created_at', $this->timestampStart]);
|
||||||
|
|||||||
30
backend/models/KeyImportForm.php
Normal file
30
backend/models/KeyImportForm.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 KeyImportForm extends Model{
|
||||||
|
|
||||||
|
public $file;
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
public function rules(){
|
||||||
|
return [
|
||||||
|
[['file'], 'file']
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,12 +5,21 @@ use yii\widgets\ActiveForm;
|
|||||||
use kartik\widgets\DatePicker;
|
use kartik\widgets\DatePicker;
|
||||||
use backend\models\DoorLogSearch;
|
use backend\models\DoorLogSearch;
|
||||||
use kartik\widgets\DateTimePicker;
|
use kartik\widgets\DateTimePicker;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\components\Helper;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\models\DoorLogSearch */
|
/* @var $model backend\models\DoorLogSearch */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$accountOptions = ['' =>'Mind']+ HtmlHelper::mkAccountOptions( Account::read() );
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="door-log-search">
|
<div class="door-log-search">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
@ -64,6 +73,10 @@ use kartik\widgets\DateTimePicker;
|
|||||||
]
|
]
|
||||||
]) ?>
|
]) ?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList( $accountOptions )->label("Kassza") ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@ -42,6 +42,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
[
|
[
|
||||||
'attribute' => 'key_number',
|
'attribute' => 'key_number',
|
||||||
'label' => 'Kulcs'
|
'label' => 'Kulcs'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'account_name',
|
||||||
|
'label' => 'Kassza'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'customer_id_customer',
|
'attribute' => 'customer_id_customer',
|
||||||
|
|||||||
16
backend/views/key/import.php
Normal file
16
backend/views/key/import.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
?>
|
||||||
|
<h1>Kulcs importálás</h1>
|
||||||
|
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'file')->fileInput() ?>
|
||||||
|
|
||||||
|
<button>Submit</button>
|
||||||
|
<?php
|
||||||
|
echo ($model->message);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php ActiveForm::end() ?>
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
-0.0.36
|
||||||
|
- Door log- add account
|
||||||
|
- Key import - no menu ( key/import )
|
||||||
-0.0.35
|
-0.0.35
|
||||||
- Forgóvilla direction mező feldolgozása
|
- Forgóvilla direction mező feldolgozása
|
||||||
- manuális olvasás irása a door_log táblába
|
- manuális olvasás irása a door_log táblába
|
||||||
|
|||||||
@ -4,7 +4,7 @@ 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.35',
|
'version' => 'v0.0.36',
|
||||||
'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
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use common\components\Helper;
|
|||||||
* @property integer $id_key
|
* @property integer $id_key
|
||||||
* @property integer $direction
|
* @property integer $direction
|
||||||
* @property integer $type
|
* @property integer $type
|
||||||
|
* @property integer $id_account
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $source_app
|
* @property string $source_app
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160216_201757_alter__table__door_log__add__column_id_account extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("door_log", "id_account", "int default null");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160216_201757_alter__table__door_log__add__column_id_account cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -113,6 +113,8 @@ class ReceptionForm extends Model
|
|||||||
$dlog->type = $this->card->type;
|
$dlog->type = $this->card->type;
|
||||||
$dlog->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
|
$dlog->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
|
||||||
|
|
||||||
|
$dlog->id_account = Account::readDefault();
|
||||||
|
|
||||||
$dlog->created_at = date('Y-m-d H:i:s');
|
$dlog->created_at = date('Y-m-d H:i:s');
|
||||||
$dlog->save(false);
|
$dlog->save(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user