Ejemplo n.º 1
0
 public function altaAction()
 {
     // action body
     $request = $this->getRequest();
     $idEncuesta = $this->getParam("idEncuesta");
     $formulario = new Encuesta_Form_AltaSeccion();
     if ($request->isGet()) {
         if (!is_null($idEncuesta)) {
             $encuesta = $this->encuestaDAO->obtenerEncuesta($idEncuesta);
             $this->view->encuesta = $encuesta;
             $this->view->formulario = $formulario;
         } else {
             $this->_helper->redirector->gotoSimple("index", "index", "encuesta");
         }
     } else {
         if ($request->isPost()) {
             if ($formulario->isValid($request->getPost())) {
                 $datos = $formulario->getValues();
                 $seccion = new Encuesta_Model_Seccion($datos);
                 $seccion->setIdEncuesta($idEncuesta);
                 $seccion->setFecha(date("Y-m-d H:i:s", time()));
                 $this->seccionDAO->crearSeccion($seccion);
                 $this->_helper->redirector->gotoSimple("index", "index", "encuesta", array("idEncuesta" => $idEncuesta));
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function crearSeccion(Encuesta_Model_Seccion $seccion)
 {
     $tablaSeccion = $this->tablaSeccion;
     $select = $tablaSeccion->select()->from($tablaSeccion)->where("idEncuesta = ?", $seccion->getIdEncuesta());
     $orden = count($tablaSeccion->fetchAll($select));
     $orden++;
     $seccion->setOrden($orden);
     $seccion->setElementos("0");
     $seccion->setHash($seccion->getHash());
     $seccion->setFecha(date("Y-m-d H:i:s", time()));
     $tablaSeccion->insert($seccion->toArray());
 }