width = '100%'; $table->class = 'databox filters'; $table->size = []; $table->data = []; $table->data[0][0] = __('Module'); $table->data[0][1] = html_print_select_from_sql( $sqlModuleInventoryAgentView, 'module_inventory_agent_view', $module, 'javascript:this.form.submit();', __('All'), 0, true ); $table->data[0][2] = __('Date'); $table->data[0][3] = html_print_select( $utimestampSelectValues, 'utimestamp', $utimestamp, 'javascript:this.form.submit();', __('Now'), 0, true ); $table->data[0][4] = __('Search'); $table->data[0][5] = html_print_input_text('search_string', $search_string, '', 25, 0, true); $table->data[0][6] = html_print_submit_button(__('Search'), 'search_button', false, 'class="sub wand"', true); // Show filters table. echo sprintf( '
%s
', $id_agente, html_print_table($table, true) ); unset($table); $idModuleInventory = null; $rowTable = 1; $printedTables = 0; // Inventory module data. foreach ($rows as $row) { if ($utimestamp > 0) { $data_row = db_get_row_sql( "SELECT data, timestamp FROM tagente_datos_inventory WHERE utimestamp <= '".$utimestamp."' AND id_agent_module_inventory = ".$row['id_agent_module_inventory'].' ORDER BY utimestamp DESC' ); if ($data_row !== false) { $row['data'] = $data_row['data']; $row['timestamp'] = $data_row['timestamp']; } } if ($idModuleInventory != $row['id_module_inventory']) { if (isset($table) === true && $rowTable > 1) { html_print_table($table); unset($table); $rowTable = 1; $printedTables++; } $table = new StdClass(); $table->width = '98%'; $table->align = []; $table->cellpadding = 4; $table->cellspacing = 4; $table->class = 'databox filters'; $table->head = []; $table->head[0] = $row['name'].' - ('.date($config['date_format'], $row['utimestamp']).')'; if ((bool) $row['block_mode'] === true) { $table->head[0] .= '   '.html_print_image( 'images/op_inventory.menu.png', true, [ 'alt' => __('Diff view'), 'title' => __('Diff view'), 'style' => 'vertical-align: middle; opacity: 0.8;', ] ).''; } $subHeadTitles = explode(';', io_safe_output($row['data_format'])); $table->head_colspan = []; $table->head_colspan[0] = (1 + count($subHeadTitles)); $total_fields = count($subHeadTitles); $table->rowspan = []; $table->data = []; $iterator = 0; foreach ($subHeadTitles as $titleData) { $table->data[0][$iterator] = $titleData; $table->cellstyle[0][$iterator] = 'background: #373737; color: #FFF;'; $iterator++; } } if ($row['block_mode']) { $rowTable++; $table->data[$rowTable][0] = '
'.$row['data'].'
'; } else { $arrayDataRowsInventory = explode(SEPARATOR_ROW, io_safe_output($row['data'])); // SPLIT DATA IN ROWS // Remove the empty item caused by a line ending with a new line. $len = count($arrayDataRowsInventory); if (end($arrayDataRowsInventory) == '') { $len--; unset($arrayDataRowsInventory[$len]); } $iterator1 = 0; $numRowHasNameAgent = $rowTable; $rowPair = true; $iterator = 0; foreach ($arrayDataRowsInventory as $dataRowInventory) { $table->rowclass[$iterator] = ($rowPair === true) ? 'rowPair' : 'rowOdd'; $rowPair = !$rowPair; $iterator++; // Because SQL query extract all rows (row1;row2;row3...) and only I want the row has // the search string. if ($search_string && preg_match('/'.io_safe_output($search_string).'/i', io_safe_output($dataRowInventory)) == 0) { continue; } if ($rowTable > $numRowHasNameAgent) { $table->data[$rowTable][0] = ''; } $arrayDataColumnInventory = explode(SEPARATOR_COLUMN, $dataRowInventory); // SPLIT ROW IN COLUMNS. $iterator2 = 0; foreach ($arrayDataColumnInventory as $dataColumnInventory) { $table->data[$rowTable][$iterator2] = $dataColumnInventory; $iterator2++; } $iterator1++; $rowTable++; } if ($iterator1 > 5) { // PRINT COUNT TOTAL. $table->data[$rowTable][0] = ''.__('Total').': '.$iterator1; $rowTable++; } } $idModuleInventory = $row['id_module_inventory']; } if (isset($table) === true && $rowTable > 1) { html_print_table($table); $printedTables++; } if ($printedTables === 0) { echo "
".__('No data found.').'
'; }