Clean code

This commit is contained in:
Laurent Destailleur 2018-05-31 17:12:08 +02:00
parent 0503373e31
commit 7c0afbe025
3 changed files with 41 additions and 37 deletions

View File

@ -1784,11 +1784,14 @@ class FactureLigneRec extends CommonInvoiceLine
$sql.= ", info_bits='".price2num($this->info_bits)."'"; $sql.= ", info_bits='".price2num($this->info_bits)."'";
$sql.= ", date_start_fill=".(int) $this->date_start_fill; $sql.= ", date_start_fill=".(int) $this->date_start_fill;
$sql.= ", date_end_fill=".(int) $this->date_end_fill; $sql.= ", date_end_fill=".(int) $this->date_end_fill;
$sql.= ", total_ht='".price2num($this->total_ht)."'"; if (empty($this->skip_update_total))
$sql.= ", total_tva='".price2num($this->total_tva)."'"; {
$sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; $sql.= ", total_ht=".price2num($this->total_ht);
$sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; $sql.= ", total_tva=".price2num($this->total_tva);
$sql.= ", total_ttc='".price2num($this->total_ttc)."'"; $sql.= ", total_localtax1=".price2num($this->total_localtax1);
$sql.= ", total_localtax2=".price2num($this->total_localtax2);
$sql.= ", total_ttc=".price2num($this->total_ttc);
}
$sql.= ", rang=".$this->rang; $sql.= ", rang=".$this->rang;
$sql.= ", special_code=".$this->special_code; $sql.= ", special_code=".$this->special_code;
$sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit )."'":"null"); $sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit )."'":"null");

View File

@ -4676,11 +4676,11 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ", special_code='".$this->db->escape($this->special_code)."'"; $sql.= ", special_code='".$this->db->escape($this->special_code)."'";
if (empty($this->skip_update_total)) if (empty($this->skip_update_total))
{ {
$sql.= ", total_ht=".price2num($this->total_ht).""; $sql.= ", total_ht=".price2num($this->total_ht);
$sql.= ", total_tva=".price2num($this->total_tva).""; $sql.= ", total_tva=".price2num($this->total_tva);
$sql.= ", total_ttc=".price2num($this->total_ttc).""; $sql.= ", total_ttc=".price2num($this->total_ttc);
$sql.= ", total_localtax1=".price2num($this->total_localtax1).""; $sql.= ", total_localtax1=".price2num($this->total_localtax1);
$sql.= ", total_localtax2=".price2num($this->total_localtax2).""; $sql.= ", total_localtax2=".price2num($this->total_localtax2);
} }
$sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null");
$sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'";
@ -4773,6 +4773,7 @@ class FactureLigne extends CommonInvoiceLine
/** /**
* Mise a jour en base des champs total_xxx de ligne de facture * Mise a jour en base des champs total_xxx de ligne de facture
* TODO What is goal of this method ?
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */

View File

@ -1287,36 +1287,36 @@ class Contrat extends CommonObject
$result=$this->call_trigger('CONTRACT_MODIFY',$user); $result=$this->call_trigger('CONTRACT_MODIFY',$user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
}
}
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
} }
} }
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/** /**
* Ajoute une ligne de contrat en base * Ajoute une ligne de contrat en base