add newsletter changes
This commit is contained in:
@@ -114,7 +114,7 @@ class CustomerController extends Controller
|
||||
$model->country = "Magyarország";
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->warn_mail_ticket_expire_enabled = 1;
|
||||
$model->newsletter = 1;
|
||||
$model->newsletter = 0;
|
||||
|
||||
$receptionForm = new ReceptionForm();
|
||||
$receptionForm->number = $number;
|
||||
|
||||
@@ -17,6 +17,7 @@ use common\components\Helper;
|
||||
use common\models\Log;
|
||||
use common\models\Customer;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use frontend\models\SubscribeForm;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
@@ -181,6 +182,8 @@ class SiteController extends Controller
|
||||
|
||||
public function actionNewsletterUnsubscribe($id,$token)
|
||||
{
|
||||
|
||||
$this->layout = "main-nologin";
|
||||
|
||||
$customer = Customer::find()
|
||||
->andWhere(['id_customer' => $id ])
|
||||
@@ -196,8 +199,59 @@ class SiteController extends Controller
|
||||
$customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time();
|
||||
$customer->save();
|
||||
|
||||
Log::logC([
|
||||
'id_customer' => $customer->id_customer,
|
||||
'type' => Log::$TYPE_NEWSLETTER_UNSUBSCRIBE,
|
||||
"message" => "Hírlevél feliratkozás: ". $customer->name
|
||||
]);
|
||||
|
||||
|
||||
return $this->render("unsubscribe");
|
||||
}
|
||||
|
||||
public function actionNewsletterSubscribe($id,$token)
|
||||
{
|
||||
$this->layout = "main-nologin";
|
||||
|
||||
|
||||
|
||||
$customer = Customer::find()
|
||||
->andWhere(['id_customer' => $id ])
|
||||
->andWhere(['newsletter_token' => $token])
|
||||
->one();
|
||||
|
||||
if ( !isset($customer)){
|
||||
throw new NotFoundHttpException("Az oldal nem található");
|
||||
}
|
||||
$model = new SubscribeForm([
|
||||
'customer' => $customer
|
||||
]);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
|
||||
|
||||
|
||||
|
||||
$customer->newsletter = 1;
|
||||
$customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time();
|
||||
$customer->save();
|
||||
|
||||
|
||||
Log::logC([
|
||||
'id_customer' => $customer->id_customer,
|
||||
'type' => Log::$TYPE_NEWSLETTER_SUBSCRIBE,
|
||||
"message" => "Hírlevél feliratkozás: ". $customer->name ." - " . $customer->email
|
||||
]);
|
||||
|
||||
return $this->redirect(["newsletter-subscribe-success"]);
|
||||
}
|
||||
return $this->render("subscribeform",['model' => $model]);
|
||||
}
|
||||
|
||||
public function actionNewsletterSubscribeSuccess( )
|
||||
{
|
||||
$this->layout = "main-nologin";
|
||||
return $this->render("subscribe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs user up.
|
||||
|
||||
Reference in New Issue
Block a user