From e099507594412df8acd573100377e7342f07843a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Oct 2020 18:53:03 +0100 Subject: [PATCH] Fix regression --- htdocs/core/class/commonincoterm.class.php | 2 +- htdocs/delivery/card.php | 39 +++++++++++----------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index b2d5491684e..f98f3aaabad 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -105,7 +105,7 @@ trait CommonIncoterm * * @param int $id_incoterm Id of incoterm to set or '' to remove * @param string $location location of incoterm - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setIncoterms($id_incoterm, $location) { diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 440de00499e..5eb373d4f0d 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -74,6 +74,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('deliverycard', 'globalcard')); +$error = 0; + /* * Actions @@ -86,19 +88,17 @@ if ($action == 'add') { $db->begin(); - $object->date_livraison = time(); - $object->note = GETPOST("note", 'restricthtml'); - $object->note_private = GETPOST("note", 'restricthtml'); - $object->commande_id = GETPOST("commande_id", 'int'); + $object->date_delivery = dol_now(); + $object->note = GETPOST("note", 'restricthtml'); + $object->note_private = GETPOST("note", 'restricthtml'); + $object->commande_id = GETPOST("commande_id", 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) - { + if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) { $expedition->entrepot_id = GETPOST('entrepot_id'); } - // On boucle sur chaque ligne de commande pour completer objet livraison - // avec qte a livrer + // We loop on each line of order to complete object delivery with qty to delivery $commande = new Commande($db); $commande->fetch($object->commande_id); $commande->fetch_lines(); @@ -107,15 +107,15 @@ if ($action == 'add') { $qty = "qtyl".$i; $idl = "idl".$i; - if ($_POST[$qty] > 0) + $qtytouse = price2num(GETPOST($qty)); + if ($qtytouse > 0) { - $object->addline($_POST[$idl], $_POST[$qty]); + $object->addline(GETPOST($idl), price2num($qtytouse)); } } $ret = $object->create($user); - if ($ret > 0) - { + if ($ret > 0) { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -123,7 +123,6 @@ if ($action == 'add') setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $_GET["commande_id"] = $_POST["commande_id"]; $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && @@ -168,7 +167,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio } } -if ($action == 'setdate_livraison' && $user->rights->expedition->delivery->creer) +if ($action == 'setdate_delivery' && $user->rights->expedition->delivery->creer) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $result = $object->setDeliveryDate($user, $datedelivery); @@ -181,7 +180,7 @@ if ($action == 'setdate_livraison' && $user->rights->expedition->delivery->creer // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); + $result = $object->setIncoterms((int) GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // Update extrafields @@ -434,15 +433,15 @@ if ($action == 'create') // Create. Seems to no be used print $langs->trans('DateReceived'); print ''; - if ($action != 'editdate_livraison') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).''; + if ($action != 'editdate_delivery') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).''; print ''; print ''; - if ($action == 'editdate_livraison') + if ($action == 'editdate_delivery') { - print '
'; + print ''; print ''; - print ''; - print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 1); + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_delivery", 1, 1); print ''; print '
'; } else {