diff --git a/backend/controllers/AccountController.php b/backend/controllers/AccountController.php index cc91a32..13eaa1c 100644 --- a/backend/controllers/AccountController.php +++ b/backend/controllers/AccountController.php @@ -5,9 +5,7 @@ namespace backend\controllers; use Yii; use common\models\Account; use backend\models\AccountSearch; -use yii\web\Controller; use yii\web\NotFoundHttpException; -use yii\filters\VerbFilter; /** * AccountController implements the CRUD actions for Account model. @@ -60,6 +58,7 @@ class AccountController extends \backend\controllers\BackendController * Displays a single Account model. * @param integer $id * @return mixed + * @throws NotFoundHttpException */ public function actionView($id) { @@ -91,6 +90,7 @@ class AccountController extends \backend\controllers\BackendController * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed + * @throws NotFoundHttpException */ public function actionUpdate($id) { diff --git a/backend/views/account/_form.php b/backend/views/account/_form.php index a4c110a..0638e08 100644 --- a/backend/views/account/_form.php +++ b/backend/views/account/_form.php @@ -19,6 +19,8 @@ use common\models\Account; field($model, 'type')->dropDownList(Account::types()) ?> + field($model, 'log_card_read_in_reception')->checkbox([], false) ?> +
isNewRecord ? Yii::t('common/account', 'Create') : Yii::t('common/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> diff --git a/backend/views/account/index.php b/backend/views/account/index.php index 982ff19..97b07b3 100644 --- a/backend/views/account/index.php +++ b/backend/views/account/index.php @@ -22,26 +22,33 @@ $this->params['breadcrumbs'][] = $this->title;

- $dataProvider, - 'columns' => [ - 'name', - [ - 'attribute' => 'status', - 'value' => 'statusHuman', - ], - [ - 'attribute' => 'type', - 'value' => 'typeHuman', - ], - 'created_at:datetime', - 'updated_at:datetime', + $dataProvider, + 'columns' => [ + 'name', + [ + 'attribute' => 'status', + 'value' => 'statusHuman', + ], + [ + 'attribute' => 'type', + 'value' => 'typeHuman', + ], + [ + 'attribute' => 'log_card_read_in_reception', + 'value' => function($model) { return $model->log_card_read_in_reception == '1' ? 'Igen' : 'Nem'; } + ], + 'created_at:datetime', + 'updated_at:datetime', - ['class' => 'yii\grid\ActionColumn', - 'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']), - - ], - ], - ]); ?> + ['class' => 'yii\grid\ActionColumn', + 'template' => RoleDefinition::getRoleTemplate(['admin' => '{view} {update}', 'employee' => '{view}', 'reception' => '{view}']), + + ], + ], + ]); + ?>
diff --git a/backend/views/account/view.php b/backend/views/account/view.php index f277bd0..19ca987 100644 --- a/backend/views/account/view.php +++ b/backend/views/account/view.php @@ -21,7 +21,8 @@ $this->params['breadcrumbs'][] = $this->title;

