From 59df244e797af11d7a293a7871d553d4de606d2f Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 6 Mar 2012 15:02:50 +0000 Subject: [PATCH] Enregistrer un profil --- .../controllers/GestionController.php | 30 ++++++++++++++++++- .../views/scripts/gestion/profiladd.phtml | 11 ++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/application/modules/frontend/controllers/GestionController.php b/application/modules/frontend/controllers/GestionController.php index 43088066..f3f8bd9f 100644 --- a/application/modules/frontend/controllers/GestionController.php +++ b/application/modules/frontend/controllers/GestionController.php @@ -35,7 +35,35 @@ class GestionController extends Zend_Controller_Action //Sauvegarde du formulaire if ( $request->isPost() ){ - + $params = $request->getParams(); + + //Vérifier le formulaire + $errForm = 0; + foreach ( $params as $key => $value ) { + if (empty($value)) { + $errForm++; + } + } + if (!$errForm) { + + $data = array( + 'idClient' => $params['idClient'], + 'login' => $params['login'], + 'reference' => $params['reference'], + 'criteres' => json_encode($params['criteres']), + 'tarifLigne' => $params['tarifLigne'], + 'dateAjout' => date('Y-m-d H:i:s'), + 'actif' => 1, + ); + $profilM = new Table_EnrichissementProfils(); + if ( $profilM->insert($data) ){ + $this->view->message('message', "Profil enregistré"); + } else { + $this->view->message('message', "Erreur lors de la sauvegarde"); + } + } else { + $this->view->message('message', "Erreur lors de la saisie"); + } } diff --git a/application/modules/frontend/views/scripts/gestion/profiladd.phtml b/application/modules/frontend/views/scripts/gestion/profiladd.phtml index e2006f34..8f7fa727 100644 --- a/application/modules/frontend/views/scripts/gestion/profiladd.phtml +++ b/application/modules/frontend/views/scripts/gestion/profiladd.phtml @@ -1,6 +1,8 @@
-
+message?> + +
@@ -17,8 +19,7 @@
- fields)>0 ) {?> fields as $value => $item ) {?> @@ -27,8 +28,10 @@
+ +
+
- \ No newline at end of file