$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.');