172 lines
5.1 KiB
PHTML
172 lines
5.1 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="idLien" value="<?=$this->edit?>"/>
|
|
<?php if ( intval($this->siren)==0 && $this->PpPm=='PM' ) {?>
|
|
<?=$this->render('saisie/lienetranger.phtml')?>
|
|
<?php } elseif ( $this->PpPm=='PP' ) {?>
|
|
<div class="fieldgrp">
|
|
<label>Siren</label>
|
|
<div class="field">
|
|
<input type="text" name="siren" value="<?=$this->siren?>"/>
|
|
</div>
|
|
</div>
|
|
<?=$this->render('saisie/lienpp.phtml')?>
|
|
<?php } else {?>
|
|
<?=$this->render('saisie/lienidentite.phtml')?>
|
|
<?php }?>
|
|
</form>
|
|
<script>
|
|
$('#dialog').dialog({ buttons: [
|
|
{ text: "Modifier", click: function() {
|
|
var form = $('form[name=saveLienRef]');
|
|
$.post(form.attr('action'), form.serialize(), function(data){
|
|
if(data.error==''){
|
|
form.replaceWith('<b>Fiche Modifié '+data.RS+'</b>');
|
|
} else {
|
|
form.replaceWith(data.error);
|
|
}
|
|
}, 'json').error(function(){ alert('Unknow error'); });
|
|
} },
|
|
{ text: "Annuler", click: function() { $(this).dialog("close"); } }
|
|
] });
|
|
</script>
|
|
|
|
<?php } else {?>
|
|
<div id="searchFiche">
|
|
|
|
<style>
|
|
|
|
</style>
|
|
|
|
<div class="fieldgrp">
|
|
<label>Recherche</label>
|
|
<div class="field">
|
|
<select name="searchType">
|
|
<option value="nom">Nom</option>
|
|
<option value="siren">Siren</option>
|
|
<option value="identifiant">Identifiant</option>
|
|
<option value="special">Spéciaux</option>
|
|
<option value="id">idRef</option>
|
|
</select>
|
|
<select name="searchCountry" style="width:100px;">
|
|
<option value="">-</option>
|
|
<?php foreach($this->countries as $code => $item) {?>
|
|
<option value="<?=$code?>"<?=$select?>><?=$item['libPays']?></option>
|
|
<?php }?>
|
|
</select>
|
|
<input type="text" name="searchTxt" 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'), null, true)?>" class="lienRef">Personne physique</a>,
|
|
<a href="<?=$this->url(array('controller'=>'saisie','action'=>'lienetranger'), null , true)?>" 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) {
|
|
var query = request.term;
|
|
var type = $('select[name=searchType]').val();
|
|
switch( type ) {
|
|
case 'siren': break;
|
|
case 'id': break;
|
|
case 'nom':
|
|
if ($('select[name=searchCountry]').val()!='') {
|
|
query = query + ',' + $('select[name=searchCountry]').val();
|
|
}
|
|
break;
|
|
}
|
|
$.getJSON('<?=$this->url(array('controller'=>'saisie','action'=>'liensearch'),null,true)?>', { q: query, type: type },
|
|
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=searchTxt]').val();
|
|
value = value.replace(/,|;|\s|\./g,'');
|
|
var display = $('div#fiche').css('display');
|
|
if (display=='none'){
|
|
$('div#fiche').css('display', 'block');
|
|
} else {
|
|
$('div#fiche').css('display', 'none');
|
|
}
|
|
if (value.length==9 && $('select[name=searchType]').val()=='siren') {
|
|
$('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 }?> |