'TVA', | 'TVA', | ||||
'Total TVA', | 'Total TVA', | ||||
'Total HT', | 'Total HT', | ||||
'Créateur', | |||||
'Classification vente', | |||||
'Code Classification vente', | |||||
]; | ]; | ||||
foreach ($documentManager->getProductsOrders($document) as $productOrderArray) { | foreach ($documentManager->getProductsOrders($document) as $productOrderArray) { | ||||
$productOrder->taxRate->value * 100, // TVA | $productOrder->taxRate->value * 100, // TVA | ||||
$tva, // Total TVA | $tva, // Total TVA | ||||
$priceTotal, // Total HT | $priceTotal, // Total HT | ||||
'', // Créateur | |||||
'', // Classification vente | |||||
'01', // Code Classification vente | |||||
]; | ]; | ||||
} | } | ||||
} | } |
else { | else { | ||||
unset($productPriceCsvArray[0]); | unset($productPriceCsvArray[0]); | ||||
$countUpdate = 0; | $countUpdate = 0; | ||||
$countCreate = 0; | |||||
$cptLine = 1; | |||||
$dataNotFound = false; | $dataNotFound = false; | ||||
$dataNotFoundArray = []; | |||||
foreach ($productPriceCsvArray as $productPriceCsv) { | foreach ($productPriceCsvArray as $productPriceCsv) { | ||||
$cptLine ++; | |||||
if (count($productPriceCsv) != 6) { | if (count($productPriceCsv) != 6) { | ||||
$dataNotFound = true; | $dataNotFound = true; | ||||
continue; | continue; | ||||
|| ($pointSaleName && !$pointSale)) { | || ($pointSaleName && !$pointSale)) { | ||||
$dataNotFound = true; | $dataNotFound = true; | ||||
$dataNotFoundArray[] = $cptLine; | |||||
continue; | continue; | ||||
} | } | ||||
$productPrice->price = $price; | $productPrice->price = $price; | ||||
$productPriceManager->saveUpdate($productPrice); | $productPriceManager->saveUpdate($productPrice); | ||||
$countUpdate++; | $countUpdate++; | ||||
} else { | |||||
$dataNotFound = true; | |||||
} | |||||
// Création automatique du prix spécifique | |||||
else { | |||||
$productPrice = $productPriceManager->instanciateProductPrice($product, $price, $user, $userGroup, $pointSale, $quantityFrom); | |||||
$productPriceManager->saveCreate($productPrice); | |||||
$countCreate ++; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if ($dataNotFound) { | if ($dataNotFound) { | ||||
$this->addFlash('error', "Attention, certaines lignes du fichier n'ont pas été prises en compte. Veuillez réessayer en repartant du fichier d'export.<br />Contacter l'administrateur du site si le problème persiste."); | |||||
$strLinesDataNotFound = '('.implode(', ', $dataNotFoundArray).')'; | |||||
$this->addFlash('error', "Attention, certaines lignes ".$strLinesDataNotFound." du fichier n'ont pas été prises en compte. Veuillez réessayer en repartant du fichier d'export.<br />Contacter l'administrateur du site si le problème persiste."); | |||||
} | } | ||||
if ($countUpdate) { | if ($countUpdate) { | ||||
$this->addFlash('success', $countUpdate . ' prix produits mis à jour.'); | $this->addFlash('success', $countUpdate . ' prix produits mis à jour.'); | ||||
} | } | ||||
if($countCreate) { | |||||
$this->addFlash('success', $countCreate . ' prix produits créés.'); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
<?php foreach ($document->orders as $order): ?> | <?php foreach ($document->orders as $order): ?> | ||||
<tr> | <tr> | ||||
<td> | <td> | ||||
<strong><?= Html::encode($orderManager->getOrderUsername($order)); ?></strong> | |||||
<strong><?= $orderManager->getOrderUsername($order); ?></strong> | |||||
<?php if ($order->distribution): ?> | <?php if ($order->distribution): ?> | ||||
le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | ||||
<?php endif; ?> | <?php endif; ?> |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\Price; | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | $producerPriceRangeManager = $this->getProducerPriceRangeManager(); | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$this->setTitle('Modifier un client') ; | |||||
$this->setTitle('Modifier un client (#'.$model->id.')') ; | |||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | ||||
$this->addBreadcrumb(['label' => Html::encode($model->lastname.' '.$model->name)]) ; | $this->addBreadcrumb(['label' => Html::encode($model->lastname.' '.$model->name)]) ; | ||||
$this->addBreadcrumb('Modifier') ; | $this->addBreadcrumb('Modifier') ; |
namespace common\logic\Product\ProductPrice\Service; | namespace common\logic\Product\ProductPrice\Service; | ||||
use common\logic\AbstractBuilder; | use common\logic\AbstractBuilder; | ||||
use common\logic\PointSale\PointSale\Model\PointSale; | |||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\Product\ProductPrice\Model\ProductPrice; | use common\logic\Product\ProductPrice\Model\ProductPrice; | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\UserGroup\Model\UserGroup; | |||||
class ProductPriceBuilder extends AbstractBuilder | class ProductPriceBuilder extends AbstractBuilder | ||||
{ | { | ||||
public function instanciateProductPrice(): ProductPrice | |||||
public function instanciateProductPrice( | |||||
Product $product, | |||||
float $price, | |||||
User $user = null, | |||||
UserGroup $userGroup = null, | |||||
PointSale $pointSale = null, | |||||
float $quantityFrom = null): ProductPrice | |||||
{ | { | ||||
$productPrice = new ProductPrice(); | $productPrice = new ProductPrice(); | ||||
$productPrice->populateProduct($product); | |||||
$productPrice->price = $price; | |||||
if($user) { | |||||
$productPrice->populateUser($user); | |||||
} | |||||
if($userGroup) { | |||||
$productPrice->populateUserGroup($userGroup); | |||||
} | |||||
if($pointSale) { | |||||
$productPrice->populatePointSale($pointSale); | |||||
} | |||||
if($quantityFrom) { | |||||
$productPrice->quantity_from = $quantityFrom; | |||||
} | |||||
return $productPrice; | return $productPrice; | ||||
} | } | ||||