From 2a2ace9fc56e152df3a806f468e6eae3d843522f Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 20 Mar 2014 16:40:32 +0000 Subject: [PATCH] issue #0001704 : Suppression et Modification --- application/controllers/SaisieController.php | 79 ++++++++++--------- .../default/scripts/identite/contacts.phtml | 4 +- .../default/scripts/saisie/contact.phtml | 5 +- library/Scores/WsScores.php | 5 +- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/application/controllers/SaisieController.php b/application/controllers/SaisieController.php index 18854d5be..745a7f315 100644 --- a/application/controllers/SaisieController.php +++ b/application/controllers/SaisieController.php @@ -2505,14 +2505,14 @@ class SaisieController extends Zend_Controller_Action } $this->view->assign('output', $output); } - + /** * Ajouter, modifier ou supprimer des dirigeants oppérationnels */ public function diropcontrolAction() { $this->_helper->layout()->disableLayout(); - + $request = $this->getRequest(); $mode = $request->getParam('mode'); $type = $request->getParam('type', 'lien'); @@ -2529,7 +2529,7 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('fonction', json_decode($fonction)); break; - + case 'edit': $fonction = $ws->getCatalogFctDir(); $infos = $ws->getDirigeantsOp($siren, $id); @@ -2549,23 +2549,23 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('siren', $siren); $this->view->assign('nic', $nic); } - + /** * Sauvegarder les modifications des dirigeants oppérationnels */ public function diropsaveAction() { $this->_helper->layout()->disableLayout(); - + $params = $this->getRequest()->getParams(); $message = ''; - + $newDate = '0000-00-00'; if (trim($params['naiss_date']) != '') { $date = new Zend_Date($params['naiss_date'], 'dd/MM/yyyy'); $newDate = $date->toString('yyyy-MM-dd'); } - + $infos = array( 'siren' => $params['siren'], 'nic' => $params['nic'], @@ -2580,7 +2580,7 @@ class SaisieController extends Zend_Controller_Action 'fax' => $params['fax'], 'email' => $params['email'] ); - + $ws = new WsScores(); $result = $ws->setDirigeantsOp(json_encode($infos), $params['mode'], $params['type'], $params['id']); @@ -2593,7 +2593,7 @@ class SaisieController extends Zend_Controller_Action } else if ($params['mode'] == 'del') { $message = $this->view->translate('Suppression'); } - + if (intval($result)!=0) { $message = $message.' '.$this->view->translate('a été réussi!'); } else { @@ -2605,13 +2605,13 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('message', $message); } - + public function diropsearchAction() { $this->_helper->layout()->disableLayout(); - + $query = $this->getRequest()->getParam('query', null); - + $param = array('query'=>$query); $output = array(); @@ -2629,35 +2629,39 @@ class SaisieController extends Zend_Controller_Action } } } - + $this->view->assign('output', $output); } - /** +/** * Edit contact information */ public function contactAction() { $request = $this->getRequest(); if ( $request->isXmlHttpRequest() ) { - $this->_helper->layout()->disableLayout(); + $this->_helper->layout()->disableLayout(); + + $id = $request->getParam('id'); + $this->view->assign('id', $id); + if ( $request->isPost() ) { $this->view->assign('post', true); + $params = $request->getParams(); $message = ''; $mode = $request->getParam('mode'); if( $mode == 'delete' ) { $ws = new WsScores(); - $result = $ws->setSaisieContactEt('', '', '', '', $id, true); + $result = $ws->setSaisieContactEt($params['siret'], '', '', '', $id, true); if ( is_string($result) ) { $this->view->assign('msg', $result); } } else { - $params = $request->getParams(); // check values $paramlist = array( 'siret' => 'SIRET', @@ -2692,9 +2696,10 @@ class SaisieController extends Zend_Controller_Action $mode = $request->getParam('mode'); $this->view->assign('mode', $mode); - $id = $request->getParam('id'); + $siret = $request->getParam('siret'); + $this->view->assign('siret', $siret); - if ($mode=='delete') { + if ( $mode=='delete' ) { $this->view->assign('mode', 'delete'); @@ -2703,46 +2708,44 @@ class SaisieController extends Zend_Controller_Action if ( $id !== null ) { $ws = new WsScores(); $result = $ws->getSaisieContactEt($id); - $data = json_decode($result); - $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); - if ($data->typeTel=='tel' || $data->typeTel=='fax' ) { - $this->view->assign('value', str_pad($data->telephone,10,'0',STR_PAD_LEFT)); - $this->view->assign('info', $data->infoTel); + $data = json_decode($result, true); + 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']); + if ($data['typeTel']=='tel' || $data['typeTel']=='fax' ) { + $this->view->assign('value', str_pad($data['telephone'],10,'0',STR_PAD_LEFT)); + $this->view->assign('info', $data['infoTel']); } 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->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->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->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'); - $this->view->assign('siret', $siret); } $this->view->telinfo = array( diff --git a/application/views/default/scripts/identite/contacts.phtml b/application/views/default/scripts/identite/contacts.phtml index ead65a259..8ac14d56b 100644 --- a/application/views/default/scripts/identite/contacts.phtml +++ b/application/views/default/scripts/identite/contacts.phtml @@ -114,8 +114,8 @@ if ($item->deleted) { edition ) {?>
- - + +
diff --git a/application/views/default/scripts/saisie/contact.phtml b/application/views/default/scripts/saisie/contact.phtml index ddb41e3a1..cc09eec72 100644 --- a/application/views/default/scripts/saisie/contact.phtml +++ b/application/views/default/scripts/saisie/contact.phtml @@ -7,8 +7,9 @@ @@ -19,7 +20,9 @@

Supprimer l'élément id=id?> ?

+ +
diff --git a/library/Scores/WsScores.php b/library/Scores/WsScores.php index 798c1b63b..830fb36e1 100644 --- a/library/Scores/WsScores.php +++ b/library/Scores/WsScores.php @@ -128,6 +128,7 @@ class WsScores $params->type = $type; $params->value = $value; $params->info = $info; + $params->delete = $delete; $client = $this->loadClient('saisie'); try { $reponse = $client->setContactEt($params); @@ -2568,7 +2569,7 @@ class WsScores return false; } } - + /** * setDirigeantsOp * @param array $infos @@ -2594,7 +2595,7 @@ class WsScores } } } - + /** * searchDirigeantsOp * @param string $query