odea/library/Scores/Field.php
2012-04-10 14:02:40 +00:00

1066 lines
28 KiB
PHP

<?php
/**
* Structure
* [name] => array(
* label =>
* fields => array(
* select => array()
* ...
* )
* famille =>
* activated =>
* type =>
*
* export => array( //Si présent paramètres pour l'enrichissement
* 'label' => Libellé pour affichage dans l'enrichissement
* 'valuedesc' => array( / valeur => libellé / )
* )
* )
*/
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'
),
'action' => array(
'label' => 'Présence d\'actionnaires',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select',
'class' => null
),
'nbActio' => array(
'label' => 'Nombre d\'actionnaires connus',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'interval',
'class' => null
),
'part' => array(
'label' => 'Nombre de participations connues',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select',
'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', '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'),
array('53', '0')
))
),
'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', '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'),
array('53', '0')
)
)
),
'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' => 'Localisation géographique',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => 'geographique',
'title' => 'Localisation'
),
'adr_com_ex' => array(
'label' => 'Localisation Villes (Exclure)',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'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' => 'geographique',
'title' => 'Localisation'
),
'adr_dept_ex' => array(
'label' => 'Liste départements (Exclure)',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null,
'action' => 'geographique',
'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' => 'geographique',
'title' => 'Localisation'
),
'adr_reg_ex' => array(
'label' => 'Liste code région (Exclure)',
'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',
),
//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'
),
'cj_ex' => array(
'label' => 'Forme Juridique (Exclure)',
'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(
'selectMultiple' => array('value' => array(
'I' => 'Inconnue',
'R' => 'Réel',
'E' => 'Estimé')
),
),
'famille' => 'financier',
'activated' => true,
'type' => 'selectMultiple',
'class' => null
),
'bilType_ex' => array(
'label' => 'Type du dernier bilan (Exclure)',
'fields' => array(
'selectMultiple' => array('value' => array(
'I' => 'Inconnue',
'R' => 'Réel',
'E' => 'Estimé')
),
),
'famille' => 'financier',
'activated' => true,
'type' => 'selectMultiple',
'class' => null
),
'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,
'type' => 'selectMultiple',
'class' => null
),
'avisCs_ex' => array(
'label' => 'Informations de paiements (Exclure)',
'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,
'type' => 'selectMultiple',
'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),
array(23, 0)
)
)
),
'famille' => 'financier',
'activated' => true,
'type' => 'intervalSelect',
'class' => null
),
'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,
'type' => 'selectMultiple',
'class' => null
),
'bilTca_ex' => array(
'label' => 'Tranche de CA issue du bilan (Exclure)',
'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,
'type' => 'selectMultiple',
'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($val = null)
{
if ( $val === null ) {
require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage();
$val = $session->getCriteres();
}
$values = array();
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']))
{
$values[$key] = explode(',', $item);
} else if (!empty($this->fields[$key]['action'])) {
if(!empty($values[$key])) {
$values[$key] = array_merge($this->selectArbo($key, $item), $values[$key]);
}
else {
if($key == 'adr_reg') {
if(!empty($values['adr_dept']))
$values['adr_dept'] = array_merge($this->selectArbo($key, $item), $values['adr_dept']);
else
$values['adr_dept'] = $this->selectArbo($key, $item);
}else {
$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) {
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, $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) == 2) {
switch($name) {
case 'adr_reg':
$table = new Table_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 Table_Nafs();
$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);
}
public function __construct($batch = false)
{
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']);
}
}
}
}
}
static public function getMinMax($name)
{
$tab = array('dateCrea_ent','dateCrea_etab');
if(!in_array($name, $tab)) {
$table = new Table_Minmaxs();
return ($table->fetchAll($table->select()->where('cle = ?', $name))->toArray());
}
return (array());
}
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']);
}
}