Merge from 1.1

This commit is contained in:
Michael RICOIS 2012-03-27 08:37:46 +00:00
commit 10668fd3f6
10 changed files with 190 additions and 157 deletions

View File

@ -2,45 +2,45 @@
class Object_Codepostaux extends Libs_Row
{
/* Selection des classes statut pour jstree */
public function _jstree_checked()
public function _jstree_checked($type)
{
require_once('Scores/SessionCiblage.php');
$session = new SessionCiblage();
$valeurs = explode(',', $session->getCritere('adr_com'));
foreach ($valeurs as $valeur)
$return[] = $valeur;
if(is_array($return))
$valeurs = explode(',', $session->getCritere($type));
foreach ($valeurs as $valeur) {
if(!empty($valeur)) {
$return[] = $valeur;
}
}
if(is_array($return)) {
return ($return);
}
return (array($valeurs));
}
public function _jstree_undetermined($niveau)
public function _jstree_undetermined($niveau, $type)
{
require_once('Scores/SessionCiblage.php');
$session = new SessionCiblage();
$table = new Table_Departements();
$valeurs = explode(',', $session->getCritere('adr_com'));
$valeurs = explode(',', $session->getCritere($type));
/*$valeurs = array_merge($valeurs, explode(',', $session->getCritere('adr_com')));*/
$in = array();
foreach($valeurs as $valeur) {
$type = explode(':', $valeur);
if($niveau == 0) {
if ($type[0] == 'adr_dept'){
$valeur = $type[1];
if ($type == 'adr_dept'){
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
} else{
$valeur = $type[1];
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
}
} else if ($niveau == 1) {
$valeur = $type[1];
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
@ -52,9 +52,10 @@ class Object_Codepostaux extends Libs_Row
public function _getClass($valeur, $niveau)
{
if(in_array($valeur, $this->_jstree_checked()))
$type = explode(':', $valeur);
if(in_array($type[1], $this->_jstree_checked($type[0])))
return ('jstree-checked');
else if (in_array($valeur, $this->_jstree_undetermined($niveau)))
else if (in_array($valeur, $this->_jstree_undetermined($niveau, $type[0])))
return ('jstree-undetermined');
}
@ -67,7 +68,7 @@ class Object_Codepostaux extends Libs_Row
foreach($regions as $nom) {
$structure[] = array(
'data' => $nom['NCCENR'],
'data' => $nom['REGION'].' '.$nom['NCCENR'],
'attr' => array('id' => 'adr_reg:'.$nom['REGION'],
'niveau' => 0,
'class' => $this->_getClass('adr_reg:'.$nom['REGION'], 0)
@ -76,7 +77,6 @@ class Object_Codepostaux extends Libs_Row
'children' => array()
);
}
return (json_encode($structure));
}

View File

@ -62,36 +62,45 @@ class Object_Comptage extends Libs_Row
require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage();
$sessionValeur = $session->getCritere($key);
$session->setCritere($key, $valeur);
if($valeur[strlen($valeur)] == ',')
$valeur = substr($valeur, 0, strlen($valeur) -1);
if($key == 'vil' or $key == 'adr_reg' or $key == 'adr_dept') {
$key = 'adr_com';
if($session->getCritere('vil')){
$valeurs = explode(',', $session->getCritere('vil'));
foreach($valeurs as $valeur) {
$vil .= 'adr_com:'.trim($valeur).',';
if(in_array($key, array('adr_dept', 'adr_com', 'adr_reg')))
{
$valeurs = explode(',', $valeur);
foreach($valeurs as $valeur)
{
$type = explode(':', $valeur);
if(count($type) == 2) {
$key = $type[0];
$valeur = $type[1];
}
//$vil = substr($vil, 0, strlen($vil)-1);
}
if($session->getCritere('adr_reg')) {
$valeurs = explode(',', $session->getCritere('adr_reg'));
foreach($valeurs as $valeur) {
$reg .= 'adr_reg:'.trim($valeur).',';
switch($key) {
case 'adr_dept':
$dept .= trim($valeur).',';
break;
case 'adr_reg':
$reg .= trim($valeur).',';
break;
case 'adr_com':
case 'vil':
default:
$vil .= trim($valeur).',';
break;
}
//$reg = substr($reg, 0, strlen($reg)-1);
}
if($session->getCritere('adr_dept')) {
$valeurs = explode(',', $session->getCritere('adr_dept'));
foreach($valeurs as $valeur) {
$dept .= 'adr_dept:'.trim($valeur).',';
}
//$dept = substr($dept, 0, strlen($dept)-1);
if(strlen($dept)>0) {
$dept = substr($dept, 0, strlen($dept)-1);
$session->setCritere('adr_dept', $dept);
}
$valeur = $vil.$dept.$reg;
if(strlen($reg)>0) {
$reg = substr($reg, 0, strlen($reg)-1);
$session->setCritere('adr_reg', $reg);
}
if(strlen($vil)>0) {
$vil = substr($vil, 0, strlen($vil)-1);
$session->setCritere('adr_com', $vil);
}
} else
$session->setCritere($key, $valeur);
}
require_once 'Scores/Field.php';
$field = new Fields();

View File

@ -2,14 +2,20 @@
<ul id="fieldsblock">
<li><?php echo $this->Field('adr_com', $this->fields->get('adr_com'));?></li>
<li style="background-image:none;height:80px;">
<?php echo $this->Field('vil', $this->fields->get('adr_com'), 'text');?>
<?php echo $this->Field('vil', $this->fields->get('adr_com'), 'text');?>
</li>
<li style="background-image:none;height:80px;">
<?php echo $this->Field('adr_dept', $this->fields->get('adr_dept'), 'text');?>
<?php echo $this->Field('adr_dept', $this->fields->get('adr_dept'), 'text');?>
</li>
<li style="background-image:none;height:80px;">
<?php echo $this->Field('adr_reg', $this->fields->get('adr_reg'), 'text');?>
<?php echo $this->Field('adr_reg', $this->fields->get('adr_reg'), 'text');?>
</li>
<li><?php echo $this->Field('zus', $this->fields->get('zus'), 'select');?></li>
<li><?php echo $this->Field('zru', $this->fields->get('zru'), 'select');?></li>
<li><?php echo $this->Field('zfu', $this->fields->get('zfu'), 'select');?></li>
<li><?php echo $this->Field('cucs', $this->fields->get('cucs'), 'select');?></li>
<li><?php echo $this->Field('zrr', $this->fields->get('zrr'), 'select');?></li>
<li><?php echo $this->Field('zafr', $this->fields->get('zafr'), 'select');?></li>
</ul>
</div>
<div style="text-align:right;margin-top:20px;">

View File

@ -6,20 +6,12 @@ Class Ciblage
private $sphinx;
private $alpha = '';
private $presentRcs = 0;
private $need;
public $index = 'ciblage';
public $nb_results = 50000;
public $nb_results = 5000;
public $max_results = 500000;
public $mysql_host = '192.168.78.230';
public $mysql_user = 'sphinx';
public $mysql_password = 'indexer';
public $mysql_database = 'jo';
public $sphinx_host = '192.168.78.252';
public $sphinx_port = 3312;
public $sphinx_match = SPH_MATCH_EXTENDED2;
public $sphinx_sort = SPH_SORT_EXTENDED;
@ -36,12 +28,14 @@ Class Ciblage
}
return ($valeur);
}
public function __construct($structure, $need = false)
{
$this->need = true;
$configuration = Zend_Registry::get('configuration');
//Instantiation Sphinx
$this->sphinx = new SphinxClient();
$this->sphinx->SetServer($this->sphinx_host, $this->sphinx_port);
$this->sphinx->SetServer($configuration->sphinx->host, intval($configuration->sphinx->port));
$this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$this->sphinx->ResetFilters();
foreach($structure as $key => $valeur) {
@ -55,8 +49,9 @@ Class Ciblage
}
}
}
/* Provisoir */
//$this->setFilter('bilTca', array(4, 5, 6));
}
public function extract()
{
$resultats = $this->execute(true);
@ -71,14 +66,12 @@ Class Ciblage
);
return $total;
}
public function calculRedevanceInsee()
{
$this->sphinx->SetFilter('presentrcs', array(0));
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
return ($resSphinx['total_found']);
}
protected function getSiret($structure)
{
$siret = array();
@ -88,10 +81,8 @@ Class Ciblage
}
return ($siret);
}
public function execute($need = false)
{
/* Retourne les resultats */
if($need) {
$return = array();
$limit = 0;
@ -107,7 +98,6 @@ Class Ciblage
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
return ($resSphinx['total_found']);
}
protected function setFilter($name, $valeur) {
if(!is_array($valeur)) {
$this->sphinx->SetFilter($name, array(intval($valeur)));
@ -115,43 +105,39 @@ Class Ciblage
$this->sphinx->SetFilter($name, $this->transformIntval($valeur));
}
}
protected function setFilterRange($name, $valeur) {
$this->sphinx->SetFilterRange($name, intval($valeur[0]), intval($valeur[1]));
}
protected function writeRequest($name, $valeur, $or = false) {
$this->alpha .= '@'.$name . '(';
if(!is_array($valeur)) {
if($or and !empty($this->alpha))
$this->alpha .= ' | ';
$this->alpha .= '@'.$name.' '.$valeur.' ';
$this->alpha .= $valeur.')';
} else {
$i = 0;
if($or and !empty($this->alpha))
$this->alpha .= ' | ';
foreach($valeur as $item) {
if($i != 0)
$this->alpha .= ' | ';
$this->alpha .= '@'.$name.' '.$item.' ';
$this->alpha .= $item;
$i++;
}
$this->alpha .= ')';
}
}
protected function setAlpha($name, $valeur)
{
$or = array('bilType');
$and = array('ape_entrep', 'ape_etab', 'age_entrep', 'age_etab', 'NaceEntrep', 'NaceEtab');
}
protected function setAlpha($name, $valeur)
{
$or = array('adr_com', 'adr_dept');
$and = array('bilType', 'ape_etab','ape_entrep', 'NaceEntrep', 'NaceEtab');
if(!empty($this->alpha))
$this->alpha .= ' ';
if(in_array($name, $or)) {
if(!empty($valeur))
$this->writeRequest($name, $valeur, true);
} else if (in_array($name, $and)) {
} else if(in_array($name, $and)) {
if(!empty($valeur))
$this->writeRequest($name, $valeur);
}
}
protected function transformIntval($array) {
$copy = array();
foreach($array as $item => $valeur) {
@ -159,104 +145,83 @@ Class Ciblage
}
return ($copy);
}
protected function dirNom($valeur) {
$this->setFilter('dirNom', $valeur);
}
protected function siege($valeur) {
$this->setFilter('siege', $valeur);
}
protected function adr_com($valeur) {
$this->setFilter('adr_com', $valeur);
$this->setAlpha('adr_com', $valeur);
}
protected function adr_dept($valeur) {
$this->setAlpha('adr_dept', $valeur);
}
protected function action($valeur) {
$this->setFilter('action', $valeur);
}
protected function part($valeur) {
$this->setFilter('part', $valeur);
}
protected function tel($valeur) {
$this->setFilter('tel', $valeur);
}
protected function fax($valeur) {
$this->setFilter('fax', $valeur);
}
protected function cj($valeur) {
$this->setFilter('cj', $valeur);
}
protected function capital($valeur) {
$valeur = $this->setMinMax($name, $valeur);
$this->setFilterRange('capital', $valeur);
}
protected function ape_etab($valeur) {
$this->setAlpha('ape_etab', $valeur);
}
protected function ape_entrep($valeur) {
$this->setAlpha('ape_entrep', $valeur);
}
protected function age_entrep($valeur) {
$this->setAlpha('age_entrep', $valeur);
}
protected function age_etab($valeur) {
$this->setAlpha('age_etab', $valeur);
}
protected function tcaexp($valeur) {
$this->setFilterRange('tcaexp', $valeur);
}
protected function teff_entrep($valeur) {
if($valeur[0] != 0 or $valeur[1] != 0)
$this->setFilterRange('teff_entrep', $valeur);
}
protected function teff_etab($valeur) {
//$valeur = $this->setMinMax($name, $valeur);
$this->setFilterRange('teff_etab', $valeur);
}
protected function rang($valeur) {
$this->setFilterRange('rang', $valeur);
}
protected function actifEco($valeur) {
$this->setFilter('actifEco', $valeur);
}
protected function presentRcs($valeur) {
$this->setFilter('presentRcs', $valeur);
}
protected function procolHisto($valeur) {
$this->setFilter('procolHisto', $valeur);
}
protected function tvaIntraValide($valeur) {
$this->setFilter('tvaIntraValide', $valeur);
}
protected function NaceEtab($valeur) {
$this->setAlpha('NaceEtab', $valeur);
}
protected function NaceEntrep($valeur) {
$this->setAlpha('NaceEntrep', $valeur);
}
protected function dateCrea_etab($valeur) {
if(empty($valeur[0])) {$valeur[0] = date('Ymd');}
if(empty($valeur[1])) {$valeur[1] = date('Ymd');}
@ -274,7 +239,6 @@ Class Ciblage
$this->setFilterRange('dateCrea_etab', $valeur);
}
protected function dateCrea_ent($valeur) {
if(empty($valeur[0])) {$valeur[0] = date('Ymd');}
if(empty($valeur[1])) {$valeur[1] = date('Ymd');}
@ -291,7 +255,6 @@ Class Ciblage
}
$this->setFilterRange('dateCrea_etab', $valeur);
}
protected function dateImmat($valeur) {
if(empty($valeur[0])) {$valeur[0] = date('Ymd');}
if(empty($valeur[1])) {$valeur[1] = date('Ymd');}
@ -308,104 +271,83 @@ Class Ciblage
}
$this->setFilterRange('dateImmat', $valeur);
}
protected function eff_entrep($valeur) {
$valeur = $this->setMinMax($name, $valeur);
$this->setFilter('eff_entrep', $valeur);
}
protected function eff_etab($valeur) {
$valeur = $this->setMinMax($name, $valeur);
$this->setFilter('eff_etab', $valeur);
}
protected function rivoli($valeur) {
$this->setFilter('rivoli', $valeur);
}
protected function nbEtab($valeur) {
$valeur = $this->setMinMax($name, $valeur);
$this->setFilterRange('nbEtab', $valeur);
}
protected function sirenGrp($valeur) {
$this->setFilter('sirenGrp', $valeur);
}
protected function nbActio($valeur) {
$valeur = $this->setMinMax('nbActio', $valeur);
$this->setFilterRange('nbActio', $valeur);
}
protected function nbMPubli($valeur) {
$this->setFilter('nbMPubli', $valeur);
}
protected function nbPart($valeur) {
$valeur = $this->setMinMax('nbPart', $valeur);
$this->setFilterRange('nbPart', $valeur);
}
protected function bilDuree($valeur) {
$this->setFilterRange('bilDuree', $valeur);
}
protected function bilType($valeur) {
$this->setAlpha('bilType', $valeur);
}
protected function bilAnnee($valeur) {
$this->setFilter('bilAnnee', $valeur);
}
protected function bilTca($valeur) {
$this->setFilter('bilTca', $valeur);
}
protected function bilEE($valeur) {
$valeur = $this->setMinMax('bilEE', $valeur);
$this->setFilterRange('bilEE', $valeur);
}
protected function bilFL($valeur) {
$valeur = $this->setMinMax('bilFL', $valeur);
$this->setFilterRange('bilFL', $valeur);
}
protected function bilFK($valeur) {
$valeur = $this->setMinMax('bilFK', $valeur);
$this->setFilterRange('bilFK', $valeur);
}
protected function bilFR($valeur) {
$valeur = $this->setMinMax('bilFR', $valeur);
$this->setFilterRange('bilFR', $valeur);
}
protected function bilGF($valeur) {
$valeur = $this->setMinMax('bilGF', $valeur);
$this->setFilterRange('bilGF', $valeur);
}
protected function bilGP($valeur) {
$valeur = $this->setMinMax('bilGP', $valeur);
$this->setFilterRange('bilGP', $valeur);
}
protected function bilGU($valeur) {
$valeur = $this->setMinMax('bilGU', $valeur);
$this->setFilterRange('bilGU', $valeur);
}
protected function bilGW($valeur) {
$valeur = $this->setMinMax('bilGW', $valeur);
$this->setFilterRange('bilGW', $valeur);
}
protected function bilHD($valeur) {
$valeur = $this->setMinMax('bilHD', $valeur);
$this->setFilterRange('bilHD', $valeur);
@ -479,7 +421,6 @@ Class Ciblage
$valeur[0] = $format1[2].$format1[1].$format1[0];
$valeur[1] = $format2[2].$format2[1].$format2[0];
}
//print_r($valeur);
$this->setFilterRange('bilCloture', $valeur);
}
}

