<?php
/*
 * @version			$Id: index.php 10381 2008-06-01 03:35:53Z $
 * @package			Carteasy
 * @copyright		Copyright (C) 2005 - 2011 Wlanium
 * @license			proprietary
 * @author			Thomas Bartelt
 * Carteasy is a web shop system
 */

class PaymentMethod {

	public function __construct() {}

	private function __clone() {}

	public static function get_all($active_only = false) {
		$db = Registry::get('base')->db;

		$sql = "SELECT * FROM payment_methods";

		if ($active_only) {
			$sql .= ' WHERE active=1';
		}

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

		if ($result->num_rows > 0) {
			$return = array();

			while ($obj = $result->fetch_object()) {
				$return[] = $obj;
			}

			return $return;
		}

		return false;
	} // end get_all

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

		$sql = "SELECT name FROM payment_methods WHERE id=$id";

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

		if ($result->num_rows > 0) {
			$obj = $result->fetch_object();

			return $obj->name;
		}

		return false;
	} // end get_name

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

		$sql = "SELECT * FROM payment_methods WHERE id=$id";

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

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

		return false;
	} // end get_data

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

		$sql = "SELECT order_text FROM payment_methods WHERE id=$id";

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

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

		return false;
	}
}