diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 84992cc45bc86..fa40a1860b6b8 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -124,6 +124,8 @@ if ($forcelangprod == $current_lang) { $object->label = $libelle; $object->description = dol_htmlcleanlastbr($desc); + + $object->update($user); } else { $object->multilangs[$forcelangprod]["label"] = $libelle; $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f815cd849ed8c..c0a0d240fa757 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2387,7 +2387,7 @@ $formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->delivery_date); } // Incomplete payment. We ask if reason = discount or other - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250, 600); } if ($action == 'closeas') { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7457acd4e36bc..07bdd50e7a523 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -827,17 +827,22 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txloca $result = $this->line->insert(); if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) { - $this->line_order(true, 'DESC'); - } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - $linecount = count($this->lines); - for ($ii = $ranktouse; $ii <= $linecount; $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + if (!isset($this->context['createfromclone'])) { + if (!empty($fk_parent_line)) { + // Always reorder if child line + $this->line_order(true, 'DESC'); + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { + // Update all rank of all other lines starting from the same $ranktouse + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } } + + $this->lines[] = $this->line; } - // Mise a jour information denormalisees au niveau de la propale meme + // Update denormalized fields at the order level if (empty($noupdateafterinsertline)) { $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e60536c9bcbd9..881ed15a9eea0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -218,10 +218,10 @@ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('IdThirdParty')), null, 'errors'); } else { if ($object->id > 0) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later - $orig = clone $object; + // We clone object to avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. + $objectutil = dol_clone($object, 1); - $result = $object->createFromClone($user, $socid); + $result = $objectutil->createFromClone($user, $socid); if ($result > 0) { $warningMsgLineList = array(); // check all product lines are to sell otherwise add a warning message for each product line is not to sell @@ -243,7 +243,6 @@ exit; } else { setEventMessages($object->error, $object->errors, 'errors'); - $object = $orig; $action = ''; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5fb70cfcc54ed..aada73c641fa2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -113,9 +113,16 @@ class Commande extends CommonOrder /** * Status of the order * @var int + * @deprecated Use status */ public $statut; + /** + * Status of the order + * @var int + */ + public $status; + /** * @var int Status Billed or not */ @@ -793,12 +800,10 @@ public function set_reopen($user) * * @param User $user Object user that close * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer <0 if KO, 0=Nothing done, >0 if OK */ public function cloture($user, $notrigger = 0) { - global $conf; - $error = 0; $usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'creer')) @@ -1098,6 +1103,7 @@ public function create($user, $notrigger = 0) $line->ref_ext, 1 ); + if ($result < 0) { if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) { $this->error = $this->db->lasterror(); @@ -1541,7 +1547,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt $logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent"; $logtext .= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start"; - $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise, ref_ext=$ref_ext"; + $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise, ref_ext=$ref_ext rang=$rang"; dol_syslog(get_class($this).$logtext, LOG_DEBUG); if ($this->statut == self::STATUS_DRAFT) { @@ -1681,6 +1687,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt // Rang to use $ranktouse = $rang; + if ($ranktouse == -1) { $rangmax = $this->line_max($fk_parent_line); $ranktouse = $rangmax + 1; @@ -1753,24 +1760,28 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt $result = $this->line->insert($user); if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) { - $this->line_order(true, 'DESC'); - } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - $linecount = count($this->lines); - for ($ii = $ranktouse; $ii <= $linecount; $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); - } - } - - // Mise a jour information denormalisees au niveau de la commande meme + // Update denormalized fields at the order level if (empty($noupdateafterinsertline)) { $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. } if ($result > 0) { + if (!isset($this->context['createfromclone'])) { + if (!empty($fk_parent_line)) { + // Always reorder if child line + $this->line_order(true, 'DESC'); + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { + // Update all rank of all other lines starting from the same $ranktouse + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } + + $this->lines[] = $this->line; + } + $this->db->commit(); - $this->lines[] = $this->line; return $this->line->id; } else { $this->db->rollback(); @@ -1899,7 +1910,7 @@ public function fetch($id, $ref = '', $ref_ext = '', $notused = '') return -1; } - $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_user_modif, c.fk_statut'; + $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_user_modif, c.fk_statut as status'; $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.deposit_percent, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql .= ', c.fk_account'; $sql .= ', c.date_commande, c.date_valid, c.tms'; @@ -1955,8 +1966,8 @@ public function fetch($id, $ref = '', $ref_ext = '', $notused = '') $this->fk_project = $obj->fk_project; $this->project = null; // Clear if another value was already set by fetch_projet - $this->statut = $obj->fk_statut; - $this->status = $obj->fk_statut; + $this->statut = $obj->status; + $this->status = $obj->status; $this->user_author_id = $obj->fk_user_author; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/commande/class/orderline.class.php b/htdocs/commande/class/orderline.class.php index ec78db8e44dfc..618bbcccf74d9 100644 --- a/htdocs/commande/class/orderline.class.php +++ b/htdocs/commande/class/orderline.class.php @@ -341,7 +341,7 @@ public function delete(User $user, $notrigger = 0) } /** - * Insert line into database + * Insert line into database. This also set $this->id. * * @param User $user User that modify * @param int $notrigger 1 = disable triggers @@ -487,7 +487,7 @@ public function insert($user = null, $notrigger = 0) if (!$error) { $this->db->commit(); - return 1; + return $this->id; } foreach ($this->errors as $errmsg) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e588d00475f98..9e9ba12eda0f4 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -766,14 +766,16 @@ } } } + if ($action == 'validate' && $permissiontoadd && $objectclass !== null) { if (GETPOST('confirm') == 'yes') { + /** @var Commande $objecttmp */ $objecttmp = new $objectclass($db); $db->begin(); $error = 0; foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 0) { + if ($objecttmp->status == $objecttmp::STATUS_DRAFT) { if (!empty($objecttmp->fk_warehouse)) { $idwarehouse = $objecttmp->fk_warehouse; } else { @@ -804,21 +806,23 @@ } if ($action == 'shipped' && $permissiontoadd && $objectclass !== null) { if (GETPOST('confirm') == 'yes') { + /** @var Commande $objecttmp */ $objecttmp = new $objectclass($db); $db->begin(); $error = 0; foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { - if ($objecttmp->cloture($user)) { + if ($objecttmp->status == $objecttmp::STATUS_VALIDATED || $objecttmp->status == $objecttmp::STATUS_SHIPMENTONPROCESS || $objecttmp->status == $objecttmp::STATUS_CLOSED) { + $result = $objecttmp->cloture($user); + if ($result > 0) { setEventMessages($langs->trans('StatusOrderDelivered', $objecttmp->ref), null, 'mesgs'); - } else { + } elseif ($result < 0) { setEventMessages($langs->trans('ErrorOrderStatusCantBeSetToDelivered'), null, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); + setEventMessages($langs->trans('ErrorObjectHasWrongStatus', $objecttmp->ref), null, 'errors'); $error++; } } else { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d7583b42d6245..153a2c99bd834 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4110,21 +4110,26 @@ public function addline( $result = $this->line->insert(); if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) { - $this->line_order(true, 'DESC'); - } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - $linecount = count($this->lines); - for ($ii = $ranktouse; $ii <= $linecount; $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); - } - } - - // Mise a jour information denormalisees au niveau de la facture meme + // Update denormalized fields at the order level if (empty($noupdateafterinsertline)) { $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. } + if (!isset($this->context['createfromclone'])) { + if (!empty($fk_parent_line)) { + // Always reorder if child line + $this->line_order(true, 'DESC'); + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { + // Update all rank of all other lines starting from the same $ranktouse + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } + + $this->lines[] = $this->line; + } + if ($result > 0) { $this->db->commit(); return $this->line->id; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1558bfea3dcc9..30b233204ff01 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -74,7 +74,7 @@ public function __construct($db) * @param string $htmlname HTML name * @param string $modulepart Module part * @param string $dirformainimage Main directory of module - * @param string $subdirformainimage Subdirectory into main directory. Often ''. + * @param string $subdirformainimage Subdirectory into main directory. Often '', can be 'logos/'. * @param string $fileformainimage File name of image to show * @return string HTML code to show and edit image */ @@ -104,8 +104,8 @@ public function showImageToEdit(string $htmlname, string $modulepart, string $di $maxfilesizearray = getMaxFileSizeArray(); $maxmin = $maxfilesizearray['maxmin']; - $fileformainimagesmall = getImageFileNameForSize($fileformainimage, '_small'); - $fileformainimagemini = getImageFileNameForSize($fileformainimage, '_mini'); + $fileformainimagesmall = getImageFileNameForSize($fileformainimage, '_small'); // This include the "thumbs/..." in path + $fileformainimagemini = getImageFileNameForSize($fileformainimage, '_mini'); // This include the "thumbs/..." in path $out = ''; @@ -119,16 +119,16 @@ public function showImageToEdit(string $htmlname, string $modulepart, string $di $out .= '
'; $out .= ''.img_delete($langs->trans("Delete"), '', 'marginleftonly').''; $out .= '
'; - if (file_exists($dirformainimage.'/'.$subdirformainimage.'thumbs/'.$fileformainimagesmall)) { + if (file_exists($dirformainimage.'/'.$subdirformainimage.$fileformainimagesmall)) { $out .= '
'; - $out .= ''; + $out .= ''; $out .= '
'; } elseif (!empty($fileformainimage)) { // Regenerate the thumbs - if (!file_exists($dirformainimage.'/'.$subdirformainimage.'thumbs/'.$fileformainimagemini)) { + if (!file_exists($dirformainimage.'/'.$subdirformainimage.$fileformainimagemini)) { $imgThumbMini = vignette($dirformainimage.'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini, '_mini', $quality); } - $imgThumbSmall = vignette($dirformainimage.'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini, '_small', $quality); + $imgThumbSmall = vignette($dirformainimage.'/'.$subdirformainimage.$fileformainimage, $maxwidthsmall, $maxheightsmall, '_small', $quality); $out .= '
'; $out .= ''; $out .= '
'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 1bf8f9e06b87e..7d9beb89411e2 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1941,9 +1941,9 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu */ function showModulesExludedForExternal($modules) { - global $conf, $langs; + global $langs; - $text = $langs->trans("OnlyFollowingModulesAreOpenedToExternalUsers"); + $text = $langs->transnoentitiesnoconv("OnlyFollowingModulesAreOpenedToExternalUsers"); $listofmodules = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')); // List of modules qualified for external user management $i = 0; @@ -1967,11 +1967,11 @@ function showModulesExludedForExternal($modules) } $i++; - $tmptext = $langs->trans('Module'.$module->numero.'Name'); + $tmptext = $langs->transnoentitiesnoconv('Module'.$module->numero.'Name'); if ($tmptext != 'Module'.$module->numero.'Name') { - $text .= $langs->trans('Module'.$module->numero.'Name'); + $text .= $langs->transnoentitiesnoconv('Module'.$module->numero.'Name'); } else { - $text .= $langs->trans($module->name); + $text .= $langs->transnoentitiesnoconv($module->name); } } } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 19f2b59b50f3a..37ff20b4b6a88 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -328,7 +328,7 @@ function productlot_prepare_head($object) */ function product_admin_prepare_head() { - global $langs, $conf, $user, $db; + global $langs, $conf, $db; $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('product'); @@ -368,24 +368,31 @@ function product_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_price_extrafields.php'; - $head[$h][1] = $langs->trans("ProductLevelExtraFields"); - $nbExtrafields = $extrafields->attributes['product_price']['count']; - if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + // Extrafields for price levels + if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_price_extrafields.php'; + $head[$h][1] = $langs->trans("ProductLevelExtraFields"); + $nbExtrafields = $extrafields->attributes['product_price']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'levelAttributes'; + $h++; } - $head[$h][2] = 'levelAttributes'; - $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_customer_extrafields.php'; - $head[$h][1] = $langs->trans("ProductCustomerExtraFields"); - $nbExtrafields = $extrafields->attributes['product_customer_price']['count']; - if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + //Extrafields for price per customer + if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_customer_extrafields.php'; + $head[$h][1] = $langs->trans("ProductCustomerExtraFields"); + $nbExtrafields = $extrafields->attributes['product_customer_price']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'customerAttributes'; + $h++; } - $head[$h][2] = 'customerAttributes'; - $h++; + // Supplier prices $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php'; $head[$h][1] = $langs->trans("ProductSupplierExtraFields"); $nbExtrafields = $extrafields->attributes['product_fournisseur_price']['count']; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3bf206313c92f..7cdb5f92d0fcc 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1997,7 +1997,7 @@ public function createFromClone(User $user, $socid = 0, $notrigger = 0) * @param ?int $date_end Date end of service * @param array $array_options extrafields array * @param ?int $fk_unit Code of the unit to use. Null to use the default one - * @param int|string $pu_ht_devise Amount in currency + * @param int|string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @param int $rang Rank @@ -2006,7 +2006,7 @@ public function createFromClone(User $user, $socid = 0, $notrigger = 0) */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = 0, $date_start = null, $date_end = null, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1, $special_code = 0) { - global $langs, $mysoc, $conf; + global $langs, $mysoc; dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $info_bits, $notrigger, $date_start, $date_end, $fk_unit, $pu_ht_devise, $origin, $origin_id"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2243,19 +2243,25 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txloca $result = $this->line->insert($notrigger); if ($result > 0) { - // Reorder if child line - if (!empty($this->line->fk_parent_line)) { - $this->line_order(true, 'DESC'); - } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - $linecount = count($this->lines); - for ($ii = $rang; $ii <= $linecount; $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); - } - } - - // Mise a jour information denormalisees au niveau de la commande meme + // Update denormalized fields at the order level $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + if ($result > 0) { + if (!isset($this->context['createfromclone'])) { + if (!empty($this->line->fk_parent_line)) { + // Always reorder if child line + $this->line_order(true, 'DESC'); + } elseif ($rang > 0 && $rang <= count($this->lines)) { + // Update all rank of all other lines starting from the same $ranktouse + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } + + $this->lines[] = $this->line; + } + $this->db->commit(); return $this->line->id; } else { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1f6bce675e224..d911e369d690e 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2303,19 +2303,25 @@ public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $f $result = $supplierinvoiceline->insert($notrigger); if ($result > 0) { - // Reorder if child line - if (!empty($fk_parent_line)) { - $this->line_order(true, 'DESC'); - } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - $linecount = count($this->lines); - for ($ii = $rang; $ii <= $linecount; $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); - } - } - - // Mise a jour information denormalisees au niveau de la facture meme + // Update denormalized fields at the order level $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + if ($result > 0) { + if (!isset($this->context['createfromclone'])) { + if (!empty($fk_parent_line)) { + // Always reorder if child line + $this->line_order(true, 'DESC'); + } elseif ($rang > 0 && $rang <= count($this->lines)) { + // Update all rank of all other lines starting from the same $ranktouse + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } + + $this->lines[] = $supplierinvoiceline; + } + $this->db->commit(); return $supplierinvoiceline->id; } else { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 848634b588c79..caa92273db767 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -2062,7 +2062,11 @@ } // Billed if (!empty($arrayfields['cf.billed']['checked'])) { - print ''.yn($obj->billed).''; + print ''; + if ($obj->billed) { + print yn($obj->billed, $langs->trans("Billed")); + } + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index a5ac018f4fc3f..1f9126c5962dd 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -232,6 +232,7 @@ ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' ErrorTooManyErrorsProcessStopped=Too many errors. Process was stopped. ErrorMassValidationNotAllowedWhenStockIncreaseOnAction=Mass validation is not possible when option to increase/decrease stock is set on this action (you must validate one by one so you can define the warehouse to increase/decrease) ErrorObjectMustHaveStatusDraftToBeValidated=Object %s must have status 'Draft' to be validated. +ErrorObjectHasWrongStatus=Object %s must have another status for this operation. ErrorObjectMustHaveLinesToBeValidated=Object %s must have lines to be validated. ErrorOnlyInvoiceValidatedCanBeSentInMassAction=Only validated invoices can be sent using the "Send by email" mass action. ErrorChooseBetweenFreeEntryOrPredefinedProduct=You must choose if article is a predefined product or not diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 130b4bc1ce771..d833ba4391602 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -122,9 +122,11 @@ if ($tmprule == $princingrules) { // We are on selected rule, we enable it if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'PRODUCT_PRICE_UNIQ', 1, 'chaine', 0, '', $conf->entity); } else { $multirule = explode('&', $princingrules); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 71c71590c54fc..42b6b585810b6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1513,7 +1513,7 @@ $totalarray['nbfield']++; } if (!empty($arrayfields['co.country_code']['checked'])) { - print_liste_field_titre($arrayfields['co.country_code']['label'], $_SERVER["PHP_SELF"], "co.country_code", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($arrayfields['co.country_code']['label'], $_SERVER["PHP_SELF"], "country.code", "", $param, "", $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } if (!empty($arrayfields['commercial']['checked'])) { @@ -1889,7 +1889,7 @@ } // Country code if (!empty($arrayfields['co.country_code']['checked'])) { - print ''; + print ''; print $obj->country_code; print ''; if (!$i) {