* $sql = sprintf("DELETE FROM categories WHERE id = %d", $catid); * $res = $pdb->query($sql); */ $msg = "The selected category was totally removed."; // send back to self with messageness header("Location: {$_SERVER['PHP_SELF']}?info=" . base64_encode($msg)); } if ($SHOWFORM) { $fex = new formex('POST'); $fex->js_src_inline = true; $fex->add_element($colmap); // all those things in $colmap are in the form now $fex->set_element_opts('ship_class_id', $shipTypes); $fex->add_element('op', array($ACTION, 'submit')); // the button $fex->set_element_opts('parent_cat_id', cshopUtils::get_all_parent_categories($pdb)); if ($ACTION == OP_EDIT) { $sql = sprintf("SELECT name, descrip, ship_class_id, is_taxable, level, feature_rank, is_active, parent_cat_id , order_weight\n , m.filename AS icon_media_id\n FROM cm_categories c LEFT JOIN cm_media_files m ON (m.id = c.icon_media_id)\n WHERE c.id = %d", $catid); $fex->elem_vals = $pdb->getRow($sql); $fex->add_element('id', array('hid id', 'hidden', $catid, null)); // important $cat_name = $fex->elem_vals['name']; /** if there are zero products in this category, let them delete it **/ $sql = sprintf("SELECT COUNT(*) FROM cm_products_categories WHERE cm_categories_id = %d", $catid); $product_count = $pdb->getOne($sql); if ($product_count) { $confirm_msg = "There are {$product_count} products that are in this category. If you delete the category, they may be hidden from customers. Are you sure?"; } else { $confirm_msg = 'This will remove this category from the site permanently. Are you sure?'; } $fex->add_element('op_kill', array(OP_KILL, 'submit', null, null, 'onclick="return confirm(\'' . $confirm_msg . '\')"'));
$msg = "Product media file was successfully removed"; } } } if ($msg and !count($errs)) { /** redir on success **/ header(sprintf("Location: %s?nid=%d&msg=%s", $_SERVER['PHP_SELF'], $productid, base64_encode($msg))); exit; } if ($ACTION == OP_ADD or $ACTION == OP_EDIT) { $fex = new formex('POST'); $fex->js_src_inline = true; $fex->add_element($colmap); $fex->add_element('op', array($ACTION, 'submit', null, null, 1)); $fex->add_element('nid', array('id', 'hidden', $productid, null)); $fex->set_element_opts('colorways_id', cshopUtils::get_all_colors($pdb, true)); if ($ACTION == OP_EDIT) { $sql = sprintf("SELECT colorways_id, order_weight, class, filename_large AS upfile\n FROM {$tablename} WHERE id = %d", $reqid); $row = $pdb->getRow($sql); $fex->elem_vals = $row; $fex->add_element('reqid', array('reqid', 'hidden', $reqid, null)); $fex->add_element('op_kill', array(OP_KILL, 'submit', null, null, 'onclick="return confirm(\'Are you sure?\')"')); } } else { /** list all cm_categories in one big ass dump using HTML_Table **/ $table = new fu_HTML_Table(array('width' => '90%', 'align' => 'center')); $table->setAutoGrow(true); $table->setAutoFill("-"); $header_row = array('class' => 'Class', 'filename_fmt' => 'File Name', 'colorname' => 'Colorway', 'order_weight' => 'weight'); $table->addRow(array_values($header_row), null, 'TH'); $table->addCol(array(' '), 'align="center"', 'th');
} } /** setup the form that goes at the top */ $pc->set_id($productid); $onchange = 'onchange="cmSetSkuField()"'; $fex = new formex('POST'); $fex->add_element('sizes', array('Size', 'select', array(), null, $onchange, 1)); $fex->add_element('colors', array('Colors', 'select', array(), null, $onchange, 1)); $fex->add_element('qty', array('Qty', 'text', 1, array('size' => 3, 'maxlength' => 6), 1)); $fex->add_element('sku', array('SKU', 'text', '', array('size' => 16, 'maxlength' => 64), 1)); if ($USE_ADDERS) { $fex->add_element('adder', array('Adder', 'text', '0.00', array('size' => 7, 'maxlength' => 10), 'onchange="cmAddPrice(this.value)"', 1)); } $fex->add_element('nid', array('id', 'hidden', $productid, null)); $fex->set_element_opts('sizes', array('' => '-----') + cshopUtils::get_all_sizes($pdb)); $fex->set_element_opts('colors', array('' => '-----') + cshopUtils::get_all_colors($pdb)); if (isset($invid) and $ACTION == OP_EDIT) { $sql = sprintf("SELECT i.sizes_id AS sizes, i.colorways_id AS colors, i.qty, i.sku, adder\n , IFNULL((p.price + adder), p.price) AS total_price\n FROM {$inventory_table} i, cm_products p WHERE i.id = %d AND p.id = i.product_id", $invid); $inv_record = $pdb->getRow($sql); $fex->elem_vals = $inv_record; $killlink = sprintf('%s?op_kill=%d&nid=%d', $_SERVER['PHP_SELF'], $invid, $productid); } /* get the product SKU as a base, for the JS magic in the Size/Color selects */ $sku_base = $pc->get_header('sku'); $base_price = $pc->get_header('price'); $total_price = isset($inv_record) ? $inv_record['total_price'] : $base_price; /** list all inventory records in one big ass dump using HTML_Table **/ $table = new fu_HTML_Table(array('width' => '90%', 'align' => 'center')); $table->setAutoGrow(true); $table->setAutoFill("-"); $header_row = array('sku' => 'SKU', 'size' => 'size', 'color' => 'Color', 'qty' => 'Qty.');
*/ require_once CONFIG_DIR . 'cshop.config.php'; require_once "fu_HTML_Table.class.php"; require_once "filter_form.class.php"; require_once "res_pager.class.php"; require_once "store.edit.inc.php"; /** **/ $range = 50; $offset = isset($_GET['page']) ? ($_GET['page'] - 1) * $range : 0; $filt = new filter_form('GET'); $filt->left_td_style = ''; $filt->field_prefix = ''; $filt->add_element('hdr1', array('Category:', 'heading')); $filt->add_element('cat', array('', 'select', cshopUtils::get_all_categories($pdb, true))); $filt->add_element('hdr2', array('Manufacturer', 'heading')); $filt->add_element('mfr', array('', 'select', cshopUtils::get_all_manufacturers($pdb, true))); $filt->add_element('hdr3', array('SKU', 'heading')); $filt->add_element('sku', array('', 'text', '', array('size' => 5))); $filt->add_element('op_filter', array('GO', 'submit')); /** if there were things selected in the filter forms then make up some WHERE * clauses to narrow the results */ $where = ''; $getvars = ''; if (isset($_GET['mfr']) or isset($_GET['cat'])) { $where = 'WHERE 1=1 '; if (!empty($_GET['mfr'])) { $where .= ' AND cm_manufacturers_id = ' . $pdb->quoteSmart($_GET['mfr']); $getvars .= '&mfr=' . urlencode($_GET['mfr']); } if (!empty($_GET['cat'])) { $where .= ' AND pc.cm_categories_id = ' . $pdb->quoteSmart($_GET['cat']);
} if ($SHOWFORM) { $fex->left_td_style = ''; if ($ACTION == OP_EDIT) { $pc->set_id($productid); } if (isset($pc->colmap_help) && is_array($pc->colmap_help)) { foreach ($pc->colmap_help as $k => $text) { $fex->set_elem_helptext($k, $text); } } if (isset($colmap['cm_manufacturers_id'])) { $fex->set_element_opts('cm_manufacturers_id', cshopUtils::get_all_manufacturers($pdb)); } if (isset($colmap['cm_ship_class_id'])) { $fex->set_element_opts('cm_ship_class_id', cshopUtils::get_all_ship_classes($pdb)); } if ($ACTION == OP_EDIT) { $fex->elem_vals = $pc->fetch(null, true); $product_name = $fex->elem_vals['title']; $fex->add_element('id', array('', 'hidden', $productid, null)); // important } $fex->add_element('op', array($ACTION, 'submit')); // the button if ($ACTION == OP_EDIT) { $confirm_msg = 'This will remove this product from the site permanently. Are you sure?'; $fex->add_element('op_kill', array(OP_KILL, 'submit', null, array('class' => 'killButton'), "onclick=\"return confirm('{$confirm_msg}')\"")); } } /* decide which tab to show based on GET param 'win' */