diff --git a/application/controllers/ProfilController.php b/application/controllers/ProfilController.php index b4c8b7b6..767d6cfc 100644 --- a/application/controllers/ProfilController.php +++ b/application/controllers/ProfilController.php @@ -19,8 +19,6 @@ class ProfilController extends Zend_Controller_Action require_once 'Scores/Enrichissement.php'; $data = new Enrichissement(); - $this->view->assign('elements', $data->getDico()); - if ( $id != null ) { $profilM = new Application_Model_Profil(); $profil = $profilM->find($id); @@ -30,6 +28,7 @@ class ProfilController extends Zend_Controller_Action $tmp[] = $data->getDicoLib($critere); } $this->view->assign('profil', $tmp); + $this->view->assign('reference', $profil->current()->reference); } } @@ -38,10 +37,34 @@ class ProfilController extends Zend_Controller_Action { $request = $this->getRequest(); $id = $request->getParam('id', null); - + require_once 'Scores/Enrichissement.php'; - $data = new Enrichissement(); - $this->view->assign('elements', $data->getDico()); + $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) { + $values = false; + if (preg_match('/(.*)\((.*)\)/', $critere, $matches)) + { + $values = $matches[2]; + } + + $tmp[$critere] = array( + 'lib' => $data->getDicoLib($critere), + 'values' => $values, + ); + } + $this->view->assign('criteres', $tmp); + $this->view->assign('reference', $profil->current()->reference); + } + $this->view->assign('id', $id); + $this->view->assign('edit', true); + $this->view->assign('elements', $data->getDico()); + } public function saveAction() @@ -58,11 +81,21 @@ class ProfilController extends Zend_Controller_Action $data = array( 'reference' => $reference, 'criteres' => json_encode($criteres), - ); - if ( $profilM->insert($data) ){ - echo ''; + ); + + $id = $request->getParam('id', null); + if ( $id != null ) { + if ( $profilM->update($data, 'id='.$id) ){ + echo ''; + } else { + echo 'Erreur'; + } } else { - echo 'Erreur'; + if ( $profilM->insert($data) ){ + echo ''; + } else { + echo 'Erreur'; + } } } diff --git a/application/views/scripts/profil/create.phtml b/application/views/scripts/profil/create.phtml index b69b9560..c469925e 100644 --- a/application/views/scripts/profil/create.phtml +++ b/application/views/scripts/profil/create.phtml @@ -3,7 +3,7 @@ div#entete { width:45%; float:left; border:1px solid #bebebe; - height:400px; + height:500px; overflow:auto; margin:5px 0; } @@ -16,12 +16,12 @@ div#entete li { font-weight:bold; color:#000000; margin-left:30px; - padding-left:10px; + padding:5px 10px; } div#dico { width:45%; - height:400px; + height:500px; float:right; border:1px solid #bebebe; overflow:auto; @@ -30,7 +30,7 @@ div#dico { div#dico li { list-style-type:none; - padding-left:10px; + padding:5px 10px; background-color:#4D90FE; border-top:2px solid #ffffff; border-bottom:2px solid #ffffff; @@ -39,15 +39,28 @@ div#dico li { color:#000000; } +input[type="text"] { + border:1px solid; +}