$field_simple_odd =& $workbook->addformat(array(bold => FIELD_BOLD, size => FIELD_FONT_SIZE, font => FIELD_FONT_FAMILY, bottom => FIELD_BOTTOM_BORDER, bottom_color => FIELD_BOTTOM_BORDER_COLOR, align => FIELD_ALIGN, text_wrap => FIELD_TEXT_WRAP, num_format => FIELD_NUM_FORMAT, bg_color => FIELD_BG_COLOR)); if (Registry::get('addons.price_list.group_by_category') == "Y") { // Display products according to the categories names. fn_echo(fn_get_lang_var('generating_xls') . '<br />'); // Group the products by categories // Prepare XLS data $categories = fn_get_plain_categories_tree(0, false); foreach ($categories as $category) { if ($category['product_count'] == 0) { continue; } fn_echo('<br />' . $category['category']); $counter->Clear(); // Write category name $worksheet->set_row($row - 1, CATEGORY_NAME_HEIGHT); $worksheet->write($col . $row, array_pad(array(fn_price_list_build_category_name($category['id_path'])), count($selected_fields), ''), $category_heading); $worksheet->set_row($row, FIELD_HEADING_HEIGHT); $row++; foreach ($selected_fields as $field => $active) { if ($field == 'image') { continue; // FIX ME! Some problems with the compability of the Excel format } $worksheet->write($col . $row, $price_schema['fields'][$field]['title'], $field_heading); if (isset($width[$col])) { if ($width[$col] < strlen($price_schema['fields'][$field]['title'])) { $width[$col] = strlen($price_schema['fields'][$field]['title']); } } else { $width[$col] = strlen($price_schema['fields'][$field]['title']) * FIELD_MWIDTH; }
} else { fn_echo(__('generating_pdf') . '<br />'); // Group the products by categories // Prepare PDF data $categories = fn_get_plain_categories_tree(0, false); foreach ($categories as $category) { if ($category['product_count'] == 0) { continue; } fn_echo('<br />' . $category['category']); $counter->clear(); // Write category name $tbl = ''; $tbl .= '<table border="0" cellpadding="' . TABLE_CELLPADDING . '" cellspacing="' . TABLE_CELLSPACING . '" width="100%">'; $tbl .= '<tr>'; $tbl .= '<td align="left" style="background-color: ' . CATEGORY_HEADER_BG_COLOR . '; font-size: ' . CATEGORY_HEADER_FONT_SIZE . '; color: ' . CATEGORY_HEADER_FONT_COLOR . '" colspan="' . count(Registry::get('addons.price_list.price_list_fields')) . '"><strong>' . fn_price_list_build_category_name($category['id_path']) . '</strong></td>'; $tbl .= '</tr>'; $tbl .= '</table>'; // Write product head fields $tbl .= '<table border="0" cellpadding="' . TABLE_CELLPADDING . '" cellspacing="' . TABLE_CELLSPACING . '" width="100%">'; $tbl .= '<tr>'; foreach (Registry::get('addons.price_list.price_list_fields') as $field_name => $active) { $tbl .= '<td style="font-size: ' . FIELDS_HEADER_FONT_SIZE . ';" width="' . $price_schema['fields'][$field_name]['min_width'] . '%"><strong>' . $price_schema['fields'][$field_name]['title'] . '</strong></td>'; } $tbl .= '</tr>'; $tbl .= '</table>'; Pdf::batchAdd($tbl); $page = 1; $total = ITEMS_PER_PAGE; $fill = true; $params = $_REQUEST;
// Prepare XLS data $categories = fn_get_plain_categories_tree(0, false); $end_col = 'A'; for ($i = 1; $i < count($selected_fields); $i++) { $end_col++; } foreach ($categories as $category) { if ($category['product_count'] == 0) { continue; } fn_echo('<br />' . $category['category']); $counter->clear(); // Write category name $col = 'A'; $worksheet->getRowDimension($row)->setRowHeight(CATEGORY_NAME_HEIGHT); $worksheet->setCellValue($col . $row, fn_price_list_build_category_name($category['id_path'])); $worksheet->mergeCells($col . $row . ':' . $end_col . $row); $worksheet->getStyle($col . $row)->applyFromArray($styles['category_heading']); $row++; // output category products $params = $_REQUEST; $params['sort_by'] = $price_schema['fields'][Registry::get('addons.price_list.price_list_sorting')]['sort_by']; $params['page'] = $page; $params['skip_view'] = 'Y'; $params['cid'] = $category['category_id']; $params['subcats'] = 'N'; fn_price_list_print_products($params, $worksheet, $counter, $row, $width, $selected_fields, $price_schema, $styles); } } else { $params = $_REQUEST; $params['sort_by'] = $price_schema['fields'][Registry::get('addons.price_list.price_list_sorting')]['sort_by'];
protected function printCategoryRow($category) { $this->writer->writeSheetRow($this->sheet, array(fn_price_list_build_category_name($category['id_path']))); }
protected function printCategoryRow($category) { // Write category name $tbl = '<tr>'; $tbl .= '<th class="category" colspan="' . count($this->selected_fields) . '">' . fn_price_list_build_category_name($category['id_path']) . '</th>'; $tbl .= '</tr>'; // Write product head fields $tbl .= '<tr>'; foreach ($this->selected_fields as $field_name => $active) { $tbl .= '<th width="' . $this->price_schema['fields'][$field_name]['min_width'] . '%">' . $this->price_schema['fields'][$field_name]['title'] . '</th>'; } $tbl .= '</tr>'; $this->tbl .= $tbl; }