diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f9320caddea..666b72d0940 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -243,8 +243,8 @@ if (empty($reshook)) while (isset($_POST[$batch])) { // save line of detail into sub_qty - $sub_qty[$j]['q']=GETPOST($qty,'int'); // the qty we want to move for this stock record - $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); // the id into llx_product_batch of stock record to move + $sub_qty[$j]['q']=GETPOST($qty,'int'); // the qty we want to move for this stock record + $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); // the id into llx_product_batch of stock record to move $subtotalqty+=$sub_qty[$j]['q']; //var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']); @@ -262,9 +262,14 @@ if (empty($reshook)) } else { - // Case we dont use the list of available qty for each warehouse/lot - // GUI does not allow this yet - setEventMessage('StockRequiredToChooseWhichLotToUse', 'errors'); + // No detail were provided for lots + if (! empty($_POST[$qty])) + { + // We try to set an amount + // Case we dont use the list of available qty for each warehouse/lot + // GUI does not allow this yet + setEventMessage('StockIsRequiredToChooseWhichLotToUse', 'errors'); + } } } else if (isset($_POST[$stockLocation])) @@ -810,7 +815,7 @@ if ($action == 'create') print ''; - // Lecture des expeditions deja effectuees + // Load shipments already done for same order $object->loadExpeditions(); if ($numAsked) @@ -919,6 +924,7 @@ if ($action == 'create') print ''; print ''; + // Qty to ship $quantityAsked = $line->qty; if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -938,7 +944,7 @@ if ($action == 'create') $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number $deliverableQty=min($quantityToBeDelivered, $stock); if ($deliverableQty < 0) $deliverableQty = 0; - if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() && is_object($product->stock_warehouse[$warehouse_id]))) + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { // Quantity to send print ''; // end line and start a new one for lot/serial - + $staticwarehouse=new Entrepot($db); if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) + { + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) + { + $nbofsuggested++; + } + } print ''; - if (count($product->stock_warehouse[$warehouse_id]->detail_batch)) + if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered,$batchStock); - print ''; + print ''; @@ -1045,8 +1062,8 @@ if ($action == 'create') } else { - print ''; - print ''; @@ -1066,6 +1083,15 @@ if ($action == 'create') print ''; $subj=0; + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if ($stock_warehouse->real > 0) + { + $nbofsuggested++; + } + } foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock { $warehouseObject=new Entrepot($db); @@ -1076,7 +1102,8 @@ if ($action == 'create') $deliverableQty = min($quantityToBeDelivered,$stock); $deliverableQty = max(0, $deliverableQty); // Quantity to send - print ''; + print ''; @@ -1185,10 +1223,14 @@ if ($action == 'create') if ($subj == 0) // Line not shown yet, we show it { print ''; - print '
'; @@ -1009,21 +1015,32 @@ if ($action == 'create') } else { + // Product need lot print '
'; + print '
'; print ''; print '
'; + print ''; + print '
'; print ' '; print '
'; + print '
'; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print ''; @@ -1146,16 +1173,27 @@ if ($action == 'create') $warehouseObject=new Entrepot($db); $productlotObject=new Productlot($db); + // Define nb of lines suggested for this order line + $nbofsuggested=0; + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { + if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { + foreach ($stock_warehouse->detail_batch as $dbatch) + { + $nbofsuggested++; + } + } + } foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { $warehouseObject->fetch($warehouse_id); if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { - foreach ($stock_warehouse->detail_batch as $dbatch) + foreach ($stock_warehouse->detail_batch as $dbatch) { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered,$batchStock); - print '
'; + print '
'; print ''; print '
'; + print '
'; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - //$disabled='disabled="disabled"'; + $disabled=''; + if (! empty($conf->productbatch->enabled) && $product->hasbatch()) + { + $disabled='disabled="disabled"'; + } print ' '; } else