mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into NEW_deposit_payment_terms
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -266,6 +266,11 @@ class Commande extends CommonOrder
|
||||
//! key of pos source ('0', '1', ...)
|
||||
public $pos_source;
|
||||
|
||||
/**
|
||||
* @var array Array with line of all shipments
|
||||
*/
|
||||
public $expeditions;
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
@@ -392,9 +397,6 @@ class Commande extends CommonOrder
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
$this->remise = 0;
|
||||
$this->remise_percent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,7 +501,8 @@ class Commande extends CommonOrder
|
||||
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
||||
$sql .= " fk_statut = ".self::STATUS_VALIDATED.",";
|
||||
$sql .= " date_valid='".$this->db->idate($now)."',";
|
||||
$sql .= " fk_user_valid = ".((int) $user->id);
|
||||
$sql .= " fk_user_valid = ".((int) $user->id).",";
|
||||
$sql .= " fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::valid", LOG_DEBUG);
|
||||
@@ -629,7 +632,8 @@ class Commande extends CommonOrder
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
|
||||
$sql .= " SET fk_statut = ".self::STATUS_DRAFT;
|
||||
$sql .= " SET fk_statut = ".self::STATUS_DRAFT.",";
|
||||
$sql .= " fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -703,7 +707,8 @@ class Commande extends CommonOrder
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
||||
$sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
|
||||
$sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0,';
|
||||
$sql .= " fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
|
||||
@@ -764,7 +769,8 @@ class Commande extends CommonOrder
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET fk_statut = '.self::STATUS_CLOSED.',';
|
||||
$sql .= ' fk_user_cloture = '.((int) $user->id).',';
|
||||
$sql .= " date_cloture = '".$this->db->idate($now)."'";
|
||||
$sql .= " date_cloture = '".$this->db->idate($now)."',";
|
||||
$sql .= " fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > '.self::STATUS_DRAFT;
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -812,7 +818,8 @@ class Commande extends CommonOrder
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
|
||||
$sql .= " SET fk_statut = ".self::STATUS_CANCELED;
|
||||
$sql .= " SET fk_statut = ".self::STATUS_CANCELED.",";
|
||||
$sql .= " fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
$sql .= " AND fk_statut = ".self::STATUS_VALIDATED;
|
||||
|
||||
@@ -876,7 +883,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $conf, $langs, $mysoc;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
@@ -1044,7 +1051,8 @@ class Commande extends CommonOrder
|
||||
$origintype,
|
||||
$originid,
|
||||
0,
|
||||
$line->ref_ext
|
||||
$line->ref_ext,
|
||||
1
|
||||
);
|
||||
if ($result < 0) {
|
||||
if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) {
|
||||
@@ -1056,11 +1064,13 @@ class Commande extends CommonOrder
|
||||
return -1;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $line->product_type == 9) {
|
||||
if ($result > 0) {
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
|
||||
$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.
|
||||
|
||||
// update ref
|
||||
$initialref = '(PROV'.$this->id.')';
|
||||
if (!empty($this->ref)) {
|
||||
@@ -1440,6 +1450,7 @@ class Commande extends CommonOrder
|
||||
* @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id
|
||||
* @param double $pu_ht_devise Unit price in currency
|
||||
* @param string $ref_ext line external reference
|
||||
* @param int $noupdateafterinsertline No update after insert of line
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*
|
||||
* @see add_product()
|
||||
@@ -1449,7 +1460,7 @@ class Commande extends CommonOrder
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '')
|
||||
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '', $noupdateafterinsertline = 0)
|
||||
{
|
||||
global $mysoc, $conf, $langs, $user;
|
||||
|
||||
@@ -1660,7 +1671,10 @@ class Commande extends CommonOrder
|
||||
}
|
||||
|
||||
// Mise a jour informations denormalisees au niveau de la commande meme
|
||||
$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 (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) {
|
||||
$this->db->commit();
|
||||
return $this->line->id;
|
||||
@@ -1791,7 +1805,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_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';
|
||||
$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';
|
||||
@@ -1856,6 +1870,7 @@ class Commande extends CommonOrder
|
||||
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->user_valid = $obj->fk_user_valid;
|
||||
$this->user_modification = $obj->fk_user_modif;
|
||||
$this->total_ht = $obj->total_ht;
|
||||
$this->total_tva = $obj->total_tva;
|
||||
$this->total_localtax1 = $obj->total_localtax1;
|
||||
@@ -2017,9 +2032,9 @@ class Commande extends CommonOrder
|
||||
/**
|
||||
* Load array lines
|
||||
*
|
||||
* @param int $only_product Return only physical products, not services
|
||||
* @param int $only_product Return only physical products, not services
|
||||
* @param int $loadalsotranslation Return translation for products
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
||||
{
|
||||
@@ -2214,9 +2229,10 @@ class Commande extends CommonOrder
|
||||
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
|
||||
*
|
||||
* @param int $filtre_statut Filter on shipment status
|
||||
* @param int $fk_product Add a filter on a product
|
||||
* @return int <0 if KO, Nb of lines found if OK
|
||||
*/
|
||||
public function loadExpeditions($filtre_statut = -1)
|
||||
public function loadExpeditions($filtre_statut = -1, $fk_product = 0)
|
||||
{
|
||||
$this->expeditions = array();
|
||||
|
||||
@@ -3665,7 +3681,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
global $conf, $langs, $user, $hookmanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
@@ -3766,6 +3782,15 @@ class Commande extends CommonOrder
|
||||
}
|
||||
}
|
||||
|
||||
global $action;
|
||||
$hookmanager->initHooks(array($this->element . 'dao'));
|
||||
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
|
||||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) {
|
||||
$result = $hookmanager->resPrint;
|
||||
} else {
|
||||
$result .= $hookmanager->resPrint;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user