$return = createPromotion($mobile, $rule_id); $errorcode = $return['errorcode']; $success = $return['success']; $promotions = $return['data']; if ($success != 1) { throw new Exception($return['data']); } } else { if ($method == 'use' or $method = 'disable') { if (isset($param['additional']) and trim($param['additional'] != '')) { $promotion_id = $param['additional']; } else { $errorcode = 10029; throw new Exception("NO_PROMOTION_ID_WHEN_USE_OR_DISABLE_PROMORION"); } $return = updatePromotion($promotion_id, $method); $errorcode = $return['errorcode']; $success = $return['success']; $promotions = $return['data']; if ($success == 0) { throw new Exception($return['data']); } } else { $errorcode = 10030; throw new Exception("INVALID_METHOD"); } } } $result = array("data" => $promotions, "success" => 1, "errorcode" => 0); if (isset($param['array']) and trim($param['array']) != '') { dump_msg($result);
<title>Aptaris - Advertisement Event System</title> <div class="header"><a href="index.html"> <img src="images/logo_100.jpg" alt="logo" /> <h1>Advertisement Event System - Update a Promotion</h1></a> <br/><hr/> </div> </head> <body> <center> <?php require 'db_connect.inc'; connect(); //Update promotion in the database updatePromotion(); function updatePromotion() { $promoCode = $_POST['promoCode']; $promoName = $_POST['promoName']; $description = $_POST['promoDescription']; $amountOff = $_POST['amountOff']; $promoType = $_POST['promoType']; if ($promoType == 'Percent' && $amountOff >= 1) { $amountOff = str_replace("%", "", $amountOff); $amountOff = $amountOff / 100; } $updateStatement = "Update Promotion SET Name = '" . $promoName . "', Description = '" . $description . "', AmountOff = '" . $amountOff . "', PromoType = '" . $promoType . "' WHERE PromoCode = '" . $promoCode . "'"; // Execute the query--it will return either true or false $result = mysql_query($updateStatement); $message = "";