Merge depuis branches 1.1

This commit is contained in:
Michael RICOIS 2012-03-09 09:03:35 +00:00
commit 7397619660
18 changed files with 383 additions and 95 deletions

View File

@ -0,0 +1,9 @@
<?php
class AideController extends Zend_Controller_Action
{
public function indexAction(){}
public function aproposdeAction(){}
}

View File

@ -55,11 +55,12 @@ class DashboardController extends Libs_Controller
public function ciblageAction()
{
require_once('Scores/Field.php');
$object = new Object_Dashboard();
$request = $this->getRequest();
$comptage = $object->ciblagedetail($request->getParam('id'));
$this->view->label = new Fields();
$this->view->criteres = $comptage['criteres'];
$this->view->comptages = $comptage['comptages'];

View File

@ -57,7 +57,7 @@ class EnrichissementController extends Zend_Controller_Action
$request = $this->getRequest();
$key = $request->getParam('key', '');
if (!empty($key)) {
if ( !empty($key) ) {
//$rep sera égal à false si la clef n'existe pas dans le cache apc
$rep = apc_fetch('upload_'.$key);
echo json_encode($rep);
@ -76,9 +76,19 @@ class EnrichissementController extends Zend_Controller_Action
//Vérifier les profils du client
if ( $idProfil===null ){
//Selection du profil du client
}
//Selection du profil du client
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$profilsM = new Table_EnrichissementProfils();
$sql = $profilsM->select()
->from($profilsM, array('id'))
->where('idClient=?', $user->idClient)
->where('login=?', $user->username)
->where('actif=?', 1);
$profil = $profilsM->fetchRow($sql);
$idProfil = $profil->id;
}
//Récupération des critères du ciblage
$criteresM = new Table_Criteres();
@ -91,24 +101,11 @@ class EnrichissementController extends Zend_Controller_Action
$field = new Fields();
$values = $field->getValues($structure);
//Actualisation du comptage
//Récupération des SIRET
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($values);
$infosExtraction = $ciblage->extract();
//Enregistrement du nouveau comptage
$data = array(
'idDefinition' => $criteres->id,
'resultat' => $infosExtraction['total'],
'uniteInsee' => $infosExtraction['insee'],
'dateAjout' => date('YmdHis'),
);
$comptagesM = new Table_Comptages();
$idComptage = $comptagesM->insert($data);
//Récupération des SIRET
//Attention calcul uniteInsee réelle
//car si donnée insee alors toutes les lignes doivent être comptés en unité insee
$data = array(
@ -127,8 +124,6 @@ class EnrichissementController extends Zend_Controller_Action
$identifiantsM = new Table_EnrichissementIdentifiants();
$idIdentifiant = $identifiantsM->insert($data);
}
/**
@ -149,10 +144,12 @@ class EnrichissementController extends Zend_Controller_Action
->where('idClient=?', $user->idClient)
->where('login=?', $user->username)
->where('actif=?', 1);
$profil = $profilsM->fetchRow($sql);
$profil = $profilsM->fetchRow($sql);
if ($profil)
if ($profil!==null)
{
$this->view->assign('profil', true);
$idCritere = $request->getParam('id', null);
$comptagesM = new Table_Comptages();
@ -163,12 +160,13 @@ class EnrichissementController extends Zend_Controller_Action
$comptages = $comptagesM->fetchAll($sql);
if ( $comptages->count()>0 ) {
$item = $comptages[0];
//Si le ciblage n'est pas du jour, refaire le comptage par rapport aux critères de ciblage
//@todo : Si le ciblage n'est pas du jour, refaire le comptage par rapport aux critères de ciblage
$this->view->assign('resultat', $item['resultat']);
$this->view->assign('uniteInsee', $item['uniteInsee']);
//Calcul du prix
//Calcul du prix
$redevanceInsee = 3.295/100; //Seuil de facturation 52 734 euros
$prixInsee = $item['uniteInsee']*$redevanceInsee;
$infoInsee = '';
if ($profil->dataInsee){

View File

@ -34,24 +34,57 @@ class GestionController extends Zend_Controller_Action
$request = $this->getRequest();
//Sauvegarde du formulaire
if ( $request->isPost() ){
if ( $request->isPost() && $request->getParam('submit')=='Enregistrer' ){
$params = $request->getParams();
//Vérifier le formulaire
$errForm = 0;
foreach ( $params as $key => $value ) {
if (empty($value)) {
$errForm++;
}
}
if (!$errForm) {
$dataInsee = 0;
// Est ce qu'il existe une donnée insee
require_once 'Scores/Enrichissement.php';
$fieldsM = new Enrichissement();
$fields = $fieldsM->getFields();
foreach ( $fields as $key => $val) {
if ( array_key_exists('insee', $val) && $val['insee']===true) {
$dateInsee = 1;
break;
}
}
$data = array(
'idClient' => $params['idClient'],
'login' => $params['login'],
'reference' => $params['reference'],
'criteres' => json_encode($params['criteres']),
'tarifLigne' => $params['tarifLigne'],
'dataInsee' => $dataInsee,
'dateAjout' => date('Y-m-d H:i:s'),
'actif' => 1,
);
$profilM = new Table_EnrichissementProfils();
if ( $profilM->insert($data) ){
$this->view->assign('message', "Profil enregistré");
} else {
$this->view->assign('message', "Erreur lors de la sauvegarde");
}
} else {
$this->view->assign('message', "Erreur lors de la saisie");
}
}
//Affichage du formulaire
require_once 'Scores/Field.php';
$fieldsM = new Fields();
$allFields = $fieldsM->getFields();
$fields = array();
foreach($allFields as $name => $item)
{
if ( array_key_exists('export', $item) ) {
$fields[$name] = $item['label'];
}
}
$this->view->assign('fields', $fields);
require_once 'Scores/Enrichissement.php';
$fieldsM = new Enrichissement();
$allFields = $fieldsM->getFields();
$this->view->assign('fields', $allFields);
}
public function profildelAction(){}

View File

@ -22,12 +22,24 @@ Class IndexController extends Libs_Controller
public function criteresAction()
{
$this->_helper->layout()->disableLayout();
$ajax = $this->getRequest()->getParam('ajax');
if($ajax)
$this->_helper->layout()->disableLayout();
require_once 'Scores/SessionCiblage.php';
require_once 'Scores/Field.php';
$session = new SessionCiblage();
$this->view->field = new Fields();
$this->view->criteres = $session->getCriteres();
}
public function removeAction()
{
require_once('Scores/SessionCiblage.php');
$this->_helper->layout()->disableLayout();
$session = new SessionCiblage();
$session->unsetCritere($this->getRequest()->getParam('critere'));
$this->_redirect('/');
}
}

View File

@ -0,0 +1,48 @@
<?php
Class UploadController extends Zend_Controller_Action
{
protected $path;
protected $extensions;
public function init()
{
/*$config = Zend_Registrey::get('configuration');
$path = realpath($config->path->data).'/clients';
$this->path = $path;
$this->extensions = array('.csv');
if(!file_exists($path)) mkdir($path);*/
}
public function upload()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if(!empty($_FILES) and count($_FILES) == 1)
{
$tmp_name = $_FILES['fichier']['tmp_name'];
$extension = strrchr($_FILES['fichier']['name'], '.');
if(in_array($extension, $this->extensions)) {
if (move_uploaded_file($tmp_name, $path.'/'.$tmp_name.'.'.$extension))
return ($tmp_name);
}
}
return (false);
}
public function arborescanceAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$url = implode('/', $this->getRequest()->getParams());
echo $url;
//$file = $this->upload();
/*if($file)
{
$csv = fgetcsv($file);
$csv = str_replace(';', ',', $csv);
echo $csv;
}*/
}
}

