mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-20 15:53:16 +01:00
To get source of command on command file
This commit is contained in:
@@ -64,6 +64,8 @@ class Commande extends CommonObject
|
||||
var $mode_reglement_code;
|
||||
var $availability_id;
|
||||
var $availability_code;
|
||||
var $demand_reason_id;
|
||||
var $demand_reason_code;
|
||||
var $fk_delivery_address;
|
||||
var $adresse;
|
||||
var $date; // Date commande
|
||||
@@ -567,7 +569,7 @@ class Commande extends CommonObject
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
|
||||
$sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client";
|
||||
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, date_livraison, fk_adresse_livraison";
|
||||
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_demand_reason, date_livraison, fk_adresse_livraison";
|
||||
$sql.= ", remise_absolue, remise_percent";
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
@@ -580,6 +582,7 @@ class Commande extends CommonObject
|
||||
$sql.= ", ".($this->cond_reglement_id>0?"'".$this->cond_reglement_id."'":"null");
|
||||
$sql.= ", ".($this->mode_reglement_id>0?"'".$this->mode_reglement_id."'":"null");
|
||||
$sql.= ", ".($this->availability_id>0?"'".$this->availability_id."'":"null");
|
||||
$sql.= ", ".($this->demand_reason_id>0?"'".$this->demand_reason_id."'":"null");
|
||||
$sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
|
||||
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
|
||||
$sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL');
|
||||
@@ -854,6 +857,7 @@ class Commande extends CommonObject
|
||||
$this->cond_reglement_id = $object->cond_reglement_id;
|
||||
$this->mode_reglement_id = $object->mode_reglement_id;
|
||||
$this->availability_id = $object->availability_id;
|
||||
$this->demand_reason_id = $object->demand_reason_id;
|
||||
$this->date_livraison = $object->date_livraison;
|
||||
$this->fk_delivery_address = $object->fk_delivery_address;
|
||||
$this->contact_id = $object->contactid;
|
||||
@@ -1142,7 +1146,7 @@ class Commande extends CommonObject
|
||||
if (empty($id) && empty($ref)) return -1;
|
||||
|
||||
$sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut';
|
||||
$sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability';
|
||||
$sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_demand_reason';
|
||||
$sql.= ', c.date_commande';
|
||||
$sql.= ', c.date_livraison';
|
||||
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee';
|
||||
@@ -1150,11 +1154,13 @@ class Commande extends CommonObject
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
|
||||
$sql.= ', ca.code as availability_code';
|
||||
$sql.= ', dr.code as demand_reason_code';
|
||||
$sql.= ', el.fk_source';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_demand_reason as dr ON (c.fk_demand_reason = ca.rowid)';
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = c.rowid AND el.targettype = '".$this->element."'";
|
||||
$sql.= " WHERE c.entity = ".$conf->entity;
|
||||
if ($ref) $sql.= " AND c.ref='".$ref."'";
|
||||
@@ -1198,6 +1204,8 @@ class Commande extends CommonObject
|
||||
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
|
||||
$this->availability_id = $obj->fk_availability;
|
||||
$this->availability_code = $obj->availability_code;
|
||||
$this->demand_reason_id = $obj->fk_demand_reason;
|
||||
$this->demand_reason_code = $obj->demand_reason_code;
|
||||
$this->date_livraison = $this->db->jdate($obj->date_livraison);
|
||||
$this->fk_delivery_address = $obj->fk_adresse_livraison;
|
||||
$this->propale_id = $obj->fk_source;
|
||||
@@ -1810,6 +1818,34 @@ class Commande extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set source of demand
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param delivery delai de livraison
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_demand_reason($user, $id)
|
||||
{
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande ";
|
||||
$sql.= " SET fk_demand_reason = '".$id."'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->fk_demand_reason = $id;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("Commande::set_demand_reason Erreur SQL");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return list of orders (eventuelly filtered on a user) into an array
|
||||
* \param brouillon 0=non brouillon, 1=brouillon
|
||||
@@ -1954,6 +1990,39 @@ class Commande extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Change la source de la demande
|
||||
* \param mode Id du nouveau mode
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function demand_reason($demand_reason_id)
|
||||
{
|
||||
dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
|
||||
if ($this->statut >= 0)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
|
||||
$sql .= ' SET fk_demand_reason = '.$demand_reason_id;
|
||||
$sql .= ' WHERE rowid='.$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->demand_reason_id = $demand_reason_id;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::demand_reason Erreur '.$sql.' - '.$this->db->error(), LOG_ERR);
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::demand_reason, etat facture incompatible', LOG_ERR);
|
||||
$this->error='Etat commande incompatible '.$this->statut;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set customer ref
|
||||
* \param user User that make change
|
||||
@@ -2495,6 +2564,7 @@ class Commande extends CommonObject
|
||||
$this->cond_reglement_code = 'RECEP';
|
||||
$this->mode_reglement_code = 'CHQ';
|
||||
$this->availability_code = 'DSP';
|
||||
$this->demand_reason_code = 'SRC_00';
|
||||
$this->note_public='This is a comment (public)';
|
||||
$this->note='This is a comment (private)';
|
||||
// Lines
|
||||
|
||||
Reference in New Issue
Block a user