function buildUpdateArray($domain_id, $record_type, $data_array)
{
    $exclude_keys = array('record_skipped');
    $sql_records = buildSQLRecords($record_type, $domain_id);
    if (!count($sql_records) && $record_type == 'SOA') {
        return $data_array;
    }
    $raw_changes = compareValues($data_array, $sql_records);
    if (count($raw_changes)) {
        foreach ($raw_changes as $i => $data_array) {
            foreach ($exclude_keys as $key) {
                if (!array_key_exists($key, $data_array)) {
                    unset($sql_records[$i][$key]);
                }
            }
            $changes[$i] = array_merge($sql_records[$i], $raw_changes[$i]);
        }
    } else {
        return false;
    }
    unset($sql_records, $raw_changes);
    return $changes;
}
Пример #2
0
function compareArraysInternal($resultNew, $resultOld, $path)
{
    global $ID_FIELDS;
    $errors = array();
    foreach ($resultOld as $key => $oldValue) {
        $subPath = "{$path}/{$key}";
        if (!array_key_exists($key, $resultNew)) {
            $errors[$subPath] = "missing field {$key} (path={$path})";
            continue;
        }
        $newValue = $resultNew[$key];
        if (is_array($oldValue) && is_array($newValue)) {
            $errors = array_merge($errors, compareArrays($newValue, $oldValue, $subPath));
        } else {
            if (is_string($oldValue) && is_string($newValue)) {
                if (!compareValues($newValue, $oldValue)) {
                    $newValueParsed = xmlToArray($newValue);
                    $oldValueParsed = xmlToArray($oldValue);
                    if ($newValueParsed && $oldValueParsed && is_array($newValueParsed) && is_array($oldValueParsed)) {
                        $errors = array_merge($errors, compareArrays($newValueParsed, $oldValueParsed, $subPath));
                    } else {
                        $errors[$subPath] = "field {$key} has different value (path={$path} new={$newValue} old={$oldValue})";
                    }
                    if (in_array($key, $ID_FIELDS)) {
                        break;
                    }
                    // id is different, all other fields will be different as well
                }
            } else {
                if ($newValue !== $oldValue) {
                    $errors[$subPath] = "field {$key} has different type (path={$path} new={$newValue} old={$oldValue})";
                }
            }
        }
    }
    return $errors;
}
Пример #3
0
    $file_data[$provider_id . $tax_id]["CorporateContactName"] = (string) $obj_worksheet->getCellByColumnAndRow(50, $row)->getValue();
    $file_data[$provider_id . $tax_id]["CorporatePhone"] = (string) $obj_worksheet->getCellByColumnAndRow(51, $row)->getValue();
    $file_data[$provider_id . $tax_id]["CorporateFax"] = (string) $obj_worksheet->getCellByColumnAndRow(52, $row)->getValue();
    $file_data[$provider_id . $tax_id]["CorporateContactEmailAddress"] = (string) $obj_worksheet->getCellByColumnAndRow(53, $row)->getValue();
    $file_data[$provider_id . $tax_id]["CorporateWebSiteAddress"] = (string) $obj_worksheet->getCellByColumnAndRow(54, $row)->getValue();
    $file_data[$provider_id . $tax_id]["Visited"] = (string) "FALSE";
}
// print_r($file_data);
/** Load and Compare VISUALCACTUS Data **/
$sqlQuery = "Exec usp_USI_GetCurrentACSProviders";
$process = odbc_exec($connection_string, $sqlQuery) or die(odbc_errormsg() . $sqlQuery);
while ($vc_data = odbc_fetch_array($process)) {
    $index = str_replace(' ', '', $vc_data["ProviderID#"] . $vc_data["TaxId"]);
    if ($file_data[$index]) {
        // Compare all fields and mark/append all changes
        compareValues($file_data[$index], $vc_data);
        $file_data[$index]["Visited"] = "TRUE";
    } else {
        // If not, add a completely new entry (maybe check matching provider id and/or tax id)
        $vc_data["ChangeAddTerminate"] = "Add";
        $vc_data["Visited"] = "TRUE";
        array_push($file_data, $vc_data);
    }
}
/** Terminate facilities from file not found in Visual Cactus**/
foreach ($file_data as &$facility) {
    if ($facility["Visited"] == "FALSE") {
        $facility["ChangeAddTerminate"] = "Terminate";
        $facility["TerminationDate"] = date('m/d/Y');
    }
}