Grosse MAJ

This commit is contained in:
Damien LASSERRE 2012-03-15 15:44:10 +00:00
parent d668dbc2d1
commit 7135be80d3
17 changed files with 389 additions and 146 deletions

View File

@ -8,26 +8,27 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view = $this->getResource('view');
$pathStyle = '/themes/default/styles';
$pathScript = '/themes/default/scripts';
$view->setEncoding('UTF-8');
$view->doctype('XHTML1_STRICT');
$view->headMeta()
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR');
$view->headLink()
->appendStylesheet($pathStyle.'/jquery.qtip.css', 'all')
->appendStylesheet('/themes/jstree/default/style.css')
->appendStylesheet('/themes/jqueryui/jquery-ui.css', 'all')
->appendStylesheet($pathStyle.'/main.css', 'all');
$view->headScript()
->appendFile($pathScript.'/jquery.js', 'text/javascript')
->appendFile($pathScript.'/jquery.bgiframe.js', 'text/javascript')
->appendFile($pathScript.'/jquery.cookie.js', 'text/javascript')
->appendFile($pathScript.'/jquery-ui.js', 'text/javascript')
->appendFile($pathScript.'/jquery.qtip.js', 'text/javascript')
->appendFile($pathScript.'/upload.js', 'text/javascript')
->appendFile($pathScript.'/scripts.js', 'text/javascript');
$view->headTitle()->setSeparator(' - ');

View File

