public function execute()
 {
     try {
         if (request::getInstance()->isMethod('POST')) {
             // DATOS DE ANIMAL
             $numeroIdentificacion = request::getInstance()->getPost(animalTableClass::getNameField(animalTableClass::NUMERO, true));
             //validar si los campos estan vacios
             $datos = array($numeroIdentificacion);
             $validatorEmpty = validator::getInstance()->validateFieldsEmpty($datos);
             if ($validatorEmpty == false) {
                 throw new PDOException(i18n::__(10006, null, 'errors', null, 10006));
             }
             //Validar el formato de fecha
             //                $validacionFecha = validator::getInstance()->validateDate($fecha);
             //                if ($validacionFecha == true) {
             //                    throw new PDOException(i18n::__(10005, null, 'errors', null, 10005));
             //                }
             //Validar campos numericos
             //            $validacionNumericos = validator::getInstance()->validateCharactersNumber($peso);
             //            if ($validacionNumericos == true) {
             //                throw new PDOException(i18n::__(10005, null, 'errors', null, 10005));
             //            }
             //                $validacionNumericos = validator::getInstance()->validateCharactersNumber($edad);
             //                if ($validacionNumericos == true) {
             //                    throw new PDOException(i18n::__(10005, null, 'errors', null, 10005));
             //                }
             //Insertar la informacion del usuario
             $data = array(animalTableClass::LOTE_ID => 2, animalTableClass::NUMERO => $numeroIdentificacion);
             animalTableClass::insert($data);
             session::getInstance()->setSuccess(i18n::__('succesCreate', null, 'animal'));
             log::register(i18n::__('create'), animalTableClass::getNameTable());
             routing::getInstance()->redirect('animal', 'indexAnimal');
         } else {
             log::register(i18n::__('create'), animalTableClass::getNameTable(), i18n::__('errorCreateBitacora'));
             session::getInstance()->setError(i18n::__('errorCreate', null, 'animal'));
             routing::getInstance()->redirect('animal', 'indexAnimal');
         }
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $where = null;
         //            if (session::getInstance()->hasAttribute('animalFiltersAnimal')) {
         //                $where = session::getInstance()->getAttribute('animalFiltersAnimal');
         //            }
         if (request::getInstance()->hasPost('report')) {
             $report = request::getInstance()->getPost('report');
             //
             //                if (isset($report['edad_inicial']) and $report['edad_inicial'] !== null and $report['edad_inicial'] !== '' and isset($report['edad_fin']) and $report['edad_fin'] !== null and $report['edad_fin'] !== '') {
             //                    $edad_inicial = validate::getInstance()->validateCharactersNumber($report['edad_inicial']);
             //                    $edad_fin = validate::getInstance()->validateCharactersNumber($report['edad_fin']);
             //                    /*echo ($edad_inicial) ? 'verdadero' : 'falso';
             //                    exit();*/
             //                    if ($edad_inicial == true or $edad_fin == true) {
             //                        throw new PDOException(i18n::__(10007, null, 'errors'));
             //                    }
             //                    $where[animalTableClass::EDAD] = array(
             //                        $report['edad_inicial'],
             //                        $report['edad_fin']
             //                    );
             //                }
             //
             //                if (isset($report['peso_inicial']) and $report['peso_inicial'] !== null and $report['peso_inicial'] !== '' and isset($report['peso_fin']) and $report['peso_fin'] !== null and $report['peso_fin'] !== '') {
             //                    $peso_inicial = validate::getInstance()->validateCharactersSpecial($report['peso_inicial']);
             //                    $peso_fin = validate::getInstance()->validateCharactersSpacial($report['peso_fin']);
             //                    if ($edad_inicial == true or $edad_fin == true) {
             //                        throw new PDOException(i18n::__(10007, null, 'errors'));
             //                    }
             //                    $where[animalTableClass::PESO] = array(
             //                        $report['peso_inicial'],
             //                        $report['peso_fin']
             //                    );
             //                }
             //                if (isset($report['fecha_inicial']) and $report['fecha_inicial'] !== null and $report['fecha_inicial'] !== '' and isset($report['fecha_fin']) and $report['fecha_fin'] !== null and $report['fecha_fin'] !== '') {
             //                    $fecha_inicial = validate::getInstance()->validateDate($filter['fecha_inicial']);
             //                    $fecha_fin = validate::getInstance()->validateDate($filter['fecha_fin']);
             //                    if ($fecha_inicial == false or $fecha_fin == false) {
             //                        throw new PDOException(i18n::__(10008, null, 'errors'));
             //                    }
             //                    $where[animalTableClass::FECHA_INGRESO] = array(
             //                        date(config::getFormatTimestamp(), strtotime($report['fecha_inicial'])),
             //                        date(config::getFormatTimestamp(), strtotime($report['fecha_fin']))
             //                    );
             //                }
             if (isset($report['tipo_doc']) and $report['tipo_doc'] !== null and $report['tipo_doc'] !== '' and $report['tipo_doc'] !== "default") {
                 $tipo_doc = validate::getInstance()->validateCharactersNumber($report['tipo_doc']);
                 if ($tipo_doc == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::NOMBRE] = $report['tipo_doc'];
             }
             if (isset($report['usuario']) and $report['usuario'] !== null and $report['usuario'] !== '' and $report['usuario'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersSpecial($report['usuario']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::TIPO_DOC] = $report['usuario'];
             }
             if (isset($report['usuario']) and $report['usuario'] !== null and $report['usuario'] !== '' and $report['usuario'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersSpecial($report['usuario']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::NUMERO_DOCUMENTO] = $report['usuario'];
             }
             if (isset($report['usuario']) and $report['usuario'] !== null and $report['usuario'] !== '' and $report['usuario'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersSpecial($report['usuario']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::CIUDAD_ID] = $report['usuario'];
             }
             if (isset($report['usuario']) and $report['usuario'] !== null and $report['usuario'] !== '' and $report['usuario'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersSpecial($report['usuario']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::TELEFONO] = $report['usuario'];
             }
             if (isset($report['usuario']) and $report['usuario'] !== null and $report['usuario'] !== '' and $report['usuario'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersSpecial($report['usuario']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[datosUsuarioTableClass::DIRECCION] = $report['usuario'];
             }
         }
         $fields = array(datosUsuarioTableClass::ID, datosUsuarioTableClass::NOMBRE, datosUsuarioTableClass::APELLIDOS, datosUsuarioTableClass::NUMERO_DOCUMENTO, datosUsuarioTableClass::TELEFONO, datosUsuarioTableClass::DIRECCION);
         $fields2 = array(ciudadTableClass::NOMBRE);
         $fields3 = array(usuarioTableClass::USER);
         $fields4 = array(tipoDocumentoTableClass::DESCRIPCION);
         $fJoin1 = datosUsuarioTableClass::CIUDAD_ID;
         $fJoin2 = ciudadTableClass::ID;
         $fJoin3 = datosUsuarioTableClass::USUARIO_ID;
         $fJoin4 = usuarioTableClass::ID;
         $fJoin5 = datosUsuarioTableClass::TIPO_DOC;
         $fJoin6 = tipoDocumentoTableClass::ID;
         $orderBy = array(datosUsuarioTableClass::ID);
         $this->objDatos = datosUsuarioTableClass::getAllJoin($fields, $fields2, $fields3, $fields4, $fJoin1, $fJoin2, $fJoin3, $fJoin4, $fJoin5, $fJoin6, false, $orderBy, 'ASC', null, null, $where);
         $this->mensaje = 'Informe de Usuarios en Nuestro Sistema';
         $this->defineView('index', 'usuario', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $where = null;
         if (session::getInstance()->hasAttribute('animalFiltersAnimal')) {
             $where = session::getInstance()->getAttribute('animalFiltersAnimal');
         }
         if (request::getInstance()->hasPost('report')) {
             $report = request::getInstance()->getPost('report');
             //
             if (isset($report['edad_inicial']) and $report['edad_inicial'] !== null and $report['edad_inicial'] !== '' and isset($report['edad_fin']) and $report['edad_fin'] !== null and $report['edad_fin'] !== '') {
                 $edad_inicial = validate::getInstance()->validateCharactersNumber($report['edad_inicial']);
                 $edad_fin = validate::getInstance()->validateCharactersNumber($report['edad_fin']);
                 /* echo ($edad_inicial) ? 'verdadero' : 'falso';
                    exit(); */
                 if ($edad_inicial == true or $edad_fin == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[animalTableClass::EDAD] = array($report['edad_inicial'], $report['edad_fin']);
             }
             if (isset($report['peso_inicial']) and $report['peso_inicial'] !== null and $report['peso_inicial'] !== '' and isset($report['peso_fin']) and $report['peso_fin'] !== null and $report['peso_fin'] !== '') {
                 $peso_inicial = validate::getInstance()->validateCharactersNumber($report['peso_inicial']);
                 $peso_fin = validate::getInstance()->validateCharactersNumber($report['peso_fin']);
                 if ($edad_inicial == true or $edad_fin == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[animalTableClass::PESO] = array($report['peso_inicial'], $report['peso_fin']);
             }
             if (isset($report['fecha_inicial']) and $report['fecha_inicial'] !== null and $report['fecha_inicial'] !== '' and isset($report['fecha_fin']) and $report['fecha_fin'] !== null and $report['fecha_fin'] !== '') {
                 $fecha_inicial = validate::getInstance()->validateDate($filter['fecha_inicial']);
                 $fecha_fin = validate::getInstance()->validateDate($filter['fecha_fin']);
                 if ($fecha_inicial == false or $fecha_fin == false) {
                     throw new PDOException(i18n::__(10008, null, 'errors'));
                 }
                 $where[animalTableClass::FECHA_INGRESO] = array(date(config::getFormatTimestamp(), strtotime($report['fecha_inicial'])), date(config::getFormatTimestamp(), strtotime($report['fecha_fin'])));
             }
             if (isset($report['genero']) and $report['genero'] !== null and $report['genero'] !== '' and $report['genero'] !== "default") {
                 $genero = validate::getInstance()->validateCharactersNumber($report['genero']);
                 if ($genero == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[animalTableClass::GENERO_ID] = $report['genero'];
             }
             if (isset($report['lote']) and $report['lote'] !== null and $report['lote'] !== '' and $report['lote'] !== "default") {
                 $lote = validate::getInstance()->validateCharactersNumber($report['lote']);
                 if ($lote == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[animalTableClass::LOTE_ID] = $report['lote'];
             }
             if (isset($report['raza']) and $report['raza'] !== null and $report['raza'] !== '' and $report['raza'] !== "default") {
                 $raza = validate::getInstance()->validateCharactersNumber($report['raza']);
                 if ($raza == true) {
                     throw new PDOException(i18n::__(10007, null, 'errors'));
                 }
                 $where[animalTableClass::RAZA] = $report['raza'];
             }
         }
         $fields = array(animalTableClass::ID, animalTableClass::PESO, animalTableClass::PRECIO_ANIMAL, animalTableClass::FECHA_NACIMIENTO, animalTableClass::NUMERO, animalTableClass::PRECIO_ANIMAL, animalTableClass::FECHA_NACIMIENTO, animalTableClass::PARTO);
         $fields2 = array(generoTableClass::NOMBRE);
         $fields3 = array(loteTableClass::NOMBRE);
         $fields4 = array(razaTableClass::NOMBRE_RAZA);
         $fJoin1 = animalTableClass::GENERO_ID;
         $fJoin2 = generoTableClass::ID;
         $fJoin3 = animalTableClass::LOTE_ID;
         $fJoin4 = loteTableClass::ID;
         $fJoin5 = animalTableClass::RAZA;
         $fJoin6 = razaTableClass::ID;
         $orderBy = array(animalTableClass::ID);
         $this->objAnimal = animalTableClass::getAllJoin($fields, $fields2, $fields3, $fields4, $fJoin1, $fJoin2, $fJoin3, $fJoin4, $fJoin5, $fJoin6, true, $orderBy, 'ASC', null, null, $where);
         $this->mensaje = 'Informe de Cerdos en Nuestro Sistema';
         $this->defineView('index', 'animal', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }