$reset = "hidden"; } else { $reset = ""; } /* --- BUTTON HANDLER --- */ if (isset($_POST['btn-sale']) && $_POST['btn-sale'] == 'Apply Discount') { $promo_id = filter_var($_POST['category'], FILTER_SANITIZE_STRING); $promo_type_id = $_POST['type_id']; $promo_value = filter_var($_POST['promo_value'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $promo_start = cleanurl($_POST['date_from']); $promo_end = cleanurl($_POST['date_to']); foreach ($promo_type_id as $promo_type_id) { $promo_type_id = filter_var($promo_type_id, FILTER_SANITIZE_STRING); $count_item = $_get->count_sale_items($promo_type_id); if ($count_item->rows > 0) { $_update->deleteSale($promo_type_id); } $_update->updateSale($promo_id, $promo_type_id, $promo_value, $promo_start, $promo_end); } $page = 'self'; $type = 'success'; $msg = 'Successfully added promo(s)'; set_alert($type, $msg); safe_redirect($page); } else { if (isset($_POST['btn-sale']) && $_POST['btn-sale'] == "Remove All Discounts") { $_update->deleteAllSale('1'); $page = 'self'; $type = 'success'; $msg = 'Successfully deleted all promo(s)'; set_alert($type, $msg);
} else { $reset = ""; } /* --- REMOVE EXPIRED SALE --- */ $d = date('d'); $m = date('m'); $y = date('Y'); $s = date('s'); $i = date('i'); $h = date('H'); $today = $y . '-' . $m . '-' . $d . ' ' . $h . ':' . $i . ':' . $s; $countExpiredSale = $_get->countExpiredItem($today); if ($countExpiredSale->rows > 0) { $getExpiredSale = $_get->getExpiredItem($today); foreach ($getExpiredSale as $getExpiredSales) { $_update->deleteSale($getExpiredSales->product_type_id); } } /* --- BUTTON HANDLER --- */ if (isset($_POST['btn-sale']) && $_POST['btn-sale'] == 'Apply Discount') { $promo_id = filter_var($_POST['category'], FILTER_SANITIZE_STRING); $promo_type_id = $_POST['type_id']; $promo_value = filter_var($_POST['promo_value'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $promo_start = cleanurl($_POST['date_from']); $promo_end = cleanurl($_POST['date_to']); foreach ($promo_type_id as $promo_type_id) { $promo_type_id = filter_var($promo_type_id, FILTER_SANITIZE_STRING); $count_item = $_get->count_sale_items($promo_type_id); if ($count_item->rows > 0) { $_update->deleteSale($promo_type_id); }