<?php
class Service_CostRecording extends Common_Service
{
    /**
     * @var null
     */
    public static $_modelClass = null;

    /**
     * @return Table_Application|null
     */
    public static function getModelInstance()
    {
        if (is_null(self::$_modelClass)) {
            self::$_modelClass = new Table_CostRecording();
        }
        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 = "cr_id")
    {
        $model = self::getModelInstance();
        return $model->update($row, $value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function delete($value, $field = "cr_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 = 'cr_id', $columns = "*")
    {
        $model = self::getModelInstance();
        return $model->getByField($value, $field, $columns);
    }

    /**
     * @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' => 'cr_id',
            'E1' => 'order_code',
            'E2' => 'customer_code',
            'E3' => 'reference_no',
            'E4' => 'tracking_number',
            'E5' => 'sm_code',
            'E6' => 'country_id',
            'E7' => 'weight',
            'E8' => 'cost_fee',
            'E9' => 'ticket_fare',
            'E10' => 'fuel_addons',
            'E11' => 'total_fee',
            'E12' => 'price_batch_number',
            'E13' => 'currency_batch_number',
            'E14' => 'sm_baf',
            'E15' => 'currency_code',
            'E16' => 'currency_rate',
            'E17' => 'provider_currency_code',
            'E18' => 'provider_currency_rate',
            'E19' => 'add_time',
            'E20' => 'update_time',
        );
        return $row;
    }

}