From a169b3348ee2d5249baccc0fadc8adeffd747c75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 14:36:22 +0100 Subject: [PATCH] Fix show alays date fields for contract module. Fix select of product were lost. --- htdocs/commande/card.php | 32 +++++++++++------------ htdocs/core/tpl/objectline_create.tpl.php | 22 +++++++--------- htdocs/fourn/commande/card.php | 6 ++--- htdocs/product/class/product.class.php | 4 +-- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 12150f9a61e..27c333eec21 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -207,13 +207,13 @@ if (empty($reshook)) if ($datecommande == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; - $error ++; + $error++; } if (! $error) { @@ -334,7 +334,7 @@ if (empty($reshook)) $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); if ($result < 0) { - $error ++; + $error++; break; } @@ -349,14 +349,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessage($srcobject->error, 'errors'); - $error ++; + $error++; } } else { setEventMessage($object->error, 'errors'); - $error ++; + $error++; } } else { // Required extrafield left blank, error message already defined by setOptionalsFromPost() @@ -390,7 +390,7 @@ if (empty($reshook)) $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - $error ++; + $error++; } } @@ -554,24 +554,24 @@ if (empty($reshook)) if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { @@ -826,7 +826,7 @@ if (empty($reshook)) if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type'); @@ -835,7 +835,7 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + $error++; } } @@ -1137,10 +1137,10 @@ if (empty($reshook)) if (empty($reshook)) { $result = $object->insertExtraFields(); if ($result < 0) { - $error ++; + $error++; } } else if ($reshook < 0) - $error ++; + $error++; } if ($error) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6037f6c77c9..e3f2431783f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -153,12 +153,12 @@ else { if (empty($senderissupplier)) { - $form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); } else { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key + 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' ); @@ -192,23 +192,16 @@ else { tva_assuj == "0") echo '0'; - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); - } + if ($seller->tva_assuj == "0") echo '0'; + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> - "> - - "> - "> @@ -273,7 +266,7 @@ else { service->enabled) && $dateSelector && GETPOST('type') != '0') +if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; @@ -493,6 +486,11 @@ jQuery(document).ready(function() { if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); }); + + + setforpredef(); + + }); /* Function to set fields from choice */ diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7750250b00b..eefd5c961e2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -251,7 +251,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $idprod=0; $productsupplier = new ProductFournisseur($db); - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { @@ -294,12 +294,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $date_end ); } - if ($idprod == -2 || $idprod == 0) + if ($idprod == 0 || $idprod == -99) { // Product not selected $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors'); } if ($idprod == -1) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 653925701ad..ac3d8e967a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1229,14 +1229,14 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -3; } } } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } }