124 lines
3.5 KiB
PHTML
124 lines
3.5 KiB
PHTML
<?php if ($this->edit) {?>
|
|
|
|
<form name="saveLienRef" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'lienrefsave'), null, true)?>" method="post">
|
|
<input type="hidden" name="id" value="<?=$this->edit?>"/>
|
|
<?php if ( intval($this->siren)==0 && $this->PpPm=='PM' ) {?>
|
|
<?=$this->render('saisie/lienetranger.phtml')?>
|
|
<?php } elseif (intval($this->siren)==0 && $this->PpPm=='PP') {?>
|
|
<?=$this->render('saisie/lienpp.phtml')?>
|
|
<?php } else {?>
|
|
<?=$this->render('saisie/lienidentite.phtml')?>
|
|
<?php }?>
|
|
</form>
|
|
|
|
<?php } else {?>
|
|
<div id="searchFiche">
|
|
|
|
<div class="fieldgrp">
|
|
<label>Identifiant / Mots clés</label>
|
|
<div class="field">
|
|
<input type="text" name="search" class="autocomplete"/>
|
|
</div>
|
|
</div>
|
|
|
|
<a href="#" id="newfiche">Aucun résultat, Créer une nouvelle fiche</a>
|
|
|
|
<div id="fiche" style="display:none;">
|
|
|
|
<form name="saveLienRef" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'lienrefsave'), null, true)?>" method="post">
|
|
|
|
<fieldset>
|
|
<legend>Informations fiche</legend>
|
|
|
|
<div class="fieldgrp">
|
|
<label>Siren</label>
|
|
<div class="field">
|
|
<input type="text" name="siren" value=""/>
|
|
<a id="infors" href="#">Obtention Raison Sociale</a>,
|
|
<a target="_blank" href="/">Rechercher sur Extranet</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fieldgrp">
|
|
<a href="<?=$this->url(array('controller'=>'saisie','action'=>'lienpp'))?>" class="lienRef">Personne physique</a>,
|
|
<a href="<?=$this->url(array('controller'=>'saisie','action'=>'lienetranger'))?>" class="lienRef">Société étrangère</a>
|
|
</div>
|
|
<div id="lienRef"></div>
|
|
</fieldset>
|
|
|
|
<div style="text-align:right;">
|
|
<input type="submit" name="save" value="Créer la fiche"/>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
$('input.autocomplete').autocomplete({
|
|
minLength:4,
|
|
delay:1000,
|
|
source: function(request, response) {
|
|
$.getJSON('<?=$this->url(array('controller'=>'saisie','action'=>'liensearch'),null,true)?>', { q: request.term },
|
|
function(data) { response(data); }
|
|
);
|
|
},
|
|
select: function(event, ui) {
|
|
$('form[name=lien]').prepend('<input type="hidden" name="id2" value="'+ui.item.value+'"/>');
|
|
$('div#searchFiche').replaceWith('<b>Fiche sélectionnée '+ui.item.label+' (id = '+ui.item.value+')</b>');
|
|
}
|
|
});
|
|
|
|
$('form[name=saveLienRef]').submit(function(e){
|
|
e.preventDefault();
|
|
var form = $(this);
|
|
$.post(form.attr('action'), form.serialize(), function(data){
|
|
if(data.error==''){
|
|
$('form[name=lien]').prepend('<input type="hidden" name="id2" value="'+data.id+'"/>');
|
|
$('div#searchFiche').replaceWith('<b>Fiche créée '+data.RS+' (id = '+data.id+')</b>');
|
|
} else {
|
|
$('div#searchFiche').replaceWith(data.error);
|
|
}
|
|
}, 'json').error(function(){ alert('Unknow error'); });
|
|
|
|
return false;
|
|
});
|
|
|
|
$('a#newfiche').click(function(e){
|
|
e.preventDefault();
|
|
var value = $('input[name=search]').val();
|
|
var display = $('div#fiche').css('display');
|
|
if (display=='none'){
|
|
$('div#fiche').css('display', 'block');
|
|
} else {
|
|
$('div#fiche').css('display', 'none');
|
|
}
|
|
if (value.length==9) {
|
|
$('input[name=siren]').val(value);
|
|
}
|
|
});
|
|
|
|
$('a.lienRef').click(function(e){
|
|
e.preventDefault();
|
|
var url = $(this).attr('href');
|
|
$('div#lienRef').load(url);
|
|
|
|
});
|
|
|
|
$('a#infors').on('click', function(e){
|
|
e.preventDefault();
|
|
var siren = $('div#fiche input[name=siren]').val();
|
|
if(siren.length==9) {
|
|
$.post('/saisie/lienidentite', {siren: siren }, function success(data) {
|
|
$('div#lienRef').html(data);
|
|
});
|
|
} else {
|
|
alert('Siren faux!');
|
|
return false;
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<?php }?> |