Sauvegarde du profil

This commit is contained in:
Michael RICOIS 2012-01-16 14:19:25 +00:00
parent 793162719f
commit d3c68f3f00
4 changed files with 57 additions and 12 deletions

View File

@ -21,8 +21,26 @@ class ProfilController extends Zend_Controller_Action
public function saveAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$reference = $request->getParam('reference');
$criteres = $request->getParam('criteres');
$db = Zend_Registry::get('db');
$profilM = new Application_Model_Profil($db);
$data = array(
'reference' => $reference,
'criteres' => $criteres,
);
if ( $profilM->insert($data) ){
echo '';
} else {
echo 'Erreur';
}
}
}

View File

@ -46,18 +46,26 @@ div#dico li {
<ol>
<li class="placeholder">Placer les elements ici</li>
</ol>
</div>
</div>
</div>
<div id="dico">
<h1 class="ui-widget-header">Elements disponibles</h1>
<ul>
<?php foreach($this->elements as $element) {?>
<li><?=$element?></li>
<?php foreach($this->elements as $key => $element) {?>
<li id="<?=$key?>">
<?php if (isset($element['lib'])) { echo $element['lib']; } else { echo $key; }?>
<?php if (isset($element['values'])) { echo "<input type=\"text\" name=\"".$key."\" value=\"\"/>"; }?>
</li>
<?php }?>
</ul>
</div>
<div style="clear:both;">
Référence <input type="text" name="profil" value="" />
<a id="save" href="<?=$this->url(array('controller'=>'profil', 'action'=>'save'))?>">Sauvegarder</a>
</div>
<script>
$(function() {
$( "#dico li" ).draggable({
@ -69,16 +77,35 @@ $(function() {
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function( event, ui ) {
$( this ).find( ".placeholder" ).remove();
$( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
$( this ).find( ".placeholder" ).remove();
var id = ui.draggable.attr('id');
$('<li id="'+id+'"></li>').html( ui.draggable.html() ).appendTo( this );
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
// gets added unintentionally by droppable interacting with sortable
// using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
$( this ).removeClass( "ui-state-default" );
}
});
$('#save').click(function(e){
e.preventDefault();
var url = $(this).attr('href');
var list = new Array();
$('#entete ol li').each(function(index){
var id = $(this).attr('id');
if($('input[name='+id+']', this).length>0){
id = id + '(' + $('input[name='+id+']', this).val() + ')';
}
list.push(id);
});
var ref = $('input[name=profil]').val();
if (ref!='') {
$.post(url, { reference: ref, criteres: list.join() }, function(data){
if (data!='Erreur'){ window.location.href = './'; }
}, 'json');
}
});
});
</script>

View File

@ -138,10 +138,10 @@ class Enrichissement
'dirigeant'=> array(),
'encours'=> array(),
'dateBilan'=> array(),
'bilanN'=> array(),
'bilanN1'=> array(),
'bilanN2'=> array(),
'annonces'=> array(),
'bilanN'=> array('values'=>''),
'bilanN1'=> array('values'=>''),
'bilanN2'=> array('values'=>''),
'annonces'=> array('values'=>''),
);
public function __construct(){}
@ -209,7 +209,7 @@ class Enrichissement
//Retourne les clés de dictionnaire pour les données d'enrichissement
public function getDico()
{
return array_keys($this->tabDico);
return $this->tabDico;
}
//Retourne le libellé pour chaque clés du dictionnaire