Naf et CJ

This commit is contained in:
Michael RICOIS 2014-08-04 12:30:22 +00:00
parent 1b6df19364
commit 2c1064b425
5 changed files with 115 additions and 10 deletions

View File

@ -13,6 +13,7 @@ $("div#<?=$this->key?>").jstree({
'dataType': 'json',
'data' : function (node) {
var level = 0;
console.log(node.id);
if ( node.id != '#' ) {
console.log(node.li_attr.level);
level = node.li_attr.level ? node.li_attr.level : 0;

View File

@ -14,7 +14,7 @@
'controller'=>'index', 'action'=>'remove', 'critere'=>$critere), null, true)?>" aria-hidden="true">&times;</a>
<strong><?=$item['label']?>:</strong>
<?php if ( $item['in'] == 'Liste' ) { ?>
<a class="itemlist" href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist',
<a class="itemlist" title="<?=$item['label']?>" href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist',
'key'=>$critere), null, true)?>">&Eacute;léments inclus.</a>
<?php } elseif ( !empty($item['in']) ) {?>
<span><?=$item['in']?>.</span>

View File

@ -388,9 +388,16 @@ class Scores_Ciblage_FieldList
'values' => array('1' => 'Oui', '0' => 'Non'),
'activated' => true,
),
'cj' => array(),
'cj' => array(
'label' => "Forme Juridique",
'desc' => "",
'family' => 'juridique',
'type' => array(
'tree' => array( 'label' => 'Arborescence', 'title' => "Choisir dans l'arborescence des Forme Juridiques" ),
'tag' => array( 'label' => 'Recherche' ),
),
'activated' => true,
),
'actifEco' => array(
'label' => "Établissement économiquement actif",
'desc' => "Restreindre la sélection aux établissements économiquement actif/inactifs : Etablissements présumés fermés (vendus sans formalités), Pli Non Distribué (NPAI).",
@ -1092,7 +1099,7 @@ class Scores_Ciblage_FieldList
$structure = array(
'id' => 'R'.$item['REGION'],
'text' => $item['NCCENR'],
'li_attr' => array('data-level' => 1),
'li_attr' => array('level' => 1),
'children' => true,
);
$output[] = $structure;
@ -1113,7 +1120,7 @@ class Scores_Ciblage_FieldList
$structure = array(
'id' => 'D'.$item['numdep'],
'text' => $item['libdep'].' ('.$item['numdep'].')',
'li_attr' => array('data-level' => 2),
'li_attr' => array('level' => 2),
'children' => true,
);
$output[] = $structure;
@ -1221,8 +1228,80 @@ class Scores_Ciblage_FieldList
return $output;
}
public function treeParentNaf()
public function treeParentNaf($code)
{
$codeLength = strlen($code);
if ( $codeLength == 2 ) {
$nafM = new Application_Model_CiblageNaf();
$sql = $nafM->select()->where('code=?', $code);
$result = $nafM->fetchRow($sql);
return array( $result->parent );
} elseif ( $codeLength > 2 ) {
return array( substr($code, $codeLength-1) );
}
return array();
}
public function treeValuesCj($code = null, $level = 0)
{
$level = $level+1;
$fjM = new Application_Model_CiblageFormeJuridique();
$sql = $fjM->select()->order('fjCode ASC');
if ($level>1) {
$sql->where('fjCode LIKE ?', $code.'%');
}
switch($level) {
case 1:
$length = 1;
break;
case 2:
$length = 2;
break;
case 3:
$length = 4;
break;
}
$sql->where('CHAR_LENGTH(fjCode)=?', $length);
Zend_Registry::get('firebug')->info($sql->__toString());
try {
$result = $fjM->fetchAll($sql)->toArray();
} catch (Zend_Db_Exception $e) {
Zend_Registry::get('firebug')->info($e->getMessage());
}
$output = array();
foreach($result as $item)
{
$children = true;
if ( $length==4 ) {
$children = false;
}
$structure = array(
'id' => "".$item['fjCode']."",
'text' => $item['fjLibelle'],
'li_attr' => array('level' => $level),
'children' => $children,
);
$output[] = $structure;
}
return $output;
}
public function treeParentCj($code)
{
$codeLength = strlen($code);
if ( $codeLength == 2 ) {
return array( substr($code, $codeLength-1) );
} elseif ( $codeLength == 4 ) {
return array( substr($code, $codeLength-2) );
}
return array();
}

View File

@ -179,6 +179,7 @@ class Scores_Ciblage_Session
public function getTreeValues($key, $code = null, $level = null)
{
$values = $this->getSelectedValue($key);
$valuesUndetermined = array();
switch ( $key ) {
case 'geo':
@ -229,6 +230,30 @@ class Scores_Ciblage_Session
}
}
break;
case 'cj':
$valuesChecked = $values['in'];
if (count($valuesChecked)>0) {
foreach($valuesChecked as $value) {
$valuesUndetermined = array_merge($valuesUndetermined, $this->fields->treeParentCj($value));
}
}
$staticValues = $this->fields->treeValuesCj($code, $level);
Zend_Registry::get('firebug')->info($valuesChecked);
if ( count($staticValues)>0 ) {
foreach ( $staticValues as $i => $value ) {
if (in_array($value['id'], $valuesChecked)){
$staticValues[$i]['state'] = array('selected' => true);
}
if (in_array($value['id'], $valuesUndetermined)){
$staticValues[$i]['state'] = array('undetermined' => true);
}
}
}
break;
}

View File

@ -7,7 +7,7 @@ $(document).ready(function(){
$('body').on('click', 'a.itemlist', function(e){
e.preventDefault();
var title = 'OOOOOO';
var title = $(this).attr('title');
var href = $(this).attr('href');
var dialogOpts = {
bgiframe: true,
@ -27,7 +27,7 @@ $(document).ready(function(){
return false;
});
$('#extract').on('click', function(){
$('body').on('click', '#extract', function(){
var title = 'Sauvegarde du profil de ciblage';
var href = $(this).attr('href');
var dialogOpts = {
@ -49,7 +49,7 @@ $(document).ready(function(){
return false;
});
$('#preview').on('click', function(e){
$('body').on('click', '#preview', function(e){
e.preventDefault();
var title = 'Prévisualisation de votre ciblage';
var href = $(this).attr('href');