Parcourir la source

[Espace producteur] Abonnements : problème regénération commandes #1228

feature/souke
Guillaume Bourgeois il y a 1 an
Parent
révision
d3cc8bfd85
18 fichiers modifiés avec 180 ajouts et 139 suppressions
  1. +2
    -2
      backend/views/distribution/index.php
  2. +5
    -2
      backend/views/subscription/index.php
  3. +9
    -0
      common/config/main.php
  4. +2
    -5
      common/forms/SubscriptionForm.php
  5. +11
    -0
      common/logic/Order/Order/Event/OrderDeleteEvent.php
  6. +2
    -0
      common/logic/Order/Order/Model/Order.php
  7. +31
    -0
      common/logic/Order/Order/Repository/OrderRepository.php
  8. +13
    -57
      common/logic/Order/Order/Service/OrderBuilder.php
  9. +0
    -5
      common/logic/Order/Order/Service/OrderSolver.php
  10. +1
    -1
      common/logic/Subscription/Subscription/Model/Subscription.php
  11. +28
    -0
      common/logic/User/CreditHistory/Event/OrderObserver.php
  12. +13
    -9
      common/logic/User/CreditHistory/Service/CreditUtils.php
  13. +2
    -1
      producer/controllers/SubscriptionController.php
  14. +3
    -1
      producer/views/order/order.php
  15. +20
    -3
      producer/views/subscription/_form.php
  16. +1
    -1
      producer/views/subscription/form.php
  17. +2
    -2
      producer/views/subscription/index.php
  18. +35
    -50
      producer/web/js/vuejs/order-order.js

+ 2
- 2
backend/views/distribution/index.php Voir le fichier

@@ -587,7 +587,7 @@ $this->setPageTitle('Distributions') ;
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span>

<span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</div>
</script>

@@ -732,7 +732,7 @@ $this->setPageTitle('Distributions') ;
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span>

<span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</div>
</script>


+ 5
- 2
backend/views/subscription/index.php Voir le fichier

@@ -214,13 +214,16 @@ $subscriptionsArray = Subscription::searchAll() ;
[
'attribute' => 'auto_payment',
'format' => 'raw',
'label' => 'Paiement automatique',
'label' => 'Débit automatique',
'headerOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'],
'filter' => [0 => 'Non', 1 => 'Oui'],
'value' => function($model) {
if($model->auto_payment) {
if($model->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) {
return '<span class="label label-success">Déduit</span>' ;
}
elseif($model->auto_payment == Subscription::AUTO_PAYMENT_YES) {
return '<span class="label label-success">Oui</span>' ;
}
else {

+ 9
- 0
common/config/main.php Voir le fichier

@@ -40,6 +40,7 @@ use common\components\BusinessLogic;
use common\components\DolibarrApi;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Order\Order\Model\Order;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\User\CreditHistory\Model\CreditHistory;

@@ -159,16 +160,24 @@ return [
'class' => \justcoded\yii2\eventlistener\components\EventListener::class,
'listeners' => [],
'observers' => [
Order::class => [
// CreditHistory : remboursement commande
common\logic\User\CreditHistory\Event\OrderObserver::class
],
CreditHistory::class => [
// UserProducer : mise à jour du crédit
common\logic\User\UserProducer\Event\CreditHistoryObserver::class
],
Distribution::class => [
// Subscription : génération des commandes sur base des abonnements
common\logic\Subscription\Subscription\Event\DistributionObserver::class
],
DeliveryNote::class => [
// Order : assignation du bon de livraison aux commandes
common\logic\Order\Order\Event\DeliveryNoteObserver::class
],
Ticket::class => [
// User : envoi email nouveau ticket à l'administrateur
common\logic\User\User\Event\TicketObserver::class,
],
],

+ 2
- 5
common/forms/SubscriptionForm.php Voir le fichier

@@ -44,9 +44,6 @@ use common\logic\Subscription\Subscription\Model\Subscription;
use Yii;
use yii\base\Model;

/**
* Login form
*/
class SubscriptionForm extends Model
{
public $isAdmin = false ;
@@ -106,7 +103,7 @@ class SubscriptionForm extends Model
'sunday' => 'Dimanche',
'week_frequency' => 'Périodicité (semaines)',
'username' => 'Nom d\'utilisateur',
'auto_payment' => 'Paiement automatique',
'auto_payment' => 'Débit automatique',
'comment' => 'Commentaire'
];
}
@@ -150,7 +147,7 @@ class SubscriptionForm extends Model
$subscription->saturday = $this->saturday;
$subscription->sunday = $this->sunday;
$subscription->week_frequency = $this->week_frequency;
$subscription->auto_payment = (int) $this->auto_payment;
$subscription->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED;
$subscription->comment = $this->comment;

$subscription->save();

+ 11
- 0
common/logic/Order/Order/Event/OrderDeleteEvent.php Voir le fichier

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

namespace common\logic\Order\Order\Event;

use common\logic\Order\Order\Model\Order;
use yii\base\Event;

class OrderDeleteEvent extends Event
{
public Order $order;
}

+ 2
- 0
common/logic/Order/Order/Model/Order.php Voir le fichier

@@ -54,6 +54,8 @@ use common\components\ActiveRecordCommon;
*/
class Order extends ActiveRecordCommon
{
const EVENT_DELETE = 'order.event.delete';

var $amount = 0;
var $amount_with_tax = 0;
var $amount_vat = [];

+ 31
- 0
common/logic/Order/Order/Repository/OrderRepository.php Voir le fichier

@@ -18,6 +18,7 @@ use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Product\Product\Service\ProductSolver;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\User\User\Model\User;
use common\logic\User\UserProducer\Repository\UserProducerRepository;
use yii\helpers\Html;
@@ -400,4 +401,34 @@ class OrderRepository extends AbstractRepository

return intval($total / 3);
}

public function findOrdersIncomingBySubscription(Subscription $subscription, bool $begin = true)
{
if($begin) {
$dateStart = $subscription->date_begin;
$comparatorDateStart = '>=';
}
else {
$dateStart = $subscription->date_end;
$comparatorDateStart = '>';
}

$params = [
':id_producer' => GlobalParam::getCurrentProducerId(),
':date_today' => date('Y-m-d'),
':date_start' => $dateStart,
':id_subscription' => $subscription->id
];

$orders = Order::find()
->joinWith('distribution')
->where('distribution.id_producer = :id_producer')
->andWhere('distribution.date >= :date_today')
->andWhere('distribution.date ' . $comparatorDateStart . ' :date_start')
->andWhere('order.id_subscription = :id_subscription');

$orders->params($params);

return $orders->all();
}
}

+ 13
- 57
common/logic/Order/Order/Service/OrderBuilder.php Voir le fichier

@@ -14,6 +14,7 @@ use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Invoice\Model\Invoice;
use common\logic\Order\Order\Event\OrderDeleteEvent;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\ProductOrder\Model\ProductOrder;
@@ -177,31 +178,8 @@ class OrderBuilder extends AbstractBuilder

public function deleteOrdersIncomingDistributionsFromSubscription(Subscription $subscription, bool $deleteAfterDateEnd = false): int
{
$dateStart = $subscription->date_begin;
$comparatorDateStart = '>=';
if ($deleteAfterDateEnd) {
$dateStart = $subscription->date_end;
$comparatorDateStart = '>';
}

$params = [
':id_producer' => GlobalParam::getCurrentProducerId(),
':date_today' => date('Y-m-d'),
':date_start' => $dateStart,
':id_subscription' => $subscription->id
];

$orders = Order::find()
->joinWith('distribution')
->where('distribution.id_producer = :id_producer')
->andWhere('distribution.date >= :date_today')
->andWhere('distribution.date ' . $comparatorDateStart . ' :date_start')
->andWhere('order.id_subscription = :id_subscription');
$ordersArray = $this->orderRepository->findOrdersIncomingBySubscription($subscription, !$deleteAfterDateEnd);

$orders->params($params);

$ordersArray = $orders->all();
$configCredit = $this->producerRepository->getConfig('credit');

$countOrdersDeleted = 0;
if ($ordersArray && count($ordersArray)) {
@@ -209,21 +187,7 @@ class OrderBuilder extends AbstractBuilder
if ($this->distributionSolver->isDistributionAvailable($order->distribution)) {
$theOrder = $this->orderRepository->findOneOrderById($order->id);
$this->initOrder($theOrder);

// remboursement de la commande
if ($theOrder->id_user && $this->orderSolver->getOrderAmount($theOrder, Order::AMOUNT_PAID) && $configCredit) {

$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND,
$this->orderSolver->getOrderAmount($theOrder, Order::AMOUNT_PAID),
$theOrder->distribution->producer,
$theOrder->user,
GlobalParam::getCurrentUser()
);
}

$this->deleteOrder($order, true);

$countOrdersDeleted++;
}
}
@@ -437,23 +401,9 @@ class OrderBuilder extends AbstractBuilder

public function deleteOrder(Order $order, bool $force = false): bool
{
$return = false;
$this->initOrder($order);

// remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);

if ($amountPaid >= 0.01) {
$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND,
$amountPaid,
GlobalParam::getCurrentProducer(),
$order->user,
$this->userSolver->getCurrent(),
MeanPayment::CREDIT,
$order
);
}

// delete
if ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE ||
($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete))
@@ -461,15 +411,21 @@ class OrderBuilder extends AbstractBuilder

$this->productOrderBuilder->deleteProductOrdersByOrder($order);

return $this->delete($order);
} // status 'delete'
$return = $this->delete($order);
}
// status 'delete'
elseif ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) {
$order->date_delete = date('Y-m-d H:i:s');
$return = $this->update($order);
}

