Lissage complet des fonction getRapport/getIndiscoreé et getIndiscore
This commit is contained in:
parent
770d6f3b16
commit
12dcdf4f57
@ -15,7 +15,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
|
||||
public function __construct($db = null)
|
||||
{
|
||||
// Set Database
|
||||
if ($conn === null) {
|
||||
if ($this->conn === null) {
|
||||
$this->conn = Zend_Registry::get('doctrine');
|
||||
} else {
|
||||
$this->conn = $conn;
|
||||
@ -23,7 +23,6 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
|
||||
|
||||
if (Zend_Registry::isRegistered('logger')) {
|
||||
$this->logger = Zend_Registry::get('logger');
|
||||
$this->logger->info('Decrement');
|
||||
}
|
||||
}
|
||||
public function canUse($idLog,$user){
|
||||
@ -51,7 +50,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
|
||||
'consumption' => $this->logCost,
|
||||
'created' => Date('Y-m-d H:i:s'),
|
||||
);
|
||||
$this->conn->insert('sdv1.credit__consumption',$declog);
|
||||
$res=$this->conn->insert('sdv1.credit__consumption',$declog);
|
||||
switch($this->rateType){
|
||||
case 1:
|
||||
$this->setBalance($user,'');
|
||||
@ -61,6 +60,8 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
|
||||
break;
|
||||
}
|
||||
//$newbalance=
|
||||
$this->logger->info(var_export($res,true));
|
||||
return true;
|
||||
return $this->logCost.'--->'.$this->rateType;
|
||||
}
|
||||
private function setBalance($user, $idLog){
|
||||
@ -118,7 +119,7 @@ class Metier_Credit_Decrement extends Scores_Ws_Server
|
||||
}else{
|
||||
$this->rateType=0;
|
||||
$this->logCost=0;
|
||||
$this->logger->info(__LINE__ . 'getRateType KO');
|
||||
$this->logger->info(__LINE__ . 'getRateType KO'.$idLog.'-'.$user->idClient);
|
||||
}
|
||||
}
|
||||
private function sessionGetRateType(){
|
||||
|
@ -75,6 +75,8 @@ class Scores_Ws_Server
|
||||
|
||||
protected $idLog = 'unknown';
|
||||
|
||||
protected $idMainLog = 'unknown';
|
||||
|
||||
/**
|
||||
* Liste des permissions
|
||||
* @var array
|
||||
@ -383,10 +385,17 @@ class Scores_Ws_Server
|
||||
$this->conn->insert('sdv1.logs', $dataInsert);
|
||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||
}
|
||||
$this->decLog($this->idLog);
|
||||
}
|
||||
protected function decLog($idLog=null){
|
||||
if($this->idMainLog=='getRapport' && $this->idLog!=$this->idMainLog){
|
||||
return true;
|
||||
}
|
||||
$this->idLog=$idLog;
|
||||
$crdt=new Metier_Credit_Decrement();
|
||||
$ok=$crdt->setUsed($this->idLog,$this->User);
|
||||
}
|
||||
|
||||
return $ok;
|
||||
}
|
||||
/**
|
||||
* Authenticate with SoapHeader, Optional (Authentication could be done by sending HTTP Basic header - see the doc)
|
||||
* @param string $username
|
||||
@ -461,14 +470,8 @@ class Scores_Ws_Server
|
||||
if (!$this->checkPerm($perm)) {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
$this->sendError('0907');
|
||||
if(empty($idLog)){$idLog=$this->getIdLog();}
|
||||
//if(empty($idLog)){$idLog=$this->idLog;;}
|
||||
if(!empty($idLog)){
|
||||
$this->idLog=$idLog;
|
||||
if (!$this->checkCredit($idLog)) {
|
||||
$this->sendError('0907');
|
||||
}
|
||||
if (!$this->checkCredit($idLog)) {
|
||||
$this->sendError('0907');
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +480,17 @@ class Scores_Ws_Server
|
||||
* @throws SoapFault
|
||||
*/
|
||||
protected function checkCredit($idLog){
|
||||
//$this->idLog=$this->getIdLog();
|
||||
if(
|
||||
$idLog=="getRapport"
|
||||
|| $idLog=="getIndiScore2"
|
||||
){
|
||||
$this->idMainLog=$idLog;
|
||||
}
|
||||
if(empty($idLog)){$idLog=$this->getIdLog();}
|
||||
//@todo:retirer la securite apres verif
|
||||
if(!empty($idLog)){
|
||||
$this->idLog=$idLog;
|
||||
}
|
||||
$crdt=new Metier_Credit_Decrement();
|
||||
$ok=$crdt->canUse($idLog,$this->User);
|
||||
return $ok->result;
|
||||
@ -572,7 +585,7 @@ class Scores_Ws_Server
|
||||
$qb->select(array(
|
||||
'u.login', 'u.id', 'u.email', 'u.password', 'u.idClient', 'u.typeCompte', 'u.actif',
|
||||
'u.filtre_ip', 'u.profil', 'u.civilite', 'u.nom', 'u.prenom', 'u.tel', 'u.fax',
|
||||
'u.mobile', 'u.pref', 'u.rechRefType', 'u.profil', 'u.nombreConnexions',
|
||||
'u.mobile', 'u.pref', 'u.rechRefType', 'u.profil', 'u.nombreConnexions', 'u.siret',
|
||||
'u.dateDerniereConnexion', 'u.droits', 'u.referenceParDefaut', 'u.nbReponses', 'u.lang',
|
||||
'u.formatMail', 'u.dateDebutCompte', 'u.dateFinCompte', 'u.accesWS', 'u.acceptationCGU',
|
||||
'c.droits AS droitsClients', 'c.test AS clientTest', 'c.typeScore', 'c.timeout',
|
||||
@ -823,6 +836,7 @@ class Scores_Ws_Server
|
||||
$this->User->dateFinCompte = $userInfos->dateFinCompte;
|
||||
$this->User->acceptationCGU = $userInfos->acceptationCGU;
|
||||
$this->User->version = $userInfos->version;
|
||||
$this->User->siret = isset($userInfos->siret)?$userInfos->siret:0;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -920,6 +934,7 @@ class Scores_Ws_Server
|
||||
$this->User->dateFinCompte = $userInfos->dateFinCompte;
|
||||
$this->User->acceptationCGU = $userInfos->acceptationCGU;
|
||||
$this->User->version = $userInfos->version;
|
||||
$this->User->siret = isset($userInfos->siret)?$userInfos->siret:0;
|
||||
|
||||
// Add Service Parameter to user definition
|
||||
$this->User->typeScore = $result->TypeScore;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
return array(
|
||||
'GetCredit' => 'GetCredit',
|
||||
'infoCredit' => 'infoCredit',
|
||||
'InfoCredit' => 'InfoCredit',
|
||||
'PayCredit' => 'PayCredit',
|
||||
'CanUse' => 'CanUse',
|
||||
'UseCredit' => 'UseCredit',
|
||||
);
|
||||
|
@ -77,13 +77,15 @@ class Credit extends Scores_Ws_Server
|
||||
$stmt->execute();
|
||||
$info->paid=$stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$sql = "SELECT * FROM sdv1.credit__consumption c
|
||||
WHERE c.idUser=:idUser order by id desc limit 20";
|
||||
inner join credit__rate r on c.idLog=r.idLog
|
||||
WHERE c.idUser=:idUser and r.idClient=:idClient order by c.id desc limit 20";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('idUser', $idUser);
|
||||
$stmt->bindValue('idClient', $this->User->idClient);
|
||||
$stmt->execute();
|
||||
$info->used=$stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$this->wsLog(__FUNCTION__,$siret,$id);
|
||||
$this->wsLog(__FUNCTION__,$idUser,'0');
|
||||
return $info;
|
||||
}
|
||||
|
||||
@ -95,7 +97,7 @@ class Credit extends Scores_Ws_Server
|
||||
public function payCredit($ligneCredit='')
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission($this->libdroits);
|
||||
$this->permission($this->libdroits,__FUNCTION__);
|
||||
$PayCreditResult=new PayCredit();
|
||||
$ir=(array)json_decode($ligneCredit);
|
||||
$tab=explode('ww',$ir['idCmd']);
|
||||
@ -170,41 +172,37 @@ class Credit extends Scores_Ws_Server
|
||||
return $PayCreditResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement sur cache Extranet
|
||||
* @param string idLog
|
||||
* @return UseCredit
|
||||
*/
|
||||
public function useCredit($idLog)
|
||||
{
|
||||
$UseCreditResult=new UseCredit();
|
||||
$UseCreditResult->idLog=$idLog;
|
||||
$this->authenticate();
|
||||
$idUser = $this->User->id;
|
||||
$this->logger->info('idUser : '.$this->User->id.'idLog : '.$idLog);
|
||||
|
||||
//$this->permission($this->libdroits);
|
||||
$this->decLog($idLog);
|
||||
$UseCreditResult->result=true;
|
||||
return $UseCreditResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie le droit de consommer une page
|
||||
* @param string idLog
|
||||
* @return CanUse
|
||||
*/
|
||||
public function canUse($idLog)
|
||||
{
|
||||
$this->authenticate();
|
||||
$idUser = $this->User->id;
|
||||
$myRights=new \Metier_Credit_Decrement();
|
||||
/*test de la librairie pour auth
|
||||
$ok=$myRights->canUse('synthese',$this->User);
|
||||
throw(new SoapFault('MSG', 'canUse : '.__LINE__ . var_export($ok,true)));
|
||||
$canUseResult=$ok;
|
||||
*/
|
||||
/*test de la librairie pour dec*/
|
||||
$ok=$myRights->setUsed('synthese',$this->User);
|
||||
throw(new SoapFault('MSG', 'canUse : '.__LINE__ . var_export($ok,true)));
|
||||
$canUseResult=$ok;
|
||||
|
||||
|
||||
return $canUseResult;
|
||||
}
|
||||
/**
|
||||
* Ajoute des crédits supplémentaires à un utilisateur
|
||||
* @param $nbCredit
|
||||
|
||||
public function addCredit($nbCredit)
|
||||
public function canUseByCredit($idLog)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('addcredit');
|
||||
|
||||
$this->updateCredit($this->User->idClient, $this->User->login, $nbCredit);
|
||||
|
||||
$this->wsLog('addcredit', $this->User->idClient, $nbCredit);
|
||||
$idUser = $this->User->id;
|
||||
$canUseResult=$this->checkCredit($idLog);
|
||||
return $canUseResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,37 +40,19 @@ class PayCredit
|
||||
*/
|
||||
public $ligneCredit;
|
||||
}
|
||||
class CanUse
|
||||
|
||||
class UseCredit
|
||||
{
|
||||
/**
|
||||
* Identifiant de log service
|
||||
* @var string
|
||||
*/
|
||||
public $idLog;
|
||||
/**
|
||||
* Success or failed
|
||||
* @var boolean
|
||||
*/
|
||||
public $result;
|
||||
/**
|
||||
* Type de fonctionnement des credits
|
||||
* @var int
|
||||
* Params sent
|
||||
* @var string
|
||||
*/
|
||||
public $typecredit;
|
||||
public $idLog;
|
||||
|
||||
}
|
||||
|
||||
class AddCredit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class SubCredit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class UpdateCredit
|
||||
{
|
||||
|
||||
}
|
@ -1556,12 +1556,21 @@ class Entreprise extends Scores_Ws_Server
|
||||
$perm = false;
|
||||
//@todo : Gestion des droits
|
||||
switch($niveau){
|
||||
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
||||
case 2: $perms = array('indiscore2', 'indiscore2p', 'indiscore3', 'indiscore3p'); break;
|
||||
case 1: $perms = array('indiscore', 'indiscorep'); break;
|
||||
case 3:
|
||||
$perms = array('indiscore3', 'indiscore3p');
|
||||
$idLog='getReportSynthese';
|
||||
break;
|
||||
case 2:
|
||||
$perms = array('indiscore2', 'indiscore2p', 'indiscore3', 'indiscore3p');
|
||||
$idLog='getReportSynthese';
|
||||
break;
|
||||
case 1:
|
||||
$perms = array('indiscore', 'indiscorep');
|
||||
$idLog='getIndiScore';
|
||||
break;
|
||||
}
|
||||
foreach($perms as $item){
|
||||
if ( $this->checkPerm($item,'get'.ucfirst($item)) ){
|
||||
if ( $this->checkPerm($item, $idLog) ){
|
||||
$perm = true;
|
||||
break;
|
||||
}
|
||||
@ -1782,6 +1791,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$this->wsLog('indiscore+',$siren);
|
||||
} else
|
||||
$this->wsLog('indiscore',$siren);
|
||||
//$this->decLog($idLog);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -3346,6 +3356,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
}
|
||||
$this->wsLog('bilan',$siren, $millesime.':'.$typeBilan.':'.$ref);
|
||||
$resultBilan->POSTES = $tabPoste;
|
||||
$this->decLog('getBilan');
|
||||
return $resultBilan;
|
||||
}
|
||||
|
||||
@ -3745,6 +3756,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getRapport($siren, $niveau=3, $id=0, $plus=false, $ref='', $encours=0, $email='')
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->checkCredit(__FUNCTION__);
|
||||
if (empty($niveau)) $niveau = 3;
|
||||
if (empty($id)) $id = 0;
|
||||
$result = new Rapport();
|
||||
@ -3759,7 +3771,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
||||
}
|
||||
foreach($perms as $item){
|
||||
if ( $this->checkPerm($item,__FUNCTION__) ){
|
||||
if ( $this->checkPerm($item) ){
|
||||
$perm = true;
|
||||
break;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getAvisRncs($siren)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('avisrncs');
|
||||
$this->permission('avisrncs',__FUNCTION__);
|
||||
|
||||
$len = strlen($siren);
|
||||
if ( $len != 9 ) {
|
||||
@ -1043,7 +1043,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getLiensById($id, $type = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('liens');
|
||||
$this->permission('liens',__FUNCTION__);
|
||||
|
||||
try {
|
||||
$countryM = new Application_Model_JoTabPays();
|
||||
@ -2238,12 +2238,24 @@ class Entreprise extends Scores_Ws_Server
|
||||
$perm = false;
|
||||
//@todo : Gestion des droits
|
||||
switch($niveau){
|
||||
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
||||
case 2: $perms = array('indiscore2', 'indiscore2p', 'indiscore3', 'indiscore3p'); break;
|
||||
case 1: $perms = array('indiscore', 'indiscorep'); break;
|
||||
case 3:
|
||||
$perms = array('indiscore3', 'indiscore3p');
|
||||
$idLog='getReportSynthese';
|
||||
break;
|
||||
case 2:
|
||||
$perms = array('indiscore2', 'indiscore2p', 'indiscore3', 'indiscore3p');
|
||||
$idLog='getRapport';
|
||||
break;
|
||||
case 1:
|
||||
$perms = array('indiscore', 'indiscorep');
|
||||
$idLog='getIndiScore';
|
||||
break;
|
||||
default:
|
||||
$idLog='getIndiScore';
|
||||
break;
|
||||
}
|
||||
foreach($perms as $item){
|
||||
if ( $this->checkPerm($item, __FUNCTION__) ){
|
||||
if ( $this->checkPerm($item) ){
|
||||
$perm = true;
|
||||
break;
|
||||
}
|
||||
@ -2251,7 +2263,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
if ($perm === false) {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
|
||||
$this->checkCredit($idLog);
|
||||
$tabRet = array();
|
||||
$this->logger->info("IndiScore demandée pour $siren en niveau $niveau");
|
||||
if (strlen($siren) > 9 || (substr($siren,0,9)*1) < 100 ){
|
||||
@ -2473,7 +2485,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
$this->wsLog('indiscore',$siren);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -2487,7 +2498,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getValo($siren, $nic=0, $niveau=2)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('VALORISATION');
|
||||
$this->permission('VALORISATION',__FUNCTION__);
|
||||
|
||||
//Initialisation
|
||||
$accesPartenaire = true;
|
||||
@ -4574,7 +4585,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getRatios($siren, $page='ratios')
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('ratios',__FUNCTION__);
|
||||
$this->permission('ratios','get'.ucfirst($page));
|
||||
|
||||
//Initialisation
|
||||
if (empty($page)) $page = 'ratios';
|
||||
@ -4847,6 +4858,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
public function getRapport($siren, $niveau=3, $id=0, $plus=false, $ref='', $encours=0, $email='')
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->checkCredit(__FUNCTION__.'cd');
|
||||
if (empty($niveau)) $niveau = 3;
|
||||
if (empty($id)) $id = 0;
|
||||
$result = new Rapport();
|
||||
@ -4861,7 +4873,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
||||
}
|
||||
foreach($perms as $item){
|
||||
if ( $this->checkPerm($item, __FUNCTION__) ){
|
||||
if ( $this->checkPerm($item) ){
|
||||
$perm = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1268,7 +1268,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$output = new Indiscore();
|
||||
$output = $this->formatIndiscore($indiscoreStruct);
|
||||
|
||||
$this->decLog(__FUNCTION__);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -1291,6 +1291,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$indiscoreStruct = $scoring->calculIndiScore($siren);
|
||||
|
||||
//$ratiosStruct = $this->getRatios($siren);
|
||||
$this->decLog(__FUNCTION__);
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,4 +16,5 @@ if (APPLICATION_ENV == 'development'){
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
$application->bootstrap()->run();
|
Loading…
Reference in New Issue
Block a user