853 lines
23 KiB
PHP
853 lines
23 KiB
PHP
<?php
|
|
Class Fields
|
|
{
|
|
protected $fields = array
|
|
(
|
|
'siege' => array(
|
|
'label' => 'Type d\'établissement',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Sièges uniquement', '0' => 'Secondaires')),
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select'
|
|
),
|
|
'sirenGrp' => array(
|
|
'label' => 'Présence d\'un groupe',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select'
|
|
),
|
|
'tel' => array(
|
|
'label' => 'Téléphone renseigné',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select'
|
|
),
|
|
'fax' => array(
|
|
'label' => 'Télécopie renseignée',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'web' => array(
|
|
'label' => 'Site Web renseigné',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'mail' => array(
|
|
'label' => 'Email de contact renseigné',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'presentRcs' => array(
|
|
'label' => 'Etablissement présent au RNCS',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Etablissement présent au RNCS', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'adrDom' => array(
|
|
'label' => 'Adresse de domiciliation',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'dirNom' => array(
|
|
'label' => 'Nom du principal dirigeant',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Principal dirigeant renseigné', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'lieuAct' => array(
|
|
'label' => 'Lieu d\'activté',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000')),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null
|
|
),
|
|
'nbMPubli' => array(
|
|
'label' => 'Marchés publiques remportés',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'dateCrea_ent' => array(
|
|
'label' => 'Date de création de l\'entreprise',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => 'datepicker'
|
|
),
|
|
'dateCrea_etab' => array(
|
|
'label' => 'Date de création de l\'établissement',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => 'datepicker'
|
|
),
|
|
'nbActio' => array(
|
|
'label' => 'Nombre d\'actionnaires connus',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'nbPart' => array(
|
|
'label' => 'Nombre de participations connues',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'entreprise',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
// economique
|
|
'ape_etab' => array(
|
|
'label' => 'Activité de l\'établissement (Code NAF)',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null,
|
|
'action' => 'naf',
|
|
'title' => 'Selection des codes NAF etablissement'
|
|
),
|
|
'ape_entrep' => array(
|
|
'label' => 'Activité de l\'entreprise (Code NAF)',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null,
|
|
'action' => 'naf',
|
|
'title' => 'Selection des codes NAF entreprise'
|
|
),
|
|
'NaceEtab' => array(
|
|
'label' => 'Code NACE de l\'établissement',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null
|
|
),
|
|
'NaceEntrep' => array(
|
|
'label' => 'Code NACE de l\'entreprise',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null
|
|
),
|
|
'age_etab' => array(
|
|
'label' => 'Age de l\'entreprise',
|
|
'fields' => array(
|
|
'interval' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'age_entrep' => array(
|
|
'label' => 'Age de l\'établissement',
|
|
'fields' => array(
|
|
'interval' => array('value' => null)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'teff_entrep' => array(
|
|
'label' => 'Tranche d\'effectif de l\'Entreprise',
|
|
'fields' => array(
|
|
'intervalSelect' => array('value' => array(
|
|
array('0', '0'),
|
|
array('0', '1'),
|
|
array('1', '2'),
|
|
array('2', '3'),
|
|
array('3', '11'),
|
|
array('11', '12'),
|
|
array('12', '21'),
|
|
array('21', '22'),
|
|
array('22', '31'),
|
|
array('31', '32'),
|
|
array('32', '41'),
|
|
array('41', '42'),
|
|
array('42', '51'),
|
|
array('51', '52'),
|
|
array('52', '53')
|
|
))
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'intervalSelect',
|
|
'class' => null,
|
|
),
|
|
'teff_etab' => array(
|
|
'label' => 'Tranche d\'effectif de l\'établissement',
|
|
'fields' => array(
|
|
'intervalSelect' => array(
|
|
'value' => array(
|
|
array('0', '0'),
|
|
array('0', '1'),
|
|
array('1', '2'),
|
|
array('2', '3'),
|
|
array('3', '11'),
|
|
array('11', '12'),
|
|
array('12', '21'),
|
|
array('21', '22'),
|
|
array('22', '31'),
|
|
array('31', '32'),
|
|
array('32', '41'),
|
|
array('41', '42'),
|
|
array('42', '51'),
|
|
array('51', '52'),
|
|
array('52', '53')
|
|
)
|
|
)
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'intervalSelect',
|
|
'class' => null
|
|
),
|
|
'nbEtab' => array(
|
|
'label' => 'Nombre d\'établissements',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'eff_entrep' => array(
|
|
'label' => 'Effectif réel de l\'entreprise',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'eff_etab' => array(
|
|
'label' => 'Effectif réel de l\'établissement',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'economique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'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,
|
|
'type' => 'intervalSelect',
|
|
'class' => null
|
|
),
|
|
//geographique
|
|
'adr_com' => array(
|
|
'label' => 'Code commune Insee',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'geographique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null,
|
|
'action' => 'geographique',
|
|
'title' => 'Localisation'
|
|
),
|
|
//juridique
|
|
'cj' => array(
|
|
'label' => 'Forme Juridique',
|
|
'fields' => array(
|
|
'text' => array('value' => null),
|
|
'textarea' => array('value' => null)
|
|
),
|
|
'famille' => 'juridique',
|
|
'activated' => true,
|
|
'type' => 'textarea',
|
|
'class' => null,
|
|
'action' => 'juridique',
|
|
'title' => 'Forme Juridique'
|
|
),
|
|
'actifEco' => array(
|
|
'label' => 'Établissement économiquement actif',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
|
|
),
|
|
'famille' => 'juridique',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'procolHisto' => array(
|
|
'label' => 'Présence procédure collective dans histo',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
|
|
),
|
|
'famille' => 'juridique',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'tvaIntraValide' => array(
|
|
'label' => 'Numéro de TVA intracommunautaire valide',
|
|
'fields' => array(
|
|
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
|
|
),
|
|
'famille' => 'juridique',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'dateImmat' => array(
|
|
'label' => 'Date d\'immatriculation',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'juridique',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => 'datepicker'
|
|
),
|
|
//financier
|
|
'bilType' => array(
|
|
'label' => 'Type du dernier bilan',
|
|
'fields' => array(
|
|
'select' => array('value' => array('I' => 'Inconnue', 'R' => 'Réel', 'E' => 'Estimé')),
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'avisCs' => array(
|
|
'label' => 'Informations de paiements',
|
|
'fields' => array(
|
|
'select' => 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,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'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),
|
|
)
|
|
)
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'intervalSelect',
|
|
'class' => null
|
|
),
|
|
'bilTca' => array(
|
|
'label' => 'Tranche de CA issue du bilan',
|
|
'fields' => array(
|
|
'select' => 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,
|
|
'type' => 'select',
|
|
'class' => null
|
|
),
|
|
'bilAnnee' => array(
|
|
'label' => 'Dernière année de bilan',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilCloture' => array(
|
|
'label' => 'Dernière date de clôture du bilan',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '1000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => 'datepicker'
|
|
),
|
|
'bilEE' => array(
|
|
'label' => 'Total bilan (EE)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilFL' => array(
|
|
'label' => 'CA total (FL)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilFK' => array(
|
|
'label' => 'Chiffre d\'affaires Export (FK)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'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,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilGP' => array(
|
|
'label' => 'Charges Financières (GP)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'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,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilHD' => array(
|
|
'label' => 'Produits Exceptionnels (HD)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilHH' => array(
|
|
'label' => 'Charges Exceptionnels (HH)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilHL' => array(
|
|
'label' => 'Total des Produits (HL)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilHM' => array(
|
|
'label' => 'Total des Charges (HM)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilHN' => array(
|
|
'label' => 'Résultat (HN)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
),
|
|
'bilYP' => array(
|
|
'label' => 'Effectif salarié (YP)',
|
|
'fields' => array(
|
|
'interval' => array('value' => array('0', '10000000'))
|
|
),
|
|
'famille' => 'financier',
|
|
'activated' => true,
|
|
'type' => 'interval',
|
|
'class' => null
|
|
)
|
|
);
|
|
protected $requeteSql = array('cj');
|
|
|
|
public function getValues()
|
|
{
|
|
require_once 'Scores/SessionCiblage.php';
|
|
$session = new SessionCiblage();
|
|
$values = array();
|
|
|
|
foreach($session->getCriteres() 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']))
|
|
{
|
|
$values[$key] = explode(',', $item);
|
|
} else if (!empty($this->fields[$key]['action'])) {
|
|
$values[$key] = $this->selectArbo($key, $item);
|
|
} else {
|
|
$values[$key] = $item;
|
|
}
|
|
}
|
|
}
|
|
return ($values);
|
|
}
|
|
|
|
public function selectArbo($name, $valeur)
|
|
{
|
|
$values = array();
|
|
switch($name)
|
|
{
|
|
case 'ape_etab' :
|
|
case 'ape_entrep' :
|
|
$nafs = explode(',', $valeur);
|
|
foreach($nafs as $naf)
|
|
$values = array_merge($values, $this->nafArbo($name, $naf));
|
|
break;
|
|
case 'adr_com':
|
|
$valeurs = explode(',', $valeur);
|
|
foreach($valeurs as $element) {
|
|
$array = $this->localisationArbo($name, $element);
|
|
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));
|
|
}
|
|
return ($values);
|
|
}
|
|
|
|
protected function fj($name, $valeur)
|
|
{
|
|
$table = new Table_Formejuridiques();
|
|
|
|
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) == 3) {
|
|
switch($valeur[0]) {
|
|
case 'R':
|
|
$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)))
|
|
->setIntegrityCheck(false);
|
|
$result = $table->fetchAll($sql)->toArray();
|
|
foreach ($result as $res) {
|
|
$return[] = $res['INSEE'];
|
|
}
|
|
break;
|
|
case 'D':
|
|
$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)))
|
|
->setIntegrityCheck(false);
|
|
$result = $table->fetchAll($sql)->toArray();
|
|
foreach ($result as $res) {
|
|
$return[] = $res['INSEE'];
|
|
}
|
|
break;
|
|
}
|
|
} else
|
|
return (array($valeur));
|
|
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();
|
|
|
|
if(strlen($valeur) == 1)
|
|
{
|
|
$sql = $table->select()->where('parent = ?', $valeur);
|
|
$result =$table->fetchAll($sql)->toArray();
|
|
foreach($result as $code) $where .= " code LIKE '".$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 '".$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);
|
|
}
|
|
|
|
public function __construct($login)
|
|
{
|
|
require_once('Scores/SessionCiblage.php');
|
|
$session = new SessionCiblage();
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
$user = $auth->getIdentity();
|
|
|
|
$db = Zend_Registry::get('db');
|
|
/*$prefsModel = new Application_Model_Prefs($db);
|
|
|
|
$prefs = $prefsModel->find($login);
|
|
$json = $prefs->json;*/
|
|
|
|
foreach($this->fields as $name => $valeur) {
|
|
/*if(!empty($json))
|
|
{
|
|
$prefs = json_decode($json);
|
|
if(!empty($prefs)) {
|
|
if(array_key_exists($name, $prefs)) {
|
|
$this->fields[$name]['activated'] = false;
|
|
if(is_array($this->fields[$name]['type'])) {
|
|
$this->fields[$name]['type'] = $prefs[$name];
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
/*if(in_array($name, $this->requeteSql)) {
|
|
$formeJuridiques = new Application_Model_Formejuridique();
|
|
$sql = $formeJuridiques->select()->where('fjCode > 1000');
|
|
$formeJuridiques = $formeJuridiques->fetchAll($sql)->toArray();
|
|
$value = array();
|
|
foreach($formeJuridiques as $form) {
|
|
$value[$form['fjCode']] = $form['fjLibelle'].' ['.$form['fjCode'].']';
|
|
}
|
|
asort($value);
|
|
$this->fields[$name]['fields']['select']['value'] = $value;
|
|
}*/
|
|
}
|
|
}
|
|
|
|
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']);
|
|
}
|
|
} |