add automatic warn email about ticket expiration
This commit is contained in:
parent
9e9894ca4c
commit
e5774a4504
@ -1,3 +1,5 @@
|
|||||||
|
-0.0.71
|
||||||
|
- add automatic warn email sending about ticket expiration
|
||||||
-0.0.70
|
-0.0.70
|
||||||
- add make ticket transfer unpaid
|
- add make ticket transfer unpaid
|
||||||
- add ticket in cart is inactive
|
- add ticket in cart is inactive
|
||||||
|
|||||||
17
common/components/WarnMailModel.php
Normal file
17
common/components/WarnMailModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
namespace common\components;
|
||||||
|
|
||||||
|
use yii\base\Model;
|
||||||
|
|
||||||
|
class WarnMailModel extends Model{
|
||||||
|
|
||||||
|
public $day;
|
||||||
|
public $company;
|
||||||
|
public $ticketTypeName;
|
||||||
|
public $ticketTypePriceBrutto;
|
||||||
|
public $customerName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.70',
|
'version' => 'v0.0.71',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
@ -41,6 +41,11 @@ return [
|
|||||||
* Bérlet eladásnál módosítható e az ár
|
* Bérlet eladásnál módosítható e az ár
|
||||||
* */
|
* */
|
||||||
'ticket_create_price_editable' => true,
|
'ticket_create_price_editable' => true,
|
||||||
|
'warn_ticket_expire_enabled' => false,
|
||||||
|
'warn_ticket_expire_days' =>[
|
||||||
|
[
|
||||||
|
'day' => 5,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
27
common/mail/warn_expire.php
Normal file
27
common/mail/warn_expire.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<h1 style="font-size: 12px;">Kedves <?php echo $model->customerName?>!</h1>
|
||||||
|
<p style="font-size: 12px;">
|
||||||
|
Az alábbi bérleted <?php echo $model->day?> nap múlva lejár:
|
||||||
|
</p>
|
||||||
|
<ul style="font-size: 12px;">
|
||||||
|
<li>
|
||||||
|
"<?php echo $model->ticketTypeName ?>"
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p style="font-size: 12px;">
|
||||||
|
Ha ismét egy ilyen bérletet szeretnél vásárolni, akkor legközelebb ne felejts el magaddal vinni <?php echo $model->ticketTypePriceBrutto?> Ft-ot amikor edzésre mész!
|
||||||
|
</p>
|
||||||
|
<p style="font-size: 12px;">
|
||||||
|
Üdvözlettel:
|
||||||
|
</p>
|
||||||
|
<p style="font-size: 12px;">
|
||||||
|
<?php echo $model->company ?>
|
||||||
|
</p>
|
||||||
|
<p style="font-size: 10px;">
|
||||||
|
Tájékoztatunk, hogy ezen levél a tagsági kártyádat
|
||||||
|
kezelő <?php echo $model->company ?> nyivlántartó rendszerének értesítő üzenete,
|
||||||
|
így nem minősül hírlevélnek, e-mail címedet a <?php echo $model->company ?> nyilvántartó rendszerének
|
||||||
|
adatbázisából a <?php echo $model->company ?> engedélyével értük el.
|
||||||
|
A megadott adatadat az adatvédelmi törvénynek (1992. évi LXIII. törvény) és a reklámtörvénynek (2008. évi XLVIII. törvény) megfelelően kezeljük.
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
?>
|
||||||
@ -41,6 +41,8 @@ class Customer extends BaseFitnessActiveRecord
|
|||||||
const SEX_WOMAN = 20;
|
const SEX_WOMAN = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public static $ENABLED = 1;
|
||||||
|
|
||||||
public $photo_data;
|
public $photo_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace console\controllers;
|
namespace console\controllers;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models;
|
use common\models;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
|
use common\models\Customer;
|
||||||
|
use yii\db\Query;
|
||||||
|
use yii\db\Expression;
|
||||||
|
use common\components\WarnMailModel;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
class TicketController extends Controller {
|
class TicketController extends Controller {
|
||||||
|
public function actionIndex() {
|
||||||
|
|
||||||
public function actionIndex()
|
|
||||||
{
|
|
||||||
$connection = \Yii::$app->db;
|
$connection = \Yii::$app->db;
|
||||||
$command = $connection->createCommand ( Ticket::$SQL_UPDATE );
|
$command = $connection->createCommand ( Ticket::$SQL_UPDATE );
|
||||||
$result = $command->execute ();
|
$result = $command->execute ();
|
||||||
@ -18,4 +21,80 @@ class TicketController extends Controller{
|
|||||||
echo "Tickets updated: " . $result;
|
echo "Tickets updated: " . $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatikus email figyelmeztetés küldése vendégeknek, akiknek a beállított nap(ok) múlva
|
||||||
|
* lejár a bérlete
|
||||||
|
;*
|
||||||
|
*/
|
||||||
|
public function actionWarnExpire() {
|
||||||
|
\Yii::info ( "Bérlet lejár figyelmeztetés küldése" );
|
||||||
|
$warnEnabled = \Yii::$app->params ['warn_ticket_expire_enabled'];
|
||||||
|
$warnDays = \Yii::$app->params ['warn_ticket_expire_days'];
|
||||||
|
|
||||||
|
if (! $warnEnabled) {
|
||||||
|
\Yii::info ( "Bérlet lejár figyelmeztetés küldése kikapcsolva" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isset ( $warnDays ) || count ( $warnDays ) == 0) {
|
||||||
|
\Yii::info ( "Bérlet lejár figyelmeztetés küldése: nincsenek napok beállítva" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $warnDays as $warnDayConfig ) {
|
||||||
|
$dayCount = $warnDayConfig ['day'];
|
||||||
|
|
||||||
|
$query = new Query ();
|
||||||
|
$query->distinct ( true );
|
||||||
|
$query->select ( [
|
||||||
|
'customer.email as customer_email',
|
||||||
|
'customer.name as customer_name',
|
||||||
|
'ticket_type.name as ticket_type_name',
|
||||||
|
'ticket_type.price_brutto as ticket_type_price_brutto'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$query->from ( 'customer' );
|
||||||
|
$query->innerJoin ( "ticket", "customer.id_customer_card = ticket.id_card " );
|
||||||
|
$query->innerJoin ( "ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type " );
|
||||||
|
$query->andWhere ( [
|
||||||
|
'ticket.status' => Ticket::STATUS_ACTIVE ,
|
||||||
|
'customer.warn_mail_ticket_expire_enabled' => Customer::$ENABLED
|
||||||
|
] );
|
||||||
|
$query->andWhere ( [
|
||||||
|
'ticket.end' => new Expression ( 'DATE_ADD(CURDATE(),INTERVAL ' . $dayCount . ' DAY)' )
|
||||||
|
] );
|
||||||
|
|
||||||
|
$recepients = $query->all ();
|
||||||
|
|
||||||
|
\Yii::info ( "Bérlet lejár figyelmeztetés küldése: " . $dayCount . " nap múlva "
|
||||||
|
. count ( $recepients ) . " vendég bérlete jár le."
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $recepients as $recepient ) {
|
||||||
|
|
||||||
|
$recepientEmail = $recepient['customer_email'];
|
||||||
|
|
||||||
|
$model = new WarnMailModel(
|
||||||
|
[
|
||||||
|
'day' => $dayCount,
|
||||||
|
'company' => Helper::getCompanyName(),
|
||||||
|
'ticketTypeName' => $recepient['ticket_type_name'],
|
||||||
|
'ticketTypePriceBrutto' => $recepient['ticket_type_price_brutto'],
|
||||||
|
'customerName' => $recepient['customer_name']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$message = \Yii::$app->mailer->compose ( 'warn_expire', [
|
||||||
|
'model' => $model,
|
||||||
|
] );
|
||||||
|
|
||||||
|
$message
|
||||||
|
->setFrom ( "noreply@fitnessadmin.hu" )
|
||||||
|
->setTo ( $recepientEmail )
|
||||||
|
->setSubject ( "Értesítés - " . Helper::getCompanyName()." - Bérleted ".$dayCount." nap múlva lejár" )
|
||||||
|
->send ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160511_062308_alter__table__customer__add__column__warn_mail_ticket_expire_enabled extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("customer", "warn_mail_ticket_expire_enabled", "int default 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160511_062308_alter__table__customer__add__column__warn_mail_ticket_expire_enabled cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -113,7 +113,7 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
$model->country = "Magyarország";
|
$model->country = "Magyarország";
|
||||||
$model->id_user = Yii::$app->user->id;
|
$model->id_user = Yii::$app->user->id;
|
||||||
|
$model->warn_mail_ticket_expire_enabled = 1;
|
||||||
|
|
||||||
$receptionForm = new ReceptionForm();
|
$receptionForm = new ReceptionForm();
|
||||||
$receptionForm->number = $number;
|
$receptionForm->number = $number;
|
||||||
|
|||||||
@ -32,6 +32,7 @@ use common\components\Helper;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property string $cardNumber
|
* @property string $cardNumber
|
||||||
|
* @property integer $warn_mail_ticket_expire_enabled
|
||||||
*/
|
*/
|
||||||
class CustomerCreate extends \common\models\Customer
|
class CustomerCreate extends \common\models\Customer
|
||||||
{
|
{
|
||||||
@ -108,7 +109,7 @@ class CustomerCreate extends \common\models\Customer
|
|||||||
[['photo_data'] ,'safe'],
|
[['photo_data'] ,'safe'],
|
||||||
[['birth_place'] ,'safe'],
|
[['birth_place'] ,'safe'],
|
||||||
[['mother_name'] ,'safe'],
|
[['mother_name'] ,'safe'],
|
||||||
|
[['warn_mail_ticket_expire_enabled'],'integer']
|
||||||
// [['email','phone'], 'validateEmailOrPhoneRequired' ],
|
// [['email','phone'], 'validateEmailOrPhoneRequired' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,7 @@ class CustomerUpdate extends \common\models\Customer
|
|||||||
[['photo_data'] ,'safe'],
|
[['photo_data'] ,'safe'],
|
||||||
[['birth_place'] ,'safe'],
|
[['birth_place'] ,'safe'],
|
||||||
[['mother_name'] ,'safe'],
|
[['mother_name'] ,'safe'],
|
||||||
|
[['warn_mail_ticket_expire_enabled'],'integer']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,8 +142,12 @@ use kartik\widgets\DatePicker;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-6'>
|
||||||
|
<?= $form->field($model, 'warn_mail_ticket_expire_enabled')->checkbox([ 'label'=> "Kér értesítést bérlet lejáratáról"]) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||||
|
|||||||
@ -138,6 +138,13 @@ use yii\base\Widget;
|
|||||||
|
|
||||||
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-6'>
|
||||||
|
<?= $form->field($model, 'warn_mail_ticket_expire_enabled')->checkbox([ 'label'=> "Kér értesítést bérlet lejáratáról"]) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user