Qual: Removed phpcodesniffer errors
This commit is contained in:
parent
46516731e6
commit
44e4f42e86
@ -25,30 +25,31 @@
|
||||
|
||||
/**
|
||||
* \class DiscountAbsolute
|
||||
* \brief Classe permettant la gestion des remises fixes
|
||||
* \brief Class to manage absolute discounts
|
||||
*/
|
||||
class DiscountAbsolute
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $id; // Id remise
|
||||
var $id; // Id discount
|
||||
var $fk_soc;
|
||||
var $amount_ht; //
|
||||
var $amount_tva; //
|
||||
var $amount_ttc; //
|
||||
var $tva_tx; //
|
||||
var $tva_tx; // Vat rate
|
||||
var $fk_user; // Id utilisateur qui accorde la remise
|
||||
var $description; // Description libre
|
||||
var $datec; // Date creation
|
||||
var $fk_facture_line; // Id invoice line when a discount linked to invoice line
|
||||
var $fk_facture; // Id invoice when a discoutn linked to invoice
|
||||
var $fk_facture_line; // Id invoice line when a discount linked to invoice line (for absolute discounts)
|
||||
var $fk_facture; // Id invoice when a discoutn linked to invoice (for credit note)
|
||||
var $fk_facture_source; // Id facture avoir a l'origine de la remise
|
||||
var $ref_facture_source; // Ref facture avoir a l'origine de la remise
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param DB Database handler
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $DB Database handler
|
||||
*/
|
||||
function DiscountAbsolute($DB)
|
||||
{
|
||||
@ -57,10 +58,11 @@ class DiscountAbsolute
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load object from database into memory
|
||||
* \param rowid id discount to load
|
||||
* \param fk_facture_source fk_facture_source
|
||||
* \return int <0 if KO, =0 if not found, >0 if OK
|
||||
* Load object from database into memory
|
||||
*
|
||||
* @param int $rowid id discount to load
|
||||
* @param int $fk_facture_source fk_facture_source
|
||||
* @return int <0 if KO, =0 if not found, >0 if OK
|
||||
*/
|
||||
function fetch($rowid,$fk_facture_source=0)
|
||||
{
|
||||
@ -83,7 +85,7 @@ class DiscountAbsolute
|
||||
if ($rowid) $sql.= " sr.rowid=".$rowid;
|
||||
if ($fk_facture_source) $sql.= " sr.fk_facture_source=".$fk_facture_source;
|
||||
|
||||
dol_syslog("DiscountAbsolute::fetch sql=".$sql);
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -142,7 +144,7 @@ class DiscountAbsolute
|
||||
if (empty($this->description))
|
||||
{
|
||||
$this->error='BadValueForPropertyDescription';
|
||||
dol_syslog("DiscountAbsolute::create ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -157,7 +159,7 @@ class DiscountAbsolute
|
||||
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog("DiscountAbsolute::create sql=".$sql);
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -167,7 +169,7 @@ class DiscountAbsolute
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror().' - sql='.$sql;
|
||||
dol_syslog("DiscountAbsolute::create ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -193,7 +195,7 @@ class DiscountAbsolute
|
||||
$sql.=" AND fk_facture_source = ".$this->fk_facture_source;
|
||||
//$sql.=" AND rowid != ".$this->id;
|
||||
|
||||
dol_syslog("DiscountAbsolute::delete Check if we can remove discount sql=".$sql);
|
||||
dol_syslog(get_class($this)."::delete Check if we can remove discount sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -220,7 +222,7 @@ class DiscountAbsolute
|
||||
$sql.= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount
|
||||
$sql.= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit
|
||||
|
||||
dol_syslog("DiscountAbsolute::delete Delete discount sql=".$sql);
|
||||
dol_syslog(get_class($this)."::delete Delete discount sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -231,7 +233,7 @@ class DiscountAbsolute
|
||||
$sql.=" set paye=0, fk_statut=1";
|
||||
$sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source;
|
||||
|
||||
dol_syslog("DiscountAbsolute::delete Update credit note or deposit invoice statut sql=".$sql);
|
||||
dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -262,11 +264,13 @@ class DiscountAbsolute
|
||||
|
||||
|
||||
/**
|
||||
* Link the discount to a particular invoice line or a particular invoice
|
||||
* Link the discount to a particular invoice line or a particular invoice.
|
||||
* When discount is a global discount used as an invoice line, we link using rowidline.
|
||||
* When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice
|
||||
*
|
||||
* @param int $rowidline Invoice line id
|
||||
* @param int $rowidinvoice Invoice id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $rowidline Invoice line id (To use discount into invoice lines)
|
||||
* @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function link_to_invoice($rowidline,$rowidinvoice)
|
||||
{
|
||||
@ -287,7 +291,7 @@ class DiscountAbsolute
|
||||
if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice;
|
||||
$sql.=" WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog("DiscountAbsolute::link_to_invoice sql=".$sql,LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::link_to_invoice sql=".$sql,LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -298,18 +302,17 @@ class DiscountAbsolute
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR);
|
||||
dol_syslog(get_class($this)."::link_to_invoice ".$this->error,LOG_ERR);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Link the discount to a particular invoice line or a particular invoice
|
||||
* \remarks Do not call this if discount is linked to a reconcialiated invoice
|
||||
* \param rowidline Invoice line id
|
||||
* \param rowidinvoice Invoice id
|
||||
* \return int <0 if KO, >0 if OK
|
||||
* Link the discount to a particular invoice line or a particular invoice.
|
||||
* Do not call this if discount is linked to a reconcialiated invoice
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function unlink_invoice()
|
||||
{
|
||||
@ -317,7 +320,7 @@ class DiscountAbsolute
|
||||
$sql.=" SET fk_facture_line = NULL, fk_facture = NULL";
|
||||
$sql.=" WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog("DiscountAbsolute::unlink_invoice sql=".$sql,LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::unlink_invoice sql=".$sql,LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -326,19 +329,20 @@ class DiscountAbsolute
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR);
|
||||
dol_syslog(get_class($this)."::unlink_invoice ".$this->error,LOG_ERR);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoie montant TTC des reductions/avoirs en cours disponibles pour une société, un user ou autre
|
||||
* \param company Object third party for filter
|
||||
* \param user Filtre sur un user auteur des remises
|
||||
* \param filter Filtre autre
|
||||
* \param maxvalue Filter on max value for discount
|
||||
* \return int <0 si ko, montant avoir sinon
|
||||
* Renvoie montant TTC des reductions/avoirs en cours disponibles pour une société, un user ou autre
|
||||
*
|
||||
* @param Societe $company Object third party for filter
|
||||
* @param User $user Filtre sur un user auteur des remises
|
||||
* @param string $filter Filtre autre
|
||||
* @param int $maxvalue Filter on max value for discount
|
||||
* @return int <0 if KO, amount otherwise
|
||||
*/
|
||||
function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0)
|
||||
{
|
||||
@ -351,7 +355,7 @@ class DiscountAbsolute
|
||||
if ($filter) $sql.=' AND '.$filter;
|
||||
if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
|
||||
|
||||
dol_syslog("DiscountAbsolute::getAvailableDiscounts sql=".$sql,LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::getAvailableDiscounts sql=".$sql,LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -368,8 +372,10 @@ class DiscountAbsolute
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return amount (with tax) of all credit notes and deposits invoices used by invoice
|
||||
* \return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
* Return amount (with tax) of all credit notes and deposits invoices used by invoice
|
||||
*
|
||||
* @param Facture $invoice Object invoice
|
||||
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
*/
|
||||
function getSumCreditNotesUsed($invoice)
|
||||
{
|
||||
@ -378,7 +384,7 @@ class DiscountAbsolute
|
||||
$sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
|
||||
$sql.= ' AND f.type = 2';
|
||||
|
||||
dol_syslog("DiscountAbsolute::getSumCreditNotesUsed sql=".$sql,LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::getSumCreditNotesUsed sql=".$sql,LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -392,8 +398,10 @@ class DiscountAbsolute
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return amount (with tax) of all deposits invoices used by invoice
|
||||
* \return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
* Return amount (with tax) of all deposits invoices used by invoice
|
||||
*
|
||||
* @param Facture $invoice Object invoice
|
||||
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
*/
|
||||
function getSumDepositsUsed($invoice)
|
||||
{
|
||||
@ -402,7 +410,7 @@ class DiscountAbsolute
|
||||
$sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
|
||||
$sql.= ' AND f.type = 3';
|
||||
|
||||
dol_syslog("DiscountAbsolute::getSumDepositsUsed sql=".$sql,LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::getSumDepositsUsed sql=".$sql,LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -416,10 +424,11 @@ class DiscountAbsolute
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return clicable ref of object (with picto or not)
|
||||
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||
* \param option Sur quoi pointe le lien
|
||||
* \return string Chaine avec URL
|
||||
* Return clickable ref of object (with picto or not)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only
|
||||
* @param string $option Where to link to ('invoice' or 'discount')
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto,$option='invoice')
|
||||
{
|
||||
@ -451,5 +460,23 @@ class DiscountAbsolute
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the intervention with random values
|
||||
* Used to generate a intervention for the preview or demo models
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
|
||||
$this->fk_soc = 1;
|
||||
$this->amount_ht = 10;
|
||||
$this->amount_tva = 1.96;
|
||||
$this->amount_ttc = 11.96;
|
||||
$this->tva_tx = 19.6;
|
||||
$this->description = 'Specimen discount';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user