@@ -68,6 +68,13 @@ use common\models\Producer ; | |||
.$addHintCredit); | |||
?> | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
'' => 'Paramètres globaux ('.Producer::$creditFunctioningArray[Producer::getConfig('credit_functioning')].')', | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||
], []) ; ?> | |||
<div id="delivery-days"> | |||
<h2>Jours de livraison</h2> |
@@ -178,6 +178,12 @@ $this->addBreadcrumb($this->getTitle()) ; | |||
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | |||
]) | |||
->hint("Une relance est envoyé au client dès que ce seuil est dépassé.") ; ?> | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||
], []) ; ?> | |||
<?= $form->field($model, 'online_payment') | |||
->dropDownList([ |
@@ -80,7 +80,7 @@ class PointSale extends ActiveRecordCommon | |||
[['name', 'code'], 'string', 'max' => 255], | |||
[['address', 'locality', 'infos_monday', 'infos_tuesday', | |||
'infos_wednesday', 'infos_thursday', 'infos_friday', | |||
'infos_saturday', 'infos_sunday'], 'string'], | |||
'infos_saturday', 'infos_sunday','credit_functioning'], 'string'], | |||
[['point_production', 'credit', 'delivery_monday', 'delivery_tuesday', | |||
'delivery_wednesday', 'delivery_thursday', 'delivery_friday', | |||
'delivery_saturday', 'delivery_sunday'], 'boolean'], | |||
@@ -119,6 +119,7 @@ class PointSale extends ActiveRecordCommon | |||
'delivery_saturday' => 'Samedi', | |||
'delivery_sunday' => 'Dimanche', | |||
'code' => 'Code', | |||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur' | |||
]; | |||
} | |||
@@ -59,9 +59,18 @@ use yii\helpers\Html; | |||
* @property string mentions | |||
* @property string gcs | |||
* @property boolean option_allow_user_gift | |||
* @property string credit_functioning | |||
*/ | |||
class Producer extends ActiveRecordCommon | |||
{ | |||
const CREDIT_FUNCTIONING_MANDATORY = 'mandatory' ; | |||
const CREDIT_FUNCTIONING_OPTIONAL = 'optional' ; | |||
public static $creditFunctioningArray = [ | |||
self::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||
self::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||
]; | |||
var $secret_key_payplug ; | |||
/** | |||
@@ -91,7 +100,7 @@ class Producer extends ActiveRecordCommon | |||
}], | |||
[['description','mentions','gcs','order_infos','slug','secret_key_payplug'], 'string'], | |||
[['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift'], 'boolean'], | |||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type'], 'string', 'max' => 255], | |||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning'], 'string', 'max' => 255], | |||
[['free_price', 'credit_limit_reminder'], 'double'], | |||
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'], | |||
]; | |||
@@ -128,6 +137,7 @@ class Producer extends ActiveRecordCommon | |||
'mentions' => 'Mentions légales', | |||
'gcs' => 'Conditions générales de vente', | |||
'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande', | |||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur' | |||
]; | |||
} | |||
@@ -0,0 +1,20 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\mysql\Schema; | |||
use common\models\Producer ; | |||
class m190206_135142_ajout_champs_gestion_credit_avancee extends Migration { | |||
public function up() { | |||
$this->addColumn('producer', 'credit_functioning', Schema::TYPE_STRING.' DEFAULT \''.Producer::CREDIT_FUNCTIONING_OPTIONAL.'\'') ; | |||
$this->addColumn('point_sale', 'credit_functioning', Schema::TYPE_STRING) ; | |||
} | |||
public function down() { | |||
$this->dropColumn('producer', 'credit_functioning') ; | |||
$this->dropColumn('point_sale', 'credit_functioning') ; | |||
} | |||
} |
@@ -310,7 +310,7 @@ class OrderController extends ProducerBaseController | |||
$order = Order::searchOne([ | |||
'id' => $order->id | |||
]) ; | |||
if ($credit && ($pointSale->credit || $order->getAmount(Order::AMOUNT_PAID))) { | |||
if($credit && $pointSale->credit && ($posts['use_credit'] || $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY)) { | |||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||
// à payer | |||
@@ -436,7 +436,8 @@ class OrderController extends ProducerBaseController | |||
]) ; | |||
$json['producer'] = [ | |||
'order_infos' => $producer->order_infos, | |||
'credit' => $producer->credit | |||
'credit' => $producer->credit, | |||
'credit_functioning' => $producer->credit_functioning, | |||
] ; | |||
// Distributions | |||
@@ -512,6 +513,8 @@ class OrderController extends ProducerBaseController | |||
]) | |||
->all(); | |||
$creditFunctioningProducer = Producer::getConfig('credit_functioning') ; | |||
foreach($pointsSaleArray as &$pointSale) { | |||
$pointSale = array_merge($pointSale->getAttributes(),[ | |||
'pointSaleDistribution' => [ | |||
@@ -524,6 +527,9 @@ class OrderController extends ProducerBaseController | |||
if($pointSale['code'] && strlen($pointSale['code'])) { | |||
$pointSale['code'] = '***' ; | |||
} | |||
if(!strlen($pointSale['credit_functioning'])) { | |||
$pointSale['credit_functioning'] = $creditFunctioningProducer ; | |||
} | |||
} | |||
$json['points_sale'] = $pointsSaleArray; |
@@ -230,8 +230,10 @@ $this->setTitle('Commander') ; | |||
</div> | |||
<div class="credit"> | |||
<div v-if="producer.credit == 1 && pointSaleActive.credit == 1"> | |||
<span class="glyphicon glyphicon-chevron-right"></span> La commande va être réglée via votre Crédit ({{ formatPrice(credit) }}). | |||
<div class="info"> | |||
<input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled" v-if="pointSaleActive.credit_functioning == 'mandatory'" /> | |||
<input type="checkbox" id="use-credit" v-model="useCredit" v-else /> <label for="use-credit">Utiliser mon Crédit ({{ formatPrice(credit) }})</label> | |||
<div class="info" v-if="useCredit"> | |||
<span v-if="order == null || order.amount_paid == 0">{{ priceTotal(true) }} seront débités</span> | |||
<span v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | |||
<span v-else-if="order != null && order.amount_paid > priceTotal()">{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> |
@@ -17,6 +17,7 @@ var app = new Vue({ | |||
comment: '', | |||
creditCheckbox: false, | |||
credit: 0, | |||
useCredit: false, | |||
errors: [], | |||
disableConfirmButton: false, | |||
calendar: { | |||
@@ -242,6 +243,8 @@ var app = new Vue({ | |||
validatePointSale: function(idPointSale) { | |||
this.pointSaleActive = this.getPointSale(idPointSale) ; | |||
this.useCredit = true ; | |||
this.changeStep('products') ; | |||
}, | |||
productQuantityClick: function(product, quantity) { | |||
@@ -301,7 +304,8 @@ var app = new Vue({ | |||
comment: this.comment | |||
}, | |||
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | |||
products: productsArray | |||
products: productsArray, | |||
use_credit: Number(this.useCredit) | |||
}).then(function(response) { | |||
if(response.data.status == 'success') { | |||
window.location.href = chat_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; |