add(sprintf('Quick Updates Configuration Keys Not installed. Please install your configuration by clicking %sInstall%s', '', ''), 'warning'); } // installation start if ($_GET['qu_installer'] == 'install' ) { install_quick_updates(); // install new configuration keys zen_redirect(zen_href_link(FILENAME_QUICK_UPDATES)); } if ($_GET['qu_installer'] == 'remove') { remove_quick_updates(); // remove configuration variables zen_redirect(zen_href_link(FILENAME_QUICK_UPDATES)); } // end installation/removal $export_products = array(); // ? without this line the taxprice will be rounded to 0 decimals $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] = 4; define('QUICKUPDATES_DISPLAY_TVA_PRICES', QUICKUPDATES_DISPLAY_TVA_OVER); // bof functions function zen_quickupdates_table_head($sort_field, $head_text, $cols=1) { $str = ''; $str .= ' 1 ? ' colspan="' . $cols . '"' : '') . '>'; if($sort_field != '') { $str .= '' . zen_image(DIR_WS_IMAGES . 'icon_up.gif', TEXT_SORT_ALL . $head_text . ' ' . TEXT_ASCENDINGLY) . ''; $str .= '' . zen_image(DIR_WS_IMAGES . 'icon_down.gif', TEXT_SORT_ALL . $head_text . ' ' . TEXT_DESCENDINGLY) . '
'; } $str .= $head_text . ''; return $str; } // eof functions // bof GET paramaters to/from $_SESSION array & product copy stuff if ($_POST['quick_copy_from_id'] > 0) $_SESSION['quick_updates']['quick_copy_from_id'] = (int)$_POST['quick_copy_from_id']; if (!((int)$_SESSION['quick_updates']['quick_copy_from_id']) > 0) $_SESSION['quick_updates']['quick_copy_from_id'] = (int)QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT; if (isset($_POST['quick_copy_number'])) $_SESSION['quick_updates']['quick_copy_number'] = (int)$_POST['quick_copy_number']; if (!(isset($_SESSION['quick_updates']['quick_copy_number']))) $_SESSION['quick_updates']['quick_copy_number'] = 0; //// // This module changes the $_POST array! (moves import data to $_POST['quick_updates_new']) if(is_file(DIR_WS_MODULES . 'quick_import.php')) include_once(DIR_WS_MODULES . 'quick_import.php'); $products_copied = 0; unset($quick_copy); if($_POST['quick_updates_copy']){ for($i = 1; $i <= $_SESSION['quick_updates']['quick_copy_number']; $i++ ){ if(zen_products_id_valid($_SESSION['quick_updates']['quick_copy_from_id'])){ $quick_copy = quick_copy_product($_SESSION['quick_updates']['quick_copy_from_id']); // returns: $quick_copy['master_categories_id'] & $quick_copy_products_id = $quick_copy['products_id']; }else{ $messageStack->add(TEXT_PRODUCT_COPY_FROM_INVALID . '' . $_SESSION['quick_updates']['quick_copy_from_id'] . '', 'error'); } if($quick_copy){ $products_copied .= $quick_copy['products_id'] . '; '; } } if($quick_copy){ $messageStack->add(TEXT_PRODUCT_COPIED_FROM . '' . $_SESSION['quick_updates']['quick_copy_from_id'] . '' . TEXT_PRODUCT_COPIED_TO_PRODUCTS_ID . '' . $products_copied . '' . TEXT_PRODUCT_COPIED_TO_MASTER_CATEGORIES_ID . '' .$quick_copy['master_categories_id'] . '' . TEXT_PRODUCT_COPIED_SELECTION_CHANGED_WARNING, 'success'); } } if($quick_copy){ // a product has been copied, make sure it will show in the listing $_SESSION['quick_updates']['cPath'] = (int)$quick_copy['master_categories_id']; $_SESSION['quick_updates']['products_status'] = 'all'; $_SESSION['quick_updates']['manufacturer'] = 0; $_SESSION['quick_updates']['sort_by'] = 'p.products_id DESC'; //$messageStack->add(TEXT_PRODUCT_COPIED_FROM . '' . $_SESSION['quick_updates']['quick_copy_from_id'] . '' . TEXT_PRODUCT_COPIED_TO_PRODUCTS_ID . '' . $quick_copy['products_id'] . '' . TEXT_PRODUCT_COPIED_TO_MASTER_CATEGORIES_ID . '' .$quick_copy['master_categories_id'] . '' . TEXT_PRODUCT_COPIED_SELECTION_CHANGED_WARNING, 'success'); } if (isset($_GET['products_status'])) /// do not convert to int here! (conversion is done later anyway) $_SESSION['quick_updates']['products_status'] = zen_db_prepare_input($_GET['products_status']); // set the products_status view back to all (is not numeric) if a product has been copied (copied products are inactive by default) if(!isset($_SESSION['quick_updates']['products_status']) || $_POST['quick_updates_copy']) $_SESSION['quick_updates']['products_status'] = 'all'; $current_category_id = 0; if (isset($_GET['cPath'])) $_SESSION['quick_updates']['cPath'] = (int)$_GET['cPath']; if(isset($_SESSION['quick_updates']['cPath'])) //$cPath = $_SESSION['quick_updates']['cPath']; $current_category_id = $_SESSION['quick_updates']['cPath']; if (isset($_REQUEST['categories_switch'])) $_SESSION['quick_updates']['categories_switch'] = zen_db_prepare_input($_REQUEST['categories_switch']); if(!isset($_SESSION['quick_updates']['categories_switch'])) $_SESSION['quick_updates']['categories_switch'] = 'linked_cats'; // or master_cats $sort_by = 'p.products_id DESC'; if (isset($_GET['sort_by'])) $_SESSION['quick_updates']['sort_by'] = zen_db_prepare_input($_GET['sort_by']); if(isset($_SESSION['quick_updates']['sort_by'])) $sort_by = $_SESSION['quick_updates']['sort_by']; // by default show most recent added products first $manufacturer = 0; if (isset($_GET['manufacturer'])) $_SESSION['quick_updates']['manufacturer'] = (int)$_GET['manufacturer']; if(isset($_SESSION['quick_updates']['manufacturer'])) $manufacturer = $_SESSION['quick_updates']['manufacturer']; $reset_editor = 1; if (isset($_GET['reset_editor'])) $_SESSION['quick_updates']['reset_editor'] = (int)$_GET['reset_editor']; if(isset($_SESSION['quick_updates']['reset_editor'])) $reset_editor = $_SESSION['quick_updates']['reset_editor']; // possible to default to the editor set in admin? // using the stored pagenumber doesn't always make sense, reset it in that cases if(isset($_POST['quick_updates_copy']) || isset($_REQUEST['row_by_page']) || isset($_REQUEST['products_status']) || isset($_REQUEST['sort_by'])) $_SESSION['quick_updates']['page'] = 1; if($_REQUEST['page']) $_SESSION['quick_updates']['page'] = (int)$_REQUEST['page']; if(isset($_SESSION['quick_updates']['page'])) $page = $_SESSION['quick_updates']['page']; if (isset($_GET['row_by_page'])) $_SESSION['quick_updates']['row_by_page'] = (int)$_GET['row_by_page']; if(isset($_SESSION['quick_updates']['row_by_page'])) $row_by_page = $_SESSION['quick_updates']['row_by_page']; if(!($row_by_page > 0)) $row_by_page = MAX_DISPLAY_SEARCH_RESULTS; define('MAX_DISPLAY_ROW_BY_PAGE' , $row_by_page ); // eof GET paramaters to/from $_SESSION array & product copy stuff // define the szen for rollover lines per page $row_bypage_array = array(); //for ($i = 10; $i <=100 ; $i=$i+5) for ($i = 5; $i <= 320 ; $i=$i*2) { $row_bypage_array[] = array('id' => $i, 'text' => $i); } // bof get tx classes $tax_class_array = array(array('id' => '0', 'text' => NO_TAX_TEXT)); $classes = $db->Execute("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); while (!$classes->EOF) { $tax_class_array[] = array('id' => $classes->fields['tax_class_id'], 'text' => $classes->fields['tax_class_title']); $classes->MoveNext(); } // eof get tx classes // bof get manufacturers $manufacturers_array = array(array('id' => '0', 'text' => NO_MANUFACTURER)); //$manufacturers_array = array(array('id' => '0', 'text' => TEXT_ALL_MANUFACTURERS)); $manufacturers = $db->Execute("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); while (!$manufacturers->EOF) { $manufacturers_array[] = array('id' => $manufacturers->fields['manufacturers_id'], 'text' => $manufacturers->fields['manufacturers_name']); $manufacturers->MoveNext(); } // eof get manufacturers // bof get category_tree $quick_updates_category_tree = zen_get_category_tree(); // eof get category_tree // bof Update database switch ($_GET['action']) { case 'update' : // bof prepare al new data for database input if(sizeof($_POST['quick_updates_new']) > 0){ foreach($_POST['quick_updates_new'] as $key => $value){ // $value is an array here (contains values like ['products_model'][$products_id] = '1' for example) $_POST['quick_updates_new'][$key] = zen_db_prepare_input($value); } } // eof prepare al new data for database input $quick_updates_count = array(); if($_POST['quick_updates_new']['products_model']){; foreach($_POST['quick_updates_new']['products_model'] as $products_id => $new_value) { if (trim($_POST['quick_updates_new']['products_model'][$products_id]) != trim($_POST['quick_updates_old']['products_model'][$products_id])) { $quick_updates_count['products_model'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_model='" . zen_db_input($new_value) . "', products_last_modified=NOW() WHERE products_id=" . (int)$products_id); } } } // added for QUICKUPDATES_NEW_COLUMN_1 if($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1]){ foreach($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1] as $products_id => $new_value) { if ($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1][$products_id] != $_POST['quick_updates_old'][QUICKUPDATES_NEW_COLUMN_1][$products_id]) { $quick_updates_count[QUICKUPDATES_NEW_COLUMN_1][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET " . QUICKUPDATES_NEW_COLUMN_1 . "='" . $new_value . "' WHERE products_id =" . (int)$products_id); } } } if($_POST['quick_updates_new']['products_name']){ foreach($_POST['quick_updates_new']['products_name'] as $products_id => $new_value) { if (trim(stripslashes($_POST['quick_updates_new']['products_name'][$products_id])) != trim(stripslashes($_POST['quick_updates_old']['products_name'][$products_id]))) { $quick_updates_count['products_name'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . " SET products_name='" . zen_db_input($new_value) . "' WHERE products_id=" . (int)$products_id . " and language_id=" . (int)$_SESSION['languages_id']); $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['products_description']){ foreach($_POST['quick_updates_new']['products_description'] as $products_id => $new_value) { if (trim(stripslashes($_POST['quick_updates_new']['products_description'][$products_id])) != trim(stripslashes($_POST['quick_updates_old']['products_description'][$products_id]))) { $quick_updates_count['products_description'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . " SET products_description='" . zen_db_input($new_value) . "' WHERE products_id=" . (int)$products_id . " and language_id=" . (int)$_SESSION['languages_id']); } } } if($_POST['quick_updates_new']['products_price']){ foreach($_POST['quick_updates_new']['products_price'] as $products_id => $new_value) { // we look if it's a price markup and if so we look if this product has been unchecked for the markup if((!isset($_POST['flag_markup'])) || ($_POST['markup_checked'][$products_id] == true)){ // not doing markups, or this product is checked for markup // (this saves a lot of obsolete hidden $_POST's, when not doing price markups) $apply_price_update = true; }else{ // doing markups, but this products is not checked $apply_price_update = false; } if (($_POST['quick_updates_new']['products_price'][$products_id] != $_POST['quick_updates_old']['products_price'][$products_id]) && $apply_price_update) { $quick_updates_count['products_price'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_price='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); // fix the sort order for prices (catalog side) zen_update_products_price_sorter((int)$products_id); } } } if($_POST['quick_updates_new']['products_weight']){ foreach($_POST['quick_updates_new']['products_weight'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_weight'][$products_id] != $_POST['quick_updates_old']['products_weight'][$products_id]) { $quick_updates_count['products_weight'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_weight='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['products_quantity']){ foreach($_POST['quick_updates_new']['products_quantity'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_quantity'][$products_id] != $_POST['quick_updates_old']['products_quantity'][$products_id]) { $quick_updates_count['products_quantity'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_quantity='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['manufacturers_id']){ foreach($_POST['quick_updates_new']['manufacturers_id'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['manufacturers_id'][$products_id] != $_POST['quick_updates_old']['manufacturers_id'][$products_id]) { $quick_updates_count['manufacturers_id'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET manufacturers_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['products_sort_order']){ foreach($_POST['quick_updates_new']['products_sort_order'] as $products_id => $new_value) { if (trim($_POST['quick_updates_new']['products_sort_order'][$products_id]) != trim($_POST['quick_updates_old']['products_sort_order'][$products_id])) { $quick_updates_count['products_sort_order'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_sort_order='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['products_image']){ foreach($_POST['quick_updates_new']['products_image'] as $products_id => $new_value) { if (trim($_POST['quick_updates_new']['products_image'][$products_id]) != trim($_POST['quick_updates_old']['products_image'][$products_id])) { $quick_updates_count['products_image'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_image='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_old']['products_status']){ foreach($_POST['quick_updates_old']['products_status'] as $products_id => $status) { if(!isset($_POST['quick_updates_new']['products_status'][$products_id])) $_POST['quick_updates_new']['products_status'][$products_id] = '0'; if ($_POST['quick_updates_new']['products_status'][$products_id] != $_POST['quick_updates_old']['products_status'][$products_id]) { $quick_updates_count['products_status'][$products_id] = $products_id; zen_set_product_status((int)$products_id, (int)$_POST['quick_updates_new']['products_status'][$products_id]); } } } if($_POST['quick_updates_new']['products_tax_class_id']){ foreach($_POST['quick_updates_new']['products_tax_class_id'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_tax_class_id'][$products_id] != $_POST['quick_updates_old']['products_tax_class_id'][$products_id]) { $quick_updates_count['products_tax_class_id'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_tax_class_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); } } } if($_POST['quick_updates_new']['categories_id']){ foreach($_POST['quick_updates_new']['categories_id'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['categories_id'][$products_id] != $_POST['quick_updates_old']['categories_id'][$products_id]) { if(zen_childs_in_category_count($new_value)) { $messageStack->add(TEXT_CATEGORY_WITH_CHILDS . ' ' . zen_get_category_name($new_value, (int)$_SESSION["languages_id"]) . ' [' . $new_value . ']', 'error'); continue; } // if the categories_id that links the master_categories_id is updated, we update the master accordingly (to prevent invalid linked master id's) if($_POST['quick_updates_old']['categories_id'] == $_POST['quick_updates_old']['master_categories_id']){ $quick_updates_count['master_categories_id'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); zen_update_products_price_sorter((int)$products_id); // needed? } $quick_updates_count['categories_id'][$products_id] = $products_id; //$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " SET categories_id='" . (int)$new_value . "', products_id=" . (int)$products_id . " WHERE products_id=" . (int)$products_id) . " AND categories_id=" . (int)$_POST['quick_updates_old']['categories_id'][$products_id]); // changed INSERT INTO to UPDATE to prevent conflicts $db->Execute("UPDATE " . TABLE_PRODUCTS_TO_CATEGORIES . " SET categories_id='" . (int)$new_value . "', products_id=" . (int)$products_id . " WHERE products_id=" . (int)$products_id . " AND categories_id=" . (int)$_POST['quick_updates_old']['categories_id'][$products_id]); } } } if($_POST['quick_updates_new']['master_categories_id']){ foreach($_POST['quick_updates_new']['master_categories_id'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['master_categories_id'][$products_id] != $_POST['quick_updates_old']['master_categories_id'][$products_id]) { if(zen_childs_in_category_count($new_value)) { $messageStack->add(TEXT_CATEGORY_WITH_CHILDS . ' ' . zen_get_category_name($new_value, (int)$_SESSION["languages_id"]) . ' [' . $new_value . ']', 'error'); continue; } // add invalid warning here?? (if the new master_cat is not linked) $quick_updates_count['master_categories_id'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id); zen_update_products_price_sorter((int)$products_id); // needed? } } } // added for products_purchase_price and margin if($_POST['quick_updates_new']['products_purchase_price']){ foreach($_POST['quick_updates_new']['products_purchase_price'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_purchase_price'][$products_id] != $_POST['quick_updates_old']['products_purchase_price'][$products_id]) { $quick_updates_count['products_purchase_price'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_purchase_price='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id); } } } // added for products_purchase_price and margin if($_POST['quick_updates_new']['products_margin']){ foreach($_POST['quick_updates_new']['products_margin'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_margin'][$products_id] != $_POST['quick_updates_old']['products_margin'][$products_id]) { $quick_updates_count['products_margin'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_margin='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id); } } } // added for p.products_price_w if($_POST['quick_updates_new']['products_price_w']){ foreach($_POST['quick_updates_new']['products_price_w'] as $products_id => $new_value) { if ($_POST['quick_updates_new']['products_price_w'][$products_id] != $_POST['quick_updates_old']['products_price_w'][$products_id]) { $quick_updates_count['products_price_w'][$products_id] = $products_id; $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_price_w='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id); } } } $quick_updates_count_string = ''; if(sizeof($quick_updates_count) > 0){ $quick_updates_count_string = '' . "\n"; foreach($quick_updates_count as $key => $value){ $quick_updates_count_string .= '' . "\n"; foreach($value as $key2 => $value2){ $quick_updates_ids[$key2] = true; } } $quick_updates_count_string .= '
' . $key . TEXT_PRODUCTS_UPDATED_IDS . ': ' . implode(', ',$value) . '
' . "\n"; $messageStack->add(sizeof($quick_updates_ids) . ' ' . TEXT_PRODUCTS_UPDATED . $quick_updates_count_string, 'success'); } break; case 'calcul' : if ($_POST['price_markup']) $preview_markup_price = true; break; } // end switch ($_GET['action']) // eof Update database // bof get products data from db //// control string sort page if ($sort_by && !ereg('order by', $sort_by)){ $sort_by = 'order by ' . $sort_by ; }else{ // added default sort order $sort_by = 'order by ' . 'products_id DESC' ; } //// controle lenght (lines per page) $split_page = $page; if ($split_page > 1) $rows = $split_page * MAX_DISPLAY_ROW_BY_PAGE - MAX_DISPLAY_ROW_BY_PAGE; $extra_query = ''; // added for products_purchase_price and margin if(QUICKUPDATES_MODIFY_PURCHASE_AND_MARGIN == 'true') $extra_query .= ' p.products_purchase_price, p.products_margin,'; // added for p.products_price_w if(QUICKUPDATES_MODIFY_WHOLESALE_PRICE == 'true') $extra_query .= ' p.products_price_w,'; // added for QUICKUPDATES_NEW_COLUMN_1 if(QUICKUPDATES_MODIFY_NEW_COLUMN_1 == 'true') $extra_query .= ' p.' . QUICKUPDATES_NEW_COLUMN_1 . ','; $products_query_raw = "select p.products_id, p.products_type, p.products_image, " . $extra_query . " p.products_model, pd.products_name, p.products_status, p.products_weight, p.products_quantity, p.manufacturers_id, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, pd.products_description, p.products_quantity_order_max, p.products_sort_order, p.master_categories_id, m.manufacturers_name, p2c.categories_id from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION["languages_id"] . "') LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id) LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON (p.products_id = p2c.products_id)"; $where = array(); if(is_numeric($_SESSION['quick_updates']['products_status'])){ $where[] = "p.products_status = '" . (int)$_SESSION['quick_updates']['products_status'] . "'"; } if ($current_category_id > 0){ $where[] = "p2c.categories_id = '" . $current_category_id . "'"; } if($manufacturer){ $where[] = "p.manufacturers_id = '" . (int)$manufacturer . "'"; } if(sizeof($where) > 0) { $products_query_raw .= " where " . implode(' and ', $where); } $products_query_raw .= " " . $sort_by; //// page splitter and display each products info $products_split = new splitPageResults($split_page, MAX_DISPLAY_ROW_BY_PAGE, $products_query_raw, $products_query_numrows); $products = $db->Execute($products_query_raw); // eof get products data from db // Let's start displaying page with forms ?> > <?php echo TITLE; ?>
0){ $image_sql = "select c.categories_image as image from " . TABLE_CATEGORIES . " c where c.categories_id=" . $current_category_id; } else { if($manufacturer){ $image_sql = "select manufacturers_image as image from " . TABLE_MANUFACTURERS . " where manufacturers_id=" . $manufacturer; } } if($image_sql != '') { $image = $db->Execute($image_sql); echo zen_image(DIR_WS_CATALOG . DIR_WS_IMAGES . $image->fields['image'], '', 40); } // eof show the current categories_image or manufacturers_image ?>
Un-Install Quick Updates
0){ echo TEXT_QUICK_COPY_REPEAT . $_SESSION['quick_updates']['quick_copy_from_id'] . ' x ' . $_SESSION['quick_updates']['quick_copy_number']; echo zen_draw_form('quickcopyfromtop', FILENAME_QUICK_UPDATES); echo zen_draw_hidden_field('quick_copy_from_id', $_SESSION['quick_updates']['quick_copy_from_id']); echo zen_draw_hidden_field('quick_updates_copy', 1) . "\n"; echo zen_draw_hidden_field('quick_copy_number', $_SESSION['quick_updates']['quick_copy_number']) . "\n"; echo zen_image_submit('button_copy.gif', BUTTON_TEXT_QUICK_COPY) . "\n"; echo '' . "\n"; ; } // eof show quick copy repeat button ?> ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; } //no idea what this line is usefull for so it's commented out echo ' ' . zen_draw_checkbox_field('marge','yes',true,'no') . ' ' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', TEXT_MARGE_INFO); if ($preview_markup_price != true) { echo TEXT_SPEC_PRICE_INFO1 ; } else { echo TEXT_SPEC_PRICE_INFO2; } ?> '; // eof toggle switch for editor ?>
array('id' => 'all', 'text' => 'All'), '1' => array('id' => '1', 'text' => 'Active'), '2' => array('id' => '0', 'text' => 'Inactive')), $_SESSION['quick_updates']['products_status'] ,'onChange="this.form.submit();"'); ?> '; ?> $_SESSION['quick_updates']['quick_copy_number'],'text' => $_SESSION['quick_updates']['quick_copy_number'] . 'x'); $array[] = array('id' => 'linked_cats','text' => 'Edit Linked Cats'); $array[] = array('id' => 'master_cats','text' => 'Edit Master Cats'); echo zen_draw_pull_down_menu('categories_switch', $array, $_SESSION['quick_updates']['categories_switch'], 'onChange="this.form.submit();"'); echo ''; ?>
EOF) { // check the previous products_id: // we do not want products that are linked to multiple categories show up multiple times! ("top cat" selected) if($prev_products_id != $products->fields['products_id']){ $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } //// check for global add value or rates, calcul and round values rates if ($flag_markup){ if (substr($_POST['price_markup'],-1) == '%') { $value = trim($_POST['price_markup'], '%'); if(strpos($_POST['price_markup'], '-') === 0){ $value = trim($value, '-'); // substract percentage $price = sprintf("%01.4f", round($products->fields['products_price'] - (($value/ 100) * $products->fields['products_price']),4)); } else { $value = trim($value, '+'); // add percentage //(add is the same as substract of course, but I retain this if/else structure because different treatment might be desired) $valeur = (1 - (ereg_replace("%", '', $_POST['price_markup']) / 100)); $price = sprintf("%01.4f", round($products->fields['products_price'] + (($value/ 100) * $products->fields['products_price']),4)); } } else { // add value $price = sprintf("%01.4f", round($products->fields['products_price'] + $_POST['price_markup'],4)); } } else { $price = $products->fields['products_price'] ; } //// Check Tax_rate for displaying TTC $tax_rate = $db->Execute("select r.tax_rate, c.tax_class_title from " . TABLE_TAX_RATES . " r, " . TABLE_TAX_CLASS . " c where r.tax_class_id=" . $products->fields['products_tax_class_id'] . " and c.tax_class_id=" . $products->fields['products_tax_class_id']); if($tax_rate->fields['tax_rate'] == '') $tax_rate->fields['tax_rate'] = 0; //// display Product Infomation Lines $tr = ''; echo $tr; //if(QUICKUPDATES_DISPLAY_ID == 'true') // we always display the id! echo '' . "\n"; if(QUICKUPDATES_DISPLAY_THUMBNAIL == 'true'){ echo '' . "\n"; } if(QUICKUPDATES_MODIFY_MODEL == 'true') { echo '' . "\n"; } // added for QUICKUPDATES_NEW_COLUMN_1 if(QUICKUPDATES_MODIFY_NEW_COLUMN_1 == 'true'){ echo '' . "\n"; } if(QUICKUPDATES_MODIFY_NAME == 'true'){ // added div wrapper to allow advanced :hover styling echo '' . "\n"; } if(QUICKUPDATES_MODIFY_DESCRIPTION == 'true'||QUICKUPDATES_MODIFY_DESCRIPTION_POPUP == 'true') { echo '\n"; if(QUICKUPDATES_MODIFY_DESCRIPTION_POPUP == 'true') { //echo '\n"; } if(QUICKUPDATES_MODIFY_MANUFACTURER == 'true') { echo '' . "\n"; } if(QUICKUPDATES_MODIFY_STATUS == 'true') { echo '' . "\n"; } if(QUICKUPDATES_MODIFY_SORT_ORDER == 'true') { echo '' . "\n"; } if(QUICKUPDATES_MODIFY_QUANTITY == 'true') { echo '' . "\n"; } // added for products_purchase_price and margin if(QUICKUPDATES_MODIFY_PURCHASE_AND_MARGIN == 'true'){ $parameters = 'size="6" onKeyUp="updateMargin(' . $products->fields['products_id'] . ');"'; echo '' . "\n"; } // added for products_purchase_price and margin if(QUICKUPDATES_MODIFY_PURCHASE_AND_MARGIN == 'true'){ //if ($products->fields['products_margin'] == 0 ) $zeroWarning= ' *'; else $zeroWarning = ''; $parameters = 'size="6"'; echo '' . "\n"; } // added for p.products_price_w if(QUICKUPDATES_MODIFY_WHOLESALE_PRICE == 'true'){ $parameters = 'size="' . QUICKUPDATES_MODIFY_WHOLESALE_PRICE_INPUT_SIZE . '"'; echo '' . "\n"; } //// get the specials products list $specials_array = array(); $specials = $db->Execute("select p.products_id, s.products_id, s.specials_id from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = p.products_id"); while (!$specials->EOF) { $specials_array[] = $specials->fields['products_id']; $specials->MoveNext(); } //// check specials $parameters = 'size="6"'; if(QUICKUPDATES_DISPLAY_TVA_PRICES == 'true'){ // updateMargin on products_price(was only on products_purchase_price before) $parameters .= ' onKeyUp="updateGross(' . $products->fields['products_id'] . '); updateMargin(' . $products->fields['products_id'] . ');"'; } if (in_array($products->fields['products_id'], $specials_array)){ $spec = $db->Execute("select s.products_id, s.specials_id from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = " . (int)$products->fields['products_id'] . ""); $flag_special = true; echo '' . "\n"; echo '' . "\n"; if(QUICKUPDATES_MODIFY_WEIGHT == 'true') { echo '' . "\n"; } if(QUICKUPDATES_MODIFY_TAX == 'true') { echo '' . "\n"; } if(QUICKUPDATES_MODIFY_CATEGORY == 'true') { //products_to_categories.php?products_filter=198 $zen_get_master_categories_pulldown = zen_get_master_categories_pulldown($products->fields['products_id']); /* if(!in_array($products->fields['categories_id'], $zen_get_master_categories_pulldown)){ //exit('error'); } */ $multilinked = false; if(count($zen_get_master_categories_pulldown) > 2){ $multilinked = true; } $invalidcat = false; if(($multilinked == false)&&($products->fields['master_categories_id'] != $products->fields['categories_id'])){ $invalidcat = true; } $prod2cat_link = '(' . $products->fields['categories_id'] . '/' . $products->fields['master_categories_id']. ')'; // echo '' . "\n"; } // eof QUICKUPDATES_MODIFY_CATEGORY //// links to preview or full edit $type_handler = $zc_products->get_admin_handler($products->fields['products_type']); if(QUICKUPDATES_DISPLAY_PREVIEW == 'true') echo '' . "\n"; if(QUICKUPDATES_DISPLAY_EDIT == 'true') echo '' . "\n"; echo ''; // bof export viewed products paulm // (= preparation to post to external script + quick copy function) $export_products[$products->fields['products_id']]['products_model'] = $products->fields['products_model']; if(defined('QUICKUPDATES_NEW_COLUMN_1')){ $export_products[$products->fields['products_id']][QUICKUPDATES_NEW_COLUMN_1] = $products->fields[QUICKUPDATES_NEW_COLUMN_1]; } // eof export viewed products paulm $prev_products_id = $products->fields['products_id']; } // eof if($prev_products_id != $products->fields['products_id']){ $products->MoveNext(); } // eof walk products object ?>
'; // added for external links paulm if (defined('QUICKUPDATES_DISPLAY_ID_INFO')){ // handler page needed for products type $handler_page = ''; //$handler_page = ? echo sprintf(QUICKUPDATES_DISPLAY_ID_INFO, $products->fields['products_id'], $handler_page, zen_image(DIR_WS_IMAGES . 'icon_info.gif', QUICKUPDATES_DISPLAY_ID_INFO_ALT)); } echo $products->fields['products_id']; echo '' . zen_draw_hidden_field('quick_updates_new[products_image][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_image']), 'id="SelectImageName_' . $products->fields['products_id'] . '"') . zen_draw_hidden_field('quick_updates_old[products_image][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_image'])) . '' . zen_image(DIR_WS_CATALOG_IMAGES . $products->fields['products_image'], TEXT_SELECT_IMAGE, QUICKUPDATES_DISPLAY_THUMBNAIL_WIDTH, QUICKUPDATES_DISPLAY_THUMBNAIL_HEIGHT, 'id="SelectImageName_' . $products->fields['products_id'] . '_img"') . '' . ''; echo zen_draw_input_field('quick_updates_new[products_model][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_model']), 'size="12"') . zen_draw_hidden_field('quick_updates_old[products_model][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_model'])); // added for external links paulm if (defined('QUICKUPDATES_MODIFY_MODEL_INFO')){ echo sprintf(QUICKUPDATES_MODIFY_MODEL_INFO, $products->fields['products_id'], stripslashes($products->fields['products_model']), zen_image(DIR_WS_IMAGES . 'icon_info.gif', stripslashes($products->fields['products_model']))); } echo ''; $parameters = 'size="6"'; echo zen_draw_input_field('quick_updates_new[' . QUICKUPDATES_NEW_COLUMN_1 . '][' . $products->fields['products_id'] . ']', stripslashes($products->fields[QUICKUPDATES_NEW_COLUMN_1]), $parameters) . zen_draw_hidden_field('quick_updates_old[' . QUICKUPDATES_NEW_COLUMN_1 . '][' . $products->fields['products_id'] . ']', stripslashes($products->fields[QUICKUPDATES_NEW_COLUMN_1])); // added for external links paulm if (defined('QUICKUPDATES_QUICKUPDATES_NEW_COLUMN_1_INFO')){ echo sprintf(QUICKUPDATES_QUICKUPDATES_NEW_COLUMN_1_INFO, $products->fields['products_id'], stripslashes($products->fields[QUICKUPDATES_NEW_COLUMN_1]), zen_image(DIR_WS_IMAGES . 'icon_info.gif', stripslashes($products->fields[QUICKUPDATES_NEW_COLUMN_1]))); } echo '
' . zen_draw_input_field('quick_updates_new[products_name][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_name']), 'size="16"') . zen_draw_hidden_field('quick_updates_old[products_name][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_name'])) . '
'; // no need to display description when popup edit is enabled (?) if(QUICKUPDATES_MODIFY_DESCRIPTION_POPUP == 'true') echo '
'; echo zen_draw_textarea_field('quick_updates_new[products_description][' . $products->fields['products_id'] . ']', 'soft', 200, 2, stripslashes($products->fields['products_description']), 'id="description_' . $products->fields['products_id'] . '"') . zen_draw_hidden_field('quick_updates_old[products_description][' . $products->fields['products_id'] . '] ', stripslashes($products->fields['products_description'])); if(QUICKUPDATES_MODIFY_DESCRIPTION_POPUP == 'true') echo '
'; //echo "
' echo '' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', TEXT_HTML_EDIT_DESC) . '' . stripslashes($products->fields['products_description']) . ''; } echo "' . zen_draw_pull_down_menu('quick_updates_new[manufacturers_id][' . $products->fields['products_id'] . ']', $manufacturers_array, $products->fields['manufacturers_id'], 'style="width: 6em;"') . zen_draw_hidden_field('quick_updates_old[manufacturers_id][' . $products->fields['products_id'] . ']', $products->fields['manufacturers_id']) . '' . zen_draw_checkbox_field('quick_updates_new[products_status][' . $products->fields['products_id'] . ']', 1, false, $products->fields['products_status'], '') . zen_draw_hidden_field('quick_updates_old[products_status][' . $products->fields['products_id'] . ']', $products->fields['products_status']) . '' . zen_draw_input_field('quick_updates_new[products_sort_order][' . $products->fields['products_id'] . ']', $products->fields['products_sort_order'], 'size="3"') . zen_draw_hidden_field('quick_updates_old[products_sort_order][' . $products->fields['products_id'] . ']', $products->fields['products_sort_order']) . '' . zen_draw_input_field('quick_updates_new[products_quantity][' . $products->fields['products_id'] . ']', $products->fields['products_quantity'], 'size="3"') . zen_draw_hidden_field('quick_updates_old[products_quantity][' . $products->fields['products_id'] . ']', $products->fields['products_quantity']) . '' . zen_draw_input_field('quick_updates_new[products_purchase_price][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_purchase_price']), $parameters) . zen_draw_hidden_field('quick_updates_old[products_purchase_price][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_purchase_price'])) . '' . zen_draw_input_field('quick_updates_new[products_margin][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_margin']), $parameters) . zen_draw_hidden_field('quick_updates_old[products_margin][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_margin'])) . '' . zen_draw_input_field('quick_updates_new[products_price_w][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_price_w'])) . zen_draw_hidden_field('quick_updates_old[products_price_w][' . $products->fields['products_id'] . ']', stripslashes($products->fields['products_price_w']), $parameters) . ''; }else{ $flag_special = false; echo ''; } echo zen_draw_input_field('quick_updates_new[products_price][' . $products->fields['products_id'] . ']', $price, $parameters); if ($flag_markup){ echo zen_draw_checkbox_field('markup_checked[' . $products->fields['products_id'] . ']', '1', (!($flag_special)&&($_POST['marge']))); //echo zen_draw_hidden_field('markup[' . $products->fields['products_id'] . ']', '1'); } else { // this has become obsolete since we changed prices to update by default when markup is not set //echo zen_draw_hidden_field('update_price[' . $products->fields['products_id'] . ']', 'yes'); } if($flag_special){ echo ' '. zen_image(DIR_WS_IMAGES . 'icon_info.gif', TEXT_SPECIALS_PRODUCTS) . ''; } if(QUICKUPDATES_DISPLAY_TVA_PRICES == 'true'){ $parameters = 'size="6"'; $parameters .= ' onKeyUp="updateNet(' . $products->fields['products_id'] . '); updateMargin(' . $products->fields['products_id'] . ');"'; // $taxprice needs the $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] to be set (done at top of file) // an alternative might be to use $price (i.s.o. $taxprice) and update it with updatGross('$products->fields['products_id']') for each product ?) $tax_price = zen_add_tax($price, $tax_rate->fields['tax_rate']); $tax_price = sprintf("%01.2f", round($tax_price, 4)); echo '' . zen_draw_input_field('quick_updates_new[products_taxprice][' . $products->fields['products_id'] . ']', $tax_price, $parameters); //echo zen_draw_hidden_field('update_taxprice['.$products->fields['products_id'].']','yes'); echo zen_draw_hidden_field('quick_updates_old[products_tax_value]['.$products->fields['products_id'].']', $tax_rate->fields['tax_rate']); } echo zen_draw_hidden_field('quick_updates_old[products_price][' . $products->fields['products_id'] . ']', $products->fields['products_price']); echo '' . zen_image(DIR_WS_IMAGES . 'icon_products_price_manager.gif', QUICKUPDATES_PPM_LINK_ALT) . ''; echo '' . zen_draw_input_field('quick_updates_new[products_weight][' . $products->fields['products_id'] . ']', $products->fields['products_weight'], 'size="4"') . zen_draw_hidden_field('quick_updates_old[products_weight][' . $products->fields['products_id'] . ']', $products->fields['products_weight']) . '' . zen_draw_pull_down_menu('quick_updates_new[products_tax_class_id][' . $products->fields['products_id'] . ']', $tax_class_array, $products->fields['products_tax_class_id'], 'style="width: 5em;"') . zen_draw_hidden_field('quick_updates_old[products_tax_class_id][' . $products->fields['products_id'] . ']', $products->fields['products_tax_class_id']) . ''; if($_SESSION['quick_updates']['categories_switch'] == 'master_cats'){ // show/edit the master cats products table echo zen_draw_pull_down_menu('quick_updates_new[master_categories_id][' . $products->fields['products_id'] . ']', zen_get_master_categories_pulldown($products->fields['products_id']), $products->fields['master_categories_id']); }else{ // show/edit the linked cats products_to_categories table if($invalidcat == true){ echo TEXT_QU_CHECK_CAT_INVALID; }elseif($multilinked == true){ echo TEXT_QU_CHECK_CAT_MULTILINKS; }else{ echo zen_draw_pull_down_menu('quick_updates_new[categories_id][' . $products->fields['products_id'] . ']', $quick_updates_category_tree, $products->fields['categories_id'], ''); echo zen_draw_hidden_field('quick_updates_old[categories_id][' . $products->fields['products_id'] . ']', $products->fields['categories_id']); } } // we need the old master_categories_id value in both cases echo zen_draw_hidden_field('quick_updates_old[master_categories_id][' . $products->fields['products_id'] . ']', $products->fields['master_categories_id']); echo $prod2cat_link; echo '' . zen_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '
' . PRINT_TEXT . '  '; echo zen_image_submit('button_update.gif', IMAGE_UPDATE); echo '  ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; // eof display bottom page buttons ?>
display_count($products_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, $split_page, TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> display_links($products_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, MAX_DISPLAY_PAGE_LINKS, $split_page); ?>
'; foreach($export_products as $key => $value){ //echo zen_draw_hidden_field('selected_product[' . $key . ']', $value) . "\n"; echo zen_draw_hidden_field('export_products[' . $key . '][products_model]', $value['products_model']) . "\n"; if (defined('QUICKUPDATES_NEW_COLUMN_1')){ echo zen_draw_hidden_field('export_products[' . $key . '][' . QUICKUPDATES_NEW_COLUMN_1 . ']', $value[QUICKUPDATES_NEW_COLUMN_1]) . "\n"; } } echo zen_image_submit('button_update.gif', 'Export products'); echo ''; } ?> fields['products_id']]['products_model'] if (zen_products_id_valid(QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT)){ $quick_copy_from_array[] = array( 'id' => QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT, 'text' => 'id:' . QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT . ' (' . TEXT_QUICK_COPY_PRODUCT_ID_DEFAULT . ')' ); } foreach((array)$export_products as $key => $value){ if(!empty($value['products_model'])) $text = ' (' . $value['products_model'] . ')'; $quick_copy_from_array[] = array( 'id' => $key, 'text' => 'id:' . $key . $text ); } echo zen_draw_form('quickcopyfrom', FILENAME_QUICK_UPDATES); echo zen_draw_pull_down_menu('quick_copy_from_id', $quick_copy_from_array, $_SESSION['quick_updates']['quick_copy_from_id']); $array = array(); //$array[] = array('id' => $_SESSION['quick_updates']['quick_copy_number'],'text' => $_SESSION['quick_updates']['quick_copy_number'] . 'x'); $array[] = array('id' => 0,'text' => '0x'); $array[] = array('id' => 1,'text' => '1x'); $array[] = array('id' => 10,'text' => '10x'); echo zen_draw_pull_down_menu('quick_copy_number', $array, $_SESSION['quick_updates']['quick_copy_number']); echo zen_draw_hidden_field('quick_updates_copy', 1) . "\n"; echo zen_image_submit('button_copy.gif', BUTTON_TEXT_QUICK_COPY) . "\n"; ?>