50 |
var $date_creation; |
var $date_creation; |
51 |
var $date_validation; |
var $date_validation; |
52 |
var $date_cloture; |
var $date_cloture; |
|
|
|
53 |
var $commercial_signature_id; |
var $commercial_signature_id; |
54 |
var $commercial_suivi_id; |
var $commercial_suivi_id; |
55 |
|
|
224 |
*/ |
*/ |
225 |
function fetch($id) |
function fetch($id) |
226 |
{ |
{ |
227 |
$sql = "SELECT rowid, statut, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise,"; |
$sql = "SELECT rowid, statut, ref, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise,"; |
228 |
$sql.= " fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat,"; |
$sql.= " fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat,"; |
229 |
$sql.= " fk_user_author,"; |
$sql.= " fk_user_author,"; |
230 |
$sql.= " fk_projet,"; |
$sql.= " fk_projet,"; |
240 |
if ($result) |
if ($result) |
241 |
{ |
{ |
242 |
$this->id = $result["rowid"]; |
$this->id = $result["rowid"]; |
243 |
$this->ref = $result["rowid"]; |
$this->ref = (!isset($result["ref"])) ? $result["rowid"] : $result["ref"]; |
244 |
$this->statut = $result["statut"]; |
$this->statut = $result["statut"]; |
245 |
$this->factureid = $result["fk_facture"]; |
$this->factureid = $result["fk_facture"]; |
246 |
$this->facturedetid = $result["fk_facturedet"]; |
$this->facturedetid = $result["fk_facturedet"]; |
421 |
// Insère contrat |
// Insère contrat |
422 |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat"; |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat"; |
423 |
// $sql.= ", fk_commercial_signature, fk_commercial_suivi"; |
// $sql.= ", fk_commercial_signature, fk_commercial_suivi"; |
424 |
$sql.= ")"; |
$sql.= " , ref)"; |
425 |
$sql.= " VALUES (now(),".$this->soc_id.",".$user->id; |
$sql.= " VALUES (now(),".$this->soc_id.",".$user->id; |
426 |
$sql.= ",".$this->db->idate($this->date_contrat); |
$sql.= ",".$this->db->idate($this->date_contrat); |
427 |
// $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null"); |
// $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null"); |
428 |
// $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null"); |
// $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null"); |
429 |
|
$sql .= ", " . (strlen($this->ref)<=0 ? "null" : "'".$this->ref."'"); |
430 |
$sql.= ")"; |
$sql.= ")"; |
431 |
$resql=$this->db->query($sql); |
$resql=$this->db->query($sql); |
432 |
if ($resql) |
if ($resql) |
811 |
*/ |
*/ |
812 |
function info($id) |
function info($id) |
813 |
{ |
{ |
814 |
$sql = "SELECT c.rowid, ".$this->db->pdate("datec")." as datec, ".$this->db->pdate("date_cloture")." as date_cloture,"; |
$sql = "SELECT c.rowid, c.ref, ".$this->db->pdate("datec")." as datec, ".$this->db->pdate("date_cloture")." as date_cloture,"; |
815 |
$sql.= $this->db->pdate("c.tms")." as date_modification,"; |
$sql.= $this->db->pdate("c.tms")." as date_modification,"; |
816 |
$sql.= " fk_user_author, fk_user_cloture"; |
$sql.= " fk_user_author, fk_user_cloture"; |
817 |
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; |
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; |
837 |
$cuser->fetch(); |
$cuser->fetch(); |
838 |
$this->user_cloture = $cuser; |
$this->user_cloture = $cuser; |
839 |
} |
} |
840 |
|
$this->ref = $obj->ref; |
841 |
$this->date_creation = $obj->datec; |
$this->date_creation = $obj->datec; |
842 |
$this->date_modification = $obj->date_modification; |
$this->date_modification = $obj->date_modification; |
843 |
$this->date_cloture = $obj->date_cloture; |
$this->date_cloture = $obj->date_cloture; |
870 |
$resql=$this->db->query($sql); |
$resql=$this->db->query($sql); |
871 |
if ($resql) |
if ($resql) |
872 |
{ |
{ |
873 |
$num=$this->db->num_rows($result); |
$num=$this->db->num_rows($resql); |
874 |
$i=0; |
$i=0; |
875 |
while ($i < $num) |
while ($i < $num) |
876 |
{ |
{ |
877 |
$obj = $this->db->fetch_object($result); |
$obj = $this->db->fetch_object($resql); |
878 |
$tab[$i]=$obj->rowid; |
$tab[$i]=$obj->rowid; |
879 |
$i++; |
$i++; |
880 |
} |
} |
957 |
$sql.="SELECT rowid from ".MAIN_DB_PREFIX."c_type_contact"; |
$sql.="SELECT rowid from ".MAIN_DB_PREFIX."c_type_contact"; |
958 |
$sql.=" WHERE element='contrat' AND source='internal'"; |
$sql.=" WHERE element='contrat' AND source='internal'"; |
959 |
$sql.=" AND code='".$type_contact."'"; |
$sql.=" AND code='".$type_contact."'"; |
960 |
if ( $this->db->query($sql) ) |
$resql = $this->db->query($sql); |
961 |
|
if ( $resql ) |
962 |
{ |
{ |
963 |
$obj = $this->db->fetch_object($resql); |
$obj = $this->db->fetch_object($resql); |
964 |
if ($obj) $type_contact=$obj->rowid; |
if ($obj) $type_contact=$obj->rowid; |
1004 |
/** |
/** |
1005 |
* |
* |
1006 |
* \brief Misea jour du contact associé au contrat |
* \brief Misea jour du contact associé au contrat |
1007 |
* \param rowid La reference du lien contant contact. |
* \param rowid La reference du lien contrat-contact |
1008 |
* \param statut Le nouveau statut |
* \param statut Le nouveau statut |
1009 |
* \param nature Description du contact |
* \param nature Description du contact |
1010 |
* \return int <0 si erreur, >0 si ok |
* \return int <0 si erreur, >0 si ok |
1124 |
$resql=$this->db->query($sql); |
$resql=$this->db->query($sql); |
1125 |
if ($resql) |
if ($resql) |
1126 |
{ |
{ |
1127 |
$obj = $this->db->fetch_object($result); |
$obj = $this->db->fetch_object($resql); |
1128 |
return $obj; |
return $obj; |
1129 |
} |
} |
1130 |
else |
else |
1157 |
$resql=$this->db->query($sql); |
$resql=$this->db->query($sql); |
1158 |
if ($resql) |
if ($resql) |
1159 |
{ |
{ |
1160 |
$num=$this->db->num_rows($result); |
$num=$this->db->num_rows($resql); |
1161 |
$i=0; |
$i=0; |
1162 |
while ($i < $num) |
while ($i < $num) |
1163 |
{ |
{ |
1164 |
$obj = $this->db->fetch_object($result); |
$obj = $this->db->fetch_object($resql); |
1165 |
|
|
1166 |
$transkey="TypeContact_".$element."_".$source."_".$obj->code; |
$transkey="TypeContact_".$element."_".$source."_".$obj->code; |
1167 |
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |