This commit is contained in:
Michael RICOIS 2012-05-22 06:38:00 +00:00
commit a11b00afd5
22 changed files with 387 additions and 146 deletions

View File

@ -55,4 +55,19 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
Zend_Registry::set('db', $db);
}
protected function _initCache()
{
//MetadataCache pour la base de données
$frontendOptions = array(
'lifetime' => 14400,
'automatic_serialization' => true
);
$backendOptions = array();
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
//Cache pour les données de la base à stocker
}
}

View File

@ -157,11 +157,15 @@ class DashboardController extends Zend_Controller_Action
//Construction affichage des critères
foreach ( $decodeCriteres as $key => $item ) {
$inValue = $fields->getValueLabel($key, $item['in']);
$exValue = $fields->getValueLabel($key, $item['ex']);
//Add label to struct for display
$infosCriteres[] = array(
'label' => $fields->getLabel($key),
'in' => $item['in'],
'ex' => $item['ex'],
'in' => $inValue,
'ex' => $exValue,
);
}

View File

@ -136,7 +136,6 @@ class EnrichissementController extends Zend_Controller_Action
);
$identifiantsM = new Application_Model_EnrichissementIdentifiants();
$idIdentifiant = $identifiantsM->insert($data);
//exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$idIdentifiant);
}
/**
@ -169,9 +168,7 @@ class EnrichissementController extends Zend_Controller_Action
->order('dateAjout DESC')
->limit(1);
$comptages = $comptagesM->fetchAll($sql);
$old = $comptages;
$oldResultat = $old[0]->resultat;
$oldResultatInsee = $old[0]->uniteInsee;
if ( $comptages->count()>0 ) {
$item = $comptages[0];
$date = explode(' ', $item->dateAjout);
@ -208,12 +205,6 @@ class EnrichissementController extends Zend_Controller_Action
$this->view->infoInsee = $infoInsee;
$this->view->id = $item['id'];
/*$this->view->oldDate = $date;
$this->view->oldResult = $oldResultat;
$this->view->oldResultInsee = $oldResultatInsee;
$this->view->oldPrice = round(($oldResultat* $profil->tarifLigne)+ $oldResultatInsee);
$this->view->oldPriceInsee = round($oldResultatInsee*$redevanceInsee, 2);*/
$this->view->criteres = $criteres;
}
}

View File

@ -1,22 +0,0 @@
<?php
Class ExtractController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
require_once 'Scores/Ciblage.php';
require_once 'Scores/Field.php';
$field = new Fields();
$ciblage = new Ciblage($field->getValues());
$ciblage->extract();
}
public function batchAction()
{
$action = $this->getRequest();
$request = $action->getParam('reference');
}
}

View File

@ -12,6 +12,9 @@ class GestionController extends Zend_Controller_Action
$this->view->headScript()->appendFile('/themes/default/scripts/dashboard.js', 'text/javascript');
}
/**
* Display all links
*/
public function indexAction()
{
@ -47,8 +50,9 @@ class GestionController extends Zend_Controller_Action
$this->view->assign('profils', $profils);
}
public function profilAction(){}
/**
* Define fields for extraction to user
*/
public function profiladdAction()
{
$request = $this->getRequest();
@ -116,7 +120,97 @@ class GestionController extends Zend_Controller_Action
}
public function comptagesAction()
/**
* List commands which must be done
*/
public function commandesAction()
{
$request = $this->getRequest();
$commandesM = new Application_Model_EnrichissementIdentifiants();
$sql = $commandesM->select()->setIntegrityCheck(false)
->from('enrichissement_identifiants AS e', array(
'e.id',
'e.reference AS commandeReference',
'e.nbLigneTotales',
'e.uniteInsee',
"DATE_FORMAT(e.dateAdded, '%Y/%m/%d %H:%i:%s') AS dateAdded"
))
->join('criteres', 'idCriteres = criteres.id', array(
'criteres.reference AS critereReference',
'criteres.login',
))
->where('e.dateStart = ?', "0000-00-00 00:00:00")
->where('fichier = ""')
->order('e.dateAdded DESC');
$this->view->commandes = $commandesM->fetchAll($sql)->toArray();
}
/**
* List commands with a file
*/
public function enrichissementsAction()
{
$commandesM = new Application_Model_EnrichissementIdentifiants();
$sql = $commandesM->select()->setIntegrityCheck(false)
->from('enrichissement_identifiants AS e', array(
'e.id',
'e.reference AS commandeReference',
'e.nbLigneTotales',
'e.uniteInsee',
"DATE_FORMAT(e.dateAdded, '%Y/%m/%d %H:%i:%s') AS dateAdded"
))
->join('criteres', 'idCriteres = criteres.id', array(
'criteres.reference AS critereReference',
'criteres.login',
))
->where('fichier != ""')
->order('e.dateAdded DESC');
$this->view->commandes = $commandesM->fetchAll($sql)->toArray();
}
/**
* Load enrichissement batch to complete data
*/
public function enrichitAction()
{
$request = $this->getRequest();
$id = $request->getParam('id');
exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$id.' &');
}
/**
* Extract sirets from database
* @todo : To csv file
*/
public function siretscsvAction()
{
$id = $this->getRequest()->getParam('id');
$table = new Application_Model_EnrichissementIdentifiants();
$sql = $table->select()
->where('idComptage = ?', $id);
$result = $table->fetchRow($sql);
if(!empty($result)) {
$result = $result->toArray();
$sirets = json_decode($result['identifiants'], true);
foreach($sirets as $siret) {
echo $siret."\n";
}
}else {
echo 'Aucune commande d\'enrichissement sur ce comptage';
}
exit;
}
/**
* List criteres and the last count
*/
public function ciblagesAction()
{
$comptagesM = new Application_Model_Comptages();
@ -137,30 +231,4 @@ class GestionController extends Zend_Controller_Action
$this->view->comptages = $comptages;
}
public function enrichissementsAction()
{
$table = new Application_Model_EnrichissementIdentifiants();
$sql = $table->select()
->order('dateAdded DESC');
$this->view->enrichissements = $table->fetchAll($sql)->toArray();
}
public function extractAction()
{
$id = $this->getRequest()->getParam('id');
$table = new Application_Model_EnrichissementIdentifiants();
$sql = $table->select()
->where('idComptage = ?', $id);
$result = $table->fetchRow($sql);
if(!empty($result)) {
$result = $result->toArray();
$sirets = json_decode($result['identifiants'], true);
foreach($sirets as $siret) {
echo $siret."\n";
}
}else {
echo 'Aucune commande d\'enrichissement sur ce comptage';
}
exit;
}
}

View File

@ -24,12 +24,56 @@ class IndexController extends Zend_Controller_Action
if($ajax)
$this->_helper->layout()->disableLayout();
$session = new Scores_Fields();
$fields = new Scores_Fields();
$this->view->field = $session;
$this->view->criteres = $session->getCriteres();
$infosCriteres = array();
$decodeCriteres = $fields->getCriteres();
//Construction affichage des critères
foreach ( $decodeCriteres as $key => $item ) {
$inValue = $fields->getValueLabel($key, $item['in']);
$exValue = $fields->getValueLabel($key, $item['ex']);
$infosCriteres[$key] = array(
'label' => $fields->getLabel($key),
'in' => $inValue,
'ex' => $exValue,
);
}
$this->view->infos = $infosCriteres;
}
public function criterelistAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$critere = $request->getParam('key');
$fields = new Scores_Fields();
$values = $fields->getCritere($critere);
//Inclusion
if (count($values['in'])>0) {
$inLabels = $fields->getValueLabel($critere, $values['in']);
$inValues = array_values($values['in']);
$this->view->assign('inLabels', $inLabels);
$this->view->assign('inValues', $inValues);
}
//Exclusion
if (count($values['ex'])>0) {
$exLabels = $fields->getValueLabel($critere, $values['ex']);
$exValues = array_values($values['ex']);
$this->view->assign('exLabels', $exLabels);
$this->view->assign('exValues', $exValues);
}
}
public function removeAction()
{
$this->_helper->layout()->disableLayout();

View File

@ -12,9 +12,35 @@
<fieldset>
<legend>Critères</legend>
<pre>
<?php print_r($this->criteres)?>
</pre>
<?php foreach ( $this->criteres as $criteres ) { ?>
<div>
<h3><?=$criteres['label']?></h3>
<?php if (is_string($criteres['in'])) {?>
<div><?=$criteres['in']?></div>
<?php } else {?>
<?php if ( is_array($criteres['in']) && count($criteres['in'])>0 ) { ?>
<div>
<p>Inclu :</p>
<?php foreach( $criteres['in'] as $item ) {?>
<p><?=$item?></p>
<?php }?>
</div>
<?php }?>
<?php if ( is_array($criteres['ex']) && count($criteres['ex'])>0 ) { ?>
<div>
<p>Exclu :</p>
<?php foreach( $criteres['ex'] as $item ) {?>
<p><?=$item?></p>
<?php }?>
</div>
<?php }?>
<?php }?>
</div>
<?php }?>
</fieldset>
<fieldset>

View File

@ -1,5 +1,5 @@
<div id="dashboard">
<h2>Liste des comptages</h2>
<h2>Liste des ciblages</h2>
<div>
<table>
<tr>
@ -19,9 +19,6 @@
<td><?=$comptage['uniteInsee']?></td>
<td>
<a href="">Actualiser</a>
<a class="enrichissementref" href="<?=$this->url(array('controller'=> 'enrichissement','action'=>'reference', 'id'=>$comptage['idDefinition']))?>">Enrichissement</a>
<a href="<?=$this->url(array('controller'=> 'gestion','action'=>'extract', 'id'=>$comptage['idDefinition']))?>">Extraire les sirets</a>
<a href="">Supprimer</a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -0,0 +1,30 @@
<div id="dashboard">
<h2>Liste des commandes</h2>
<div>
<table>
<tr>
<th><b>Date de création</b></th>
<th><b>Référence</b></th>
<th><b>Résultat</b></th>
<th><b>Insee</b></th>
<th><b>login</b></th>
<th><b>Reférence ciblage</b></th>
<th><b>Actions</b></th>
</tr>
<?php foreach($this->commandes as $item): ?>
<tr>
<td><?=$item['dateAdded']?></td>
<td><?=$item['commandeReference']?></td>
<td><?=$item['nbLigneTotales']?></td>
<td><?=$item['uniteInsee']?></td>
<td><?=$item['login']?></td>
<td><?=$item['critereReference']?></td>
<td>
<a class="enrichissementref" href="<?=$this->url(array('controller'=> 'gestion','action'=>'enrichit', 'id'=>$item['id']))?>">Enrichissement</a>
<a href="<?=$this->url(array('controller'=> 'gestion','action'=>'extract', 'id'=>$item['id']))?>">Extraire les sirets</a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>

View File

@ -1,29 +1,29 @@
<div id="dashboard">
<h2>Liste des comptages</h2>
<h2>Liste des commandes</h2>
<div>
<table>
<tr>
<th><b>Id comptage</b></th>
<th><b>Reference</b></th>
<th><b>NB Ligne Totales</b></th>
<th><b>NB Ligne Traites</b></th>
<th><b>Unitee INSEE</b></th>
<th><b>Date création</b></th>
<th><b>Date début</b></th>
<th><b>Date d'arret</b></th>
<th><b>Date de création</b></th>
<th><b>Référence</b></th>
<th><b>Résultat</b></th>
<th><b>Insee</b></th>
<th><b>login</b></th>
<th><b>Reférence ciblage</b></th>
<th><b>Fichier</b></th>
<th><b>Actions</b></th>
</tr>
<?php foreach($this->enrichissements as $enrichissement): ?>
<?php foreach($this->commandes as $item): ?>
<tr>
<td><?php echo $enrichissement['idComptage']; ?></td>
<td><?php echo $enrichissement['reference']; ?></td>
<td><?php echo $enrichissement['nbLigneTotales']; ?></td>
<td><?php echo $enrichissement['nbLigneTraites']; ?></td>
<td><?php echo $enrichissement['uniteInsee']; ?></td>
<td><?php echo $enrichissement['dateAdded']; ?></td>
<td><?php echo $enrichissement['dateStart']; ?></td>
<td><?php echo $enrichissement['dateStop']; ?></td>
<td><a href="/enrichissement/download/id/<?php echo $enrichissement['id'];?>"><?php echo $enrichissement['fichier']; ?></a></td>
<td><?=$item['dateAdded']?></td>
<td><?=$item['commandeReference']?></td>
<td><?=$item['nbLigneTotales']?></td>
<td><?=$item['uniteInsee']?></td>
<td><?=$item['login']?></td>
<td><?=$item['critereReference']?></td>
<td>
<a class="enrichissementref" href="<?=$this->url(array('controller'=> 'enrichissement','action'=>'reference', 'id'=>$comptage['idDefinition']))?>">Enrichissement</a>
<a href="<?=$this->url(array('controller'=> 'gestion','action'=>'extract', 'id'=>$comptage['idDefinition']))?>">Extraire les sirets</a>
</td>
</tr>
<?php endforeach; ?>
</table>

View File

@ -5,8 +5,10 @@
<a href="<?=$this->url(array('controller'=>'gestion', 'action'=>'profiladd'))?>">Créer un profil d'enrichissement pour un client (idClient, login)</a>
<h2>Gestion des commandes</h2>
<a href="<?php echo $this->url(array('controller' => 'gestion', 'action' => 'comptages'));?>">Liste des comptages</a><br />
<a href="<?php echo $this->url(array('controller' => 'gestion', 'action' => 'enrichissements'));?>">Liste des enrichissements</a>
<a href="<?=$this->url(array('controller' => 'gestion', 'action' => 'commandes'));?>">Liste des commandes</a><br />
<a href="<?=$this->url(array('controller' => 'gestion', 'action' => 'enrichissements'));?>">Liste des commandes terminées</a><br/>
<a href="<?=$this->url(array('controller' => 'gestion', 'action' => 'ciblages'));?>">Liste des ciblages</a><br />
<h2>Facturation</h2>
</div>

View File

@ -0,0 +1,15 @@
<?php if (count($this->inValues)>0) {?>
<ul>
<?php foreach ($this->inValues as $i => $item) {?>
<li><?=$this->inLabels[$i]?></li>
<?php }?>
</ul>
<?php }?>
<?php if (count($this->exValues)>0) {?>
<ul>
<?php foreach ($this->exValues as $i => $item) {?>
<li><?=$this->exLabels[$i]?></li>
<?php }?>
</ul>
<?php }?>

View File

@ -5,6 +5,7 @@
#criteres {
border: 1px solid;
padding:10px 0;
margin: 0 1px;
}
#criteres tr td {
@ -17,49 +18,30 @@
<div id="criteres">
<?php $color = 0;foreach($this->criteres as $critere => $valeur):?>
<?php $label = $this->field->get($critere); ?>
<?php if($valeur != 'tous' and $valeur != null and $valeur != 'null' and $valeur != ',' and !empty($valeur)):?>
<?php if(!is_array($valeur)) {$valeur = explode(',', $valeur);} ?>
<?php if ( count($this->infos)>0 ) {?>
<?php $color = 0;?>
<?php foreach($this->infos as $critere => $item) {?>
<div style="width:100%;" class="clearfix<?php echo ((($color%2) == 0) ? ' color' : ''); $color++; ?>">
<div style="float:left; margin:2px 0;">
<?=$label['label'];?>
<?php if(is_array($valeur)):?>
<?php $i=0; foreach ($valeur as $val):?>
<?php if($i>5)break; ?>
<?php if($label['type'] != 'textarea' and $label['type'] != 'interval' and $label['type'] != 'intervalSelect') :?>
<?php echo $label['fields'][$label['type']]['value'][$val];?> <?php (($i%3 == 0)?'<br />':''); $i++;?>
<?php else :?>
<?php
if($label['type'] == 'interval') {
if(empty($val)) {
echo '-';
} else
echo $val;
} else
echo $val.', ';
?>
<?php $i++; endif;?>
<?php endforeach;?>
<?php else: ?>
<?php echo $val;?>
<?php endif; ?>
<?=$item['label']?>
<?php if ( is_string($item['in']) && !empty($item['in']) ) { ?>
<br/>&nbsp;&nbsp;<?=$item['in']?>
<?php } elseif ( is_array($item['in']) || is_array($item['ex']) ) {?>
<br/>&nbsp;&nbsp;<a class="criterelist" href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist', 'key'=>$critere), null, true)?>">Liste</a>
<?php }?>
</div>
<div style="height:16px; width:16px; float:right;">
<a class="remove" href="index/remove/critere/<?=$critere;?>">
<a class="remove" href="<?=$this->url(array('controller'=>'index', 'action'=>'remove', 'critere'=>$critere), null, true)?>">
<img src="/themes/default/images/cross.png" />
</a>
</div>
</div>
<?php endif;?>
<?php endforeach;?>
<?php }?>
<?php }?>
</div>

