Fields update

This commit is contained in:
Michael RICOIS 2014-07-04 07:36:07 +00:00
parent c0a378c276
commit fd50f7ce6c
22 changed files with 580 additions and 3010 deletions

View File

@ -34,6 +34,26 @@ class FieldsController extends Zend_Controller_Action
}
}
public function tagAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$name = $request->getParam('name');
$scoresFields = new Scores_Ciblage_FieldList();
$result = $scoresFields->getItemValues($name);
$values = array();
foreach ( $result as $k => $v ) {
$values[] = array(
'label' => $v,
'value' => $k,
);
}
$this->view->values = $values;
}
/**
* Manage autocomplete
*/

View File

@ -57,22 +57,46 @@ class IndexController extends Zend_Controller_Action
$inValue = $valueSelected['in'];
$exValue = $valueSelected['ex'];
$inLabel = array();
if ( count($inValue)>0 ) {
foreach ( $inValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$inLabel[] = $params['values'][$value];
}
}
}
if ( $params['type'] == 'one' ) {
$exLabel = array();
if ( count($exValue)>0 ) {
foreach ( $exValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$exLabel[] = $params['values'][$value];
}
$inLabel = '';
if ( count($inValue)>0 ) {
foreach ( $inValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$inLabel = $params['values'][$value];
}
}
}
$exLabel = '';
if ( count($exValue)>0 ) {
foreach ( $exValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$exLabel = $params['values'][$value];
}
}
}
} else {
$inLabel = array();
if ( count($inValue)>0 ) {
foreach ( $inValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$inLabel[] = $params['values'][$value];
}
}
}
$exLabel = array();
if ( count($exValue)>0 ) {
foreach ( $exValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$exLabel[] = $params['values'][$value];
}
}
}
}
$infosCriteres[$key] = array(
@ -127,10 +151,8 @@ class IndexController extends Zend_Controller_Action
$this->view->assign('exValues', $exValue);
}
}
}
public function removeAction()
{
$this->_helper->layout()->disableLayout();

View File

@ -3,11 +3,12 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
{
public function Field($name)
{
$field = new Scores_Ciblage_FieldList();
$fields = new Scores_Ciblage_FieldList();
//@todo : Get valueSeclected from session
$sessionValue = new Scores_Ciblage_Session($fields);
$valueSelected = $sessionValue->getSelectedValues();
$html = $field->getItemHtml($name);
$html = $fields->getItemHtml($name, $valueSelected);
if ($html) {
return $html;

View File

@ -0,0 +1 @@
<?=json_encode($this->values)?>

View File

@ -10,13 +10,15 @@
<?php if ( count($this->infos)>0 ) {?>
<?php foreach($this->infos as $critere => $item) {?>
<div class="alert alert-info">
<a class="close" data-dismiss="alert" href="<?=$this->url(array('controller'=>'index', 'action'=>'remove', 'critere'=>$critere), null, true)?>" aria-hidden="true">&times;</a>
<a class="close" data-dismiss="alert" href="<?=$this->url(array(
'controller'=>'index', 'action'=>'remove', 'critere'=>$critere), null, true)?>" aria-hidden="true">&times;</a>
<div style='font-weight: 700;'><?=$item['label']?>:</div>
<?php if ( is_string($item['in']) && !empty($item['in']) ) {?>
<p>&nbsp;&nbsp;<?=$item['in']?>
<p>&nbsp;&nbsp;<?=$item['in']?></p>
<?php } elseif ( is_array($item['in']) || is_array($item['ex']) ) {?>
&nbsp;&nbsp;<a class="criterelist" title="<?=$item['label']?>" href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist', 'key'=>$critere), null, true)?>">Liste</a>
<?php }?></p>
<p>&nbsp;&nbsp;<a class="criterelist" title="<?=$item['label']?>" href="<?=$this->url(array(
'controller'=>'index', 'action'=>'criterelist', 'key'=>$critere), null, true)?>">Liste</a></p>
<?php }?>
</div>
<?php }?>
<?php } else {?><div class="alert alert-warning">Aucune sélection.</div><?}?>

View File

