123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
- error_reporting(E_ALL & ~E_NOTICE);
- class ParserFile
- {
-
- protected $idLicitacion = 0;
- protected $datos_iniciales = array();
- protected $contrat_folder = array();
- protected $keyPadreRecursiva = "";
- protected $rutaDiaria = "";
- protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/format";
- protected $fechaInicioParser = "";
-
- //TODO: Añadir los nodos que falten mirando la libreria de java
- //TODO Nuevo Nodo: Proveedor de pliegos->TenderingTerms->DocumentProviderParty
- //TODO Nuevo Nodo: Lugar de recepción->TenderingTerms->TenderRecipientParty
- //TODO Nuevo Nodo: Proveedor de información adicional->TenderingTerms->AdditionalInformationParty
- //TODO Nuevo Nodo: Información sobre recursos//Lugar de presentación de recursos//Fecha límite de presentación de recursos//Arbitraje->TenderingTerms->AppealTerms
- //TODO Nuevo Nodo: Eventos->TenderingProcess->OpenTenderEvent
-
- public function __construct()
- {
- $this->CI = &get_instance();
- $this->CI->load->helper('file');
- $this->CI->load->library('parserdatabasebruto');
- $this->CI->load->library('parserdatabaselimpio');
- }
-
- public function index($rutaDiariaDownloader, $fechaInicioParser, $datosPerfil)
- {
- $this->rutaDiaria = $rutaDiariaDownloader . "/format/";
- $this->fechaInicioParser = $fechaInicioParser;
- $files = get_filenames($this->rutaDiaria, true);
-
- guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "----------------------------------", false);
-
- foreach ($files as $file) {
- $resultEntries = array();
- $entrada = file_get_contents($file);
- $xml = simplexml_load_string($entrada, "SimpleXMLElement"); //, LIBXML_NOCDATA | LIBXML_PARSEHUGE);
- $json = json_encode($xml);
- $array = json_decode($json, true);
-
- $filename = basename($file);
- $aux = 0;
- foreach ($array['entry'] as $clave => $row) {
- $arrayDeletedEntries = $xml->children('at', true);
-
- $resultEntries[$filename]['general'][$aux] = $this->nodoEntry($row, $datosPerfil->id);
-
- $resultEntries[$filename]['contractInfo'][$aux] = $this->nodoContractFolderStatus($row);
-
- $resultEntries[$filename]['locatedContractingParty'][$aux] = $this->nodoLocatedContractingParty($row);
-
- $resultEntries[$filename]['party'][$aux] = $this->nodoParty($row);
-
- $resultEntries[$filename]['procurementProject'][$aux] = $this->nodoPresupuesto($row);
-
- $resultEntries[$filename]['procurementProjectLot'][$aux] = $this->nodoProcurementProjectLot($row);
-
- $resultEntries[$filename]['tenderingTerms'][$aux] = $this->nodoTenderingTerms($row);
-
- $resultEntries[$filename]['tenderingProcess'][$aux] = $this->nodoTenderingProcess($row);
-
- $resultEntries[$filename]['tenderingResult'][$aux] = $this->nodoTenderResult($row);
-
- //$resultEntries[$filename]['validNoticeInfo'][$aux] = $this->nodoValidNoticeInfo($row);
-
- $resultEntries[$filename]['legalDocs'][$aux] = $this->nodoLegalDoc($row);
-
- $resultEntries[$filename]['technicalDocs'][$aux] = $this->nodoTechnicalDocumentReference($row);
-
- $resultEntries[$filename]['generalDocs'][$aux] = $this->nodoGeneralDocuments($row);
-
- $resultEntries[$filename]['additionalDocs'][$aux] = $this->nodoAdditionalDocumentReference($row);
-
- $aux++;
-
- //$this->recurseXML($array['entry'], true);
- }
-
- $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser, $datosPerfil);
-
- $resultEntries = array();
- //$this->CI->parserdatabaselimpio->index();
- }
-
- return;
- }
-
- private function nodoEntry($xml, $tipoPerfil)
- {
- $resultEntries = array();
- $id_licitacion = (string) substr($xml['id'], strrpos($xml['id'], '/') + 1);
- $resultEntries['url_id_licitacion'] = (string) $xml['id'];
- $resultEntries['id_licitacion'] = $id_licitacion;
- $this->idLicitacion = $id_licitacion;
- //$resultEntries['link_uri'] = (string) $this->existAttribute($xml, "link", "string", 'href');
- $resultEntries['summary'] = (string) $xml['summary'];
- $resultEntries['title'] = (string) $xml['title'];
- $resultEntries['updated'] = (string) $xml['updated'];
- $resultEntries['tipo_perfil_licitacion'] = $tipoPerfil;
- $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
- return $resultEntries;
- }
-
- private function nodoContractFolderStatus($xml)
- {
- $resultEntries = array();
- if (array_key_exists("ContractFolderStatus", $xml)) {
- $contractFolder = (array) $xml['ContractFolderStatus'];
-
- $resultEntries['ContractFolderID'] = (string) $contractFolder['ContractFolderID'];
- $resultEntries['ContractFolderStatusCode'] = (string) $contractFolder['ContractFolderStatusCode'];
- $resultEntries['ContractFolderStatusCodeAttr'] = $this->existAttribute($contractFolder, "ContractFolderStatusCode", "string", 'listURI');
- $resultEntries['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['id_compuesta'] = $this->idLicitacion . "_01";
- $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
- }
-
- return $resultEntries;
- }
-
- private function nodoLocatedContractingParty($xml)
- {
- $resultEntries = array();
- if (array_key_exists("LocatedContractingParty", $xml['ContractFolderStatus'])) {
- $LocatedContractingParty = $xml['ContractFolderStatus']['LocatedContractingParty'];
-
- $resultEntries['locatedContractingParty']['contractingPartyTypeCode'] = $this->existNodo($LocatedContractingParty, "ContractingPartyTypeCode", 'string');
- //$resultEntries['locatedContractingParty']['contractingPartyTypeCodeUri'] = $this->existAttribute($LocatedContractingParty, "ContractingPartyTypeCode", 'string', 'listURI');
-
- if (array_key_exists("ActivityCode", $xml['ContractFolderStatus']['LocatedContractingParty'])) {
- $activity = $xml['ContractFolderStatus']['LocatedContractingParty']['ActivityCode'];
- if (!is_array($activity)) {
- $activity = array(0 => $activity);
- }
- for ($i = 0; $i < count($activity); $i++) {
- $resultEntries['activity'][$i]['activityCode'] = (string) $activity[$i];
- //$resultEntries['activity'][$i]['activityCodeUri'] = (string) $activity[$i]->attributes()['listURI'];
- $resultEntries['activity'][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['activity'][$i]['id_compuesta'] = $this->idLicitacion . "_02_" . $i;
- $resultEntries['activity']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
-
- $resultEntries['locatedContractingParty']['buyerProfileURIID'] = $this->existNodo($LocatedContractingParty, "BuyerProfileURIID", 'string');
- $resultEntries['locatedContractingParty']['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['locatedContractingParty']['id_compuesta'] = $this->idLicitacion . "_02";
- $resultEntries['locatedContractingParty']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
-
- return $resultEntries;
- }
-
- private function nodoParty($xml)
- {
- $resultEntries = array();
- if (array_key_exists("Party", $xml['ContractFolderStatus']['LocatedContractingParty'])) {
- $party = $xml['ContractFolderStatus']['LocatedContractingParty']['Party'];
-
- $resultEntries['party']['websiteURI'] = $this->existNodo($party, "WebsiteURI", 'string');
-
- if (array_key_exists("PartyIdentification", $party)) {
- for ($i = 0; $i < count($party['PartyIdentification']); $i++) {
- $resultEntries['partyIdentification'][$i]['idPartyIdent'] = $this->existNodo($party['PartyIdentification'][$i], "ID", 'string');
- //$resultEntries['partyIdentification'][$i]['attr'] = $this->existAttribute($party, $party['PartyIdentification'][$i]['ID'], "string", 'schemeName');
- $resultEntries['partyIdentification'][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['partyIdentification'][$i]['id_compuesta'] = $this->idLicitacion . "_03_" . $i;
- $resultEntries['partyIdentification']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
-
- $resultEntries['party']['partyName'] = $this->existNodo($party['PartyName'], "Name", 'string');
- $resultEntries['party']['city'] = $this->existNodo($party['PostalAddress'], "CityName", 'string');
- $resultEntries['party']['codpostal'] = $this->existNodo($party['PostalAddress'], "PostalZone", 'string');
- $resultEntries['party']['direccion'] = $this->existNodo($party['PostalAddress']['AddressLine'], "Line", 'string');
- $resultEntries['party']['country'] = $this->existNodo($party['PostalAddress']['Country'], "Name", 'string');
- $resultEntries['party']['contact_name'] = $this->existNodo($party['Contact'], "Name", 'string');
- $resultEntries['party']['contact_email'] = $this->existNodo($party['Contact'], "ElectronicMail", 'string');
- $resultEntries['party']['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['party']['id_compuesta'] = $this->idLicitacion . "_03";
- $resultEntries['party']['fecha_creacion_log'] = $this->fechaInicioParser;
-
- }
- return $resultEntries;
- }
-
- private function nodoPresupuesto($xml)
- {
- $resultEntries = array();
-
- //$procurementProject = $xml->ContractFolderStatus->ProcurementProject;
- if (array_key_exists("ProcurementProject", $xml['ContractFolderStatus'])) {
- $procurementProject = $xml['ContractFolderStatus']['ProcurementProject'];
-
- $resultEntries['budget']['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['budget']['id_compuesta'] = $this->idLicitacion . "_04";
- $resultEntries['budget']['fecha_creacion_log'] = $this->fechaInicioParser;
- $resultEntries['budget']['name'] = $this->existNodo($procurementProject, 'Name', 'string');
- $resultEntries['budget']['typeCode'] = $this->existNodo($procurementProject, 'TypeCode', 'string');
- $resultEntries['budget']['subTypeCode'] = $this->existNodo($procurementProject, 'SubTypeCode', 'string');
-
- if (array_key_exists("BudgetAmount", $procurementProject)) {
- $resultEntries['budget']['estimatedOverallContractAmount'] = $this->existNodo($procurementProject['BudgetAmount'], 'EstimatedOverallContractAmount', 'string');
- $resultEntries['budget']['totalAmount'] = $this->existNodo($procurementProject['BudgetAmount'], 'TotalAmount', 'string');
- $resultEntries['budget']['taxExclusiveAmount'] = $this->existNodo($procurementProject['BudgetAmount'], 'TaxExclusiveAmount', 'string');
- }
-
- if (array_key_exists("RequiredCommodityClassification", $procurementProject)) {
- $firstKey = array_key_first($procurementProject['RequiredCommodityClassification']);
- if ($this->idLicitacion == "8815986") {
- $var = 1;
- }
- if ($firstKey === "ItemClassificationCode") {
- $procurementProject['RequiredCommodityClassification'] = array(0 => $procurementProject['RequiredCommodityClassification']);
- }
-
- for ($i = 0; $i < count($procurementProject['RequiredCommodityClassification']); $i++) {
- $resultEntries['itemClass'][$i]['itemClassification_value'] = $this->existNodo($procurementProject['RequiredCommodityClassification'][$i], 'ItemClassificationCode', 'string');
- //$resultEntries['itemClass'][$i]['itemClassification_attr'] = (string) $procurementProject['RequiredCommodityClassification'][$i]['ItemClassificationCode']['listURI'];
- $resultEntries['itemClass'][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['itemClass'][$i]['id_compuesta'] = $this->idLicitacion . "_04_" . $i;
- $resultEntries['itemClass']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
-
- if (array_key_exists("RealizedLocation", $procurementProject)) {
- $resultEntries['budget']['countrySubentity'] = $this->existNodo($procurementProject['RealizedLocation'], 'CountrySubentity', 'string');
- if (array_key_exists("CountrySubentityCode", $procurementProject['RealizedLocation'])) {
- $resultEntries['budget']['countrySubentityCode'] = $this->existNodo($procurementProject['RealizedLocation'], 'CountrySubentityCode', 'string');
- //$resultEntries['budget']['countrySubentityCodeAttr'] = $this->existAttribute($procurementProject['RealizedLocation'], "CountrySubentityCode", "string", 'listURI');
- }
-
- if (array_key_exists("Address", $procurementProject['RealizedLocation'])) {
- $resultEntries['budget']['cityName'] = $this->existNodo($procurementProject['RealizedLocation']['Address']['Country'], 'CityName', 'string');
- $resultEntries['budget']['IdentificationCode'] = $this->existNodo($procurementProject['RealizedLocation']['Address']['Country'], 'IdentificationCode', 'string');
- $resultEntries['budget']['countryName'] = $this->existNodo($procurementProject['RealizedLocation']['Address']['Country'], 'Name', 'string');
- }
- }
-
- $resultEntries['budget']['durationMesure'] = $this->existNodo($procurementProject['PlannedPeriod'], 'DurationMeasure', 'string');
- $resultEntries['budget']['duracion_inicio'] = $this->existNodo($procurementProject['PlannedPeriod'], 'StartDate', 'string');
- $resultEntries['budget']['duracion_fin'] = $this->existNodo($procurementProject['PlannedPeriod'], 'EndDate', 'string');
- //$resultEntries['budget']['medida'] = $this->existAttribute($procurementProject['PlannedPeriod'], "DurationMeasure", "string", 'unitCode');
-
- if (array_key_exists("ContractExtension", $procurementProject)) {
- $resultEntries['budget']['contractExtension'] = $this->existNodo($procurementProject['ContractExtension'], 'OptionsDescription', 'string');
- }
- }
-
- return $resultEntries;
- }
-
- private function nodoProcurementProjectLot($xml)
- {
- $resultEntries = array();
- if (array_key_exists("ProcurementProjectLot", $xml['ContractFolderStatus'])) {
- $procurementProjectLot = $xml['ContractFolderStatus']['ProcurementProjectLot'];
- $firstKey = array_key_first($procurementProjectLot);
-
- if ($firstKey !== 0) {
- $procurementProjectLot = array(0 => $procurementProjectLot);
- }
- for ($i = 0; $i < count($procurementProjectLot); $i++) {
- $resultEntries["lot"][$i]['idProcurementLot'] = $this->existNodo($procurementProjectLot[$i], 'ID', 'string');
- $resultEntries["lot"][$i]['name'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject'], 'Name', 'string');
- $resultEntries["lot"][$i]['totalAmount'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['BudgetAmount'], 'TotalAmount', 'string');
- $resultEntries["lot"][$i]['taxExclusiveAmount'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['BudgetAmount'], 'TaxExclusiveAmount', 'string');
- $resultEntries["lot"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries["lot"][$i]['id_compuesta'] = $this->idLicitacion . "_05_" . $i;
- $resultEntries["lot"]['fecha_creacion_log'] = $this->fechaInicioParser;
-
- if (array_key_exists("RealizedLocation", $procurementProjectLot[$i]['ProcurementProject'])) {
- $resultEntries["lot"][$i]['countrySubentity'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['RealizedLocation'], 'CountrySubentity', 'string');
- $resultEntries["lot"][$i]['countrySubentityCode'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['RealizedLocation'], 'CountrySubentityCode', 'string');
- $resultEntries["lot"][$i]['identificationCode'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['RealizedLocation']['Address']['Country'], 'IdentificationCode', 'string');
- $resultEntries["lot"][$i]['nameLocation'] = $this->existNodo($procurementProjectLot[$i]['ProcurementProject']['RealizedLocation']['Address']['Country'], 'Name', 'string');
-
- if (array_key_exists("RequiredCommodityClassification", $procurementProjectLot[$i]['ProcurementProject'])) {
- $clasificacionItems = $procurementProjectLot[$i]['ProcurementProject']['RequiredCommodityClassification'];
- $firstKey = array_key_first($clasificacionItems);
- if ($firstKey !== 0) {
- $clasificacionItems = array(0 => $clasificacionItems);
- }
- for ($j = 0; $j < count($clasificacionItems); $j++) {
-
- $resultEntries['itemClassification'][] = array(
- "idItem" => $this->existNodo($clasificacionItems[$j], "ItemClassificationCode", "string"),
- "id_ajena_licitacion" => $this->idLicitacion,
- "id_compuesta" => $this->idLicitacion . "_05_" . $i . "_" . $j,
- "fecha_creacion_log" => $this->fechaInicioParser,
- //$resultEntries["itemClassification"][$i]['itemClassification'][$j]['id_attr'] = $this->existAttribute($clasificacionItems[$j], "ItemClassificationCode", "string", 'listURI');
- );
- }
- }
- }
- }
- }
-
- return $resultEntries;
- }
-
- private function nodoTenderResult($xml)
- {
- $resultEntries = array();
- if (array_key_exists("TenderResult", $xml['ContractFolderStatus'])) {
- $tenderResult = $xml['ContractFolderStatus']['TenderResult'];
- $firstKey = array_key_first($tenderResult);
- if ($firstKey !== 0) {
- $tenderResult = array(0 => $tenderResult);
- }
- for ($i = 0; $i < count($tenderResult); $i++) {
- $resultEntries[$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['id_compuesta'] = $this->idLicitacion . "_06_" . $i;
- $resultEntries[$i]['fecha_creacion_log'] = $this->fechaInicioParser;
- $resultEntries[$i]['resultCode'] = $this->existNodo($tenderResult[$i], 'ResultCode', 'string');
- $resultEntries[$i]['description'] = $this->existNodo($tenderResult[$i], 'Description', 'string');
- $resultEntries[$i]['awardDate'] = $this->existNodo($tenderResult[$i], 'AwardDate', 'string');
- $resultEntries[$i]['receivedTenderQuantity'] = $this->existNodo($tenderResult[$i], 'ReceivedTenderQuantity', 'string');
- $resultEntries[$i]['lowerTenderAmount'] = $this->existNodo($tenderResult[$i], 'LowerTenderAmount', 'string');
- $resultEntries[$i]['higherTenderAmount'] = $this->existNodo($tenderResult[$i], 'HigherTenderAmount', 'string');
- $resultEntries[$i]['startDate'] = $this->existNodo($tenderResult[$i], 'StartDate', 'string');
- $resultEntries[$i]['smeawardedIndicator'] = $this->existNodo($tenderResult[$i], 'SMEAwardedIndicator', 'string');
- //AwardedTenderedProject
- $resultEntries[$i]['contract_id'] = $this->existNodo($tenderResult[$i]->Contract, 'ID', 'string');
- $resultEntries[$i]['contract_issueDate'] = $this->existNodo($tenderResult[$i]->Contract, 'IssueDate', 'string');
-
- if (array_key_exists("WinningParty", $tenderResult[$i])) {
- $winningParty = $tenderResult[$i]['WinningParty'];
- $resultEntries[$i]['partyIdentification'] = $this->existNodo($winningParty['PartyIdentification'], 'ID', 'string');
- $resultEntries[$i]['partyName'] = $this->existNodo($winningParty['PartyName'], 'Name', 'string');
- }
- if (array_key_exists("AwardedTenderedProject", $tenderResult[$i])) {
- $awardedTenderedProject = $tenderResult[$i]['AwardedTenderedProject'];
- $resultEntries[$i]['procurementProjectLotID'] = $this->existNodo($awardedTenderedProject, 'ProcurementProjectLotID', 'string');
- $resultEntries[$i]['TaxExclusiveAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'TaxExclusiveAmount', 'string');
- $resultEntries[$i]['PayableAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'PayableAmount', 'string');
- }
- }
- }
-
- //$resultFinal = $this->array_remove_empty($resultEntries);
- return $resultEntries;
- }
-
- private function nodoTenderingTerms($xml)
- {
- $resultEntries = array();
- if (array_key_exists("TenderingTerms", $xml['ContractFolderStatus'])) {
- $TenderingTerms = $xml['ContractFolderStatus']['TenderingTerms'];
-
- $resultEntries['tenderingTerm']['requiredCurriculaIndicator'] = $this->existNodo($TenderingTerms, 'RequiredCurriculaIndicator', 'string');
- $resultEntries['tenderingTerm']['variantConstraintIndicator'] = $this->existNodo($TenderingTerms, 'VariantConstraintIndicator', 'string');
- $resultEntries['tenderingTerm']['fundingProgramCode'] = $this->existNodo($TenderingTerms, 'FundingProgramCode', 'string');
- $resultEntries['tenderingTerm']['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['tenderingTerm']['id_compuesta'] = $this->idLicitacion . "_07";
- $resultEntries['tenderingTerm']['fecha_creacion_log'] = $this->fechaInicioParser;
-
- if (array_key_exists("RequiredFinancialGuarantee", $TenderingTerms)) {
- $resultEntries['tenderingTerm']['guaranteeTypeCode'] = $this->existNodo($TenderingTerms['RequiredFinancialGuarantee'], 'GuaranteeTypeCode', 'string');
- $resultEntries['tenderingTerm']['guaranteeTypeCode_attr'] = $this->existAttribute($TenderingTerms['RequiredFinancialGuarantee'], "GuaranteeTypeCode", "string", 'listURI');
- $resultEntries['tenderingTerm']['requiredFinancialGuarantee_Amount'] = $this->existNodo($TenderingTerms['RequiredFinancialGuarantee'], 'AmountRate', 'string');
-
- }
-
- $resultEntries['tenderingTerm']['procurementLegislationDocumentReference'] = $this->existNodo($TenderingTerms['ProcurementLegislationDocumentReference'], 'ID', 'string');
- $resultEntries['tenderingTerm']['allowedSubcontractTerms'] = $this->existNodo($TenderingTerms['AllowedSubcontractTerms'], 'Description', 'string');
-
- if (array_key_exists("AwardingTerms", $TenderingTerms)) {
- $tendererAwardingTerms = $TenderingTerms['AwardingTerms'];
- for ($i = 0; $i < count($tendererAwardingTerms['AwardingCriteria']); $i++) {
- $resultEntries["awardingCriteria"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererAwardingTerms[$i], 'Description', 'string');
- $resultEntries["awardingCriteria"][$i]['description'] = $this->existNodo($tendererAwardingTerms[$i], 'WeightNumeric', 'string');
- $resultEntries["awardingCriteria"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries["awardingCriteria"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
- $resultEntries['awardingCriteria']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
-
- if (array_key_exists("TendererQualificationRequest", $TenderingTerms)) {
- $tendererQualificationRequest = $TenderingTerms['TendererQualificationRequest'];
- $resultEntries['tenderingTerm']['description'] = $this->existNodo($tendererQualificationRequest, 'Description', 'string');
- $resultEntries['tenderingTerm']['personalSituation'] = $this->existNodo($tendererQualificationRequest, 'PersonalSituation', 'string');
- for ($i = 0; $i < count($tendererQualificationRequest); $i++) {
- if (isset($tendererQualificationRequest[$i]->TechnicalEvaluationCriteria->EvaluationCriteriaTypeCode)) {
- $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], 'EvaluationCriteriaTypeCode', 'string');
- $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], "EvaluationCriteriaTypeCode", "sting", 'listURI');
- $resultEntries["TendererQualificationRequest"][$i]['description'] = $this->existNodo($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], 'Description', 'string');
- $resultEntries["TendererQualificationRequest"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries["TendererQualificationRequest"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
- $resultEntries['TendererQualificationRequest']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
-
- }
-
- if (array_key_exists("FinancialEvaluationCriteria", $TenderingTerms['TendererQualificationRequest'])) {
- $financialEvaluationCriteria = $TenderingTerms['TendererQualificationRequest']['FinancialEvaluationCriteria'];
- for ($i = 0; $i < count($financialEvaluationCriteria); $i++) {
- $resultEntries["FinancialEvaluationCriteria"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($financialEvaluationCriteria[$i], 'EvaluationCriteriaTypeCode', 'string');
- $resultEntries["FinancialEvaluationCriteria"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($financialEvaluationCriteria[$i], "EvaluationCriteriaTypeCode", "string", 'listURI');
- $resultEntries["FinancialEvaluationCriteria"][$i]['description'] = $this->existNodo($financialEvaluationCriteria[$i], 'Description', 'string');
- $resultEntries["FinancialEvaluationCriteria"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries["FinancialEvaluationCriteria"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
- $resultEntries['FinancialEvaluationCriteria']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
-
- if (array_key_exists("SpecificTendererRequirement", $TenderingTerms['TendererQualificationRequest'])) {
- $specificTendererRequirement = $TenderingTerms['TendererQualificationRequest']['SpecificTendererRequirement'];
- for ($i = 0; $i < count($specificTendererRequirement); $i++) {
-
- $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($specificTendererRequirement[$i]['SpecificTendererRequirement'], 'RequirementTypeCode', 'string');
- $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($specificTendererRequirement[$i]['SpecificTendererRequirement'], "RequirementTypeCode", "string", 'listURI');
- $resultEntries["SpecificTendererRequirement"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries["SpecificTendererRequirement"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
- $resultEntries['SpecificTendererRequirement']['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- }
- }
-
- $resultEntries["tenderingTerm"]['language'] = $this->existNodo($TenderingTerms['Language'], 'ID', 'string');
- }
-
- return $resultEntries;
- }
-
- private function nodoTenderingProcess($xml)
- {
- $resultEntries = array();
- if (array_key_exists("TenderingProcess", $xml['ContractFolderStatus'])) {
- $tenderingProcess = $xml['ContractFolderStatus']['TenderingProcess'];
-
- //TenderingProcess
- $resultEntries['procedureCode'] = $this->existNodo($tenderingProcess, 'ProcedureCode', 'string');
- $resultEntries['procedureCode_attr'] = $this->existAttribute($tenderingProcess, "ProcedureCode", "string", 'listURI');
-
- $resultEntries['urgencyCode'] = $this->existNodo($tenderingProcess, 'UrgencyCode', 'string');
- $resultEntries['urgencyCode_attr'] = $this->existAttribute($tenderingProcess, "UrgencyCode", "string", 'listURI');
-
- $resultEntries['contractingSystemCode'] = $this->existNodo($tenderingProcess, 'ContractingSystemCode', 'string');
- $resultEntries['contractingSystemCode_attr'] = $this->existAttribute($tenderingProcess, "ContractingSystemCode", "string", 'listURI');
-
- $resultEntries['partPresentationCode'] = $this->existNodo($tenderingProcess, 'PartPresentationCode', 'string');
- $resultEntries['partPresentationCode_attr'] = $this->existAttribute($tenderingProcess, "PartPresentationCode", "string", 'listURI');
-
- $resultEntries['submissionMethodCode'] = $this->existNodo($tenderingProcess, 'SubmissionMethodCode', 'string');
- $resultEntries['submissionMethodCode_attr'] = $this->existAttribute($tenderingProcess, "SubmissionMethodCode", "string", 'listURI');
-
- $resultEntries['maximumLotPresentationQuantity'] = $this->existNodo($tenderingProcess, 'MaximumLotPresentationQuantity', 'string');
- $resultEntries['maximumTendererAwardedLotsQuantity'] = $this->existNodo($tenderingProcess, 'MaximumTendererAwardedLotsQuantity', 'string');
- $resultEntries['deadLineEndDate'] = $this->existNodo($tenderingProcess['TenderSubmissionDeadlinePeriod'], 'EndDate', 'string');
- $resultEntries['deadLineEndTime'] = $this->existNodo($tenderingProcess['TenderSubmissionDeadlinePeriod'], 'EndTime', 'string');
- $resultEntries['deadLineDescription'] = $this->existNodo($tenderingProcess['TenderSubmissionDeadlinePeriod'], 'Description', 'string');
- $resultEntries['auctionTerms'] = $this->existNodo($tenderingProcess['AuctionTerms'], 'AuctionConstraintIndicator', 'string');
- $resultEntries['LotsCombinationContractingAuthorityRights'] = $this->existNodo($tenderingProcess, 'LotsCombinationContractingAuthorityRights', 'string');
- $resultEntries['documentAvailablePeriod_EndDate'] = $this->existNodo($tenderingProcess['DocumentAvailabilityPeriod'], 'EndDate', 'string');
- $resultEntries['documentAvailablePeriod_EndTime'] = $this->existNodo($tenderingProcess['DocumentAvailabilityPeriod'], 'EndTime', 'string');
- $resultEntries['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['id_compuesta'] = $this->idLicitacion . "_08";
- $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- return $resultEntries;
- }
-
- private function nodoLegalDoc($xml)
- {
- $resultEntries = array();
- if (array_key_exists("LegalDocumentReference", $xml['ContractFolderStatus'])) {
- $legalDocumentReference = $xml['ContractFolderStatus']['LegalDocumentReference'];
-
- $resultEntries['idDoc'] = $this->existNodo($legalDocumentReference, 'ID', 'string');
- $resultEntries['attachment'] = $this->existNodo($legalDocumentReference['Attachment']['ExternalReference'], 'URI', 'string');
- $resultEntries['documentHash'] = $this->existNodo($legalDocumentReference['Attachment']['ExternalReference'], 'DocumentHash', 'string');
- $resultEntries['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['id_compuesta'] = $this->idLicitacion . "_09";
- $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
-
- return $resultEntries;
- }
- //$resultFinal = $this->checkArrayValuesEmpty($resultEntries);
- //return $this->idLicitacion;
- }
-
- private function nodoTechnicalDocumentReference($xml)
- {
- $resultEntries = array();
- if (array_key_exists("TechnicalDocumentReference", $xml['ContractFolderStatus'])) {
- $technicalDocumentReference = $xml['ContractFolderStatus']['TechnicalDocumentReference'];
- $resultEntries['idDoc'] = $this->existNodo($technicalDocumentReference, 'ID', 'string');
- $resultEntries['attachment'] = $this->existNodo($technicalDocumentReference['Attachment']['ExternalReference'], 'URI', 'string');
- $resultEntries['documentHash'] = $this->existNodo($technicalDocumentReference['Attachment']['ExternalReference'], 'DocumentHash', 'string');
- $resultEntries['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries['id_compuesta'] = $this->idLicitacion . "_10";
- $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
-
- return $resultEntries;
- }
- //$resultFinal = $this->checkArrayValuesEmpty($resultEntries);
- //return $this->idLicitacion;
- }
-
- private function nodoAdditionalDocumentReference($xml)
- {
- $resultEntries = array();
- if (array_key_exists("AdditionalDocumentReference", $xml['ContractFolderStatus'])) {
- $additionalDocumentReference = $xml['ContractFolderStatus']['AdditionalDocumentReference'];
- if (array_key_first($additionalDocumentReference) !== 0) {
- $additionalDocumentReference = array(0 => $additionalDocumentReference);
- }
- for ($i = 0; $i < count($additionalDocumentReference); $i++) {
- $resultEntries[$i]['idDoc'] = $this->existNodo($additionalDocumentReference[$i], 'ID', 'string');
- $resultEntries[$i]['attachment'] = $this->existNodo($additionalDocumentReference[$i]['Attachment']['ExternalReference'], 'URI', 'string');
- $resultEntries[$i]['documentHash'] = $this->existNodo($additionalDocumentReference[$i]['Attachment']['ExternalReference'], 'DocumentHash', 'string');
- $resultEntries[$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['id_compuesta'] = $this->idLicitacion . "_11_" . $i;
- $resultEntries[$i]['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- return $resultEntries;
- }
- //$resultFinal = $this->checkArrayValuesEmpty($resultEntries);
- //return $this->idLicitacion;
- }
-
- private function nodoGeneralDocuments($xml)
- {
- $resultEntries = array();
- if (array_key_exists("GeneralDocument", $xml['ContractFolderStatus'])) {
- $generalDocument = $xml['ContractFolderStatus']['GeneralDocument'];
-
- if (array_key_first($generalDocument) !== 0) {
- $generalDocument = array(0 => $generalDocument);
- }
- for ($i = 0; $i < count($generalDocument); $i++) {
- $resultEntries[$i]['idDoc'] = $this->existNodo($generalDocument[$i]['GeneralDocumentDocumentReference'], 'ID', 'string');
- $resultEntries[$i]['attachment'] = $this->existNodo($generalDocument[$i]['GeneralDocumentDocumentReference']['Attachment']['ExternalReference'], 'URI', 'string');
- $resultEntries[$i]['fileName'] = $this->existNodo($generalDocument[$i]['GeneralDocumentDocumentReference']['Attachment']['ExternalReference'], 'FileName', 'string');
- $resultEntries[$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['id_compuesta'] = $this->idLicitacion . "_13_" . $i;
- $resultEntries[$i]['fecha_creacion_log'] = $this->fechaInicioParser;
- }
- return $resultEntries;
- }
- //return $this->idLicitacion;
- }
-
- /*private function nodoValidNoticeInfo($xml)
- {
- $resultEntries = array();
- if (array_key_exists("ValidNoticeInfo", $xml['ContractFolderStatus'])) {
- $validNoticeInfo = $xml['ContractFolderStatus']['ValidNoticeInfo'];
- $firstKey = array_key_first($validNoticeInfo);
- if ($firstKey !== 0) {
- $validNoticeInfo = array(0 => $validNoticeInfo);
- }
- for ($i = 0; $i < count($validNoticeInfo); $i++) {
- $resultEntries[$i]['noticeTypeCode'] = $this->existNodo($validNoticeInfo[$i], 'NoticeTypeCode', 'string');
- $resultEntries[$i]['publicationMediaName'] = $this->existNodo($validNoticeInfo[$i]['AdditionalPublicationStatus'], 'PublicationMediaName', 'string');
- $resultEntries[$i]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['id_compuesta'] = $this->idLicitacion . "_12_" . $i;
-
- if (array_key_exists("AdditionalPublicationStatus", $xml['ContractFolderStatus']['ValidNoticeInfo'][$i])) {
- $additionalPublicationDocument = $xml['ContractFolderStatus']['ValidNoticeInfo'][$i]['AdditionalPublicationStatus'];
- //echo ($this->idLicitacion . "</br>");
- if (!is_countable($additionalPublicationDocument['AdditionalPublicationDocumentReference'])) {
- echo "idlici" . $this->idLicitacion;
- }
-
- if ($firstKey !== 0) {
- $additionalPublicationDocument['AdditionalPublicationDocumentReference'] = array(0 => $additionalPublicationDocument['AdditionalPublicationDocumentReference']);
- }
- for ($j = 0; $j < count($additionalPublicationDocument['AdditionalPublicationDocumentReference']); $j++) {
-
- $firstKey = array_key_first($additionalPublicationDocument['AdditionalPublicationDocumentReference']);
-
- $resultEntries[$i]['fechas'][$j]['fechas'] = $this->existNodo($additionalPublicationDocument['AdditionalPublicationDocumentReference'][$j], 'IssueDate', 'string');
- $resultEntries[$i]['fechas'][$j]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['fechas'][$j]['id_compuesta'] = $this->idLicitacion . "_12_" . $i . "_" . $j;
- if ($additionalPublicationDocument['AdditionalPublicationDocumentReference'][$j]['DocumentTypeCode']) {
- $resultEntries[$i]['documento'][$j]['documento'] = $this->existNodo($additionalPublicationDocument['AdditionalPublicationDocumentReference'][$j]['Attachment']['ExternalReference'], 'URI', 'string');
- $resultEntries[$i]['documento'][$j]['filename'] = $this->existNodo($additionalPublicationDocument['AdditionalPublicationDocumentReference'][$j]['Attachment']['ExternalReference'], 'FileName', 'string');
- $resultEntries[$i]['documento'][$j]['id_ajena_licitacion'] = $this->idLicitacion;
- $resultEntries[$i]['documento'][$j]['id_compuesta'] = $this->idLicitacion . "_12_" . $i . "_" . $j;
- }
- }
- }
- }
- }
-
- //$resultFinal = $this->checkArrayValuesEmpty($resultEntries);
- return $resultEntries;
- }*/
-
- private function existNodo($nodo, $nodoHijo, $tipo)
- {
-
- if (isset($nodo) && @count($nodo) > 0) {
- return $this->switchTipo($tipo, $nodo[$nodoHijo]);
- } else {
- return "";
- }
- }
-
- private function existAttribute($nodo, $nodoHijo, $tipo, $nombreAttributo)
- {
- $nodoFinal = $nodo->{$nodoHijo};
- if (isset($nodoFinal) && !empty($nodoFinal)) {
- //if (@count($nodo->{$nodoHijo}) > 0) {
- return $this->switchTipoAttribute($tipo, $nodo->{$nodoHijo}, $nombreAttributo);
- //}
- } else {
- return "";
- }
- }
-
- private function switchTipo($tipo, $nodo)
- {
- switch ($tipo) {
- case 'string':
- return (string) $nodo;
- break;
- case 'int':
- return (int) $nodo;
- break;
- case 'array':
- return (array) $nodo;
- break;
- }
- }
-
- private function switchTipoAttribute($tipo, $nodo, $attributo)
- {
- switch ($tipo) {
- case 'string':
- return (string) $nodo->attributes()[$attributo];
- break;
- }
- }
- }
-
- /* End of file ParserFile.php */
- /* Location: ./application/libraries/ParserFile.php */
|