return $this->saveUpdate($order);
if($return) {
$orderDeleteEvent = new OrderDeleteEvent();
$orderDeleteEvent->order = $order;
$order->trigger(Order::EVENT_DELETE, $orderDeleteEvent);
}

return false;
return $return;
}

/**

+ 0
- 5
common/logic/Order/Order/Service/OrderSolver.php Voir le fichier

@@ -7,7 +7,6 @@ use common\logic\AbstractService;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Product\Product\Model\Product;
use common\logic\SolverInterface;
@@ -114,7 +113,6 @@ class OrderSolver extends AbstractService implements SolverInterface
/**
* Retourne une chaine de caractère décrivant l'utilisateur lié à la commande.
*/
// getStrUser
public function getOrderUsername(Order $order): string
{
if (isset($order->user)) {
@@ -177,7 +175,6 @@ class OrderSolver extends AbstractService implements SolverInterface
/**
* Retourne un bloc html présentant une date.
*/
// getBlockDate
public function getDateAsHtml(Order $order): string
{
return '<div class="block-date">
@@ -336,7 +333,6 @@ class OrderSolver extends AbstractService implements SolverInterface
/**
* Retourne le montant de la commande (total, payé, restant, ou en surplus).
*/
// getAmount
public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false)
{
$amount = $order->amount;
@@ -347,7 +343,6 @@ class OrderSolver extends AbstractService implements SolverInterface
return $this->_getAmountGeneric($order, $type, $amount, $format);
}

// getAmountWithTax
public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false)
{
$amount = $order->amount + $this->getOrderTotalVat($order, $type);

+ 1
- 1
common/logic/Subscription/Subscription/Model/Subscription.php Voir le fichier

@@ -94,7 +94,7 @@ class Subscription extends ActiveRecordCommon
'saturday' => 'Samedi',
'sunday' => 'Dimanche',
'week_frequency' => 'Périodicité',
'auto_payment' => 'Paiement automatique',
'auto_payment' => 'Débit automatique',
'comment' => 'Commentaire'
];
}

+ 28
- 0
common/logic/User/CreditHistory/Event/OrderObserver.php Voir le fichier

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

namespace common\logic\User\CreditHistory\Event;

use common\logic\Order\Order\Event\OrderDeleteEvent;
use common\logic\Order\Order\Model\Order;
use common\logic\User\CreditHistory\Wrapper\CreditHistoryManager;
use common\logic\User\User\Wrapper\UserManager;
use justcoded\yii2\eventlistener\observers\Observer;

class OrderObserver extends Observer
{
public function events()
{
return [
Order::EVENT_DELETE => 'onOrderDelete'
];
}

public function onOrderDelete(OrderDeleteEvent $event)
{
$order = $event->order;
$creditHistoryManager = CreditHistoryManager::getInstance();
$userManager = UserManager::getInstance();

$creditHistoryManager->refundOrder($order, $userManager->getCurrent());
}
}

+ 13
- 9
common/logic/User/CreditHistory/Service/CreditUtils.php Voir le fichier

@@ -93,15 +93,19 @@ class CreditUtils extends AbstractService implements UtilsInterface

