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/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/service/ub-php/Dockerfile b/docker/service/ub-php/Dockerfile index a4bb694..6b202e9 100644 --- a/docker/service/ub-php/Dockerfile +++ b/docker/service/ub-php/Dockerfile @@ -37,6 +37,8 @@ RUN a2enmod rewrite COPY 000-default.conf /etc/apache2/sites-available/ +COPY index.html /var/www/html/ + # Ports EXPOSE 80 @@ -52,6 +54,7 @@ RUN FILE=/etc/php/7.0/apache2/php.ini \ && echo "\nxdebug.remote_connect_back=1 " >> $FILE \ && echo "\n" >> $FILE + ENV XDEBUG_CONFIG="idekey=PHPSTORM" # Default command 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/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; }