<?php
defined('BASEPATH') or exit('No direct script access allowed');

/**
 *
 * Model Parser_model
 *
 * This Model for ...
 *
 * @package        CodeIgniter
 * @category    Model
 * @author    Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
 * @link      https://github.com/setdjod/myci-extension/
 * @param     ...
 * @return    ...
 *
 */

class Parser_model extends CI_Model
{

    // ------------------------------------------------------------------------

    public function __construct()
    {
        parent::__construct();
    }

    public function inicioParser()
    {
        $data = array(
            'cron_ejecucion' => 1,
            "fecha_ejecucion" => date("Y-m-d h:i:s"),
        );

        $this->db->where('id', 0);
        $this->db->update('parametros_cron', $data);
    }

    public function stopParser()
    {
        $data = array(
            'cron_ejecucion' => 0,
            "fecha_ejecucion" => date("Y-m-d h:i:s"),
            
        );

        $this->db->where('id', 0);
        $this->db->update('parametros_cron', $data);
    }

    public function existCronRun()
    {
        $sql = "SELECT * FROM parametros_cron";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->row();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getUrlArchivos()
    {
        $sql = "SELECT * FROM tipo_licitacion_tablas";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function setInicioLicitacion($licitacionArr)
    {
        $this->db->insert('BRUTO_datos_iniciales', $licitacionArr);
        return $this->db->insert_id();
    }

    public function getMapaTablas()
    {
        $sql = "SELECT * FROM mapa_tablas_parser ORDER BY orden ASC";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getDatosBrutos($tabla)
    {
        $sql = "SELECT * FROM $tabla";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

}

/* End of file Parser_model.php */
/* Location: ./application/models/Parser_model.php */
