This commit is contained in:
Laurent Destailleur 2012-01-04 21:47:40 +01:00
parent 3f8d2cbef8
commit 915bc47a58
9 changed files with 287 additions and 243 deletions

View File

@ -72,22 +72,21 @@ class Contrat extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Contrat($DB) function Contrat($db)
{ {
global $langs; $this->db = $db;
$this->product = new Product($db);
$this->db = $DB ; $this->societe = new Societe($db);
$this->product = new Product($DB); $this->user_service = new User($db);
$this->societe = new Societe($DB); $this->user_cloture = new User($db);
$this->user_service = new User($DB);
$this->user_cloture = new User($DB);
} }
/** /**
* Return next contract ref * Return next contract ref
* @param soc objet society *
* @param Societe $soc objet society
* @return string free reference for contract * @return string free reference for contract
*/ */
function getNextNumRef($soc) function getNextNumRef($soc)
@ -121,7 +120,7 @@ class Contrat extends CommonObject
} }
else else
{ {
dol_print_error($db,"Contract::getNextValue ".$obj->error); dol_print_error($db,get_class($this)."::getNextValue ".$obj->error);
return ""; return "";
} }
} }
@ -133,13 +132,14 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Activate a contract line * Activate a contract line
* \param user Objet User qui active le contrat *
* \param line_id Id de la ligne de detail a activer * @param user Objet User qui active le contrat
* \param date Date d'ouverture * @param line_id Id de la ligne de detail a activer
* \param date_end Date fin prevue * @param date Date d'ouverture
* \param comment A comment typed by user * @param date_end Date fin prevue
* \return int <0 if KO, >0 if OK * @param comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/ */
function active_line($user, $line_id, $date, $date_end='', $comment='') function active_line($user, $line_id, $date, $date_end='', $comment='')
{ {
@ -157,7 +157,7 @@ class Contrat extends CommonObject
$sql.= " commentaire = '".$this->db->escape($comment)."'"; $sql.= " commentaire = '".$this->db->escape($comment)."'";
$sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3 OR statut = 5)"; $sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3 OR statut = 5)";
dol_syslog("Contrat::active_line sql=".$sql); dol_syslog(get_class($this)."::active_line sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -174,7 +174,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("Contrat::active_line error ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::active_line error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -182,12 +182,13 @@ class Contrat extends CommonObject
/** /**
* \brief Close a contract line * Close a contract line
* \param user Objet User qui active le contrat *
* \param line_id Id de la ligne de detail a activer * @param user Objet User qui active le contrat
* \param date_end Date fin * @param line_id Id de la ligne de detail a activer
* \param comment A comment typed by user * @param date_end Date fin
* \return int <0 if KO, >0 if OK * @param comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/ */
function close_line($user, $line_id, $date_end, $comment='') function close_line($user, $line_id, $date_end, $comment='')
{ {
@ -221,7 +222,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("Contrat::close_line error ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::close_line error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -231,9 +232,9 @@ class Contrat extends CommonObject
/** /**
* Close all lines of a contract * Close all lines of a contract
* *
* @param user Object User making action * @param User $user Object User making action
* @param langs Object Lang * @param Translate $langs Object Lang
* @param conf Object Conf * @param Conf $conf Object Conf
* @return void * @return void
*/ */
function cloture($user,$langs='',$conf='') function cloture($user,$langs='',$conf='')
@ -279,11 +280,12 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Validate a contract * Validate a contract
* \param user Objet User *
* \param langs Environnement langue de l'utilisateur * @param user Objet User
* \param conf Environnement de configuration lors de l'operation * @param langs Environnement langue de l'utilisateur
* \return int <0 if KO, >0 if OK * @param conf Environnement de configuration lors de l'operation
* @return int <0 if KO, >0 if OK
*/ */
function validate($user,$langs,$conf) function validate($user,$langs,$conf)
{ {
@ -314,7 +316,8 @@ class Contrat extends CommonObject
/** /**
* Load a contract from database * Load a contract from database
* @param id Id of contract to load *
* @param int $id Id of contract to load
* @return int <0 if KO, id of contract if OK * @return int <0 if KO, id of contract if OK
*/ */
function fetch($id,$ref='') function fetch($id,$ref='')
@ -329,7 +332,7 @@ class Contrat extends CommonObject
if ($ref) $sql.= " WHERE ref='".$ref."'"; if ($ref) $sql.= " WHERE ref='".$ref."'";
else $sql.= " WHERE rowid=".$id; else $sql.= " WHERE rowid=".$id;
dol_syslog("Contrat::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -369,14 +372,14 @@ class Contrat extends CommonObject
} }
else else
{ {
dol_syslog("Contrat::Fetch Erreur contrat non trouve"); dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve");
$this->error="Contrat non trouve"; $this->error="Contract not found";
return -2; return -2;
} }
} }
else else
{ {
dol_syslog("Contrat::Fetch Erreur lecture contrat"); dol_syslog(get_class($this)."::Fetch Erreur lecture contrat");
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
@ -385,6 +388,7 @@ class Contrat extends CommonObject
/** /**
* Load lignes array into this->lines * Load lignes array into this->lines
*
* @return Array Return array of contract lines * @return Array Return array of contract lines
*/ */
function fetch_lines() function fetch_lines()
@ -420,7 +424,7 @@ class Contrat extends CommonObject
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid"; $sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid";
$sql.= " ORDER by d.rowid ASC"; $sql.= " ORDER by d.rowid ASC";
dol_syslog("Contrat::fetch_lines sql=".$sql); dol_syslog(get_class($this)."::fetch_lines sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -494,7 +498,7 @@ class Contrat extends CommonObject
} }
else else
{ {
dol_syslog("Contrat::Fetch Erreur lecture des lignes de contrats liees aux produits"); dol_syslog(get_class($this)."::Fetch Erreur lecture des lignes de contrats liees aux produits");
return -3; return -3;
} }
@ -582,7 +586,7 @@ class Contrat extends CommonObject
} }
else else
{ {
dol_syslog("Contrat::Fetch Erreur lecture des lignes de contrat non liees aux produits"); dol_syslog(get_class($this)."::Fetch Erreur lecture des lignes de contrat non liees aux produits");
$this->error=$this->db->error(); $this->error=$this->db->error();
return -2; return -2;
} }
@ -596,9 +600,10 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Create a contract into database * Create a contract into database
* \param user User that create *
* \return int <0 if KO, id of contract if OK * @param User $user User that create
* @return int <0 if KO, id of contract if OK
*/ */
function create($user) function create($user)
{ {
@ -666,7 +671,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error=$interface->error; $this->error=$interface->error;
dol_syslog("Contrat::create - 30 - ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create - 30 - ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
@ -675,7 +680,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error="Failed to add contact"; $this->error="Failed to add contact";
dol_syslog("Contrat::create - 20 - ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create - 20 - ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
@ -684,7 +689,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error=$langs->trans("UnknownError: ".$this->db->error()." - sql=".$sql); $this->error=$langs->trans("UnknownError: ".$this->db->error()." - sql=".$sql);
dol_syslog("Contrat::create - 10 - ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create - 10 - ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
@ -693,11 +698,12 @@ class Contrat extends CommonObject
/** /**
* \brief Supprime l'objet de la base * Supprime l'objet de la base
* \param user Utilisateur qui supprime *
* \param langs Environnement langue de l'utilisateur * @param user Utilisateur qui supprime
* \param conf Environnement de configuration lors de l'operation * @param langs Environnement langue de l'utilisateur
* \return int < 0 si erreur, > 0 si ok * @param conf Environnement de configuration lors de l'operation
* @return int < 0 si erreur, > 0 si ok
*/ */
function delete($user,$langs='',$conf='') function delete($user,$langs='',$conf='')
{ {
@ -711,7 +717,7 @@ class Contrat extends CommonObject
$res = $this->delete_linked_contact(); $res = $this->delete_linked_contact();
if ($res < 0) if ($res < 0)
{ {
dol_syslog("Contract::delete error", LOG_ERR); dol_syslog(get_class($this)."::delete error", LOG_ERR);
$error++; $error++;
} }
} }
@ -728,7 +734,7 @@ class Contrat extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id;
dol_syslog("Contrat::delete contratdet_log sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::delete contratdet_log sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -749,7 +755,7 @@ class Contrat extends CommonObject
$sql= "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; $sql= "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log ";
$sql.= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",",$tab_resql).")"; $sql.= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",",$tab_resql).")";
dol_syslog("Contrat::delete contratdet_log sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::delete contratdet_log sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -765,7 +771,7 @@ class Contrat extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
$sql.= " WHERE fk_contrat=".$this->id; $sql.= " WHERE fk_contrat=".$this->id;
dol_syslog("Contrat::delete contratdet sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::delete contratdet sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -780,7 +786,7 @@ class Contrat extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
dol_syslog("Contrat::delete contrat sql=".$sql); dol_syslog(get_class($this)."::delete contrat sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -804,7 +810,7 @@ class Contrat extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Contrat::delete ERROR ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ERROR ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -812,27 +818,28 @@ class Contrat extends CommonObject
/** /**
* \brief Ajoute une ligne de contrat en base * Ajoute une ligne de contrat en base
* \param desc Description de la ligne *
* \param pu_ht Prix unitaire HT * @param desc Description de la ligne
* \param qty Quantite * @param pu_ht Prix unitaire HT
* \param txtva Taux tva * @param qty Quantite
* \param txlocaltax1 Local tax 1 rate * @param txtva Taux tva
* \param txlocaltax2 Local tax 2 rate * @param txlocaltax1 Local tax 1 rate
* \param fk_product Id produit * @param txlocaltax2 Local tax 2 rate
* \param remise_percent Pourcentage de remise de la ligne * @param fk_product Id produit
* \param date_start Date de debut prevue * @param remise_percent Pourcentage de remise de la ligne
* \param date_end Date de fin prevue * @param date_start Date de debut prevue
* \param price_base_type HT ou TTC * @param date_end Date de fin prevue
* \param pu_ttc Prix unitaire TTC * @param price_base_type HT ou TTC
* \param info_bits Bits de type de lignes * @param pu_ttc Prix unitaire TTC
* \return int <0 si erreur, >0 si ok * @param info_bits Bits de type de lignes
* @return int <0 si erreur, >0 si ok
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0)
{ {
global $user, $langs, $conf; global $user, $langs, $conf;
dol_syslog("Contrat::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits"); dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits");
if ($this->statut >= 0) if ($this->statut >= 0)
{ {
@ -903,7 +910,7 @@ class Contrat extends CommonObject
if ($date_end > 0) { $sql.= ",".$this->db->idate($date_end); } if ($date_end > 0) { $sql.= ",".$this->db->idate($date_end); }
$sql.= ")"; $sql.= ")";
dol_syslog("Contrat::addline sql=".$sql); dol_syslog(get_class($this)."::addline sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -925,36 +932,35 @@ class Contrat extends CommonObject
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->error()." sql=".$sql;
dol_syslog("Contrat::addline ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::addline ".$this->error,LOG_ERR);
return -1; return -1;
} }
} }
else else
{ {
dol_syslog("Contrat::addline ErrorTryToAddLineOnValidatedContract", LOG_ERR); dol_syslog(get_class($this)."::addline ErrorTryToAddLineOnValidatedContract", LOG_ERR);
return -2; return -2;
} }
} }
/** /**
* \brief Mets a jour une ligne de contrat * Mets a jour une ligne de contrat
* \param rowid Id de la ligne de facture *
* \param desc Description de la ligne * @param rowid Id de la ligne de facture
* \param pu Prix unitaire * @param desc Description de la ligne
* \param qty Quantite * @param pu Prix unitaire
* \param remise_percent Pourcentage de remise de la ligne * @param qty Quantite
* \param date_start Date de debut prevue * @param remise_percent Pourcentage de remise de la ligne
* \param date_end Date de fin prevue * @param date_start Date de debut prevue
* \param tvatx Taux TVA * @param date_end Date de fin prevue
* \param localtax1tx Local tax 1 rate * @param tvatx Taux TVA
* \param localtax2tx Local tax 2 rate * @param localtax1tx Local tax 1 rate
* \param date_debut_reel Date de debut reelle * @param localtax2tx Local tax 2 rate
* \param date_fin_reel Date de fin reelle * @param date_debut_reel Date de debut reelle
* \return int < 0 si erreur, > 0 si ok * @param date_fin_reel Date de fin reelle
* @return int < 0 si erreur, > 0 si ok
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start='', $date_end='', $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='')
$date_start='', $date_end='', $tvatx, $localtax1tx=0, $localtax2tx=0,
$date_debut_reel='', $date_fin_reel='')
{ {
global $user, $conf, $langs; global $user, $conf, $langs;
@ -978,7 +984,7 @@ class Contrat extends CommonObject
$remise_percent=0; $remise_percent=0;
} }
dol_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx"); dol_syslog(get_class($this)."::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx");
$this->db->begin(); $this->db->begin();
@ -1001,7 +1007,7 @@ class Contrat extends CommonObject
else { $sql.=",date_cloture=null"; } else { $sql.=",date_cloture=null"; }
$sql .= " WHERE rowid = ".$rowid; $sql .= " WHERE rowid = ".$rowid;
dol_syslog("Contrat::UpdateLine sql=".$sql); dol_syslog(get_class($this)."::UpdateLine sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -1014,7 +1020,7 @@ class Contrat extends CommonObject
else else
{ {
$this->db->rollback(); $this->db->rollback();
dol_syslog("Contrat::UpdateLigne Erreur -2"); dol_syslog(get_class($this)."::UpdateLigne Erreur -2");
return -2; return -2;
} }
} }
@ -1022,16 +1028,17 @@ class Contrat extends CommonObject
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Contrat::UpdateLigne Erreur -1"); dol_syslog(get_class($this)."::UpdateLigne Erreur -1");
return -1; return -1;
} }
} }
/** /**
* \brief Delete a contract line * Delete a contract line
* \param idline Id of line to delete *
* \param user User that delete * @param idline Id of line to delete
* \return int >0 if OK, <0 if KO * @param user User that delete
* @return int >0 if OK, <0 if KO
*/ */
function deleteline($idline,$user) function deleteline($idline,$user)
{ {
@ -1044,12 +1051,12 @@ class Contrat extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
$sql.= " WHERE rowid=".$idline; $sql.= " WHERE rowid=".$idline;
dol_syslog("Contratdet::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (! $resql)
{ {
$this->error="Error ".$this->db->lasterror(); $this->error="Error ".$this->db->lasterror();
dol_syslog("Contratdet::delete ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -1070,8 +1077,9 @@ class Contrat extends CommonObject
/** /**
* \brief Update statut of contract according to services * Update statut of contract according to services
* \return int <0 si ko, >0 si ok *
* @return int <0 if KO, >0 if OK
*/ */
function update_statut($user) function update_statut($user)
{ {
@ -1093,6 +1101,7 @@ class Contrat extends CommonObject
/** /**
* Return label of a contract status * Return label of a contract status
*
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services
* @return string Label * @return string Label
*/ */
@ -1103,6 +1112,7 @@ class Contrat extends CommonObject
/** /**
* Renvoi label of a given contrat status * Renvoi label of a given contrat status
*
* @param statut Status id * @param statut Status id
* @param mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services * @param mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services
* @return string Label * @return string Label
@ -1161,10 +1171,11 @@ class Contrat extends CommonObject
/** /**
* \brief Renvoie nom clicable (avec eventuellement le picto) * Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul *
* \param maxlength Max length of ref * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \return string Chaine avec URL * @param int $maxlength Max length of ref
* @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$maxlength=0) function getNomUrl($withpicto=0,$maxlength=0)
{ {
@ -1185,9 +1196,11 @@ class Contrat extends CommonObject
return $result; return $result;
} }
/* /**
* \brief Charge les informations d'ordre info dans l'objet contrat * Charge les informations d'ordre info dans l'objet contrat
* \param id id du contrat a charger *
* @param int $id id du contrat a charger
* @return void
*/ */
function info($id) function info($id)
{ {
@ -1233,9 +1246,10 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Return list of line rowid * Return list of line rowid
* \param statut Status of lines to get *
* \return array Array of line's rowid * @param statut Status of lines to get
* @return array Array of line's rowid
*/ */
function array_detail($statut=-1) function array_detail($statut=-1)
{ {
@ -1246,7 +1260,7 @@ class Contrat extends CommonObject
$sql.= " WHERE fk_contrat =".$this->id; $sql.= " WHERE fk_contrat =".$this->id;
if ($statut >= 0) $sql.= " AND statut = '$statut'"; if ($statut >= 0) $sql.= " AND statut = '$statut'";
dol_syslog("Contrat::array_detail() sql=".$sql,LOG_DEBUG); dol_syslog(get_class($this)."::array_detail() sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1268,9 +1282,10 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Return list of other contracts for same company than current contract * Return list of other contracts for same company than current contract
* \param option 'all' or 'others' *
* \return array Array of contracts id * @param option 'all' or 'others'
* @return array Array of contracts id
*/ */
function getListOfContracts($option='all') function getListOfContracts($option='all')
{ {
@ -1281,7 +1296,7 @@ class Contrat extends CommonObject
$sql.= " WHERE fk_soc =".$this->socid; $sql.= " WHERE fk_soc =".$this->socid;
if ($option == 'others') $sql.= " AND c.rowid != ".$this->id; if ($option == 'others') $sql.= " AND c.rowid != ".$this->id;
dol_syslog("Contrat::getOtherContracts() sql=".$sql,LOG_DEBUG); dol_syslog(get_class($this)."::getOtherContracts() sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1307,6 +1322,7 @@ class Contrat extends CommonObject
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param user Objet user * @param user Objet user
* @param mode "inactive" pour services a activer, "expired" pour services expires * @param mode "inactive" pour services a activer, "expired" pour services expires
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -1367,8 +1383,9 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Charge indicateurs this->nb de tableau de bord * Charge indicateurs this->nb de tableau de bord
* \return int <0 si ko, >0 si ok *
* @return int <0 si ko, >0 si ok
*/ */
function load_state_board() function load_state_board()
{ {
@ -1409,8 +1426,9 @@ class Contrat extends CommonObject
/* gestion des contacts d'un contrat */ /* gestion des contacts d'un contrat */
/** /**
* \brief Retourne id des contacts clients de facturation * Return id des contacts clients de facturation
* \return array Liste des id contacts facturation *
* @return array Liste des id contacts facturation
*/ */
function getIdBillingContact() function getIdBillingContact()
{ {
@ -1418,8 +1436,9 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Retourne id des contacts clients de prestation * Return id des contacts clients de prestation
* \return array Liste des id contacts prestation *
* @return array Liste des id contacts prestation
*/ */
function getIdServiceContact() function getIdServiceContact()
{ {
@ -1551,16 +1570,18 @@ class ContratLigne
/** /**
* Constructeur d'objets ligne de contrat * Constructeur d'objets ligne de contrat
* @param DB Database access handler *
* @param DoliDB $db Database access handler
*/ */
function ContratLigne($DB) function ContratLigne($db)
{ {
$this->db = $DB; $this->db = $db;
} }
/** /**
* Return label of this contract line status * Return label of this contract line status
*
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle * @return string Libelle
*/ */
@ -1571,6 +1592,7 @@ class ContratLigne
/** /**
* Return label of a contract line status * Return label of a contract line status
*
* @param statut id statut * @param statut id statut
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param expired 0=Not expired, 1=Expired, -1=Both or unknown * @param expired 0=Not expired, 1=Expired, -1=Both or unknown
@ -1632,6 +1654,7 @@ class ContratLigne
/** /**
* Renvoie nom clicable (avec eventuellement le picto) * Renvoie nom clicable (avec eventuellement le picto)
*
* @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
@ -1656,6 +1679,7 @@ class ContratLigne
/** /**
* Load object in memory from database * Load object in memory from database
*
* @param id id object * @param id id object
* @param ref Ref of contract * @param ref Ref of contract
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -1704,7 +1728,7 @@ class ContratLigne
if ($id) $sql.= " WHERE t.rowid = ".$id; if ($id) $sql.= " WHERE t.rowid = ".$id;
if ($ref) $sql.= " WHERE t.rowid = '".$ref."'"; if ($ref) $sql.= " WHERE t.rowid = '".$ref."'";
dol_syslog("Contratdet::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1754,7 +1778,7 @@ class ContratLigne
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error="Error ".$this->db->lasterror();
dol_syslog("ContratLigne::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -1762,8 +1786,9 @@ class ContratLigne
/** /**
* Update database for contract line * Update database for contract line
* @param user User that modify *
* @param notrigger 0=no, 1=yes (no update trigger) * @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user, $notrigger=0) function update($user, $notrigger=0)
@ -1866,6 +1891,7 @@ class ContratLigne
/** /**
* Mise a jour en base des champs total_xxx de ligne * Mise a jour en base des champs total_xxx de ligne
* Used by migration process * Used by migration process
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_total() function update_total()

View File

@ -167,9 +167,10 @@ $bc[true]=' class="bg2"';
/** /**
* \brief Load conf file (file must exists) * Load conf file (file must exists)
* \param dolibarr_main_document_root Root directory of Dolibarr bin files *
* \return int <0 if KO, >0 if OK * @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/ */
function conf($dolibarr_main_document_root) function conf($dolibarr_main_document_root)
{ {
@ -240,10 +241,11 @@ function pHeader($soutitre,$next,$action='none')
} }
/** /**
* Enter description here... * Show footer
* *
* @param $nonext * @param string $nonext No button "Next step"
* @param $setuplang * @param string $setuplang Language code
* @return void
*/ */
function pFooter($nonext=0,$setuplang='') function pFooter($nonext=0,$setuplang='')
{ {
@ -258,8 +260,8 @@ function pFooter($nonext=0,$setuplang='')
/** /**
* Output a text into a log file * Output a text into a log file
* *
* @param $message * @param string $message Message to show
* @param $level * @param string $level Log level
*/ */
function dolibarr_support_syslog($message, $level=LOG_DEBUG) function dolibarr_support_syslog($message, $level=LOG_DEBUG)
{ {

View File

@ -28,7 +28,7 @@ error_reporting(0);
// and no database access to do. // and no database access to do.
include_once("./inc.php"); include_once("./inc.php");
$uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root);
$pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine $pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
define('DOL_URL_ROOT', $pos); // URL racine relative define('DOL_URL_ROOT', $pos); // URL racine relative

View File

@ -25,7 +25,7 @@ error_reporting(0);
include_once("./inc.php"); include_once("./inc.php");
$uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root);
$pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine $pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
define('DOL_URL_ROOT', $pos); // URL racine relative define('DOL_URL_ROOT', $pos); // URL racine relative

View File

@ -100,26 +100,26 @@ print '<br><br>';
// WSDL // WSDL
print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>'; print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php?wsdl'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php?wsdl'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php?wsdl'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php?wsdl'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->fournisseur->enabled) if ($conf->fournisseur->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php?wsdl'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
print '<br>'; print '<br>';
@ -127,26 +127,26 @@ print '<br>';
// Endpoint // Endpoint
print '<u>'.$langs->trans("EndPointIs").':</u><br>'; print '<u>'.$langs->trans("EndPointIs").':</u><br>';
$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
if ($conf->fournisseur->enabled) if ($conf->fournisseur->enabled)
{ {
$url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_supplier_invoice.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
} }
print '<br>'; print '<br>';

View File

@ -244,9 +244,12 @@ $server->register(
/** /**
* Get invoice from id, ref or ref_ext * Get invoice from id, ref or ref_ext.
* *
* @param array $authentication Array of authentication information * @param array $authentication Array of authentication information
* @param int $id Id
* @param string $ref Ref
* @param string $ref_ext Ref_ext
* @return array Array result * @return array Array result
*/ */
function getInvoice($authentication,$id='',$ref='',$ref_ext='') function getInvoice($authentication,$id='',$ref='',$ref_ext='')
@ -354,6 +357,7 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
* Get list of invoices for third party * Get list of invoices for third party
* *
* @param array $authentication Array of authentication information * @param array $authentication Array of authentication information
* @param int $idthirdparty Id thirdparty
* @return array Array result * @return array Array result
*/ */
function getInvoicesForThirdParty($authentication,$idthirdparty) function getInvoicesForThirdParty($authentication,$idthirdparty)

View File

@ -92,16 +92,17 @@ $styleuse='encoded'; // encoded/literal/literal wrapped
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap. // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
// Register WSDL // Register WSDL
$server->register('getVersions', $server->register(
// Entry values 'getVersions',
array('authentication'=>'tns:authentication'), // Entry values
// Exit values array('authentication'=>'tns:authentication'),
array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'), // Exit values
$ns, array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
$ns.'#getVersions', $ns,
$styledoc, $ns.'#getVersions',
$styleuse, $styledoc,
'WS to get Versions' $styleuse,
'WS to get Versions'
); );

View File

@ -215,6 +215,12 @@ $server->register(
/** /**
* Get invoice from id, ref or ref_ext * Get invoice from id, ref or ref_ext
*
* @param array $authentication Array of authentication information
* @param int $id Id
* @param string $ref Ref
* @param string $ref_ext Ref_ext
* @return array Array result
*/ */
function getSupplierInvoice($authentication,$id='',$ref='',$ref_ext='') function getSupplierInvoice($authentication,$id='',$ref='',$ref_ext='')
{ {
@ -320,6 +326,11 @@ function getSupplierInvoice($authentication,$id='',$ref='',$ref_ext='')
/** /**
* Get list of invoices for third party * Get list of invoices for third party
*
* @param array $authentication Array of authentication information
* @param int $idthirdparty Id thirdparty
* @return array Array result
*
*/ */
function getSupplierInvoicesForThirdParty($authentication,$idthirdparty) function getSupplierInvoicesForThirdParty($authentication,$idthirdparty)
{ {

View File

@ -88,33 +88,33 @@ $server->wsdl->addComplexType(
'all', 'all',
'', '',
array( array(
'element' => array('name'=>'element','type'=>'xsd:string'), 'element' => array('name'=>'element','type'=>'xsd:string'),
'id' => array('name'=>'id','type'=>'xsd:string'), 'id' => array('name'=>'id','type'=>'xsd:string'),
'lastname' => array('name'=>'lastname','type'=>'xsd:string'), 'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
'firstname' => array('name'=>'firstname','type'=>'xsd:string'), 'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
'note' => array('name'=>'note','type'=>'xsd:string'), 'note' => array('name'=>'note','type'=>'xsd:string'),
'email' => array('name'=>'email','type'=>'xsd:string'), 'email' => array('name'=>'email','type'=>'xsd:string'),
'signature' => array('name'=>'signature','type'=>'xsd:string'), 'signature' => array('name'=>'signature','type'=>'xsd:string'),
'office_phone' => array('name'=>'office_phone','type'=>'xsd:string'), 'office_phone' => array('name'=>'office_phone','type'=>'xsd:string'),
'office_fax' => array('name'=>'office_fax','type'=>'xsd:string'), 'office_fax' => array('name'=>'office_fax','type'=>'xsd:string'),
'user_mobile' => array('name'=>'user_mobile','type'=>'xsd:string'), 'user_mobile' => array('name'=>'user_mobile','type'=>'xsd:string'),
'admin' => array('name'=>'admin','type'=>'xsd:string'), 'admin' => array('name'=>'admin','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'), 'login' => array('name'=>'login','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'), 'entity' => array('name'=>'entity','type'=>'xsd:string'),
'pass_indatabase' => array('name'=>'pass_indatabase','type'=>'xsd:string'), 'pass_indatabase' => array('name'=>'pass_indatabase','type'=>'xsd:string'),
'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted','type'=>'xsd:string'), 'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted','type'=>'xsd:string'),
'datec' => array('name'=>'datec','type'=>'xsd:dateTime'), 'datec' => array('name'=>'datec','type'=>'xsd:dateTime'),
'datem' => array('name'=>'datem','type'=>'xsd:dateTime'), 'datem' => array('name'=>'datem','type'=>'xsd:dateTime'),
'societe_id' => array('name'=>'societe_id','type'=>'xsd:string'), 'societe_id' => array('name'=>'societe_id','type'=>'xsd:string'),
'fk_member' => array('name'=>'fk_member','type'=>'xsd:string'), 'fk_member' => array('name'=>'fk_member','type'=>'xsd:string'),
'datelastlogin' => array('name'=>'datelastlogin','type'=>'xsd:dateTime'), 'datelastlogin' => array('name'=>'datelastlogin','type'=>'xsd:dateTime'),
'datepreviouslogin' => array('name'=>'datepreviouslogin','type'=>'xsd:dateTime'), 'datepreviouslogin' => array('name'=>'datepreviouslogin','type'=>'xsd:dateTime'),
'statut' => array('name'=>'statut','type'=>'xsd:string'), 'statut' => array('name'=>'statut','type'=>'xsd:string'),
'photo' => array('name'=>'photo','type'=>'xsd:string'), 'photo' => array('name'=>'photo','type'=>'xsd:string'),
'lang' => array('name'=>'lang','type'=>'xsd:string'), 'lang' => array('name'=>'lang','type'=>'xsd:string'),
'entrepots' => array('name'=>'entrepots','type'=>'xsd:string'), 'entrepots' => array('name'=>'entrepots','type'=>'xsd:string'),
//'rights' => array('name'=>'rights','type'=>'xsd:string'), //'rights' => array('name'=>'rights','type'=>'xsd:string'),
'canvas' => array('name'=>'canvas','type'=>'xsd:string') 'canvas' => array('name'=>'canvas','type'=>'xsd:string')
) )
); );