static function generateTable($table_definition, $is_main = true) { $html = ''; $border = ""; // $border = 'border: 1px solid black !important; '; $header_title = isset($table_definition["header"]["title"]) ? $table_definition["header"]["title"] : null; $header_columns = isset($table_definition["header"]["columns"]) ? $table_definition["header"]["columns"] : null; $table_body = isset($table_definition["body"]) ? $table_definition["body"] : null; $table_rows = isset($table_definition["body"]["rows"]) ? $table_definition["body"]["rows"] : null; //Title if ($header_title) { $html .= $header_title; } if ($is_main) { $html .= "<table class='dataTable outerTable' style='border: 1px solid #CACACA;'>"; } else { $html .= "<table class='sub-table dataTable'>"; } //Header row if ($header_columns) { $html .= "<thead>"; $html .= "<tr>"; // $html .= "<tr style='border: 1px solid black !important;'>"; $html .= WidgetUtil::generateHeaderColumns($header_columns); $html .= "</tr>"; $html .= "</thead>"; } //Table body if (isset($table_body)) { $html .= "<tbody>"; //Table rows if (isset($table_rows)) { $alternating_row_count = 0; $inner_tbl_count = 0; $outer_table_count = 0; for ($row_index = 0; $row_index < count($table_rows); $row_index++) { if (isset($table_rows[$row_index]['columns'])) { if ($alternating_row_count % 2 == 0) { $class = "even outer"; } else { $class = "odd outer"; } $alternating_row_count++; WidgetUtil::populateMaxColumnLength($table_rows); // $html .= "<tr class='".$class."' style='border: 1px solid black !important;'>"; $html .= "<tr class='" . $class . "' >"; $html .= WidgetUtil::generateColumns($table_rows[$row_index]['columns']); $html .= "</tr>"; } elseif (isset($table_rows[$row_index]['child_tables'])) { $display_main = $outer_table_count > 0 ? "display: none;" : ""; $outer_table_count++; $col_span = count($table_rows[$row_index - 1]['columns']); $html .= "<tr class='showHide' style='" . $display_main . "'>"; $html .= "<td colspan='" . $col_span . "'>"; $html .= "<div>"; for ($tbl_index = 0; $tbl_index < count($table_rows[$row_index]['child_tables']); $tbl_index++) { // $html .= "<tr class='showHide' style='border: 1px solid black !important;'>"; $html .= WidgetUtil::generateTable($table_rows[$row_index]['child_tables'][$tbl_index]); } $html .= "</div>"; $html .= "</td>"; $html .= "</tr>"; } elseif (isset($table_rows[$row_index]['embed_node'])) { $display_main = $outer_table_count > 0 ? "display: none;" : ""; $outer_table_count++; $col_span = count($table_rows[$row_index - 1]['columns']); $html .= "<tr class='showHide' style='" . $display_main . "'>"; $html .= "<td colspan='" . $col_span . "'>"; $html .= "<div>"; for ($tbl_index = 0; $tbl_index < count($table_rows[$row_index]['embed_node']); $tbl_index++) { // $html .= "<tr class='showHide' style='border: 1px solid black !important;'>"; $html .= $table_rows[$row_index]['embed_node'][$tbl_index]; } $html .= "</div>"; $html .= "</td>"; $html .= "</tr>"; } elseif (isset($table_rows[$row_index]['inner_table'])) { $display = $inner_tbl_count > 0 ? "display: none;" : ""; $inner_tbl_count++; $col_span = count($table_rows[$row_index - 1]['columns']); // $html .= "<tr class='showHide' style='".$display." border: 1px solid black !important;'>"; $html .= "<tr class='showHide' style='" . $display . "'>"; $html .= "<td colspan='" . $col_span . "'>"; $html .= "<div class='scroll'>"; $html .= WidgetUtil::generateTable($table_rows[$row_index]['inner_table'], false); $html .= "</div>"; $html .= "</td>"; $html .= "</tr>"; } } } $html .= "</tbody>"; } else { $html .= "<tbody>"; $html .= "<tr class='odd'>"; $html .= "<td class='dataTables_empty' valign='top' colspan='" . count($header_columns) . "'>"; $html .= "<div id='no-records-datatable' class='clearfix'>"; $html .= "<span>No Matching Records Found</span>"; $html .= "</div>"; $html .= "</td>"; $html .= "</tr>"; $html .= "</tbody>"; } $html .= "</table>"; return $html; }