Переглянути джерело

Merge branch 'dev'

master
Guillaume 4 роки тому
джерело
коміт
ced87dd97e
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);
}
}


Завантаження…
Відмінити
Зберегти