<?php





defined('BASEPATH') OR exit('No direct script access allowed');





class Mntc5365 extends CI_Model {





    function __construct() {


        parent::__construct();


        $this->load->dbforge();


    }


    


    public function saveNtc5365($informe){


        $this->createTable();


        $this->db->insert('ntc_5365',$informe[0]);


        return 1;


        


    }


    


    public function getInformeFecha($fechainicio,$fechafin){


        $this->createTable();


        $consulta = <<<EOF


                SELECT * FROM ntc_5365 n WHERE  DATE_FORMAT(n.fechaPrueba, '%Y-%m-%d')


 BETWEEN DATE_FORMAT('$fechainicio', '%Y-%m-%d %h:%i:%s') AND DATE_FORMAT('$fechafin', '%Y-%m-%d %h:%i:%s')       


EOF;


        $rta = $this->db->query($consulta);


        if ($rta->num_rows() > 0) {


            $rta = $rta->result();


            return $rta;


        } else {


            return [];


        }


    }


    


    public function createTable(){


        $ntc_5365 = $this->db->query("SHOW TABLES LIKE 'ntc_5365'");


        if (!$ntc_5365->num_rows() > 0) {


            $consulta = <<<EOF


              CREATE TABLE `ntc_5365` (


            	`idntc` INT(11) NOT NULL AUTO_INCREMENT,


            	`nit` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',


            	`nombreCda` VARCHAR(500) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`expedienteCornare` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroConsecutivoPrueba` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroCertificado` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`marca` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`annoModelo` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`placa` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`cilindraje` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`tipoMotor` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`disenno` VARCHAR(100) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`fechaPrueba` DATETIME NOT NULL,


            	`nombreInspector` VARCHAR(100) NOT NULL DEFAULT '0',


            	`temperaturaAmbiente` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`humedadRelativa` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`ciudad` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`direccion` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`temperaturaMotor` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroCilindros` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`rpmRalenti` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`hcRalenti` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`coRalenti` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`co2Ralenti` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`o2Ralenti` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`presenciaDilucion` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`conceptoFinal` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorPef` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`marcaAnalizador` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroSerieAnalizador` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroSerieBanco` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`numeroSerieElectronico` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`nombreSoftwareAplicacion` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`versionSoftwareAplicacion` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanHcBaja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanCoBaja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanCo2Baja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoHcBaja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoCoBaja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoCo2Baja` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanHcAlta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanCoAlta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`spanCo2Alta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoHcAlta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoCoAlta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`valorLeidoCo2Alta` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	`fechaVerificacion` DATETIME NOT NULL,


            	`resultadoVerificacion` VARCHAR(50) NOT NULL COLLATE 'utf8mb3_general_ci',


            	PRIMARY KEY (`idntc`) USING BTREE


            )


            COLLATE='utf8mb3_general_ci'


            ENGINE=MyISAM


            ;


                     


EOF;


            $this->db->query($consulta);


        }


    }


}





    


