-
+
-
-

-
-
+
diff --git a/customer/app/src/styles/bootstrap-custom.scss b/customer/app/src/styles/bootstrap-custom.scss
index 8f38d89..69fae70 100644
--- a/customer/app/src/styles/bootstrap-custom.scss
+++ b/customer/app/src/styles/bootstrap-custom.scss
@@ -21,7 +21,7 @@ $utilities: map-merge(
property: max-width,
responsive: true,
class: mw2,
- values: ( 25: 25%, 50: 50%, 100: 100%)
+ values: ( 25: 25%, 50: 50%, 80: 80%, 100: 100%)
),
),
$utilities
diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php
index 89f5663..c5769b7 100644
--- a/frontend/controllers/CustomerController.php
+++ b/frontend/controllers/CustomerController.php
@@ -4,11 +4,15 @@ namespace frontend\controllers;
use backend\models\CustomerActivateForm;
use frontend\models\SingleCustomerActivateForm;
+use common\components\Helper;
+use frontend\components\HtmlHelper;
+use frontend\models\PasswordChangeModel;
use frontend\models\TowelForm;
use Yii;
use common\models\Customer;
use frontend\models\ReceptionForm;
use yii\base\InvalidConfigException;
+use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@@ -23,9 +27,9 @@ use common\models\Log;
*/
class CustomerController extends Controller
{
-
-
-
+
+
+
public function behaviors()
{
return [
@@ -47,7 +51,7 @@ class CustomerController extends Controller
// everything else is denied
],
],
-
+
];
}
@@ -70,9 +74,9 @@ class CustomerController extends Controller
public function actionReception($number = ""){
$model = new ReceptionForm();
-
+
$model->number = $number;
-
+
$model->readCard();
if ( $model->defaultAccount && $model->defaultAccount->isLogCardReadInReceptionOn()) {
@@ -88,7 +92,7 @@ class CustomerController extends Controller
}else if ( $model->isCardWithCustomer() ){
return $this->redirect([ 'ticket/create', 'number' => $model->card->number ]);
}
-
+
return $this->render('reception',['model' => $model]);
}
@@ -122,7 +126,7 @@ class CustomerController extends Controller
public function actionCreate($number = null)
{
$model = new CustomerCreate();
-
+
$model->country = "Magyarország";
$model->id_user = Yii::$app->user->id;
$model->warn_mail_ticket_expire_enabled = 1;
@@ -131,21 +135,21 @@ class CustomerController extends Controller
$receptionForm = new ReceptionForm();
$receptionForm->number = $number;
$receptionForm->readCard();
-
+
if ( isset($number)){
$model->cardNumber = $number;
}
-
+
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$this->saveBinaryImage($model);
\Yii::$app->session->setFlash( 'success','Vendég létrehozva!' );
-
+
Log::log([
'type' =>Log::$TYPE_CREATE_CUSTOMER,
- 'message' => 'Új vendég:' .$model->name,
+ 'message' => 'Új vendég:' .$model->name,
'id_customer' => $model->id_customer
]);
-
+
return $this->redirect(['update', 'number' => $model->cardNumber]);
} else {
return $this->render('create', [
@@ -170,11 +174,11 @@ class CustomerController extends Controller
/** @var \backend\models\CustomerUpdate $model */
$model = null;
-
+
$receptionForm = new ReceptionForm();
$receptionForm->number = $number;
$receptionForm->readCard();
-
+
if ( $number != null ){
$card = Card::readCard($number);
if ( $card != null ){
@@ -183,7 +187,7 @@ class CustomerController extends Controller
->andWhere( [ 'customer.id_customer_card' => $card->id_card ])->one();
}
}
-
+
if ( $model == null) {
throw new NotFoundHttpException('The requested page does not exist.');
}
@@ -197,22 +201,22 @@ class CustomerController extends Controller
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
-
+
$this->saveBinaryImage($model);
-
-
+
+
\Yii::$app->session->setFlash( 'success','Vendég módosításai elmentve' );
-
+
$cardNumber = $card->number;
if ( isset( $model->replacementCard ) ){
$cardNumber = $model->replacementCard->number;
}
-
+
return $this->redirect(['update', 'number' => $cardNumber ]);
} else {
-
-
-
+
+
+
return $this->render('update', [
'model' => $model,
'receptionForm' => $receptionForm
@@ -221,6 +225,38 @@ class CustomerController extends Controller
}
+ public function actionPasswordChange($id_card){
+ $card = Card::findOne($id_card);
+ if ( !isset($card)){
+ throw new BadRequestHttpException("card not found");
+ }
+ $customer = $card->customer;
+
+ if ( !isset($card)){
+ throw new BadRequestHttpException("customer not found");
+ }
+
+
+ $model = new PasswordChangeModel();
+ $model->card = $card;
+ $model->customer = $customer;
+ $model->email = $customer->email;
+ $model->companyName = Helper::getCompanyName();
+
+ if ( \Yii::$app->request->isPost ){
+ $model->load(\Yii::$app->request->post());
+ if ( $model->changePassword() ){
+ return $this->redirect(['password-change', 'id_card' => $card->id_card ]);
+ }
+
+ }
+
+ return $this->render("password-change",[
+ 'card' => $card,
+ 'model' => $model
+ ]);
+ }
+
/**
* Save images as binary data.
* @param $model \common\models\Customer
@@ -236,9 +272,9 @@ class CustomerController extends Controller
$image = new Image();
$image->path = $path;
$image->save();
-
+
//todo delete old image
-
+
$model->id_image = $image->id_image;
$model->save(false);
}
diff --git a/frontend/models/PasswordChangeModel.php b/frontend/models/PasswordChangeModel.php
new file mode 100644
index 0000000..9ab38a9
--- /dev/null
+++ b/frontend/models/PasswordChangeModel.php
@@ -0,0 +1,83 @@
+ 'trim'],
+ ['email', 'required'],
+ ['email', 'email'],
+ ['email', 'string', 'max' => 255],
+ ['email', 'validateUnique'],
+
+ ];
+ }
+
+ public function validateUnique($attribute, $params)
+ {
+ $customerWithProvidedEmail = Customer::findOne(['email' => $this->email]);
+ if (isset($customerWithProvidedEmail)) {
+ if ($customerWithProvidedEmail->id_customer != $this->customer->id_customer) {
+ $this->addError("email", "Az e-mail cím már használatban van");
+ }
+ }
+ }
+
+ /**
+ * Signs user up.
+ *
+ * @return boolean
+ */
+ public function changePassword()
+ {
+ if ($this->validate()) {
+
+ $this->customer->email = $this->email;
+ $this->plainPassword = Helper::generateRandomString(
+ 8,
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXabcdefghijklmnopqrstuvwx"
+ );
+ $this->customer->setPassword($this->plainPassword);
+
+ if ($this->customer->save(false)) {
+
+ $message = \Yii::$app->mailer->compose("customer_password_change", ['model' => $this]);
+
+ $message
+ ->setFrom(["noreply@fitnessadmin.hu" => Helper::getCompanyName()])
+ ->setTo($this->customer->email)
+ ->setSubject("Értesítés - " . Helper::getCompanyName() . " - új jelszó")
+ ->send();
+
+ \Yii::$app->session->setFlash('success', 'Email módosítva, jelszó elküldve');
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/frontend/views/common/_customer_tab.php b/frontend/views/common/_customer_tab.php
index f4481cc..5ea6c5f 100644
--- a/frontend/views/common/_customer_tab.php
+++ b/frontend/views/common/_customer_tab.php
@@ -2,7 +2,7 @@
use yii\helpers\Url;
?>
-controller->id .'/'. Yii::$app->controller->action->id;
@@ -15,16 +15,17 @@ $todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
$items = [
- [ 'Recepció', ['customer/reception', 'number' => $card->number ]],
- [ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
- [ 'Adatlap', ['customer/update', 'number' => $card->number ]],
- [ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
- [ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
- [ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
- [ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
+ [ 'Recepció', ['customer/reception', 'number' => $card->number ]],
+ [ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
+ [ 'Adatlap', ['customer/update', 'number' => $card->number ]],
+ [ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
+ [ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
+ [ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
+ [ '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 ]],
+ [ 'Jelszó küldése', ['customer/password-change', 'id_card' => $card->id_card ]],
];
@@ -38,7 +39,7 @@ $items = [
- title = Yii::t('frontend/key', 'Vendéghez rendelt kulcsok');
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+ $card])?>
+
+
+
+ 'contact-form']); ?>
+
+
+ = $form->field($model, 'email') ?>
+
+
+
+ = Html::submitButton('E-mail beállítása és jelszó küldése', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
+
+
+
+
+