Exemple #1
0
                     foreach ($product['combinations'] as $c_id => $c_value) {
                         $product['price'] = $product['combination_prices'][$c_id];
                         $product['weight'] = $product['combination_weight'][$c_id];
                         $product['amount'] = $product['combination_amount'][$c_id];
                         $product['product_code'] = $product['combination_code'][$c_id];
                         $tbl .= fn_price_list_print_product_data($product, $selected_fields, $style, $price_schema, $c_value);
                         $fill = !$fill;
                         if ($fill) {
                             $style = 'style="background-color: ' . FIELDS_ODD_BG_COLOR . '"';
                         } else {
                             $style = '';
                         }
                         $counter->out();
                     }
                 } else {
                     $tbl .= fn_price_list_print_product_data($product, $selected_fields, $style, $price_schema);
                     $fill = !$fill;
                 }
                 $counter->out();
             }
             $tbl .= '</table>';
             $counter->out();
             Pdf::batchAdd($tbl);
         }
     }
 }
 //Close and output PDF document
 $temp_filename = fn_create_temp_file();
 $imp_filename = $temp_filename . '.pdf';
 fn_rename($temp_filename, $imp_filename);
 Pdf::batchRender($imp_filename, true);
Exemple #2
0
function fn_price_list_print_products($params, &$worksheet, &$counter, &$row, &$width, $selected_fields, $price_schema, $styles)
{
    $worksheet->getRowDimension($row)->setRowHeight(FIELD_HEADING_HEIGHT);
    $col = 'A';
    foreach ($selected_fields as $field => $active) {
        $worksheet->setCellValue($col . $row, $price_schema['fields'][$field]['title']);
        $worksheet->getStyle($col . $row)->applyFromArray($styles['field_heading']);
        if (!isset($width[$col]) || $width[$col] < strlen($price_schema['fields'][$field]['title'])) {
            $width[$col] = strlen($price_schema['fields'][$field]['title']);
        }
        $col++;
    }
    $row++;
    $total = ITEMS_PER_PAGE;
    $fill = true;
    while (ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
        list($products, $search) = fn_get_products($params, ITEMS_PER_PAGE);
        $total = $search['total_items'];
        $params['page']++;
        $_params = array('get_icon' => true, 'get_detailed' => true, 'get_options' => Registry::get('addons.price_list.include_options') == 'Y' ? true : false, 'get_discounts' => false);
        fn_gather_additional_products_data($products, $_params);
        // Write products information
        foreach ($products as $product) {
            if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
                $product_comb = fn_price_list_get_combination($product);
                if (!empty($selected_fields['image'])) {
                    $default_image = $product['main_pair'];
                    $comb_hashes = db_get_hash_single_array("SELECT oi.combination, oi.combination_hash FROM ?:product_options_inventory AS oi LEFT JOIN ?:images_links as il ON oi.combination_hash = il.object_id AND object_type = ?s WHERE oi.product_id = ?i", array('combination', 'combination_hash'), 'product_option', $product['product_id']);
                    if (!empty($comb_hashes)) {
                        $default_image = fn_get_image_pairs($product['product_id'], 'product', 'M', true, false, CART_LANGUAGE);
                    }
                }
                foreach ($product_comb['combinations'] as $c_id => $c_value) {
                    if (!empty($selected_fields['image'])) {
                        $combination = fn_get_options_combination($c_value);
                        if (!empty($comb_hashes[$combination])) {
                            $product['main_pair'] = fn_get_image_pairs($comb_hashes[$combination], 'product_option', 'M', true, true, CART_LANGUAGE);
                        } else {
                            $product['main_pair'] = $default_image;
                        }
                    }
                    $product['price'] = $product_comb['combination_prices'][$c_id];
                    $product['weight'] = $product_comb['combination_weight'][$c_id];
                    $product['amount'] = $product_comb['combination_amount'][$c_id];
                    $product['product_code'] = $product_comb['combination_code'][$c_id];
                    fn_price_list_print_product_data($product, $worksheet, $row, $width, $selected_fields, $styles, $c_value);
                    $row++;
                }
            } else {
                fn_price_list_print_product_data($product, $worksheet, $row, $width, $selected_fields, $styles);
                $row++;
            }
        }
        $counter->Out();
    }
    return true;
}