<?php |
<?php |
|
|
include_once ("../lib/common.inc.php"); |
include_once ("../lib/common.inc.php"); |
function processFile($fpath, $tablename) |
|
{ |
$contractNoticeFields = array( |
global $conn; |
"importFile", |
$row = 1; |
"agencyName", |
$handle = fopen($fpath, "r"); |
"parentCN", |
//"t" mode string translates windows line breaks to unix |
"CNID", |
$datamapping0711 = array( |
"publishDate", |
"Agency" => "agencyName", |
"amendDate", |
"Parent CN ID" => "parentCN", |
"contractStart", |
"CN ID" => "CNID", |
"contractEnd", |
"Publish Date" => "publishDate", |
"value", |
"Amendment Date" => "amendDate", |
"description", |
"Status" => "", |
"agencyID", |
"StartDate" => "contractStart", |
"category", |
"EndDate" => "contractEnd", |
"procurementMethod", |
"Value" => "value", |
"atmID", |
"Description" => "description", |
"SONID", |
"Agency Ref Id" => "agencyID", |
"confidentialityContract", |
"Category" => "category", |
"confidentialityContractReason", |
"Procurement Method" => "procurementMethod", |
"confidentialityOutputs", |
"ATM ID" => "atmID", |
"confidentialityOutputsReason", |
"SON ID" => "SONID", |
"consultancy", |
"Confidentiality - Contract" => "confidentialityContract", |
"consultancyReason", |
"Confidentiality - Contract Reason(s)" => "confidentialityContractReason", |
"amendmentReason", |
"Confidentiality - Outputs" => "confidentialityOutputs", |
"supplierName", |
"Confidentiality - Outputs Reason(s)" => "confidentialityOutputsReason", |
"supplierAddress", |
"Consultancy" => "consultancy", |
"supplierCity", |
"Consultancy Reason(s)" => "consultancyReason", |
"supplierPostcode", |
"Amendment Reason" => "amendmentReason", |
"supplierCountry", |
"Supplier Name" => "supplierName", |
"supplierABNExempt", |
"Supplier Address" => "supplierAddress", |
"supplierABN", |
"Supplier City" => "supplierCity", |
"contactBranch", |
"Supplier Postcode" => "supplierPostcode", |
"contactDivision", |
"Supplier Country" => "supplierCountry", |
"contactPostcode" |
"Supplier ABNExempt" => "supplierABNExempt", |
); |
"Supplier ABN" => "supplierABN", |
$agencyFields = array( |
"Agency Branch" => "contactBranch", |
"agencyName" |
"Agency Divison" => "contactDivision", |
); |
"Agency Postcode" => "contactPostcode", |
$supplierFields = array( |
"" => "" |
"supplierName", |
); |
"supplierAddress", |
$headers; |
"supplierCity", |
$contractNoticeFields = array( |
"supplierPostcode", |
"importFile", |
"supplierCountry", |
"agencyName", |
"supplierABNExempt", |
"parentCN", |
"supplierABN" |
"CNID", |
); |
"publishDate", |
$contractNoticeInsertQ = 'INSERT INTO contractnotice ("' . implode('" , "', $contractNoticeFields) . '") VALUES ( '; |
"amendDate", |
foreach ($contractNoticeFields as $key => $f) { |
"contractStart", |
$contractNoticeInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
"contractEnd", |
} |
"value", |
$contractNoticeInsertQ.= ");"; |
"description", |
$contractNoticeInsertQ = $conn->prepare($contractNoticeInsertQ); |
"agencyID", |
|
"category", |
$supplierInsertQ = 'INSERT INTO supplierdetails ("' . implode('" , "', $supplierFields) . '") VALUES ( '; |
"procurementMethod", |
foreach ($supplierFields as $key => $f) { |
"atmID", |
$supplierInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
"SONID", |
} |
"confidentialityContract", |
$supplierInsertQ.= ");"; |
"confidentialityContractReason", |
$supplierInsertQ = $conn->prepare($supplierInsertQ); |
"confidentialityOutputs", |
|
"confidentialityOutputsReason", |
$agencyInsertQ = 'INSERT INTO agency_nametoabn ("' . implode('" , "', $agencyFields) . '") VALUES ( '; |
"consultancy", |
foreach ($agencyFields as $key => $f) { |
"consultancyReason", |
$agencyInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
"amendmentReason", |
} |
"supplierName", |
$agencyInsertQ.= ");"; |
"supplierAddress", |
$agencyInsertQ = $conn->prepare($agencyInsertQ); |
"supplierCity", |
|
"supplierPostcode", |
function processFile($fpath, $tablename) { |
"supplierCountry", |
global $conn, $contractNoticeQ, $supplierInsertQ, $agencyInsertQ; |
"supplierABNExempt", |
$row = 1; |
"supplierABN", |
$handle = fopen($fpath, "r"); |
"contactBranch", |
//"t" mode string translates windows line breaks to unix |
"contactDivision", |
$datamapping0711 = array( |
"contactPostcode" |
"Agency" => "agencyName", |
); |
"Parent CN ID" => "parentCN", |
$agencyFields = array( |
"CN ID" => "CNID", |
"agencyName" |
"Publish Date" => "publishDate", |
); |
"Amendment Date" => "amendDate", |
$supplierFields = array( |
"Status" => "", |
"supplierName", |
"StartDate" => "contractStart", |
"supplierAddress", |
"EndDate" => "contractEnd", |
"supplierCity", |
"Value" => "value", |
"supplierPostcode", |
"Description" => "description", |
"supplierCountry", |
"Agency Ref Id" => "agencyID", |
"supplierABNExempt", |
"Category" => "category", |
"supplierABN" |
"Procurement Method" => "procurementMethod", |
); |
"ATM ID" => "atmID", |
if ($tablename == "contractnotice") { |
"SON ID" => "SONID", |
$contractNoticeInsertQ = 'INSERT INTO contractnotice ("' . implode('" , "', $contractNoticeFields) . '") VALUES ( '; |
"Confidentiality - Contract" => "confidentialityContract", |
foreach ($contractNoticeFields as $key => $f) { |
"Confidentiality - Contract Reason(s)" => "confidentialityContractReason", |
$contractNoticeInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
"Confidentiality - Outputs" => "confidentialityOutputs", |
} |
"Confidentiality - Outputs Reason(s)" => "confidentialityOutputsReason", |
$contractNoticeInsertQ.= ");"; |
"Consultancy" => "consultancy", |
$contractNoticeInsertQ = $conn->prepare($contractNoticeInsertQ); |
"Consultancy Reason(s)" => "consultancyReason", |
} |
"Amendment Reason" => "amendmentReason", |
else if ($tablename == "supplierdetails") { |
"Supplier Name" => "supplierName", |
$supplierInsertQ = 'INSERT INTO supplierdetails ("' . implode('" , "', $supplierFields) . '") VALUES ( '; |
"Supplier Address" => "supplierAddress", |
foreach ($supplierFields as $key => $f) { |
"Supplier City" => "supplierCity", |
$supplierInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
"Supplier Postcode" => "supplierPostcode", |
} |
"Supplier Country" => "supplierCountry", |
$supplierInsertQ.= ");"; |
"Supplier ABNExempt" => "supplierABNExempt", |
$supplierInsertQ = $conn->prepare($supplierInsertQ); |
"Supplier ABN" => "supplierABN", |
} |
"Agency Branch" => "contactBranch", |
else if ($tablename == "agency") { |
"Agency Divison" => "contactDivision", |
$agencyInsertQ = 'INSERT INTO agency ("' . implode('" , "', $agencyFields) . '") VALUES ( '; |
"Agency Postcode" => "contactPostcode", |
foreach ($agencyFields as $key => $f) { |
"" => "" |
$agencyInsertQ.= ($key == 0 ? "" : ", ") . "?"; |
); |
} |
$headers; |
$agencyInsertQ.= ");"; |
|
$agencyInsertQ = $conn->prepare($agencyInsertQ); |
while (($data = fgetcsv($handle, 1000, "\t")) !== false) { |
} |
$num = count($data); |
while (($data = fgetcsv($handle, 1000, "\t")) !== false) { |
if ($row == 3) { |
$num = count($data); |
$headers = $data; |
if ($row == 3) { |
} elseif ($row > |