<?php

class CancellationRequestsHelper {

	//=========================================
	//
	//	THIS CLASS IS STATIC ONLY
	//
	//=========================================
	private function __construct() {
	}

	private function __clone() {
	}

	//=========================================
	//
	//	THE PUBLIC INTERFACE
	//
	//=========================================

	public static function get_cancellation_request_status_by_order_id($order_id) {
		$db = Registry::get('base')->db;

		$sql = "SELECT
					cancellation_status
				FROM
					orders
				WHERE
					id=".$db->real_escape_string($order_id);

		$result = $db->query($sql);

		if ($result->num_rows > 0) {
			return $result->fetch_object()->status;
		}

		return false;
	}

	public static function set_status($id, $status) {
		$db = Registry::get('base')->db;

		$sql = "UPDATE orders
				SET cancellation_status=".$db->real_escape_string($status)."
				WHERE id=".$db->real_escape_string($id);

		return $db->query($sql);
	}

	public static function set_statuses($ids, $status) {
		$db = Registry::get('base')->db;

		$sql = "UPDATE orders
				SET cancellation_status=".$db->real_escape_string($status)."
				WHERE id IN (".$db->real_escape_string($ids).")";

		return $db->query($sql);
	}

}