浏览代码

[producer] Mail de confirmation : distinction envoi au client et envoi au producteur

dev
Guillaume 4 年前
父节点
当前提交
382a178cd8
共有 4 个文件被更改,包括 56 次插入23 次删除
  1. +5
    -0
      backend/views/producer/update.php
  2. +3
    -2
      common/models/Producer.php
  3. +18
    -0
      console/migrations/m201026_074711_option_email_confirm_producer.php
  4. +30
    -21
      producer/controllers/OrderController.php

+ 5
- 0
backend/views/producer/update.php 查看文件

@@ -226,6 +226,11 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
1 => 'Oui'
], []); ?>
<?= $form->field($model, 'option_email_confirm_producer')
->dropDownList([
0 => 'Non',
1 => 'Oui'
], []); ?>
</div>
</div>


+ 3
- 2
common/models/Producer.php 查看文件

@@ -134,7 +134,7 @@ class Producer extends ActiveRecordCommon
}],
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status',
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info'], 'string'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm'], 'boolean'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer'], 'boolean'],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255],
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
@@ -214,7 +214,8 @@ class Producer extends ActiveRecordCommon
'behavior_home_point_sale_day_list' => 'Accueil : affichage des jours de distribution',
'behavior_order_select_distribution' => 'Sélection de la date de distribution',
'option_payment_info' => 'Informations liées au paiement',
'option_email_confirm' => 'Envoyer un email de confirmation'
'option_email_confirm' => 'Envoyer un email de confirmation au client',
'option_email_confirm_producer' => 'Envoyer un email de confirmation au producteur',
];
}


+ 18
- 0
console/migrations/m201026_074711_option_email_confirm_producer.php 查看文件

@@ -0,0 +1,18 @@
<?php

use yii\db\Migration;

class m201026_074711_option_email_confirm_producer extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'option_email_confirm_producer', Schema::TYPE_BOOLEAN.' DEFAULT 0');
}

public function safeDown()
{
$this->dropColumn('producer', 'option_email_confirm_producer');

return false;
}
}

+ 30
- 21
producer/controllers/OrderController.php 查看文件

@@ -409,31 +409,40 @@ class OrderController extends ProducerBaseController
$order->changeOrderStatus('waiting-paiement-on-delivery', 'user');
}

// envoi mail de confirmation
if($isNewOrder && Producer::getConfig('option_email_confirm')) {
$user = User::getCurrent() ;
$paramsEmail = [
'from_email' => $producer->getEmailOpendistrib(),
'from_name' => $producer->name,
'to_email' => $user->email,
'to_name' => $user->getUsername(),
'subject' => '['.$producer->name.'] Confirmation de commande',
'content_view_text' => '@common/mail/orderConfirm-text.php',
'content_view_html' => '@common/mail/orderConfirm-html.php',
'content_params' => [
'order' => $order,
'pointSale' => $pointSale,
'distribution' => $distribution,
'user' => $user
]
] ;
$successMail = Mailjet::sendMail($paramsEmail);

$user = User::getCurrent() ;
$paramsEmail = [
'from_email' => $producer->getEmailOpendistrib(),
'from_name' => $producer->name,
'to_email' => $user->email,
'to_name' => $user->getUsername(),
'subject' => '['.$producer->name.'] Confirmation de commande',
'content_view_text' => '@common/mail/orderConfirm-text.php',
'content_view_html' => '@common/mail/orderConfirm-html.php',
'content_params' => [
'order' => $order,
'pointSale' => $pointSale,
'distribution' => $distribution,
'user' => $user
]
] ;


/*
* Envoi email de confirmation
*/
if($isNewOrder) {
// au client
if(Producer::getConfig('option_email_confirm')) {
Mailjet::sendMail($paramsEmail);
}

// au producteur
$contactProducer = $producer->getMainContact() ;
if($contactProducer && strlen($contactProducer->email)) {
if(Producer::getConfig('option_email_confirm_producer') && $contactProducer && strlen($contactProducer->email)) {
$paramsEmail['to_email'] = $contactProducer->email ;
$paramsEmail['to_name'] = $contactProducer->name ;
$successMail = Mailjet::sendMail($paramsEmail);
Mailjet::sendMail($paramsEmail);
}
}


正在加载...
取消
保存