mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -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 @@ class Commande extends CommonOrder
|
||||
*
|
||||
* @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 @@ class Commande extends CommonOrder
|
||||
$line->ref_ext,
|
||||
1
|
||||
);
|
||||
|
||||
if ($result < 0) {
|
||||
if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) {
|
||||
$this->error = $this->db->lasterror();
|
||||
@@ -1541,7 +1547,7 @@ class Commande extends CommonOrder
|
||||
|
||||
$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 @@ class Commande extends CommonOrder
|
||||
|
||||
// Rang to use
|
||||
$ranktouse = $rang;
|
||||
|
||||
if ($ranktouse == -1) {
|
||||
$rangmax = $this->line_max($fk_parent_line);
|
||||
$ranktouse = $rangmax + 1;
|
||||
@@ -1753,24 +1760,28 @@ class Commande extends CommonOrder
|
||||
|
||||
$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 @@ class Commande extends CommonOrder
|
||||
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 @@ class Commande extends CommonOrder
|
||||
$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;
|
||||
|
||||
Reference in New Issue
Block a user