diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 630433324c4..8759f2eebf3 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -68,6 +68,13 @@ class FactureRec extends CommonInvoice
var $usenewprice=0;
+ var $suspended; // status
+
+ const STATUS_NOTSUSPENDED = 0;
+ const STATUS_SUSPENDED = 1;
+
+
+
/**
* Constructor
*
@@ -95,6 +102,7 @@ class FactureRec extends CommonInvoice
// Clean parameters
$this->titre=trim($this->titre);
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
+ if (empty($this->suspended)) $this->suspended=0;
// No frequency defined then no next date to execution
if (empty($this->frequency))
@@ -147,6 +155,7 @@ class FactureRec extends CommonInvoice
$sql.= ", fk_multicurrency";
$sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx";
+ $sql.= ", suspended";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->titre)."'";
$sql.= ", ".$facsrc->socid;
@@ -167,13 +176,14 @@ class FactureRec extends CommonInvoice
$sql.= ", '".$this->db->escape($this->unit_frequency)."'";
$sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL');
$sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL');
- $sql.= ", ".$this->nb_gen_done;
- $sql.= ", ".$this->nb_gen_max;
- $sql.= ", ".$this->auto_validate;
- $sql.= ", ".$this->generate_pdf;
- $sql.= ", ".$facsrc->fk_multicurrency;
- $sql.= ", '".$facsrc->multicurrency_code."'";
- $sql.= ", ".$facsrc->multicurrency_tx;
+ $sql.= ", ".$this->db->escape($this->nb_gen_done);
+ $sql.= ", ".$this->db->escape($this->nb_gen_max);
+ $sql.= ", ".$this->db->escape($this->auto_validate);
+ $sql.= ", ".$this->db->escape($this->generate_pdf);
+ $sql.= ", ".$this->db->escape($facsrc->fk_multicurrency);
+ $sql.= ", '".$this->db->escape($facsrc->multicurrency_code)."'";
+ $sql.= ", ".$this->db->escape($facsrc->multicurrency_tx);
+ $sql.= ", ".$this->db->escape($this->suspended);
$sql.= ")";
if ($this->db->query($sql))
@@ -1149,49 +1159,69 @@ class FactureRec extends CommonInvoice
$prefix='';
if ($recur)
{
- if ($status == 1) return $langs->trans('Disabled'); // credit note
+ if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
else return $langs->trans('Active');
}
- else return $langs->trans("Draft");
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
+ else return $langs->trans("Draft");
+ }
}
if ($mode == 1)
{
$prefix='Short';
if ($recur)
{
- if ($status == 1) return $langs->trans('Disabled');
+ if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
else return $langs->trans('Active');
}
- else return $langs->trans("Draft");
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
+ else return $langs->trans("Draft");
+ }
}
if ($mode == 2)
{
if ($recur)
{
- if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
- else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
+ else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
+ }
}
if ($mode == 3)
{
if ($recur)
{
$prefix='Short';
- if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6');
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6');
else return img_picto($langs->trans('Active'),'statut4');
}
- else return img_picto($langs->trans('Draft'),'statut0');
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6');
+ else return img_picto($langs->trans('Draft'),'statut0');
+ }
}
if ($mode == 4)
{
$prefix='';
if ($recur)
{
- if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
- else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
+ else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
+ }
}
if ($mode == 5 || $mode == 6)
{
@@ -1199,10 +1229,14 @@ class FactureRec extends CommonInvoice
if ($mode == 5) $prefix='Short';
if ($recur)
{
- if ($status == 1) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut6');
+ if ($status == self::STATUS_SUSPENDED) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut6');
else return ''.$langs->trans('Active').' '.img_picto($langs->trans('Active'),'statut4');
}
- else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');
+ else
+ {
+ if ($status == self::STATUS_SUSPENDED) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut6');
+ else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');
+ }
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index d80c67a8aeb..f92b80570b6 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2841,7 +2841,6 @@ abstract class CommonObject
$sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')";
}
$sql .= ' ORDER BY sourcetype';
- //print $sql;
dol_syslog(get_class($this)."::fetchObjectLink", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -3086,9 +3085,10 @@ abstract class CommonObject
* @param int $status Status to set
* @param int $elementId Id of element to force (use this->id by default)
* @param string $elementType Type of element to force (use this->table_element by default)
+ * @param string $trigkey Trigger key to use for trigger
* @return int <0 if KO, >0 if OK
*/
- function setStatut($status,$elementId=null,$elementType='')
+ function setStatut($status, $elementId=null, $elementType='', $trigkey='')
{
global $user,$langs,$conf;
@@ -3100,6 +3100,7 @@ abstract class CommonObject
$this->db->begin();
$fieldstatus="fk_statut";
+ if ($elementTable == 'facture_rec') $fieldstatus="suspended";
if ($elementTable == 'mailing') $fieldstatus="statut";
if ($elementTable == 'cronjob') $fieldstatus="status";
if ($elementTable == 'user') $fieldstatus="statut";
@@ -3117,13 +3118,16 @@ abstract class CommonObject
{
$error = 0;
- $trigkey='';
- if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
- if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
- if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
- if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE';
- if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED';
- if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED';
+ // Try autoset of trigkey
+ if (empty($trigkey))
+ {
+ if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
+ if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
+ if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
+ if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE';
+ if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED';
+ if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED';
+ }
if ($trigkey)
{