View File

@ -19,8 +19,6 @@ class Object_Comptage extends Libs_Row
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$db = Zend_Registry::get('db');
//Enregistrement des critères
$criteresM = new Table_Criteres();
$data = array(
@ -40,7 +38,6 @@ class Object_Comptage extends Libs_Row
'idDefinition' => $id,
'resultat' => $resultat,
'uniteInsee' => $nbInsee,
'tarif' => '',
'dateAjout' => date('Y-m-d H:i:s'),
);
if ($comptageM->insert($data)) {
@ -49,13 +46,13 @@ class Object_Comptage extends Libs_Row
'msg'=> "Vos critères ont été sauvegardés sous la référence $ref"));
} else {
echo json_encode(array(
'error'=>1,
'msg'=> "Erreur lors de l'enregistrement"));
'error'=>1,
'msg'=> "Erreur lors de l'enregistrement"));
}
} else {
echo json_encode(array(
'error'=>1,
'msg'=> "Erreur lors de l'enregistrement"));
'error'=>1,
'msg'=> "Erreur lors de l'enregistrement"));
}
}
}

View File

@ -63,6 +63,11 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$field['label'],
$this->radioHTML($name, $field));
break;
case 'file':
$html.= $this->structureHTML(
$field['label'],
$this->fileuploadHtml($name, $field));
break;
}
$html.= '</div>';
}
@ -212,6 +217,7 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$type = 'Cj';
break;
}
/* Modifier les données */
$return = '<textarea rows="5" style="border:1px inset silver;width:60%" class="criteres complited'.$type.'" id="textarea_'.$name.'" name="'.$name.'">'.$session->getCritere($name).'</textarea>';
$return .= '<a href="" class="autocomplet" textarea="'.$name.'">Valider</a>';
return ($return);
@ -226,6 +232,12 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
return ($return);
}
private function fileuploadHtml($name, $field)
{
$return = '<input class="upload" type="file" name="fichier" id="'.$name.'" /> ';
return ($return);
}
/* Radios */
private function radioHTML($name, $field, $item)
{

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1 @@
<?php

View File

@ -31,7 +31,4 @@ $('form#save').bind('submit', function(){
});
</script>
<?php endif;?>
<pre>
<?php print_r($this->criteres)?>
</pre>
<?php endif;?>

View File

@ -1,11 +1,17 @@
<div id="dashboard" style="padding:10px">
<a href="/dashboard/index">Tableau de bord</a> > Detail du ciblage
<h2></h2>
<fieldset>
<legend>Critères</legend>
<?php foreach(json_decode($this->criteres['criteres'], true) as $critere => $valeur): ?>
<?php echo '<b>'.$critere . '</b> : '.$valeur;?>,
<?php if(!empty($valeur) and $valeur != ',' and !empty($critere)): ?>
<?php $label = $this->label->get($critere); ?>
<?php if($label['type'] != 'textarea' and $label['type'] != 'interval') :?>
<?php echo '<b>'.$label['label'] . '</b> : '.$label['fields'][$label['type']]['value'][$valeur];?><br />
<?php else: ?>
<?php echo '<b>'.$label['label'] . '</b>:'.$valeur; ?><br />
<?php endif; ?>
<?php endif; ?>
<?php endforeach;?>
</fieldset>

View File

@ -1,6 +1,8 @@
<div id="dashboard">
<form>
<?=$this->message?>
<form name="profil" method="post" action="<?=$this->url(array('controller'=>'gestion', 'action'=>'profiladd'))?>">
<label>idClient</label>
<input type="text" name="idClient" />
<br/>
@ -15,27 +17,21 @@
<input type="text" name="tarifLigne" />
<br/>
<div style="width:100%;">
<div style="width:45%;float:left;">
<div>
<label>Selection des données pour l'enrichissement</label>
<select name="listcriteres">
<option value="">-</option>
<select style="padding:5px;" name="criteres[]" multiple size="20">
<?php if ( count($this->fields)>0 ) {?>
<?php foreach ( $this->fields as $value => $lib ) {?>
<option value="<?=$value?>"><?=$lib?></option>
<?php foreach ( $this->fields as $value => $item ) {?>
<option value="<?=$value?>"><?=$item['label']?></option>
<?php }?>
<?php }?>
</select>
</div>
<div style="width:45%;float:right;" id="criteres">
Criteres
</div>
</div>
<div style="clear:both;"></div>
<input type="submit" name="submit" value="Enregistrer"/>
</form>
</div>
</div>

View File

@ -1,20 +1,50 @@
<h1>Vos critères de selections</h1>
<table style="margin-top:15px">
<?php foreach($this->criteres as $critere => $valeur):?>
<style>
.color {
background-color:#DEDEDE;
}
#criteres_ra
{
font-size: 11px;
}
#criteres_ra tr td {
border-left: 1px solid black;
padding-left:5px;
}
</style>
<table id="criteres_ra" style="margin-top:15px">
<tr>
<td><b>Champ séléction</b></td>
<td><b>Votre critère</b></td>
</tr>
<?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 != ','):?>
<?php $valeur = explode(',', $valeur); ?>
<tr>
<td valign="top" style="width:150px"><b style="text-decoration: underline"><?php echo $critere;?></b></td>
<tr <?php echo ((($color%2) == 0)?'class="color"':''); $color++;?>>
<td valign="top" style="width:150px">
<?php echo $label['label'];?>
</td>
<td>
<?php if(is_array($valeur)):?>
<?php $i=0; foreach ($valeur as $val):?>
<b><?php echo $val?></b> <?php (($i%3 == 0)?'<br />':''); $i++;?>
<?php endforeach;?>
<?php if($label['type'] != 'textarea' and $label['type'] != 'interval') :?>
<?php echo $label['fields'][$label['type']]['value'][$val];?> <?php (($i%3 == 0)?'<br />':''); $i++;?>
<?php else :?>
<?php echo $val;?>,
<?php endif;?>
<?php endforeach;?>
<?php else: ?>
<b><?php echo $val;?></b>
<?php echo $val;?>
<?php endif; ?>
</td>
<td>
<a class="remove" href="index/remove/critere/<?php echo $critere;?>">
<img src="/themes/default/images/cross.png" />
</a>
</td>
</tr>
<?php endif; ?>
<?php endif;?>
<?php endforeach;?>
</table>