View File

@ -1,11 +1,11 @@
<div id="panel"><?=$this->action('criteres', 'index');?></div>
<div id="panel"><?=$this->action('criteres', 'index')?></div>
<div id="tabs">
<ul>
<li div="_entreprise"><a href="#tabs-1">Critères Entreprise</a></li>
<li div="_economique"><a href="#tabs-2">Situation économique</a></li>
<li div="_geographique"><a href="#tabs-3">Secteur géographique</a></li>
<li div="_juridique"><a href="#tabs-4">Situation juridique</a></li>
<li div="_financiere"><a href="#tabs-5">Situation financière</a></li>
<li><a href="#tabs-1">Critères Entreprise</a></li>
<li><a href="#tabs-2">Situation économique</a></li>
<li><a href="#tabs-3">Secteur géographique</a></li>
<li><a href="#tabs-4">Situation juridique</a></li>
<li><a href="#tabs-5">Situation financière</a></li>
</ul>
<div id="tabs-1"><?=$this->action('index', 'entreprise')?></div>
<div id="tabs-2"><?=$this->action('index', 'economique')?></div>

View File

@ -74,7 +74,8 @@ if ($opts->id)
->where('id = ?', $commande['idProfil']);
$profil = $db->fetchRow($sql);
$dataProfil = json_decode($profil['criteres'], true);
} else if ($opts->file)
}
else if ($opts->file)
{
}

