2012-11-12 17:55:37 +00:00
<?php if ( $this -> edit ) { ?>
2012-11-14 17:21:32 +00:00
< form name = "saveLienRef" action = " <? = $this -> url ( array ( 'controller' => 'saisie' , 'action' => 'lienrefsave' ), null , true ) ?> " method = "post" >
2012-11-15 15:41:35 +00:00
< input type = "hidden" name = "idLien" value = " <? = $this -> edit ?> " />
2012-11-12 17:55:37 +00:00
<?php if ( intval ( $this -> siren ) == 0 && $this -> PpPm == 'PM' ) { ?>
<? = $this -> render ( 'saisie/lienetranger.phtml' ) ?>
2012-12-03 15:01:40 +00:00
<?php } elseif ( $this -> PpPm == 'PP' ) { ?>
< div class = "fieldgrp" >
< label > Siren< / label >
< div class = "field" >
< input type = "text" name = "siren" value = " <? = $this -> siren ?> " />
< / div >
< / div >
2012-11-12 17:55:37 +00:00
<? = $this -> render ( 'saisie/lienpp.phtml' ) ?>
<?php } else { ?>
<? = $this -> render ( 'saisie/lienidentite.phtml' ) ?>
<?php } ?>
2012-11-14 17:21:32 +00:00
< / form >
2012-11-15 15:41:35 +00:00
< 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 >
2012-11-12 17:55:37 +00:00
<?php } else { ?>
2012-10-15 09:12:59 +00:00
< div id = "searchFiche" >
< div class = "fieldgrp" >
2012-11-22 07:44:55 +00:00
< label > Recherche< / label >
2012-10-15 09:12:59 +00:00
< div class = "field" >
2012-11-22 07:44:55 +00:00
< select name = "searchType" >
< option value = "nom" > Nom< / option >
< option value = "siren" > Siren< / option >
2012-12-18 16:26:41 +00:00
< option value = "identifiant" > Identifiant< / option >
2012-11-26 17:18:44 +00:00
< option value = "special" > Spéciaux< / option >
2012-12-18 16:26:41 +00:00
< option value = "id" > idRef< / option >
2012-11-22 07:44:55 +00:00
< / select >
< select name = "searchCountry" style = "width:100px;" >
< option value = "" > -< / option >
2012-12-12 15:31:16 +00:00
<?php foreach ( $this -> countries as $code => $item ) { ?>
< option value = " <? = $code ?> " <? = $select ?> > <? = $item [ 'libPays' ] ?> </ option >
2012-11-22 07:44:55 +00:00
<?php } ?>
< / select >
< input type = "text" name = "searchTxt" class = "autocomplete" / >
2012-10-15 09:12:59 +00:00
< / 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" >
2012-11-09 11:33:00 +00:00
< input type = "text" name = "siren" value = "" / >
< a id = "infors" href = "#" > Obtention Raison Sociale< / a > ,
< a target = "_blank" href = "/" > Rechercher sur Extranet< / a >
2012-10-15 09:12:59 +00:00
< / div >
< / div >
< div class = "fieldgrp" >
2012-11-15 10:15:44 +00:00
< 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 >
2012-10-15 09:12:59 +00:00
< / div >
< div id = "lienRef" > < / div >
2012-11-14 17:21:32 +00:00
< / fieldset >
2012-10-15 09:12:59 +00:00
< div style = "text-align:right;" >
< input type = "submit" name = "save" value = "Créer la fiche" / >
< / div >
< / form >
< / div >
2012-10-25 10:15:26 +00:00
< script >
2012-10-15 09:12:59 +00:00
$('input.autocomplete').autocomplete({
minLength:4,
delay:1000,
source: function(request, response) {
2012-11-22 07:44:55 +00:00
var query = request.term;
2012-11-22 08:41:34 +00:00
var type = $('select[name=searchType]').val();
2012-11-22 07:44:55 +00:00
switch( type ) {
case 'siren': break;
case 'id': break;
case 'nom':
2012-11-22 08:41:34 +00:00
if ($('select[name=searchCountry]').val()!='') {
2012-11-22 08:54:56 +00:00
query = query + ',' + $('select[name=searchCountry]').val();
2012-11-22 07:44:55 +00:00
}
break;
}
$.getJSON('<? = $this -> url ( array ( 'controller' => 'saisie' , 'action' => 'liensearch' ), null , true ) ?> ', { q: query, type: type },
2012-10-15 09:12:59 +00:00
function(data) { response(data); }
);
},
select: function(event, ui) {
2012-10-23 15:28:17 +00:00
$('form[name=lien]').prepend('< input type = "hidden" name = "id2" value = "'+ui.item.value+'" / > ');
2013-01-08 15:41:11 +00:00
$('div#searchFiche').replaceWith('< b > Fiche sélectionnée '+ui.item.label+
' (id = < a style = "text-decoration:underline;" target = "_blank" href = " <? = $this -> url ( array ( 'controller' => 'identite' , 'action' => 'liens' )) ?> /lienref/'+ui.item.value+
'">'+ui.item.value+'< / a > )< / b > ');
2012-10-15 09:12:59 +00:00
}
});
2012-12-18 16:26:41 +00:00
2012-10-15 09:12:59 +00:00
$('form[name=saveLienRef]').submit(function(e){
2012-10-23 15:28:17 +00:00
e.preventDefault();
2012-10-15 09:12:59 +00:00
var form = $(this);
$.post(form.attr('action'), form.serialize(), function(data){
if(data.error==''){
2012-10-23 15:28:17 +00:00
$('form[name=lien]').prepend('< input type = "hidden" name = "id2" value = "'+data.id+'" / > ');
2012-11-09 11:33:00 +00:00
$('div#searchFiche').replaceWith('< b > Fiche créée '+data.RS+' (id = '+data.id+')< / b > ');
2012-10-15 09:12:59 +00:00
} else {
$('div#searchFiche').replaceWith(data.error);
}
}, 'json').error(function(){ alert('Unknow error'); });
2012-12-18 16:26:41 +00:00
2012-10-15 09:12:59 +00:00
return false;
});
2012-12-18 16:26:41 +00:00
2012-10-15 09:12:59 +00:00
$('a#newfiche').click(function(e){
e.preventDefault();
2012-12-12 15:31:16 +00:00
var value = $('input[name=searchTxt]').val();
value = value.replace(/,|;|\s|\./g,'');
2012-10-15 09:12:59 +00:00
var display = $('div#fiche').css('display');
if (display=='none'){
$('div#fiche').css('display', 'block');
} else {
$('div#fiche').css('display', 'none');
}
2012-12-12 15:31:16 +00:00
if (value.length==9 & & $('select[name=searchType]').val()=='siren') {
2012-11-12 17:55:37 +00:00
$('input[name=siren]').val(value);
}
2012-10-15 09:12:59 +00:00
});
$('a.lienRef').click(function(e){
e.preventDefault();
var url = $(this).attr('href');
$('div#lienRef').load(url);
});
2012-10-23 15:28:17 +00:00
2012-11-09 11:33:00 +00:00
$('a#infors').on('click', function(e){
2012-10-23 15:28:17 +00:00
e.preventDefault();
2012-11-09 11:33:00 +00:00
var siren = $('div#fiche input[name=siren]').val();
2012-10-23 15:28:17 +00:00
if(siren.length==9) {
2012-10-31 10:09:27 +00:00
$.post('/saisie/lienidentite', {siren: siren }, function success(data) {
$('div#lienRef').html(data);
2012-10-23 15:28:17 +00:00
});
} else {
alert('Siren faux!');
return false;
}
});
2012-10-15 09:12:59 +00:00
< / script >
2012-12-18 16:26:41 +00:00
2012-11-12 17:55:37 +00:00
< / div >
<?php } ?>