From fd23d97793639126e2d9da7c94e336543c354a30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Aug 2010 17:42:25 +0000 Subject: [PATCH] Fix: Error on page when going from some link --- htdocs/expedition/fiche.php | 80 +++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 1a2aed2789b..520a0868959 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -48,13 +48,12 @@ $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); -$origin = "expedition"; +$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal $origin_id = isset($_REQUEST["id"])?$_REQUEST["id"]:''; +if (empty($origin_id)) $origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; // Id of order or propal +if (empty($origin_id)) $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal $id = $origin_id; -$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal -$origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; // Id of order or propal - // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -539,58 +538,53 @@ if ($_GET["action"] == 'create') $quantityAsked = $line->qty; $quantityToBeDelivered = $quantityAsked - $quantityDelivered; - if ($conf->stock->enabled - //&& $line->product_type == 0 - ) + $defaultqty=0; + if ($_REQUEST["entrepot_id"]) { - $defaultqty=0; - if ($_REQUEST["entrepot_id"]) - { - //var_dump($product); - $stock = $product->stock_warehouse[$_REQUEST["entrepot_id"]]->real; - $stock+=0; // Convertit en numerique - $defaultqty=min($quantityToBeDelivered, $stock); - if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; - } + //var_dump($product); + $stock = $product->stock_warehouse[$_REQUEST["entrepot_id"]]->real; + $stock+=0; // Convertit en numerique + $defaultqty=min($quantityToBeDelivered, $stock); + if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; + } - // Quantity to send + // Quantity to send + print ''; + if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''; + print ''; + } + else print '0'; + print ''; + + // Stock + if ($conf->stock->enabled) + { print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print ''; - print ''; - } - else print '0'; - print ''; - - // Stock - if ($conf->stock->enabled) - { - print ''; - if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + // Show warehous + if ($_REQUEST["entrepot_id"]) { - // Show warehous - if ($_REQUEST["entrepot_id"]) + $formproduct->selectWarehouses($_REQUEST["entrepot_id"],'entl'.$indiceAsked,'',1,0,$line->fk_product); + //print $stock.' '.$quantityToBeDelivered; + //if ($stock >= 0 && $stock < $quantityToBeDelivered) + if ($stock < $quantityToBeDelivered) { - $formproduct->selectWarehouses($_REQUEST["entrepot_id"],'entl'.$indiceAsked,'',1,0,$line->fk_product); - //print $stock.' '.$quantityToBeDelivered; - //if ($stock >= 0 && $stock < $quantityToBeDelivered) - if ($stock < $quantityToBeDelivered) - { - print ' '.img_warning($langs->trans("StockTooLow")); - } - } - else - { - $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product); + print ' '.img_warning($langs->trans("StockTooLow")); } } else { - print $langs->trans("Service"); + $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product); } - print ''; } + else + { + print $langs->trans("Service"); + } + print ''; } /*else {