function rate_article($aid, $rate, $uid) { $rated = check_if_user_rate_article($aid, $uid); if ($rated) { update_rate($aid, $rate, $uid); } else { add_rate($aid, $rate, $uid); } }
function rate_change() { global $_STATE; if ($_SERVER['REQUEST_METHOD'] == "POST") { //POST carries rate data save_input(); $_STATE->replies = array(); } else { foreach ($_GET as $field => $reply) { //GET carries replies $_STATE->replies[$field] = $reply; } } if (!audit_input()) { return; } if ($_STATE->rates[$_STATE->rate_ndx]["ID"] == 0) { add_rate(); } elseif ($_STATE->new_rate["eff"] == 0) { delete_rate(); } else { update_rate(); } }
} else { if ($page == "addItem" && check_perms("items")) { require_once "./include/additem.inc"; if (isset($_POST['submit'])) { process_form(); } else { display_form(); } } else { if ($page == "update" && check_perms("items")) { require_once "./include/update.inc"; if (isset($_POST['submit'])) { update_item($_POST['code'], $_POST['amount']); } else { if (isset($_POST['rateUpdate'])) { update_rate($_POST['code'], $_POST['rate']); } else { if (isset($_GET['search'])) { display_item($_GET['search']); } else { if (isset($_POST['block'])) { block_items(); } else { display_item(); } } } } } else { if ($page == "getdetails") { require_once "./include/getdetails.inc";
insertCourierRate($courier_id['latest_id'], $provinces, $city['city_name'], '0', $weight); } } $rate = clean_price($_POST['courier_rate']); $courier_rate_id = get_min_courier($courier_id['latest_id']); $initial_id = $courier_rate_id['latest_id']; foreach ($rate as $rate) { update_rate($initial_id, $courier_id['latest_id'], $rate); $initial_id++; } // INTERNATIONAL $courier_name = $courier_id['latest_id']; $courier_province = "international"; $courier_city = $_POST['international_id']; $courier_rate = clean_price($_POST['international_rate']); $courier_weight = $_POST['courier_weight']; $courier_rate_id = get_min_courier($courier_id['latest_id']); $initial_id = $courier_rate_id['latest_id']; foreach ($courier_city as $key => $city) { insertCourierRate($courier_name, $courier_province, $city, $courier_rate[$key], $courier_weight); } foreach ($courier_rate as $rate) { update_rate($initial_id, $courier_id['latest_id'], $rate); $initial_id++; } } } } //$_SESSION['alert'] = "success"; //$_SESSION['msg'] = "Item(s) has been successfully added."; }