modification controller

This commit is contained in:
Damien LASSERRE 2012-01-30 09:06:55 +00:00
parent 1c4eda048c
commit 731947589c
3 changed files with 87 additions and 73 deletions

View File

@ -8,15 +8,15 @@ class ArborescenceController extends Zend_Controller_Action
{ {
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
$request = $this->getRequest(); $request = $this->getRequest();
$key = $request->getParam('key'); $key = $request->getParam('key');
$this->view->assign('key', $key); $this->view->assign('key', $key);
//Récupération des valeurs enregistrées en session //Récupération des valeurs enregistrées en session
require_once 'Scores/SessionCiblage.php'; require_once 'Scores/SessionCiblage.php';
$sessionCiblage = new SessionCiblage(); $sessionCiblage = new SessionCiblage();
$val = $sessionCiblage->getCritere($key); $val = $sessionCiblage->getCritere($key);
$valuesChecked = array(); $valuesChecked = array();
$valuesUndetermined = array(); $valuesUndetermined = array();
if ($val != null){ if ($val != null){
$valuesChecked = explode(',',$val); $valuesChecked = explode(',',$val);
@ -26,17 +26,17 @@ class ArborescenceController extends Zend_Controller_Action
} }
$niveau = $request->getParam('niveau', 1); $niveau = $request->getParam('niveau', 1);
$nafM = new Application_Model_Naf(); $nafM = new Application_Model_Naf();
$sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC'); $sql = $nafM->select()->where('niveau = ?', $niveau)->order('code ASC');
$result = $nafM->fetchAll($sql)->toArray(); $result = $nafM->fetchAll($sql)->toArray();
$tabNaf = array(); $tabNaf = array();
foreach($result as $item) foreach($result as $item)
{ {
$structure = array( $structure = array(
'data' => $item['code'].' - '.$item['lib'], 'data' => $item['code'].' - '.$item['lib'],
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']), 'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
'state' => 'closed', 'state' => 'closed',
'children' => array(), 'children' => array(),
); );
if (in_array($item['code'], $valuesChecked)){ if (in_array($item['code'], $valuesChecked)){
$structure['attr']['class'] = 'jstree-checked'; $structure['attr']['class'] = 'jstree-checked';
@ -57,14 +57,15 @@ class ArborescenceController extends Zend_Controller_Action
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest(); $request = $this->getRequest();
$key = $request->getParam('key'); $key = $request->getParam('key');
//Récupération des valeurs enregistrées en session //Récupération des valeurs enregistrées en session
require_once 'Scores/SessionCiblage.php'; require_once 'Scores/SessionCiblage.php';
$sessionCiblage = new SessionCiblage(); $sessionCiblage = new SessionCiblage();
$val = $sessionCiblage->getCritere($key); $val = $sessionCiblage->getCritere($key);
$valuesChecked = array(); $valuesChecked = array();
$valuesUndetermined = array(); $valuesUndetermined = array();
if ($val != null){ if ($val != null){
$valuesChecked = explode(',',$val); $valuesChecked = explode(',',$val);
@ -73,12 +74,12 @@ class ArborescenceController extends Zend_Controller_Action
} }
} }
$request = $this->getRequest(); $request = $this->getRequest();
$niveau = $request->getParam('niveau', 1); $niveau = $request->getParam('niveau', 1);
$niveau++; $niveau++;
$parent = $request->getParam('parent', ''); $parent = $request->getParam('parent', '');
$nafM = new Application_Model_Naf(); $nafM = new Application_Model_Naf();
$sql = $nafM->select(); $sql = $nafM->select();
if (!empty($parent) && $niveau==2) { if (!empty($parent) && $niveau==2) {
$sql->where('parent = ?', $parent); $sql->where('parent = ?', $parent);
} elseif (!empty($parent) && $niveau>2) { } elseif (!empty($parent) && $niveau>2) {
@ -113,15 +114,15 @@ class ArborescenceController extends Zend_Controller_Action
$out = array(); $out = array();
if (strlen($value)>2) { if (strlen($value)>2) {
$niveau = strlen($value)-1; $niveau = strlen($value)-1;
$new = substr($value,0,$niveau); $new = substr($value,0,$niveau);
$out = array_merge($out, array($new), $this->getNafParent($new, $niveau1)); $out = array_merge($out, array($new), $this->getNafParent($new, $niveau1));
} elseif (strlen($value)==2 && $niveau1 === true) { } elseif (strlen($value)==2 && $niveau1 === true) {
$nafM = new Application_Model_Naf(); $nafM = new Application_Model_Naf();
$sql = $nafM->select() $sql = $nafM->select()
->from($nafM, array('parent')) ->from($nafM, array('parent'))
->where('code = ?', $value); ->where('code = ?', $value);
$result = $nafM->fetchRow($sql); $result = $nafM->fetchRow($sql);
$out[] = $result->parent; $out[] = $result->parent;
} }
return $out; return $out;
} }
@ -137,8 +138,9 @@ class ArborescenceController extends Zend_Controller_Action
$this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js'); $this->view->inlineScript()->appendFile('/themes/default/scripts/jquery.jstree.js');
require_once 'Scores/SessionCiblage.php'; require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage(); $session = new SessionCiblage();
$val = $session->getCritere('adr_cp'); $val = $session->getCritere('adr_cp');
$valuesCheckeds = explode(',', $val); $valuesCheckeds = explode(',', $val);
if(count($valuesCheckeds) > 0) { if(count($valuesCheckeds) > 0) {
for($i=0;count($valuesCheckeds) > $i;$i++) { for($i=0;count($valuesCheckeds) > $i;$i++) {
@ -151,10 +153,10 @@ class ArborescenceController extends Zend_Controller_Action
$values = explode(',', $val); $values = explode(',', $val);
foreach($values as $valuesChecked) { foreach($values as $valuesChecked) {
if(strlen($valuesChecked) == 5) { if(strlen($valuesChecked) == 5) {
$dept = substr($valuesChecked, 0, 2); $dept = substr($valuesChecked, 0, 2);
$table = new Application_Model_Departements(); $table = new Application_Model_Departements();
$sql = $table->select()->from('departements', array('codeRegionInsee'))->where('numdep = ?',$dept); $sql = $table->select()->from('departements', array('codeRegionInsee'))->where('numdep = ?',$dept);
$results = $table->fetchAll($sql)->toArray(); $results = $table->fetchAll($sql)->toArray();
foreach($results as $result) { foreach($results as $result) {
$valuesUndetermined[] = $result['codeRegionInsee']; $valuesUndetermined[] = $result['codeRegionInsee'];
} }
@ -162,8 +164,8 @@ class ArborescenceController extends Zend_Controller_Action
if(substr($valuesChecked, 0, 1) == 'R') { if(substr($valuesChecked, 0, 1) == 'R') {
$valuesCheckeds[] = substr($valuesChecked, 1); $valuesCheckeds[] = substr($valuesChecked, 1);
} else if (substr($valuesChecked, 0, 1) == 'D') { } else if (substr($valuesChecked, 0, 1) == 'D') {
$table = new Application_Model_Departements(); $table = new Application_Model_Departements();
$sql = $table->select()->from('departements', array('codeRegionInsee'))->where('numdep = ?', substr($valuesChecked, 1)); $sql = $table->select()->from('departements', array('codeRegionInsee'))->where('numdep = ?', substr($valuesChecked, 1));
$result = $table->fetchAll($sql)->toArray(); $result = $table->fetchAll($sql)->toArray();
foreach($result as $item) { foreach($result as $item) {
$valuesUndetermined[] = $item['codeRegionInsee']; $valuesUndetermined[] = $item['codeRegionInsee'];
@ -175,17 +177,17 @@ class ArborescenceController extends Zend_Controller_Action
$key = $this->getRequest()->getParam('key'); $key = $this->getRequest()->getParam('key');
$this->view->assign('key', $key); $this->view->assign('key', $key);
$regionsM = new Application_Model_Regions(); $regionsM = new Application_Model_Regions();
$sql = $regionsM->select()->from('regions'); $sql = $regionsM->select()->from('regions');
$regions = $regionsM->fetchAll()->toArray(); $regions = $regionsM->fetchAll()->toArray();
$structure = array(); $structure = array();
foreach($regions as $region) { foreach($regions as $region) {
$structure = array( $structure = array(
'data' => $region['NCCENR'], 'data' => $region['NCCENR'],
'attr' => array('id' => 'R'.$region['REGION'], 'niveau' => 0), 'attr' => array('id' => 'R'.$region['REGION'], 'niveau' => 0),
'state' => 'closed', 'state' => 'closed',
'children' => array() 'children' => array()
); );
if(in_array($region['REGION'], $valuesCheckeds)) { if(in_array($region['REGION'], $valuesCheckeds)) {
$structure['attr']['class'] = 'jstree-checked'; $structure['attr']['class'] = 'jstree-checked';
@ -203,16 +205,17 @@ class ArborescenceController extends Zend_Controller_Action
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest(); $request = $this->getRequest();
$key = $request->getParam('key'); $key = $request->getParam('key');
$id = $request->getParam('id'); $id = $request->getParam('id');
if($id[0] == 'R') { if($id[0] == 'R') {
require_once 'Scores/SessionCiblage.php'; require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage(); $session = new SessionCiblage();
$val = $session->getCritere('adr_cp'); $val = $session->getCritere('adr_cp');
$valuesCheckeds = array(); $valuesCheckeds = array();
$valuesUndetermined = array(); $valuesUndetermined = array();
if($val != null) if($val != null)
{ {
$values = explode(',', $val); $values = explode(',', $val);
@ -234,8 +237,8 @@ class ArborescenceController extends Zend_Controller_Action
} }
} }
$region = substr($request->getParam('id'), 1); $region = substr($request->getParam('id'), 1);
$deps = new Application_Model_Departements(); $deps = new Application_Model_Departements();
$sql = $deps->select() $sql = $deps->select()
->from('departements') ->from('departements')
->where('codeRegionInsee = ?', $region); ->where('codeRegionInsee = ?', $region);
$departements = $deps->fetchAll($sql)->toArray(); $departements = $deps->fetchAll($sql)->toArray();
@ -255,35 +258,35 @@ class ArborescenceController extends Zend_Controller_Action
$departementTab[] = $structure; $departementTab[] = $structure;
} }
echo json_encode($departementTab); echo json_encode($departementTab);
} else if($id[0] == 'D') { } else if ($id[0] == 'D')
{
require_once 'Scores/SessionCiblage.php'; require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage(); $session = new SessionCiblage();
$val = $session->getCritere('adr_cp'); $val = $session->getCritere('adr_cp');
$valuesCheckeds = array(); $valuesCheckeds = array();
if($val != null) if($val != null)
{ {
$values = explode(',', $val); $values = explode(',', $val);
//print_r($values);
foreach($values as $valuesChecked) { foreach($values as $valuesChecked) {
if(strlen($valuesChecked) == 5) { if(strlen($valuesChecked) == 5) {
$valuesCheckeds[] = $valuesChecked; $valuesCheckeds[] = $valuesChecked;
} }
else if(substr($valuesChecked, 0, 1) == 'D') { else if(substr($valuesChecked, 0, 1) == 'D') {
$table = new Application_Model_Codepostaux(); $table = new Application_Model_Codepostaux();
$sql = $table->select()->from('codepostaux', array('Codepos'))->where('Codepos LIKE "'.substr($valuesChecked, 1).'%"'); $sql = $table->select()->from('codepostaux', array('Codepos'))->where('Codepos LIKE "'.substr($valuesChecked, 1).'%"');
$results = $table->fetchAll($sql)->toArray(); $results = $table->fetchAll($sql)->toArray();
foreach($results as $result) { foreach($results as $result) {
if(!in_array($result['Codepos'], $values)) if(!in_array($result['Codepos'], $values))
$valuesCheckeds[] = $result['Codepos']; $valuesCheckeds[] = $result['Codepos'];
} }
} else if (substr($valuesChecked, 0, 1) == 'R') { } else if (substr($valuesChecked, 0, 1) == 'R') {
$Departements= new Application_Model_Departements(); $Departements = new Application_Model_Departements();
$sql = $Departements->select()->from('departements', array('numdep'))->where('codeRegionInsee = ?', substr($valuesChecked, 1)); $sql = $Departements->select()->from('departements', array('numdep'))->where('codeRegionInsee = ?', substr($valuesChecked, 1));
$results = $Departements->fetchAll($sql)->toArray(); $results = $Departements->fetchAll($sql)->toArray();
foreach($results as $result) { foreach($results as $result) {
$table = new Application_Model_Codepostaux(); $table = new Application_Model_Codepostaux();
$sql = $table->select()->from('codepostaux', array('Codepos'))->where('Codepos LIKE "'.$result['numdep'].'%"'); $sql = $table->select()->from('codepostaux', array('Codepos'))->where('Codepos LIKE "'.$result['numdep'].'%"');
$codes = $table->fetchAll($sql)->toArray(); $codes = $table->fetchAll($sql)->toArray();
foreach($codes as $code) { foreach($codes as $code) {
if(!in_array($result['Codepos'], $values)) if(!in_array($result['Codepos'], $values))
$valuesCheckeds[] = $code['Codepos']; $valuesCheckeds[] = $code['Codepos'];
@ -293,12 +296,12 @@ class ArborescenceController extends Zend_Controller_Action
} }
} }
$numdep = substr($request->getParam('id'), 1); $numdep = substr($request->getParam('id'), 1);
$code = new Application_Model_Codepostaux(); $code = new Application_Model_Codepostaux();
$sql = $code->select() $sql = $code->select()
->from('codepostaux') ->from('codepostaux')
->where('Codepos LIKE "'.$numdep.'%"'); ->where('Codepos LIKE "'.$numdep.'%"');
$codePostaux = $code->fetchAll($sql)->toArray(); $codePostaux = $code->fetchAll($sql)->toArray();
foreach($codePostaux as $codePostau) { foreach($codePostaux as $codePostau) {
$structure = array( $structure = array(
'data' => '[ '.$codePostau['Codepos'].' ]'.ucfirst(strtolower($codePostau['Commune'])), 'data' => '[ '.$codePostau['Codepos'].' ]'.ucfirst(strtolower($codePostau['Commune'])),
@ -319,7 +322,7 @@ class ArborescenceController extends Zend_Controller_Action
*/ */
public function juridqueAction() public function juridqueAction()
{ {
$valeurs = $this>getRequest()->getParam('');
} }

View File

@ -19,14 +19,24 @@ class CriteresController extends Zend_Controller_Action
} }
} }
public function entrepriseAction(){} public function entrepriseAction(){
$this->view->headLink()->appendStylesheet('/themes/default/styles/criteres/'.$this->getRequest()->getActionName().'.css', 'all');
}
public function economiqueAction(){} public function economiqueAction(){
$this->view->headLink()->appendStylesheet('/themes/default/styles/criteres/'.$this->getRequest()->getActionName().'.css', 'all');
}
public function geographiqueAction(){} public function geographiqueAction(){
$this->view->headLink()->appendStylesheet('/themes/default/styles/criteres/'.$this->getRequest()->getActionName().'.css', 'all');
}
public function juridiqueAction(){} public function juridiqueAction(){
$this->view->headLink()->appendStylesheet('/themes/default/styles/criteres/'.$this->getRequest()->getActionName().'.css', 'all');
}
public function financiereAction(){} public function financiereAction(){
$this->view->headLink()->appendStylesheet('/themes/default/styles/criteres/'.$this->getRequest()->getActionName().'.css', 'all');
}
} }

View File

@ -22,11 +22,12 @@ class IndexController extends Zend_Controller_Action
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
$user = $auth->getIdentity(); $user = $auth->getIdentity();
$session = new SessionCiblage();
//Chargement de la structure des champs et des préférences utilisateurs //Chargement de la structure des champs et des préférences utilisateurs
require_once 'Scores/Field.php'; require_once 'Scores/Field.php';
$fields = new Fields($user->username); $fields = new Fields($user->username);
$this->view->fields = $fields; $this->view->fields = $fields;
$this->view->criteres = $session->getCriteres();
} }
public function resetAction() public function resetAction()