diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c7a9494cb7a..7d106da5999 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1949,7 +1949,7 @@ class Adherent extends CommonObject $this->naiss=time(); $this->photo=''; $this->public=1; - $this->statut=1; + $this->statut=0; $this->datefin=time(); $this->datevalid=time(); diff --git a/htdocs/comm/propal/propal.class.php b/htdocs/comm/propal/propal.class.php index e8439e2ed77..625b638b3da 100644 --- a/htdocs/comm/propal/propal.class.php +++ b/htdocs/comm/propal/propal.class.php @@ -1903,27 +1903,6 @@ class Propal extends CommonObject { global $user,$langs,$conf; - // Charge tableau des id de societe socids - $socids = array(); - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE client IN (1, 3)"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; - - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } - // Charge tableau des produits prodids $prodids = array(); $sql = "SELECT rowid"; @@ -1948,15 +1927,16 @@ class Propal extends CommonObject $this->ref = 'SPECIMEN'; $this->ref_client='NEMICEPS'; $this->specimen=1; - $socid = rand(1, $num_socs); - $this->socid = $socids[$socid]; + $this->socid = 1; $this->date = time(); $this->fin_validite = $this->date+3600*24*30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_id = 7; $this->mode_reglement_code = 'CHQ'; - $this->note_public='SPECIMEN'; + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; + // Lines $nbp = rand(1, 9); $xnbp = 0; while ($xnbp < $nbp) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a8a5a0f486e..28ba7dc16f4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2234,37 +2234,12 @@ class Commande extends CommonObject dol_syslog("Commande::initAsSpecimen"); - // Charge tableau des id de societe socids - $socids = array(); - - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE client IN (1, 3)"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; - - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } - // Charge tableau des produits prodids $prodids = array(); - $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); if ($resql) { @@ -2282,13 +2257,14 @@ class Commande extends CommonObject $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $socid = rand(1, $num_socs); - $this->socid = $socids[$socid]; + $this->socid = 1; $this->date = time(); $this->date_lim_reglement=$this->date+3600*24*30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; - $this->note_public='SPECIMEN'; + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; + // Lines $nbp = rand(1, 9); $xnbp = 0; while ($xnbp < $nbp) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b9f960e4b1a..fb482158098 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2734,35 +2734,11 @@ class Facture extends CommonObject { global $user,$langs,$conf; - $socids = array(); - - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE client IN (1, 3)"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; - - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } - $prodids = array(); - $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); if ($resql) { @@ -2780,8 +2756,7 @@ class Facture extends CommonObject $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $socid = rand(1, $num_socs); - $this->socid = $socids[$socid]; + $this->socid = 1; $this->date = time(); $this->date_lim_reglement=$this->date+3600*24*30; $this->cond_reglement_id = 1; @@ -2789,6 +2764,7 @@ class Facture extends CommonObject $this->mode_reglement_id = 7; $this->mode_reglement_code = 'CHQ'; $this->note_public='SPECIMEN'; + // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index c9851ba42c9..afebe903a15 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -503,7 +503,7 @@ class Contrat extends CommonObject } else { - dol_syslog("Contrat::Fetch Erreur lecture des lignes de contrat non li�es aux produits"); + dol_syslog("Contrat::Fetch Erreur lecture des lignes de contrat non liees aux produits"); $this->error=$this->db->error(); return -2; } @@ -516,12 +516,12 @@ class Contrat extends CommonObject /** * \brief Create a contract into database * \param user User that create - * \param langs Environnement langue de l'utilisateur - * \param conf Environnement de configuration lors de l'operation - * \return int <0 si erreur, id contrat cre sinon + * \return int <0 if KO, id of contract if OK */ - function create($user,$langs='',$conf='') + function create($user) { + global $conf,$langs,$mysoc; + // Check parameters $paramsok=1; if ($this->commercial_signature_id <= 0) @@ -559,11 +559,11 @@ class Contrat extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat"); - // Ins�re contacts commerciaux ('SALESREPSIGN','contrat') + // Insert contacts commerciaux ('SALESREPSIGN','contrat') $result=$this->add_contact($this->commercial_signature_id,'SALESREPSIGN','internal'); if ($result < 0) $error++; - // Ins�re contacts commerciaux ('SALESREPFOLL','contrat') + // Insert contacts commerciaux ('SALESREPFOLL','contrat') $result=$this->add_contact($this->commercial_suivi_id,'SALESREPFOLL','internal'); if ($result < 0) $error++; @@ -783,7 +783,7 @@ class Contrat extends CommonObject */ function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0) { - global $langs, $conf; + global $user, $langs, $conf; dol_syslog("Contrat::addline $desc, $pu_ht, $qty, $txtva, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits"); @@ -857,7 +857,7 @@ class Contrat extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $result=$this->update_statut(); + $result=$this->update_statut($user); if ($result > 0) { $this->db->commit(); @@ -903,6 +903,8 @@ class Contrat extends CommonObject $date_start='', $date_end='', $tvatx, $date_debut_reel='', $date_fin_reel='') { + global $user, $conf, $langs; + // Nettoyage parametres $qty=trim($qty); $desc=trim($desc); @@ -947,7 +949,7 @@ class Contrat extends CommonObject $result = $this->db->query($sql); if ($result) { - $result=$this->update_statut(); + $result=$this->update_statut($user); if ($result >= 0) { $this->db->commit(); @@ -1013,7 +1015,7 @@ class Contrat extends CommonObject * \brief Update statut of contract according to services * \return int <0 si ko, >0 si ok */ - function update_statut() + function update_statut($user) { // If draft, we keep it (should not happen) if ($this->statut == 0) return 1; @@ -1366,6 +1368,73 @@ class Contrat extends CommonObject return $this->getIdContact('external','SERVICE'); } + + /** + * \brief Initialise le membre avec valeurs fictives aleatoire + */ + function initAsSpecimen() + { + global $user,$langs,$conf; + + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE envente = 1"; + $sql.= " AND entity = ".$conf->entity; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + + + + // Initialise parametres + $this->id=0; + $this->specimen=1; + + $this->ref = 'DOLIBARR'; + $this->socid = 1; + $this->statut= 0; + $this->date_contrat = dol_now(); + $this->commercial_signature_id = 1; + $this->commercial_suivi_id = 1; + $this->note='This is a comment (private)'; + $this->note='This is a comment (public)'; + $this->fk_projet = 0; + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $ligne=new ContratLigne($this->db); + $ligne->desc=$langs->trans("Description")." ".$xnbp; + $ligne->qty=1; + $ligne->subprice=100; + $ligne->price=100; + $ligne->tva_tx=19.6; + $ligne->remise_percent=10; + $ligne->total_ht=90; + $ligne->total_ttc=107.64; // 90 * 1.196 + $ligne->total_tva=17.64; + $prodid = rand(1, $num_prods); + $ligne->fk_product=$prodids[$prodid]; + $this->lignes[$xnbp]=$ligne; + $xnbp++; + } + + $this->amount_ht = $xnbp*100; + $this->total_ht = $xnbp*100; + $this->total_tva = $xnbp*19.6; + $this->total_ttc = $xnbp*119.6; + } } @@ -1687,7 +1756,7 @@ class ContratLigne { $contrat=new Contrat($this->db); $contrat->fetch($this->fk_contrat); - $result=$contrat->update_statut(); + $result=$contrat->update_statut($user); } else { diff --git a/htdocs/core/interfaces.class.php b/htdocs/core/interfaces.class.php index 34f9f0fafd2..45532d420e3 100644 --- a/htdocs/core/interfaces.class.php +++ b/htdocs/core/interfaces.class.php @@ -37,8 +37,8 @@ class Interfaces var $errors = array(); // Array for errors /** - * \brief Constructeur. - * \param DB handler d'acces base + * \brief Constructor. + * \param DB Database handler */ function Interfaces($DB) { @@ -48,17 +48,22 @@ class Interfaces /** * \brief Fonction appelee lors du declenchement d'un evenement Dolibarr. * Cette fonction declenche tous les triggers trouves actifs. - * \param action Code de l'evenement + * \param action Trigger event code * \param object Objet concern * \param user Objet user * \param lang Objet lang * \param conf Objet conf - * \return int Nb triggers ayant agit si pas d'erreurs, -Nb en erreur sinon. + * \return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. */ function run_triggers($action,$object,$user,$langs,$conf) { // Check parameters - if (! is_object($object) || ! is_object($user) || ! is_object($langs) || ! is_object($conf)) + if (! is_object($object) || ! is_object($conf)) // Error + { + dol_syslog('interface::run_triggers was called with wrong parameters object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_ERROR); + return -1; + } + if (! is_object($user) || ! is_object($langs)) // Warning { dol_syslog('interface::run_triggers was called with wrong parameters object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); }