Browse Source

[Backend] Correctif ajout produit + ajout produit dans documents

feature/souke
Guillaume 1 year ago
parent
commit
416bad3dfa
3 changed files with 4 additions and 5 deletions
  1. +2
    -1
      backend/controllers/DocumentController.php
  2. +0
    -2
      backend/controllers/ProductController.php
  3. +2
    -2
      common/logic/Product/Product/Service/ProductSolver.php

+ 2
- 1
backend/controllers/DocumentController.php View File



if ($documentManager->isValidClass($classDocument)) { if ($documentManager->isValidClass($classDocument)) {
$document = $this->findModel($idDocument, $classDocument); $document = $this->findModel($idDocument, $classDocument);
$classDocumentComplete = $documentManager->getClass($document, true);
$product = $productManager->findOneProductById($idProduct); $product = $productManager->findOneProductById($idProduct);


if ($document && $product) { if ($document && $product) {
$order->status = 'tmp-order'; $order->status = 'tmp-order';
$order->origin = Order::ORIGIN_ADMIN; $order->origin = Order::ORIGIN_ADMIN;
$order->date = date('Y-m-d H:i:s'); $order->date = date('Y-m-d H:i:s');
$fieldIdDocument = 'id_' . $classDocument::tableName();
$fieldIdDocument = 'id_' . $classDocumentComplete::tableName();
$order->$fieldIdDocument = $document->id; $order->$fieldIdDocument = $document->id;
$order->save(); $order->save();
} else { } else {

+ 0
- 2
backend/controllers/ProductController.php View File

if ($model->file && $model->validate()) { if ($model->file && $model->validate()) {
$productPriceCsvArray = array_map(function($data) { return str_getcsv($data,";");}, file($model->file->tempName)); $productPriceCsvArray = array_map(function($data) { return str_getcsv($data,";");}, file($model->file->tempName));


//die('mime type : '.BaseFileHelper::getMimeType($model->file->tempName));

if(!$productPriceCsvArray || count($productPriceCsvArray[0]) != 6) { if(!$productPriceCsvArray || count($productPriceCsvArray[0]) != 6) {
$this->setFlash('error', "Format de fichier invalide. Veuillez vérifier que le séparateur de champs de votre fichier est bien \";\"."); $this->setFlash('error', "Format de fichier invalide. Veuillez vérifier que le séparateur de champs de votre fichier est bien \";\".");
} }

+ 2
- 2
common/logic/Product/Product/Service/ProductSolver.php View File



public function getProductQuantityMaxByDay(Product $product, string $day): ?float public function getProductQuantityMaxByDay(Product $product, string $day): ?float
{ {
$quantityMax = $product->quantity_max;
$quantityMax = ($product->quantity_max && $product->quantity_max > 0) ? $product->quantity_max : null;
if($this->isProductQuantityMaxDefinedByDay($product, $day)) { if($this->isProductQuantityMaxDefinedByDay($product, $day)) {
$fieldQuantityMax = $this->getProductFieldNameQuantityMax($day); $fieldQuantityMax = $this->getProductFieldNameQuantityMax($day);
$quantityMax = (float) $product->$fieldQuantityMax;
$quantityMax = $product->$fieldQuantityMax;
} }
return $quantityMax; return $quantityMax;

Loading…
Cancel
Save