View File

@ -1,5 +1,5 @@
<div id="panel">
<?php echo $this->action('criteres', 'index');?>
</div>
<div id="tabs">
<ul>

View File

@ -1,7 +1,166 @@
<?php
class Enrichissement
{
/**
* Déclaration des colonnes de la table de données pour la transposition
*
*/
protected $columns = array(
'id' => array(),
'source' => array(),
'source_id' => array(),
'triCode' => array(),
'autre_id' => array(),
'siren' => array(),
'nic' => array(),
'actif' => array(
'value' => array(
'1' => "actif",
'0' => "inactif",
)
),
'siege' => array(
'value' => array(
'1' => "Etablissement Siege",
'0' => "Etablissement Secondaire",
)
),
'raisonSociale' => array(),
'enseigne' => array(),
'sigle' => array(),
'identite_pre' => array(),
'marques' => array(),
'adr_num' => array(),
'adr_btq' => array(),
'adr_typeVoie' => array(),
'adr_libVoie' => array(),
'adr_comp' => array(),
'adr_cp' => array(),
'adr_ville' => array(),
'adr_dep' => array(),
'adr_com' => array(),
'tel' => array(),
'fax' => array(),
'cj' => array(),
'capital' => array(),
'capitalDev' => array(),
'capitalSrc' => array(),
'ape_etab' => array(),
'ape_entrep' => array(),
'age_entrep' => array(),
'age_etab' => array(),
'tca' => array(),
'tcaexp' => array(),
'teff_entrep' => array(),
'teff_etab' => array(),
'rang' => array(),
'web' => array(),
'mail' => array(),
'adrDom' => array(),
'lieuAct' => array(),
'actifEco' => array(),
'presentRcs' => array(),
'procolHisto' => array(),
'tvaIntraCle' => array(),
'tvaIntraValide' => array(),
'ape4_etab' => array(),
'ape4_entrep' => array(),
'NaceEtab' => array(),
'NaceEntrep' => array(),
'dateCrea_etab' => array(),
'dateCrea_ent' => array(),
'dateImmat' => array(),
'eff_entrep' => array(),
'eff_etab' => array(),
'distSP' => array(),
'achPost' => array(),
'rivoli' => array(),
'dirCiv' => array(),
'dirNom' => array(),
'dirPrenom' => array(),
'dirDateNaiss' => array(),
'dirFct' => array(),
'nbEtab' => array(),
'nbMPubli' => array(),
'sirenGrp' => array(),
'nbActio' => array(),
'nbPart' => array(),
'bilType' => array(),
'bilAnnee' => array(),
'bilCloture' => array(),
'bilDuree' => array(),
'bilTca' => array(),
'bilEE' => array(),
'bilFL' => array(),
'bilFK' => array(),
'bilFR' => array(),
'bilGF' => array(),
'bilGP' => array(),
'bilGU' => array(),
'bilGW' => array(),
'bilHD' => array(),
'bilHH' => array(),
'bilHL' => array(),
'bilHM' => array(),
'bilHN' => array(),
'bilYP' => array(),
'avisCs' => array(),
);
/**
* Déclaration des champs exportable
* @var unknown_type
*/
protected $fields = array(
'actif' => array(
'label' => "Actif",
'column' => 'actif',
),
'siege' => array(
'label' => "Type d'établissement",
'column' => 'siege'
),
'raisonSociale' => array(
'label' => "Raison Sociale",
'column' => 'raisonSociale'
),
'enseigne' => array(
'label' => "Enseigne",
'column' => 'enseigne'
),
'sigle' => array(
'label' => "Sigle",
'column' => 'sigle'
),
'marques' => array(
'label' => "Marques déposées",
'column' => 'marques'
),
'tel' => array(
'label' => "Téléphone",
'column' => 'tel'
),
'fax' => array(
'label' => "Fax",
'column' => 'fax'
),
'cj' => array(
'label' => "Forme juridique",
'column' => 'cj'
),
'dirigeant' => array(
'label' => "Dirigeant",
'column' => array('dirCiv', 'dirNom', 'dirPrenom', 'dirDateNaiss', 'dirFct')
),
);
public function __construct(){}
public function getFields()
{
return $this->fields;
}
}

