Issue #0001788: [Dirigeants Opérationnels] Ajouter, modifier et supprimer les dirigeants operationnels

This commit is contained in:
Aram HARUTYUNYAN 2014-03-18 11:36:08 +00:00
parent 9820bb9b4f
commit 9062138e1b
9 changed files with 596 additions and 15 deletions

View File

@ -117,6 +117,54 @@ class DirigeantController extends Zend_Controller_Action
$this->view->assign('AutrePage', $this->getRequest()->getParam('apage'));
$user = new Scores_Utilisateur();
$this->view->assign('accessWorldCheck', $user->checkPerm('WORLDCHECK'));
$this->view->assign('surveillance', $user->checkPerm('survdirigeants'));
$this->view->assign('edition', $user->checkModeEdition());
}
public function diropficheAction()
{
$this->_helper->layout()->disableLayout();
$siren = substr($this->siret, 0, 9);
$this->view->assign('siret', $this->siret);
$this->view->assign('id', $this->id);
}
public function diropliensAction()
{
$siren = substr($this->siret, 0, 9);
$this->view->headTitle()->prepend('Liste des entreprises');
$ws = new WsScores();
$entListe = array();
$param = array('id'=>$this->id);
$infos = $ws->searchDirigeantsOp(json_encode($param));
$liste = $infos->item;
$fct = json_decode($ws->getCatalogFctDir(), true);
foreach($liste as $key=>$val)
{
$item = new stdClass();
$item->RS = $ws->getIdentiteLight($val->siren);
$item->siren = $val->siren;
$item->nic = $val->nic;
$item->libFct = $fct[intval($val->codFct)]['libelle'];
$entListe[] = $item;
}
$this->view->assign('liste', $entListe);
$this->view->assign('nom', $liste[0]->nom);
$this->view->assign('prenom', $liste[0]->prenom);
$user = new Scores_Utilisateur();
$this->view->assign('accessWorldCheck', $user->checkPerm('WORLDCHECK'));
}
}

View File

