Filtre RNCS à partir des paramètres client sur l'enrichissement

This commit is contained in:
Michael RICOIS 2013-01-09 10:38:45 +00:00
parent 9716e52619
commit caccc9d9fd

View File

@ -77,8 +77,8 @@ class EnrichissementController extends Zend_Controller_Action
$ref = $request->getParam('ref');
//Si forfait check si le montant restant est suffisant
//Identifiant comptage
$comptage = new Application_Model_Comptages();
$sql = $comptage->select()->where('idDefinition = ?', $idCriteres);
@ -92,6 +92,10 @@ class EnrichissementController extends Zend_Controller_Action
$structure = json_decode($criteres->criteres, true);
//Informations utilisateur
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
//Récupération des SIRET
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($structure, $user->globalRNCS);
@ -125,7 +129,7 @@ class EnrichissementController extends Zend_Controller_Action
$idIdentifiant = $identifiantsM->insert($data);
//@todo : ajouter la valeur (prix) du fichier au compteur global afin de décompter du forfait
$this->view->assign('ref', $ref);
}
@ -138,12 +142,12 @@ class EnrichissementController extends Zend_Controller_Action
$request = $this->getRequest();
$selectprofil = $request->getParam('profil', 'default');
//Récupération du profil de l'utilisateur
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$priceLine = $user->priceLine;
//Other profil for this login ?
$profilsM = new Application_Model_EnrichissementProfils();
$sql = $profilsM->select()
@ -151,7 +155,7 @@ class EnrichissementController extends Zend_Controller_Action
->where('actif=1')
->where('login=?', $user->username);
$profils = $profilsM->fetchAll($sql)->toArray();
$profilId = 0;
foreach($profils as $item) {
if ($selectprofil == $item['id']) {
@ -164,11 +168,11 @@ class EnrichissementController extends Zend_Controller_Action
if ($profilId == 0) {
$profilId = $defaultProfilId;
}
Zend_Registry::get('firebug')->info($profilId);
if ( count($profils)>0 ) {
$this->view->assign('profil', $profilId);
$idCritere = $request->getParam('id', null);
@ -194,14 +198,14 @@ class EnrichissementController extends Zend_Controller_Action
$item['resultat'] = $count->execute();
$item['uniteInsee'] = $count->calculRedevanceInsee();
}
$this->view->assign('resultat', $item['resultat']);
$this->view->assign('uniteInsee', $item['uniteInsee']);
//Calcul du prix
//@todo : Put it somewhere we can modify it
$redevanceInsee = 3.295/100; //Seuil de facturation 52 734 euros
//@todo : Si le client a déjà payé la redevance INSEE
$prixInsee = $item['uniteInsee']*$redevanceInsee;
$infoInsee = '';
@ -211,29 +215,29 @@ class EnrichissementController extends Zend_Controller_Action
}
$this->view->prixInsee = round($prixInsee, 2);
$this->view->infoInsee = $infoInsee;
$prix = round($item['resultat'] * $priceLine + $prixInsee, 2);
//Forfait - Liste des commandes et calcul
if ($user->forfait>0)
{
$dateBegin = $user->dateContrat;
$dateEnd = date('YmdHis', mktime(0,0,0,substr($user->dateContrat,5,2)+$user->periodContrat, substr($user->dateContrat,8,2), substr($user->dateContrat,0,4)));
$commandesM = new Application_Model_EnrichissementIdentifiants();
$sql = $commandesM->select()->setIntegrityCheck(false)
->from( array('commande' => 'enrichissement_identifiants'), array('SUM(nbLigneTotales) as total', 'SUM(uniteInsee) as insee'))
->join( array('critere' => 'ciblage_criteres'), 'critere.id = commande.idCriteres', array())
->where("dateAdded BETWEEN '".$dateBegin."' AND '".$dateEnd."'")
->where('idClient = ?', $user->idClient);
$result = $commandesM->fetchRow($sql);
if ($result) {
$total = $result['total'];
$insee = $result['insee'];
$conso = round($total * $priceLine + $insee * $redevanceInsee, 2);
}
$this->view->forfaitRemain = $user->forfait - $conso - $prix;
}
//Limite lignes totales
@ -242,9 +246,9 @@ class EnrichissementController extends Zend_Controller_Action
}
//Illimité
elseif ($user->forfait==0 && $user->limitFiles==0) {
}
$this->view->prix = $prix;
$this->view->id = $item['id'];
$this->view->ref = $criteres->reference.'-'.uniqid();
@ -260,9 +264,9 @@ class EnrichissementController extends Zend_Controller_Action
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$id = $this->getRequest()->getParam('id');
/*
* Do not download file that not own by the user
* List profil
@ -271,7 +275,7 @@ class EnrichissementController extends Zend_Controller_Action
$sql = $profilM->select()
->from($profilM, array('id'))
->where('login=?',$identity->username);
$profils = $profilM->fetchAll($sql);
if ( $profils->count()>0 ) {
$profilList = array();
@ -279,7 +283,7 @@ class EnrichissementController extends Zend_Controller_Action
$profilList[] = $item['id'];
}
}
/*
* List finish file
*/