@ -106,7 +106,7 @@ class EnrichissementController extends Zend_Controller_Action
//Récupération des SIRET
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($values);
$infosExtraction = $ciblage->extract();
$infosExtraction = $ciblage->execute(true);
//Attention calcul uniteInsee réelle
//car si donnée insee alors toutes les lignes doivent être comptés en unité insee
@ -125,7 +125,6 @@ class EnrichissementController extends Zend_Controller_Action
);
$identifiantsM = new Table_EnrichissementIdentifiants();
$idIdentifiant = $identifiantsM->insert($data);
}
/**

View File

@ -0,0 +1,22 @@
<?php
Class ExtractController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
require_once 'Scores/Ciblage.php';
require_once 'Scores/Field.php';
$field = new Fields();
$ciblage = new Ciblage($field->getValues());
$ciblage->extract();
}
public function batchAction()
{
$action = $this->getRequest();
$request = $action->getParam('reference');
}
}

View File

@ -54,7 +54,7 @@ class GeographiqueController extends Libs_Controller
foreach ($result as $item) {
$output[] = array(
'label' => $item->libdep . $separator . $item->numdep,
'value' => 'D'.$item->numdep
'value' => $item->numdep
);
}
return ($output);
@ -62,8 +62,9 @@ class GeographiqueController extends Libs_Controller
protected function completedVil($q)
{
$table = new Table_Codepostauxs();
$table = new Table_Codepostauxs();
$separator = ' ';
$sql = $table->select()->where('Commune LIKE "'.$q.'%"');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
@ -77,15 +78,16 @@ class GeographiqueController extends Libs_Controller
protected function completedReg($q)
{
$table = new Table_Regions();
$table = new Table_Regions();
$separator = ' ';
$sql = $table->select()
->where('NCCENR LIKE "%'.$q.'%"');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
$output[] = array(
'label' => $item->NCCENR . $separator . $item->REGION,
'value' => 'R'.$item->REGION
'value' => $item->REGION
);
}
return ($output);

View File

@ -32,7 +32,7 @@ Class IndexController extends Libs_Controller
$this->view->field = new Fields();
$this->view->criteres = $session->getCriteres();
}
public function removeAction()
{
require_once('Scores/SessionCiblage.php');

View File

@ -24,26 +24,27 @@ class Object_Codepostaux extends Libs_Row
$in = array();
foreach($valeurs as $valeur) {
$type = explode(':', $valeur);
if($niveau == 0) {
if ($valeur[0] == 'D'){
$valeur = substr($valeur, 1, strlen($valeur));
if ($type[0] == 'adr_dept'){
$valeur = $type[1];
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
$in[] = 'R'.$code['codeRegionInsee'];
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
} else{
$valeur = substr($valeur, 0, strlen($valeur));
$valeur = $type[1];
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
$in[] = 'R'.$code['codeRegionInsee'];
$in[] = 'adr_reg:'.$code['codeRegionInsee'];
}
} else if ($niveau == 1) {
$valeur = substr($valeur, 0, strlen($valeur));
$valeur = $type[1];
$insee = $table->fetchAll($table->select('departements', array('codeRegionInsee'))
->where('numdep = ?', substr($valeur, 0, 2)))->toArray();
foreach ($insee as $code)
$in[] = 'D'.$code['numdep'];
$in[] = 'adr_dept:'.$code['numdep'];
}
}
return ($in);
@ -67,9 +68,9 @@ class Object_Codepostaux extends Libs_Row
foreach($regions as $nom) {
$structure[] = array(
'data' => $nom['NCCENR'],
'attr' => array('id' => 'R'.$nom['REGION'],
'attr' => array('id' => 'adr_reg:'.$nom['REGION'],
'niveau' => 0,
'class' => $this->_getClass('R'.$nom['REGION'], 0)
'class' => $this->_getClass('adr_reg:'.$nom['REGION'], 0)
),
'state' => 'closed',
'children' => array()
@ -81,17 +82,18 @@ class Object_Codepostaux extends Libs_Row
public function _getDepartements($codeRegionInsee)
{
$code = explode(':', $codeRegionInsee);
$departement = new Table_Departements();
$departements = $departement->fetchAll($departement->select()
->where('codeRegionInsee ='.substr($codeRegionInsee, 1, strlen($codeRegionInsee))))->toArray();
->where('codeRegionInsee ='.$code[1]))->toArray();
$structure = array();
foreach($departements as $nom) {
$structure[] = array(
'data' => $nom['libdep'],
'attr' => array('id' => 'D'.$nom['numdep'],
'attr' => array('id' => 'adr_dept:'.$nom['numdep'],
'niveau' => 1,
'class' => $this->_getClass('D'.$nom['numdep'], 1)
'class' => $this->_getClass('adr_dept:'.$nom['numdep'], 1)
),
'state' => 'closed',
'children' => array()
@ -103,17 +105,17 @@ class Object_Codepostaux extends Libs_Row
public function _getCommunes($numdep)
{
$numdep = substr($numdep, 1, strlen($numdep));
$numdep = explode(':', $numdep);
$codepostau = new Table_Codepostauxs();
$codepostaux = $codepostau->fetchAll($codepostau->select()->where('codepos LIKE "'.$numdep.'%"'))->toArray();
$codepostaux = $codepostau->fetchAll($codepostau->select()->where('codepos LIKE "'.$numdep[1].'%"'))->toArray();
$structure = array();
foreach($codepostaux as $nom) {
$structure[] = array(
'data' => $nom['Commune'],
'attr' => array('id'=> $nom['INSEE'],
'attr' => array('id'=> 'adr_com:'.$nom['INSEE'],
'niveau' => 2,
'class' => $this->_getClass($nom['INSEE'], 2)
'class' => $this->_getClass('adr_com:'.$nom['INSEE'], 2)
),
'state' => 'closed',
'children' => array()

View File

@ -66,24 +66,35 @@ class Object_Comptage extends Libs_Row
$session->setCritere($key, $valeur);
if($valeur[strlen($valeur)] == ',')
$valeur = substr($valeur, 0, strlen($valeur) -1);
if($key == 'reg' or $key == 'vil' or $key == 'dep') {
if($key == 'vil' or $key == 'adr_reg' or $key == 'adr_dept') {
$key = 'adr_com';
if($session->getCritere('reg')){
$reg = trim($session->getCritere('reg'));
}
if($session->getCritere('vil')){
$vil = trim($session->getCritere('vil'));
$valeurs = explode(',', $session->getCritere('vil'));
foreach($valeurs as $valeur) {
$vil .= 'adr_com:'.trim($valeur).',';
}
$vil = substr($vil, 0, strlen($vil)-1);
}
if($session->getCritere('dep')){
$dep = trim($session->getCritere('dep'));
if($session->getCritere('adr_reg')) {
$valeurs = explode(',', $session->getCritere('adr_reg'));
foreach($valeurs as $valeur) {
$reg .= 'adr_reg:'.trim($valeur).',';
}
$reg = substr($reg, 0, strlen($reg)-1);
}
$valeur = implode('', array($reg, $vil, $dep));
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);
}
$valeur = implode('', array($vil, $reg, $dept));
$session->setCritere($key, $valeur);
}
require_once 'Scores/Field.php';
$field = new Fields();
//Comptage
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($field->getValues());

View File

@ -51,7 +51,7 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
}
$html.= $this->structureHTML(
$label,
$this->textHTML($name, $field, $name));
$this->textHTML($name, $field, $name), $field['help'][ucfirst($name)]);
break;
case 'textarea':
$html.= $this->structureHTML(
@ -74,11 +74,11 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
return $html;
}
private function structureHTML($label, $html, $liens = array())
private function structureHTML($label, $html, $help = null)
{
$out = '';
$out.= $this->structureLabel($label);
$out.= '<div class="field">'.$html.$this->structureLink($liens).'</div>';
$out.= $this->structureLabel($label, $help);
$out.= '<div class="field">'.$html.'</div>';
return $out;
}
@ -86,28 +86,16 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
* Définition du label
* @param unknown_type $label
*/
private function structureLabel($label)
private function structureLabel($label, $help)
{
return '<label>'.$label.'</label>';
$return = '<label>'.$label.'</label>';
if($help)
$return .= '<p style="font-size:9px;">'.$help.'</p>';
return ($return);
}
/**
* Définition des liens
*/
private function structureLink($liens = array())
{
$html = '';
if (count($liens)>0) {
foreach($liens as $lien){
$html.= '<a href="'.$lien['url'].'">'.$lien['lib'].'</a>';
}
}
if (!empty($html)) {
return '<span>'.$html.'</span>';
}
return '';
}
private function intervalSelectHTML($name, $field)
{
$session = new SessionCiblage();
@ -133,7 +121,6 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
private function selectMultipleHTML($name, $field)
{
$session = new SessionCiblage();
$return = '<select class="criteres" name="'.$name.'">';
$return .= '<option value="tous">Tous</option>';
foreach($field['fields'][$field['type']]['value'] as $value => $label) {
@ -204,12 +191,6 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
case 'ape_etab':
$type = 'Naf';
break;
case 'dep':
$type = 'Dep';
break;
case 'reg':
$type = 'Reg';
break;
case 'vil':
$type= 'Vil';
break;

View File

@ -1,9 +1,22 @@
<div id="geographique">
<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');?></li>
<li style="background-image:none;height:80px;"><?php echo $this->Field('dep', $this->fields->get('adr_com'), 'text');?></li>
<li style="background-image:none;height:80px;"><?php echo $this->Field('reg', $this->fields->get('adr_com'), 'text');?></li>
<li style="background-image:none;height:80px;">
<img style="float:right" src="/themes/default/images/help.png" />
<?php echo $this->Field('vil', $this->fields->get('adr_com'), 'text');?>
</li>
<li style="background-image:none;height:80px;">
<i>Indiquez les noms ou les codes des départements séparés par des virgules.
Si vous disposez d'une liste sous forme excel glissez le fichier dans l'encadré,
Pour la corse vous pouvez indiquer 20 ou 2A, 2B, pour les DOM-TOM vous pouvez indiquer deux ou trois chiffres,
exemple : 97 ou 971, 972...</i>
<?php echo $this->Field('adr_dept', $this->fields->get('adr_dept'), 'text');?>
</li>
<li style="background-image:none;height:80px;">
<i>Indiquez les noms ou les codes (insee) des régions séparés par des virgules.
Si vous disposez d'une liste sous forme excel glissez le fichier dans l'encadré</i>
<?php echo $this->Field('adr_reg', $this->fields->get('adr_reg'), 'text');?>
</li>
</ul>
</div>
<div style="text-align:right;margin-top:20px;">

View File

@ -1,7 +1,11 @@
<div id="juridique">
<ul id="fieldsblock">
<li><?php echo $this->Field('cj', $this->fields->get('cj'));?></li>
<li style="background-image:none;height:80px;"><?php echo $this->Field('cj', $this->fields->get('cj'), 'text');?></li>
<li style="background-image:none;height:80px;">
<i>Indiquez les formes juridiques ou les codes (insee) sur un deux ou quatres chiffres séparés par des virgules.
Si vous disposez d'une liste sous forme excel glissez le fichier dans l'encadré</i>
<?php echo $this->Field('cj', $this->fields->get('cj'), 'text');?>
</li>
<li><?php echo $this->Field('actifEco', $this->fields->get('actifEco'));?></li>
<li><?php echo $this->Field('procolHisto', $this->fields->get('procolHisto'));?></li>
<li><?php echo $this->Field('tvaIntraValide', $this->fields->get('tvaIntraValide'));?></li>

163
batch/extract.php Normal file
View File

@ -0,0 +1,163 @@
<?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';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
require_once APPLICATION_PATH . '/../library/Zend/Loader/Autoloader.php';
Class extract
{
protected $db;
protected $dbMetier;
protected $reference;
public function __construct($reference)
{
$this->reference = $reference;
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases');
try {
$this->db = Zend_Db::factory($dbConfig->db);
} catch ( Exception $e ) {
exit ( $e->getMessage() );
}
}
public function getHttp()
{
/* Depuis le navigateur */
}
protected function getCj($liste)
{
foreach($liste as $valeur)
{
if(strlen($valeur) < 5) {
$sql = $this->db->select('formejuridique', array('fjCode'))
->from('formejuridique')
->where('fjCode LIKE "'.$valeur.'%"');
} else {
$sql = $this->db->select('formejuridique', array('fjCode'))
->from('formejuridique')
->where('fjCode = "'.$valeur.'"');exit;
}
$result = $this->db->fetchAll($sql);
foreach ($result as $code) {
if(strlen($code['fjCode']) > 2) {
$return[] = $code['fjCode'];
}
}
}
return ($return);
}
protected function localisationArbo($name, $liste)
{
foreach($liste as $valeur)
{
if(strlen($valeur) == 2) {
switch($name) {
case 'adr_reg':
$return = array();
$sql = $this->db->select()
->from('departements')
->join(array('cp' => 'codepostaux'), 'cp.codepos LIKE CONCAT(departements.numdep, "%")', array('INSEE'))
->where('codeRegionInsee ='.$valeur);
$result = $this->db->fetchAll($sql);
foreach ($result as $res) {
$return[] = trim($res['INSEE']);
}
break;
case 'adr_dept':
$return = array();
$sql = $this->db->select()
->from('departements')
->join(array('cp' => 'codepostaux'), 'cp.codepos LIKE CONCAT(departements.numdep, "%")', array('INSEE'))
->where('numdep ='.$valeur);
$result = $this->db->fetchAll($sql);
foreach ($result as $res) {
$return[] = trim($res['INSEE']);
}
break;
}
}
}
return ($return);
}
public function getCli()
{
require_once('Scores/Ciblage.php');
require_once('Scores/Field.php');
$sql = 'SELECT id, idDefinition, uniteInsee FROM comptages WHERE id = '.$this->reference;
$fetch = $this->db->query($sql);
$result = $fetch->fetchAll();
$idComptage = $result[0]['id'];
$uniteInsee = $result[0]['uniteInsee'];
$sql = 'SELECT id, criteres.criteres FROM criteres WHERE id ='.$result[0]['idDefinition'];
$fetch = $this->db->query($sql);
$result = $fetch->fetchAll();
$idCriteres = $result[0]['id'];
$structure = json_decode($result[0]['criteres']);
$element = array();
foreach ($structure as $name => $valeur){
$type = explode(':', $valeur);
if($type[0] == 'adr_dept') {
$array['adr_com'] = $this->localisationArbo($type[0], explode(',', $type[1]));
}
if($name == 'cj') {
$array['cj'] = $this->getCj(explode(',', $valeur));
}
}
$array['ape_etab'] = explode(',', $structure->ape_etab);
$ciblage = new Ciblage($array);
$res = $ciblage->execute(true);
$data = array(
'idComptage' => $idComptage,
'idCriteres' => $idCriteres,
'idProfil' => 0,
'reference' => 'batch',
'identifiants' => json_encode($res),
'nbLigneTotales' => count($res),
'nbLigneTraites' => count($res),
'uniteInsee' => $uniteInsee,
'error' => 0
);
//$this->db->insert('enrichissement_identifiants',$data);
$fd = fopen($idComptage.'_batch'.date('Y-m-d-hms').'.csv', 'x+');
try {
$array = array();
foreach($res as $field) {
fputcsv($fd, array($field), ';');
}
} catch(Exception $e) {
echo $e->getMessage();
}
fclose($fd);
echo count($res).' Success !';
}
}
$a = new extract('20');
$a->getCli();

View File

@ -9,7 +9,7 @@ Class Ciblage
public $index = 'ciblage';
public $nb_results = 5000;
public $nb_results = 50000;
public $max_results = 500000;
public $mysql_host = '192.168.78.230';
@ -75,13 +75,33 @@ Class Ciblage
return ($resSphinx['total_found']);
}
protected function getSiret($structure)
{
$siret = array();
foreach($structure['matches'] as $element)
{
$siret[] = $element['attrs']['siren'].$element['attrs']['nic'];
}
return ($siret);
}
public function execute($need = false)
{
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
/* Retourne les resultats */
if($need) {
return ($resSphinx);
}
$return = array();
$limit = 0;
do {
$this->sphinx->SetLimits($limit, 1000, 50000);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
if(is_array($resSphinx))
$return = array_merge($return, $this->getSiret($resSphinx));
$limit = $limit + 1000;
}while($limit < $resSphinx['total_found']);
return ($return);
} else
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
return ($resSphinx['total_found']);
}
@ -144,14 +164,6 @@ Class Ciblage
protected function siege($valeur) {
$this->setFilter('siege', $valeur);
}
protected function adr_cp($valeur) {
$this->setFilter('adr_cp', $valeur);
}
protected function adr_dep($valeur) {
$this->setAlpha('adr_dep', $valeur);
}
protected function adr_com($valeur) {
$this->setFilter('adr_com', $valeur);
@ -178,7 +190,7 @@ Class Ciblage
}
protected function capital($valeur) {
$valeur = $this->setMinMax($name, $valeur);
//$valeur = $this->setMinMax($name, $valeur);
$this->setFilterRange('capital', $valeur);
}

View File

@ -374,7 +374,33 @@ Class Fields
'class' => null,
'action' => 'geographique',
'title' => 'Localisation'
),
),
'adr_dept' => array(
'label' => 'Liste départements',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => '',
'title' => 'Localisation'
),
'adr_reg' => array(
'label' => 'Liste code région',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => '',
'title' => 'Localisation'
),
//juridique
'cj' => array(
'label' => 'Forme Juridique',
@ -658,18 +684,26 @@ 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
$this->fields[$key]['type'] == 'textarea' and
empty($this->fields[$key]['action']) or $this->fields[$key]['action'] == 'naf')
empty($this->fields[$key]['action']))
{
$values[$key] = explode(',', $item);
} else if (!empty($this->fields[$key]['action'])) {
$values[$key] = $this->selectArbo($key, $item);
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);
}
} else {
$values[$key] = $item;
}
@ -687,24 +721,32 @@ Class Fields
case 'ape_entrep' :
$nafs = explode(',', $valeur);
foreach($nafs as $naf) {
if($naf != ' ')
if($naf != ' ') {
$values = array_merge($values, $this->nafArbo($name, $naf));
}
}
break;
case 'adr_dept':
case 'adr_reg':
case 'adr_com':
$valeurs = explode(',', $valeur);
foreach($valeurs as $element) {
$array = $this->localisationArbo($name, $element);
if(!empty($array))
$values = array_merge($values, $array);
if(!empty($element)) {
$val = explode(':', $element);
$array = array_diff($this->localisationArbo($val[0], $val[1]), $values);
if(!empty($array)) {
$values = array_merge($values, $array);
}
}
}
break;
case 'cj':
$valeurs = explode(',', $valeur);
foreach($valeurs as $valeur)
$values = array_merge($values, $this->fj($name, $valeur));
foreach($valeurs as $valeur) {
if($valeur != ' ' and !empty($valeur))
$values = array_merge($values, $this->fj($name, $valeur));
}
}
return ($values);
}
@ -715,11 +757,11 @@ Class Fields
if(strlen($valeur) < 5) {
$sql = $table->select('formejuridique', array('fjCode'))
->where('fjCode LIKE "'.$valeur.'%"');
} else
} else {
$sql = $table->select('formejuridique', array('fjCode'))
->where('fjCode = "'.$valeur.'"');
}
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $code) {
if(strlen($code['fjCode']) > 2) {
$return[] = $code['fjCode'];
@ -730,14 +772,14 @@ Class Fields
protected function localisationArbo($name, $valeur)
{
if(strlen($valeur) <= 3) {
switch($valeur[0]) {
case 'R':
if(strlen($valeur) == 2) {
switch($name) {
case 'adr_reg':
$table = new Table_Departements();
$sql = $table->select()
->from('departements')
->join(array('cp' => 'codepostaux'), 'cp.codepos LIKE CONCAT(departements.numdep, "%")', array('INSEE'))
->where('codeRegionInsee ='.substr($valeur, 1, strlen($valeur)))
->where('codeRegionInsee ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
@ -745,12 +787,12 @@ Class Fields
$return[] = $res['INSEE'];
}
break;
case 'D':
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 ='.substr($valeur, 1, strlen($valeur)))
->where('numdep ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $res) {
@ -763,40 +805,13 @@ Class Fields
return ($return);
}
protected function deptArbo($name, $valeur)
{
if(strlen($valeur) < 5){
if($valeur[0] == 'D') {
$codepostaux = new Table_Codepostauxs();
$sql = $codepostaux->select()->where('Codepos LIKE "'.substr($valeur, 1).'%"');
$codes = $codepostaux->fetchAll($sql)->toArray();
foreach($codes as $code) {
$values[] = $code['Codepos'];
}
} else if($valeur[0] == 'R') {
$departements = new Table_Departements();
$codepostaux = new Table_Codepostauxs();
$sql = $departements->select()->from('departements', array('numdep'))->where('codeRegionInsee = ?', substr($valeur, 1));
$results = $departements->fetchAll($sql)->toArray();
foreach($results as $result) {
$sql = $codepostaux->select()->from('codepostaux', array('Codepos'))->where('Codepos LIKE "'.$result['numdep'].'%"');
$codes = $codepostaux->fetchAll($sql)->toArray();
foreach($codes as $code) {
$values[] = $code['Codepos'];
}
}
}
return ($values);
}
return (array($valeur));
}
protected function nafArbo($key, $valeur)
{
$value = array();
$table = new Table_Nafs();
$valeur = trim($valeur);
if(strlen($valeur) == 1)
{
$sql = $table->select()->where('parent = ?', $valeur);
@ -816,13 +831,17 @@ Class Fields
return ($value);
}
public function __construct()
public function __construct($batch = false)
{
foreach($this->fields as $name => $valeur) {
if($this->fields[$name]['type'] == 'interval') {
$minmax = $this->getMinMax($name);
$this->fields[$name]['fields'][$this->fields['type']]['value']
= array($minmax[0]['min'], $minmax[0]['max']);
if(!$batch) {
foreach($this->fields as $name => $valeur) {
if($this->fields[$name]['type'] == 'interval') {
$minmax = $this->getMinMax($name);
if(!empty($minmax)) {
$this->fields[$name]['fields'][$this->fields[$name]['type']]['value']
= array($minmax[0]['min'], $minmax[0]['max']);
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

View File

@ -40,7 +40,7 @@ $(document).ready(function(){
}
});
$('textarea.complitedDep').autocomplete({
$('#textarea_adr_dept').autocomplete({
delay:600,
source: function(request, response) {
$.getJSON('/geographique/completed/dep/1', { q: extractLast( request.term ) },
@ -57,7 +57,7 @@ $(document).ready(function(){
}
});
$('textarea.complitedReg').autocomplete({
$('#textarea_adr_reg').autocomplete({
delay:600,
source: function(request, response) {
$.getJSON('/geographique/completed/reg/1', { q: extractLast( request.term ) },

View File

@ -0,0 +1,14 @@
$(document).ready(function(){
$('.upload').change(function(){
term = $(this).val();
a = term.split('/');
$.ajax(
'/upload/arborescance/'+a,
{
type : "GET",
cache : false,
data : $(this).serializeArray()
}
);
});
});

View File

@ -5,7 +5,7 @@
}
#geographique li {
height:20px;
height:30px;
padding:5px;
border:1px solid silver;
margin-top:2px;