<?php
/**
 * 用户订单状态表
 * $Id$
 * @author zongbiao
 * @package jp.fishow.entity.definition
 */
class OrderStatus
{
	public $id;
	public $name;
	public $title;
	
	function __construct($record) {
		$this->id = $record["id"];
		$this->name = $record["name"];
		$this->title = $record["title"];
	}
	
	/**
	 * 返回示例的列表
	 * @return array ImageType一覧
	 */
	public static function getList() {
		static $result;
			
		if ((!is_array($result)) || (count($result) < 1)) {
			
			$data = array();
			$tmp = array("id"=>1, "name"=>"NEW", "title"=>"订单生成");
			array_push($data, $tmp);
			
			$tmp = array("id"=>2, "name"=>"SUCCESS", "title"=>"支付成功");
			array_push($data, $tmp);
			
			$tmp = array("id"=>3, "name"=>"CANCEL", "title"=>"取消支付");
			array_push($data, $tmp);
			
			$tmp = array("id"=>4, "name"=>"NG", "title"=>"其他错误");
			array_push($data, $tmp);
			
			$result = array();
			foreach ($data as $row) {
				$tmp2 = new OrderStatus($row);
				array_push($result, $tmp2);
			}
		}
		return $result;
	}
	
	/**
	 * 通过定义名称获取object
	 * @return OrderStatus 对应实例。没有的时候返回null。
	 */
	public static function getByName($name) {
		$list = OrderStatus::getList();
		foreach ($list as $tmp) {
			if ($tmp->name == $name) {
				return $tmp;
			}
		}
		return null;
	}
	
	/**
	 * 通过定义名称获取title
	 */
	public static function getTitleByName($name) {
		$list = OrderStatus::getList();
		foreach ($list as $tmp) {
			if ($tmp->name == $name) {
				return $tmp->title;
			}
		}
		return null;
	}

}