From 4da392a3cf7568f426895c5f51dedf563ae118c9 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 19 Mar 2014 07:26:31 +0000 Subject: [PATCH] issue #0001704 : Enregistrement des contacts (au SIRET) --- application/controllers/SaisieController.php | 74 +++++++++++++------ .../default/scripts/saisie/contact.phtml | 33 ++++++++- library/Scores/WsScores.php | 24 ++---- 3 files changed, 90 insertions(+), 41 deletions(-) diff --git a/application/controllers/SaisieController.php b/application/controllers/SaisieController.php index 6dbe0a0bf..a5537329b 100644 --- a/application/controllers/SaisieController.php +++ b/application/controllers/SaisieController.php @@ -47,7 +47,7 @@ class SaisieController extends Zend_Controller_Action array( "triId"=>"1790", "triCode"=>"CAYENL", "triNom"=>"Chambre Détachée de la Cour d'Appel de Fort de France à Cayenne", "triCP"=>"97300" ), array( "triId"=>"1798", "triCode"=>"AGENL", "triNom"=>"Cour d'Appel d'Agen", "triCP"=>"47916" ), ); - + protected $codVoie = array( 'ABE' => "Abbaye", 'AGL' => "Agglomération", @@ -2337,20 +2337,20 @@ class SaisieController extends Zend_Controller_Action } } - + public function liendeleteAction() { $this->_helper->layout()->disableLayout(); - + $request = $this->getRequest(); $id = $request->getParam('idFiche', null); $infos = array ('delete' => '1'); - + $ws = new WsScores(); - + if ($id===null) { $siren = $request->getParam('siren'); - + $result = $ws->searchLienRef($siren, 'siren'); if (count($result->item)>0) { foreach ($result->item as $item) { @@ -2359,7 +2359,7 @@ class SaisieController extends Zend_Controller_Action } } } - + if ( $request->isPost() ) { if ($id == null) { $message = 'Fiche n\'est pas trouvée'; @@ -2485,11 +2485,11 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('output', $output); } - + public function codvoieAction() { $this->_helper->layout()->disableLayout(); - + $codvoie = $this->getRequest()->getParam('codvoie', null); $output = array(); @@ -2644,13 +2644,22 @@ class SaisieController extends Zend_Controller_Action $message = ''; $mode = $request->getParam('mode'); - if( in_array($mode, array('create', 'edit')) ) { + if( $mode == 'delete' ) { + + $ws = new WsScores(); + $result = $ws->setSaisieContactEt('', '', '', '', $id, true); + if ( is_string($result) ) { + $this->view->assign('msg', $result); + } + + } else { + $params = $request->getParams(); // check values $paramlist = array( - 'siret' => 'SIRET', - 'type' => 'Type', - 'value' => 'Valeur', + 'siret' => 'SIRET', + 'type' => 'Type', + 'value' => 'Valeur', ); foreach ($paramlist as $item => $val) { @@ -2663,7 +2672,7 @@ class SaisieController extends Zend_Controller_Action if ($message == '') { //setContactEt $ws = new WsScores(); - $result = $ws->setSaisieContactEt($siret, $type, $value, $info); + $result = $ws->setSaisieContactEt($params['siret'], $params['type'], $params['value'], $params['info']); if ( is_string($result) ) { $this->view->assign('msg', $result); @@ -2673,19 +2682,13 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('msg', $message); } - } else { - - $ws = new WsScores(); - $result = $ws->delSaisieContactEt($id); - if ( is_string($result) ) { - $this->view->assign('msg', $result); - } - } } else { $mode = $request->getParam('mode'); + $this->view->assign('mode', $mode); + $id = $request->getParam('id'); if ($mode=='delete') { @@ -2698,7 +2701,6 @@ class SaisieController extends Zend_Controller_Action $ws = new WsScores(); $result = $ws->getSaisieContactEt($id); $data = json_decode($result); - Zend_Registry::get('firebug')->info($data); $this->view->assign('id', $data->id); $this->view->assign('siret', str_pad($data->siren,9,'0',STR_PAD_LEFT).str_pad($data->nic,5,'0',STR_PAD_LEFT)); $this->view->assign('type', $data->typeTel); @@ -2708,6 +2710,32 @@ class SaisieController extends Zend_Controller_Action } else { $this->view->assign('value', $data->infoTel); } + $tabChange = array(); + if ( $data->idUtilisateur != 0 ) { + $change = new stdClass(); + $change->UserId = $data->idUtilisateur; + $change->UserName = $data->idUtilisateurName; + $change->Date = $data->dateInsert; + $change->Type = 'add'; + $tabChange[] = $change; + } + if ( $data->idUpdate != 0 ) { + $change = new stdClass(); + $change->UserId = $data->idUpdate; + $change->UserName = $data->idUpdateName; + $change->Date = $data->dateUpdate; + $change->Type = 'edit'; + $tabChange[] = $change; + } + if ( $data->idSuppr != 0 ) { + $change = new stdClass(); + $change->UserId = $data->idSuppr; + $change->UserName = $data->idSupprName; + $change->Date = $data->dateSuppr; + $change->Type = 'del'; + $tabChange[] = $change; + } + $this->view->Modif = $tabChange; } else { $siret = $request->getParam('siret'); diff --git a/application/views/default/scripts/saisie/contact.phtml b/application/views/default/scripts/saisie/contact.phtml index 9c15de113..ddb41e3a1 100644 --- a/application/views/default/scripts/saisie/contact.phtml +++ b/application/views/default/scripts/saisie/contact.phtml @@ -24,7 +24,38 @@ +Modif)>0 ) {?> +Modif as $item ) {?> +

+ type) { + case 'add': + $date = new Zend_Date($item->dateInsert, 'yyyy-MM-dd'); + ?> + Création le toString('dd/MM/yyyy')?> par idUtilisateurName?>. + dateUpdate, 'yyyy-MM-dd'); + ?> + Modification le toString('dd/MM/yyyy')?> par idUpdateName?>. + dateSuppr, 'yyyy-MM-dd'); + ?> + Suppression le toString('dd/MM/yyyy')?> par idSupprName?>. + +

+ + +
+ + id) {?> @@ -40,7 +71,7 @@
- +

Téléphone france saisit sans séparateur, maximum 10 chiffres (format: XXXXXXXXXX) diff --git a/library/Scores/WsScores.php b/library/Scores/WsScores.php index f57c69bbb..9e78ee8ed 100644 --- a/library/Scores/WsScores.php +++ b/library/Scores/WsScores.php @@ -120,28 +120,18 @@ class WsScores } } - public function delSaisieContactEt($id) + public function setSaisieContactEt($siret, $type, $value, $info, $id=null, $delete=false) { $params = new stdClass(); $params->id = $id; + $params->siret = $siret; + $params->type = $type; + $params->value = $value; + $params->info = $info; $client = $this->loadClient('saisie'); try { - $reponse = $client->delContactEt($params); - return $reponse->delContactEtResult; - } catch (SoapFault $fault) { - Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring); - return $fault->faultstring; - } - } - - public function setSaisieContactEt($siret, $type, $value, $info, $id=null) - { - $params = new stdClass(); - $params->id = $id; - $client = $this->loadClient('saisie'); - try { - $reponse = $client->getContactEt($params); - return $reponse->getContactEtResult; + $reponse = $client->setContactEt($params); + return $reponse->setContactEtResult; } catch (SoapFault $fault) { Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring); return $fault->faultstring;