/* * $sql = sprintf("DELETE FROM bundle_categories WHERE categoryid = %d", $catid); * $res = $pdb->query($sql); * $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 {
$SHOWFORM = true; } /** either show an adding/editing form **************************************************/ if ($SHOWFORM) { $c = CSHOP_CLASSES_PRODUCT; $pc = new $c($pdb); $fex = new formex(); $fex->js_src_inline = true; $fex->left_td_style = ''; $fex->field_prefix = ''; $fex->add_element($sm->colmap_zones); // all those things in $colmap are in the form now $fex->add_element('op', array($ACTION, 'submit')); // the button $country_opts = formex::get_country_opts(true); $fex->set_element_opts('cm_shipmethods_zone_locales', $country_opts); if ($ACTION == OP_EDIT) { $vals = $sm->fetch_zone($req_id); /* convert linear array of ISO codes to isocode => countryname */ $cy = array(); foreach ($vals['cm_shipmethods_zone_locales'] as $iso) { $cy[$iso] = $country_opts[$iso]; } $vals['cm_shipmethods_zone_locales'] = $cy; $fex->elem_vals = $vals; $method_title = $vals['zone_name']; $fex->add_element('id', array('hid id', 'hidden', $req_id)); // important } else { $method_title = 'ADD NEW ZONE'; }
} } } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_error_handler'); } if ($msg and !count($errs)) { /** redir on success **/ header(sprintf("Location: %s?nid=%d&msg=%s", $_SERVER['PHP_SELF'], $productid, base64_encode($msg))); exit; } /** build form **/ $fex = new formex('POST'); $allproducts = $pc->get_product_list(); $fex->js_src_inline = true; $fex->add_element($colmap); $fex->set_element_opts('cm_products_relations', $allproducts); $fex->add_element('op', array($ACTION, 'submit', null, null, 1)); $fex->add_element('nid', array('id', 'hidden', $productid, 1)); $fex->set_elem_default_vals('cm_products_relations', $pc->fetch_related_products()); /** **/ // get message for display if any if (isset($_GET['msg'])) { $msg = base64_decode($_GET['msg']); } # output template ############################################################################## ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>product media control framelet</title>
$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');
} } } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_error_handler'); } if ($msg and !count($errs)) { /** redir on success **/ header(sprintf("Location: %s?nid=%d&msg=%s", $_SERVER['PHP_SELF'], $productid, base64_encode($msg))); exit; } /** build form **/ $fex = new formex('POST'); $allcats = $pcat->get_categories_for_select(0, 0, true); $fex->js_src_inline = true; $fex->add_element($colmap); $fex->set_element_opts('cm_products_categories', $allcats); $fex->add_element('op', array($ACTION, 'submit', null, null, 1)); $fex->add_element('nid', array('id', 'hidden', $productid, 1)); $product_info = $pc->fetch(array('title'), true); $fex->set_elem_default_vals('cm_products_categories', $product_info['cm_products_categories']); /** **/ // get message for display if any if (isset($_GET['msg'])) { $msg = base64_decode($_GET['msg']); } # output template ############################################################################## ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head>
$SUCCESS = "inventory record removed from the system"; } } /** 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("-");
$smarty->assign('giftcards', $inactive_giftcards); } /* ORDER UPDATE FORM - built in the USA */ $fex = new formex('POST'); $fex->js_src_inline = true; $fex->field_prefix = ''; $fex->max_size = 25; $fex->add_element($order->colmap); /* add elements for the customer notify */ $fex->add_element('do_notify', array('Notify Customer?', 'toggle')); $fex->add_element('comments', array('Comments', 'textarea')); $fex->add_element('op_update', array('UPDATE', 'submit')); // the button $fex->add_element($reqIdKey, array(null, 'hidden', $itemid)); // important $fex->set_element_opts('orders_status', $order->get_statuses()); $fex->elem_vals = $orderinfo; if (empty($orderinfo['ship_date'])) { $fex->elem_vals['ship_date'] = date('Y-m-d'); } if (empty($orderinfo['delivery_date'])) { $fex->elem_vals['delivery_date'] = date('Y-m-d'); } $smarty->assign('upform', $fex->get_struct()); $pagetitle = 'ORDER DETAIL - ' . $itemid; /* */ $SHOWFORM = 1; } else { /** create filter form **/ $filter_columns = array('order.id' => 'Order ID', 'order.token' => 'Order Number', 'user.email' => 'customer email', 'user.name' => 'customer name'); $filt = new filter_form('GET');
$msg = "Product was successfully removed from the site"; } header("Location: store.edit.list.php?info=" . base64_encode($msg)); } 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}')\""));