{NAME} EOF; function addProduct($input) { global $table,$masterError; if(!isset($input['make']) || empty($input['make'])) { $masterError .= "Input field 'make' isn't set.
\n"; } if(!isset($input['modal']) || empty($input['modal'])) { $masterError .= "Input field 'modal' isn't set.
\n"; } if(!isset($input['man']) || empty($input['man'])) { $masterError .= "Input field 'manufacturer' isn't set.
\n"; } if(!isset($input['cat']) || empty($input['cat'])) { $masterError .= "Input field 'category' isn't set.
\n"; } if($input['printer']=="no") { if(!isset($input['price']) || empty($input['price'])) { $masterError .= "Input field 'price' isn't set.
\n"; } $input['price'] = str_replace(",",NULL,$input['price']); $input['price'] = number_format($input['price'],2); $input['price'] = str_replace(",",NULL,$input['price']); if(!ereg("^[0-9]+(.[0-9]{2})?$", $input['price'])) { $masterError .= "The price is invalid. Please input a value with two optional decimal points."; } } else { $input['price'] = ""; } $printer = $input['printer']=="yes"?TRUE:FALSE; if($printer) { $accessory = $input['accessory']=="yes"?TRUE:FALSE; $parentPrinter = $accessory?$input['parentPrinter']:FALSE; } $disabled = $input['disabled']?TRUE:FALSE; if($masterError) { return FALSE; } if(mysql_query("INSERT INTO {$table['products']} (`make`,`modal`,`category`,`manufacturer`,`price`,`description`,`active`,`accessory`,`printer`,`isPrinter`) VALUES ('{$input['make']}','{$input['modal']}','{$input['cat']}','{$input['man']}','{$input['price']}','{$input['description']}','" . ($disabled?"0":"1") . "','" . ($accessory?"1":"0") . "','" . (isset($parentPrinter)?$parentPrinter:"0") . "','" . ($printer?"1":"0") . "')")) { return TRUE; } else { $masterError = mysql_error(); return FALSE; } } if(isset($_POST['submit'])) { if($_POST['submit'] == "Add New Product") { if(addProduct($_POST['product'])) { if($_POST['action'] == "done") { header("Location: " . $site['urlroot'] . "/acp/index.php?page=viewproducts&view=" . $_POST['product']['cat']); exit; } else if($_POST['action'] == "another") { $masterSuccess .= "Successfully added a product.
\n"; unset($_POST['product']); } } else { $masterError = "There was a problem submitting the new product:
\n".$masterError; } } } ?>
Add Product
Make
Modal
Manufacturer
Category
Description:
Is this product a printer?
Printers aren't for sale. Only used for customer profiles.
Yes /> No />
;"> To which printer does this accessory belong?
;">
Disabled: />
Disabled products are no longer available for order. Also note that products can not be deleted but can only be edited or disabled.
Price
$ (0000.00)
/> Submit and go back to the category product list.
/> Submit and submit another.