diff --git a/library/Metier/Credit/Contact.php b/library/Metier/Credit/Contact.php index 71e22439..cbeb2876 100644 --- a/library/Metier/Credit/Contact.php +++ b/library/Metier/Credit/Contact.php @@ -1,9 +1,4 @@ 'En attente de reponse', + '2' => 'En cours de traitement', + '3' => 'Resolu' + ); + + /** + * Libelle des champs de valeur + * @var array + */ + private $libelles=array( + 'id' => 'Reference enregistrement', + 'idUSer' => 'Reference utilisateur', + 'begin' => 'Message du', + 'subject' => 'Categorie', + 'message' => 'Message envoyé', + 'stage' => 'Etape', + 'answer' => 'Suivi' + ); + public function __construct($db = null) { // Set Database @@ -25,6 +61,15 @@ class Metier_Credit_Contact extends Scores_Ws_Server $this->logger = Zend_Registry::get('logger'); } } + + /** + * Libelles correspondants aux id + * @return array + */ + public function getLibelles() + { + return array('libelles' => $this->libelles, 'stages' => $this->stages,'subjects' => $this->subjects); + } public function saveFirstContact($data){ try{ $res=$this->conn->insert('sdv1.credit__contact',$data); @@ -37,8 +82,10 @@ class Metier_Credit_Contact extends Scores_Ws_Server return true; } public function getlisteContacts($idUser){ - $sql='select * from sdv1.credit__contact where idUSer=:idUser - and (stage<3 or (stage=3 and begin>"'.Date('Y-m-d',time()-300*24*3600).'")) order by id desc;'; + $sql='select c.*, u.email, u.login,u.nom, u.prenom + from sdv1.credit__contact c inner join sdv1.utilisateurs u on c.idUSer=u.id + where c.idUSer=:idUser + and (stage<3 or (stage=3 and begin>"'.Date('Y-m-d',time()-300*24*3600).'")) order by c.stage asc,c.id desc;'; $stmt = $this->conn->prepare($sql); $stmt->bindValue('idUser', $idUser); $stmt->execute(); diff --git a/library/Metier/Credit/Information.php b/library/Metier/Credit/Information.php index bf1b42f5..9a028da0 100644 --- a/library/Metier/Credit/Information.php +++ b/library/Metier/Credit/Information.php @@ -80,12 +80,20 @@ class Metier_Credit_Information extends Scores_Ws_Server * Recuperation des informations necessaires a la facturation * @param int $id */ - public function getInfosFacture($id){ - $sql='select c.*, u.idClient, u.siret, u.email,u.nom,u.prenom - from sdv1.credit__paid c inner join sdv1.utilisateurs u on c.idUser=u.id - where c.id= :id;'; - $stmt = $this->conn->prepare($sql); - $stmt->bindValue('id', $id); + public function getInfosFacture($id,$user){ + if(intval($id)>0){ + $sql='select c.*, u.idClient, u.siret, u.email,u.nom,u.prenom + from sdv1.credit__paid c inner join sdv1.utilisateurs u on c.idUser=u.id + where c.id= :id;'; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('id', $id); + }else{ + $sql='select u.idClient, u.siret, u.email,u.nom,u.prenom + from sdv1.utilisateurs u + where u.id= :id;'; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('id', $user->id); + } $stmt->execute(); if ($stmt->rowCount() == 1) { $infos['commande']=$stmt->fetch(PDO::FETCH_ASSOC); @@ -106,7 +114,8 @@ class Metier_Credit_Information extends Scores_Ws_Server $this->logger->error($e->getMessage()); } } - + $iInsee = new Metier_Insee_MInsee(); + $infos['entrep']= $iInsee->getIdentiteEntreprise($siren, $nic, 0, false); return $infos; } public function getHistoUser($user,$nbligpaid=20,$nbligused=50){ diff --git a/library/WsScore/Credit/v0.1/Service.php b/library/WsScore/Credit/v0.1/Service.php index 981765fb..d4966c16 100644 --- a/library/WsScore/Credit/v0.1/Service.php +++ b/library/WsScore/Credit/v0.1/Service.php @@ -91,6 +91,7 @@ class Credit extends Scores_Ws_Server $PayCreditResult->result=false; return $PayCreditResult; } + $sql = "SELECT transaction FROM sdv1.credit__paid c WHERE c.idCmd=:idCmd"; $stmt = $this->conn->prepare($sql); @@ -216,7 +217,7 @@ class Credit extends Scores_Ws_Server $GetfactinfosCreditResult=new GetfactinfosCredit(); $GetfactinfosCreditResult->id=$id; $crdt=new Metier_Credit_Information(); - $GetfactinfosCreditResult->result=$crdt->getInfosFacture($id); + $GetfactinfosCreditResult->result=$crdt->getInfosFacture($id,$this->User); return $GetfactinfosCreditResult; }