diff --git a/changelog.txt b/changelog.txt index 2dee3d4..b6c922b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +-0.1.21 + - add fingerprint frontend gui -0.1.20 - add fingerprint basics -0.1.19 diff --git a/common/config/params.php b/common/config/params.php index d9b43cb..4624f53 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -5,7 +5,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.1.20', + 'version' => 'v0.1.21', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/models/Fingerprint.php b/common/models/Fingerprint.php index 2a64343..0082866 100644 --- a/common/models/Fingerprint.php +++ b/common/models/Fingerprint.php @@ -20,10 +20,12 @@ class Fingerprint extends ActiveRecord { public function behaviors() { - return ArrayHelper::merge( [ + return ArrayHelper::merge([ [ 'class' => TimestampBehavior::className(), - 'value' => function(){ return date('Y-m-d H:i:s' ); }, + 'value' => static function () { + return date('Y-m-d H:i:s'); + }, 'updatedAtAttribute' => false, ] ], parent::behaviors()); @@ -55,11 +57,11 @@ class Fingerprint extends ActiveRecord * @inheritdoc */ public function attributeLabels() - { + { return [ 'id_fingerprint' => Yii::t('common/fingerprint', 'Id Fingerprint'), 'id_customer' => Yii::t('common/fingerprint', 'Id Customer'), - 'fingerprint' => Yii::t('common/fingerprint', 'Fingerprint'), + 'fingerprint' => Yii::t('common/fingerprint', 'Ujjlenyomat'), 'created_at' => Yii::t('common/fingerprint', 'Created At'), 'updated_at' => Yii::t('common/fingerprint', 'Updated At'), ]; diff --git a/frontend/controllers/FingerprintController.php b/frontend/controllers/FingerprintController.php new file mode 100644 index 0000000..f38d0c5 --- /dev/null +++ b/frontend/controllers/FingerprintController.php @@ -0,0 +1,126 @@ + [ + 'class' => AccessControl::className(), + 'only' => ['index'], + 'rules' => [ + // allow authenticated users + [ + 'allow' => true, + 'roles' => ['@'], + ], + // everything else is denied + ], + ], + + ]; + } + + /** + * @return string + * @throws NotFoundHttpException + */ + public function actionIndex() + { + $searchModel = new FingerprintSearch(); + + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'card' => $searchModel->card, + 'customer' => $searchModel->customer, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * @param $id_card + * @return string|Response + * @throws NotFoundHttpException + */ + public function actionCreate($id_card) + { + + /** @var Card $card */ + $card = Card::findOne($id_card); + + if (!isset($card)) { + throw new NotFoundHttpException('Card not found:' . $id_card); + } + + $customer = Customer::findOne($card->customer); + + if (!isset($customer)) { + throw new NotFoundHttpException('Customer not found'); + } + + + $model = new FingerprintCreate(); + $model->id_customer = $customer->id_customer; + + /** @noinspection NotOptimalIfConditionsInspection */ + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index', 'FingerprintSearch[id_card]' => $card->id_card]); + } + return $this->render('create', [ + 'model' => $model, + ]); + + } + + + /** + * @param $id + * @return Response + * @throws NotFoundHttpException + * @throws Throwable + * @throws StaleObjectException + */ + public function actionDelete($id) + { + + $model = Fingerprint::findOne($id); + + if (!isset($model)) { + throw new NotFoundHttpException(); + } + + + /** @var Customer $customer */ + $customer = Customer::findOne($model->id_customer); + + $model->delete(); + + return $this->redirect([ + 'index', + 'FingerprintSearch[id_card]' => $customer->id_customer_card + ]); + + } + +} diff --git a/frontend/models/FingerprintCreate.php b/frontend/models/FingerprintCreate.php new file mode 100644 index 0000000..4ea09f9 --- /dev/null +++ b/frontend/models/FingerprintCreate.php @@ -0,0 +1,21 @@ +load($params); + $this->validate(); + + + $query = Fingerprint::find(); + + /** @var Card $card */ + $card = Card::findOne($this->id_card); + + if ( !isset($card)){ + throw new NotFoundHttpException('Card not found:' . $this->id_card); + } + $this->card = $card; + + $customer = Customer::findOne($card->customer); + + if ( !isset($customer)){ + throw new NotFoundHttpException('Customer not found'); + } + + + $this->customer = $customer; + + $query->andWhere(['id_customer' => $customer->id_customer]); + return new ActiveDataProvider([ + 'query' => $query, + ]); +} + +} diff --git a/frontend/views/common/_customer_tab.php b/frontend/views/common/_customer_tab.php index b40b0f9..f4481cc 100644 --- a/frontend/views/common/_customer_tab.php +++ b/frontend/views/common/_customer_tab.php @@ -5,8 +5,9 @@ use yii\helpers\Url; 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')); @@ -23,6 +24,7 @@ $items = [ [ '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 ]], ]; @@ -51,4 +53,4 @@ $items = [

Vendég: customer->name ?>

Kártyaszám: number ?>

- \ No newline at end of file + diff --git a/frontend/views/fingerprint/create.php b/frontend/views/fingerprint/create.php new file mode 100644 index 0000000..119dbd1 --- /dev/null +++ b/frontend/views/fingerprint/create.php @@ -0,0 +1,35 @@ +title = 'Ujjlenyomat hozzáadása'; +$this->params['breadcrumbs'][] = ['label' => 'Ujjlenyomatok', 'url' => ['index', 'id_customer' => $model->id_customer]]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +
+ + + + field($model, 'fingerprint')->textInput(['maxlength' => true]) ?> + + + field($model, 'id_customer')->hiddenInput(['maxlength' => true])->label(false) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
+
diff --git a/frontend/views/fingerprint/index.php b/frontend/views/fingerprint/index.php new file mode 100644 index 0000000..429bf51 --- /dev/null +++ b/frontend/views/fingerprint/index.php @@ -0,0 +1,37 @@ + +

Ujjlenyomatok

+ + +

+ $card->id_card], ['class' => 'btn btn-success']); + ?> +