- $model, 'attributes' => [ 'name', @@ -34,6 +35,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'type', 'value' => $model->typeHuman ], + [ + 'attribute' => 'log_card_read_in_reception', + 'value' => $model->log_card_read_in_reception == '1' ? 'Igen' : 'Nem' + ], 'created_at:datetime', 'updated_at:datetime', ], diff --git a/changelog.txt b/changelog.txt index 8946bc2..e9834be 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +-0.1.10 + - allow card read log for account(s) in reception2 -0.1.09 - fix orignal_price migration -0.1.08 diff --git a/common/config/params.php b/common/config/params.php index ef780b5..b259bac 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.09', + 'version' => 'v0.1.10', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/messages/hu/common/account.php b/common/messages/hu/common/account.php index 7d92753..c97bcce 100644 --- a/common/messages/hu/common/account.php +++ b/common/messages/hu/common/account.php @@ -35,4 +35,5 @@ return [ 'Update {modelClass}: ' => '{modelClass} módosítása: ', 'Updated At' => 'Módosítás ideje', 'Visible for all' => 'Mindenkinek látható', + 'Log Card Read in Reception' => 'Kártya olvasás logolása a recepción' ]; diff --git a/common/models/Account.php b/common/models/Account.php index 2ded224..4e98310 100644 --- a/common/models/Account.php +++ b/common/models/Account.php @@ -12,11 +12,12 @@ use yii\helpers\ArrayHelper; * This is the model class for table "account". * * @property integer $id_account - * @property string $name + * @property string $name * @property integer $status * @property integer $type - * @property string $created_at - * @property string $updated_at + * @property string $created_at + * @property string $updated_at + * @property integer $log_card_read_in_reception */ class Account extends \yii\db\ActiveRecord { @@ -55,7 +56,7 @@ class Account extends \yii\db\ActiveRecord return [ [['name', 'type'], 'required'], [['name', ], 'unique'], - [['status', 'type'], 'integer'], + [['status', 'type','log_card_read_in_reception'], 'integer'], [['name'], 'string', 'max' => 64] ]; } @@ -72,6 +73,7 @@ class Account extends \yii\db\ActiveRecord 'type' => Yii::t('common/account', 'Type'), 'created_at' => Yii::t('common/account', 'Created At'), 'updated_at' => Yii::t('common/account', 'Updated At'), + 'log_card_read_in_reception' => Yii::t('common/account', 'Log Card Read in Reception'), ]; } @@ -115,6 +117,19 @@ class Account extends \yii\db\ActiveRecord return $this->status == self::STATUS_DELETED; } + /** + * When this account is the current default account, + * and this flag is turned on, then if a card will be + * read in the reception masks , than we will care a doorlog + * into the database. + * Use case is example "Botond", where there is no + * three arm gate, but we want to track the customers. + * @return bool + */ + public function isLogCardReadInReceptionOn(){ + return $this->log_card_read_in_reception == 1; + } + /** * $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive * @param null $forceIncludeAccount the next account should be included too, even if it is not @@ -205,5 +220,7 @@ class Account extends \yii\db\ActiveRecord public static function toAccaountMap($accounts){ return ArrayHelper::map( $accounts,'id_account','name' ); } - + + + } diff --git a/common/models/Customer.php b/common/models/Customer.php index 03c707a..79f008d 100644 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -11,6 +11,7 @@ use Yii; * @property integer $id_user * @property integer $id_partner_card * @property integer $id_proposer + * @property integer $id_image * @property string $name * @property string $email * @property string $password diff --git a/console/migrations/m180206_174419_alter_table_account_add_column_log_card_read_in_reception.php b/console/migrations/m180206_174419_alter_table_account_add_column_log_card_read_in_reception.php new file mode 100644 index 0000000..43e416f --- /dev/null +++ b/console/migrations/m180206_174419_alter_table_account_add_column_log_card_read_in_reception.php @@ -0,0 +1,28 @@ +addColumn(\common\models\Account::tableName(), "log_card_read_in_reception", $this->boolean() ); + + } + + public function down() + { + $this->dropColumn(\common\models\Account::tableName(),"log_card_read_in_reception"); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 0000000..fa6c06a --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker-compose build --force-rm --no-cache diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..9121d2d --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,4 @@ +version: '2' +services: + fitness-ub-php-7: + build: ./service/ub-php diff --git a/docker/service/ub-php/000-default.conf b/docker/service/ub-php/000-default.conf new file mode 100644 index 0000000..da2537a --- /dev/null +++ b/docker/service/ub-php/000-default.conf @@ -0,0 +1,42 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + # Always set these headers. + Header always set Access-Control-Allow-Origin "*" + Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" + Header always set Access-Control-Max-Age "1000" + Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" + + # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request. + RewriteEngine On + RewriteCond %{REQUEST_METHOD} OPTIONS + RewriteRule ^(.*)$ $1 [R=200,L] + + + diff --git a/docker/service/ub-php/Dockerfile b/docker/service/ub-php/Dockerfile new file mode 100644 index 0000000..6b202e9 --- /dev/null +++ b/docker/service/ub-php/Dockerfile @@ -0,0 +1,62 @@ +FROM ubuntu:16.04 +MAINTAINER rocho02@gmail.com + +# apt-get +RUN apt-get update \ + && apt-get -y install bzip2 git nano wget zip unzip curl vim \ + && apt-get -y install libmcrypt-dev libzzip-dev zziplib-bin zlib1g-dev \ + && apt-get -y install apache2 +# && ufw allow in "Apache Full" \ + +RUN apt-get -y install php \ + libapache2-mod-php \ + php-mcrypt \ + php-mysql \ + php-xml \ + php7.0-gd \ + php7.0-mbstring + +RUN apt-get -y install php-xdebug php-soap php-curl + +RUN apt-get -y install \ + # Required by composer + git \ + zlib1g-dev \ + --no-install-recommends + +# Install composer +COPY install-composer /install-composer +RUN /install-composer && rm /install-composer + +RUN mkdir -p /var/www/html/api && mkdir -p /var/www/html/admin && mkdir -p /var/www/html/public + +WORKDIR /var/www + +RUN a2enmod headers +RUN a2enmod rewrite + +COPY 000-default.conf /etc/apache2/sites-available/ + +COPY index.html /var/www/html/ + +# Ports +EXPOSE 80 + +RUN FILE=/etc/php/7.0/apache2/php.ini \ + && echo "\n" >> $FILE \ + && echo "\n# Added for xdebug" >> $FILE \ + && echo "\nzend_extension=\"/usr/lib/php/20151012/xdebug.so\" " >> $FILE \ + && echo "\nxdebug.remote_enable=1 " >> $FILE \ + && echo "\nxdebug.remote_handler=dbgp " >> $FILE \ + && echo "\nxdebug.remote_mode=req " >> $FILE \ + && echo "\nxdebug.remote_host=172.17.0.1 " >> $FILE \ + && echo "\nxdebug.remote_port=9000 " >> $FILE \ + && echo "\nxdebug.remote_connect_back=1 " >> $FILE \ + && echo "\n" >> $FILE + + +ENV XDEBUG_CONFIG="idekey=PHPSTORM" + +# Default command +CMD ["apachectl", "-D", "FOREGROUND"] + diff --git a/docker/service/ub-php/index.html b/docker/service/ub-php/index.html new file mode 100644 index 0000000..79f68f5 --- /dev/null +++ b/docker/service/ub-php/index.html @@ -0,0 +1,11 @@ + + + + + + Fitness Web Backend +
+ Fitness Web Frontend + + + \ No newline at end of file diff --git a/docker/service/ub-php/install-composer b/docker/service/ub-php/install-composer new file mode 100644 index 0000000..f7d34be --- /dev/null +++ b/docker/service/ub-php/install-composer @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_SIGNATURE=$(curl https://composer.github.io/installer.sig) +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") + +if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] +then + >&2 echo 'ERROR: Invalid installer signature' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --install-dir=/usr/bin --filename=composer +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 0000000..1a10592 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +PROJECT_DIR=$(pwd)/.. + +docker run \ + -v ${PROJECT_DIR}:/var/www/html/fitness_web \ + --rm \ + -d \ + -p 86:80 \ + --name fitness-web \ + --hostname test.fintess_web.hu \ + -e XDEBUG_CONFIG="idekey=PHPSTORM" \ + docker_fitness-ub-php-7:latest diff --git a/frontend/config/main.php b/frontend/config/main.php index 8a43570..8d20607 100644 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -10,7 +10,7 @@ return [ 'id' => 'app-frontend', 'name' =>'Fitness recepció', 'basePath' => dirname(__DIR__), - 'bootstrap' => ['log','assetsAutoCompress'], + 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\controllers', 'components' => [ 'assetsAutoCompress' => diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php index b589e47..8605438 100644 --- a/frontend/controllers/CustomerController.php +++ b/frontend/controllers/CustomerController.php @@ -6,6 +6,7 @@ use frontend\models\TowelForm; use Yii; use common\models\Customer; use frontend\models\ReceptionForm; +use yii\base\InvalidConfigException; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -54,8 +55,12 @@ class CustomerController extends Controller $model->number = $number; $model->readCard(); -// $model->mkDoorLog(); - + + if ( $model->defaultAccount && $model->defaultAccount->isLogCardReadInReceptionOn()) { + $model->mkDoorLog(); + } + + if ( $model->isFreeCard() ){ return $this->redirect([ 'create', 'number' => $model->card->number ]); }else if ( $model->isCardWithKey()){ @@ -91,7 +96,9 @@ class CustomerController extends Controller /** * Creates a new Customer model. * If creation is successful, the browser will be redirected to the 'view' page. + * @param null $number the card number literal * @return mixed + * @throws \yii\web\HttpException */ public function actionCreate($number = null) { @@ -129,18 +136,21 @@ class CustomerController extends Controller } } - /** - * Updates an existing Customer model. - * If update is successful, the browser will be redirected to the 'view' page. - * @param null $number - * @return mixed - * @throws NotFoundHttpException - * @internal param int $id - */ + /** + * Updates an existing Customer model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param null $number + * @return mixed + * @throws NotFoundHttpException + * @internal param int $id + * @throws \yii\web\HttpException + */ public function actionUpdate($number = null) { $card = null; - $model = null; + + /** @var \backend\models\CustomerUpdate $model */ + $model = null; $receptionForm = new ReceptionForm(); $receptionForm->number = $number; @@ -158,10 +168,15 @@ class CustomerController extends Controller if ( $model == null) { throw new NotFoundHttpException('The requested page does not exist.'); } - - $model->birthdate= isset($model->birthdate ) ? Yii::$app->formatter->asDate($model->birthdate) :''; - + + try { + $model->birthdate = isset($model->birthdate) ? Yii::$app->formatter->asDate($model->birthdate) : ''; + } catch (InvalidConfigException $e) { + \Yii::error("Failed to format date: " . $e->getMessage()); + $model->birthdate = ''; + } + if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->saveBinaryImage($model); @@ -185,15 +200,20 @@ class CustomerController extends Controller ]); } } - - protected function saveBinaryImage($model){ + + /** + * Save images as binary data. + * @param $model \common\models\Customer + * @throws \yii\web\HttpException + */ + protected function saveBinaryImage($model) { if ( !empty($model->photo_data)){ $encoded_data = $model->photo_data; $binary_data = base64_decode( $encoded_data ); // save to server (beware of permissions) $path = \common\components\Image::saveBinary($binary_data,'profile'); - + $image = new Image(); $image->path = $path; $image->save(); diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php index d08e277..b273dca 100644 --- a/frontend/models/ReceptionForm.php +++ b/frontend/models/ReceptionForm.php @@ -2,10 +2,8 @@ namespace frontend\models; -use Yii; use yii\base\Model; use common\models\Card; -use common\models\Customer; use common\models\Ticket; use common\models\Account; use common\models\CardSearch; @@ -21,6 +19,8 @@ use common\models\DoorLog; * ContactForm is the model behind the contact form. * * @property \common\models\Card $card + * @property \common\models\Account $defaultAccount + * @property \common\models\AccountState $lastCassaState */ class ReceptionForm extends Model { @@ -74,10 +74,6 @@ class ReceptionForm extends Model $this->card = $query->one(); - if ( $this->card == null ){ - - } - if ( $this->card != null ){ $this->customer = $this->card->customer; $this->readValidTickets(); @@ -85,6 +81,7 @@ class ReceptionForm extends Model } + public function readCard(){ $this->number = Helper::fixAsciiChars( $this->number ); @@ -121,9 +118,12 @@ class ReceptionForm extends Model $this->cardSearchModel = new CardSearch(); } - + + + public function mkDoorLog(){ - + + if ( !isset($this->card)){ return; } diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..1067df1 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./docker/start.sh \ No newline at end of file