Fix clean parameters
This commit is contained in:
parent
8dfa87fcf6
commit
04e1458a3f
@ -715,6 +715,9 @@ class FactureRec extends CommonInvoice
|
||||
dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
// Clean parameters
|
||||
if (empty($remise_percent)) $remise_percent = 0;
|
||||
|
||||
// Check parameters
|
||||
if ($type < 0) return -1;
|
||||
|
||||
|
||||
@ -538,11 +538,13 @@ class Contrat extends CommonObject
|
||||
/**
|
||||
* Load a contract from database
|
||||
*
|
||||
* @param int $id Id of contract to load
|
||||
* @param string $ref Ref
|
||||
* @return int <0 if KO, id of contract if OK
|
||||
* @param int $id Id of contract to load
|
||||
* @param string $ref Ref
|
||||
* @param string $ref_customer Customer ref
|
||||
* @param string $ref_supplier Supplier ref
|
||||
* @return int <0 if KO, 0 if not found, Id of contract if OK
|
||||
*/
|
||||
function fetch($id,$ref='')
|
||||
function fetch($id, $ref='', $ref_customer='', $ref_supplier='')
|
||||
{
|
||||
$sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
|
||||
$sql.= " ref_supplier, ref_customer,";
|
||||
@ -553,12 +555,20 @@ class Contrat extends CommonObject
|
||||
$sql.= " fk_commercial_signature, fk_commercial_suivi,";
|
||||
$sql.= " note_private, note_public, model_pdf, extraparams";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
|
||||
if (! $id) $sql.=" WHERE entity IN (".getEntity('contract', 0).")";
|
||||
else $sql.= " WHERE rowid=".$id;
|
||||
if ($ref_customer)
|
||||
{
|
||||
$sql.= " AND ref_customer = '".$this->db->escape($ref_customer)."'";
|
||||
}
|
||||
if ($ref_supplier)
|
||||
{
|
||||
$sql.= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'";
|
||||
}
|
||||
if ($ref)
|
||||
{
|
||||
$sql.= " WHERE ref='".$this->db->escape($ref)."'";
|
||||
$sql.= " AND entity IN (".getEntity('contract', 0).")";
|
||||
$sql.= " AND ref='".$this->db->escape($ref)."'";
|
||||
}
|
||||
else $sql.= " WHERE rowid=".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -628,7 +638,7 @@ class Contrat extends CommonObject
|
||||
{
|
||||
dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve");
|
||||
$this->error="Contract not found";
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2834,6 +2844,7 @@ class ContratLigne extends CommonObjectLine
|
||||
if (empty($this->total_ttc)) $this->total_ttc = 0;
|
||||
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
|
||||
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
|
||||
if (empty($this->remise_percent)) $this->remise_percent = 0;
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
Loading…
Reference in New Issue
Block a user