@ -2505,6 +2505,130 @@ 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');
$id = $request->getParam('id', null);
$siret = $request->getParam('siret');
$siren = substr($siret, 0, 9);
$nic = substr($siret, 9, 5);
$ws = new WsScores();
switch ($mode) {
case 'add':
$fonction = $this->fctDir();
$this->view->assign('fonction', $fonction);
case 'edit':
$fonction = $this->fctDir();
$infos = $ws->getDirigeantsOp($siren, $id);
$this->view->assign('fonction', $fonction);
$this->view->assign('infos', $infos->item[0]);
case 'del':
$infos = $ws->getDirigeantsOp($siren, $id);
}
$this->view->assign('mode', $mode);
$this->view->assign('type', $type);
$this->view->assign('id', $id);
$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'],
'civilite' => $params['civilite'],
'nom' => $params['nom'],
'prenom' => $params['prenom'],
'nom_usage' => $params['nom_usage'],
'dateNais' => $newDate,
'lieuNais' => $params['naiss_lieu'],
'codFct' => $params['codFct'],
'tel' => $params['tel'],
'fax' => $params['fax'],
'email' => $params['email']
);
$ws = new WsScores();
$result = $ws->setDirigeantsOp(json_encode($infos), $params['mode'], $params['type'], $params['id']);
if(is_int(intval($result)))
{
if($params['mode'] == 'add'){
$message = $this->view->translate('Ajout');
} else if ($params['mode'] == 'edit') {
$message = $this->view->translate('Edition');
} else if ($params['mode'] == 'del') {
$message = $this->view->translate('Suppression');
}
if (intval($result)!=0) {
$message = $message.' '.$this->view->translate('a été réussi!');
} else {
$message = $message.' '.$this->view->translate('n\'a pas été réussi!');
}
} else {
$message = $result;
}
$this->view->assign('message', $message);
}
public function diropsearchAction()
{
$this->_helper->layout()->disableLayout();
$query = $this->getRequest()->getParam('query', null);
$param = array('query'=>$query);
$output = array();
if ( null !== $query) {
$ws = new WsScores();
$infos = $ws->searchDirigeantsOp(json_encode($param));
if ( count($infos)>0 ) {
foreach ($infos->item as $item) {
$output[] = array(
'label' => str_pad($item->siren, 9, 0, STR_PAD_LEFT).": ".$item->nom.' '.$item->prenom,
'value' => $item->nom.' '.$item->prenom,
'id' => $item->id
);
}
}
}
$this->view->assign('output', $output);
}
/**
* Edit contact information

View File

@ -0,0 +1,50 @@
<?php $param = array(
'controller'=>'saisie',
'action'=>'diropcontrol',
'mode'=>'edit',
'type'=>'fiche',
'siret'=>$this->siret,
'id'=>$this->id);
?>
<p><a class="dialog" title="Modifier le dirigeant" href="<?=$this->url($param, null, true)?>">
<?=$this->translate("Editer la fiche")?></a></p>
<?php $param['mode']='del';?>
<p><a class="dialog" title="Supprimer le dirigeant" href="<?=$this->url($param, null, true)?>">
<?=$this->translate("Supprimer la fiche")?></a></p>
<?php $param = array(
'controller'=>'dirigeant',
'action'=>'diropliens',
'siret'=>$this->siret,
'id'=>$this->id);
?>
<p><a title="Liste des entreprises" href="<?=$this->url($param, null, true)?>">
<?=$this->translate("Liste des entreprises")?></a></p>
<script>
$('a.dialog').on('click', function(){
$('div.qtip').hide();
var href = $(this).attr('href');
if (href!='#') {
var title = $(this).attr('title');
var dialogOpts = {
bgiframe: true,
title: title,
width: 600,
height: 550,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Quitter: function() { $(this).dialog('close'); }
},
close: function() { $('#dialog').remove(); }
};
$('<div id="dialog"></div>').dialog(dialogOpts);
return false;
}
});
</script>

View File

@ -33,13 +33,16 @@
<h2><?=$this->translate("Liste des dirigeants actifs")?></h2>
<div class="paragraph">
<?php if ($this->edition) {?>
<a class="dialog" title="Ajouter un dirigeant" href="<?=$this->url(array('controller'=>'saisie','action'=>'diropcontrol','mode'=>'add','siret'=>$this->siret,'lienref'=>$this->lienref), null, true)?>">
<img style="vertical-align:middle;" src="/themes/default/images/interfaces/ajouter.png" /><?=$this->translate("Ajouter un dirigeant")?></a>
<?php }?>
<?php if ( count($this->dirigeants)>0 ) {?>
<table class="data">
<?php foreach ($this->dirigeants as $dir) {?>
<tr>
<td class="StyleInfoData" width="120"><?=$dir->Titre?></td>
<td class="StyleInfoData" width="200">
<td class="StyleInfoData diropfiche" id="<?=$dir->Id?>" width="200">
<?php if ($dir->Societe != '') { ?>
<a href="<?=$this->url(array(
'controller' => 'recherche',
@ -64,18 +67,59 @@
</a>
<?php } ?>
</td>
<td class="StyleInfoData" width="230">
<?php if (trim($dir->NaissDate) != '' && trim($dir->NaissVille.' '.$dir->NaissDepPays) != '') { ?>
<?=$this->translate("né(e) le")?> <?=$dir->NaissDate?> à <?=$dir->NaissVille?>
<?php if (trim($dir->NaissDepPays) != '') { ?>
&nbsp;(<?=$dir->NaissDepPays?>)
<?php }?>
<?php } else if (trim($dir->NaissDate) != '') {?>
<?=$this->translate("né(e) le")?> <?=$dir->NaissDate?>
<?php } else if (trim($dir->NaissVille.' '.$dir->NaissDepPays) != '') { ?>
<?=$this->translate("né(e) à")?> <?=$dir->NaissVille?> &nbsp;(<?=$dir->NaissDepPays?>)
<?php } ?>
<td class="StyleInfoData" width="220">
<?php
$message = '';
if (trim($dir->NaissDate) != '' && trim($dir->NaissDate)!='0000-00-00') {
$date = new Zend_Date($dir->NaissDate, 'yyyy-MM-dd');
$message = $message.' '.$this->translate("le").' '.$date->toString('dd/MM/yyyy');
}
if (trim($dir->NaissVille.' '.$dir->NaissDepPays) != '') {
$message = $message.' '.$this->translate("à").' '.$dir->NaissVille;
}
if ($message!='') {
if ($dir->Civilite=='' || $dir->Civilite==null) {
$message = $this->translate("né(e)").' '.$message;
} else if ($dir->Civilite=='M') {
$message = $this->translate("né").' '.$message;
} else {
$message = $this->translate("née").' '.$message;
}
echo $message;
}
?>
</td>
<?php if ($this->edition) {?>
<td>
<a class="dialog" title="Modifier le dirigeant" href="<?=$this->url(array('controller'=>'saisie','action'=>'diropcontrol','mode'=>'edit','siret'=>$this->siret,'id'=>$dir->Id), null, true)?>">
<img src="/themes/default/images/interfaces/editer.png" /></a>
<a class="dialog" title="Supprimer le dirigeant" href="<?=$this->url(array('controller'=>'saisie','action'=>'diropcontrol','mode'=>'del','siret'=>$this->siret,'id'=>$dir->Id), null, true)?>">
<img src="/themes/default/images/interfaces/supprimer.png" /></a>
</td>
<?php if (empty($this->AutrePage) && $this->accessWorldCheck) {?>
<td>
<?php if ($dir->Societe != '') { ?>
<img style="cursor:pointer;" class="wcheck" data-url="<?=$this->url(array(
'controller'=>'worldcheck','action'=>'occurence','siren'=>$this->siren,
'dirType'=>'ORGANISATION','dirSociete'=>$dir->Societe),null,true);?>" src="/themes/default/images/worldcheck/wc.png"/>
<?php }?>
<?php if ($dir->Nom != '') {
$param = array(
'controller'=>'worldcheck',
'action'=>'occurence',
'siren'=>$this->siren,
'dirType'=>'INDIVIDUAL',
'dirNom'=>$dir->Nom,
'dirPrenom'=>$dir->Prenom,
);
?>
<img style="cursor:pointer;" class="wcheck" data-url="<?=$this->url($param,null,true);?>" src="/themes/default/images/worldcheck/wc.png"/>
<?php } ?>
</td>
<?php }?>
<?php }?>
</tr>
<?php } ?>
</table>
@ -93,4 +137,55 @@
<?php if (empty($this->AutrePage)){?>
<?=$this->render('cgu.phtml', $this->cgu)?>
</div>
<?php }?>
<?php }?>
<script>
$('td.diropfiche').each(function(){
$(this).qtip({
hide: { event: 'unfocus' },
show: { solo: true, delay: 2000 },
content: {
button: true,
title: $(this).text(),
text: "Chargement...",
ajax: { url: '<?=$this->url(array('controller'=>'dirigeant','action'=>'diropfiche'),null,true)?>/siret/'+<?=$this->siret?>+'/id/'+$(this).attr('id') } },
position: { my: "bottom left", at: "top left" }
});
});
$('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: 550,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Quitter: function() { $(this).dialog('close'); }
},
close: function() { $('#dialog').remove(); }
};
$('<div id="dialog"></div>').dialog(dialogOpts);
return false;
}
});
$('img.wcheck').each(function(){
$(this).qtip({
hide: { event: 'unfocus' },
show: { solo: true, delay: 500 },
content: {
button: true,
title: 'WorlCheck',
text: "Chargement...",
ajax: { url: $(this).data('url') } },
position: { my: 'right center', at: 'left center' }
});
});
</script>

View File

@ -0,0 +1,95 @@
<style>
.err {
border-style:solid;
border-width:1px;
border-color:red;
}
</style>
<div class="fields">
<div class="fieldgrp">
<label>Civilité</label>
<div class="field">
<?php
$civilites = array('M', 'MME', 'MLE');
foreach ($civilites as $civilite) {
$checked=(strcmp($civilite, $this->infos->Civilite)==0)?"checked":"";
?>
<?=$civilite ?><input type="radio" name="civilite" value="<?=$civilite?>" <?=$checked?>/>
<?php }?>
</div>
</div>
<div class="fieldgrp">
<label>Nom</label>
<div class="field">
<input type="text" name="nom" value="<?=$this->infos->Nom?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Prenom</label>
<div class="field">
<input type="text" name="prenom" value="<?=$this->infos->Prenom?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Nom d'usage</label>
<div class="field">
<input type="text" name="nom_usage" value="<?=$this->infos->NomUsage?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Date de naissance</label>
<div class="field">
<?php
if (trim($this->infos->NaissDate) != '' && trim($this->infos->NaissDate)!='0000-00-00') {
$date = new Zend_Date($this->infos->NaissDate, 'yyyy-MM-dd');
$newDate = $date->toString('dd/MM/yyyy');
}
?>
<input type="text" name="naiss_date" value="<?=$newDate?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Lieu de naissance</label>
<div class="field">
<input type="text" name="naiss_lieu" value="<?=$this->infos->NaissVille?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Téléphone</label>
<div class="field">
<input type="text" name="tel" value="<?=$this->infos->Tel?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Télécopie</label>
<div class="field">
<input type="text" name="fax" value="<?=$this->infos->Fax?>"/>
</div>
</div>
<div class="fieldgrp">
<label>Email</label>
<div class="field">
<input type="text" name="email" value="<?=$this->infos->Email?>"/>
</div>
</div>
</div>
<script>
$('input[name=email]').on("focusout", function(){
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!regex.test($(this).val())) {
$(this).addClass('err');
}
else {
$(this).removeClass('err');
}
});
</script>

View File

@ -0,0 +1,106 @@
<?php if ($this->mode=='add') { ?>
<div class="fieldgrp"><label><?=$this->translate("Rechercher") ?></label>
<div class="field"><input type="text" name="recherche"/></div>
</div>
<?php }?>
<form name="dirop" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'diropsave'),null, true)?>" method="post">
<input type="hidden" name="type" value="<?=$this->type?>" />
<input type="hidden" name="mode" value="<?=$this->mode?>" />
<input type="hidden" name="siren" value="<?=$this->siren?>" />
<input type="hidden" name="nic" value="<?=$this->nic?>" />
<input type="hidden" name="id" value="<?=$this->id?>" />
<?php if ($this->mode=='add') { ?>
<p class="titre"></p>
<div class="fieldgrp"><label><?=$this->translate("Fonction") ?></label>
<div class="field"><select name="codFct" style="width:380px;">
<option value="0000">-</option>
<?php foreach ($this->fonction as $key=>$val) { ?>
<option value="<?=$key ?>"><?=$val?></option>
<?php }?>
</select>
</div></div>
<?php echo $this->partial('/saisie/diropcontrol-form.phtml');?>
<?php
} else if ($this->mode=='edit') {
if ($this->type=='fiche') {
echo $this->translate("Modifier la fiche du dirigeant");
echo $this->render('/saisie/diropcontrol-form.phtml');
} else {?>
<div class="fieldgrp"><label><?=$this->translate("Fonction") ?></label>
<div class="field"><select name="codFct" style="width:380px;>
<option value="0000">-</option>
<?php foreach ($this->fonction as $key=>$val) {
$selected=(strcmp($key, $this->infos->Code)==0)?"selected":""; ?>
<option value="<?=$key ?>" <?=$selected?>><?=$val?></option>
<?php }?>
</select>
</div></div>
<?php }?>
<?php } else if ($this->mode=='del') {
if ($this->type=='fiche') {
echo $this->translate("Supprimer la fiche du dirigeant");
} else {
echo $this->translate("Supprimer le lien du dirigeant");
}?>
<?php }?>
</form>
<script>
$('#dialog').dialog({ buttons: [
{ text: "Valider", click: function() {
var form = $('form[name=dirop]');
$.post(form.attr('action'), form.serialize(), function(data){
$('#dialog').html(data);
}).fail(function(){ alert('Unknown error'); });
}},
{ text: "Annuler", click: function() { $(this).dialog('close'); } }
] });
$.datepicker.setDefaults( $.datepicker.regional["fr"] );
$('input[name=naiss_date]').datepicker({ changeMonth: true, changeYear: true });
</script>
<?php if ($this->mode=='add') { ?>
<script>
$('form').hide();
$(".ui-dialog-buttonpane button:contains('Valider')").hide();
$('input[name=recherche]').on("focus", function(){
$(".ui-dialog-buttonpane button:contains('Valider')").hide();
$('p.titre').text('');
$('form').hide();
$('input[name=type]').val('');
});
$('input[name=recherche]').autocomplete({
minLength: 3,
delay: 500,
source: function(request, response) {
var recherche = $('input[name=recherche]').val();
$.getJSON('<?=$this->url(array('controller'=>'saisie','action'=>'diropsearch'),null,true)?>',
{ query: recherche },
function(data) {response(data); console.log(data);}
);
},
select: function( event, ui ) {
$(".ui-dialog-buttonpane button:contains('Valider')").show();
$('p.titre').text('Ajouter le dirigeant à la sociéte');
$('form').show();
$('input[name=type]').val('lien');
$('form .fields').hide();
$('input[name=recherche]').attr('value', ui.item.value);
$('input[name=id]').attr('value', ui.item.id);
},
change: function(event, ui) {
if (ui.item == null) {
$(".ui-dialog-buttonpane button:contains('Valider')").show();
$('p.titre').text('Enregistrer un dirigeant et l\'ajouter à la sociéte');
$('form').show();
$('input[name=type]').val('fiche');
$('form .fields').show();
}
}
});
</script>
<?php }?>

View File

@ -0,0 +1,12 @@
<?=$this->message ?>
<script>
$('#dialog').dialog({
buttons: [{
text: "Quitter",
click: function() {
location.reload();
$(this).dialog('close');
}
}]
});
</script>

View File

@ -0,0 +1 @@
<?=json_encode($this->output)?>

View File

@ -2551,7 +2551,7 @@ class WsScores
* getDirigeantsOp
* @param string $siren
*/
public function getDirigeantsOp($siren)
public function getDirigeantsOp($siren, $id = null)
{
$filename = 'dirigeantsop-'.$siren;
@ -2564,6 +2564,7 @@ class WsScores
$params = new StdClass();
$params->siren = $siren;
$params->id = $id;
$client = $this->loadClient('interne');
try {
$reponse = $client->getDirigeantsOp($params);
@ -2577,6 +2578,55 @@ class WsScores
return false;
}
}
/**
* setDirigeantsOp
* @param array $infos
*/
public function setDirigeantsOp($infos, $mode, $type, $id)
{
$params = new stdClass();
$params->infos = $infos;
$params->mode = $mode;
$params->type = $type;
$params->id = $id;
$client = $this->loadClient('saisie');
try {
$reponse = $client->setDirigeantsOp($params);
return $reponse->setDirigeantsOpResult;
} catch (SoapFault $fault) {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
return false;
}
}
}
/**
* searchDirigeantsOp
* @param string $query
*/
public function searchDirigeantsOp($query)
{
$params = new stdClass();
$params->query = $query;
$client = $this->loadClient('saisie');
try {
$reponse = $client->searchDirigeantsOp($params);
return $reponse->searchDirigeantsOpResult;
} catch (SoapFault $fault) {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
return false;
}
}
}
/**
* getIdentiteLight