diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2fdb91ec935..2451e6dc2ce 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -207,6 +207,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once' include DOL_DOCUMENT_ROOT . '/core/actions_lineupdown.inc.php'; // Must be 'include', not 'include_once' + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { if (!($socid > 0)) { @@ -1278,6 +1279,13 @@ if (empty($reshook)) { } } + $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc); + + if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; @@ -1287,6 +1295,10 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } + if ($qty < 0 && !getDolGlobalString('PROPAL_ENABLE_NEGATIVE_QTY')) { + setEventMessages($langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; @@ -1306,8 +1318,7 @@ if (empty($reshook)) { } } - $propal_qty_requirement = (getDolGlobalString('PROPAL_ENABLE_NEGATIVE_QTY') ? ($qty >= 0 || $qty <= 0) : $qty >= 0); - if (!$error && $propal_qty_requirement && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) { + if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) { $pu_ht = 0; $pu_ttc = 0; $pu_ht_devise = 0; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 61aac40eb72..501ed8784f5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1016,7 +1016,10 @@ if (empty($reshook)) { } } - if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) { + $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc); + + if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) { + $langs->load("errors"); setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -1032,10 +1035,12 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($qty < 0) { + + if ($qty < 0 && !getDolGlobalString('ORDER_ENABLE_NEGATIVE_QTY')) { setEventMessages($langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; @@ -1055,7 +1060,7 @@ if (empty($reshook)) { } } - if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) { + if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) { // Clean parameters $date_start = dol_mktime(GETPOSTINT('date_start' . $predef . 'hour'), GETPOSTINT('date_start' . $predef . 'min'), GETPOSTINT('date_start' . $predef . 'sec'), GETPOSTINT('date_start' . $predef . 'month'), GETPOSTINT('date_start' . $predef . 'day'), GETPOSTINT('date_start' . $predef . 'year')); $date_end = dol_mktime(GETPOSTINT('date_end' . $predef . 'hour'), GETPOSTINT('date_end' . $predef . 'min'), GETPOSTINT('date_end' . $predef . 'sec'), GETPOSTINT('date_end' . $predef . 'month'), GETPOSTINT('date_end' . $predef . 'day'), GETPOSTINT('date_end' . $predef . 'year')); @@ -1673,7 +1678,7 @@ if (empty($reshook)) { } } - if ($qty < 0) { + if ($qty < 0 && !getDolGlobalString('ORDER_ENABLE_NEGATIVE_QTY')) { setEventMessages($langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; $action = 'editline'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5b19de7c676..3635aca2b79 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1232,6 +1232,7 @@ class Form if (empty($hidetext)) { print $langs->trans("Type").'...'; } + print ''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c23fcb1f563..dd7107d17b7 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -246,7 +246,10 @@ if ($nolinesbefore) { if ($forceall >= 0 && (isModEnabled("product") || isModEnabled("service"))) { print ''; } @@ -804,11 +807,11 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { } if (jQuery("#select_type").val() != '-1') { - console.log("we remove class"); + console.log("we remove class placeholder"); jQuery("#select_type").removeClass("placeholder"); setFocusOnDescription(); } else { - console.log("we add class"); + console.log("we add class placeholder"); jQuery("#select_type").addClass("placeholder"); } }); @@ -826,9 +829,12 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { + console.log("emulate click on prod_entry_mode_predef"); jQuery("#prod_entry_mode_predef").click(); + } elseif (!GETPOSTISSET("type")) { // If not a type selected from previous page + ?> + console.log("add class placeholder"); jQuery("#select_type").addClass("placeholder"); hasRight('margins', 'creer')) { } } }); - /* When changing predefined product, we reload list of supplier prices required for margin combo */