odea/library/Scores/Fields.php

1043 lines
27 KiB
PHP
Raw Normal View History

<?php
/**
*
*/
class Scores_Fields
{
/**
* Fields options to display
* [name] => array(
* label =>
* fields => array(
* type => array()
* ...
* )
* famille =>
* activated =>
* type =>
* )
* )
*
2012-05-11 20:25:55 +00:00
* name : the key to retrieve field parameters
* label : the string to display as title
2012-05-11 20:25:55 +00:00
* famille : the key to identify where familly the field belongs to
* activated : true or false
*
* fields : define all different fields for the same element
* => type : which type of element (select, text, tree, ...), it's the key for array
2012-05-11 20:25:55 +00:00
* => value :
* => label (optional) :
* => class :
* @var array
*/
protected $fields = array
(
2012-05-11 20:25:55 +00:00
'siege' => array (
'label' => "Type d'établissement",
'fields' => array(
'select' => array('value' => array('1' => 'Sièges', '0' => 'Secondaires')),
),
'famille' => 'entreprise',
'activated' => true,
),
2012-05-11 20:25:55 +00:00
'groupe' => array(
'label' => "Appartient à un groupe",
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'entreprise',
'activated' => true,
),
'tel' => array(
'label' => 'Téléphone renseigné',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'fax' => array(
'label' => 'Télécopie renseignée',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'web' => array(
'label' => 'Site Web renseigné',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'mail' => array(
'label' => 'Email de contact renseigné',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'presentRcs' => array(
'label' => 'Etablissement présent au RNCS',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'adrDom' => array(
'label' => 'Adresse de domiciliation',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'dirNom' => array(
'label' => 'Nom du principal dirigeant présent',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
/* What is this ? */
'lieuAct' => array(
'label' => "Lieu d\'activté",
'fields' => array(
'interval' => array('value' => array('0', '1000')),
'textarea' => array('value' => null)
),
'famille' => 'entreprise',
'activated' => true,
),
'nbMPubli' => array(
'label' => 'Marchés publiques remportés',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'dateCrea_ent' => array(
2012-05-11 20:25:55 +00:00
'label' => "Date de création de l'entreprise",
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'entreprise',
'activated' => true,
),
'dateCrea_etab' => array(
'label' => "Date de création de l'établissement",
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'entreprise',
'activated' => true,
),
'action' => array(
'label' => 'Présence d\'actionnaires',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'nbActio' => array(
'label' => 'Nombre d\'actionnaires connus',
'fields' => array(
2012-05-11 20:25:55 +00:00
//@todo : getMinMax
'interval' => array('value' => null)
),
'famille' => 'entreprise',
'activated' => true,
),
2012-05-11 20:25:55 +00:00
'participation' => array(
'label' => "Présence de participations",
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
),
'nbPart' => array(
'label' => 'Nombre de participations connues',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'entreprise',
'activated' => true,
),
'ape_etab' => array(
'label' => "Activité de l'établissement (Code NAF)",
'fields' => array(
'tree' => array('value' => null, 'action' => 'naf', 'title' => "Arborescence de code NAF etablissement"),
'text' => array('value' => null, 'label' => "Recherche de code NAF", 'title'=>"Selection de code NAF etablissement"),
),
'famille' => 'economique',
'activated' => true,
),
'ape_entrep' => array(
2012-05-14 13:16:14 +00:00
'label' => "Activité de l'entreprise (Code NAF)",
'fields' => array(
2012-05-14 13:16:14 +00:00
'tree' => array('value' => null, 'action' => 'naf', 'title' => "Arborescence de code NAF entreprise"),
'text' => array('value' => null, 'label' => "Recherche de code NAF", 'title'=>"Selection de code NAF entreprise"),
),
'famille' => 'economique',
'activated' => true,
),
'NaceEtab' => array(
'label' => 'Code NACE de l\'établissement',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
),
'NaceEntrep' => array(
'label' => 'Code NACE de l\'entreprise',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
),
'age_etab' => array(
'label' => 'Age de l\'entreprise',
'fields' => array(
'interval' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
),
'age_entrep' => array(
'label' => 'Age de l\'établissement',
'fields' => array(
'interval' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
),
'teff_entrep' => array(
2012-05-11 20:25:55 +00:00
'label' => "Tranche d'effectif de l'Entreprise",
'fields' => array(
2012-05-11 20:25:55 +00:00
'selectMultiple' => array(
'value' => array(
'NN' => "Unités non employeuses",
'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",
),
),
),
'famille' => 'economique',
'activated' => true,
),
'teff_etab' => array(
'label' => 'Tranche d\'effectif de l\'établissement',
'fields' => array(
2012-05-11 20:25:55 +00:00
'selectMultiple' => array(
'value' => array(
2012-05-11 20:25:55 +00:00
'NN' => "Unités non employeuses",
'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",
)
2012-05-11 20:25:55 +00:00
),
),
'famille' => 'economique',
'activated' => true,
),
'nbEtab' => array(
'label' => 'Nombre d\'établissements',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'economique',
'activated' => true,
),
'eff_entrep' => array(
'label' => 'Effectif réel de l\'entreprise',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'economique',
'activated' => true,
),
'eff_etab' => array(
'label' => 'Effectif réel de l\'établissement',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'economique',
'activated' => true,
),
'capital' => array(
'label' => 'Capital de l\'entreprise',
'fields' => array(
'intervalSelect' => array(
'value' => array(
array(0, 15000),
array(15000, 30000),
array(30000, 75000),
array(75000, 150000),
array(150000, 750000),
array(750000, 0),
)
)
),
'famille' => 'economique',
'activated' => true,
),
//geographique
'adr_com' => array(
'label' => 'Localisation géographique',
'fields' => array(
'tree' => array('value' => null, 'action' => 'geographique', 'title' => "Arborescence géographique"),
'text' => array('value' => null, 'label' => "Recherche", 'title'=>"Recherche géographique"),
),
'famille' => 'geographique',
'activated' => true,
),
2012-05-11 20:25:55 +00:00
'geo_domtom' => array(
'label' => 'Exlcure les DOM-TOM',
'fields' => array(
2012-05-11 20:25:55 +00:00
'checkbox' => array('value' => '1'),
),
'famille' => 'geographique',
'activated' => true,
),
2012-05-11 20:25:55 +00:00
'geo_etranger' => array(
'label' => 'Exclure les départements étrangers',
'fields' => array(
2012-05-11 20:25:55 +00:00
'checkbox' => array('value' => '1'),
),
'famille' => 'geographique',
'activated' => true,
),
2012-05-11 20:25:55 +00:00
'geo_corse' => array(
'label' => 'Exclure la corse',
'fields' => array(
2012-05-11 20:25:55 +00:00
'checkbox' => array('value' => '1'),
),
'famille' => 'geographique',
'activated' => true,
),
'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' => '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',
),
/*
* Forme Juridique
*/
'cj' => array(
'label' => 'Forme Juridique',
'fields' => array(
'tree' => array('value' => null, 'action' => 'juridique', 'title' => "Arborescence Forme Juridique"),
'text' => array('value' => null, 'label' => "Recherche", 'title'=>"Recherche Forme Juridique"),
),
'famille' => 'juridique',
'activated' => true,
),
'actifEco' => array(
'label' => 'Établissement économiquement actif',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'juridique',
'activated' => true,
),
'procolHisto' => array(
'label' => 'Présence procédure collective dans histo',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'juridique',
'activated' => true,
),
'tvaIntraValide' => array(
'label' => 'Numéro de TVA intracommunautaire valide',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'juridique',
'activated' => true,
),
'dateImmat' => array(
'label' => 'Date d\'immatriculation',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'juridique',
'activated' => true,
),
//financier
'bilType' => array(
'label' => 'Type du dernier bilan',
'fields' => array(
'selectMultiple' => array('value' => array(
'I' => 'Inconnue',
'R' => 'Réel',
'E' => 'Estimé')
),
),
'famille' => 'financier',
'activated' => true,
),
'avisCs' => array(
'label' => 'Informations de paiements',
'fields' => array(
'selectMultiple' => array('value' => array(
'' => 'Risque indéterminé',
'00' => 'Aucun risque resencé',
'10' => 'Présence d\'impayé(s)',
'15' => 'Présence de privilèges',
'23-29-39-43' => 'Risque moyen',
'21-26-28' => 'Risque important',
'31-50' => 'Risque très important',
'24' => 'Risque dans le groupe')
),
),
'famille' => 'financier',
'activated' => true,
),
'bilDuree' => array(
'label' => 'Durée du dernier bilan en mois',
'fields' => array(
'intervalSelect' => array(
'value' => array(
array(0, 5),
array(5, 10),
array(10, 15),
array(20, 23),
array(23, 0)
)
)
),
'famille' => 'financier',
'activated' => true,
),
'bilTca' => array(
'label' => 'Tranche de CA issue du bilan',
'fields' => array(
'selectMultiple' => array('value' => array(
'0' => 'Non déterminée',
'1' => 'de 500K€ à1M€',
'2' => 'de 1 à 2 ME',
'3' => 'de 2 à 5 ME',
'4' => 'de 5 à 10 ME',
'5' => 'de 10 à 20 ME',
'6' => 'de 20 à 50 ME',
'7' => '50 à 100 ME',
'8' => 'de 100 à 200 ME',
'9' => '+ de 200 ME'
)),
),
'famille' => 'financier',
'activated' => true,
),
'bilAnnee' => array(
'label' => 'Dernière année de bilan',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilCloture' => array(
'label' => 'Dernière date de clôture du bilan',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilEE' => array(
'label' => 'Total bilan (EE)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilFL' => array(
'label' => 'CA total (FL)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilFK' => array(
'label' => 'Chiffre d\'affaires Export (FK)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilFR' => array(
'label' => 'Produits d\'Exploitation (FR)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilGF' => array(
'label' => 'Charges d\'Exploitation (GF)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilGP' => array(
'label' => 'Charges Financières (GP)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilGW' => array(
'label' => 'R.C.A.I - Résultat courant av. impôt (GW)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilHD' => array(
'label' => 'Produits Exceptionnels (HD)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilHH' => array(
'label' => 'Charges Exceptionnels (HH)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilHL' => array(
'label' => 'Total des Produits (HL)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilHM' => array(
'label' => 'Total des Charges (HM)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilHN' => array(
'label' => 'Résultat (HN)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
),
'bilYP' => array(
'label' => 'Effectif salarié (YP)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
)
);
/**
* Save all information in this array
* The key NB is mandatory as this
* ['NB']['total'] => store the number of elements matches
* ['NB']['insee'] => store the number of elements matches which type is INSEE
2012-05-11 20:25:55 +00:00
* Other keys
* [key][in] => inclusion
* [key][ex] => exclusion
* @var array
*/
protected $ciblage;
protected $total = null;
protected $insee = null;
/**
*
* @param boolean $batch
*/
public function __construct($batch = false)
{
$session = new Zend_Session_Namespace('ciblage');
$this->ciblage = empty($session->ciblage) ? array() : $session->ciblage;
if (isset($this->ciblage['NB']['total'])) { $this->total = $this->ciblage['NB']['total']; }
if (isset($this->ciblage['NB']['insee'])) { $this->insee = $this->ciblage['NB']['insee']; }
if (isset($this->ciblage['NB'])) { unset($this->ciblage['NB']); }
}
/**
* Save data to session
*/
protected function setSession()
{
$session = new Zend_Session_Namespace('ciblage');
$this->ciblage['NB']['total'] = $this->total;
$this->ciblage['NB']['insee'] = $this->insee;
$session->ciblage = $this->ciblage;
}
/**
* Enregistre un critère et sa valeur
* @param string $key
* @param mixed $value
2012-05-11 20:25:55 +00:00
* @param boolean $ex
*/
2012-05-11 20:25:55 +00:00
public function setCritere($key, $value, $ex = false)
{
2012-05-11 20:25:55 +00:00
//Remove critere for these values on all type of fields
if ( in_array($value, array('', '-', null)) ) {
unset($this->ciblage[$key]);
return;
}
2012-05-14 13:16:14 +00:00
if ( !is_array($value) ) {
//Remove all space in string value
$value = str_replace(' ', '', $value);
//Try to detect separator et transform as array
if ( preg_match_all('/([0-9A-Z]*)(,|;)/i', $value, $matches) ){
$value = $matches[1];
}
}
2012-05-11 20:25:55 +00:00
//Before to save the value
$types = array_keys($this->fields[$key]['fields']);
switch ( $types[0] ) {
case 'interval':
$value = explode(',', $value);
//@todo : Check Min Max
break;
case 'checkbox':
if ( $value==0 ) {
unset($this->ciblage[$key]);
return;
}
break;
}
2012-05-14 13:16:14 +00:00
2012-05-11 20:25:55 +00:00
//Save the value
if ($ex) {
$this->ciblage[$key]['ex'] = $value;
} else {
$this->ciblage[$key]['in'] = $value;
}
$this->setSession();
}
/**
* Définir les critères en une fois
* @param array $criteres Criteres as array with key => val
*/
public function setCriteres($criteres)
{
$this->ciblage = $criteres;
$this->setSession();
}
/**
* Désactivation d'un critère
* @param string $key
*/
public function unsetCritere($key)
{
2012-05-11 20:25:55 +00:00
if( key_exists($key, $this->ciblage) ) {
unset($this->ciblage[$key]);
$this->setSession();
}
}
/**
* Permet de supprimer une valeur dans une clef de session
* @param string $key
* @param mixed $valeur
*/
public function unsetCritereValue($key, $valeur) {
//@todo provisoir trouver une autre technique plus adapté.
if(key_exists($key, $this->ciblage)) {
$don = explode(',', $this->ciblage[$key]);
foreach ($don as $val) {
if($val == $valeur)
$don[key($don)] = '';
else
$new[] = $val;
}
if(count($new) > 0) {
$don = implode(',', $new);
if(!empty($don))
$this->ciblage[$key] = $don;
} else {
unset($this->ciblage[$key]);
}
$this->setSession();
}
}
/**
* Récupération de la valeur d'un critère
* @param string $key
*/
public function getCritere($key)
{
if(array_key_exists($key, $this->ciblage)) {
return $this->ciblage[$key];
}
return null;
}
/**
* Récupération des critères et de leurs valeurs
*/
public function getCriteres()
{
return $this->ciblage;
}
/**
* Définit un élément de comptage
* @param string $element
* @param integer $nb
*/
public function setNb($element, $nb)
{
$this->{$element} = $nb;
$this->setSession();
}
/**
* Récupére la valeur d'un élément de comptage
* @param string $element
*/
public function getNb($element)
{
return $this->{$element};
}
/**
* Suppression des critères de toutes une famille
* @param string $famille
*/
public function resetFamille($famille)
{
$reference = $this->getByFamille($famille);
foreach($this->ciblage as $name => $valeur) {
if($name != 'null') {
if(array_key_exists($name, $reference)) {
unset($this->ciblage[$name]);
}
}
}
$this->setSession();
}
/**
* Suppression de toutes les valeurs en session
*/
public function clearCiblage()
{
Zend_Session::namespaceUnset('ciblage');
}
public function getValues($val = null)
{
if ( $val === null ) {
2012-05-11 20:25:55 +00:00
$val = $this->getCriteres();
}
2012-05-11 20:25:55 +00:00
return $val;
}
public function selectArbo($name, $valeur)
{
$values = array();
switch($name)
{
case 'ape_etab' :
case 'ape_entrep' :
case 'ape_etab_ex':
case 'ape_entrep_ex':
$nafs = explode(',', $valeur);
foreach($nafs as $naf) {
if($naf != ' ') {
$values = array_merge($values, $this->nafArbo($name, $naf));
}
}
break;
case 'adr_dept':
case 'adr_reg':
case 'adr_com':
case 'adr_com_ex':
case 'adr_dept_ex':
$valeurs = explode(',', $valeur);
foreach($valeurs as $element) {
if(!empty($element)) {
$val = explode(':', $element);
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);
}
}
}
break;
case 'cj':
case 'cj_ex':
$valeurs = explode(',', $valeur);
foreach($valeurs as $valeur) {
if($valeur != ' ' and !empty($valeur))
$values = array_merge($values, $this->fj($name, trim($valeur)));
}
}
return ($values);
}
protected function fj($name, $valeur)
{
$table = new Application_Model_FormeJuridique();
if(strlen($valeur) < 5) {
$sql = $table->select('formejuridique', array('fjCode'))
->where('fjCode LIKE "'.$valeur.'%"');
} 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'];
}
}
return ($return);
}
protected function localisationArbo($name, $valeur)
{
if(strlen($valeur) == 2) {
switch($name) {
case 'adr_reg':
$table = new Application_Model_Departements();
$sql = $table->select()
->from('departements')
->where('codeRegionInsee ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $res) {
$return[] = trim($res['numdep']);
}
break;
case 'adr_dept':
case 'adr_dept_ex':
return (array($valeur));
break;
}
} else
return (array($valeur));
return ($return);
}
protected function nafArbo($key, $valeur)
{
$value = array();
$table = new Application_Model_Naf();
$valeur = trim($valeur);
if(strlen($valeur) == 1)
{
$sql = $table->select()->where('parent = ?', $valeur);
$result =$table->fetchAll($sql)->toArray();
foreach($result as $code) $where .= " code LIKE '".trim($code['code'])."%' and niveau = 5 or ";
$where = substr($where, 0, (strlen($where)) - 3);
$sql = $table->select()->where($where);
$result = $table->fetchAll($sql)->toArray();
foreach($result as $code) $value[] = $code['code'];
} else if(strlen($valeur) < 5){
$sql = $table->select()->where('code LIKE "'.trim($valeur).'%" and niveau = 5');
$result = $table->fetchAll($sql)->toArray();
foreach($result as $code) $value[] = $code['code'];
} else if(strlen($valeur) == 5) {
$value[] = $valeur;
}
return ($value);
}
2012-05-11 20:25:55 +00:00
protected function getMinMax($name)
{
2012-05-11 20:25:55 +00:00
$MinMaxM = new Application_Model_MinMax();
$minmax = $table->fetchAll($table->select()->where('cle = ?', $name))->toArray();
return $minmax;
}
public function getFields() {
return $this->fields;
}
public function get($name)
{
if ($this->fields[$name]['activated'] == true)
return $this->fields[$name];
return null;
}
public function getByFamille($famille)
{
$section = array();
foreach($this->fields as $name => $item) {
if($item['famille'] == $famille) {
$section[$name] = $item;
}
}
return ($section);
}
public function getNotActivated($fields)
{
foreach($fields as $name => $field)
{
if(!$field['activated']) {
$desactivated[$name] = "";
} else if ($field['activated']){
}
}
return (json_encode($desactivated));
}
public function getLibelle($name)
{
return $this->fields[$name]['label'];
}
}