Parcourir la source

Merge branch 'dev'

prodstable
Guillaume il y a 2 ans
Parent
révision
eb6b64a04f
1 fichiers modifiés avec 27 ajouts et 20 suppressions
  1. +27
    -20
      backend/controllers/DocumentController.php

+ 27
- 20
backend/controllers/DocumentController.php Voir le fichier

@@ -358,6 +358,32 @@ class DocumentController extends BackendController
'id_user' => $document->user->id
]);

$productsArray = yii\helpers\ArrayHelper::map(
$productsArray,
'id',
function ($product) use ($document, $userProducer, $pointSale) {
return array_merge($product->getAttributes(), [
'price_with_tax' => $product->getPriceWithTax([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'price' => $product->getPrice([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'wording_unit' => $product->wording_unit,
'tax_rate' => $product->taxRate->value
]);
}
);

// ne fonctionne pas, à creuser
/*uasort($productsArray, function($a, $b) {
return $a['order'] < $b['order'] ? 1 : -1;
});*/

return [
'return' => 'success',
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value,
@@ -366,26 +392,7 @@ class DocumentController extends BackendController
'class' => $document->getClass()
]),
'id_user' => $document->user->id,
'products' => yii\helpers\ArrayHelper::map(
$productsArray,
'order',
function ($product) use ($document, $userProducer, $pointSale) {
return array_merge($product->getAttributes(), [
'price_with_tax' => $product->getPriceWithTax([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'price' => $product->getPrice([
'user' => $document->user,
'user_producer' => $userProducer,
'point_sale' => $pointSale,
]),
'wording_unit' => $product->wording_unit,
'tax_rate' => $product->taxRate->value
]);
}
),
'products' => $productsArray,
'orders' => $ordersArray,
'total' => ($document->getClass() == 'Invoice' || $document->getClass(
) == 'DeliveryNote') ? $document->getAmount(

Chargement…
Annuler
Enregistrer