<?php

namespace frontend\models;

use Yii;
use yii\base\Model;
use common\models\Card;
use common\models\Customer;
use common\models\Product;
use common\models\Transfer;
use yii\base\Object;
use common\models\Account;
use common\models\Discount;
use common\models\Currency;
use common\models\UserSoldItem;
use common\models\Sale;
use common\models\ShoppingCart;

/**
 * ContactForm is the model behind the contact form.
 * 
 *  @property integer id_account
 *  @property common\models\Account $account
 *  
 *  
 */
class CreateAccountSelectForm extends Model
{

		public $id_account;
		public $account;
		public $accounts;
		
		public function rules(){
			return [
				[['id_account'],  'integer'   ],
				[['id_account'],  'validateAccount'   ],
			
			];
		}
		
		public function validateAccount($attribute,$params){
			$this->account = Account::readOne($this->id_account);
			if ( !isset($this->account)){
				$this->addError($attribute, Yii::t('frontend/collection', 'Invalid transfer!'));
			}
		}
		
		public function attributeLabels(){
			return [
	
				'id_account' => Yii::t('frontend/collection', 'Account'),
			
			];
		}
	 
}