+ + + $dataProvider, + 'columns' => [ + [ + 'attribute' => 'fingerprint', + 'label' => "Ujjlenyomat" + ], + [ + 'attribute' => 'created_at', + 'label' => "Létrehozva", + 'format' => 'datetime' + ], + ['class' => 'yii\grid\ActionColumn', + 'template' => '{delete}', + ] + ] +]); +?> diff --git a/rest/controllers/FingerprintController.php b/rest/controllers/FingerprintController.php index 58a00c3..fb6c303 100644 --- a/rest/controllers/FingerprintController.php +++ b/rest/controllers/FingerprintController.php @@ -1,4 +1,5 @@ -$idCustomer]); - $fingerPrintModel = new Fingerprint(); $fingerPrintModel->id_customer = $customer->id_customer; $fingerPrintModel->fingerprint = $fingerPrint; @@ -45,6 +47,9 @@ class FingerprintController extends RestController public function actionEnter($fingerPrint) { + if ( !Yii::$app->request->isPost){ + throw new BadRequestHttpException(); + } /** @var Fingerprint $fingerPrint */ $fingerPrint = Fingerprint::find()->andWhere(['fingerPrint' => $fingerPrint])->one(); @@ -60,8 +65,20 @@ class FingerprintController extends RestController throw new HttpException(404, 'Not Found'); } + $card = $customer->card; + + $tickets = Ticket::readActive($card); + + $id_ticket = null; + if ( isset($tickets) && count($tickets) > 0){ + $ticket = $tickets[0]; + $id_ticket = $ticket->id_ticket; + } + return [ + 'id_card' => $card->id_card, + 'id_ticket' => $id_ticket, 'id_customer' => $customer->id_customer ];