<?php
class Service_FeeAndCostDetail 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_FeeAndCostDetail();
        }
        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 = "fc_id")
    {
        $model = self::getModelInstance();
        return $model->update($row, $value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function delete($value, $field = "fc_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 = 'fc_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' => 'fc_id',
            'E1' => 'code_number',
            'E2' => 'code_type',
            'E3' => 'customer_code',
            'E4' => 'reference_no',
            'E5' => 'tracking_number',
            'E6' => 'sm_code',
            'E7' => 'country_code',
            'E8' => 'fee_code',
            'E9' => 'fee_name',
            'E10' => 'fee_amount_org',
            'E11' => 'fee_currency_code_org',
            'E12' => 'cost_amount_org',
            'E13' => 'cost_currency_code_org',
            'E14' => 'fee_amount_customer',
            'E15' => 'fee_currency_code_customer',
            'E16' => 'sp_code',
            'E17' => 'cost_amount_sp',
            'E18' => 'cost_currency_code_sp',
            'E19' => 'discount_customer',
            'E20' => 'price_batch_number',
            'E21' => 'currency_batch_number',
            'E22' => 'fee_time',
            'E23' => 'fee_time_recalculate',
            'E24' => 'ip',
            'E25' => 'ip_recalculate',
            'E26' => 'operator',
            'E27' => 'operator_recalculate',
        );
        return $row;
    }

}