2012-02-02 17:29:14 +00:00
|
|
|
<?php
|
|
|
|
class Object_Formejuridique extends Libs_Row
|
|
|
|
{
|
2012-02-16 08:18:18 +00:00
|
|
|
protected function _jstree_checked()
|
|
|
|
{
|
|
|
|
require_once('Scores/SessionCiblage.php');
|
|
|
|
$session = new SessionCiblage();
|
|
|
|
$valeurs = explode(',', $session->getCritere('cj'));
|
|
|
|
|
|
|
|
foreach($valeurs as $valeur) {
|
2012-02-16 10:03:24 +00:00
|
|
|
if($valeur != '')
|
|
|
|
$return[] = $valeur;
|
2012-02-16 08:18:18 +00:00
|
|
|
}
|
|
|
|
if(is_array($return))
|
|
|
|
return ($return);
|
|
|
|
return (array($valeurs));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function _jstree_undetermined()
|
|
|
|
{
|
|
|
|
return (array());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function _getClass($valeur)
|
|
|
|
{
|
|
|
|
if(in_array($valeur, $this->_jstree_checked()))
|
|
|
|
return ('jstree-checked');
|
|
|
|
else if (in_array($valeur, $this->_jstree_undetermined()))
|
|
|
|
return ('jstree-undetermined');
|
|
|
|
}
|
|
|
|
|
2012-02-15 09:25:21 +00:00
|
|
|
public function _getParents()
|
|
|
|
{
|
|
|
|
$formes = new Table_Formejuridiques();
|
|
|
|
$formes = $formes->fetchAll($formes->select()->where('LENGTH(fjCode) = 1'))->toArray();
|
|
|
|
$structure = array();
|
|
|
|
|
|
|
|
foreach($formes as $forme) {
|
|
|
|
$structure[] = array(
|
|
|
|
'data' => $forme['fjCode'].' : '.$forme['fjLibelle'],
|
2012-02-16 08:18:18 +00:00
|
|
|
'attr' => array('id' => $forme['fjCode'],
|
|
|
|
'class' => $this->_getClass($forme['fjCode'])),
|
2012-02-15 09:25:21 +00:00
|
|
|
'state' => 'closed',
|
2012-02-16 08:18:18 +00:00
|
|
|
'children' => array($this->_getFils($forme['fjCode'])),
|
|
|
|
);
|
2012-02-15 09:25:21 +00:00
|
|
|
}
|
|
|
|
return (json_encode($structure));
|
|
|
|
}
|
2012-02-02 17:29:14 +00:00
|
|
|
|
2012-02-15 09:25:21 +00:00
|
|
|
public function _getFils($fjcode)
|
|
|
|
{
|
|
|
|
$lenth = ((strlen($fjcode) == 2)?4:2);
|
|
|
|
$formes = new Table_Formejuridiques();
|
|
|
|
$sql = $formes->select()->from('formejuridique', array(
|
|
|
|
'size' => new Zend_Db_Expr('LENGTH(fjCode)'),
|
|
|
|
'fjCode',
|
|
|
|
'fjLibelle'))
|
|
|
|
->where('fjCode LIKE "'.$fjcode.'%"')
|
|
|
|
->having('size = ?', $lenth);
|
|
|
|
$formes = $formes->fetchAll($sql)->toArray();
|
|
|
|
$structure = array();
|
|
|
|
foreach($formes as $forme) {
|
|
|
|
$structure = array(
|
|
|
|
'data' => $forme['fjCode'].' : '.$forme['fjLibelle'],
|
2012-02-16 08:18:18 +00:00
|
|
|
'attr' => array('id' => $forme['fjCode'],
|
|
|
|
'class' => $this->_getClass($forme['fjCode'])),
|
2012-02-15 09:25:21 +00:00
|
|
|
'state' => 'close',
|
|
|
|
'children' => (($lenth < 6)?$this->_getFils($forme['fjCode']):array())
|
|
|
|
);
|
|
|
|
$tabfj[] = $structure;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($tabfj);
|
|
|
|
}
|
2012-02-02 17:29:14 +00:00
|
|
|
}
|