Example #1
0
function Insert_Product_Catalog($atts)
{
    // Include the required global variables, and create a few new ones
    global $wpdb, $categories_table_name, $subcategories_table_name, $tags_table_name, $tagged_items_table_name, $tag_groups_table_name, $catalogues_table_name, $catalogue_items_table_name, $items_table_name, $fields_meta_table_name, $item_videos_table_name;
    global $ProductString, $ProdCats, $ProdSubCats, $ProdTags, $ProdCustomFields, $ProdCatString, $ProdSubCatString, $ProdTagString, $ProdCustomFieldsString, $Catalogue_ID, $Catalogue_Layout_Format, $Catalogue_Sidebar, $Full_Version, $TagGroupName;
    global $link_base;
    $ProductString = "";
    $Filter = get_option("UPCP_Filter_Type");
    $Color = get_option("UPCP_Color_Scheme");
    $Links = get_option("UPCP_Product_Links");
    $Detail_Image = get_option("UPCP_Details_Image");
    $Pretty_Links = get_option("UPCP_Pretty_Links");
    $Mobile_Style = get_option("UPCP_Mobile_SS");
    $Tag_Logic = get_option("UPCP_Tag_Logic");
    $Links = get_option("UPCP_Product_Links");
    $Pagination_Location = get_option("UPCP_Pagination_Location");
    $CaseInsensitiveSearch = get_option("UPCP_Case_Insensitive_Search");
    $Maintain_Filtering = get_option("UPCP_Maintain_Filtering");
    $Show_Category_Descriptions = get_option("UPCP_Show_Category_Descriptions");
    $Products_Per_Page = get_option("UPCP_Products_Per_Page");
    $ProductSearch = get_option("UPCP_Product_Search");
    $Inner_Filter = get_option("UPCP_Inner_Filter");
    $Pagination_Background = get_option("UPCP_Pagination_Background");
    $Pagination_Border = get_option("UPCP_Pagination_Border");
    $Pagination_Shadow = get_option("UPCP_Pagination_Shadow");
    $Pagination_Gradient = get_option("UPCP_Pagination_Gradient");
    $Pagination_Font = get_option("UPCP_Pagination_Font");
    $Products_Pagination_Label = get_option("UPCP_Products_Pagination_Label");
    $Product_Name_Search_Label = get_option("UPCP_Product_Name_Search_Label");
    $Product_Search_Text_Label = get_option("UPCP_Product_Name_Text_Label");
    $No_Results_Found_Label = get_option("UPCP_No_Results_Found_Label");
    if ($Products_Pagination_Label != "") {
        $Products_Pagination_Text = $Products_Pagination_Label;
    } else {
        $Products_Pagination_Text = __(' products', 'UPCP');
    }
    if ($Product_Name_Search_Label != "") {
        $SearchLabel = $Product_Name_Search_Label;
    } else {
        if ($ProductSearch == "namedesc" or $ProductSearch == "namedesccust") {
            $SearchLabel = __("Product Search14", 'UPCP');
        } else {
            $SearchLabel = __("Product Name:", 'UPCP');
        }
    }
    if ($prod_name != "") {
        $Product_Name_Text = $prod_name;
    } elseif ($Product_Search_Text_Label != "") {
        $Product_Name_Text = $Product_Search_Text_Label;
    } else {
        if ($ProductSearch == "namedesc" or $ProductSearch == "namedesccust") {
            $Product_Name_Text = __("Search...", 'UPCP');
        } else {
            $Product_Name_Text = __("Name...", 'UPCP');
        }
    }
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array("id" => "1", "excluded_layouts" => "None", "starting_layout" => "", "products_per_page" => "", "current_page" => 1, "sidebar" => "Yes", "only_inner" => "No", "ajax_reload" => "No", "ajax_url" => "", "request_count" => 0, "category" => "", "subcategory" => "", "tags" => "", "custom_fields" => "", "prod_name" => "", "link_base" => ""), $atts));
    if ($ajax_reload != "No") {
        $ajax_reload = ucfirst(strtolower($ajax_reload));
    }
    // Select the catalogue information from the database
    $Catalogue = $wpdb->get_row("SELECT * FROM {$catalogues_table_name} WHERE Catalogue_ID=" . $id);
    $CatalogueItems = $wpdb->get_results("SELECT * FROM {$catalogue_items_table_name} WHERE Catalogue_ID=" . $id . " ORDER BY Position");
    // Add any additional CSS in-line
    if ($Catalogue->Catalogue_Custom_CSS != "") {
        $HeaderBar .= "<style type='text/css'>";
        $HeaderBar .= $Catalogue->Catalogue_Custom_CSS;
        $HeaderBar .= "</style>";
    }
    //Add styling options that have been set
    if ($Full_Version == "Yes") {
        $HeaderBar .= UPCP_Add_Modified_Styles();
    }
    if ($Detail_Image != "") {
        $HeaderBar .= "<style type='text/css'>";
        $HeaderBar .= ".upcp-thumb-details-link, .upcp-list-details-link, .upcp-detail-details-link {";
        $HeaderBar .= "background: url('" . $Detail_Image . "');";
        $HeaderBar .= "}";
        $HeaderBar .= "</style>";
    }
    $Top_JS .= "<script language='JavaScript' type='text/javascript'>";
    if ($Maintain_Filtering == "Yes") {
        $Top_JS .= "var maintain_filtering = 'Yes';";
    } else {
        $Top_JS .= "var maintain_filtering = 'No';";
    }
    $Top_JS .= "</script>";
    $HeaderBar .= $Top_JS;
    if ($Links == "New") {
        $Target = "_blank";
    } else {
        $Target = "_self";
    }
    $HeaderBar .= "<form id='upcp-hidden-filtering-form' method='post' target='" . $Target . "'>";
    $HeaderBar .= "<input type='hidden' id='upcp-selected-categories' name='categories' value='" . $_POST['categories'] . "' />";
    $HeaderBar .= "<input type='hidden' id='upcp-selected-subcategories' name='subcategories' value='" . $_POST['subcategories'] . "' />";
    $HeaderBar .= "<input type='hidden' id='upcp-selected-tags' name='tags' value='" . $_POST['tags'] . "' />";
    $HeaderBar .= "<input type='hidden' id='upcp-selected-prod-name' name='prod_name' value='" . $_POST['prod_name'] . "' />";
    $HeaderBar .= "</form>";
    if (get_query_var('single_product') != "" or $_GET['SingleProduct'] != "") {
        $ProductString .= $HeaderBar;
        $ProductString .= SingleProductPage();
        return $ProductString;
    }
    $Catalogue_ID = $id;
    $Catalogue_Sidebar = $sidebar;
    $Starting_Layout = ucfirst($starting_layout);
    if ($excluded_layouts != "None") {
        $Excluded_Layouts = explode(",", $excluded_layouts);
    } else {
        $Excluded_Layouts = array();
    }
    if (isset($_GET['categories'])) {
        $category = explode(",", $_GET['categories']);
    } elseif (isset($_POST['categories']) and $_POST['categories'] != "") {
        $category = explode(",", $_POST['categories']);
    } elseif ($category == "") {
        $category = array();
    } else {
        $category = explode(",", $category);
    }
    if (isset($_GET['sub-categories'])) {
        $subcategory = explode(",", $_GET['sub-categories']);
    } elseif (isset($_POST['subcategories']) and $_POST['subcategories'] != "") {
        $subcategory = explode(",", $_POST['subcategories']);
    } elseif ($subcategory == "") {
        $subcategory = array();
    } else {
        $subcategory = explode(",", $subcategory);
    }
    if (isset($_GET['tags'])) {
        $tags = explode(",", $_GET['tags']);
    } elseif (isset($_POST['tags']) and $_POST['tags'] != "") {
        $tags = explode(",", $_POST['tags']);
    } elseif ($tags == "") {
        $tags = array();
    } else {
        $tags = explode(",", $tags);
    }
    if (isset($_POST['prod_name']) and $_POST['prod_name'] != "") {
        $prod_name = $_POST['prod_name'];
    }
    //Pagination early work
    if ($products_per_page == "") {
        $products_per_page = $Products_Per_Page;
    }
    if ($category != "" or $subcategory != "" or $tags != "" or $prod_name != "") {
        $Filtered = "Yes";
    } else {
        $Filtered = "No";
    }
    $ProductString .= "<div class='upcp-Hide-Item' id='upcp-shortcode-atts'>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-catalogue-id'>" . $id . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-catalogue-sidebar'>" . $sidebar . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-starting-layout'>" . $starting_layout . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-current-layout'>" . $starting_layout . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-exclude-layouts'>" . $excluded_layouts . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-current-page'>" . $current_page . "</div>";
    $ProductString .= "<div class='shortcode-attr' id='upcp-default-search-text'>" . $Product_Name_Text . "</div>";
    if ($ajax_reload == "Yes") {
        $ProductString .= "<div class='shortcode-attr' id='upcp-base-url'>" . $ajax_url . "</div>";
    } else {
        $uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
        //if ($uri_parts[0] != "/") {$ProductString .= "<div class='shortcode-attr' id='upcp-base-url'>" . $uri_parts[0] . "</div>";}
        if (strpos($uri_parts[1], "page_id") === false) {
            $ProductString .= "<div class='shortcode-attr' id='upcp-base-url'>" . $uri_parts[0] . "</div>";
        } else {
            $ProductString .= "<div class='shortcode-attr' id='upcp-base-url'>" . $uri_parts[0] . "?" . $uri_parts[1] . "</div>";
        }
        //else {$ProductString .= "<div class='shortcode-attr' id='upcp-base-url'>/?" . $uri_parts[1] . "</div>";}
    }
    $ProductString .= "</div>";
    if (sizeOf($Excluded_Layouts) > 0) {
        for ($i = 0; $i < sizeOf($Excluded_Layouts); $i++) {
            $ExcludedLayouts[$i] = ucfirst(trim($Excluded_Layouts[$i]));
        }
    } else {
        $ExcludedLayouts = array();
    }
    if ($Starting_Layout == "") {
        if (!in_array("Thumbnail", $Excluded_Layouts)) {
            $Starting_Layout = "Thumbnail";
        } elseif (!in_array("List", $Excluded_Layouts)) {
            $Starting_Layout = "List";
        } else {
            $Starting_Layout = "Detail";
        }
    }
    // Make sure that the layout is set
    if ($layout_format != "Thumbnail" and $layout_format != "List") {
        if ($Catalogue->Catalogue_Layout_Format != "") {
            $format = $Catalogue->Catalogue_Layout_Format;
        } else {
            $format = "Thumbnail";
        }
    } else {
        $format = $layout_format;
    }
    // Arrays to store what categories, sub-categories and tags are applied to the product in the catalogue
    $ProdCats = array();
    $ProdSubCats = array();
    $ProdTags = array();
    $ProdCustomFields = array();
    // If filtering for custom fields, build the field/value query string
    if ($custom_fields != "") {
        $Custom_Field_IDs = explode(",", $custom_fields);
        foreach ($Custom_Field_IDs as $Custom_Field_ID) {
            $Field_ID = substr($Custom_Field_ID, 0, strpos($Custom_Field_ID, "=>"));
            $Field_Value = substr($Custom_Field_ID, strpos($Custom_Field_ID, "=>") + 2);
            $Selected_Custom_Fields[$Field_ID][] = html_entity_decode($Field_Value);
        }
        $Custom_Fields_Sql_String .= "(";
        foreach ($Selected_Custom_Fields as $Field_ID => $Selected_Custom_Field) {
            $Custom_Fields_Sql_String .= "(";
            $Custom_Fields_Sql_String .= "Field_ID='" . $Field_ID . "' AND (";
            foreach ($Selected_Custom_Field as $Value) {
                $Custom_Fields_Sql_String .= "Meta_Value LIKE '" . $Value . "' OR Meta_Value LIKE '" . $Value . ",%' OR Meta_Value LIKE '%," . $Value . ",%' OR Meta_Value LIKE '%," . $Value . "' OR ";
            }
            $Custom_Fields_Sql_String = substr($Custom_Fields_Sql_String, 0, -4);
            $Custom_Fields_Sql_String .= "))";
            $Custom_Fields_Sql_String .= " OR ";
        }
        $Custom_Fields_Sql_String = substr($Custom_Fields_Sql_String, 0, -4);
        $Custom_Fields_Sql_String .= ")";
        $Custom_Field_Count = sizeOf($Selected_Custom_Fields);
    }
    $ProdThumbString .= "<div id='prod-cat-" . $id . "' class='prod-cat thumb-display ";
    if ($Starting_Layout != "Thumbnail") {
        $ProdThumbString .= "hidden-field";
    }
    $ProdThumbString .= "'>\n";
    $ProdThumbString .= "%upcp_pagination_placeholder_top%";
    $ProdListString .= "<div id='prod-cat-" . $id . "' class='prod-cat list-display ";
    if ($Starting_Layout != "List") {
        $ProdListString .= "hidden-field";
    }
    $ProdListString .= "'>\n";
    $ProdListString .= "%upcp_pagination_placeholder_top%";
    $ProdDetailString .= "<div id='prod-cat-" . $id . "' class='prod-cat detail-display ";
    if ($Starting_Layout != "Detail") {
        $ProdDetailString .= "hidden-field";
    }
    $ProdDetailString .= "'>\n";
    $ProdDetailString .= "%upcp_pagination_placeholder_top%";
    $Product_Count = 0;
    foreach ($CatalogueItems as $CatalogueItem) {
        // If the item is a product, then simply call the AddProduct function to add it to the code
        if ($CatalogueItem->Item_ID != "" and $CatalogueItem->Item_ID != 0) {
            $Product = $wpdb->get_row("SELECT * FROM {$items_table_name} WHERE Item_ID=" . $CatalogueItem->Item_ID);
            $ProdTagObj = $wpdb->get_results("SELECT Tag_ID FROM {$tagged_items_table_name} WHERE Item_ID=" . $CatalogueItem->Item_ID);
            if ($ajax_reload == "No") {
                $Prod_Custom_Fields = $wpdb->get_results("SELECT Field_ID, Meta_Value FROM {$fields_meta_table_name} WHERE Item_ID=" . $Product->Item_ID);
            }
            if ($Product->Item_Display_Status != "Hide") {
                if (sizeOf($category) == 0 or in_array($Product->Category_ID, $category)) {
                    if (sizeOf($subcategory) == 0 or in_array($Product->SubCategory_ID, $subcategory)) {
                        $ProdTag = ObjectToArray($ProdTagObj);
                        $Tag_Check = CheckTags($tags, $ProdTag, $Tag_Logic);
                        if ($Tag_Check == "Yes") {
                            $Custom_Field_Check = Custom_Field_Check($Custom_Fields_Sql_String, $Custom_Field_Count, $Product->Item_ID);
                            if ($Custom_Field_Check == "Yes") {
                                $Name_Search_Match = SearchProductName($Product->Item_ID, $Product->Item_Name, $Product->Item_Description, $prod_name, $CaseInsensitiveSearch, $ProductSearch);
                                if ($Name_Search_Match == "Yes") {
                                    $Pagination_Check = CheckPagination($Product_Count, $products_per_page, $current_page, $Filtered);
                                    if ($Pagination_Check == "OK") {
                                        $HeaderBar .= "<a id='hidden_FB_link-" . $Product->Item_ID . "' class='fancybox' href='#prod-cat-addt-details-" . $Product->Item_ID . "'></a>";
                                        if (!in_array("Thumbnail", $ExcludedLayouts)) {
                                            $ProdThumbString .= AddProduct("Thumbnail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                        }
                                        if (!in_array("List", $ExcludedLayouts)) {
                                            $ProdListString .= AddProduct("List", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                        }
                                        if (!in_array("Detail", $ExcludedLayouts)) {
                                            $ProdDetailString .= AddProduct("Detail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                        }
                                    }
                                    $Product_Count++;
                                }
                            }
                        }
                    }
                }
            }
            if ($ajax_reload == "No") {
                FilterCount($Product, $ProdTagObj, $Prod_Custom_Fields);
            }
            unset($NameSearchMatch);
        }
        // If the item is a category, then add the appropriate extra HTML and call the AddProduct function
        // for each individual product in the category
        if ($CatalogueItem->Category_ID != "" and $CatalogueItem->Category_ID != 0) {
            if (sizeOf($category) == 0 or in_array($CatalogueItem->Category_ID, $category)) {
                $CatProdCount = 0;
                $Category = $wpdb->get_row("SELECT Category_Name, Category_Description FROM {$categories_table_name} WHERE Category_ID=" . $CatalogueItem->Category_ID);
                $ProdThumbString .= "<div id='prod-cat-category-" . $CatalogueItem->Category_ID . "' class='prod-cat-category upcp-thumb-category'>\n";
                $ProdListString .= "<div id='prod-cat-category-" . $CatalogueItem->Category_ID . "' class='prod-cat-category upcp-list-category'>\n";
                $ProdDetailString .= "<div id='prod-cat-category-" . $CatalogueItem->Category_ID . "' class='prod-cat-category upcp-detail-category'>\n";
                $ProdThumbString .= "%Category_Label%";
                $ProdListString .= "%Category_Label%";
                $ProdDetailString .= "%Category_Label%";
                $CatThumbHead = "<div id='prod-cat-category-label-" . $CatalogueItem->Category_ID . "' class='prod-cat-category-label upcp-thumb-category-label'><div class='prod-cat-category-name'>" . $Category->Category_Name . "</div>";
                if ($Show_Category_Descriptions == "Yes") {
                    $CatThumbHead .= "<div class='prod-cat-category-description'>" . $Category->Category_Description . "</div></div>\n";
                } else {
                    $CatThumbHead .= "</div>\n";
                }
                $CatListHead = "<div id='prod-cat-category-label-" . $CatalogueItem->Category_ID . "' class='prod-cat-category-label upcp-list-category-label'><div class='prod-cat-category-name'>" . $Category->Category_Name . "</div>";
                if ($Show_Category_Descriptions == "Yes") {
                    $CatListHead .= "<div class='prod-cat-category-description'>" . $Category->Category_Description . "</div></div>\n";
                } else {
                    $CatListHead .= "</div>\n";
                }
                $CatDetailHead = "<div id='prod-cat-category-label-" . $CatalogueItem->Category_ID . "' class='prod-cat-category-label upcp-detail-category-label'><div class='prod-cat-category-name'>" . $Category->Category_Name . "</div>";
                if ($Show_Category_Descriptions == "Yes") {
                    $CatDetailHead .= "<div class='prod-cat-category-description'>" . $Category->Category_Description . "</div></div>\n";
                } else {
                    $CatDetailHead .= "</div>\n";
                }
            }
            $Products = $wpdb->get_results("SELECT * FROM {$items_table_name} WHERE Category_ID=" . $CatalogueItem->Category_ID . " ORDER BY Item_Category_Product_Order");
            foreach ($Products as $Product) {
                $ProdTagObj = $wpdb->get_results("SELECT Tag_ID FROM {$tagged_items_table_name} WHERE Item_ID=" . $Product->Item_ID);
                if ($ajax_reload == "No") {
                    $Prod_Custom_Fields = $wpdb->get_results("SELECT Field_ID, Meta_Value FROM {$fields_meta_table_name} WHERE Item_ID=" . $Product->Item_ID);
                }
                if ($Product->Item_Display_Status != "Hide") {
                    if (sizeOf($category) == 0 or in_array($Product->Category_ID, $category)) {
                        if (sizeOf($subcategory) == 0 or in_array($Product->SubCategory_ID, $subcategory)) {
                            $ProdTag = ObjectToArray($ProdTagObj);
                            $Tag_Check = CheckTags($tags, $ProdTag, $Tag_Logic);
                            if ($Tag_Check == "Yes") {
                                $Custom_Field_Check = Custom_Field_Check($Custom_Fields_Sql_String, $Custom_Field_Count, $Product->Item_ID);
                                if ($Custom_Field_Check == "Yes") {
                                    $Name_Search_Match = SearchProductName($Product->Item_ID, $Product->Item_Name, $Product->Item_Description, $prod_name, $CaseInsensitiveSearch, $ProductSearch);
                                    if ($Name_Search_Match == "Yes") {
                                        $Pagination_Check = CheckPagination($Product_Count, $products_per_page, $current_page, $Filtered);
                                        if ($Pagination_Check == "OK") {
                                            $HeaderBar .= "<a id='hidden_FB_link-" . $Product->Item_ID . "' class='fancybox' href='#prod-cat-addt-details-" . $Product->Item_ID . "'></a>";
                                            if (!in_array("Thumbnail", $ExcludedLayouts)) {
                                                $ProdThumbString .= AddProduct("Thumbnail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                            }
                                            if (!in_array("List", $ExcludedLayouts)) {
                                                $ProdListString .= AddProduct("List", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                            }
                                            if (!in_array("Detail", $ExcludedLayouts)) {
                                                $ProdDetailString .= AddProduct("Detail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                            }
                                            $CatProdCount++;
                                        }
                                        $Product_Count++;
                                    }
                                }
                            }
                        }
                    }
                }
                if ($ajax_reload == "No") {
                    FilterCount($Product, $ProdTagObj, $Prod_Custom_Fields);
                }
                unset($NameSearchMatch);
            }
            if (sizeOf($category) == 0 or in_array($CatalogueItem->Category_ID, $category)) {
                if ($CatProdCount > 0) {
                    $ProdThumbString = str_replace("%Category_Label%", $CatThumbHead, $ProdThumbString);
                    $ProdListString = str_replace("%Category_Label%", $CatListHead, $ProdListString);
                    $ProdDetailString = str_replace("%Category_Label%", $CatDetailHead, $ProdDetailString);
                } else {
                    $ProdThumbString = str_replace("%Category_Label%", "", $ProdThumbString);
                    $ProdListString = str_replace("%Category_Label%", "", $ProdListString);
                    $ProdDetailString = str_replace("%Category_Label%", "", $ProdDetailString);
                }
                $ProdThumbString .= "</div>";
                $ProdListString .= "</div>";
                $ProdDetailString .= "</div>";
            }
        }
        // If the item is a sub-category, then add the appropriate extra HTML and call the AddProduct function
        // for each individual product in the sub-category
        if ($CatalogueItem->SubCategory_ID != "" and $CatalogueItem->SubCategory_ID != 0) {
            if (sizeOf($subcategory) == 0 or in_array($CatalogueItem->SubCategory_ID, $subcategory)) {
                $Products = $wpdb->get_results("SELECT * FROM {$items_table_name} WHERE SubCategory_ID=" . $CatalogueItem->SubCategory_ID);
                foreach ($Products as $Product) {
                    $ProdTagObj = $wpdb->get_results("SELECT Tag_ID FROM {$tagged_items_table_name} WHERE Item_ID=" . $CatalogueItem->Item_ID);
                    if ($ajax_reload == "No") {
                        $Prod_Custom_Fields = $wpdb->get_results("SELECT Field_ID, Meta_Value FROM {$fields_meta_table_name} WHERE Item_ID=" . $Product->Item_ID);
                    }
                    if ($Product->Item_Display_Status != "Hide") {
                        if (sizeOf($category) == 0 or in_array($Product->Category_ID, $category)) {
                            if (sizeOf($subcategory) == 0 or in_array($Product->SubCategory_ID, $subcategory)) {
                                $ProdTag = ObjectToArray($ProdTagObj);
                                $Tag_Check = CheckTags($tags, $ProdTag, $Tag_Logic);
                                if ($Tag_Check == "Yes") {
                                    $Custom_Field_Check = Custom_Field_Check($Custom_Fields_Sql_String, $Custom_Field_Count, $Product->Item_ID);
                                    if ($Custom_Field_Check == "Yes") {
                                        $Name_Search_Match = SearchProductName($Product->Item_ID, $Product->Item_Name, $Product->Item_Description, $prod_name, $CaseInsensitiveSearch, $ProductSearch);
                                        if ($Name_Search_Match == "Yes") {
                                            $Pagination_Check = CheckPagination($Product_Count, $products_per_page, $current_page, $Filtered);
                                            if ($Pagination_Check == "OK") {
                                                $HeaderBar .= "<a id='hidden_FB_link-" . $Product->Item_ID . "' class='fancybox' href='#prod-cat-addt-details-" . $Product->Item_ID . "'></a>";
                                                if (!in_array("Thumbnail", $ExcludedLayouts)) {
                                                    $ProdThumbString .= AddProduct("Thumbnail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                                }
                                                if (!in_array("List", $ExcludedLayouts)) {
                                                    $ProdListString .= AddProduct("List", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                                }
                                                if (!in_array("Detail", $ExcludedLayouts)) {
                                                    $ProdDetailString .= AddProduct("Detail", $Product->Item_ID, $Product, $ProdTagObj, $ajax_reload, $ajax_url);
                                                }
                                            }
                                            $Product_Count++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($ajax_reload == "No") {
                        FilterCount($Product, $ProdTagObj, $Prod_Custom_Fields);
                    }
                    unset($NameSearchMatch);
                }
            }
        }
        //if ($Pagination_Check == "Over") {break;}
    }
    if ($Product_Count == 0) {
        $ProdThumbString .= $No_Results_Found_Label;
        $ProdListString .= $No_Results_Found_Label;
        $ProdDetailString .= $No_Results_Found_Label;
    }
    $ProdThumbString .= "<div class='upcp-clear'></div>\n";
    $ProdListString .= "<div class='upcp-clear'></div>\n";
    $ProdDetailString .= "<div class='upcp-clear'></div>\n";
    if ($Pagination_Location == "Bottom" or $Pagination_Location == "Both") {
        $ProdThumbString .= "%upcp_pagination_placeholder_bottom%";
        $ProdListString .= "%upcp_pagination_placeholder_bottom%";
        $ProdDetailString .= "%upcp_pagination_placeholder_bottom%";
        /*$ProdThumbString .= "<div class='upcp-clear'></div>\n";
        		$ProdListString .= "<div class='upcp-clear'></div>\n";
        		$ProdDetailString .= "<div class='upcp-clear'></div>\n";*/
    }
    $ProdThumbString .= "</div>\n";
    $ProdListString .= "</div>\n";
    $ProdDetailString .= "</div>\n";
    if (in_array("Thumbnail", $ExcludedLayouts)) {
        unset($ProdThumbString);
    }
    if (in_array("List", $ExcludedLayouts)) {
        unset($ProdListString);
    }
    if (in_array("Detail", $ExcludedLayouts)) {
        unset($ProdDetailString);
    }
    //Deal with creating the page counter, if pagination is neccessary
    if ($Filtered == "Yes") {
        $Total_Products = $Product_Count;
    } else {
        $Total_Products = $Catalogue->Catalogue_Item_Count;
    }
    if ($Total_Products > $products_per_page) {
        $Num_Pages = ceil($Total_Products / $products_per_page);
        $PrevPage = max($current_page - 1, 1);
        $NextPage = min($current_page + 1, $Num_Pages);
        $PaginationString .= "<div class='catalogue-nav ";
        $PaginationString .= "upcp-cat-nav-bg-" . $Pagination_Background . " ";
        $PaginationString .= "upcp-cat-nav-border-" . $Pagination_Border . " ";
        $PaginationString .= "upcp-cat-nav-" . $Pagination_Shadow . " ";
        $PaginationString .= "upcp-cat-nav-" . $Pagination_Gradient . " ";
        $PaginationString .= "'>";
        $PaginationString .= "<span class='displaying-num'>" . $Total_Products . $Products_Pagination_Text . "</span>";
        $PaginationString .= "<span class='pagination-links'>";
        $PaginationString .= "<a class='first-page' title='Go to the first page' href='#' onclick='UPCP_DisplayPage(\"1\")'>&#171;</a>";
        $PaginationString .= "<a class='prev-page' title='Go to the previous page' href='#' onclick='UPCP_DisplayPage(\"" . $PrevPage . "\")'>&#8249;</a>";
        $PaginationString .= "<span class='paging-input'>" . $current_page . __(' of ', 'UPCP') . "<span class='total-pages'>" . $Num_Pages . "</span></span>";
        $PaginationString .= "<a class='next-page' title='Go to the next page' href='#' onclick='UPCP_DisplayPage(\"" . $NextPage . "\")'>&#8250;</a>";
        $PaginationString .= "<a class='last-page' title='Go to the last page' href='#' onclick='UPCP_DisplayPage(\"" . $Num_Pages . "\")'>&#187;</a>";
        $PaginationString .= "</span>";
        $PaginationString .= "</div>";
        if ($current_page == 1) {
            $PaginationString = str_replace("first-page", "first-page disabled", $PaginationString);
        }
        if ($current_page == 1) {
            $PaginationString = str_replace("prev-page", "prev-page disabled", $PaginationString);
        }
        if ($current_page == $Num_Pages) {
            $PaginationString = str_replace("next-page", "next-page disabled", $PaginationString);
        }
        if ($current_page == $Num_Pages) {
            $PaginationString = str_replace("last-page", "last-page disabled", $PaginationString);
        }
        /*if ($current_page != 1) {$PaginationString .= "<a href='#' onclick='UPCP_DisplayPage(\"1\")>" . __('First', 'UPCP') . "</a>";}
        		if ($current_page != 1) {$PaginationString .= "<a href='#' onclick='UPCP_DisplayPage(\"" . $current_page - 1 . "\")>" . __('Previous', 'UPCP') . "</a>";}
        				
        		$PaginationString .= "<span class='paging-input'>" . $current_page . __(' of ', 'UPCP') . "<span class='total-pages'>" . $Num_Pages . "</span></span>";
        				
        		if ($current_page != $Num_Pages) {$PaginationString .= "<a href='#' onclick='UPCP_DisplayPage(\"" . $current_page + 1 . "\")>" . __('Next', 'UPCP') . "</a>";}
        		if ($current_page != $Num_Pages) {$PaginationString .= "<a href='#' onclick='UPCP_DisplayPage(\"" . $Num_Pages . "\")>" . __('Last', 'UPCP') . "</a>";}*/
    }
    if ($Pagination_Location == "Bottom") {
        $ProdThumbString = str_replace("%upcp_pagination_placeholder_top%", "", $ProdThumbString);
        $ProdListString = str_replace("%upcp_pagination_placeholder_top%", "", $ProdListString);
        $ProdDetailString = str_replace("%upcp_pagination_placeholder_top%", "", $ProdDetailString);
    }
    if ($Pagination_Location == "Top") {
        $ProdThumbString = str_replace("%upcp_pagination_placeholder_bottom%", "", $ProdThumbString);
        $ProdListString = str_replace("%upcp_pagination_placeholder_bottom%", "", $ProdListString);
        $ProdDetailString = str_replace("%upcp_pagination_placeholder_bottom%", "", $ProdDetailString);
    }
    $ProdThumbString = str_replace("%upcp_pagination_placeholder_top%", $PaginationString, $ProdThumbString);
    $ProdListString = str_replace("%upcp_pagination_placeholder_top%", $PaginationString, $ProdListString);
    $ProdDetailString = str_replace("%upcp_pagination_placeholder_top%", $PaginationString, $ProdDetailString);
    $ProdThumbString = str_replace("%upcp_pagination_placeholder_bottom%", $PaginationString, $ProdThumbString);
    $ProdListString = str_replace("%upcp_pagination_placeholder_bottom%", $PaginationString, $ProdListString);
    $ProdDetailString = str_replace("%upcp_pagination_placeholder_bottom%", $PaginationString, $ProdDetailString);
    // Create string from the arrays, should use the implode function instead
    foreach ($ProdCats as $key => $value) {
        $ProdCatString .= $key . ",";
    }
    $ProdCatString = trim($ProdCatString, " ,");
    foreach ($ProdSubCats as $key => $value) {
        $ProdSubCatString .= $key . ",";
    }
    $ProdSubCatString = trim($ProdSubCatString, " ,");
    foreach ($ProdTags as $key => $value) {
        $ProdTagString .= $key . ",";
    }
    $ProdTagString = trim($ProdTagString, " ,");
    foreach ($ProdCustomFields as $key => $value) {
        $ProdCustomFieldsString .= $key . ",";
    }
    $ProdCustomFieldsString = trim($ProdCustomFieldsString, " ,");
    // If the sidebar is requested, add it
    if (($sidebar == "Yes" or $sidebar == "yes" or $sidebar == "YES") and $only_inner != "Yes") {
        $SidebarString = BuildSidebar($category, $subcategory, $tags, $prod_name);
    }
    if ($Mobile_Style == "Yes") {
        $MobileMenuString .= "<div id='prod-cat-mobile-menu' class='upcp-mobile-menu'>\n";
        $MobileMenuString .= "<div id='prod-cat-mobile-search'>\n";
        if ($Tag_Logic == "OR") {
            $MobileMenuString .= "<input type='text' id='upcp-mobile-search' class='jquery-prod-name-text mobile-search' name='Mobile_Search' value='" . __('Product Name', 'UPCP') . "...' onfocus='FieldFocus(this);' onblur='FieldBlur(this);' onkeyup='UPCP_Filer_Results_OR();'>\n";
        } else {
            $MobileMenuString .= "<input type='text' id='upcp-mobile-search' class='jquery-prod-name-text mobile-search' name='Mobile_Search' value='" . __('Product Name', 'UPCP') . "...' onfocus='FieldFocus(this);' onblur='FieldBlur(this);'  onkeyup='UPCP_Filer_Results();'>\n";
        }
        $MobileMenuString .= "</div>";
        $MobileMenuString .= "</div>";
    }
    $HeaderBar .= "<div class='prod-cat-header-div " . $Color . "-prod-cat-header-div'>";
    $HeaderBar .= "<div class='prod-cat-header-padding'></div>";
    $HeaderBar .= "<div id='starting-layout' class='hidden-field'>" . $Starting_Layout . "</div>";
    if (!in_array("Thumbnail", $ExcludedLayouts)) {
        $HeaderBar .= "<a href='#' onclick='ToggleView(\"Thumbnail\");return false;' title='Thumbnail'><div class='upcp-thumb-toggle-icon " . $Color . "-thumb-icon'></div></a>";
    }
    if (!in_array("List", $ExcludedLayouts)) {
        $HeaderBar .= "<a href='#' onclick='ToggleView(\"List\"); return false;' title='List'><div class='upcp-list-toggle-icon " . $Color . "-list-icon'></div></a>";
    }
    if (!in_array("Detail", $ExcludedLayouts)) {
        $HeaderBar .= "<a href='#' onclick='ToggleView(\"Detail\"); return false;' title='Detail'><div class='upcp-details-toggle-icon " . $Color . "-details-icon'></div></a>";
    }
    $HeaderBar .= "<div class='upcp-clear'></div>";
    $HeaderBar .= "</div>";
    $Bottom_JS .= "<script language='JavaScript' type='text/javascript'>";
    if (isset($_GET['Product_ID'])) {
        $Bottom_JS .= "jQuery(window).load(OpenProduct('" . $_GET['Product_ID'] . "'));";
    }
    $Bottom_JS .= "</script>";
    if ($only_inner != "Yes") {
        $InnerString .= "<div class='prod-cat-inner'>";
    }
    $InnerString .= $ProdThumbString . "<div class='upcp-clear'></div>" . $ProdListString . "<div class='upcp-clear'></div>" . $ProdDetailString . "<div class='upcp-clear'></div>";
    if ($only_inner != "Yes") {
        $InnerString .= "</div>";
    }
    if (function_exists("mb_convert_encoding")) {
        $InnerString = mb_convert_encoding($InnerString, 'UTF-8');
    } else {
        $InnerString = htmlspecialchars_decode(utf8_decode(htmlentities($InnerString, ENT_COMPAT, 'utf-8', false)));
    }
    if ($only_inner == "Yes") {
        if ($Inner_Filter == "Yes") {
            $InnerString = apply_filters('the_content', $InnerString);
        }
        $ReturnArray['request_count'] = $request_count;
        $ReturnArray['message'] = $InnerString;
        $PHP_Version = UPCP_Return_PHP_Version();
        if ($PHP_Version > 50300) {
            return json_encode($ReturnArray, JSON_UNESCAPED_UNICODE);
        } else {
            return json_encode($ReturnArray);
        }
    }
    $ProductString .= "<div class='prod-cat-container'>";
    $ProductString .= $HeaderBar;
    $ProductString .= $MobileMenuString;
    $ProductString .= $SidebarString;
    $ProductString .= $InnerString;
    $ProductString .= $Bottom_JS;
    $ProductString .= "<div class='upcp-clear'></div></div>";
    return $ProductString;
}
             $row[] = $aRow[$i];
             if ($i == $count - 1) {
                 $row[] = '<input type="checkbox" name="check_' . $aRow[$hidden] . '" class="check" value="' . $aRow[$hidden] . '" />';
             }
         }
         $data['aaData'][] = $row;
     }
     $_log->logInfo('get_list');
     break;
 case 'save_prod':
     $prod_id = $_REQUEST['id'];
     $arr = array('code' => htmlspecialchars($_REQUEST['cod'], ENT_QUOTES), 'name' => htmlspecialchars($_REQUEST['n'], ENT_QUOTES), 'category' => $_REQUEST['cat'], 'unit' => $_REQUEST['un'], 'min' => $_REQUEST['min'], 'comment' => htmlspecialchars($_REQUEST['c'], ENT_QUOTES), 'image' => $_REQUEST['img']);
     if ($prod_id == '') {
         if (!CheckProductExist($arr['name'])) {
             if (!CheckProductCode($arr['code'])) {
                 AddProduct($user_id, $arr);
             } else {
                 $error = 'პროდუქტი ასეთი კოდით უკვე არის სიაში!';
             }
         } else {
             $error = '"' . $arr['name'] . '" უკვე არის სიაში!';
         }
     } else {
         SaveProduct($prod_id, $user_id, $arr);
     }
     break;
 case 'disable':
     $prod_id = $_REQUEST['id'];
     DisableProduct($prod_id);
     break;
 case 'delete_image':
Example #3
0
    header('location:../user/login.php');
}
//Require các file cần thiết
require '../../configs/config.php';
require '../../libraries/connect.php';
require '../../models/category.php';
require '../../models/product.php';
//Xử lý POST dữ liệu lên
if ($_POST) {
    //Upload hình ảnh
    $image = $_FILES['image']['name'];
    if ($image != NULL) {
        move_uploaded_file($_FILES['image']['tmp_name'], '../../userfile/' . $image);
    } else {
        $image = null;
    }
    //Nhận dữ liệu từ form gán vào mảng
    $data = array('category_id' => $_POST['category_id'], 'name' => $_POST['name'], 'detail' => $_POST['detail'], 'image' => $image, 'price' => $_POST['price'], 'status' => isset($_POST['status']) ? 1 : 0, 'created' => date('Y-m-d H:i:s'), 'modified' => date('Y-m-d H:i:s'));
    echo $data['category_id'];
    echo $data['name'];
    //Truy vấn thêm mới vào cơ sở dữ liệu
    if (AddProduct($data)) {
        echo "Thêm mới thành công";
    } else {
        echo "Thêm mới không thành công";
    }
}
//Lấy danh sách danh mục sản phẩm có trạng thái kích hoạt (Status = 1)
$category_active_list = GetCategoryActiveList();
//Require file giao diện (View)
require '../../views/admin/product/v_add.php';
         $last_price = number_format(GetLastPrice($prod_id), 2, '.', '');
     }
     $data = array('self_price' => $self_price, 'last_price' => $last_price);
     break;
 case 'save_prod':
     $price_id = $_REQUEST['id'];
     $prod_name = $_REQUEST['n'];
     $sp_price = $_REQUEST['sp'];
     $sb_price = $_REQUEST['sb'];
     if (empty($sb_price)) {
         $sb_price = 0;
     }
     $prod_id = GetProductID($prod_name);
     if ($prod_name != '' && $price_id == '') {
         if (!CheckProductExist($prod_id)) {
             AddProduct($user_id, $prod_id, $sp_price, $sb_price);
             global $log;
             $log->setInsertLog('pricelist');
         } else {
             $error = $prod_name . ' უკვე არის სიაში!';
         }
     } else {
         SaveProduct($user_id, $price_id, $prod_id, $sp_price, $sb_price);
     }
     break;
 case 'disable':
     $prod_id = $_REQUEST['id'];
     DisableProduct($prod_id);
     break;
 default:
     $error = 'Action is Null';
Example #5
0
        }
        return $paging;
    }
}
/*###########################################################
Section : Main
###########################################################*/
$user->AuthenticationAdmin();
if (empty($pf)) {
    ShowAllProducts();
    ShowFormAllProducts();
} elseif ($pf == 'browse') {
    ShowAllProducts();
    ShowFormAllProducts();
} elseif ($pf == 'add') {
    GetPaymentCurrency();
    if ($process == 'add') {
        AddProduct();
    } else {
        ShowFormAddProducts();
    }
} elseif ($pf == 'detail') {
    GetPaymentCurrency();
    ShowDetailProduct();
    ShowFormDetailProduct();
} elseif ($pf == 'delete') {
    DeleteProduct($_REQUEST['delete']);
} elseif ($pf == 'search') {
    ShowSearchResultProducts();
    ShowFormSearchResultProducts();
}
Example #6
0
<?php

session_start();
?>

<?php 
header('Content-Type: application/json');
include 'classes.php';
$jsonResult = new JSON(array(), null, array());
$config = $jsonResult->GetAccesToken();
if ($config !== null) {
    AddProduct($config, $jsonResult);
} else {
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['token_error'];
}
print $jsonResult->PrepareJSON();
function AddProduct($config, $jsonResult)
{
    $cargo_id = $_GET["cargo_id"];
    $kind_id = "";
    $kind = $_GET["kind"];
    $amount = $_GET["amount"];
    $sql1 = "SELECT COUNT(name) as kind_amount , kind_id FROM kind WHERE name = '" . $kind . "';";
    $sql2 = "INSERT INTO kind(name) VALUES('" . $kind . "')";
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $result1 = $conn->query($sql1);
        foreach ($result1 as $row) {
            if ($row['kind_amount'] === "0") {
                $conn->query($sql2);
Example #7
0
File: admin.php Project: gblok/rsc
                <link rel="shortcut icon" href="data/admin/favicon.ico" type="image/x-icon">
                <title><?php 
            echo ADMIN_PRODUCT_TITLE;
            ?>
</title>

                <?php 
            // add new product and open configurator
            // it works when user click "setting..." and new product is added
            if (isset($_POST["AddProductAndOpenConfigurator"])) {
                if ($_POST["AddProductAndOpenConfigurator"] == 1) {
                    if (CONF_BACKEND_SAFEMODE) {
                        //this action is forbidden when SAFE MODE is ON
                        Redirect(ADMIN_FILE . "?safemode=yes&productID=" . $_GET["productID"] . "&eaction=prod");
                    }
                    $productID = AddProduct($_POST["categoryID"], $_POST["name"], $_POST["price"], $_POST["description"], $_POST["in_stock"], $_POST["brief_description"], $_POST["list_price"], $_POST["product_code"], $_POST["sort_order"], isset($_POST["ProductIsProgram"]), "eproduct_filename", $_POST["eproduct_available_days"], $_POST["eproduct_download_times"], $_POST["weight"], $_POST["meta_description"], $_POST["meta_keywords"], isset($_POST["free_shipping"]), $_POST["min_order_amount"], $_POST["shipping_freight"], $_POST["tax_class"], $_POST["currencyID"], $_POST["opt_margin"], $_POST["sef"], $_POST["title"]);
                    $_GET["productID"] = $productID;
                    $updatedValues = ScanPostVariableWithId(array("option_value", "option_radio_type"));
                    configUpdateOptionValue($productID, $updatedValues);
                    OpenConfigurator($_POST["optionID"], $productID);
                }
            }
            // show product
            if ($_GET["productID"] != 0) {
                $product = GetProduct($_GET["productID"]);
                $product["description"] = html_spchars($product["description"]);
                $product["brief_description"] = html_spchars($product["brief_description"]);
                $product["sef"] = html_spchars($product["sef"]);
                if (!$product["title"]) {
                    $product["title"] = "";
                }
Example #8
0
function _importProduct($row, $dbc, $identity_column, $dbcPhotos, $updated_extra_option, $currentCategoryID)
{
    $row["not defined"] = "";
    $row[$identity_column] = trim($row[$identity_column]);
    //search for product within current category
    $q = db_query("select productID, categoryID, customers_rating  from " . PRODUCTS_TABLE . " where categoryID=" . (int) $currentCategoryID . " and " . xEscSQL($_POST["update_column"]) . " LIKE '" . xEscSQL(trim($row[$identity_column])) . "'");
    $rowdb = db_fetch_row($q);
    if (!$rowdb && $_POST["update_column"] == 'product_code') {
        //not found
        //search for product in all categories
        $q = db_query("select productID, categoryID, customers_rating  from " . PRODUCTS_TABLE . " where " . xEscSQL($_POST["update_column"]) . " LIKE '" . xEscSQL(trim($row[$identity_column])) . "'");
        $rowdb = db_fetch_row($q);
    }
    $currency = $_POST['currencyISO'] ? $_POST['currencyISO'] : CONF_DEFAULT_CURRENCY;
    if (strcmp($dbc['ISO'], "not defined")) {
        $currencyID = getCurrencyID($row[$dbc['ISO']]);
        $currency = $currencyID ? $currencyID : $currency;
    }
    if ($rowdb) {
        //update product info
        $productID = $rowdb["productID"];
        $rowdb = GetProduct($productID);
        if (strcmp($dbc["Price"], "not defined")) {
            $Price = $row[$dbc["Price"]];
            $Price = str_replace(" ", "", $Price);
            $Price = str_replace(",", ".", $Price);
            $Price = (double) $Price;
        } else {
            $Price = $rowdb["Price_admin"];
        }
        if (strcmp($dbc["list_price"], "not defined")) {
            $list_price = $row[$dbc["list_price"]];
            $list_price = str_replace(" ", "", $list_price);
            $list_price = str_replace(",", ".", $list_price);
            $list_price = (double) $list_price;
        } else {
            $list_price = $rowdb["list_price_base"];
        }
        if (strcmp($dbc["sort_order"], "not defined")) {
            $sort_order = (int) $row[$dbc["sort_order"]];
        } else {
            $sort_order = $rowdb["sort_order"];
        }
        if (strcmp($dbc["in_stock"], "not defined")) {
            $in_stock = (int) $row[$dbc["in_stock"]];
        } else {
            $in_stock = $rowdb["in_stock"];
        }
        if (strcmp($dbc["eproduct_filename"], "not defined")) {
            $eproduct_filename = $row[$dbc["eproduct_filename"]];
        } else {
            $eproduct_filename = $rowdb["eproduct_filename"];
        }
        if (strcmp($dbc["eproduct_available_days"], "not defined")) {
            $eproduct_available_days = (int) $row[$dbc["eproduct_available_days"]];
        } else {
            $eproduct_available_days = $rowdb["eproduct_available_days"];
        }
        if (strcmp($dbc["eproduct_download_times"], "not defined")) {
            $eproduct_download_times = (int) $row[$dbc["eproduct_download_times"]];
        } else {
            $eproduct_download_times = $rowdb["eproduct_download_times"];
        }
        if (strcmp($dbc["weight"], "not defined")) {
            $weight = (double) $row[$dbc["weight"]];
        } else {
            $weight = $rowdb["weight"];
        }
        if (strcmp($dbc["free_shipping"], "not defined")) {
            $free_shipping = trim($row[$dbc["free_shipping"]]) == "+" ? 1 : 0;
        } else {
            $free_shipping = $rowdb["free_shipping"];
        }
        if (strcmp($dbc["min_order_amount"], "not defined")) {
            $min_order_amount = (int) $row[$dbc["min_order_amount"]];
        } else {
            $min_order_amount = $rowdb["min_order_amount"];
        }
        if (strcmp($dbc["shipping_freight"], "not defined")) {
            $shipping_freight = (double) $row[$dbc["shipping_freight"]];
        } else {
            $shipping_freight = $rowdb["shipping_freight"];
        }
        if (strcmp($dbc["description"], "not defined")) {
            $description = $row[$dbc["description"]];
        } else {
            $description = $rowdb["description"];
        }
        if (strcmp($dbc["brief_description"], "not defined")) {
            $brief_description = $row[$dbc["brief_description"]];
        } else {
            $brief_description = $rowdb["brief_description"];
        }
        if (strcmp($dbc["product_code"], "not defined")) {
            $product_code = $row[$dbc["product_code"]];
        } else {
            $product_code = xHtmlSpecialCharsDecode($rowdb["product_code"]);
        }
        if (strcmp($dbc["meta_description"], "not defined")) {
            $meta_description = $row[$dbc["meta_description"]];
        } else {
            $meta_description = xHtmlSpecialCharsDecode($rowdb["meta_description"]);
        }
        if (strcmp($dbc["meta_keywords"], "not defined")) {
            $meta_keywords = $row[$dbc["meta_keywords"]];
        } else {
            $meta_keywords = xHtmlSpecialCharsDecode($rowdb["meta_keywords"]);
        }
        if (strcmp($dbc["name"], "not defined")) {
            $name = $row[$dbc["name"]];
        } else {
            $name = xHtmlSpecialCharsDecode($rowdb["name"]);
        }
        if (strcmp($dbc["title"], "not defined")) {
            $title = $row[$dbc["title"]];
        } else {
            $title = xHtmlSpecialCharsDecode($rowdb["title"]);
        }
        if (strcmp($dbc["sef"], "not defined")) {
            $sef = $row[$dbc["sef"]];
        } else {
            $sef = xHtmlSpecialCharsDecode($rowdb["sef"]);
        }
        $opt_margin = $rowdb["opt_margin"];
        $categoryID = $rowdb["categoryID"];
        $customers_rating = $rowdb["customers_rating"];
        $ProductIsProgram = trim($eproduct_filename) != "";
        UpdateProduct($productID, $categoryID, $name, $Price, $description, $in_stock, $customers_rating, $brief_description, $list_price, $product_code, $sort_order, $ProductIsProgram, "", $eproduct_available_days, $eproduct_download_times, $weight, $meta_description, $meta_keywords, $free_shipping, $min_order_amount, $shipping_freight, null, $currency, $opt_margin, $sef, $title, 0);
    } else {
        // add new product
        $Price = 0.0;
        $list_price = 0.0;
        $sort_order = 0;
        $in_stock = 0;
        $eproduct_filename = "";
        $eproduct_available_days = 0;
        $eproduct_download_times = 0;
        $weight = 0.0;
        $free_shipping = 0;
        $min_order_amount = 1;
        $shipping_freight = 0.0;
        if (strcmp($dbc["Price"], "not defined")) {
            $Price = (double) $row[$dbc["Price"]];
        }
        if (strcmp($dbc["list_price"], "not defined")) {
            $list_price = (double) $row[$dbc["list_price"]];
        }
        if (strcmp($dbc["sort_order"], "not defined")) {
            $sort_order = (int) $row[$dbc["sort_order"]];
        }
        if (strcmp($dbc["in_stock"], "not defined")) {
            $in_stock = (int) $row[$dbc["in_stock"]];
        }
        if (strcmp($dbc["eproduct_filename"], "not defined")) {
            $eproduct_filename = $row[$dbc["eproduct_filename"]];
        }
        if (strcmp($dbc["eproduct_available_days"], "not defined")) {
            $eproduct_available_days = (int) $row[$dbc["eproduct_available_days"]];
        }
        if (strcmp($dbc["eproduct_download_times"], "not defined")) {
            $eproduct_download_times = (int) $row[$dbc["eproduct_download_times"]];
        }
        if (strcmp($dbc["weight"], "not defined")) {
            $weight = (double) $row[$dbc["weight"]];
        }
        if (strcmp($dbc["free_shipping"], "not defined")) {
            $free_shipping = trim($row[$dbc["free_shipping"]]) == "+" ? 1 : 0;
        }
        if (strcmp($dbc["min_order_amount"], "not defined")) {
            $min_order_amount = (int) $row[$dbc["min_order_amount"]];
        }
        if (strcmp($dbc["shipping_freight"], "not defined")) {
            $shipping_freight = (double) $row[$dbc["shipping_freight"]];
        }
        $ProductIsProgram = trim($row[$dbc["eproduct_filename"]]) != "";
        $sef = $row[$dbc["sef"]];
        $productID = AddProduct($currentCategoryID, $row[$dbc["name"]], $Price, $row[$dbc["description"]], $in_stock, $row[$dbc["brief_description"]], $list_price, $row[$dbc["product_code"]], $sort_order, $ProductIsProgram, "", $eproduct_available_days, $eproduct_download_times, $weight, $row[$dbc["meta_description"]], $row[$dbc["meta_keywords"]], $free_shipping, $min_order_amount, $shipping_freight, CONF_DEFAULT_TAX_CLASS, $currency, 1, $sef, $row[$dbc["title"]], 0);
    }
    if (strlen($eproduct_filename)) {
        SetProductFile($productID, $eproduct_filename);
    }
    _importExtraOptionValues($row, $productID, $updated_extra_option);
    if (count($dbcPhotos) > 0) {
        _importProductPictures($row, $dbcPhotos, $productID);
    }
    if (!empty($sef)) {
        fu_generate_product($productID, $sef);
    }
}