/** * Display XHTML for comparing * * @param int $cell_id The cell to display data for * @param string $cell_data The data in the cell * @param int $work_unit_id */ function compare_display($cell_id, $cell_data, $work_unit_id) { global $db; //Select column_multi_group or column_group from work parents of this work_id $sql = "SELECT wp.parent_work_id, w.column_group_id, w.column_multi_group_id\r\n\t\tFROM work_parent as wp, work_unit as wu, work as w\r\n\t\tWHERE wp.work_id = wu.work_id\r\n\t\tAND wu.work_unit_id = '{$work_unit_id}'\r\n\t\tAND w.work_id = wp.parent_work_id"; //Loop over all columns for this column_group and display cell contents (break on any difference) $rs = $db->GetAll($sql); //create an XHTML table so we can display columnwise $tablecontents = array(); $tablecontents_match = array(); print "<table class='tclass'><tr>"; $j = 0; $maxi = 0; foreach ($rs as $r) { $wi = $r['parent_work_id']; $title = ""; if (!empty($r['column_group_id'])) { $title = "cgi" . $r['column_group_id']; } if (!empty($r['column_multi_group_id'])) { $title = "cmgi" . $r['column_multi_group_id']; } print "<th>{$title}</th>"; $sql = "SELECT c.column_id, ce.cell_id, c.description, c.name, c.code_level_id\r\n\t\t\tFROM work AS w \r\n\t\t\tJOIN `column` AS c ON (w.column_multi_group_id = c.column_multi_group_id OR c.column_group_id = w.column_group_id)\r\n\t\t\tJOIN `work_unit` as wu ON (wu.work_unit_id = '{$work_unit_id}')\r\n\t\t\tJOIN `cell` AS ce2 ON (ce2.cell_id = wu.cell_id)\r\n\t\t\tLEFT JOIN `cell` AS ce ON (ce.column_id = c.column_id AND ce.row_id = ce2.row_id)\r\n\t\t\tWHERE w.work_id = '{$wi}'\r\n\t\t\tORDER BY c.column_id ASC"; $compare = $db->GetAll($sql); $i = 0; $k = 0; foreach ($compare as $c) { $ceid = $c['cell_id']; $colid = $c['column_id']; $desc = $c['description']; list($data, $rev) = get_cell_data($ceid); $contents = ""; if (!empty($data)) { if (!empty($c['code_level_id'])) { $cli = $c['code_level_id']; //Replace with code label if a code supplied $sql = "SELECT `label`\r\n\t\t\t\t\t\tFROM `code`\r\n\t\t\t\t\t\tWHERE `code_level_id` = '{$cli}'\r\n\t\t\t\t\t\tAND `value` LIKE '{$data}'"; $crs = $db->GetRow($sql); if (!empty($crs)) { $data = $crs['label']; } } $contents = $desc . " : " . $data; $tablecontents[$i][$j] = $contents; $i++; if ($i > $maxi) { $maxi = $i; } } $tablecontents_match[$k][$j] = $contents; $k++; } $j++; } print "</tr>"; //New table display which matches columns for ($x = 0; $x < $k; $x++) { $blank = true; foreach ($tablecontents_match[$x] as $c) { if (!empty($c)) { $blank = false; break; } } if (!$blank) { print "<tr>"; for ($y = 0; $y < $j; $y++) { print "<td>"; if (isset($tablecontents_match[$x][$y])) { print $tablecontents_match[$x][$y]; } print "</td>"; } print "</tr>"; } } print "</table>"; /* //Original table display print "<table>"; for ($x = 0; $x < $maxi; $x++) { print "<tr>"; for ($y = 0; $y < $j; $y++) { print "<td>"; if (isset($tablecontents[$x][$y])) print $tablecontents[$x][$y]; print "</td>"; } print "</tr>"; } print "</table>"; */ //coding print "<div class='header' id='header'>"; display_codes($work_unit_id); print "</div>"; }
print "<form action='?' method='post' id='cleancodeform'>"; print "<p><input type='submit' name='submit' value='" . T_("Submit and continue") . "'/> <input type='submit' name='submit_end' value='" . T_("Submit and end work") . "'/> <input type='submit' name='submit_refer' value='" . T_("Refer to supervisor") . "'/> <input type='submit' name='submit_end_only' value='" . T_("End work") . "'/></p>"; print "<div id='cleancode'>"; $r = get_work_process($work_unit_id); $cell_id = $r['cell_id']; $process_id = $r['process_id']; $work_id = $r['work_id']; $cdata = get_cell_data($cell_id); $process_function = get_process_function($process_id); if ($process_function == false) { //search area print "<div id='searcharea'><label for='search'>" . T_("Search") . ":</label><input type='text' id='search' name='search'/> <span id='searchclick'>" . T_("Click here to search (or press enter)") . "</span></div>"; //coding print "<div class='header' id='header'>"; if ($code_id == false) { display_codes($work_unit_id, $operator_id, $cdata[0]); } else { display_all_codes($code_id, true, $work_unit_id); } print "</div>"; } else { if (is_callable($process_function)) { call_user_func($process_function, $cell_id, $cdata[0], $work_unit_id); } else { print "<p>" . T_("Error: Cannot execute process function:") . " {$process_function}</p>"; } } print "<input type='hidden' name='work_unit_id' value='{$work_unit_id}'/></div>"; print "</form>"; } print "</div>";