Fix clean parameters

This commit is contained in:
Laurent Destailleur 2017-09-19 22:03:44 +02:00
parent 8dfa87fcf6
commit 04e1458a3f
2 changed files with 22 additions and 8 deletions

View File

@ -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); 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'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent = 0;
// Check parameters // Check parameters
if ($type < 0) return -1; if ($type < 0) return -1;

View File

@ -538,11 +538,13 @@ class Contrat extends CommonObject
/** /**
* Load a contract from database * Load a contract from database
* *
* @param int $id Id of contract to load * @param int $id Id of contract to load
* @param string $ref Ref * @param string $ref Ref
* @return int <0 if KO, id of contract if OK * @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 = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
$sql.= " ref_supplier, ref_customer,"; $sql.= " ref_supplier, ref_customer,";
@ -553,12 +555,20 @@ class Contrat extends CommonObject
$sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,";
$sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " note_private, note_public, model_pdf, extraparams";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat"; $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) if ($ref)
{ {
$sql.= " WHERE ref='".$this->db->escape($ref)."'"; $sql.= " AND ref='".$this->db->escape($ref)."'";
$sql.= " AND entity IN (".getEntity('contract', 0).")";
} }
else $sql.= " WHERE rowid=".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -628,7 +638,7 @@ class Contrat extends CommonObject
{ {
dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve"); dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve");
$this->error="Contract not found"; $this->error="Contract not found";
return -2; return 0;
} }
} }
else else
@ -2834,6 +2844,7 @@ class ContratLigne extends CommonObjectLine
if (empty($this->total_ttc)) $this->total_ttc = 0; if (empty($this->total_ttc)) $this->total_ttc = 0;
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
if (empty($this->remise_percent)) $this->remise_percent = 0;
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values