Xlsexport_model.php 8.1KB

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