Xlsexport_model.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. // ------------------------------------------------------------------------
  20. public function __construct()
  21. {
  22. parent::__construct();
  23. }
  24. // ------------------------------------------------------------------------
  25. // ------------------------------------------------------------------------
  26. public function getLicitaciones($having = "")
  27. {
  28. $sql = "SELECT
  29. CF.id,
  30. LI.id_licitacion,
  31. GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
  32. LI.link_uri,
  33. LI.updated,
  34. CF.contractFolderID,
  35. CF.contractFolderStatusCode,
  36. LP.buyerProfileURIID,
  37. LP.contractingPartyTypeCode,
  38. MP.partyName,
  39. MP.codpostal,
  40. MP.websiteURI,
  41. MP.city,
  42. MP.direccion,
  43. MP.contact_name,
  44. MP.contact_email,
  45. PROJ.NAME as name,
  46. PROJ.estimatedOverallContractAmount,
  47. PROJ.taxExclusiveAmount,
  48. PROJ.totalAmount,
  49. PROJ.countrySubentityCode,
  50. PROJ.countrySubentity,
  51. PROJ.durationMesure,
  52. PROJ.medida,
  53. PROJ.duracion_inicio,
  54. PROJ.duracion_fin,
  55. PROJ.contractExtension,
  56. TT.procurementLegislationDocumentReference,
  57. TT.allowedSubcontractTerms,
  58. RCF.descripcion AS contrato_status,
  59. RLP.nombre AS tipo_administracion,
  60. TPC.descripcion AS tipo_contrato,
  61. RTP.nombre AS tipoTender,
  62. RTPC.nombre AS contrato_sistema,
  63. RTPS.nombre AS submision,
  64. RTPU.nombre AS urgency,
  65. LI.fecha_creacion_log
  66. FROM
  67. maestro_datos_iniciales_licitacion LI
  68. JOIN import_licitaciones_temp temp ON LI.id_licitacion = temp.id_licitacion
  69. LEFT JOIN maestro_contract_folder CF ON CF.id_ajena_licitacion = LI.id_licitacion
  70. LEFT JOIN maestro_located_contracting_party LP ON LP.id_ajena_licitacion = LI.id_licitacion
  71. LEFT JOIN maestro_party MP ON MP.id_ajena_licitacion = LI.id_licitacion
  72. LEFT JOIN maestro_procurement_project PROJ ON PROJ.id_ajena_licitacion = LI.id_licitacion
  73. LEFT JOIN maestro_procurement_project_itemclass PROJI ON PROJI.id_ajena_licitacion = LI.id_licitacion
  74. LEFT JOIN maestro_tendering_process TP ON TP.id_ajena_licitacion = LI.id_licitacion
  75. LEFT JOIN maestro_tendering_terms TT ON TT.id_ajena_licitacion = LI.id_licitacion
  76. LEFT JOIN relacionada_contract_status RCF ON RCF.CODE = CF.contractFolderStatusCode
  77. LEFT JOIN relacionada_located_contracting_party RLP ON RLP.CODE = LP.contractingPartyTypeCode
  78. LEFT JOIN relacionada_tipo_contrato TPC ON TPC.CODE = PROJ.typeCode
  79. LEFT JOIN relacionada_tender_process RTP ON RTP.CODE = TP.procedureCode
  80. LEFT JOIN relacionada_tender_process_contracting_code RTPC ON RTPC.CODE = TP.contractingSystemCode
  81. LEFT JOIN relacionada_tender_process_submission RTPS ON RTPS.CODE = TP.submissionMethodCode
  82. LEFT JOIN relacionada_tender_process_urgency_code RTPU ON RTPU.CODE = TP.urgencyCode /*WHERE
  83. LI.id < 17174 */
  84. GROUP BY
  85. id_licitacion
  86. $having
  87. ORDER BY
  88. CF.id";
  89. $result = $this->db->query($sql);
  90. $datos['datos'] = $result->result();
  91. $datos['num_rows'] = $result->num_rows();
  92. return $datos;
  93. }
  94. public function getDatosByTablaAndLicitacion($tabla, $licitacionID)
  95. {
  96. $sql = "SELECT *
  97. FROM
  98. $tabla
  99. WHERE id_ajena_licitacion = $licitacionID";
  100. $result = $this->db->query($sql);
  101. $datos['datos'] = $result->result_array();
  102. $datos['num_rows'] = $result->num_rows();
  103. return $datos['datos'];
  104. }
  105. public function getTablaWithoutLicitacion($tabla)
  106. {
  107. $sql = "SELECT
  108. *
  109. FROM
  110. $tabla t1";
  111. $result = $this->db->query($sql);
  112. $datos['datos'] = $result->result_array();
  113. $datos['num_rows'] = $result->num_rows();
  114. return $datos;
  115. }
  116. public function getDatosRelacionadosByTablaAndLicitacion($tabla, $tablaAjena, $idRelacionada, $idAjenaLicitacion)
  117. {
  118. $sql = "SELECT
  119. *
  120. FROM
  121. $tabla
  122. JOIN $tablaAjena TBAJ ON TBAJ.code = " . $tabla . "." . $idRelacionada . "
  123. WHERE id_ajena_licitacion = $idAjenaLicitacion";
  124. $result = $this->db->query($sql);
  125. $datos['datos'] = $result->result_array();
  126. $datos['num_rows'] = $result->num_rows();
  127. return $datos['datos'];
  128. }
  129. public function getDatosRelacionadasTablaWithoutLicitacion($tablaRelacion, $tabla, $txtIdAjena, $id = "t1.id")
  130. {
  131. $sql = "SELECT
  132. *
  133. FROM
  134. $tabla t1
  135. JOIN
  136. $tablaRelacion t2 ON t2." . $txtIdAjena . " = t1.id";
  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 getTenderProcessRelacion()
  143. {
  144. $sql = "SELECT
  145. t2.nombre as procedureCode, t3.nombre as contractingSystemCode, t4.nombre as submissionMethodCode, t5.nombre as urgencyCode,
  146. t1.id_ajena_licitacion, t1.partPresentationCode, t1.maximumLotPresentationQuantity, t1.maximumTendererAwardedLotsQuantity, t1.lotsCombinationContractingAuthorityRights,
  147. t1.deadLineEndDate, t1.deadLineEndTime, t1.deadLineDescription, t1.auctionTerms, t1.documentAvailablePeriod_EndDate, t1.documentAvailablePeriod_EndTime
  148. FROM
  149. maestro_tendering_process t1
  150. JOIN relacionada_tender_process t2 ON t2.code = t1.procedureCode
  151. JOIN relacionada_tender_process_contracting_code t3 ON t3.code = t1.contractingSystemCode
  152. JOIN relacionada_tender_process_submission t4 ON t4.code = t1.submissionMethodCode
  153. JOIN relacionada_tender_process_urgency_code t5 ON t5.code = t1.urgencyCode";
  154. $result = $this->db->query($sql);
  155. $datos['datos'] = $result->result_array();
  156. $datos['num_rows'] = $result->num_rows();
  157. return $datos;
  158. }
  159. public function getValidNoticeInfoRelacion()
  160. {
  161. $sql = "SELECT
  162. t2.nombre as noticeTypeCode, t1.id_ajena_licitacion, t1.publicationMediaName
  163. FROM
  164. maestro_valid_notice_info t1
  165. JOIN relacionada_valid_notice_info t2 ON t2.code = t1.noticeTypeCode";
  166. $result = $this->db->query($sql);
  167. $datos['datos'] = $result->result_array();
  168. $datos['num_rows'] = $result->num_rows();
  169. return $datos;
  170. }
  171. public function getTenderResult()
  172. {
  173. $sql = "SELECT
  174. t2.nombre as resultCode, t1.id_ajena_licitacion, t1.description, t1.awardDate, t1.receivedTenderQuantity, t1.lowerTenderAmount , t1.higherTenderAmount, t1.startDate,
  175. t1.smeawardedIndicator, t1.contract_id, t1.contract_issueDate, t1.partyIdentification, t1.partyName, t1.TaxExclusiveAmount, t1.PayableAmount
  176. FROM
  177. maestro_tender_result t1
  178. JOIN relacionada_tender_result t2 ON t2.code = t1.resultCode";
  179. $result = $this->db->query($sql);
  180. $datos['datos'] = $result->result_array();
  181. $datos['num_rows'] = $result->num_rows();
  182. return $datos;
  183. }
  184. public function getTenderingTermsGarantia()
  185. {
  186. $sql = "SELECT
  187. t1.id_ajena_licitacion, t2.nombre as guaranteeTypeCode, t1.requiredCurriculaIndicator, t1.variantConstraintIndicator, t1.fundingProgramCode, t1.requiredFinancialGuarantee_Amount,
  188. t1.language, t1.allowedSubcontractTerms, t1.description, t1.personalSituation, t1.procurementLegislationDocumentReference
  189. FROM
  190. maestro_tendering_terms t1
  191. JOIN relacionada_codigo_tipo_garantia t2 ON t2.code = t1.guaranteeTypeCode";
  192. $result = $this->db->query($sql);
  193. $datos['datos'] = $result->result_array();
  194. $datos['num_rows'] = $result->num_rows();
  195. return $datos;
  196. }
  197. public function getTenderingTermsCriteriosFinanciacion()
  198. {
  199. $sql = "SELECT
  200. t2.id_ajena_licitacion,
  201. t3.nombre AS evaluationCriteriaTypeCode,
  202. t1.description
  203. FROM
  204. maestro_tendering_terms_financial_evaluation t1
  205. JOIN maestro_tendering_terms t2 ON t1.id_ajena_licitacion = t2.id
  206. JOIN relacionada_tendering_terms_financial t3 ON t3.CODE = t1.evaluationCriteriaTypeCode";
  207. $result = $this->db->query($sql);
  208. $datos['datos'] = $result->result_array();
  209. $datos['num_rows'] = $result->num_rows();
  210. return $datos;
  211. }
  212. public function getTenderingTermsCriteriosTecnicos()
  213. {
  214. $sql = "SELECT
  215. t2.id_ajena_licitacion, t3.nombre as evaluationCriteriaTypeCode, t1.description
  216. FROM
  217. maestro_tendering_terms_qualification_request t1
  218. JOIN maestro_tendering_terms t2 ON t1.id_ajena_licitacion = t2.id
  219. JOIN relacionada_tendering_terms_qualification_request t3 ON t3.code = t1.evaluationCriteriaTypeCode";
  220. $result = $this->db->query($sql);
  221. $datos['datos'] = $result->result_array();
  222. $datos['num_rows'] = $result->num_rows();
  223. return $datos;
  224. }
  225. public function getTenderingTermsRequisitos()
  226. {
  227. $sql = "SELECT
  228. t2.id_ajena_licitacion, t3.nombre as evaluationCriteriaTypeCode, t1.description
  229. FROM
  230. maestro_tendering_terms_qualification_request t1
  231. JOIN maestro_tendering_terms t2 ON t1.id_ajena_licitacion = t2.id
  232. JOIN relacionada_tendering_terms_qualification_request t3 ON t3.code = t1.evaluationCriteriaTypeCode";
  233. $result = $this->db->query($sql);
  234. $datos['datos'] = $result->result_array();
  235. $datos['num_rows'] = $result->num_rows();
  236. return $datos;
  237. }
  238. public function getProjectLotActivityByProjectLot($projectLotId)
  239. {
  240. $sql = "SELECT
  241. *
  242. FROM
  243. maestro_procurement_project_lot_item
  244. WHERE id_ajena_ppl = $projectLotId";
  245. $result = $this->db->query($sql);
  246. $datos['datos'] = $result->result_array();
  247. $datos['num_rows'] = $result->num_rows();
  248. return $datos;
  249. }
  250. }
  251. /* End of file Xlsexport_model_model.php */
  252. /* Location: ./application/models/Xlsexport_model_model.php */