odea/library/Scores/Field.php

680 lines
18 KiB
PHP

<?php
Class Fields
{
protected $fields = array
(
'siege' => array(
'label' => 'Siege',
'fields' => array(
'select' => array('value' => array(1 => 'Oui', 0 => 'Non')),
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select'
),
'sirenGrp' => array(
'label' => 'Siren de groupe',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non')),
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select'
),
'tel' => array(
'label' => 'Telephone',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select'
),
'fax' => array(
'label' => 'Telecopie',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select',
'class' => null
),
'web' => array(
'label' => 'Site Internet',
'fields' => array(
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'select',
'class' => null
),
'mail' => array(
'label' => 'Email',
'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' => 'Oui', '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' => 'Oui', '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' => 'Nombre de marches publiques remportes',
'fields' => array(
'interval' => array('value' => array('0', '1000'))
),
'famille' => 'entreprise',
'activated' => true,
'type' => 'interval',
'class' => null
),
'dateCrea_ent' => array(
'label' => 'Date de création de l\'entreprose',
'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\'etablissement',
'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' => 'Code NAF Etablissement',
'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' => 'Code NAF Entreprise',
'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' => 'Code AGE Etablissement',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
'type' => 'textarea',
'class' => null
),
'age_entrep' => array(
'label' => 'Code AGE Entreprise',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'economique',
'activated' => true,
'type' => 'textarea',
'class' => null
),
'teff_entrep' => array(
'label' => 'Tranche d\'effectif de l\'Entreprise',
'fields' => array(
'select' => array('value' => array( '0,1' => 'De 0 à 1',
'1,2' => 'De 1 à 2',
'2,3' => 'De 2 à 3',
'3,11' => 'De 3 à 11',
'11,12' => 'De 11 à 12',
'12,21' => 'De 12 à 21',
'21, 22' => 'De 21 à 22',
'22,31' => 'De 21 a 31',
'31,32' => 'De 31 à 32',
'32,41' => 'De 32 à 41',
'41,42' => 'De 41 à 42',
'42,51' => 'De 42 à 51',
'51, 52' => 'De 51 à 52',
'52, 53' => 'De 52 à 53'))
),
'famille' => 'economique',
'activated' => true,
'type' => 'select',
'class' => null
),
'teff_etab' => array(
'label' => 'Tranche d\'effectif de l\'etablissement',
'fields' => array(
'select' => array('value' => array( '0,1' => 'De 0 à 1',
'1,2' => 'De 1 à 2',
'2,3' => 'De 2 à 3',
'3,11' => 'De 3 à 11',
'11,12' => 'De 11 à 12',
'12,21' => 'De 12 à 21',
'21, 22' => 'De 21 à 22',
'22,31' => 'De 21 a 31',
'31,32' => 'De 31 à 32',
'32,41' => 'De 32 à 41',
'41,42' => 'De 41 à 42',
'42,51' => 'De 42 à 51',
'51, 52' => 'De 51 à 52',
'52, 53' => 'De 52 à 53'))
),
'famille' => 'economique',
'activated' => true,
'type' => 'select',
'class' => null
),
'nbEtab' => array(
'label' => 'Tranche d\'effectif de l\'etablissement',
'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(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'economique',
'activated' => true,
'type' => 'interval',
'class' => null
),
//geographique
'adr_cp' => array(
'label' => 'Code postal',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null
),
'adr_dep' => array(
'label' => 'Département',
'fields' => array(
'text' => array('value' => null),
'textarea' => array('value' => null)
),
'famille' => 'geographique',
'activated' => true,
'type' => 'textarea',
'class' => null
),
'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
),
//juridique
'cj' => array(
'label' => 'Forme Juridique',
'fields' => array(
'select' => array('value' => array('1' => '1', '2' => '2', '3' => '3')),
),
'famille' => 'juridique',
'activated' => true,
'type' => 'select',
'class' => null
),
'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 d\'une procédure collective dans l\'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 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', 'E' => 'Estimé', 'R' => 'Réel')),
),
'famille' => 'financier',
'activated' => true,
'type' => 'select',
'class' => null
),
'avisCs' => array(
'label' => 'Informations de paiements',
'fields' => array(
'interval' => array('value' => null),
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilDuree' => array(
'label' => 'Durée du dernier bilan en mois',
'fields' => array(
'interval' => array('value'=> null),
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilTca' => array(
'label' => 'Tranche de CA issue du bilan',
'fields' => array(
'interval' => array('value' => null),
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'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',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilFL' => array(
'label' => 'CA total',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilFK' => array(
'label' => 'Chiffre d\'affaires Export',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilFR' => array(
'label' => 'Produits d\'Exploitation',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilGF' => array(
'label' => 'Charges d\'Exploitation',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilGP' => array(
'label' => 'Produits Financiers',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilGP' => array(
'label' => 'Charges Financières',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilGW' => array(
'label' => 'RCAI (résultat courant avant impôt)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilHD' => array(
'label' => 'Produits Exceptionnels',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilHH' => array(
'label' => 'Charges Exceptionnels',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilHL' => array(
'label' => 'Total des Produits',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilHM' => array(
'label' => 'Total des Charges',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilHN' => array(
'label' => 'Résultat',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
),
'bilYP' => array(
'label' => 'Effectif de l\'entreprise au dernier bilan (poste YP)',
'fields' => array(
'interval' => array('value' => array('0', '10000000'))
),
'famille' => 'financier',
'activated' => true,
'type' => 'interval',
'class' => null
)
);
protected $requeteSql = array('cj');
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']);
}
}