array( 'label' => 'Sociétés Sieges', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select' ), 'sirenGrp' => array( 'label' => 'Société appartenant à un groupe', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select' ), 'tel' => array( 'label' => 'Contenant un Telephone', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select' ), 'fax' => array( 'label' => 'Contenant un Fax', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select', 'class' => null ), 'web' => array( 'label' => 'Contenant un site internet', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select', 'class' => null ), 'mail' => array( 'label' => 'Contenant une adresse email', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select', 'class' => null ), 'presentRcs' => array( 'label' => 'Société présente au RNCS', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select', 'class' => null ), 'adrDom' => array( 'label' => 'A une adresse de domiciliation', 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) ), 'famille' => 'entreprise', 'activated' => true, 'type' => 'select', 'class' => null ), 'dirNom' => array( 'label' => 'Contenant le 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\'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\'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' => 'Codes 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' => 'Codes 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' => 'L\'age de l\'etablissement', 'fields' => array( 'interval' => array('value' => null) ), 'famille' => 'economique', 'activated' => true, 'type' => 'interval', 'class' => null ), 'age_entrep' => array( 'label' => 'L\'age de l\'entreprise', '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\'etablissement', '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\'établassiment', '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_cp' => array( 'label' => 'Codes postaux', 'fields' => array( 'text' => array('value' => null), 'textarea' => array('value' => null) ), 'famille' => 'geographique', 'activated' => true, 'type' => 'textarea', 'class' => null, 'action' => 'geographique', 'title' => 'Localisation' ), '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' => 'Procédure collective dans l\'historique.', '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 getValues() { require_once 'Scores/SessionCiblage.php'; $session = new SessionCiblage(); $values = array(); foreach($session->getCriteres() as $key => $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_cp': $valeurs = explode(',', $valeur); foreach($valeurs as $element) { $array = $this->deptArbo($name, $element); if(!empty($array)) $values = array_merge($values, $array); } break; } return ($values); } 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']); } }