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 { |
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 \";\"."); | ||||
} | } |
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; |