clean trigger and normalize code

This commit is contained in:
florian HENRY 2016-07-08 21:28:21 +02:00
parent 2d9876d127
commit 10b0e5dd57
3 changed files with 222 additions and 157 deletions

View File

@ -59,24 +59,24 @@ class Propal extends CommonObject
* ID of the client
* @var int
*/
var $socid;
public $socid;
var $contactid;
var $author;
var $ref_client;
public $contactid;
public $author;
public $ref_client;
/**
* Status of the quote
* @var int
* @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED
*/
var $statut;
public $statut;
/**
* @deprecated
* @see date_creation
*/
var $datec;
public $datec;
/**
* Creation date
@ -88,7 +88,7 @@ class Propal extends CommonObject
* @deprecated
* @see date_validation
*/
var $datev;
public $datev;
/**
* Validation date
@ -100,70 +100,72 @@ class Propal extends CommonObject
* Date of the quote
* @var
*/
var $date;
public $date;
/**
* @deprecated
* @see date
*/
var $datep;
var $date_livraison;
var $fin_validite;
public $datep;
public $date_livraison;
public $fin_validite;
var $user_author_id;
var $user_valid_id;
var $user_close_id;
public $user_author_id;
public $user_valid_id;
public $user_close_id;
/**
* @deprecated
* @see total_ht
*/
var $price;
public $price;
/**
* @deprecated
* @see total_tva
*/
var $tva;
public $tva;
/**
* @deprecated
* @see total_ttc
*/
var $total;
public $total;
var $cond_reglement_code;
var $mode_reglement_code;
var $remise;
var $remise_percent;
var $remise_absolue;
var $fk_address;
var $address_type;
var $address;
var $availability_id;
var $availability_code;
var $demand_reason_id;
var $demand_reason_code;
public $cond_reglement_code;
public $mode_reglement_code;
public $remise;
public $remise_percent;
public $remise_absolue;
public $fk_address;
public $address_type;
public $address;
public $availability_id;
public $availability_code;
public $demand_reason_id;
public $demand_reason_code;
var $products=array();
var $extraparams=array();
public $products=array();
public $extraparams=array();
/**
* @var PropaleLigne[]
*/
var $lines = array();
var $line;
public $lines = array();
public $line;
var $labelstatut=array();
var $labelstatut_short=array();
public $labelstatut=array();
public $labelstatut_short=array();
var $specimen;
public $specimen;
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
public $oldcopy;
/**
* Draft status
@ -1641,6 +1643,13 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date = $date;
$this->datep = $date; // deprecated
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1651,9 +1660,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->date = $date;
$this->datep = $date; // deprecated
$this->db->commit();
return 1;
}
@ -1697,6 +1703,13 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fin_validite = $date_fin_validite;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1707,8 +1720,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->fin_validite = $date_fin_validite;
$this->db->commit();
return 1;
}
@ -1753,6 +1764,12 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date_livraison = $date_livraison;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1763,8 +1780,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->date_livraison = $date_livraison;
$this->db->commit();
return 1;
}
@ -1809,6 +1824,12 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_availability = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1819,8 +1840,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->fk_availability = $id;
$this->db->commit();
return 1;
}
@ -1865,6 +1884,14 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1875,8 +1902,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->fk_input_reason = $id;
$this->db->commit();
return 1;
}
@ -1920,6 +1945,12 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->ref_client = $ref_client;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1930,8 +1961,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->ref_client = $ref_client;
$this->db->commit();
return 1;
}
@ -1983,6 +2012,13 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_percent = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -1993,9 +2029,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->remise_percent = $remise;
$this->update_price(1);
$this->db->commit();
return 1;
}
@ -2045,6 +2078,13 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2055,9 +2095,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->remise_absolue = $remise;
$this->update_price(1);
$this->db->commit();
return 1;
}
@ -2201,6 +2238,14 @@ class Propal extends CommonObject
$this->generateDocument($modelpdf, $outputlangs);
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = $statut;
$this->date_cloture = $now;
$this->note_private = $note;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2211,8 +2256,6 @@ class Propal extends CommonObject
if ( ! $error )
{
$this->statut = $statut;
$this->db->commit();
return 1;
}
@ -2254,6 +2297,12 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut=self::STATUS_BILLED;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2264,8 +2313,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->statut=self::STATUS_BILLED;
$this->db->commit();
return 1;
}
@ -2320,6 +2367,13 @@ class Propal extends CommonObject
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2330,9 +2384,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
$this->db->commit();
return 1;
}
@ -2669,6 +2720,12 @@ class Propal extends CommonObject
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->availability_id = $availability_id;
}
if (! $notrigger && empty($error))
{
@ -2680,8 +2737,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->availability_id = $availability_id;
$this->db->commit();
return 1;
}
@ -2732,6 +2787,12 @@ class Propal extends CommonObject
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->demand_reason_id = $demand_reason_id;
}
if (! $notrigger && empty($error))
{
@ -2743,8 +2804,6 @@ class Propal extends CommonObject
if (! $error)
{
$this->demand_reason_id = $demand_reason_id;
$this->db->commit();
return 1;
}

View File

@ -57,99 +57,99 @@ class Commande extends CommonOrder
* Client ID
* @var int
*/
var $socid;
public $socid;
var $ref_client;
var $ref_int;
var $contactid;
public $ref_client;
public $ref_int;
public $contactid;
/**
* Status of the order. Check the following constants:
* @var int
* @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED
*/
var $statut;
public $statut;
/**
* @deprecated
* @see billed
*/
var $facturee;
var $billed; // billed or not
public $facturee;
public $billed; // billed or not
var $brouillon;
var $cond_reglement_code;
public $brouillon;
public $cond_reglement_code;
var $fk_account;
public $fk_account;
/**
* It holds the label of the payment mode. Use it in case translation cannot be found.
* @var string
*/
var $mode_reglement;
public $mode_reglement;
/**
* Payment mode id
* @var int
*/
var $mode_reglement_id;
public $mode_reglement_id;
/**
* Payment mode code
* @var string
*/
var $mode_reglement_code;
public $mode_reglement_code;
/**
* Availability delivery time id
* @var int
*/
var $availability_id;
public $availability_id;
/**
* Availability delivery time code
* @var string
*/
var $availability_code;
public $availability_code;
/**
* Label of availability delivery time. Use it in case translation cannot be found.
* @var string
*/
var $availability;
public $availability;
var $demand_reason_id;
var $demand_reason_code;
var $address;
var $date; // Date commande
public $demand_reason_id;
public $demand_reason_code;
public $address;
public $date; // Date commande
/**
* @deprecated
* @see date
*/
var $date_commande;
var $date_livraison; // Date livraison souhaitee
var $fk_remise_except;
var $remise_percent;
var $remise_absolue;
var $info_bits;
var $rang;
var $special_code;
var $source; // Origin of order
var $extraparams=array();
public $date_commande;
public $date_livraison; // Date livraison souhaitee
public $fk_remise_except;
public $remise_percent;
public $remise_absolue;
public $info_bits;
public $rang;
public $special_code;
public $source; // Origin of order
public $extraparams=array();
var $linked_objects=array();
public $linked_objects=array();
var $user_author_id;
public $user_author_id;
/**
* @var OrderLine[]
*/
var $lines = array();
public $lines = array();
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
var $oldcopy;
public $oldcopy;
/**
* ERR Not enough stock
@ -2715,14 +2715,14 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG);
if ($this->db->query($sql))
{
if (! $error)
{
$this->oldcopy= clone $this;
$this->facturee=1; // deprecated
$this->billed=1;
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2794,7 +2794,7 @@ class Commande extends CommonOrder
$this->facturee=1; // deprecated
$this->billed=1;
}
// Call trigger
$result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
if ($result < 0) $error++;

View File

@ -59,63 +59,63 @@ class Facture extends CommonInvoice
*/
protected $table_ref_field = 'facnumber';
var $socid;
public $socid;
var $author;
var $fk_user_author;
var $fk_user_valid;
var $date; // Date invoice
var $date_creation; // Creation date
var $date_validation; // Validation date
var $datem;
var $ref_client;
var $ref_int;
public $author;
public $fk_user_author;
public $fk_user_valid;
public $date; // Date invoice
public $date_creation; // Creation date
public $date_validation; // Validation date
public $datem;
public $ref_client;
public $ref_int;
//Check constants for types
var $type = self::TYPE_STANDARD;
public $type = self::TYPE_STANDARD;
//var $amount;
var $remise_absolue;
var $remise_percent;
var $total_ht=0;
var $total_tva=0;
var $total_ttc=0;
var $revenuestamp;
public $remise_absolue;
public $remise_percent;
public $total_ht=0;
public $total_tva=0;
public $total_ttc=0;
public $revenuestamp;
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
//! Fermeture alors que aucun paiement: replaced (si remplace), abandon
var $close_code;
public $close_code;
//! Commentaire si mis a paye sans paiement complet
var $close_note;
public $close_note;
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
var $paye;
public $paye;
//! id of source invoice if replacement invoice or credit note
var $fk_facture_source;
var $linked_objects=array();
var $date_lim_reglement;
var $cond_reglement_code; // Code in llx_c_paiement
var $mode_reglement_code; // Code in llx_c_paiement
var $fk_bank; // Field to store bank id to use when payment mode is withdraw
public $fk_facture_source;
public $linked_objects=array();
public $date_lim_reglement;
public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement
public $fk_bank; // Field to store bank id to use when payment mode is withdraw
/**
* @deprecated
*/
var $products=array();
public $products=array();
/**
* @var FactureLigne[]
*/
var $lines=array();
var $line;
var $extraparams=array();
var $specimen;
public $lines=array();
public $line;
public $extraparams=array();
public $specimen;
var $fac_rec;
public $fac_rec;
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* @var int Situation cycle reference number
@ -142,6 +142,8 @@ class Facture extends CommonInvoice
*/
public $tab_next_situation_invoice=array();
public $oldcopy;
/**
* Standard invoice
*/
@ -1512,8 +1514,8 @@ class Facture extends CommonInvoice
if (! $error)
{
$this->ref_client = $ref_client;
}
if (! $notrigger && empty($error))
{
@ -2887,6 +2889,13 @@ class Facture extends CommonInvoice
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
@ -2897,9 +2906,6 @@ class Facture extends CommonInvoice
if (! $error)
{
$this->remise_absolue = $remise;
$this->update_price(1);
$this->db->commit();
return 1;
}