/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreateClient()
 {
     $hU = new HttpUtils();
     if ($hU->isAjaxRequest() == false) {
         Response::error("not allowed ;)");
     }
     if (isset($_POST["clientName"]) == false || isset($_POST["clientEmail"]) == false) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Faltan parámetros obligatorios")));
     }
     $cl = Cliente::model()->findAll("email=:email", array(':email' => $_POST["clientEmail"]));
     if (sizeof($cl) > 0) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Cliente {$_POST["clientEmail"]} ya registrado en el sistema")));
     }
     $cl = new Cliente();
     $cl->surname = "";
     $cl->comments = "";
     $cl->streetaddress = "";
     $cl->name = $_POST["clientName"];
     $cl->email = $_POST["clientEmail"];
     if ($cl->save()) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_EXITO, "detalle" => "Cliente {$cl->email} registrado con éxito")));
     } else {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Error registrando cliente {$cl->email} en el sistema")));
     }
 }