<?php

class SalesReturn extends CActiveRecord
{
    public function tableName()
    {
        return 'crm_sales_return';
    }

    public function rules()
    {
        return [
            ['invoice_id, invoice_number, customer_name, return_date, created_by', 'required'],
            ['invoice_id, created_by', 'numerical','integerOnly'=>true],
            ['created_date_time', 'safe']
        ];
    }

    public function relations()
    {
        return [
            'items'=>[self::HAS_MANY,'SalesReturnItems','return_id'],
            'invoice'=>[self::BELONGS_TO,'SalesInvoice','invoice_id']
        ];
    }

    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }
}