Gestion des liens pour l'arborescence des codes NAF

This commit is contained in:
Michael RICOIS 2012-01-16 16:15:03 +00:00
parent 52c25ccf80
commit 0115d5f674
3 changed files with 32 additions and 9 deletions

View File

@ -12,8 +12,10 @@ class ArborescenceController extends Zend_Controller_Action
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
$request = $this->getRequest();
$niveau = $request->getParam('niveau', 1);
$key = $request->getParam('key');
$this->view->assign('key', $key);
$niveau = 1;
$nafM = new Application_Model_Naf();
//Niveau 1
$sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC');
@ -26,7 +28,7 @@ class ArborescenceController extends Zend_Controller_Action
'state' => 'closed',
'children' => $this->getNaf(2, $item['code']),
);
}
}
$this->view->assign('naf', json_encode($tabNaf));
}

View File

@ -1,5 +1,5 @@
<p>Liste des NAF</p>
<div id="naf" class="jstree jstree-default" style="height:300px;width:680px;overflow:auto;">
<div id="<?=$this->key?>" class="jstree jstree-default" style="height:300px;width:680px;overflow:auto;">
</div>
<?=$this->inlineScript()?>
@ -14,11 +14,7 @@ $("#naf").jstree({
"plugins" : ["themes", "json_data", "checkbox", "ui"],
"json_data" : {
"data" : <?=$this->naf?>,
"ajax" : {
"url" : '<?=$this->url(array('controller'=>'arborescence', 'action'=>'nafajax'))?>',
"data" : function(n) { return { parent: n.attr ? n.attr("id") : '' , niveau : n.attr ? n.attr("niveau") : 1 }; },
"cache" : true,
}
}
});
</script>

View File

@ -111,6 +111,31 @@ $(document).ready(function(){
set(key, values);
return false;
});
$('#tabs').delegate('a.arborescence', 'click', function(e) {
e.preventDefault();
var title = $(this).attr('title');
var href = $(this).attr('href');
var dialogOpts = {
bgiframe: true,
title: title,
width: 500,
height: 200,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Annuler: function() { $(this).dialog('close'); }
},
close: function() { $('#dailognaf').remove(); }
};
$('<div id="dailognaf"></div>').dialog(dialogOpts);
return false;
});
});
function set(key, value)