Skip to content

Commit

Permalink
Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 11, 2025
2 parents 2fc2e04 + 56f5232 commit 9bc2a3a
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 105 deletions.
2 changes: 2 additions & 0 deletions htdocs/categories/traduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
21 changes: 13 additions & 8 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
7 changes: 3 additions & 4 deletions htdocs/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -243,7 +243,6 @@
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
$object = $orig;
$action = '';
}
}
Expand Down
49 changes: 30 additions & 19 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/class/orderline.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 9 additions & 5 deletions htdocs/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 16 additions & 11 deletions htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions htdocs/core/class/html.formfile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 = '';

Expand All @@ -119,16 +119,16 @@ public function showImageToEdit(string $htmlname, string $modulepart, string $di
$out .= '<div class="inline-block valignmiddle marginrightonly">';
$out .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=remove'.$htmlname.'&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a>';
$out .= '</div>';
if (file_exists($dirformainimage.'/'.$subdirformainimage.'thumbs/'.$fileformainimagesmall)) {
if (file_exists($dirformainimage.'/'.$subdirformainimage.$fileformainimagesmall)) {
$out .= '<div class="inline-block valignmiddle marginrightonly">';
$out .= '<img id="'.$htmlname.'" style="'.$max.'height: '.$imgheight.'px; '.$max.'width: '.$imgwidth.'px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($subdirformainimage.'thumbs/'.$fileformainimagesmall).'">';
$out .= '<img id="'.$htmlname.'" style="'.$max.'height: '.$imgheight.'px; '.$max.'width: '.$imgwidth.'px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($subdirformainimage.$fileformainimagesmall).'">';
$out .= '</div>';
} 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 .= '<div class="inline-block valignmiddle">';
$out .= '<img id="'.$htmlname.'" style="'.$max.'height: '.$imgheight.'px; '.$max.'width: '.$imgwidth.'px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($subdirformainimage.'thumbs/'.basename($imgThumbSmall)).'">';
$out .= '</div>';
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/lib/admin.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
Expand Down
Loading

0 comments on commit 9bc2a3a

Please sign in to comment.