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++;
|
||||
}
|
||||
|
||||
//Make SQL request with the user profil for columns
|
||||
$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);
|
||||
$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++;
|
||||
|
@ -281,6 +281,17 @@ class Enrichissement
|
||||
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) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user