diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 913e6123..5c4ccd02 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,7 +1,14 @@ getOptions()); + Zend_Registry::set('config', $config); + return $config; + } + + protected function _initViewSettings() { $this->bootstrap('view'); $view = $this->getResource('view'); @@ -9,7 +16,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $pathScript = '/themes/default/scripts'; $view->setEncoding('UTF-8'); - $view->doctype('XHTML1_STRICT'); + $view->doctype('HTML5'); $view->headMeta() ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') @@ -25,7 +32,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap ->appendFile('/libs/jquery/jquery.js', 'text/javascript') ->appendFile('/libs/jquery/jquery.bgiframe.js', 'text/javascript') ->appendFile('/libs/jquery/jquery.cookie.js', 'text/javascript') - ->appendFile('/libs/ui/jquery-ui.js', 'text/javascript') + ->appendFile('/libs/ui/jquery-ui.min.js', 'text/javascript') ->appendFile('/libs/qtip/jquery.qtip.js', 'text/javascript') ->appendFile($pathScript.'/scripts.js', 'text/javascript'); @@ -46,15 +53,15 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap protected function _initDb() { - $dbConfig = Zend_Registry::get('configuration')->databases; - try { - $db = Zend_Db::factory($dbConfig->db); + $c = new Zend_Config($this->getOptions()); + try { + $db = Zend_Db::factory($c->profil->db->ciblage); Zend_Db_Table::setDefaultAdapter ($db); } catch ( Exception $e ) { if (APPLICATION_ENV == 'development') { print_r($e); } else { - echo "Le service rencontre actuellement un problème technique."; + echo "Le service est actuellement indisponible."; } exit; } diff --git a/application/configs/application.ini b/application/configs/application.ini index 13e7e762..501367ff 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -1,18 +1,17 @@ [production] -;phpSettings.session.gc_maxlifetime = 86400 -;phpSettings.session.cookie_lifetime = 86400 phpSettings.date.timezone = "Europe/Paris" phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" -resources.session.save_path = APPLICATION_PATH "/../cache/sessions" +resources.session.save_path = APPLICATION_PATH "/../data/sessions" resources.session.gc_maxlifetime = 86400 resources.session.cookie_lifetime = 86400 resources.session.remember_me_seconds = 86400 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth" +resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu" resources.frontController.plugins.Comptage = "Application_Controller_Plugin_Comptage" resources.frontController.params.displayExceptions = 0 resources.layout.layout = "main" @@ -22,6 +21,32 @@ autoloaderNamespaces[] = "Application_" autoloaderNamespaces[] = "Scores_" autoloaderNamespaces[] = "Form_" +; Scores configuration +profil.server.name = development +profil.webservice.location = sdsrvdev01 +profil.mail.method = smtp +profil.mail.smtp_host = smtp.free.fr +profil.mail.email.support = supportdev@scores-decisions.com +profil.mail.email.supportdev = supportdev@scores-decisions.com +profil.mail.email.contact = supportdev@scores-decisions.com +profil.mail.email.production = supportdev@scores-decisions.com +profil.path.data = "d:\www\dataciblage" +profil.db.ciblage.adapter=mysqli +profil.db.ciblage.params.host=127.0.0.1 +profil.db.ciblage.params.username=root +profil.db.ciblage.params.password=bj10sx +profil.db.ciblage.params.dbname=ciblage +profil.db.ciblage.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" +profil.db.jo.adapter=mysqli +profil.db.jo.params.host=192.168.78.230 +profil.db.jo.params.username=ciblage +profil.db.jo.params.password=z7jq8AhvrwqQJ4Yb +profil.db.jo.params.dbname=jo +profil.db.jo.params.persistent = true +profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" +profil.sphinx.host=192.168.78.252 +profil.sphinx.port=3312 + [staging : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 0243b40e..2dbc92f9 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -236,12 +236,16 @@ class ComptageController extends Zend_Controller_Action $ciblage = new Ciblage($fields->getValues(), $user->globalRNCS); $sirets = $ciblage->execute(true, 10); - $dbConfig = Zend_Registry::get('configuration')->databases; + $c = Zend_Registry::get('config'); try { - $dbMetier = Zend_Db::factory($dbConfig->jo); + $dbMetier = Zend_Db::factory($c->profil->db->jo); } catch ( Exception $e ) { - //@todo : Changer le message d'erreur - exit ( $e->getMessage() ); + if ( $user->idClient ) { + exit ( $e->getMessage() ); + } else { + echo "Prévisualisation indisponible"; + exit; + } } /** diff --git a/application/controllers/EnrichissementController.php b/application/controllers/EnrichissementController.php index aef1465d..6337df49 100644 --- a/application/controllers/EnrichissementController.php +++ b/application/controllers/EnrichissementController.php @@ -24,8 +24,8 @@ class EnrichissementController extends Zend_Controller_Action $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - $config = Zend_Registrey::get('configuration'); - $path = realpath($config->path->data).'/clients'; + $c = Zend_Registrey::get('config'); + $path = realpath($c->profil->path->data).'/clients'; if(!file_exists($path)) mkdir($path); if ( isset($_FILES) && count($_FILES)==1 ){ @@ -258,16 +258,41 @@ class EnrichissementController extends Zend_Controller_Action $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); + $auth = Zend_Auth::getInstance(); + $identity = $auth->getIdentity(); + $id = $this->getRequest()->getParam('id'); + + /* + * Do not download file that not own by the user + * List profil + */ + $profilM = new Application_Model_EnrichissementProfils(); + $sql = $profilM->select() + ->from($profilM, array('id')) + ->where('login=?',$identity->username); + + $profils = $profilM->fetchAll($sql); + if ( $profils->count()>0 ) { + $profilList = array(); + foreach ( $profils->toArray() as $item ) { + $profilList[] = $item['id']; + } + } + + /* + * List finish file + */ $table = new Application_Model_EnrichissementIdentifiants(); $sql = $table->select() + ->where('idProfil IN('.join(',', $profilList).')') ->where('id = ?', $id); $result = $table->fetchRow($sql); if(!empty($result)) { $result = $result->toArray(); $date = substr($result['dateAdded'],0,4).substr($result['dateAdded'],5,2); - $config = Zend_Registry::get('configuration'); - $path = $config->path->data.'/'.$date.'/'; + $c = Zend_Registry::get('config'); + $path = $c->profil->path->data.'/'.$date.'/'; $file = $result['fichier']; } $content_type = 'application/csv-tab-delimited-table'; diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 5a69de14..7dd128fb 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -31,7 +31,7 @@ class ErrorController extends Zend_Controller_Action $message.= "\n"; $message.= 'Message : '.$errors->exception->getMessage(); $message.= "\n"; - $message.= 'Utilisateur : '.$identity->login; + $message.= 'Utilisateur : '.$identity->username; $message.= "\n"; $message.= "File :".$errors->exception->getFile().", Ligne : ".$errors->exception->getLine(); $message.= "\n"; @@ -41,10 +41,10 @@ class ErrorController extends Zend_Controller_Action $message.= "Referer : ".$_SERVER['HTTP_REFERER']."\n"; - $configuration = Zend_Registry::get('configuration'); + $c = Zend_Registry::get('config'); require_once 'Scores/Mail.php'; $mail = new Mail(); - $mail->setSubject('[ERREUR APPLICATIVE] - '.$configuration->server->name.' -'.date('Ymd')); + $mail->setSubject('[ERREUR APPLICATIVE] - '.$c->profil->server->name.' -'.date('Ymd')); $mail->setBodyTexte($message); $mail->setFrom('supportdev'); $mail->addToKey('supportdev'); diff --git a/application/controllers/FieldsController.php b/application/controllers/FieldsController.php index 8c2d9f5a..dfbf0752 100644 --- a/application/controllers/FieldsController.php +++ b/application/controllers/FieldsController.php @@ -141,7 +141,7 @@ class FieldsController extends Zend_Controller_Action $result = $table->fetchAll($sql); foreach ($result as $item) { $output[] = array( - 'label' => $item->libdep . ' (Dépatement)', + 'label' => $item->libdep . ' (Département)', 'value' => 'D'.$item->numdep ); } diff --git a/application/controllers/GestionController.php b/application/controllers/GestionController.php index 3888b3d4..83b337d8 100644 --- a/application/controllers/GestionController.php +++ b/application/controllers/GestionController.php @@ -77,6 +77,7 @@ class GestionController extends Zend_Controller_Action 'login' => $params['login'], 'reference' => $params['reference'], 'criteres' => json_encode($params['criteres']), + 'dataInsee' => 0, 'dateAjout' => date('Y-m-d H:i:s'), 'actif' => 1, ); @@ -259,10 +260,17 @@ class GestionController extends Zend_Controller_Action */ public function customerparamAction() { - $request = $this->getRequest(); + //Fields + require_once 'Scores/Enrichissement.php'; + $fieldsM = new Enrichissement(); + $allFields = $fieldsM->getFields(); + $this->view->assign('fields', $allFields); + + $request = $this->getRequest(); $idClient= $request->getParam('id', null); - + $this->view->assign('idClient', $idClient); + if ($idClient !== null) { $paramsM = new Application_Model_CustomerParams(); $sql = $paramsM->select()->where('idClient = ?', $idClient); @@ -270,6 +278,7 @@ class GestionController extends Zend_Controller_Action $infos = null; if ($params!==null){ $infos = $params->toArray(); + $infos['criteres'] = json_decode($infos['criteres'], true); } $this->view->assign('infos',$infos); @@ -292,7 +301,7 @@ class GestionController extends Zend_Controller_Action $request = $this->getRequest(); //Sauvegarde du formulaire - if ( $request->isPost() && $request->getParam('submit')=='Enregistrer' ) { + if ( $request->isPost() && in_array($request->getParam('submit'), array('Enregistrer','Modifier')) ) { $params = $request->getParams(); //Vérifier le formulaire @@ -302,19 +311,7 @@ class GestionController extends Zend_Controller_Action $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; - } - } + if (!$errForm) { $checkValues = array( 'filterRNCS' => 0, @@ -341,18 +338,69 @@ class GestionController extends Zend_Controller_Action 'limitLines' => $params['limitLines'], 'limitFiles' => $params['limitFiles'], 'criteres' => json_encode($params['criteres']), - 'dataInsee' => $dataInsee, 'dateAdded' => date('Y-m-d H:i:s'), - ); - $customerParamsM = new Application_Model_CustomerParams(); - if ( $customerParamsM->insert($data) ){ - $this->view->assign('message', "Profil enregistré"); - } else { - $this->view->assign('message', "Erreur lors de la sauvegarde"); - } + ); + + if ($request->getParam('submit')=='Modifier') { + //Overwrite default profil for each login + $profilM = new Application_Model_EnrichissementProfils(); + $profilM->update( + array('criteres', json_encode($params['criteres'])), + "reference='default' AND idClient=".$params['idClient']); + + //Set parameters + $customerParamsM = new Application_Model_CustomerParams(); + if ( $customerParamsM->update($data, 'id='.$params['id']) ){ + $this->view->assign('message', "Profil enregistré"); + } else { + $this->view->assign('message', "Erreur lors de la sauvegarde"); + } + + } else { + //Set parameters + $customerParamsM = new Application_Model_CustomerParams(); + if ( $customerParamsM->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"); } + } else { + + $idClient = $request->getParam('id', null); + + if ($idClient !== null) { + $paramsM = new Application_Model_CustomerParams(); + $sql = $paramsM->select()->where('idClient = ?', $idClient); + $params = $paramsM->fetchRow($sql); + if ( $params!==null ) { + foreach ( $params as $key => $value ) { + switch ( $key ) { + case 'criteres': + $this->view->assign($key, json_decode($value,true)); + break; + case 'dateContrat': + $this->view->assign($key, substr($value,0,10)); + break; + default: + $this->view->assign($key, $value); + break; + } + } + } + + } else { + $this->view->assign('filterRNCS', 1); + $this->view->assign('licenceINSEE', 0); + $this->view->assign('immediatExtract', 0); + $this->view->assign('limitLines', 50000); + $this->view->assign('limitFiles', 0); + } + } } diff --git a/application/controllers/UploadController.php b/application/controllers/UploadController.php index 16fa2741..79f944e6 100644 --- a/application/controllers/UploadController.php +++ b/application/controllers/UploadController.php @@ -3,23 +3,13 @@ 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) + if(!empty($_FILES) and count($_FILES) == 1) { $tmp_name = $_FILES['fichier']['tmp_name']; $extension = strrchr($_FILES['fichier']['name'], '.'); diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 47180934..e26a7394 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -50,22 +50,22 @@ class UserController extends Zend_Controller_Action $message = $request->getParam('message'); $this->view->assign('message', $message); + $ajax = $request->getParam('ajax', 0); + $this->view->assign('ajax', $ajax); + $refresh = 5; - $baseUrl = 'http://'.$_SERVER['SERVER_NAME']; - if ($_SERVER['SERVER_PORT']!='80') { - $baseUrl.= ':'.$_SERVER['SERVER_PORT']; - } - - $url = $baseUrl.$this->view->url(array( + $url = 'http://'.$_SERVER['SERVER_NAME'].$this->view->url(array( 'controller' => 'user', 'action' => 'login', - )); + ), null, true); $this->view->assign('url', $url); - $this->view->assign('refresh', $refresh); - $this->view->headMeta()->appendHttpEquiv('refresh', $refresh.'; url='.$url); - $this->render('logout'); + + if (!$ajax) { + $this->view->assign('refresh', $refresh); + $this->view->headMeta()->appendHttpEquiv('refresh', $refresh.'; url='.$url); + } } } diff --git a/application/models/JoSphinxIdx.php b/application/models/JoSphinxIdx.php new file mode 100644 index 00000000..b76362e9 --- /dev/null +++ b/application/models/JoSphinxIdx.php @@ -0,0 +1,5 @@ + 1) { $out.= '