<?php
Doo::loadCore ( 'db/DooModel' );
/**
 * 发票相关管理相关信息及其操作业务逻辑
 * @author CP.
 * @version 1.0
 * @namespace invoice
 * @package invoiceModel
 */
class invoiceManage extends DooModel {
	/**
	 *
	 * @var integer $iid 管理组ID
	 */
	public $iid;
	/**
	 *
	 * @var string $staff 管理组人员
	 */
	public $staff;
	/**
	 *
	 * @var string $mold 管理组名称
	 */
	public $mold;
	public $_table = 'CLD_invoiceManage';
	public $_primarykey = 'iid';
	public $_fields = array (
			'iid',
			'staff',
			'mold' 
	);
	/**
	 * 根据管理组获取审批组成员
	 * @return array|array() 该管理组相关数据，人员数据数组化
	 */
	public function getInvoiceByMold($mold = "") {
		$detail = array ();
		if (! empty ( $mold )) {
			$detail = $this->getOne ( array (
					'where' => 'mold="' . $mold . '"',
					'asArray' => TRUE 
			) );
			if(empty($detail ['staff']))
				$detail ['staffList'] = array();
			else
				$detail ['staffList'] = json_decode ( $detail ['staff'], true );
		}
		return $detail;
	}
	public function getInvoiceByStaff($sid = 0) {
		$lsit=array();
		if (! empty ( $sid ))
			$lsit = $this->find ( array (
					'select'=>'mold',
					'where' => 'staff like "%[\"' . $sid . '\",%"',
					'asArray' => TRUE 
			) );
		
		return $lsit;
	}
	
	/**
	 * 获取所有管理组数据
	 * @return array|array() 该管理组相关数据,人员数据数组化
	 */
	public function getInvoiceByAll() {
		$lsit = $this->find ( array (
				'asArray' => TRUE 
		) );
		foreach ( $lsit as $key => $value ) {
			$lsit [$key] ['staffList'] = json_decode ( $value ['staff'], true );
		}
		return $lsit;
	}
}

// ?>