function insert_product($products_data, $dest_category_id, $link, $action = 'insert')
 {
     $products_id = xtc_db_prepare_input($products_data['products_id']);
     $products_date_available = xtc_db_prepare_input($products_data['products_date_available']);
     $products_date_available = date('Y-m-d') < $products_date_available ? $products_date_available : 'null';
     $products_status = xtc_db_prepare_input($products_data['products_status']);
     if ($products_data['products_startpage'] == 1) {
         $this->link_product($products_data['products_id'], 0);
         //$products_status = 1;    //web28 2012-10-30 - don't set status active
     } else {
         $this->set_product_remove_startpage_sql($products_data['products_id'], 0);
         //Dokuman - 2009-11-12 - BUGFIX #0000351: When products disable display on startpage, should update table products_to_categories
     }
     if (PRICE_IS_BRUTTO == 'true' && $products_data['products_price']) {
         $products_data['products_price'] = round($products_data['products_price'] / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100, PRICE_PRECISION);
     }
     $customers_statuses_array = xtc_get_customers_statuses();
     $permission = array();
     for ($i = 0, $n = sizeof($customers_statuses_array); $i < $n; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission[$customers_statuses_array[$i]['id']] = 0;
         }
     }
     if (isset($products_data['groups'])) {
         foreach ($products_data['groups'] as $dummy => $b) {
             $permission[$b] = 1;
         }
     }
     // build array
     if ($permission['all'] == 1) {
         $permission = array();
         end($customers_statuses_array);
         for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
             if (isset($customers_statuses_array[$i]['id'])) {
                 $permission[$customers_statuses_array[$i]['id']] = 1;
             }
         }
     }
     $permission_array = array();
     // set pointer to last key
     end($customers_statuses_array);
     for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission_array = array_merge($permission_array, array('group_permission_' . $customers_statuses_array[$i]['id'] => $permission[$customers_statuses_array[$i]['id']]));
         }
     }
     $sql_data_array = array('products_quantity' => xtc_db_prepare_input($products_data['products_quantity']), 'products_model' => xtc_db_prepare_input($products_data['products_model']), 'products_ean' => xtc_db_prepare_input($products_data['products_ean']), 'products_price' => xtc_db_prepare_input($products_data['products_price']), 'products_sort' => xtc_db_prepare_input($products_data['products_sort']), 'products_shippingtime' => xtc_db_prepare_input($products_data['shipping_status']), 'products_discount_allowed' => xtc_db_prepare_input($products_data['products_discount_allowed']), 'products_date_available' => $products_date_available, 'products_weight' => xtc_db_prepare_input($products_data['products_weight']), 'products_status' => $products_status, 'products_startpage' => xtc_db_prepare_input($products_data['products_startpage']), 'products_startpage_sort' => xtc_db_prepare_input($products_data['products_startpage_sort']), 'products_tax_class_id' => xtc_db_prepare_input($products_data['products_tax_class_id']), 'product_template' => xtc_db_prepare_input($products_data['info_template']), 'options_template' => xtc_db_prepare_input($products_data['options_template']), 'manufacturers_id' => xtc_db_prepare_input($products_data['manufacturers_id']), 'products_fsk18' => xtc_db_prepare_input($products_data['fsk18']), 'products_vpe_value' => xtc_db_prepare_input($products_data['products_vpe_value']), 'products_vpe_status' => xtc_db_prepare_input($products_data['products_vpe_status']), 'products_vpe' => xtc_db_prepare_input($products_data['products_vpe']), 'wholesaler_id' => xtc_db_prepare_input($products_data['wholesaler_id']), 'wholesaler_reorder' => xtc_db_prepare_input($products_data['wholesaler_reorder']));
     if (trim(ADD_PRODUCTS_FIELDS) != '') {
         $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_FIELDS, $products_data));
     }
     //echo print_r($sql_data_array); EXIT;
     $sql_data_array = array_merge($sql_data_array, $permission_array);
     //get the next ai-value from table products if no products_id is set
     if (!$products_id || $products_id == '') {
         $new_pid_query = xtc_db_query("SHOW TABLE STATUS LIKE '" . TABLE_PRODUCTS . "'");
         $new_pid_query_values = xtc_db_fetch_array($new_pid_query);
         $products_id = $new_pid_query_values['Auto_increment'];
     }
     //prepare products_image filename
     $accepted_products_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_products_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     if ($products_image = xtc_try_upload('products_image', DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_products_image_files_extensions, $accepted_products_image_files_mime_types)) {
         $pname_arr = explode('.', $products_image->filename);
         $nsuffix = array_pop($pname_arr);
         $products_image_name = $products_id . '_0.' . $nsuffix;
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['products_previous_image_0'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['products_previous_image_0']);
         }
         //workaround if there are v2 images mixed with v3
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_image->filename . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] == 0) {
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         } else {
             copy(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         }
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_image_name);
         require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
         require DIR_WS_INCLUDES . 'product_info_images.php';
         require DIR_WS_INCLUDES . 'product_popup_images.php';
         // set file rights
         $this->set_products_images_file_rights($products_image_name);
     } else {
         // save, when wo no upload an image
         $mo_img = array('image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
         if ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
             if ($products_data['del_mo_pic']) {
                 foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                     if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                         xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                     }
                     break;
                 }
             }
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
         } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
         }
         $products_image_name = $products_data['products_previous_image_0'];
     }
     //are we asked to delete some pics?
     if ($products_data['del_pic'] != '') {
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['del_pic'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['del_pic']);
         }
         xtc_db_query("UPDATE " . TABLE_PRODUCTS . "\n                         SET products_image = NULL\n                       WHERE products_id    = '" . xtc_db_input($products_id) . "'");
     }
     if ($products_data['del_mo_pic'] != '') {
         foreach ($products_data['del_mo_pic'] as $dummy => $val) {
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $val . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($val);
             }
             xtc_db_query("DELETE FROM " . TABLE_PRODUCTS_IMAGES . "\n                                     WHERE products_id = '" . xtc_db_input($products_id) . "'\n                                       AND image_name  = '" . $val . "'");
         }
     }
     //MO_PICS
     $accepted_mo_pics_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_mo_pics_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     for ($img = 0; $img < MO_PICS; $img++) {
         if ($pIMG = xtc_try_upload('mo_pics_' . $img, DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_mo_pics_image_files_extensions, $accepted_mo_pics_image_files_mime_types)) {
             $pname_arr = explode('.', $pIMG->filename);
             $nsuffix = array_pop($pname_arr);
             $products_image_name = $products_id . '_' . ($img + 1) . '.' . $nsuffix;
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $products_data['products_previous_image_' . ($img + 1)] . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($products_data['products_previous_image_' . ($img + 1)]);
             }
             @xtc_del_image_file($products_image_name);
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $pIMG->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $products_image_name);
             //get data & write to table
             // $mo_img = array ('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img +1), 'image_name' => xtc_db_prepare_input($products_image_name));
             $mo_img = array('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img + 1), 'image_name' => xtc_db_prepare_input($products_image_name), 'image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
             if ($action == 'insert') {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             } elseif ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
                 if ($products_data['del_mo_pic']) {
                     foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                         if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                         }
                         break;
                     }
                 }
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
             } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             }
             //image processing
             require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
             require DIR_WS_INCLUDES . 'product_info_images.php';
             require DIR_WS_INCLUDES . 'product_popup_images.php';
             //set file rights
             $this->set_products_images_file_rights($products_image_name);
         }
     }
     if (is_array($products_data['image_title'])) {
         foreach ($products_data['image_title'] as $it_image_nr => $it_image_title) {
             $mo_img = array('image_title' => xtc_db_prepare_input($it_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($it_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (is_array($products_data['image_alt'])) {
         foreach ($products_data['image_alt'] as $ia_image_nr => $ia_image_title) {
             $mo_img = array('image_alt' => xtc_db_prepare_input($ia_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($ia_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (isset($products_data['products_image']) && xtc_not_null($products_data['products_image']) && $products_data['products_image'] != 'none') {
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_data['products_image']);
     }
     if ($action == 'insert') {
         $insert_sql_data = array('products_date_added' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array);
         $products_id = xtc_db_insert_id();
         xtc_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                              SET products_id   = '" . $products_id . "',\n                              categories_id = '" . $dest_category_id . "'");
         // web28 - 2012-03-11 - link product to startpage
         /* not longer needed
            if ($products_data['products_startpage'] == 1 ) {
              xtc_db_query("INSERT INTO ".TABLE_PRODUCTS_TO_CATEGORIES."
                                    SET products_id   = '".$products_id."',
                                        categories_id = '0'");
            }
            */
     } elseif ($action == 'update') {
         $update_sql_data = array('products_last_modified' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $update_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\'');
     }
     //Included specials
     if (file_exists("includes/modules/categories_specials.php")) {
         require_once "includes/modules/categories_specials.php";
         saveSpecialsData($products_id);
     }
     $languages = xtc_get_languages();
     // Here we go, lets write Group prices into db
     // start
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $personal_price = xtc_db_prepare_input($products_data['products_price_' . $group_data[$col]['STATUS_ID']]);
             if ($personal_price == '' || $personal_price == '0.0000') {
                 $personal_price = '0.00';
             } else {
                 if (PRICE_IS_BRUTTO == 'true') {
                     $personal_price = $personal_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
                 }
                 $personal_price = xtc_round($personal_price, PRICE_PRECISION);
             }
             if ($action == 'insert') {
                 xtc_db_query("DELETE FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                              WHERE products_id = '" . $products_id . "'\n                                AND quantity    = '1'");
                 $insert_array = array();
                 $insert_array = array('personal_offer' => $personal_price, 'quantity' => '1', 'products_id' => $products_id);
                 xtc_db_perform("personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'], $insert_array);
             } else {
                 xtc_db_query("UPDATE personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                         SET personal_offer = '" . $personal_price . "'\n                                       WHERE products_id = '" . $products_id . "'\n                                         AND quantity    = '1'");
             }
         }
     }
     // end
     // ok, lets check write new staffelpreis into db (if there is one)
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $quantity = xtc_db_prepare_input($products_data['products_quantity_staffel_' . $group_data[$col]['STATUS_ID']]);
             $staffelpreis = xtc_db_prepare_input($products_data['products_price_staffel_' . $group_data[$col]['STATUS_ID']]);
             if (PRICE_IS_BRUTTO == 'true') {
                 $staffelpreis = $staffelpreis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
             }
             $staffelpreis = xtc_round($staffelpreis, PRICE_PRECISION);
             if ($staffelpreis != '' && $quantity != '') {
                 // ok, lets check entered data to get rid of user faults
                 if ($quantity <= 1) {
                     $quantity = 2;
                 }
                 $check_query = xtc_db_query("SELECT quantity\n                                                           FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                          WHERE products_id = '" . $products_id . "'\n                                                            AND quantity    = '" . $quantity . "'");
                 // dont insert if same qty!
                 if (xtc_db_num_rows($check_query) < 1) {
                     xtc_db_query("INSERT INTO personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                   SET price_id       = '',\n                                                       products_id    = '" . $products_id . "',\n                                                       quantity       = '" . $quantity . "',\n                                                       personal_offer = '" . $staffelpreis . "'");
                 }
             }
         }
     }
     foreach ($languages as $lang) {
         $language_id = $lang['id'];
         $sql_data_array = array('products_name' => xtc_db_prepare_input($products_data['products_name'][$language_id]), 'products_description' => xtc_db_prepare_input($products_data['products_description_' . $language_id]), 'products_short_description' => xtc_db_prepare_input($products_data['products_short_description_' . $language_id]), 'products_keywords' => xtc_db_prepare_input($products_data['products_keywords'][$language_id]), 'products_url' => xtc_db_prepare_input($products_data['products_url'][$language_id]), 'products_meta_title' => xtc_db_prepare_input($products_data['products_meta_title'][$language_id]), 'products_meta_description' => xtc_db_prepare_input($products_data['products_meta_description'][$language_id]), 'products_meta_keywords' => xtc_db_prepare_input($products_data['products_meta_keywords'][$language_id]));
         if (trim(ADD_PRODUCTS_DESCRIPTION_FIELDS)) {
             $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_DESCRIPTION_FIELDS, $products_data, $language_id));
         }
         if ($action == 'insert') {
             $insert_sql_data = array('products_id' => $products_id, 'language_id' => $language_id);
             $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
         } elseif ($action == 'update') {
             //BOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             $product_query = xtc_db_query("SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . "\n                                               WHERE language_id = '" . $lang['id'] . "'\n                                                 AND products_id = '" . $products_id . "'");
             if (xtc_db_num_rows($product_query) == 0) {
                 xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, array('products_id' => $products_id, 'language_id' => $lang['id']));
             }
             //EOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\' and language_id = \'' . $language_id . '\'');
         }
     }
     //redirect by update button
     if (isset($products_data['prod_update'])) {
         xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&action=new_product&pID=' . $products_id . $this->page_parameter));
     }
     xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, xtc_get_path($dest_categories_id) . '&pID=' . $products_id . $this->page_parameter));
     //web28 2012-04-14 new redirect
 }
    ?>
