<?php
class Service_PurchaseOrderBody extends Common_Service
{
    /**
     * @var null
     */
    public static $_modelClass = null;

    /**
     * @return Table_CustomerBalanceLog|null
     */
    public static function getModelInstance()
    {
        if (is_null(self::$_modelClass)) {
            self::$_modelClass = new Table_PurchaseOrderBody();
        }
        return self::$_modelClass;
    }

    /**
     * @param $row
     * @return mixed
     */
    public static function add($row)
    {
        $model = self::getModelInstance();
        return $model->add($row);
    }


    /**
     * @param $row
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function update($row, $value, $field = "pobd_id")
    {
        $model = self::getModelInstance();
        return $model->update($row, $value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function delete($value, $field = "pobd_id")
    {
        $model = self::getModelInstance();
        return $model->delete($value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @param string $colums
     * @return mixed
     */
    public static function getByField($value, $field = 'pobd_id', $colums = "*")
    {
        $model = self::getModelInstance();
        return $model->getByField($value, $field, $colums);
    }

    /**
     * @return mixed
     */
    public static function getAll()
    {
        $model = self::getModelInstance();
        return $model->getAll();
    }

    /**
     * @param array $condition
     * @param string $type
     * @param int $pageSize
     * @param int $page
     * @param string $order
     * @return mixed
     */
    public static function getByCondition($condition = array(), $type = '*', $pageSize = 0, $page = 1, $order = "")
    {
        $model = self::getModelInstance();
        return $model->getByCondition($condition, $type, $pageSize, $page, $order);
    }

    /**
     * @param $val
     * @return array
     */
    public static function validator($val)
    {
        $validateArr = $error = array();
        
        return  Common_Validator::formValidator($validateArr);
    }


    /**
     * @param array $params
     * @return array
     */
    public  function getFields()
    {
        $row = array(        
              'E0'=>'purchase_order_body.pobd_id',
			  'E1'=>'purchase_order_tracking.tracking_number',
			  'E2'=>'purchase_order.po_id',
			  'E3'=>'purchase_order.supply_code',
			  'E5'=>'purchase_order_body.product_id',
			  'E6'=>'purchase_order_body.order_quantity',
			  'E7'=>'purchase_order_body.received_quantity',
			  'E8'=>'purchase_order.create_time',
			  'E9'=>'purchase_order.customer_id',
			  'E20'=>'purchase_order_body.pobd_status',
			  'E31'=>'purchase_order.po_code',	
			  'E41'=>'product.product_sku',
			  'E51'=>'purchase_order_tracking_body.po_tb_status',	  
			               
        );
        return $row;
    }
	
	
    public static function getJoinPurchaseBodyByCondition($condition = array(), $type = '*', $pageSize = 0, $page = 1, $order = "")
    {
        $model = self::getModelInstance();
        return $model->getJoinPurchaseBodyByCondition($condition, $type, $pageSize, $page, $order);
    }
	

    public static function getJoinPurchaseBodyProductByCondition($condition = array(), $type = '*', $pageSize = 0, $page = 1, $order = "")
    {
        $model = self::getModelInstance();
        return $model->getJoinPurchaseBodyProductByCondition($condition, $type, $pageSize, $page, $order);
    }			

}