function renderRecordsError($imp_session) { $is_missed = false; $tabs = $imp_session['validation']['error']; if (count($tabs) > 1) { $k = 0; print '<div id="tabs_records"><ul>'; foreach ($tabs as $rec_tab) { $colname = @$imp_session['columns'][substr($rec_tab['field_checked'], 6)]; print '<li><a href="#rec__' . $k . '" style="color:red">' . $colname . '<br><span style="font-size:0.7em">' . @$rec_tab['short_message'] . '</span></a></li>'; $k++; } print '</ul>'; $k++; } $mapped_fields = $imp_session['validation']['mapped_fields']; $k = 0; foreach ($tabs as $rec_tab) { print '<div id="rec__' . $k . '">'; $k++; $cnt = $rec_tab['count_error']; $records = $rec_tab['recs_error']; if ($cnt > count($records)) { print "<div class='error'><b>Only the first " . count($records) . " of " . $cnt . " rows are shown</b></div>"; } $checked_field = $rec_tab['field_checked']; if (in_array(intval(substr($checked_field, 6)), $imp_session['multivals'])) { $ismultivalue = true; //highlight errors individually } else { $ismultivalue = false; } print "<div><span class='error'>Values in red are invalid: "; print "</span> " . $rec_tab['err_message'] . "<br/><br/></div>"; $is_missed = strpos($rec_tab['err_message'], 'a value must be supplied') > 0; if (count($records) > 25) { print '<br/><input type="button" value="Close popup" onClick="showRecords(\'mapping\');"><br/><br/>'; } //all this code only for small asterics //$recStruct = getAllRectypeStructures(true); //$recStruct = $recStruct['typedefs'][] $recordType = @$_REQUEST['sa_rectype']; if ($recordType) { $recStruc = getRectypeStructures(array($recordType)); $idx_reqtype = $recStruc['dtFieldNamesToIndex']['rst_RequirementType']; $recStruc = $recStruc[$recordType]['dtFields']; } else { $recStruc = null; } $detDefs = getAllDetailTypeStructures(true); $detLookup = $detDefs['lookups']; $detDefs = $detDefs['typedefs']; $idx_dt_type = $detDefs['fieldNamesToIndex']['dty_Type']; //find distinct terms values $is_enum = false; if (!$is_missed) { $err_col = 0; $m = 1; foreach ($mapped_fields as $field_name => $dt_id) { if ($field_name == $checked_field && @$detDefs[$dt_id]) { $err_col = $m; $dttype = $detDefs[$dt_id]['commonFields'][$idx_dt_type]; $is_enum = $dttype == 'enum' || $dttype == 'relationtype'; break; } $m++; } if ($is_enum) { $distinct_value = array(); if ($records && is_array($records)) { foreach ($records as $row) { $value = $row[$err_col]; if (!in_array($value, $distinct_value)) { array_push($distinct_value, $value); } } } if (count($distinct_value) > 0) { //print distinct term values print '<div style="display:none;padding-bottom:10px;" id="distinct_terms_' . $k . '"><br>'; foreach ($distinct_value as $value) { print '<div style="margin-left:30px;">' . $value . ' </div>'; } print '</div>'; print '<div><a href="#" onclick="{top.HEURIST.util.popupTinyElement(window, document.getElementById(\'distinct_terms_' . $k . '\'),{\'no-close\':false, \'no-titlebar\':false });}">Get list of unrecognised terms</a>' . ' (can be imported into terms tree)<br/> </div>'; } } } //end find distict terms values print '<table class="tbmain" cellspacing="0" cellpadding="2" width="100%"><thead><tr>'; // class="tbmain" print '<th width="20px">Line #</th>'; //HEADER - only error field $m = 1; $err_col = 0; foreach ($mapped_fields as $field_name => $dt_id) { if ($field_name == $checked_field) { $colname = @$imp_session['columns'][substr($field_name, 6)]; if (@$recStruc[$dt_id][$idx_reqtype] == "required") { $colname = $colname . "*"; } if ($is_enum) { $showlink = ' <a href="#" onclick="{showTermListPreview(' . $dt_id . ')}">show list of terms</a>'; } else { $showlink = ''; } $colname = "<font color='red'>" . $colname . "</font>" . '<br><font style="font-size:10px;font-weight:normal">' . (is_numeric($dt_id) ? $detLookup[$detDefs[$dt_id]['commonFields'][$idx_dt_type]] : $dt_id) . $showlink . "</font>"; if ($is_enum) { $colname = $colname . "<div id='termspreview" . $dt_id . "'></div>"; //container for } print "<th style='min-width:90px'>" . $colname . "</th>"; $err_col = $m; break; } $m++; } //raw row print '<th>Record content</th>'; print "</tr></thead>"; $import_table = $imp_session['import_table']; //BODY if ($records && is_array($records)) { foreach ($records as $row) { print "<tr>"; if (is_array($row)) { print "<td class='truncate'>" . $row[0] . "</td>"; if ($is_missed) { print "<td style='color:red'><missing></td>"; } else { if ($ismultivalue) { print "<td class='truncate'>" . @$row[$err_col] . "</td>"; } else { print "<td class='truncate' style='color:red'>" . @$row[$err_col] . "</td>"; } } // print raw content of import data $res = get_import_value($row[0], $import_table); if (is_array($res)) { $s = htmlspecialchars(implode(", ", $res)); print "<td title='" . $s . "'>" . $s . "</td>"; } else { print "<td> </td>"; } } print "</tr>"; } } print "</table>"; print "</div>"; } //tabs if (count($tabs) > 1) { print '</div>'; } print '<br /><br /><input type="button" value="Back to previous screen" onClick="showRecords(\'mapping\');">'; }
$response = array("status" => 'ok', "data" => $res); } else { $response = array("status" => 'error', "message" => $res); } } } //error_log(print_r($response,true)); header('Content-type: application/json;charset=UTF-8'); print json_encode($response); exit; } //end case for new UI $post_max_size = get_config_bytes(ini_get('post_max_size')); $file_max_size = get_config_bytes(ini_get('upload_max_filesize')); if (intval(@$_REQUEST["recid"]) > 0 && @$_REQUEST["table"]) { $res = get_import_value($_REQUEST["recid"], $_REQUEST["table"]); header('Content-type: text/javascript'); print json_encode($res); exit; } else { if (@$_REQUEST["clearsession"]) { clear_import_session($_REQUEST["clearsession"]); exit; } else { if (@$_REQUEST["getsession"]) { //download session download_import_session($_REQUEST["getsession"], @$_REQUEST["idfield"], @$_REQUEST["mode"]); exit; } else { if (@$_REQUEST["deleteunmatched"]) { //download session