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

/**
 *
 * Model Xlsexport_model_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 Xlsexport_model extends CI_Model
{

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

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

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

    // ------------------------------------------------------------------------
    public function getLicitaciones()
    {
        $sql = "SELECT *
                FROM
                    maestro_datos_iniciales_licitacion li
                    /*WHERE updated >= '2022-01-24 00:00:00' AND updated <= '2022-01-30 23:59:00'*/
                    WHERE id < 100";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getDatosByTablaAndLicitacion($tabla, $licitacionID)
    {
        $sql = "SELECT *
                FROM
                    $tabla
                WHERE id_ajena_licitacion = $licitacionID";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result_array();
        $datos['num_rows'] = $result->num_rows();
        return $datos['datos'];
    }

    public function getDatosRelacionadosByTablaAndLicitacion($tabla, $txtIdAjena, $idAjena)
    {
        $sql = "SELECT
                    *
                FROM
                    $tabla
                WHERE $txtIdAjena = $idAjena";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result_array();
        $datos['num_rows'] = $result->num_rows();
        return $datos['datos'];
    }

    public function getContractInfoByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_contract_folder
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getProjectByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_procurement_project
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getProjectByActivityByProject($projectId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_procurement_project_itemClass
                WHERE id_ajena_pp = $projectId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getProjectLotByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_procurement_project_lot
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getProjectLotActivityByProjectLot($projectLotId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_procurement_project_lot_item
                WHERE id_ajena_ppl = $projectLotId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getPartyByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_party
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getPartyIdentificationByLicitacion($partyId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_party_party_idenfitication
                WHERE id_ajena_party = $partyId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getLocatedPartyByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_located_contracting_party
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getLocatedPartyActivityByLicitacion($locatedPartyId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_located_contracting_party_activity
                WHERE id_ajena_lcp = $locatedPartyId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderProcessByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_tendering_process
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderResultByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_tender_result
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderingTermsByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_tendering_terms
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderingTermsAwardingByTenderTerms($tenderTermsId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_tendering_terms_awarding_terms
                WHERE id_ajena_tt = $tenderTermsId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderingTermsFinancialgByTenderTerms($tenderTermsId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_tendering_terms_financial_evaluation
                WHERE id_ajena_tt = $tenderTermsId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderingTermsQualificationByTenderTerms($tenderTermsId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_tendering_terms_qualification_request
                WHERE id_ajena_tt = $tenderTermsId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTenderingTermsSpecificByTenderTerms($tenderTermsId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_tendering_terms_specific_terms
                WHERE id_ajena_tt = $tenderTermsId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getValidNoticeInfoByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_valid_notice_info
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getValidNoticeInfoDocumentByValidId($validNoticeId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_valid_notice_info_documento
                WHERE id_ajena_vni = $validNoticeId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getValidNoticeInfoFechaByValidId($validNoticeId)
    {
        $sql = "SELECT *
                    *
                FROM
                    maestro_valid_notice_info_fecha
                WHERE id_ajena_vni = $validNoticeId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getAdditionalDocumuentsByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_additional_documents
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getGeneralDocumuentsByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_general_documents
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getLegalDocumuentsByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_legal_documents
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }

    public function getTechnicalDocumuentsByLicitacion($licitacionId)
    {
        $sql = "SELECT *
                    *
                FROM
                maestro_technical_documents
                WHERE id_ajena_licitacion = $licitacionId";
        $result = $this->db->query($sql);
        $datos['datos'] = $result->result();
        $datos['num_rows'] = $result->num_rows();
        return $datos;
    }
}

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