public function refundOrder(Order $order, User $userAction): void
{
$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND,
$this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_PAID),
$this->getProducerContext(),
$order->user,
$userAction,
MeanPayment::CREDIT,
$order
);
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);

if ($amountPaid >= 0.01 && $order->id_user) {
$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND,
$this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID),
$this->getProducerContext(),
$order->user,
$userAction,
MeanPayment::CREDIT,
$order
);
}
}

public function refundSurplusOrder(Order $order, User $userAction): void

+ 2
- 1
producer/controllers/SubscriptionController.php Voir le fichier

@@ -42,6 +42,7 @@ use common\forms\SubscriptionForm;
use common\helpers\GlobalParam;
use common\logic\Product\Product\Model\Product;
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\Subscription\Subscription\Model\SubscriptionSearch;
use yii\base\UserException;
use yii\filters\AccessControl;
@@ -166,7 +167,7 @@ class SubscriptionController extends ProducerBaseController
$model->friday = $subscription->friday;
$model->saturday = $subscription->saturday;
$model->sunday = $subscription->sunday;
$model->auto_payment = $subscription->auto_payment;
$model->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED;
$model->week_frequency = $subscription->week_frequency;

// produits

+ 3
- 1
producer/views/order/order.php Voir le fichier

@@ -56,7 +56,9 @@ $this->setTitle('Commander');

<script>
var appInitValues = {
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>'
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>',
producerOptionOrderEntryPoint: '<?= $producer->option_order_entry_point ?>',
<?php if (isset($order)): ?>pointSaleActiveId: <?= $order->id_point_sale ?><?php endif; ?>
};
</script>


+ 20
- 3
producer/views/subscription/_form.php Voir le fichier

@@ -36,9 +36,13 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager;

$producerManager = ProducerManager::getInstance();
$subscriptionManager = SubscriptionManager::getInstance();
$orderManager = OrderManager::getInstance();

\producer\assets\VuejsSubscriptionFormAsset::register($this) ;

@@ -130,15 +134,14 @@ $producerManager = ProducerManager::getInstance();
</div>
<div class="clr"></div>
<h3><span>Paiement</span></h3>

<!--<h3><span>Paiement</span></h3>
<?php if($producerManager->getConfig('credit')): ?>
<div class="form-group field-subscriptionform-auto_payment">
<label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label>
<div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div>
<div class="help-block"></div>
</div>
<?php endif; ?>
<?php endif; ?>-->
<div class="days" v-if="pointSaleActive">
<h3 id="step-days"><span>Jours</span></h3>
@@ -253,6 +256,20 @@ $producerManager = ProducerManager::getInstance();
<textarea id="subscriptionform-comment" class="form-control comment-textarea" v-model="comment"></textarea>
</div>
</div>


<?php if($idSubscription): ?>
<?php
$subscription = $subscriptionManager->findOneSubscriptionById($idSubscription);
$ordersIncomingSubscriptionArray = $orderManager->findOrdersIncomingBySubscription($subscription);
?>
<?php if($subscription && $ordersIncomingSubscriptionArray): ?>
<div class="alert alert-warning">
<span class="glyphicon glyphicon-alert"></span>
Attention, en modifiant votre abonnement, vos <?= count($ordersIncomingSubscriptionArray) ?> commande(s) à venir vont être re-générées.
</div>
<?php endif; ?>
<?php endif; ?>
<button class="btn btn-primary" disabled="disabled" v-if="disableSubmitButton">Enregistrer</button>
<button class="btn btn-primary" v-else>Enregistrer</button>

+ 1
- 1
producer/views/subscription/form.php Voir le fichier