</td>
                 <?php 
    if (USE_ADMIN_THUMBS_IN_LIST == 'true') {
        ?>
                   <td class="categories_view_data hidden-xs">
                     <?php 
        echo xtc_info_image_c($categories['categories_image'], $categories['categories_image'], '', '', $admin_thumbs_size);
        ?>
                   </td>
                   <?php 
    }
    ?>
                 <td class="categories_view_data" style="text-align: left; padding-left: 5px;">
                   <?php 
    echo '<a href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . xtc_get_path($categories['categories_id'])) . '"><span class="glyphicon glyphicon-folder-close"></span> </a>';
    echo '<a href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . 'cPath=' . $cPath . '&cID=' . $categories['categories_id'] . '&action=edit_category') . '"><span class="glyphicon glyphicon-pencil"></span> </a>';
    echo '<b><a href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '">' . $categories['categories_name'] . '</a></b>';
    ?>
                 </td>
                 <?php 
    // check product and attributes stock
    if (STOCK_CHECK == 'true') {
        echo '<td class="categories_view_data hidden-xs">--</td>';
    }
    ?>
                 <td class="categories_view_data">
                   <?php 
    //show status icons (green & red circle) with links
    if ($categories['categories_status'] == '1') {
        echo xtc_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '<a href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . 'action=setcflag&flag=0&cID=' . $categories['categories_id'] . '&cPath=' . $cPath) . '">&nbsp;&nbsp;' . xtc_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
 //BOF - Dokuman - 2010-01-29 - category name selection included in one select statement
 /*
 // get category name
 $categories_query = xtDBquery("select
 			                                        cd.categories_name
 			                                        from ".TABLE_CATEGORIES_DESCRIPTION." cd,
 			                                        ".TABLE_CATEGORIES." c,
 			                                         " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
 			                                        WHERE c.categories_id=cd.categories_id
 			                                        and p2c.products_id = '".(int) $_SESSION['tracking']['products_history'][$random_last_viewed]."'
 			                                        and cd.language_id='".(int) $_SESSION['languages_id']."'");
 $categories_data = xtc_db_fetch_array($categories_query,true);
 */
 //EOF - Dokuman - 2010-01-29 - category name selection included in one select statement
 $random_products_price = $xtPrice->xtcGetPrice($random_product['products_id'], $format = true, 1, $random_product['products_tax_class_id'], $random_product['products_price']);
 $category_path = xtc_get_path($random_product['categories_id']);
 if ($random_product['products_name'] != '') {
     $box_smarty->assign('box_content', $product->buildDataArray($random_product));
     $box_smarty->assign('MY_PAGE', 'TEXT_MY_PAGE');
     $box_smarty->assign('WATCH_CATGORY', 'TEXT_WATCH_CATEGORY');
     $box_smarty->assign('MY_PERSONAL_PAGE', xtc_href_link(FILENAME_ACCOUNT));
     //BOF - Dokuman - 2010-01-29 - category name selection included in one select statement
     //$box_smarty->assign('CATEGORY_LINK', xtc_href_link(FILENAME_DEFAULT, xtc_category_link($categories_data['categories_id'], $categories_data['categories_name'])));
     //$box_smarty->assign('CATEGORY_NAME', $categories_data['categories_name']);
     $box_smarty->assign('CATEGORY_LINK', xtc_href_link(FILENAME_DEFAULT, xtc_category_link($random_product['categories_id'], $random_product['categories_name'])));
     $box_smarty->assign('CATEGORY_NAME', $random_product['categories_name']);
     //BOF - Dokuman - 2010-01-29 - category name selection included in one select statement
     $box_smarty->assign('language', $_SESSION['language']);
     $box_smarty->caching = 0;
     $box_last_viewed = $box_smarty->fetch(CURRENT_TEMPLATE . '/boxes/box_last_viewed.html');
     $smarty->assign('box_LAST_VIEWED', $box_last_viewed);