$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | $json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); | ||||
$json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated(); | $json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated(); | ||||
$json['tiller_url_authorize_code'] = $this->getOrderModule()->getTillerManager()->getUrlAuthorizeCode(); | $json['tiller_url_authorize_code'] = $this->getOrderModule()->getTillerManager()->getUrlAuthorizeCode(); | ||||
$json['tiller_total_amount_orders'] = $this->getOrderModule()->getTillerManager()->getTotalAmountOrdersByDate($date, true); | |||||
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | $json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject); | ||||
} | } | ||||
<button id="btn-tiller" class="btn btn-xs btn-default" disabled><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button> | <button id="btn-tiller" class="btn btn-xs btn-default" disabled><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button> | ||||
</span> | </span> | ||||
</template> | </template> | ||||
<button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller"><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button> | |||||
<button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller"> | |||||
<span class="glyphicon glyphicon-refresh"></span> | |||||
Synchroniser avec Tiller | |||||
</button> | |||||
</template> | </template> | ||||
<template v-else> | <template v-else> | ||||
<a :href="tillerUrlAuthorizeCode" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-refresh"></span> Connexion Tiller</a> | <a :href="tillerUrlAuthorizeCode" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-refresh"></span> Connexion Tiller</a> | ||||
</span> | </span> | ||||
</div> | </div> | ||||
<div class="alert alert-info" v-if="producer && producer.tiller == true && orders.length > 0 && tillerTotalAmountOrders"> | |||||
Montant total commandes Tiller : {{ tillerTotalAmountOrders }} | |||||
</div> | |||||
<div class="alert alert-danger" v-if="distribution && !distribution.active && orders && orders.length > 0"> | <div class="alert alert-danger" v-if="distribution && !distribution.active && orders && orders.length > 0"> | ||||
Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées. | Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées. | ||||
</div> | </div> |
tillerIsAuthenticated: false, | tillerIsAuthenticated: false, | ||||
tillerUrlAuthorizeCode: '#', | tillerUrlAuthorizeCode: '#', | ||||
tillerIsSynchro: false, | tillerIsSynchro: false, | ||||
tillerTotalAmountOrders: false, | |||||
checkboxSelectAllOrders: false, | checkboxSelectAllOrders: false, | ||||
messageGenerateDeliveryNoteDisplayed: false, | messageGenerateDeliveryNoteDisplayed: false, | ||||
missingSubscriptions: false, | missingSubscriptions: false, | ||||
app.tillerUrlAuthorizeCode = response.data.tiller_url_authorize_code; | app.tillerUrlAuthorizeCode = response.data.tiller_url_authorize_code; | ||||
app.tillerIsAuthenticated = response.data.tiller_is_authenticated; | app.tillerIsAuthenticated = response.data.tiller_is_authenticated; | ||||
app.tillerIsSynchro = response.data.tiller_is_synchro; | app.tillerIsSynchro = response.data.tiller_is_synchro; | ||||
app.tillerTotalAmountOrders = response.data.tiller_total_amount_orders; | |||||
app.calendar.attrs = []; | app.calendar.attrs = []; | ||||
var distributions = response.data.distributions; | var distributions = response.data.distributions; |
use common\components\Tiller\TillerClientV2; | use common\components\Tiller\TillerClientV2; | ||||
use common\components\Tiller\TillerClientV3; | use common\components\Tiller\TillerClientV3; | ||||
use common\helpers\MeanPayment; | use common\helpers\MeanPayment; | ||||
use common\helpers\Price; | |||||
use domain\Order\OrderStatus\OrderStatus; | use domain\Order\OrderStatus\OrderStatus; | ||||
use domain\Order\ProductOrder\ProductOrderSolver; | use domain\Order\ProductOrder\ProductOrderSolver; | ||||
use domain\Producer\Producer\ProducerSolver; | use domain\Producer\Producer\ProducerSolver; | ||||
return false; | return false; | ||||
} | } | ||||
public function getTotalAmountOrdersByDate(string $date, bool $format = false) | |||||
{ | |||||
$totalAmount = 0; | |||||
$ordersArray = Order::searchAll([ | |||||
'distribution.date' => $date, | |||||
'order.tiller_synchronization' => 1, | |||||
], [ | |||||
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid() | |||||
]); | |||||
foreach($ordersArray as $order) { | |||||
$this->orderBuilder->initOrder($order); | |||||
$totalAmount += $this->orderSolver->getOrderAmountWithTax($order); | |||||
} | |||||
if($format) { | |||||
return Price::format($totalAmount); | |||||
} | |||||
return $totalAmount; | |||||
} | |||||
} | } |