/**
  * Finaliza una emergencia
  */
 public function save()
 {
     $this->load->library("validar");
     $correcto = true;
     $error = array();
     $params = $this->input->post(null, true);
     $emergencia = $this->emergencia_model->getById($params["id"]);
     if (!is_null($emergencia)) {
         if (!$this->validar->validarFechaSpanish($params["fecha_cierre"])) {
             $correcto = false;
             $error["fecha-cierre"] = "Debe ingresar una fecha";
         } else {
             $error["fecha-cierre"] = "";
         }
         if (!$this->validar->validarVacio($params["comentarios_cierre"])) {
             $correcto = false;
             $error["comentarios_cierre"] = "Debe ingresar los comentarios";
         } else {
             $error["comentarios_cierre"] = "";
         }
         if ($correcto) {
             $data = array("est_ia_id" => Emergencia_Estado_Model::FINALIZADA, "eme_d_fecha_cierre" => spanishDateToISO($params["fecha_cierre"]), "eme_c_comentario_cierre" => $params["comentarios_cierre"]);
             $this->emergencia_model->query()->update($data, "eme_ia_id", $emergencia->eme_ia_id);
             Evento_historial::putHistorial($emergencia->eme_ia_id, 'La emergencia ha sido finalizada: ' . $params["comentarios_cierre"]);
         }
         $respuesta = array("correcto" => $correcto, "error" => $error);
         echo json_encode($respuesta);
     } else {
         show_404();
     }
 }
 public function validarInspeccion($params)
 {
     $this->_correcto = true;
     if (!$this->validar->validarVacio($params["fecha_inspeccion"])) {
         $this->_correcto = false;
         $this->_error["fecha_inspeccion"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["fecha_inspeccion"] = "";
     }
     if ($this->validar->validarNumero($params["hallazgo_inspeccion"])) {
         $this->_error["hallazgo_inspeccion"] = "";
     } else {
         $this->_correcto = false;
         $this->_error["hallazgo_inspeccion"] = "Este dato no puede estar vacío";
     }
     if ($this->validar->validarNumero($params["cantidad_inspeccion"])) {
         $this->_error["cantidad_inspeccion"] = "";
     } else {
         $this->_correcto = false;
         $this->_error["cantidad_inspeccion"] = "Este dato no puede estar vacío";
     }
     if (!$this->validar->validarVacio($params["observaciones_inspeccion"])) {
         $this->_correcto = false;
         $this->_error["observaciones_inspeccion"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["observaciones_inspeccion"] = "";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (isset($params["ND"]) && $params["ND"] == 1 || isset($params["SR"]) && $params["SR"] == 1) {
         //no detectado
     } else {
         if (!$this->validar->validarVacio($params["resultado"])) {
             $this->_correcto = false;
             $this->_error["resultado"] = "Este dato no puede estar vacío";
         } else {
             $this->_error["resultado"] = "";
         }
     }
     $separada = explode("/", $params["resultado_fecha"]);
     if (count($separada) == 3 and strlen($separada[count($separada) - 1]) == 4) {
         if (!$this->validar->validarFechaSpanish($params["resultado_fecha"], "d/m/Y")) {
             $this->_correcto = false;
             $this->_error["resultado_fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
         } else {
             $this->_error["resultado_fecha"] = "";
         }
     } else {
         $this->_correcto = false;
         $this->_error["resultado_fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["nombre"])) {
         $this->_correcto = false;
         $this->_error["nombre"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["nombre"] = "";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["nombre"])) {
         $this->_correcto = false;
         $this->_error["nombre"] = "Debe ingresar el nombre del usuario";
     } else {
         $this->_error["nombre"] = "";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["nombre"])) {
         $this->_correcto = false;
         $this->_error["nombre"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["nombre"] = "";
     }
     if (!$this->validar->validarVacio($params["apellido"])) {
         $this->_correcto = false;
         $this->_error["apellido"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["apellido"] = "";
     }
     $separada = explode("/", $params["fecha_de_nacimiento"]);
     if (count($separada) == 3 and strlen($separada[count($separada) - 1]) == 4) {
         if (!$this->validar->validarFechaSpanish($params["fecha_de_nacimiento"], "d/m/Y")) {
             $this->_correcto = false;
             $this->_error["fecha_de_nacimiento"] = "La fecha no es válida: formato(dd/mm/yyyy)";
         } else {
             $this->_error["fecha_de_nacimiento"] = "";
         }
     } else {
         $this->_correcto = false;
         $this->_error["fecha_de_nacimiento"] = "La fecha no es válida: formato(dd/mm/yyyy)";
     }
     if (!$this->validar->validarVacio($params["direccion"])) {
         $this->_correcto = false;
         $this->_error["direccion"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["direccion"] = "";
     }
     if (!$this->validar->validarFechaSpanish($params["fecha_fur"], "d/m/Y")) {
         $this->_correcto = false;
         $this->_error["fecha_fur"] = "La fecha no es válida";
     } else {
         $this->_error["fecha_fur"] = "";
     }
     if (!$this->validar->validarFechaSpanish($params["fecha_fpp"], "d/m/Y")) {
         $this->_correcto = false;
         $this->_error["fecha_fpp"] = "La fecha no es válida";
     } else {
         $this->_error["fecha_fpp"] = "";
     }
     if (trim($params["run"]) != "") {
         if (!$this->_ci->rut->validar($params["run"])) {
             $this->_correcto = false;
             $this->_error["run"] = "El rut ingresado no es válido";
         } else {
             $this->_error["run"] = "";
         }
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["rut"])) {
         $this->_correcto = false;
         $this->_error["rut"] = "Debe ingresar el rut del usuario";
     } else {
         $this->_error["rut"] = "";
     }
     if (!$this->validar->validarVacio($params["nombre"])) {
         $this->_correcto = false;
         $this->_error["nombre"] = "Debe ingresar el nombre del usuario";
     } else {
         $this->_error["nombre"] = "";
     }
     if (!$this->validar->validarVacio($params["apellido_paterno"])) {
         $this->_correcto = false;
         $this->_error["apellido_paterno"] = "Debe ingresar el apellido del usuario";
     } else {
         $this->_error["apellido_paterno"] = "";
     }
     if (!$this->validar->validarVacio($params["apellido_materno"])) {
         $this->_correcto = false;
         $this->_error["apellido_materno"] = "Debe ingresar el apellido del usuario";
     } else {
         $this->_error["apellido_materno"] = "";
     }
     if (!$this->validar->validarVacio($params["activo"])) {
         $this->_correcto = false;
         $this->_error["activo"] = "Debe seleccionar un valor";
     } else {
         $this->_error["activo"] = "";
     }
     /*if(!$this->validar->validarVacio($params["sexo"])){
           $this->_correcto = false;
           $this->_error["sexo"] = "Debe seleccionar un valor";
       } else {
           $this->_error["sexo"] = "";
       }*/
     if (!$this->validar->validarVacio($params["cargo"])) {
         $this->_correcto = false;
         $this->_error["cargo"] = "Debe seleccionar un valor";
     } else {
         $this->_error["cargo"] = "";
     }
     if (!$this->validar->validarVacio($params["nacional"])) {
         $this->_correcto = false;
         $this->_error["nacional"] = "Debe seleccionar un valor";
     } else {
         $this->_error["nacional"] = "";
     }
     /*
             if(!$this->validar->validarVacio($params["perfil"])){
                 $this->_correcto = false;
                 $this->_error["perfil"] = "Debe seleccionar un valor";
             } else {
                 $this->_error["perfil"] = "";
             }*/
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     fb($params);
     if (!$this->validar->validarVacio($params["laboratorio"])) {
         $this->_correcto = false;
         $this->_error["laboratorio"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["laboratorio"] = "";
     }
     if (count($params['analisis']) == 0) {
         $this->_correcto = false;
         $this->_error["analisis"] = "Falta seleccionar tipos de análisis";
     } else {
         $this->_error["analisis"] = "";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["nombre_informante"])) {
         $this->_correcto = false;
         $this->_error["nombre_informante"] = "Debe ingresar el nombre del informante";
     } else {
         $this->_error["nombre_informante"] = "";
     }
     if (!$this->validar->validarVacio($params["nombre_emergencia"])) {
         $this->_correcto = false;
         $this->_error["nombre_emergencia"] = "Debe ingresar el nombre del Evento";
     } else {
         $this->_error["nombre_emergencia"] = "";
     }
     if (!$this->validar->validarVacio($params["nombre_lugar"])) {
         $this->_correcto = false;
         $this->_error["nombre_lugar"] = "Debe ingresar el nombre del lugar";
     } else {
         $this->_error["nombre_lugar"] = "";
     }
     if (!$this->validar->validarVacio($params["tipo_emergencia"])) {
         $this->_correcto = false;
         $this->_error["tipo_emergencia"] = "Debe ingresar un tipo de Evento";
     } else {
         $this->_error["tipo_emergencia"] = "";
     }
     if (!$this->validar->validarVacio($params["estado_emergencia"])) {
         $this->_correcto = false;
         $this->_error["estado_emergencia"] = "Debe seleccionar estado del Evento";
     } else {
         $this->_error["estado_emergencia"] = "";
     }
     if (!$this->validar->validarVacio($params["descripcion_emergencia"])) {
         $this->_correcto = false;
         $this->_error["descripcion_emergencia"] = "Debe ingresar una descripción del Evento";
     } else {
         $this->_error["descripcion_emergencia"] = "";
     }
     if (!$this->validar->validarFechaSpanish($params["fecha_emergencia"])) {
         $this->_correcto = false;
         $this->_error["fecha_emergencia"] = "Debe ingresar fecha/hora del Evento";
     } else {
         $this->_error["fecha_emergencia"] = "";
     }
     if (!$this->validar->validarArregloVacio($params["comunas"])) {
         $this->_correcto = false;
         $this->_error["comunas"] = "Debe ingresar al menos una comuna";
     } else {
         $this->_error["comunas"] = "";
     }
     /*$fecha_recepcion = DateTime::createFromFormat("d-m-Y H:i", $params["fecha_recepcion"]);
       if($fecha_recepcion instanceof DateTime){
           $this->_error["fecha_recepcion"] = "";
       } else {
           $this->_correcto = false;
           $this->_error["fecha_recepcion"] = "Debe ingresarse una fecha de válida";
       }*/
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     if (!$this->validar->validarVacio($params["form_coordenadas_latitud"])) {
         $this->_correcto = false;
         $this->_error["form_coordenadas_latitud"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["form_coordenadas_latitud"] = "";
     }
     if (!$this->validar->validarVacio($params["form_coordenadas_longitud"])) {
         $this->_correcto = false;
         $this->_error["form_coordenadas_longitud"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["form_coordenadas_longitud"] = "";
     }
     if (!$this->validar->validarVacio($params["form_coordenadas_calidad_de_georeferenciacion"])) {
         $this->_correcto = false;
         $this->_error["form_coordenadas_calidad_de_georeferenciacion"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["form_coordenadas_calidad_de_georeferenciacion"] = "";
     }
     $separada = explode("/", $params["fecha"]);
     if (count($separada) == 3 and strlen($separada[count($separada) - 1]) == 4) {
         if (!$this->validar->validarFechaSpanish($params["fecha"], "d/m/Y")) {
             $this->_correcto = false;
             $this->_error["fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
         } else {
             $this->_error["fecha"] = "";
         }
     } else {
         $this->_correcto = false;
         $this->_error["fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
     }
     if (!$this->validar->validarVacio($params["recurso"])) {
         $this->_correcto = false;
         $this->_error["recurso"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["recurso"] = "";
     }
     if (isset($params["ND"]) && $params["ND"] == 1) {
         //no detectado
     } else {
         if (!$this->validar->validarVacio($params["resultado"])) {
             $this->_correcto = false;
             $this->_error["resultado"] = "Este dato no puede estar vacío";
         } else {
             $this->_error["resultado"] = "";
         }
     }
     if (!$this->validar->validarVacio($params["origen"])) {
         $this->_correcto = false;
         $this->_error["origen"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["origen"] = "";
     }
     if (!$this->validar->validarVacio($params["region"])) {
         $this->_correcto = false;
         $this->_error["region"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["region"] = "";
     }
     /*if(!$this->validar->validarVacio($params["comuna"])){
           $this->_correcto = false;
           $this->_error["comuna"] = "Este dato no puede estar vacío";
       } else {
           $this->_error["comuna"] = "";
       }*/
     /*if(!$this->validar->validarVacio($params["numero_de_muestra"])){
           $this->_correcto = false;
           $this->_error["numero_de_muestra"] = "Este dato no puede estar vacío";
       } else {
           $this->_error["numero_de_muestra"] = "";
       }*/
     if (!$this->validar->validarVacio($params["laboratorio"])) {
         $this->_correcto = false;
         $this->_error["laboratorio"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["laboratorio"] = "";
     }
     return $this->_correcto;
 }
 /**
  * 
  * @param array $params
  * @return boolean
  */
 public function esValido($params)
 {
     $separada = explode("/", $params["fecha"]);
     if (count($separada) == 3 and strlen($separada[count($separada) - 1]) == 4) {
         if (!$this->validar->validarFechaSpanish($params["fecha"], "d/m/Y")) {
             $this->_correcto = false;
             $this->_error["fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
         } else {
             $this->_error["fecha"] = "";
         }
     } else {
         $this->_correcto = false;
         $this->_error["fecha"] = "La fecha no es válida: formato(dd/mm/yyyy)";
     }
     if (!$this->validar->validarVacio($params["recurso"])) {
         $this->_correcto = false;
         $this->_error["recurso"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["recurso"] = "";
     }
     if (!$this->validar->validarVacio($params["origen"])) {
         $this->_correcto = false;
         $this->_error["origen"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["origen"] = "";
     }
     if (!$this->validar->validarVacio($params["numero_de_muestra"])) {
         $this->_correcto = false;
         $this->_error["numero_de_muestra"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["numero_de_muestra"] = "";
     }
     if (!$this->validar->validarVacio($params["lugar"])) {
         $this->_correcto = false;
         $this->_error["lugar"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["lugar"] = "";
     }
     if (!$this->validar->validarVacio($params["puerto"])) {
         $this->_correcto = false;
         $this->_error["puerto"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["puerto"] = "";
     }
     if (!$this->validar->validarVacio($params["embarcacion"])) {
         $this->_correcto = false;
         $this->_error["embarcacion"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["embarcacion"] = "";
     }
     if (!$this->validar->validarVacio($params["matricula"])) {
         $this->_correcto = false;
         $this->_error["matricula"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["matricula"] = "";
     }
     if (!$this->validar->validarVacio($params["patron"])) {
         $this->_correcto = false;
         $this->_error["patron"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["patron"] = "";
     }
     if (!$this->validar->validarVacio($params["destino_de_consumo"])) {
         $this->_correcto = false;
         $this->_error["destino_de_consumo"] = "Este dato no puede estar vacío";
     } else {
         $this->_error["destino_de_consumo"] = "";
     }
     return $this->_correcto;
 }