select()->order('reference ASC'); $rows = $profilM->fetchAll($sql); $this->view->assign('profils', $rows); } public function detailAction() { $request = $this->getRequest(); $id = $request->getParam('id', null); require_once 'Scores/Enrichissement.php'; $data = new Enrichissement(); if ( $id != null ) { $profilM = new Application_Model_Profil(); $profil = $profilM->find($id); $criteres = json_decode($profil->current()->criteres, true); $tmp = array(); foreach ($criteres as $critere) { $tmp[] = $data->getDicoLib($critere); } $this->view->assign('profil', $tmp); $this->view->assign('reference', $profil->current()->reference); } } public function createAction() { $this->view->inlineScript()->appendFile('/themes/default/js/profil.js', 'text/javascript'); $request = $this->getRequest(); $id = $request->getParam('id', null); $doublon = array(); require_once 'Scores/Enrichissement.php'; $data = new Enrichissement(); if ( $id != null ) { $profilM = new Application_Model_Profil(); $profil = $profilM->find($id); $criteres = json_decode($profil->current()->criteres, true); if( $profil->current()->doublon!='' ) { $doublon = json_decode($profil->current()->doublon, true); } $tmp = array(); foreach ($criteres as $critere) { $values = false; if (preg_match('/(.*)\((.*)\)/', $critere, $matches)) { $values = $matches[2]; } $pos = strpos($critere, '('); if ($pos === false){ $key = $critere; } else { $key = substr($critere, 0, $pos); } Zend_Registry::get('firebug')->info($key); $tmp[$key] = array( 'lib' => $data->getDicoLib($key), 'values' => $values, ); } $this->view->assign('criteres', $tmp); $this->view->assign('reference', $profil->current()->reference); } $this->view->assign('doublon', $doublon); $this->view->assign('id', $id); $this->view->assign('edit', true); $this->view->assign('elements', $data->getDico()); } public function saveAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $reference = $request->getParam('reference'); $criteres = $request->getParam('criteres'); $doublon = $request->getParam('doublon'); $profilM = new Application_Model_Profil(); $data = array( 'reference' => $reference, 'criteres' => json_encode($criteres), 'doublon' => ($doublon!='') ? json_encode($doublon) : '', ); $id = $request->getParam('id', null); if ( $id != null ) { try { $result = $profilM->update($data, 'id='.$id); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('firebug')->info($e->getMessage()); } } else { try { $result = $profilM->insert($data); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('firebug')->info($e->getMessage()); } } if ( $result!=0 ){ echo ''; } else { echo 'Erreur'; } } public function setAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $idprofil = $request->getParam('idprofil'); $idfile = $request->getParam('idfile'); $commandesM = new Application_Model_Commandes(); $data = array( 'idProfil' => $idprofil, ); if ( $commandesM->update($data, "id=$idfile") ){ echo ''; } else { echo 'Erreur'; } } public function deleteAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $idfile = $request->getParam('idfile'); $db = Zend_Registry::get('db'); $commandesM = new Application_Model_Commandes($db); $commandesM->delete("id=$idfile"); $this->redirect('/'); } public function helpAction() { $this->_helper->layout()->disableLayout(); $request = $this->getRequest(); $key = $request->getParam('key'); require_once 'Scores/Enrichissement.php'; $dico = new Enrichissement(); $this->view->assign('lib', $dico->getDicoLib($key)); $this->view->assign('help', $dico->getDicoHelp($key)); $this->view->assign('columns', $dico->getDicoColumns($key)); } }