[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * @package admin 4 * @copyright Copyright 2003-2006 Zen Cart Development Team 5 * @copyright Portions Copyright 2003 osCommerce 6 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 7 * @version $Id: copy_to_confirm.php 4861 2006-10-29 17:15:42Z drbyte $ 8 */ 9 if (!defined('IS_ADMIN_FLAG')) { 10 die('Illegal Access'); 11 } 12 if (isset($_POST['products_id']) && isset($_POST['categories_id'])) { 13 $products_id = zen_db_prepare_input($_POST['products_id']); 14 $categories_id = zen_db_prepare_input($_POST['categories_id']); 15 16 // Copy attributes to duplicate product 17 $products_id_from=$products_id; 18 19 if ($_POST['copy_as'] == 'link') { 20 if ($categories_id != $current_category_id) { 21 $check = $db->Execute("select count(*) as total 22 from " . TABLE_PRODUCTS_TO_CATEGORIES . " 23 where products_id = '" . (int)$products_id . "' 24 and categories_id = '" . (int)$categories_id . "'"); 25 if ($check->fields['total'] < '1') { 26 $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " 27 (products_id, categories_id) 28 values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); 29 } 30 } else { 31 $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); 32 } 33 } elseif ($_POST['copy_as'] == 'duplicate') { 34 $old_products_id = (int)$products_id; 35 $product = $db->Execute("select products_type, products_quantity, products_model, products_image, 36 products_price, products_virtual, products_date_available, products_weight, 37 products_tax_class_id, manufacturers_id, 38 products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute, 39 product_is_free, product_is_call, products_quantity_mixed, 40 product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order, 41 products_price_sorter, master_categories_id 42 from " . TABLE_PRODUCTS . " 43 where products_id = '" . (int)$products_id . "'"); 44 45 $tmp_value = zen_db_input($product->fields['products_quantity']); 46 $products_quantity = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value; 47 $tmp_value = zen_db_input($product->fields['products_price']); 48 $products_price = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value; 49 $tmp_value = zen_db_input($product->fields['products_weight']); 50 $products_weight = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value; 51 52 $db->Execute("insert into " . TABLE_PRODUCTS . " 53 (products_type, products_quantity, products_model, products_image, 54 products_price, products_virtual, products_date_added, products_date_available, 55 products_weight, products_status, products_tax_class_id, 56 manufacturers_id, 57 products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute, 58 product_is_free, product_is_call, products_quantity_mixed, 59 product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order, 60 products_price_sorter, master_categories_id 61 ) 62 values ('" . zen_db_input($product->fields['products_type']) . "', 63 '" . $products_quantity . "', 64 '" . zen_db_input($product->fields['products_model']) . "', 65 '" . zen_db_input($product->fields['products_image']) . "', 66 '" . $products_price . "', 67 '" . zen_db_input($product->fields['products_virtual']) . "', 68 now(), 69 '" . (zen_not_null(zen_db_input($product->fields['products_date_available'])) ? zen_db_input($product->fields['products_date_available']) : '0001-01-01 00:00:00') . "', 70 '" . $products_weight . "', '0', 71 '" . (int)$product->fields['products_tax_class_id'] . "', 72 '" . (int)$product->fields['manufacturers_id'] . "', 73 '" . zen_db_input($product->fields['products_quantity_order_min']) . "', 74 '" . zen_db_input($product->fields['products_quantity_order_units']) . "', 75 '" . zen_db_input($product->fields['products_priced_by_attribute']) . "', 76 '" . (int)$product->fields['product_is_free'] . "', 77 '" . (int)$product->fields['product_is_call'] . "', 78 '" . (int)$product->fields['products_quantity_mixed'] . "', 79 '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "', 80 '" . zen_db_input($product->fields['products_qty_box_status']) . "', 81 '" . zen_db_input($product->fields['products_quantity_order_max']) . "', 82 '" . zen_db_input($product->fields['products_sort_order']) . "', 83 '" . zen_db_input($product->fields['products_price_sorter']) . "', 84 '" . zen_db_input($categories_id) . 85 "')"); 86 87 $dup_products_id = $db->Insert_ID(); 88 89 $description = $db->Execute("select language_id, products_name, products_description, 90 products_url 91 from " . TABLE_PRODUCTS_DESCRIPTION . " 92 where products_id = '" . (int)$products_id . "'"); 93 while (!$description->EOF) { 94 $db->Execute("insert into " . TABLE_PRODUCTS_DESCRIPTION . " 95 (products_id, language_id, products_name, products_description, 96 products_url, products_viewed) 97 values ('" . (int)$dup_products_id . "', 98 '" . (int)$description->fields['language_id'] . "', 99 '" . zen_db_input($description->fields['products_name']) . "', 100 '" . zen_db_input($description->fields['products_description']) . "', 101 '" . zen_db_input($description->fields['products_url']) . "', '0')"); 102 $description->MoveNext(); 103 } 104 105 $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " 106 (products_id, categories_id) 107 values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); 108 $products_id = $dup_products_id; 109 $description->MoveNext(); 110 // FIX HERE 111 ///////////////////////////////////////////////////////////////////////////////////////////// 112 // Copy attributes to duplicate product 113 // moved above $products_id_from=zen_db_input($products_id); 114 $products_id_to= $dup_products_id; 115 $products_id = $dup_products_id; 116 117 if ( $_POST['copy_attributes']=='copy_attributes_yes' and $_POST['copy_as'] == 'duplicate' ) { 118 // $products_id_to= $copy_to_products_id; 119 // $products_id_from = $pID; 120 // $copy_attributes_delete_first='1'; 121 // $copy_attributes_duplicates_skipped='1'; 122 // $copy_attributes_duplicates_overwrite='0'; 123 124 if (DOWNLOAD_ENABLED == 'true') { 125 $copy_attributes_include_downloads='1'; 126 $copy_attributes_include_filename='1'; 127 } else { 128 $copy_attributes_include_downloads='0'; 129 $copy_attributes_include_filename='0'; 130 } 131 132 zen_copy_products_attributes($products_id_from, $products_id_to); 133 } 134 // EOF: Attributes Copy on non-linked 135 ///////////////////////////////////////////////////////////////////// 136 137 // copy product discounts to duplicate 138 zen_copy_discounts_to_product($old_products_id, (int)$dup_products_id); 139 } 140 141 // reset products_price_sorter for searches etc. 142 zen_update_products_price_sorter($products_id); 143 144 } 145 zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''))); 146 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |