issue #0001704 : Gestion des contacts, add and edit

This commit is contained in:
Michael RICOIS 2013-12-05 21:40:29 +00:00
parent 2e2a38f57f
commit 065c72dcd0
5 changed files with 365 additions and 5 deletions

View File

@ -1386,6 +1386,9 @@ class IdentiteController extends Zend_Controller_Action
{
$session = new Scores_Session_Entreprise($this->siret, $this->id);
$user = new Scores_Utilisateur();
$this->view->assign('edition', $user->checkModeEdition());
$request = $this->getRequest();
$this->view->assign('siret', $this->siret);
$siren = substr($this->siret, 0, 9);

View File

@ -2243,4 +2243,198 @@ 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();
if ( $request->isPost() ) {
$this->view->assign('post', true);
$message = '';
$mode = $request->getParam('mode');
if( in_array($mode, array('create', 'edit')) ) {
$params = $request->getParams();
// check values
$paramlist = array(
'siret' => 'SIRET',
'type' => 'Type',
'value' => 'Valeur',
);
foreach ($paramlist as $item => $val) {
if (!isset($params[$item])) {
$message .= "Valeur $val vide !<br/>";
}
}
// end checking values
if ($message == '') {
//setContactEt
$ws = new WsScores();
$result = $ws->setSaisieContactEt($siret, $type, $value, $info);
if ( is_string($result) ) {
$this->view->assign('msg', $result);
}
} else {
$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');
$id = $request->getParam('id');
if ($mode=='delete') {
$this->view->assign('mode', 'delete');
} else {
if ( $id !== null ) {
$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);
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);
}
} else {
$siret = $request->getParam('siret');
$this->view->assign('siret', $siret);
}
$this->view->telinfo = array(
"accueil",
"achats",
"administratif",
"affrètement",
"agence",
"agence commerciale",
"agence industries",
"atelier(s)",
"bureau",
"bureau d'étude",
"centrale à béton",
"centre de formation",
"chef d'établissement",
"comité détablissement",
"comité d'entreprise",
"conseil",
"conseil financier",
"conseil immobilier",
"construction",
"coordination",
"cuisine",
"cuisine centrale",
"déchetterie",
"délégation départementale",
"délégation régionale",
"dépôt",
"direction",
"direction commerciale",
"direction de l'environnement",
"direction des ressources humaines",
"direction financière",
"direction générale",
"direction logistique",
"direction régionale",
"direction technique",
"direction usine",
"distribution",
"division surveillance",
"douane",
"entrepôt(s)",
"facturation",
"fournitures industrielles",
"gardien",
"gestion",
"industrie",
"inspection technique",
"laboratoire",
"local entretien",
"local syndical",
"magasin",
"matériaux",
"menuiserie",
"négoce",
"parking",
"pièces détachées",
"publicité",
"rédaction",
"répondeur",
"renseignements",
"salle d'exposition",
"secrétariat",
"secrétariat de direction",
"service après vente/SAV",
"service clients",
"service commandes",
"service commercial",
"service commercial export",
"service comptabilité",
"service comptabilité fournisseurs",
"service courrier",
"service dépannage",
"service entreprises",
"service entretien",
"service expéditions",
"service exploitation",
"service export",
"service financier",
"service formation",
"service fournisseurs",
"service import",
"service informatique",
"service international",
"service locations",
"service logistique",
"service maintenance",
"service maritime",
"service production",
"service qualité",
"service technique",
"service terrestre",
"services généraux",
"siège",
"standard",
"standard général",
"standard usine",
"syndicat",
"transitaire",
"transports",
"travaux",
"unité de production",
"usine",
);
}
}
}
}
}

View File