@@ -46,6 +46,6 @@ else {

<div class="subscription-create">
<?= $this->render('_form', [
'idSubscription' => $idSubscription
'idSubscription' => $idSubscription,
]) ?>
</div>

+ 2
- 2
producer/views/subscription/index.php Voir le fichier

@@ -162,7 +162,7 @@ $columns = [
],
] ;
if($producerManager->getConfig('credit')) {
/*if($producerManager->getConfig('credit')) {
$columns[] = [
'format' => 'raw',
'label' => 'Paiement automatique',
@@ -178,7 +178,7 @@ if($producerManager->getConfig('credit')) {
}
}
] ;
}
}*/
$columns[] = [
'class' => 'yii\grid\ActionColumn',

+ 35
- 50
producer/web/js/vuejs/order-order.js Voir le fichier

@@ -16,6 +16,7 @@ var app = new Vue({
distribution: null,
pointsSale: [],
pointSaleActive: null,
pointSaleActiveId: null,
pointsSaleCodes: [],
products: [],
categories: [],
@@ -28,6 +29,7 @@ var app = new Vue({
delivery: false,
deliveryAddress: null,
urlLogin: '#',
producerOptionOrderEntryPoint: null,
calendar: {
columns: 2,
mode: 'single',
@@ -70,25 +72,25 @@ var app = new Vue({
}, window.appInitValues);
},
mounted: function() {
let fr = new Intl.Locale("fr-FR");
var dateDefined = $('#order-distribution-date').size() || $('#distribution-date').size() ;

if(dateDefined) {
if($('#order-distribution-date').size()) {
this.date = new Date($('#order-distribution-date').html()) ;
}
else {
this.date = new Date($('#distribution-date').html()) ;
}
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
}
this.init('first') ;
this.initDate();
this.init('first');
},
methods: {
initDate: function() {
var dateDefined = $('#order-distribution-date').size() || $('#distribution-date').size() ;
if(dateDefined && (this.producerOptionOrderEntryPoint != 'point-sale' || this.pointSaleActiveId)) {
if($('#order-distribution-date').size()) {
this.date = new Date($('#order-distribution-date').html()) ;
}
else {
this.date = new Date($('#distribution-date').html()) ;
}

this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
}
},
getDate: function() {
return this.formatDate(this.date) ;
},
@@ -134,16 +136,13 @@ var app = new Vue({

axios.get("ajax-infos",{params: {
date : this.getDate(),
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0)
}})
.then(function(response) {

// distributions
var distributions = response.data.distributions;

app.calendar.attrs = [];
app.calendar.availableDates = [];

var distributions = response.data.distributions;
if (distributions.length) {
app.distributions = distributions;
var arrayDate;
@@ -161,12 +160,10 @@ var app = new Vue({
}
}

// distribution
if (response.data.distribution) {
app.distribution = response.data.distribution;
}

// liste commandes
var orders = [];
if (response.data.orders) {
orders = response.data.orders;
@@ -177,7 +174,6 @@ var app = new Vue({
arrayDate = orders[i].date_distribution.split('-');
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]);
if (app.isAvailableDate(dateOrder)) {

app.calendar.attrs.push({
highlight: true,
popover: {
@@ -185,40 +181,19 @@ var app = new Vue({
hideIndicator: true
},
dates: orders[i].date_distribution


/*highlight: {
backgroundColor: '#FF7F00'
},
contentStyle: {
color: 'white'
},
popover: {
label: orders[i].pointSale.name + ' / ' + app.formatPrice(orders[i].amount_total),
hideIndicator: true
},
dates: orders[i].date_distribution,*/
});
}
}
}

// catégories
if(response.data.categories) {
app.categories = response.data.categories ;
app.setCategoryCurrent(response.data.categories[0]) ;
}

// producer
app.producer = response.data.producer;

// user
app.user = response.data.user;

// credit
app.useCredit = response.data.producer.use_credit_checked_default;

// points de vente
if (response.data.points_sale) {
app.pointsSale = [];
var orderPointSale = 0;
@@ -233,6 +208,10 @@ var app = new Vue({
}
}

if(app.pointSaleActiveId) {
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId);
}

if(app.isChangeState('point-sale', 'point-sale', 'date')) {
app.date = null ;
app.dateFormat = null ;
@@ -249,12 +228,11 @@ var app = new Vue({
}

if(updateOrder) {
// products
if(response.data.products) {
app.products = response.data.products ;
app.products = response.data.products;
}

// order
app.order = null ;
if(response.data.order) {
app.order = response.data.order ;
@@ -276,7 +254,14 @@ var app = new Vue({
}

if(type == 'first') {
if(app.producer.option_order_entry_point == 'point-sale') {
if(app.getDate() && app.pointSaleActive) {
app.step = 'products' ;

if(response.data.products) {
app.products = response.data.products;
}
}
else if(app.producer.option_order_entry_point == 'point-sale') {
app.step = 'point-sale' ;
}
else if(app.getDate() && app.producer && app.producer.option_order_entry_point == 'date') {

Chargement…
Annuler
Enregistrer