|
|
|
|
|
|
|
|
'id_user' => $document->user->id |
|
|
'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 [ |
|
|
'return' => 'success', |
|
|
'return' => 'success', |
|
|
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, |
|
|
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, |
|
|
|
|
|
|
|
|
'class' => $document->getClass() |
|
|
'class' => $document->getClass() |
|
|
]), |
|
|
]), |
|
|
'id_user' => $document->user->id, |
|
|
'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, |
|
|
'orders' => $ordersArray, |
|
|
'total' => ($document->getClass() == 'Invoice' || $document->getClass( |
|
|
'total' => ($document->getClass() == 'Invoice' || $document->getClass( |
|
|
) == 'DeliveryNote') ? $document->getAmount( |
|
|
) == 'DeliveryNote') ? $document->getAmount( |