Beispiel #1
0
 /**
  * Creates a new linea
  */
 public function agregarLineaAlClienteAction()
 {
     $this->view->disable();
     $retorno = array();
     $retorno['success'] = false;
     $retorno['mensaje'] = " - ";
     if (!$this->request->isAjax()) {
         return $this->dispatcher->forward(array("controller" => "cliente", "action" => "index"));
     }
     $linea = new Linea();
     $linea->setLineaNombre($this->request->getPost("linea_nombre"));
     $linea->setLineaClienteId($this->request->getPost("linea_clienteId"));
     $linea->setLineaHabilitado(1);
     if (!$linea->save()) {
         $mensaje = "No se pudo guardar";
         foreach ($linea->getMessages() as $message) {
             $mensaje = $message . "<br>";
         }
         $retorno['mensaje'] = $mensaje;
         echo json_encode($retorno);
         return;
     }
     $retorno['mensaje'] = "La linea ha sido agregada correctamente";
     $retorno['success'] = true;
     echo json_encode($retorno);
     return;
 }