Prévisualisation
This commit is contained in:
parent
3b3df7a964
commit
7eaa286977
@ -183,43 +183,60 @@ class ComptageController extends Zend_Controller_Action
|
||||
$ciblage = new Ciblage($fields->getValues());
|
||||
$sirets = $ciblage->execute(true, 10);
|
||||
|
||||
|
||||
$dbConfig = Zend_Registry::get('configuration')->databases;
|
||||
try {
|
||||
$dbMetier = Zend_Db::factory($dbConfig->jo);
|
||||
} catch ( Exception $e ) {
|
||||
exit ( $e->getMessage() );
|
||||
}
|
||||
$i = 0;
|
||||
foreach($sirets as $siret) {
|
||||
if($i>10)
|
||||
break;
|
||||
$sql = $dbMetier->select()->from('etablissements_act')->where('siren = ?', substr($siret, 0, 9))
|
||||
->where('nic = ?', substr($siret, 9, strlen($siret)));
|
||||
$result = $dbMetier->fetchRow($sql);
|
||||
/*Provisoir...*/
|
||||
$result['tel'] = str_pad($result['tel'], 10, 0, STR_PAD_LEFT);
|
||||
$result['fax'] = str_pad($result['fax'], 10, 0, STR_PAD_LEFT);
|
||||
$previ[] = $result;
|
||||
$i++;
|
||||
}
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
//$object->getProfil($user->username, $user->idClient);
|
||||
$profilsM = new Application_Model_EnrichissementProfils();
|
||||
$sql = $profilsM->select()
|
||||
->where('login = ?', $user->username)
|
||||
->where('idClient = ?', $user->idClient);
|
||||
|
||||
//Make SQL request with the user profil for columns
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
$profilsM = new Application_Model_EnrichissementProfils();
|
||||
$sql = $profilsM->select()
|
||||
->where('login = ?', $user->username)
|
||||
->where('idClient = ?', $user->idClient);
|
||||
$result = $profilsM->fetchRow($sql);
|
||||
if(!empty($result)) {
|
||||
$result = $result->toArray();
|
||||
$champs = json_decode($result['criteres']);
|
||||
require_once('Scores/Enrichissement.php');
|
||||
$fields = new Enrichissement();
|
||||
$this->view->reference = $fields->getFields();
|
||||
|
||||
//@todo : Si il n'existe pas de profil, que faire ....
|
||||
|
||||
$profil = json_decode($result['criteres'], true);
|
||||
|
||||
$extractSql = $extractLabel = array();
|
||||
$extractSql[] = "CONCAT(LPAD(siren, 9, '000000000'), LPAD(nic, 5, '00000')) AS siret";
|
||||
$extractLabel[] = 'SIRET';
|
||||
|
||||
require_once('Scores/Enrichissement.php');
|
||||
$enrichissement = new Enrichissement();
|
||||
$data = $enrichissement->getFields();
|
||||
foreach ( $data as $key => $item ) {
|
||||
if (in_array($key, $profil)) {
|
||||
if ( array_key_exists('sql', $item) ) {
|
||||
$extractSql[] = $item['sql'];
|
||||
} else {
|
||||
$extractSql[] = $item['column'];
|
||||
}
|
||||
$extractLabel[] = $item['label'];
|
||||
}
|
||||
}
|
||||
$this->view->champs = $champs;
|
||||
$this->view->liste = $previ;
|
||||
|
||||
$sql = $dbMetier->select()
|
||||
->from('etablissements_act', $extractSql)
|
||||
->where('concat(siren, nic) IN('.join(',', $sirets).')');
|
||||
|
||||
$result = $dbMetier->fetchAll($sql);
|
||||
$liste = array();
|
||||
foreach ($result as $l => $line) {
|
||||
$tmp = array();
|
||||
foreach($line as $column => $data) {
|
||||
$tmp[] = $data;
|
||||
}
|
||||
$liste[] = $tmp;
|
||||
}
|
||||
|
||||
$this->view->assign('label', $extractLabel);
|
||||
$this->view->assign('liste', $liste);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
<style>
|
||||
.color{
|
||||
background-color: #DCE3FC;
|
||||
}
|
||||
</style>
|
||||
<div style="width:100%;">
|
||||
<style>
|
||||
.color{
|
||||
background-color: #DCE3FC;
|
||||
}
|
||||
</style>
|
||||
<table width="100%" style="font-size:10px;">
|
||||
<tr>
|
||||
<?php foreach($this->champs as $champ): ?>
|
||||
<th style="border-left:1px solid black;padding:2px;"><b><?php echo $champ; ?></b></th>
|
||||
<?php foreach($this->label as $label): ?>
|
||||
<th style="border-left:1px solid black;padding:2px;"><b><?=$label?></b></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php
|
||||
$i=0;
|
||||
if(count($this->liste) > 0) {
|
||||
foreach($this->liste as $societe) {
|
||||
foreach($this->liste as $line) {
|
||||
echo '<tr '.((($i%2) == 0)?'class="color"':'').'>';
|
||||
foreach($this->champs as $champ) {
|
||||
echo '<td style="border-left:1px solid silver;padding:2px">'.$societe[$this->reference[$champ]['column']].'</td>';
|
||||
foreach($line as $col) {
|
||||
echo '<td style="border-left:1px solid silver;padding:2px">'.$col.'</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
$i++;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class Enrichissement
|
||||
class Enrichissement
|
||||
{
|
||||
/**
|
||||
* Déclaration des colonnes de la table de données pour la transposition
|
||||
@ -13,7 +13,7 @@ class Enrichissement
|
||||
'autre_id' => array(),
|
||||
'siren' => array(), //Obligatoire
|
||||
'nic' => array(), //Obligatoire
|
||||
'actif' => array(
|
||||
'actif' => array(
|
||||
'values' => array(
|
||||
'1' => "actif",
|
||||
'0' => "inactif",
|
||||
@ -37,7 +37,7 @@ class Enrichissement
|
||||
'adr_comp' => array(), //Adresse - Complément
|
||||
'adr_cp' => array(), //Adresse
|
||||
'adr_ville' => array(), //Adresse
|
||||
'adr_dep' => array(), //Département | Code Commune
|
||||
'adr_dep' => array(), //Département | Code Commune
|
||||
'adr_com' => array(), //Code Commune
|
||||
'tel' => array(), //Telephone
|
||||
'fax' => array(), //Fax
|
||||
@ -89,7 +89,7 @@ class Enrichissement
|
||||
'51' => "2 000 à 4 999 salariés",
|
||||
'52' => "5 000 à 9 999 salariés",
|
||||
'53' => "10 000 salariés et plus",
|
||||
),
|
||||
),
|
||||
),
|
||||
'rang' => array(),
|
||||
'web' => array(),
|
||||
@ -143,7 +143,7 @@ class Enrichissement
|
||||
'bilHN' => array(),
|
||||
'bilYP' => array(),
|
||||
'avisCs' => array(),
|
||||
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
@ -153,31 +153,31 @@ class Enrichissement
|
||||
protected $fields = array(
|
||||
'actif' => array(
|
||||
'label' => "Actif",
|
||||
'column' => 'actif',
|
||||
'column' => 'actif',
|
||||
),
|
||||
'siege' => array(
|
||||
'label' => "Type d'établissement",
|
||||
'column' => 'siege'
|
||||
'siege' => array(
|
||||
'label' => "Type d'établissement",
|
||||
'column' => 'siege'
|
||||
),
|
||||
'raisonSociale' => array(
|
||||
'label' => "Raison Sociale",
|
||||
'column' => 'raisonSociale'
|
||||
'label' => "Raison Sociale",
|
||||
'column' => 'raisonSociale'
|
||||
),
|
||||
'enseigne' => array(
|
||||
'label' => "Enseigne",
|
||||
'column' => 'enseigne'
|
||||
'label' => "Enseigne",
|
||||
'column' => 'enseigne'
|
||||
),
|
||||
'sigle' => array(
|
||||
'label' => "Sigle",
|
||||
'column' => 'sigle'
|
||||
'label' => "Sigle",
|
||||
'column' => 'sigle'
|
||||
),
|
||||
'identite_pre' => array(
|
||||
'label' => "Identite Précédente",
|
||||
'column' => 'identite_pre'
|
||||
'label' => "Identite Précédente",
|
||||
'column' => 'identite_pre'
|
||||
),
|
||||
'marques' => array(
|
||||
'label' => "Marques déposées",
|
||||
'column' => 'marques'
|
||||
'label' => "Marques déposées",
|
||||
'column' => 'marques'
|
||||
),
|
||||
'adresse' => array(
|
||||
'label' => 'Adresse',
|
||||
@ -195,7 +195,7 @@ class Enrichissement
|
||||
'departement' => array(
|
||||
'label' => 'Département',
|
||||
'column' => 'adr_dep',
|
||||
),
|
||||
),
|
||||
'ville' => array(
|
||||
'label' => 'Ville',
|
||||
'column' => 'adr_ville',
|
||||
@ -206,23 +206,23 @@ class Enrichissement
|
||||
'sql' => 'CONCAT(adr_dep, adr_com) as codecom',
|
||||
),
|
||||
'tel' => array(
|
||||
'label' => "Téléphone",
|
||||
'label' => "Téléphone",
|
||||
'column' => 'tel' ,
|
||||
'sql' => 'LPAD(tel, 10, 0000000000) AS tel'
|
||||
),
|
||||
'fax' => array(
|
||||
'label' => "Fax",
|
||||
'label' => "Fax",
|
||||
'column' => 'fax',
|
||||
'sql' => 'LPAD(fax, 10, 0000000000) AS fax'
|
||||
),
|
||||
'cj' => array(
|
||||
'label' => "Forme juridique",
|
||||
'column' => 'cj'
|
||||
'column' => 'cj'
|
||||
),
|
||||
'dirigeant' => array(
|
||||
'label' => "Dirigeant",
|
||||
'dirigeant' => array(
|
||||
'label' => "Dirigeant",
|
||||
'column' => 'dirigeant',
|
||||
'sql' => "CONCAT_WS(' ', dirCiv, dirNom, dirPrenom) AS dirigeant",
|
||||
'sql' => "CONCAT_WS(' ', dirCiv, dirNom, dirPrenom) AS dirigeant",
|
||||
),
|
||||
'dirigeantFct' => array(
|
||||
'label' => "Dirigeant - Fonction",
|
||||
@ -259,7 +259,7 @@ class Enrichissement
|
||||
'capital' => array(
|
||||
'label' => "Capital",
|
||||
'column' => 'capital'
|
||||
),
|
||||
),
|
||||
'capitaldev' => array(
|
||||
'label' => "Devise Capital",
|
||||
'column' => 'capitalDev'
|
||||
@ -273,22 +273,33 @@ class Enrichissement
|
||||
'column' => 'age_etab'
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
public function __construct(){}
|
||||
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
|
||||
public function getSql($key)
|
||||
{
|
||||
if ( array_key_exists($key, $this->columns) ) {
|
||||
if ( array_key_exists('sql', $this->columns[$key]) ){
|
||||
return $this->columns[$key]['sql'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function getColumnValue($key)
|
||||
{
|
||||
if ( array_key_exists($key, $this->columns) ) {
|
||||
if ( array_key_exists('values', $this->columns[$key]) && count($this->columns[$key]['values'])>0 ){
|
||||
return $this->columns[$key]['values'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user