View File

@ -17,6 +17,7 @@ jo.params.host=192.168.78.230
jo.params.username=ciblage
jo.params.password=z7jq8AhvrwqQJ4Yb
jo.params.dbname=jo
jo.params.persistent = true
jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
[sphinx]

View File

@ -17,6 +17,7 @@ jo.params.host=192.168.78.230
jo.params.username=ciblage
jo.params.password=z7jq8AhvrwqQJ4Yb
jo.params.dbname=jo
jo.params.persistent = true
jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
[sphinx]

View File

@ -737,7 +737,8 @@ class Scores_Fields
switch ( $types[0] ) {
case 'interval':
//@todo : Check Min Max
//@todo : Check Number => A préciser dans Fields
//@todo : Check Date => A préciser dans Fields
break;
case 'checkbox':
if ( $value==0 ) {
@ -745,6 +746,9 @@ class Scores_Fields
return;
}
break;
case 'tree':
//Check values
break;
}
//Save the value
@ -923,6 +927,61 @@ class Scores_Fields
return $this->fields[$name]['label'];
}
public function getValueLabelNaf($values)
{
$values = array_map(function($value){ return '"'.$value.'"'; }, $values);
$out = array();
$nafM = new Application_Model_Naf();
$sql = $nafM->select()->from($nafM, array('lib'))->where('code IN ('.join(',',$values).')');
$result = $nafM->fetchAll($sql)->toArray();
foreach ( $result as $elem ) {
$out[] = $elem['lib'];
}
return $out;
}
public function getValueLabel($name, $values)
{
if (count($values)>0 && array_key_exists($name, $this->fields)) {
$fieldsType = array_keys($this->fields[$name]['fields']);
$firstType = $fieldsType[0];
$fieldsValues = $this->fields[$name]['fields'][$firstType]['value'];
switch($firstType) {
case 'select':
case 'selectMultiple':
if (is_array($values)) {
$out = array();
foreach ( $values as $item ){
if (array_key_exists($item, $fieldsValues)) {
$out[] = $fieldsValues[$item];
}
}
return $out;
} else {
if (array_key_exists($values, $fieldsValues)) {
return $fieldsValues[$values];
}
}
break;
case 'interval':
// de X à X [unités]
break;
case 'tree':
$action = ucfirst($this->fields[$name]['fields'][$firstType]['action']);
return $this->{'getValueLabel'.$action}($values);
//Recherche des valeurs
break;
}
}
return '';
}
public function getInfoCritere()
{

View File

@ -19,6 +19,31 @@ $(document).ready(function()
}
});
$("div#criteres a.criterelist").on('click', function(e){
e.preventDefault();
e.preventDefault();
var title = $(this).attr('title');
var href = $(this).attr('href');
var dialogOpts = {
bgiframe: true,
title: title,
width: 500,
height: 300,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
},
buttons: {
Fermer: function() { $(this).dialog('close'); }
},
close: function() { $('#dialogtree').remove(); }
};
$('<div id="dialogcritere"></div>').dialog(dialogOpts);
return false;
});
$('#tabs').delegate('select.criteres', 'change', function(e){
e.stopPropagation();
if ( !$(this).attr('size') ){
@ -193,6 +218,10 @@ $(document).ready(function()
}
});
});
function set(key, value, ex)

View File

@ -19,7 +19,7 @@ a img { border:none } /* Gets rid of IE's blue borders */
body {
background: url("/themes/default/images/bg-home-tile.jpg") repeat-x scroll 50% 0 #bebebe;
color: #000000;
font: 0.8em "Trebuchet MS",Verdana,Helvetica,Arial,sans-serif;
font: 0.8em Verdana,Helvetica,Arial,sans-serif;
margin: 0;
padding: 0;
}