View File

@ -29,13 +29,6 @@ Class Fields
'famille' => 'entreprise',
'activated' => true,
'type' => 'select',
'export' => array(
'label' => "Type d'établissement",
'valuedesc' => array(
'1' => "Etablissement Siege",
'0' => "Etablissement Secondaire",
),
),
),
'sirenGrp' => array(
'label' => 'Présence d\'un groupe',
@ -714,7 +707,7 @@ Class Fields
return ($values);
}
protected function fj($name, $valeur)
{
$table = new Table_Formejuridiques();

View File

@ -98,11 +98,6 @@ $(document).ready(function()
e.stopPropagation();
set($(this).attr('name'), $(this).val());
});
/*$('#tabs').delegate('textarea', 'change', function(e){
e.stopPropagation();
set($(this).attr('name'), $(this).val());
});*/
$('#tabs').delegate('a.autocomplet', 'click', function(e){
e.preventDefault();
@ -181,12 +176,12 @@ $(document).ready(function()
data : $(this).serializeArray(),
success: function(data) {
set(null, null);
window.location.replace('/');
}
});
});
});
function set(key, value)
{
$('#comptage').css('display', 'none');
@ -201,7 +196,7 @@ function set(key, value)
$.ajax({
type : "GET",
cache : false,
url : '/index/criteres',
url : '/index/criteres/ajax/1',
data : $(this).serializeArray(),
success: function(data) {
$('#panel').html(data);