require("common.php"); require("libs/Smarty.class.php"); //debug($HTTP_POST_VARS); $action = $HTTP_POST_VARS['action']; $Error = array(); if($action == "customersSubmit"){ $order = array(); $order['products'] = array(); $order['total'] = 0; if(is_array($HTTP_POST_VARS['products'])){ //user selected a predefined product $checks = $HTTP_POST_VARS['products']; foreach($checks as $k=>$v){ $product = select_one("bmad_products","id",$k); if($product != NULL){ array_push($order['products'],$product); $order['total'] += $product['cost']; } } if($order['total'] > 0){ $order['hash'] = md5(time().$order['total'].$_SERVER['REMOTE_ADDR']); $order['type'] = "CUSTOMERS"; //submit to paypal submitToPaypal($order); } } else if(($HTTP_POST_VARS['user_product_name']!="")||($HTTP_POST_VARS['user_product_cost']!="")){ $u_product_name = $HTTP_POST_VARS['user_product_name']; $u_product_cost = $HTTP_POST_VARS['user_product_cost']; if($u_product_name == ""){ array_push($Error,"PRODUCT_NAME_MISSING"); } if($u_product_cost == ""){ array_push($Error,"PRODUCT_COST_MISSING"); } if(count($Error) == 0){ $product = array(); $product['name'] = $u_product_name; $product['cost'] = $u_product_cost; array_push($order['products'],$product); $order['total'] = $product['cost']; $order['hash'] = md5(time().$order['total'].$_SERVER['REMOTE_ADDR']); $order['type'] = "CUSTOMERS"; //submit to paypal submitToPaypal($order); } } else{ array_push($Error,"PLEASE_SELECT_PRODUCT"); } } $smarty = new Smarty; $smarty->compile_check = true; $smarty->debugging = false; foreach($_APP['variables'] as $key=>$val){ $smarty->assign($key,$val); } $smarty->assign("lang",$_LANG); $smarty->assign("errors",translate($Error)); $smarty->assign("u_product_name",$u_product_name); $smarty->assign("u_product_cost",$u_product_cost); $smarty->assign("products",select("bmad_products")); $smarty->assign("customers",select("bmad_customers")); $smarty->display("customers.tpl"); include_once('footer.inc.php'); ?>