Browse Source

[Administration] Distributions > Tiller : affichage du montant total des commandes à synchroniser

develop
Guillaume Bourgeois 3 weeks ago
parent
commit
1d472392e4
4 changed files with 34 additions and 1 deletions
  1. +1
    -0
      backend/controllers/DistributionController.php
  2. +8
    -1
      backend/views/distribution/index.php
  3. +2
    -0
      backend/web/js/vuejs/distribution-index.js
  4. +23
    -0
      domain/Order/Order/TillerManager.php

+ 1
- 0
backend/controllers/DistributionController.php View File

$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);
} }



+ 8
- 1
backend/views/distribution/index.php View File

<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>

+ 2
- 0
backend/web/js/vuejs/distribution-index.js View File

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;

+ 23
- 0
domain/Order/Order/TillerManager.php View File

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;
}
} }

Loading…
Cancel
Save