@ -18,7 +18,7 @@
</div>
<h2>Historique des données de contact</h2>
<div class="paragraph">
<div class="paragraph clearfix">
<?php if ($this->all) {?>
<?php
$url = $this->url(array('controller'=>'identite', 'action'=>'contacts','siret'=>$this->siret), null, true);
@ -60,7 +60,14 @@ $('input[name=filtre]').click(function(e){
</script>
</div>
<div class="paragraph" style="clear:both;">
<div class="paragraph clearfix">
<?php if ( $this->edition ) {?>
<div style="line-height:16px;">
<a class="dialog" title="Ajouter un contact" href="<?=$this->url(array('controller'=>'saisie','action'=>'contact','mode'=>'add','siret'=>$this->siret), null, true)?>">
<img style="vertical-align:middle;" src="/themes/default/images/interfaces/ajouter.png" /> Ajouter un contact</a>
</div>
<?php }?>
<?php if ( count($this->contacts) == 0 ){?>
Aucun contacts.
@ -68,7 +75,7 @@ Aucun contacts.
<table class="data">
<tr>
<th>SIREN</th>
<th>SIREN / SIRET</th>
<th>Type</th>
<th>Contact</th>
<th>Description</th>
@ -97,9 +104,20 @@ if ($item->deleted) {
<td>
<?php if ($item->type=='fax' || $item->type=='tel' || $item->type=='mob') {?>
<?=substr(chunk_split($item->value, 2, '.'), 0, -1)?>
<?php } else if ($item->type=='web') {?>
<a href="<?=$item->value?>" target="_blank"><?=$item->value?></a>
<?php } else if ($item->type=='mail') {?>
<a href="mailto:<?=$item->value?>" target="_blank"><?=$item->value?></a>
<?php } else {?>
<?=$item->value?>
<?php }?>
<?php if( $this->edition ) {?>
<div style="float:right;">
<a class="dialog" title="Modifier le contact" href="<?=$this->url(array('controller'=>'saisie','action'=>'contact','mode'=>'edit','id'=>$item->id), null, true)?>"><img src="/themes/default/images/interfaces/editer.png" /></a>
<a class="dialog" title="Supprimer le contact" href="<?=$this->url(array('controller'=>'saisie','action'=>'contact','mode'=>'delete','id'=>$item->id), null, true)?>"><img src="/themes/default/images/interfaces/supprimer.png" /></a>
</div>
<?php }?>
</td>
<td><?=$item->description?></td>
<td>
@ -116,4 +134,31 @@ if ($item->deleted) {
<?php }?>
</div>
</div>
</div>
<?php if ($this->edition) {?>
<script>
$('a.dialog').on('click', function(){
var href = $(this).attr('href');
if (href!='#') {
var title = $(this).attr('title');
var dialogOpts = {
bgiframe: true,
title: title,
width: 600,
height: 300,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...').load(href);
},
buttons: {
Quitter: function() { $(this).dialog('close'); }
},
close: function() { $('#dialog').remove(); }
};
$('<div id="dialog"></div>').dialog(dialogOpts);
return false;
}
});
</script>
<?php }?>

View File

@ -0,0 +1,75 @@
<?php if ($this->post) {?>
<?php if ($this->msg) {?>
<?=$this->msg?>
<?php } else {?>
<p>Opération effectué.</p>
<?php }?>
<script>
$('#dialog').dialog({ buttons: [
{ text: "Fermer", click: function() { $(this).dialog("close"); } }
] });
</script>
<?php } else {?>
<?php if ($this->mode == 'delete') {?>
<p>Supprimer l'élément id=<?=$this->id?> ?</p>
<form name="contact" action="<?=$this->url(array('controller'=>'saisie','action'=>'contact'),null,true)?>" method="post">
<input type="hidden" name="id" value="<?=$this->id?>"/>
</form>
<?php } else {?>
<form name="contact" action="<?=$this->url(array('controller'=>'saisie','action'=>'contact'),null,true)?>" method="post">
<?php if ($this->id) {?>
<input type="hidden" name="id" value="<?=$this->id?>"/>
<?php }?>
<input type="hidden" name="siret" value="<?=$this->siret?>"/>
<div>
<label>Type</label>
<select name="type">
<option value="tel"<?php if($this->type=='tel') {echo ' selected';}?>>Téléphone</option>
<option value="fax"<?php if($this->type=='fax') {echo ' selected';}?>>Fax</option>
<option value="web"<?php if($this->type=='web') {echo ' selected';}?>>Site Web</option>
<option value="mail"<?php if($this->type=='mail') {echo ' selected';}?>>Email</option>
</select>
</div>
<div>
<label>Valeur</label>
<input type="text" name="" value="<?=$this->value?>">
</div>
<p>
Téléphone france saisit sans séparateur, maximum 10 chiffres (format: XXXXXXXXXX)
<br/>Site Web avec http://
</p>
<div>
<label>Info</label>
<select name="info">
<option value="">-</option>
<?php foreach( $this->telinfo as $txt ) {?>
<option <?php if($txt == $this->info) { echo ' selected'; }?>><?=$txt?></option>
<?php }?>
</select>
<span>Uniquement pour les téléphones</span>
</div>
</form>
<?php }?>
<script>
$('#dialog').dialog({ buttons: [
{ text: "Enregistrer", click: function() {
var form = $('form[name=contact]');
$.post(form.attr('action'), form.serialize(), function(data){
form.replaceWith(data);
}).fail(function(){ alert('Unknow error'); });
} },
{ text: "Annuler", click: function() { $(this).dialog("close"); } }
] });
</script>
<?php }?>

View File

@ -101,9 +101,52 @@ class WsScores
return $client;
}
public function delSaisieContactEt($id)
{
$params = new stdClass();
$params->id = $id;
$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;
} catch (SoapFault $fault) {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
return $fault->faultstring;
}
}
public function getSaisieContactEt($id)
{
$params = new stdClass();
$params->id = $id;
$client = $this->loadClient('saisie');
try {
$reponse = $client->getContactEt($params);
return $reponse->getContactEtResult;
} catch (SoapFault $fault) {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
return $fault->faultstring;
}
}
public function getContactEt($siret, $filter = null)
{
$filename = 'getcontactset-'.$siret;
$filename = 'getcontactet-'.$siret;
if ( $filter !== null ) {
$filename.= '-'.$filter;