@ -72,7 +72,6 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
//@todo : add service from WebService
->order('dateContrat DESC')->limit(1);
Zend_Registry::get('firebug')->info($sql->__toString());
$params = $paramsM->fetchAll($sql)->toArray();
if (count($params)>0) {
$identity->filterRNCS = $params[0]['filterRNCS'];

File diff suppressed because it is too large Load Diff

View File

@ -18,8 +18,7 @@ class Scores_Ciblage_Field_List
public function getHTML($valueSelected = array())
{
$html = '<div class="row">' .
'<div class="col-md-10">' .
'<div class="btn-group criteres" name="'.$this->name.'">';
'<div class="col-md-10">';
$valueTxt = '';
if ( count($valueSelected)>0 ) {
@ -33,11 +32,11 @@ class Scores_Ciblage_Field_List
}
$html.= '<textarea class="form-control" rows="3" name="'.$this->name.'">';
$html.= $valueTxt;
$html.= '</textarea>';
$html.= '</textarea>'.
'</div>';
$html.= '<div class="col-md-2">' .
'<button class="btn btn-primary btn-sm pull-right" type="button">Sélectionner</button>' .
'</div>'.
'</div>'.
'</div>';
return $html;
}

View File

@ -17,7 +17,7 @@ class Scores_Ciblage_Field_Many
public function getHTML($valueSelected = array())
{
$html = '<div class="row">' .
$html = '<div class="row ciblage-many">' .
'<div class="col-md-10">';
if ( count($this->data)>0 ) {
$html.= '<select multiple class="form-control" name="'.$this->name.'">';
@ -32,7 +32,7 @@ class Scores_Ciblage_Field_Many
}
$html.= '</div>'.
'<div class="col-md-2">' .
'<button class="btn btn-primary btn-sm" type="button">Sélectionner</button>' .
'<button class="btn btn-primary btn-sm" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
'</div>'.
'</div>';
return $html;

View File

@ -17,7 +17,7 @@ class Scores_Ciblage_Field_One
public function getHTML($valueSelected = '')
{
$html = '<div class="btn-group critere-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
$html = '<div class="btn-group ciblage-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
if ( count($this->data)>0 ) {
foreach ( $this->data as $value => $label ) {
$active = '';

View File

@ -17,15 +17,19 @@ class Scores_Ciblage_Field_Range
public function getHTML($valueSelected = array())
{
$html = '<div class="col-md-10">';
$html = '<div class="row ciblage-range">'.
'<div class="col-md-10">';
if ( count($this->data)>0 ) {
if ( count($valueSelected)==0 ) {
if ( $valueSelected === null || count($valueSelected)==0 ) {
$valueSelected = $this->data;
}
Zend_Registry::get('firebug')->info('Range');
Zend_Registry::get('firebug')->info($valueSelected);
$html.= '<b style="margin:0 15px">'.number_format($this->data['min'], 0, ',', ' ').'</b>'.
'<input id="slider_'.$this->name.'" type="text" class="span2" value=""
'<input id="slider-'.$this->name.'" type="text" class="span2" value=""
data-slider-min="'.$this->data['min'].'"
data-slider-max="'.$this->data['max'].'"
data-slider-step="1"
@ -34,14 +38,15 @@ class Scores_Ciblage_Field_Range
}
$html.= '</div>'.
'<div class="col-md-2">' .
'<button class="btn btn-primary btn-sm pull-right" type="button">Sélectionner</button>' .
'<button class="btn btn-primary btn-sm pull-right" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
'</div>'.
'</div>';
return $html;
}
public function getJS()
{
return '$("#slider_'.$this->name.'").slider({});';
return '$("#slider-'.$this->name.'").slider({});';
}
}

View File

@ -1,5 +1,37 @@
<?php
class Scores_Ciblage_Field_Search
{
protected $name = null;
protected $data = null;
/**
*
* @param string $name
* @param array $data
*/
public function __construct($name, $data)
{
$this->name = $name;
$this->data = $data;
}
public function getHTML($valueSelected = '')
{
$html = '<div class="btn-group critere-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
if ( count($this->data)>0 ) {
foreach ( $this->data as $value => $label ) {
$active = '';
if( $valueSelected === $value ) {
$active = ' active';
}
$html.= '<label class="btn btn-primary btn-sm'.$active.'">'.
'<input type="radio" name="'.$this->name.'" value="'.$value.'">'.$label.
'</label>';
}
}
$html .= '</div>';
return $html;
}
}

View File

@ -0,0 +1,43 @@
<?php
class Scores_Ciblage_Field_Tag
{
protected $name = null;
protected $data = null;
/**
*
* @param string $name
* @param array $data
*/
public function __construct($name, $data)
{
$this->name = $name;
$this->data = $data;
}
public function getHTML($valueSelected = '')
{
$html = '<div class="row ciblage-tag">' .
'<div class="col-md-2">';
$html.= '<input class="tags" type="text" data-url="/fields/tag/name/'.$this->name.'" value=""/>';
$html.= '</div>'.
'<div class="col-md-8">' . '</div>' .
'<div class="col-md-2">' .
'<button class="btn btn-primary btn-sm" type="button" data-ciblagename="'.$this->name.'">Ajouter</button>' .
'</div>'.
'</div>';
return $html;
}
}

View File

@ -1,5 +1,37 @@
<?php
class Scores_Ciblage_Field_Tree
{
protected $name = null;
protected $data = null;
/**
*
* @param string $name
* @param array $data
*/
public function __construct($name, $data)
{
$this->name = $name;
$this->data = $data;
}
public function getHTML($valueSelected = '')
{
$html = '<div class="btn-group critere-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
if ( count($this->data)>0 ) {
foreach ( $this->data as $value => $label ) {
$active = '';
if( $valueSelected === $value ) {
$active = ' active';
}
$html.= '<label class="btn btn-primary btn-sm'.$active.'">'.
'<input type="radio" name="'.$this->name.'" value="'.$value.'">'.$label.
'</label>';
}
}
$html .= '</div>';
return $html;
}
}

View File

@ -140,10 +140,17 @@ class Scores_Ciblage_FieldList
'minmax' => 'number',
'activated' => true,
),
'ape_etab' => array(),
'ape_entrep' => array(),
'NaceEtab' => array(),
'NaceEntrep' => array(),
'age_etab' => array(
'label' => "Age de l'établissement",
'desc' => "Restreindre la sélection suivant l'age des établissements.",
@ -242,14 +249,94 @@ class Scores_Ciblage_FieldList
'minmax' => 'number',
'activated' => true,
),
'geo' => array(),
'geo_domtom' => array(),
'geo_etranger' => array(),
'geo_corse' => array(),
'codesinsee' => array(),
'codespostaux' => array(),
'codesdepts' => array(),
'adr_reg' => array(),
'geo' => array(
'label' => "Localisation géographique",
'desc' => "",
'family' => 'geographique',
'type' => array(
'tree' => array( 'label' => 'Arborescence' ),
'tag' => array( 'label' => 'Recherche' ),
),
/*'sql' => array(
'columns' => array('Commune AS label', 'INSEE AS value'),
'table' => 'fields_codepostaux',
),*/
'activated' => true,
),
'geo_domtom' => array(
'label' => "Exclure les DOM-TOM",
'desc' => "Exclure les établissements situés dans les DOM-TOM",
'family' => 'geographique',
'type' => 'one',
'values' => array('1' => 'Exclure'),
'activated' => true,
),
'geo_etranger' => array(
'label' => "Exclure les sociétés étrangères",
'desc' => "Exclure les entreprises dont l'établissement siège est situé à l'étranger",
'family' => 'geographique',
'type' => 'one',
'values' => array('1' => 'Exclure'),
'activated' => true,
),
'geo_corse' => array(
'label' => "Exclure la corse",
'desc' => "Exclure les établissements situés en région Corse",
'family' => 'geographique',
'type' => 'one',
'values' => array('1' => 'Exclure'),
'activated' => true,
),
'codesinsee' => array(
'label' => "Liste de codes communes Insee",
'desc' => "Liste de codes communes Insee séparés par des virgules ou des points-virgules",
'family' => 'geographique',
'type' => 'list',
'sql' => array(
'columns' => array('Commune AS label', 'INSEE AS value'),
'table' => 'fields_codepostaux',
),
'activated' => true,
),
'codespostaux' => array(
'label' => "Liste de codes postaux",
'desc' => "Liste de codes postaux séparés par des virgules ou des points-virgules",
'family' => 'geographique',
'type' => 'list',
'sql' => array(
'columns' => array('Commune AS label', 'Codepos AS value'),
'table' => 'fields_codepostaux',
),
'activated' => true,
),
'codesdepts' => array(
'label' => "Liste de départements",
'desc' => "Liste de code départements séparés par des virgules ou des points-virgules",
'family' => 'geographique',
'type' => 'list',
'sql' => array(
'columns' => array('libdep AS label', 'numdep AS value'),
'table' => 'fields_departements',
),
'activated' => true,
),
'adr_reg' => array(
'label' => "Liste de régions",
'desc' => "Liste de régions",
'family' => 'geographique',
'type' => 'tag',
'sql' => array(
'columns' => array('NCCENR AS label', 'REGION AS value'),
'table' => 'fields_regions',
),
'activated' => true,
),
'zus' => array(
'label' => "Zones Urbaines Sensibles",
'desc' => "Restreindre la sélection aux établissements situés en Zone Urbaine Sensible (ou ZUS). Les ZUS sont des territoire infra-urbain défini par les pouvoirs publics français bénéficiant d'aides spécifiques sous forme d'exonérations fiscales et sociales.",
@ -548,48 +635,62 @@ class Scores_Ciblage_FieldList
$html = '<div class="panel panel-info">';
$html.= '<div class="panel-heading">'.$this->items[$name]['label'].'</div>';
//Bloc content
$htmlfield = '';
switch ($type) {
case 'list':
$field = new Scores_Ciblage_Field_List($name, $values);
break;
case 'many':
$field = new Scores_Ciblage_Field_Many($name, $values);
break;
case 'one':
$field = new Scores_Ciblage_Field_One($name, $values);
break;
case 'range':
$field = new Scores_Ciblage_Field_Range($name, $values);
break;
case 'rangedate':
$field = new Scores_Ciblage_Field_RangeDate($name, $values);
break;
case 'search':
$field = new Scores_Ciblage_Field_Search($name, $values);
break;
case 'tree':
$field = new Scores_Ciblage_Field_Tree($name, $values);
break;
}
if ( is_array($type) ) {
$htmlfield = $field->getHTML($valueSelected);
$html.= '<div class="panel-body">' . $htmlfield . '</div>';
if ( method_exists($field, 'getJS') ) {
$html.= '<script>'.$field->getJS().'</script>';
} else {
//Bloc content
$htmlfield = '';
switch ($type) {
case 'list':
$field = new Scores_Ciblage_Field_List($name, $values);
break;
case 'many':
$field = new Scores_Ciblage_Field_Many($name, $values);
break;
case 'one':
$field = new Scores_Ciblage_Field_One($name, $values);
break;
case 'range':
$field = new Scores_Ciblage_Field_Range($name, $values);
break;
case 'rangedate':
$field = new Scores_Ciblage_Field_RangeDate($name, $values);
break;
case 'search':
$field = new Scores_Ciblage_Field_Search($name, $values);
break;
case 'tree':
$field = new Scores_Ciblage_Field_Tree($name, $values);
break;
case 'tag':
$field = new Scores_Ciblage_Field_Tag($name, $values);
break;
}
$htmlfield = $field->getHTML($valueSelected);
$html.= '<div class="panel-body">' . $htmlfield . '</div>';
if ( method_exists($field, 'getJS') ) {
$html.= '<script>'.$field->getJS().'</script>';
}
}
//Bloc footer
$html.= '<div class="panel-footer"><small class="text-justify">' . $this->items[$name]['desc'] . '</small></div>';
$html.= '</div>';
return $html;
}
public function getItemsStruct()
{
return $this->items;
}
public function getItemsByFamily($family)
{
return $this->__items(false, $family);
@ -618,6 +719,7 @@ class Scores_Ciblage_FieldList
$item['label'] = $info['label'];
$item['desc'] = $info['desc'];
$item['type'] = $info['type'];
if ( $withValues ) {
$item['values'] = $this->getItemValues($key);
@ -647,7 +749,6 @@ class Scores_Ciblage_FieldList
//Override info with values from getMinMax
if ( array_key_exists('minmax', $info) ) {
Zend_Registry::get('firebug')->info('minmax');
$values = $this->getMinMax($key);
}
@ -670,22 +771,36 @@ class Scores_Ciblage_FieldList
$minmaxType = $info['minmax'];
if ( is_array($minmaxType) ) {
return $minmaxType;
} else {
//@todo : Faire fichier de cache des minmax
$valuesM = new Application_Model_CiblageMinMax();
$sql = $valuesM->select()->where('cle=?', $key);
try {
$result = $valuesM->fetchRow($sql);
if ($result !== null) {
return array(
'min' => $result->min,
'max' => $result->max,
);
$cacheFile = APPLICATION_PATH . '/../library/Scores/Table/' . $key . '.php';
if ( file_exists($cacheFile) ) {
$values = include $cacheFile;
if ( is_array($values) ) {
return $values;
}
} catch(Zend_Db_Exception $e) {
} else {
//@todo : Faire fichier de cache des minmax
$valuesM = new Application_Model_CiblageMinMax();
$sql = $valuesM->select()->where('cle=?', $key);
try {
$result = $valuesM->fetchRow($sql);
if ($result !== null) {
return array(
'min' => $result->min,
'max' => $result->max,
);
}
} catch(Zend_Db_Exception $e) {}
}
}
return array();
@ -693,6 +808,35 @@ class Scores_Ciblage_FieldList
protected function getDbValues($key)
{
$info = $this->items[$key];
$columns = $info['sql']['columns'];
$table = $info['sql']['table'];
$cacheFile = APPLICATION_PATH . '/../library/Scores/Table/' . $key . '.php';
if ( file_exists($cacheFile) ) {
$values = include $cacheFile;
if ( is_array($values) ) {
return $values;
}
} else {
$db = Zend_Db_Table::getDefaultAdapter();
$sql = $db->select()->from($table, $columns, 'ciblage');
try {
$values = array();
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
if ( count($result)>0 ) {
foreach ($result as $item) {
$values[$item->value] = $item->label;
}
}
return $values;
} catch(Zend_Db_Exception $e) {}
}
return array();
}

View File

@ -79,38 +79,33 @@ class Scores_Ciblage_Session
$valueToSave = null;
//Prepare data
if ( is_array($value) ) {
foreach ( $value as $item ) {
if ( in_array($item, $staticValues) ) {
$valueToSave[] = $item;
}
}
} else {
if ( in_array($value, $staticValues) ) {
$valueToSave = array($value);
} else {
return false;
}
}
//Prepare to save date in session
if ( $valueToSave !== null ) {
//Save the value
if ($ex) {
Zend_Registry::get('firebug')->info('Exclude : ');
Zend_Registry::get('firebug')->info($value);
$this->ciblage->select[$key]['ex'] = $value;
Zend_Registry::get('firebug')->info('Exclude');
Zend_Registry::get('firebug')->info($valueToSave);
$this->ciblage->select[$key]['ex'] = $valueToSave;
} else {
Zend_Registry::get('firebug')->info('Include: ');
Zend_Registry::get('firebug')->info($value);
$this->ciblage->select[$key]['in'] = $value;
Zend_Registry::get('firebug')->info('Include');
Zend_Registry::get('firebug')->info($valueToSave);
$this->ciblage->select[$key]['in'] = $valueToSave;
}
return true;
}

View File

@ -1,298 +0,0 @@
<?php
class Enrichissement
{
/**
* Déclaration des champs exportable
* @var array
*/
protected $fields = array(
'siege' => array(
'label' => "Type d'établissement",
'column' => 'siege',
'values' => array(
'1' => "Etablissement Siege",
'0' => "Etablissement Secondaire",
),
),
'raisonSociale' => array(
'label' => "Raison Sociale",
'column' => 'raisonSociale'
),
'enseigne' => array(
'label' => "Enseigne",
'column' => 'enseigne'
),
'sigle' => array(
'label' => "Sigle",
'column' => 'sigle'
),
'identite_pre' => array(
'label' => "Identite Précédente",
'column' => 'identite_pre'
),
'marques' => array(
'label' => "Marques déposées",
'column' => 'marques'
),
'adresse' => array(
'label' => 'Adresse',
'column' => 'adresse',
'sql' => "CONCAT_WS(' ', adr_num, adr_btq, adr_typeVoie, adr_libVoie) as adresse",
),
'adr_comp' => array(
'label' => 'Adresse - Complément',
'column' => 'adr_comp',
),
'codepostal' => array(
'label' => 'Code Postal',
'column' => 'adr_cp',
),
'departement' => array(
'label' => 'Département',
'column' => 'adr_dep',
),
'ville' => array(
'label' => 'Ville',
'column' => 'adr_ville',
),
'codecommune' => array(
'label' => 'Code Commune',
'column' => 'codecom',
'sql' => 'CONCAT(adr_dep, adr_com) as codecom',
),
'tel' => array(
'label' => "Téléphone",
'column' => 'tel' ,
'sql' => 'LPAD(tel, 10, 0000000000) AS tel'
),
'fax' => array(
'label' => "Fax",
'column' => 'fax',
'sql' => 'LPAD(fax, 10, 0000000000) AS fax'
),
'cj' => array(
'label' => "Code Forme juridique",
'column' => 'cj',
'join' => array(
'label' => 'Forme juridique',
'column' => 'libelle',
'table' => 'jo.tabFJur',
'cond' => 'jo.etablissements_act.cj = cjL.code'
)
),
'dirigeant' => array(
'label' => "Dirigeant",
'column' => 'dirigeant',
'sql' => "CONCAT_WS(' ', dirCiv, dirNom, dirPrenom) AS dirigeant",
),
'dirigeantFct' => array(
'label' => "Dirigeant - Code Fonction",
'column' => 'dirFct',
'join' => array(
'label' => 'Dirigeant - Libelle Fonction',
'column' => 'libelle',
'table' => 'jo.bodacc_fonctions',
'cond' => 'jo.etablissements_act.dirFct = dirigeantFctL.codeFct')
),
'dirigeantnaiss' => array(
'label' => "Dirigeant - Date de naissance",
'column' => 'dirDateNaiss'
),
'nafetablissement' => array(
'label' => "Code NAF Etablissement",
'column' => 'ape_etab',
'join' => array(
'label' => 'NAF Etablissement - Libelle',
'column' => 'libNaf5',
'table' => 'jo.tabNaf5',
'cond' => 'jo.etablissements_act.ape_etab = nafetablissementL.codNaf5')
),
'nafentreprise' => array(
'label' => "Code NAF Entreprise",
'column' => 'ape_entrep',
'join' => array(
'label' => 'NAF Entreprise - Libelle',
'column' => 'libNaf5',
'table' => 'jo.tabNaf5',
'cond' => 'jo.etablissements_act.ape_entrep = nafentrepriseL.codNaf5')
),
'effetablissement' => array(
'label' => "Effectif Etablissement",
'column' => 'eff_etab'
),
'effentreprise' => array(
'label' => "Effectif Entreprise",
'column' => 'eff_entrep'
),
'teffetablissement' => array(
'label' => "Code Tranche Effectif Etablissement",
'column' => 'teff_etab',
'values' => array(
'NN' => "Unités non employeuses", //@todo : a vérifier NULL dans la base
'0' => "0 salarié",
'1' => "1 ou 2 salariés",
'2' => "3 à 5 salariés",
'3' => "6 à 9 salariés",
'11' => "10 à 19 salariés",
'12' => "20 à 49 salariés",
'21' => "50 à 99 salariés",
'22' => "100 à 199 salariés",
'31' => "200 à 249 salariés",
'32' => "250 à 499 salariés",
'41' => "500 à 999 salariés",
'42' => "1 000 à 1 999 salariés",
'51' => "2 000 à 4 999 salariés",
'52' => "5 000 à 9 999 salariés",
'53' => "10 000 salariés et plus",
),
),
'teffentreprise' => array(
'label' => "Code Tranche Effectif Entreprise",
'column' => 'teff_entrep',
'values' => array(
'NN' => "Unités non employeuses", //@todo : a vérifier NULL dans la base
'0' => "0 salarié",
'1' => "1 ou 2 salariés",
'2' => "3 à 5 salariés",
'3' => "6 à 9 salariés",
'11' => "10 à 19 salariés",
'12' => "20 à 49 salariés",
'21' => "50 à 99 salariés",
'22' => "100 à 199 salariés",
'31' => "200 à 249 salariés",
'32' => "250 à 499 salariés",
'41' => "500 à 999 salariés",
'42' => "1 000 à 1 999 salariés",
'51' => "2 000 à 4 999 salariés",
'52' => "5 000 à 9 999 salariés",
'53' => "10 000 salariés et plus",
),
),
'capital' => array(
'label' => "Capital",
'column' => 'capital'
),
'capitaldev' => array(
'label' => "Devise Capital",
'column' => 'capitalDev'
),
'ageentrep' => array(
'label' => "Age de l'entreprise",
'column' => 'age_entrep'
),
'ageetab' => array(
'label' => "Age de l'établissement",
'column' => 'age_etab'
),
//autre_id
//capital
//tca
//tcaexp
'nomcommercial' => array(
'label' => "Nom commercial",
'column' => 'nomCommercial',
),
'siteweb' => array(
'label' => "Site web",
'column' => 'web',
),
'mail' => array(
'label' => "Adresse email",
'column' => 'mail',
),
//adrDom
//lieuAct
//explen
//explet
//actifEco
//procolHisto
//tvaIntraCle
//ape4_etab
//ape4_entrep
//NaceEtab
//NaceEntrep
//dateCrea_etab
//dateCrea_ent
//dateImmat
//distSP
//achPost
//rivoli
//lambert
//zus
//zru
//zfu
//cucs
//zrr
//zafr
'nbetab' => array(
'label' => "Nombre d'établissements",
'column' => 'nbEtab',
),
'nbmpubli' => array(
'label' => "Nombre de marché public remporté",
'column' => 'nbMPubli',
),
'sirengrp' => array(
'label' => "SIREN du groupe",
'column' => 'sirenGrp',
),
'nbactio' => array(
'label' => "Nombre d'actionnaires",
'column' => 'nbActio',
),
'nbpart' => array(
'label' => "Nombre de participations",
'column' => 'nbPart',
),
'bilfl' => array(
'label' => "CA total (FL)",
'column' => 'bilFL',
),
'bilcloture' => array(
'label' => 'Date de clôture du bilan',
'column' => 'bilCloture',
),
'biltype' => array(
'label' => 'Type du bilan',
'column' => 'bilType',
'values' => array(
'1' => 'Inconnus',
'2' => 'Réels',
'3' => 'Estimés'
)
),
//bilAnnee
//bilDuree
//avisCs
//risque
);
public function __construct(){}
public function getFields()
{
return $this->fields;
}
public function getSql($key)
{
if ( array_key_exists($key, $this->fields) ) {
if ( array_key_exists('sql', $this->fields[$key]) ){
return $this->fields[$key]['sql'];
}
}
return false;
}
public function getColumnValue($key)
{
if ( array_key_exists($key, $this->fields) ) {
if ( array_key_exists('values', $this->fields[$key]) && count($this->fields[$key]['values'])>0 ){
return $this->fields[$key]['values'];
}
}
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ $(document).ready(function()
return false;
});*/
$('div.critere-one input[type=radio]').change(function(e){
$('div.ciblage-one input[type=radio]').change(function(e){
e.preventDefault();
var btn = $(this);
var result = set(btn.attr('name'), btn.val());
@ -32,31 +32,37 @@ $(document).ready(function()
$('div.critere-one[name='+btn.attr('name')+']').button('reset');
}
});
$('div.ciblage-many button').change(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('select[name='+key+']:selected').val();
var result = set(key, values);
if (!result) {
alert('error');
$('div.critere-one[name='+btn.attr('name')+']').button('reset');
}
});
$('div.ciblage-range button').change(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('#slider-'+key).slider('getValue');
alert(values);
});
$('div.ciblage-rangedate button').change(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('#slider-'+key).slider('getValue');
alert(values);
});
/*$('.panel-group').delegate('div.criteres label', 'change', function(e){
e.stopPropagation();
if ( !$(this).parent('div').attr('size') ){
var valeur = $(this).find('input').val();
set($(this).parent('div').attr('name'), valeur);
}
});*/
/*$('.panel-group').delegate('input[type=checkbox].criteres', 'click', function(e){
e.stopPropagation();
if($(this).is(':checked')) {
set($(this).attr('name'), 1);
} else {
set($(this).attr('name'), 0);
}
});*/
/*$('input[type=text].autocomplete')
.bind( "keydown", function( event ) {
$('input[type=text].autocomplete').bind('keydown', function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active ) {
event.preventDefault();
}
})
.autocomplete({
}).autocomplete({
minLength:2,
source: function(request, response) {
var val = extractLast( request.term );
@ -79,9 +85,9 @@ $(document).ready(function()
return false;
},
close: function ( event, ui) { this.value = ''; },
});*/
});
/*$('.panel-group').delegate('a.autocomplete', 'click', function(e){
$('.panel-group').delegate('a.autocomplete', 'click', function(e){
e.stopPropagation();
var name = $(this).parent().find('input.criteres').attr('name');
var ul = $(this).parent().find('ul.selectqueries');
@ -93,9 +99,9 @@ $(document).ready(function()
set(name, values.join(','));
}
ul.empty();
});*/
});
/*$('.panel-group').delegate('a.autocompleteEx', 'click', function(e){
$('.panel-group').delegate('a.autocompleteEx', 'click', function(e){
e.stopPropagation();
var name = $(this).parent().find('input.criteres').attr('name');
var ul = $(this).parent().find('ul.selectqueries');
@ -107,141 +113,31 @@ $(document).ready(function()
set(name, values.join(','), 1);
}
ul.empty();
});*/
/*$('.panel-group').delegate('a.selectMultiple', 'click', function(e){
e.stopPropagation();
var obj = $(this).parent().find('label.active input');
set(obj.attr('name'), obj.val());
});*/
/*$('.panel-group').delegate('a.selectMultipleEx', 'click', function(e){
e.stopPropagation();
var obj = $(this).parent().find('select.criteres');
set(obj.attr('name'), obj.val(), 1);
});*/
/*$('.panel-group').delegate('a.intervalDate', 'click', function(e){
e.preventDefault();
var key = $(this).attr('id');
var val1 = $('select[name='+key+'1_a]').val() + $('select[name='+key+'1_m]').val() + $('select[name='+key+'1_j]').val();
var val2 = $('select[name='+key+'2_a]').val() + $('select[name='+key+'2_m]').val() + $('select[name='+key+'2_j]').val();
if(!val1) val1 = '';
if(!val2) val2 = '';
var values = val1 + ',' + val2;
set(key, values);
return false;
});*/
/*$('.panel-group').delegate('a.interval', 'click', function(e){
e.preventDefault();
var key = $(this).attr('id');
var val1 = $('input[name='+key+'1]').val();
var val2 = $('input[name='+key+'2]').val();
if(!val1) val1 = '';
if(!val2) val2 = '';
var values = val1 + ',' + val2;
set(key, values);
return false;
});*/
/*$('.panel-group').delegate('a.intervalSelect', 'click', function(e){
e.preventDefault();
var key = $(this).attr('id');
var values = $('select[name='+key+'1] option:selected').val()+','+$('select[name='+key+'2] option:selected').val();
set(key, values);
return false;
});*/
/*$('.panel-group').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: 900,
height: 500,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Valider: function() {
var key = $('div.jstree').attr('id');
var elements = [];
$('div.jstree').jstree("get_checked").each(function(){
elements.push(this.id);
});
set(key, elements.join(","));
$(this).dialog('close');
},
Fermer: function() { $(this).dialog('close'); }
},
close: function() { $('#dialogtree').remove(); }
};
$('<div id="dialogtree"></div>').dialog(dialogOpts);
return false;
});*/
/*$('.panel-group').delegate('a.text', 'click', function(e) {
e.preventDefault();
var id = $(this).attr('id');
if ($('div#field_text_'+id).css('display') == 'none') {
$('div#field_text_'+id).show('blind');
} else {
$('div#field_text_'+id).hide('blind');
}
});*/
/*$('.panel-group').delegate('a.dlist', 'click', function(e) {
e.preventDefault();
var id = $(this).attr('id');
if ($('div#field_list_'+id).css('display') == 'none') {
$('div#field_list_'+id).show('blind');
} else {
$('div#field_list_'+id).hide('blind');
}
});*/
/*$('.panel-group').delegate('a.list', 'click', function(e){
e.stopPropagation();
var obj = $(this).parent().find('textarea.criteres');
//regexp
set(obj.attr('name'), obj.val());
});*/
/*$('.panel-group').delegate('a.listEx', 'click', function(e){
e.stopPropagation();
var obj = $(this).parent().find('textarea.criteres');
//regexp
set(obj.attr('name'), obj.val(), 1);
});*/
});
});
function set(key, value, ex) {
ex = typeof ex !== 'undefined' ? ex : 0;
$('#panel').html('<span class="glyphicon glyphicon-refresh img-rounded"></span>');
var result = false;
$.post('/comptage/index', { cle:key, valeur:value, exclude:ex }, function(data, status) {
//Resume criteres content
$.post('/index/criteres', { total:data.count, insee:data.insee }, function(data) { $('#panel').html(data); });
if (data.error==1) {
$('div#actionMessage').html('<div class="alert alert-danger"><strong>Erreur !</strong> Un problème technique est survenu.</div>');
return false;
result = false;
}
if (data.error==2) {
$('div#actionMessage').html('<div class="alert alert-warning"><strong>Information !</strong> Valeur saisi incorrecte.</div>');
return false;
result = false;
}
return true;
}, 'json').error(function(){
$('div#actionMessage').html('<div class="alert alert-danger"><strong>Erreur !</strong> Un problème inconnu est survenu.</div>');
return false;
result = false;
});
return result;
}
function split( val ) {

View File

@ -58,6 +58,10 @@ if(isset($opts->install))
mkdir(APPLICATION_PATH . '/../data');
mkdir(APPLICATION_PATH . '/../data/sessions');
//Initialisation du cache des valeurs des champs
//Modification des permissions
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
passthru('chmod +x '.APPLICATION_PATH.'/../scripts/cron.php');

123
scripts/build/setCache.php Normal file
View File

@ -0,0 +1,123 @@
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
define('APPLICATION_ENV', 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
//require_once 'Zend/Application.php';
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/Zend/autoload_classmap.php',
__DIR__ . '/../../library/Application/autoload_classmap.php',
__DIR__ . '/../../library/Scores/autoload_classmap.php',
__DIR__ . '/../../application/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
),
'fallback_autoloader' => true
)
));
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Aide.",
'key-s' => "Genere le cache des valeurs pour un element",
'minmax' => "",
'table' => "",
'overwrite' => "Ecraser le fichier",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
$config = new Zend_Config($application->getOptions());
try {
$db = Zend_Db::factory($config->profil->db->metier);
} catch ( Exception $e ) {
exit ( $e->getMessage() );
}
Zend_Db_Table::setDefaultAdapter($db);
$fields = new Scores_Ciblage_FieldList();
$list = $fields->getItemsStruct();
foreach ( $list as $key => $item ) {
if ( $opts->key!=null && $opts->key != $key) continue;
if ( $opts->table && array_key_exists('sql', $item) ) {
$file = APPLICATION_PATH . '/../library/Scores/Table/'.$key.'.php';
if ( $opts->overwrite && file_exists($file) ) {
unlink($file);
}
if ( !file_exists($file) ) {
echo "Create cache for ".$key." => ".$file;
$values = $fields->getItemValues($key);
file_put_contents($file, "<?php\n");
file_put_contents($file, "return array(\n", FILE_APPEND);
foreach ( $values as $k => $v ) {
file_put_contents($file, "\t'".$k."' => \"".$v."\",\n", FILE_APPEND);
}
file_put_contents($file, ");", FILE_APPEND);
echo " - OK\n";
}
} elseif ( $opts->minmax && array_key_exists('minmax', $item) ) {
$file = APPLICATION_PATH . '/../library/Scores/Table/'.$key.'.php';
if ( file_exists($file) ) unlink($file);
if ( $opts->overwrite && file_exists($file) ) {
unlink($file);
}
if ( !file_exists($file) ) {
echo "Create cache for ".$key." => ".$file;
$values = $fields->getItemValues($key);
file_put_contents($file, "<?php\n");
file_put_contents($file, "return array(\n", FILE_APPEND);
file_put_contents($file, "\t'min'=> ".$values['min'].",\n", FILE_APPEND);
file_put_contents($file, "\t'max'=> ".$values['max'].",\n", FILE_APPEND);
file_put_contents($file, ");", FILE_APPEND);
echo " - OK\n";
}
}
}

View File

@ -13,7 +13,27 @@ set_include_path(implode(PATH_SEPARATOR, array(
)));
/** Zend_Application */
require_once 'Zend/Application.php';
//require_once 'Zend/Application.php';
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/Zend/autoload_classmap.php',
__DIR__ . '/../../library/Application/autoload_classmap.php',
__DIR__ . '/../../library/Scores/autoload_classmap.php',
__DIR__ . '/../../application/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
),
'fallback_autoloader' => true
)
));
// Create application, bootstrap, and run
$application = new Zend_Application(