View File

@ -380,12 +380,12 @@ Class Fields
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => '',
'action' => 'geographique',
'title' => 'Localisation'
),
'adr_reg' => array(
@ -393,14 +393,68 @@ Class Fields
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => '',
'action' => 'geographique',
'title' => 'Localisation'
),
'zus' => array(
'label' => 'Zones urbaines sensibles',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
'zru' => array(
'label' => 'Zones de redynamisation urbaine',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
'zfu' => array(
'label' => 'zones franches urbaines',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
'cucs' => array(
'label' => 'Contrats urbains de cohésion sociale',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
'zrr' => array(
'label' => 'Zone de revitalisation rurale',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
'zafr' => array(
'label' => 'Zones Aide à finalité régionale',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'geographique',
'activated' => true,
'type' => 'select',
),
//juridique
'cj' => array(
'label' => 'Forme Juridique',
@ -684,25 +738,24 @@ Class Fields
$val = $session->getCriteres();
}
$values = array();
unset($val['vil']);
foreach($val as $key => $item)
{
if($item != '') {
if($this->fields[$key]['type'] == 'interval' or
$this->fields[$key]['type'] == 'intervalSelect' or
if( $this->fields[$key]['type'] == 'interval' or
$this->fields[$key]['type'] == 'intervalSelect' or
$this->fields[$key]['type'] == 'textarea' and
empty($this->fields[$key]['action']))
{
$values[$key] = explode(',', $item);
} else if (!empty($this->fields[$key]['action'])) {
if($key == 'adr_reg' or $key == 'adr_dept') {
$key = 'adr_com';
}
if(!empty($values[$key])) {
$values[$key] = array_merge($this->selectArbo($key, $item), $values[$key]);
}
else {
$values[$key] = $this->selectArbo($key, $item);
if($key == 'adr_reg')
$values['adr_dept'] = $this->selectArbo($key, $item);
else
$values[$key] = $this->selectArbo($key, $item);
}
} else {
$values[$key] = $item;
@ -714,7 +767,7 @@ Class Fields
public function selectArbo($name, $valeur)
{
$values = array();
$values = array();
switch($name)
{
case 'ape_etab' :
@ -733,7 +786,15 @@ Class Fields
foreach($valeurs as $element) {
if(!empty($element)) {
$val = explode(':', $element);
$array = array_diff($this->localisationArbo($val[0], $val[1]), $values);
if(count($val)>1) {
$diff = $this->localisationArbo($val[0], $val[1]);
if(!empty($diff))
$array = array_diff($diff, $values);
} else if(!empty($element)) {
$diff = $this->localisationArbo($name, $element);
if(!empty($diff))
$array = array_diff($diff, $values);
}
if(!empty($array)) {
$values = array_merge($values, $array);
}
@ -778,26 +839,15 @@ Class Fields
$table = new Table_Departements();
$sql = $table->select()
->from('departements')
->join(array('cp' => 'codepostaux'), 'cp.codepos LIKE CONCAT(departements.numdep, "%")', array('INSEE'))
->where('codeRegionInsee ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $res) {
$return[] = trim($res['INSEE']);
$return[] = trim($res['numdep']);
}
break;
case 'adr_dept':
$table = new Table_Departements();
$sql = $table->select()
->from('departements')
->join(array('cp' => 'codepostaux'), 'cp.codepos LIKE CONCAT(departements.numdep, "%")', array('INSEE'))
->where('numdep ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $res) {
$return[] = trim($res['INSEE']);
}
return (array($valeur));
break;
}
} else
@ -829,7 +879,7 @@ Class Fields
}
return ($value);
}
public function __construct($batch = false)
{
if(!$batch) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

View File

@ -180,6 +180,28 @@ $(document).ready(function()
}
});
});
$('.saveciblage').on('click', function(){
var title = 'Sauvegarde du profil de ciblage';
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() { $('#dialogsaveciblage').remove(); }
};
$('<div id="dialogsaveciblage"></div>').dialog(dialogOpts);
return false;
});
});
function set(key, value)

View File

@ -45,7 +45,8 @@
#entreprise select
{
width:265px;
width:265px;
border:1px solid silver;
}
.resetFamille

View File

@ -4,8 +4,12 @@
text-shadow: 1px 1px 1px white;
}
#geographique select {
width:70%;
}
#geographique li {
height:30px;
height:20px;
padding:5px;
border:1px solid silver;
margin-top:2px;