/******************************************************************************/
/* PDF Catalogs v.2.0.9 for osCommerce v.2.2 MS2 PHP 5 */
/* */
/* by Snarg (Supa.Snarg@gmail.com), Septemer 2008 */
/* */
/* Based on PDF Catalogs v.2.0.1 by: */
/* by Infobroker (info@cooleshops.de), April 2006 */
/* by Antonios THROUVALAS (antonios@throuvalas.net), April 2004 */
/* by Mitch O`Brian (mitchobrian.de), juli2004 2004 */
/* by Nicolas Hilly (n.hilly@laposte.net), August 2004 */
/* by Christophe Buchi (chris@butch.ch), September 2004 */
/* by Ryan Kononoff (ryankononoff@shaw.ca), October 2004 */
/* */
/* Based on PDF Catalogs v.1.4 by gurvan.riou@laposte.net */
/* */
/* Uses FPDF (http://www.fpdf.org), Version 1.52, by Olivier PLATHEY */
/* modified by Infobroker */
/* */
/* Credit goes also to: */
/* - Yamasoft (http://www.yamasoft.com/php-gif.zip) for their GIF class, */
/* - Jerome FENAL (jerome.fenal@logicacmg.com) for introducing GIF Support */
/* in the FPDF Class, */
/* - The osC forums members (forums.oscommerce.com)! */
/* */
/* Please donate to the osCommerce Core Team! */
/* Freeware, You may use, modify and redistribute this software as you wish! */
/******************************************************************************/
**note: Snarg is not, in any way, shape or form, a programmer. If this breaks your stuff, I'm sorry. It works for me.
>> DESCRIPTION:
The Pdf_Catalogs Contribution generates catalogs of products in the PDF format
for all installed languages of your osCommerce online shop. It displays the
products with pictures, their full descriptions and prices in a PDF format.
Products are sorted by their categories. ¨
Customer can create catalogs of products in the PDF format for different categories
Example see here: http://www.cooleshops.de/happy_hours/pdf_catalogue_info.php
>> INSTALLATION IN ADMINISTRATION:
1 - Copy the following files and directory to their respective location:
- catalog/admin/font directory and its content!
- catalog/admin/pdf_catalogue.php,
- catalog/admin/pdf_config.php,
- catalog/admin/pdf_define_intro.php,
- catalog/admin/pdf_fpdf.php,
- catalog/admin/pdf_gif.php,
- catalog/admin/includes/languages/english/pdf_catalogue.php
- catalog/admin/includes/languages/espanol/pdf_catalogue.php
- catalog/admin/includes/languages/german/pdf_catalogue.php
- catalog/admin/includes/languages/french/pdf_catalogue.php
2 - In catalog/admin/includes/filenames.php insert following line, at the end of
the file, just before '?>' :
define('FILENAME_PDF_CATALOGUE', 'pdf_catalogue.php'); // PDF Catalog
define('FILENAME_PDF_DEFINE_INTRO', 'pdf_define_intro.php'); // PDF Catalog
define('FILENAME_PDF_LINK', '../catalogues/catalog_2.pdf'); // PDF Catalog v. 1.58
**note: make sure the url (above) is valid in your configuration.
**note: In this case the link goes up one directory and then enters the catalogues dir then opens catalog_2.pdf
**note: If the link in the admin to 'View PDF file' shows a PDF in another language, or does not work at all, then try in admin/includes/filenames.php change:
define('FILENAME_PDF_LINK', '../catalogues/catalog_2.pdf'); // PDF Catalog v. 1.58
to
define('FILENAME_PDF_LINK', '../catalogues/catalog_1.pdf'); // PDF Catalog v. 1.58
3 - In catalog/admin/includes/languages/english.php insert following line :
define('BOX_TOOLS_PDF_CATALOGUE', 'Generate Catalog(s)'); // PDF Catalog v.1.51
define('PDF_DEFINE_INTRO', 'This presentation will be used as the introduction of the PDF catalogues and presentation page.'); // PDF Catalog v.1.55
define('BOX_INFORMATION_PDF_DEFINE_INTRO', 'PDF Introduction'); // PDF Catalog v.1.55
define('BOX_TOOLS_PDF_LINK', 'View PDF Document');
In catalog/admin/includes/languages/german.php insert following line :
define('BOX_TOOLS_PDF_CATALOGUE', 'PDF Katalog erstellen'); // PDF Catalog v. 1.51
define('PDF_DEFINE_INTRO', 'Diese Einleitung wird im pdf File als Einleitung angezeigt.'); // PDF Catalog v.1.55
define('BOX_INFORMATION_PDF_DEFINE_INTRO', 'PDF Einleitung'); // PDF Catalog v.1.55
define('BOX_TOOLS_PDF_LINK', 'PDF Anzeigen');
Do the same for any other language available!
4 - In catalog/admin/includes/boxes/tools.php, or any other box, insert following line :
'
' . // PDF Catalog v.1.51
'
' . // PDF Catalog v.1.55
'
' .
5 - copy the following function from admin/include/functions/languages.php inside admin/include/functions/general.php
function tep_get_languages_directory($code) {
global $languages_id;
$language_query = tep_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . tep_db_input($code) . "'");
if (tep_db_num_rows($language_query)) {
$language = tep_db_fetch_array($language_query);
$languages_id = $language['languages_id'];
return $language['directory'];
} else {
return false;
}
}
N.B.: You can remove the admin/include/functions/languages.php as it shouldn't be used anymore
>>>>>>>>>>>>>>>>>
** ONLY for migration from 1.51 to 1.55 : About the removal of the function pdf_catalog.php/CountProductsInCategory :
Instead use general.php/tep_products_in_category_count is reccursive by default while CountProductsInCategory() used USE_RECURSIVE_COUNT.
For the 2% of people WHO REALLY WANT a non recursive product counting, do the 2 following steps :
1) - in admin/include/functions/general.php/replace :
tep_products_in_category_count($category_id, $include_inactive = false) {
by
tep_products_in_category_count($category_id, $include_inactive = false, $include_subcateg = true) {
10 lines later replace (include the recursive call into a if condition :
$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'");
if (tep_db_num_rows($child_categories_query)) {
while ($child_categories = tep_db_fetch_array($child_categories_query)) {
$products_count += tep_products_in_category_count($child_categories['categories_id'], $include_inactive);
}
}
by
if ($include_subcateg == true) {
$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'");
if (tep_db_num_rows($child_categories_query)) {
while ($child_categories = tep_db_fetch_array($child_categories_query)) {
$products_count += tep_products_in_category_count($child_categories['categories_id'], $include_inactive);
}
}
}
2)- in admin/pdf_catalog.php
around the line 235
replace tep_products_in_category_count($cid,'false');
by tep_products_in_category_count($cid,'false','false'); // or true if you want recursivity
around the line 235
replace tep_products_in_category_count($categoriesidarray[$i],'false');
by tep_products_in_category_count($categoriesidarray[$i],'false','false'); // or true if you want recursivity
N.B.: You can remove the function CountProductsInCategory() in pdf_catalog.php as it's not used anymore.
The enhanced general.php/tep_products_in_category_count () can be used in admin/categories.php to show only the number of products within a category without the ones in subcategoies.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>> INSTALLATION IN CATALOG:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1 - Make directory /catalogues and chmod 755. That's where the generated PDF
catalogs will be stored. You may use another name for that directory. If you
do so, don't forget to make the necessary changes in the pdf_config.php file!
2 - Copy the following files to their respective location:
- catalog/font directory and its content!
- catalog/pdf_catalogue_info.php,
- catalog/pdf_catalogue_info2.php,
- catalog/pdf_download_katalog.php,
- catalog/pdf_config.php,
- catalog/pdf_fpdf.php,
- catalog/pdf_gif.php,
- catalog/images/getacro.gif,
- catalog/images/adobe_pdf.gif,
- catalog/images/no_picture.jpg,
- catalog/includes/languages/english/pdf_catalogue_info.php,
- catalog/includes/languages/english/pdf_catalogue_info2.php,
- catalog/includes/languages/english/pdf_define_intro.php,
- catalog/includes/languages/espanol/pdf_catalogue_info.php,
- catalog/includes/languages/espanol/pdf_catalogue_info2.php,
- catalog/includes/languages/espanol/pdf_define_intro.php,
- catalog/includes/languages/german/pdf_catalogue_info.php,
- catalog/includes/languages/german/pdf_catalogue_info2.php,
- catalog/includes/languages/german/pdf_define_intro.php,
- catalog/includes/languages/french/pdf_catalogue_info.php,
- catalog/includes/languages/french/pdf_define_intro.php
3 - In catalog/includes/filenames.php insert following line, at the end of the file, just
before '?>' :
define('FILENAME_PDF_CATALOGUE', 'pdf_catalogue_info.php'); // PDF Catalog v.1.51
define('FILENAME_PDF_DEFINE_INTRO','pdf_define_intro.php'); // PDF Catalog v.1.55
define('FILENAME_PDF_KATALOG', 'pdf_download_katalog.php'); // PDF Catalog v 1.6
4 - In catalog/includes/boxes/information.php insert following line in the links array :
'' . BOX_INFORMATION_PDF_CATALOGUE . '
'. // PDF Catalog v.1.51
5 - In catalog/includes/languages/english.php put following line :
define('BOX_INFORMATION_PDF_CATALOGUE', 'Downloadable catalog'); // PDF Catalog v.1.51
an other languages where you need
6 - In catalog/includes/functions/general.php add before the final ?> :
function tep_get_languages_directory($code) {
global $languages_id;
$language_query = tep_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . tep_db_input($code) . "'");
if (tep_db_num_rows($language_query)) {
$language = tep_db_fetch_array($language_query);
$languages_id = $language['languages_id'];
return $language['directory'];
} else {
return false;
}
}
function tep_get_languages() {
$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
while ($languages = tep_db_fetch_array($languages_query)) {
$languages_array[] = array('id' => $languages['languages_id'],
'name' => $languages['name'],
'code' => $languages['code'],
'image' => $languages['image'],
'directory' => $languages['directory']);
}
return $languages_array;
}
>> CONFIGURATION:
To configure the script, edit the file catalog/admin/pdf_config.php, catalog/pdf_config.php and the file
catalog/pdf_catalogue_info.php! The files contain the necessary instructions!
>> USE:
After installing the script, go to the administration panel, under 'Tools', and
click on 'Generate Catalog(s)'. The script will create as many PDF files as the
languages you have installed in your osCommerce site.
>> MULTILINGUAL SUPPORT:
To add new fonts and encoding support, visit the FPDF site and read the tutorials
about 'Adding new fonts and encoding support'!
>> TROUBLESHOOTING
- "Warning: filesize(): Stat failed for catalogues/osCommerce_X.pdf (errno=2 - No such file or directory)"
* Check if you have created the PDF files through the administration panel, or
* Check the configuration of your script, pay attention to the PDF filename and
to the directory, where the PDF files will be saved!
>> KNOWN ISSUES:
- If you are using GIF files, setting in the configuration the 'Resize images'
option to '1' (1 = yes) will generate an error!
- Generating PDF files needs time and processor ressources. The FPDF FAQ (FPDF is
the class used to create the PDF files) indicates following limits in the size
of the PDF files:
* The maximum memory size allocated to PHP scripts defaults to 8MB. For very big
document, especially with images, this limit may be reached (the file being built
into memory). The parameter is configured in the php.ini file.
* The maximum execution time allocated defaults to 30 seconds. This limit can of
course be easily reached. It is configured in php.ini and may be altered dynamically
with set_time_limit().
* Browsers generally have a 5 minute time-out. If you send the PDF directly to the
browser and reach the limit, it will be lost. Remark: even when the browser goes in
time-out, the script may continue to run on the server.
Similar concerns may appear if you have many different languages installed, because
the script will attempt to create one PDF file per installed language.
>> TODO:
- Database driven configuration
- Correct some errors with handling GIF files