Test date fin de contrat
This commit is contained in:
parent
7b2eb49921
commit
27df43931e
@ -56,14 +56,14 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
} else {
|
||||
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
|
||||
|
||||
//Authentifié => on met à jour la session
|
||||
if ( $auth->hasIdentity() )
|
||||
{
|
||||
|
||||
|
||||
$identity = $auth->getIdentity();
|
||||
$identity->time = time() + $identity->timeout;
|
||||
|
||||
|
||||
if ( !isset($identity->dateContrat) && $layout->isEnabled() )
|
||||
{
|
||||
//Get customer's params
|
||||
@ -72,7 +72,7 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
->where('idClient = ?', $identity->idClient)
|
||||
//@todo : add service from WebService
|
||||
->order('dateContrat DESC')->limit(1);
|
||||
|
||||
|
||||
Zend_Registry::get('firebug')->info($sql->__toString());
|
||||
$params = $paramsM->fetchAll($sql)->toArray();
|
||||
if (count($params)>0) {
|
||||
@ -86,50 +86,66 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
$identity->priceLine = $params[0]['priceLine'];
|
||||
$identity->forfait = $params[0]['forfait'];
|
||||
}
|
||||
|
||||
|
||||
//Get user's preference
|
||||
$prefsM = new Application_Model_Prefs();
|
||||
$pref = $prefsM->find($identity->username)->current();
|
||||
if ($pref) {
|
||||
$identity->preferences = json_decode($pref->json, true);
|
||||
}
|
||||
|
||||
|
||||
//Add a global value to join filterRNCS and preferences RNCS
|
||||
if ($identity->filterRNCS) {
|
||||
$identity->globalRNCS = 1;
|
||||
}
|
||||
|
||||
if (isset($identity->preferences['filter']['rncs']) && $identity->preferences['filter']['rncs']==1) {
|
||||
|
||||
if (isset($identity->preferences['filter']['rncs'])
|
||||
&& $identity->preferences['filter']['rncs']==1) {
|
||||
$identity->globalRNCS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Zend_Registry::get('firebug')->info($identity);
|
||||
|
||||
|
||||
//No contrat define
|
||||
if ( $identity->dateContrat=='0000-00-00 00:00:00' ) {
|
||||
//If no params are detected, display a message to contact support
|
||||
$request->setModuleName('default')
|
||||
->setControllerName('aide')
|
||||
->setActionName('message')
|
||||
->setParam('typeMsg', 'support');
|
||||
->setControllerName('aide')
|
||||
->setActionName('message')
|
||||
->setParam('typeMsg', 'support');
|
||||
}
|
||||
|
||||
//@todo : Check dateContrat and calculate end of contrat
|
||||
|
||||
//Check dateContrat and calculate end of contrat
|
||||
else {
|
||||
|
||||
$hour = intval(substr($identity->dateContrat,11,2));
|
||||
$min = intval(substr($identity->dateContrat,14,2));
|
||||
$sec = intval(substr($identity->dateContrat,17,2));
|
||||
$month = intval(substr($identity->dateContrat,5,2)) + $identity->periodContrat;
|
||||
$day = intval(substr($identity->dateContrat,8,2));
|
||||
$year = intval(substr($identity->dateContrat,0,4));
|
||||
$dateFinContrat = mktime($hour,$min,$sec,$month,$day,$year);
|
||||
|
||||
if ( $dateFinContrat > time() ) {
|
||||
$request->setModuleName('default')
|
||||
->setControllerName('user')
|
||||
->setActionName('logout')
|
||||
->setParam('message', "Votre Contrat est arrivé à expiration.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$auth->getStorage()->write($identity);
|
||||
|
||||
|
||||
if ( $identity->profil=="SuperAdministrateur" ) {
|
||||
$view = $layout->getView();
|
||||
$view->admin = true;
|
||||
}
|
||||
|
||||
|
||||
if (Zend_Session::namespaceIsset('login')){
|
||||
Zend_Session::namespaceUnset('login');
|
||||
}
|
||||
|
||||
|
||||
} elseif (time() > $auth->getIdentity()->time ) {
|
||||
|
||||
|
||||
if ( $request->getControllerName()=='index' && $request->getActionName()=='index' ) {
|
||||
$request->setModuleName('default')
|
||||
->setControllerName('user')
|
||||
@ -140,9 +156,9 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
->setActionName('logout')
|
||||
->setParam('ajax', $request->isXmlHttpRequest());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if ( !$request->isXmlHttpRequest() ) {
|
||||
$session = new Zend_Session_Namespace('login');
|
||||
$session->url = $_SERVER['REQUEST_URI'];
|
||||
@ -155,7 +171,7 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
->setActionName('logout')
|
||||
->setParam('ajax', 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user