Xlsexport_model.php 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. defined('BASEPATH') or exit('No direct script access allowed');
  3. /**
  4. *
  5. * Model Xlsexport_model_model
  6. *
  7. * This Model for ...
  8. *
  9. * @package CodeIgniter
  10. * @category Model
  11. * @author Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
  12. * @link https://github.com/setdjod/myci-extension/
  13. * @param ...
  14. * @return ...
  15. *
  16. */
  17. class Xlsexport_model extends CI_Model
  18. {
  19. protected $fechaLog = "";
  20. public function __construct()
  21. {
  22. parent::__construct();
  23. $this->fechaLog = $this->getLastDateLog()->fecha_maxima;
  24. }
  25. public function getLastDateLog()
  26. {
  27. $sql = "SELECT MAX(fecha) as fecha_maxima FROM config_fecha_importaciones LIMIT 1";
  28. $result = $this->db->query($sql);
  29. return $result->row();
  30. }
  31. // ------------------------------------------------------------------------
  32. // ------------------------------------------------------------------------
  33. public function getLicitaciones($idUltimaImportacion)
  34. {
  35. $sql = " SELECT
  36. CF.id,
  37. LI.id_licitacion,
  38. GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
  39. LI.link_uri,
  40. LI.updated,
  41. LI.estadoLicitacion,
  42. CF.contractFolderID,
  43. CF.contractFolderStatusCode,
  44. LP.buyerProfileURIID,
  45. LP.contractingPartyTypeCode,
  46. MP.partyName,
  47. MP.codpostal,
  48. MP.websiteURI,
  49. MP.city,
  50. MP.direccion,
  51. MP.contact_name,
  52. MP.contact_email,
  53. MPI.idPartyIdent AS partyItem,
  54. MPI.attr as tipoIdParty,
  55. PROJ.NAME as nameProject,
  56. PROJ.estimatedOverallContractAmount,
  57. PROJ.taxExclusiveAmount,
  58. PROJ.totalAmount,
  59. PROJ.countrySubentityCode,
  60. PROJ.countrySubentity,
  61. PROJ.durationMesure,
  62. PROJ.medida,
  63. PROJ.duracion_inicio,
  64. PROJ.duracion_fin,
  65. PROJ.contractExtension,
  66. TT.procurementLegislationDocumentReference,
  67. TT.allowedSubcontractTerms,
  68. RCF.descripcion AS contrato_status,
  69. RLP.nombre AS tipo_administracion,
  70. TPC.descripcion AS tipo_contrato,
  71. RTP.nombre AS tipoTender,
  72. RTPC.nombre AS contrato_sistema,
  73. RTPS.nombre AS submision,
  74. RTPU.nombre AS urgency,
  75. LI.fecha_creacion_log
  76. FROM
  77. global_datos_iniciales_licitacion LI
  78. JOIN global_contract_folder CF ON CF.id_ajena_licitacion = LI.id_licitacion
  79. JOIN global_located_contracting_party LP ON LP.id_ajena_licitacion = LI.id_licitacion
  80. JOIN global_party MP ON MP.id_ajena_licitacion = LI.id_licitacion
  81. JOIN global_party_party_idenfitication MPI on MPI.id_ajena_licitacion = LI.id_licitacion AND MPI.attr = 'DIR3'
  82. JOIN global_procurement_project PROJ ON PROJ.id_ajena_licitacion = LI.id_licitacion
  83. JOIN global_procurement_project_itemclass PROJI ON PROJI.id_ajena_licitacion = LI.id_licitacion
  84. JOIN global_tendering_process TP ON TP.id_ajena_licitacion = LI.id_licitacion
  85. JOIN global_tendering_terms TT ON TT.id_ajena_licitacion = LI.id_licitacion
  86. JOIN codice_contract_status RCF ON RCF.CODE = CF.contractFolderStatusCode
  87. JOIN codice_located_contracting_party RLP ON RLP.CODE = LP.contractingPartyTypeCode
  88. JOIN codice_tipo_contrato TPC ON TPC.CODE = PROJ.typeCode
  89. JOIN codice_tender_process RTP ON RTP.CODE = TP.procedureCode
  90. JOIN codice_tender_process_contracting_code RTPC ON RTPC.CODE = TP.contractingSystemCode
  91. JOIN codice_tender_process_submission RTPS ON RTPS.CODE = TP.submissionMethodCode
  92. JOIN codice_tender_process_urgency_code RTPU ON RTPU.CODE = TP.urgencyCode
  93. WHERE LI.id_importacion = $idUltimaImportacion
  94. GROUP BY
  95. id_licitacion";
  96. $result = $this->db->query($sql);
  97. $datos['datos'] = $result->result();
  98. $datos['num_rows'] = $result->num_rows();
  99. return $datos;
  100. }
  101. public function getFullDatosUltimasInsertadas()
  102. {
  103. $sql = "SELECT *
  104. FROM
  105. vista_datos_licitacion";
  106. $result = $this->db->query($sql);
  107. $datos['datos'] = $result->result();
  108. $datos['num_rows'] = $result->num_rows();
  109. return $datos;
  110. }
  111. public function getTablaByFechaLog($tabla)
  112. {
  113. $sql = "SELECT * FROM $tabla
  114. WHERE fecha_creacion_log = '$this->fechaLog'";
  115. $result = $this->db->query($sql);
  116. $datos['datos'] = $result->result_array();
  117. $datos['num_rows'] = $result->num_rows();
  118. return $datos;
  119. }
  120. public function getProjectLotItem()
  121. {
  122. $sql = "SELECT
  123. MP.idProcurementLot,
  124. MP.countrySubentity,
  125. MP.countrySubentityCode,
  126. MP.totalAmount,
  127. MP.taxExclusiveAmount,
  128. MP.`name`,
  129. MP.id_ajena_licitacion,
  130. GROUP_CONCAT( MPI.idItem ) AS itemClassification_attr
  131. FROM
  132. global_procurement_project_lot MP
  133. JOIN global_procurement_project_lot_item MPI ON MP.id_compuesta = MPI.id_compuesta_padre
  134. WHERE
  135. MPI.fecha_creacion_log = '$this->fechaLog'
  136. GROUP BY
  137. MP.id_compuesta";
  138. $result = $this->db->query($sql);
  139. $datos['datos'] = $result->result_array();
  140. $datos['num_rows'] = $result->num_rows();
  141. return $datos;
  142. }
  143. public function getFechasPublicadas($idLicitacion)
  144. {
  145. $sql = "SELECT MIN(fechas) as fecha
  146. FROM
  147. global_valid_notice_info_fecha WHERE id_ajena_licitacion = '$idLicitacion'";
  148. $result = $this->db->query($sql);
  149. $datos['datos'] = $result->row();
  150. $datos['num_rows'] = $result->num_rows();
  151. return $datos;
  152. }
  153. public function getTenderingTermsCodes()
  154. {
  155. $sql = "SELECT
  156. TP.*,
  157. RTP.nombre AS tipoTender, /*procedureCode*/
  158. RTPC.nombre AS contrato_sistema, /*urgencyCode*/
  159. RTPS.nombre AS submision, /*contractingSistemCode*/
  160. RTPU.nombre AS urgency /*urgencyCode*/
  161. FROM
  162. global_tendering_process TP
  163. JOIN codice_tender_process RTP ON RTP.CODE = TP.procedureCode
  164. JOIN codice_tender_process_contracting_code RTPC ON RTPC.CODE = TP.contractingSystemCode
  165. JOIN codice_tender_process_submission RTPS ON RTPS.CODE = TP.submissionMethodCode
  166. JOIN codice_tender_process_urgency_code RTPU ON RTPU.CODE = TP.urgencyCode
  167. WHERE
  168. TP.fecha_creacion_log = '$this->fechaLog'";
  169. $result = $this->db->query($sql);
  170. $datos['datos'] = $result->result_array();
  171. $datos['num_rows'] = $result->num_rows();
  172. return $datos;
  173. }
  174. public function getDatosRelacionadasTablaWithoutLicitacion($tabla, $tablaRelacion, $txtIdAjena, $id = "t1.id")
  175. {
  176. $sql = "SELECT
  177. *,
  178. t2.nombre as code_desc
  179. FROM
  180. $tabla t1
  181. JOIN
  182. $tablaRelacion t2 ON t2." . $txtIdAjena . " = t1." . $id . "
  183. WHERE t1.fecha_creacion_log = '$this->fechaLog'";
  184. $result = $this->db->query($sql);
  185. $datos['datos'] = $result->result_array();
  186. $datos['num_rows'] = $result->num_rows();
  187. return $datos;
  188. }
  189. }
  190. /* End of file Xlsexport_model_model.php */
  191. /* Location: ./application/models/Xlsexport_model_model.php */