<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
use yii\base\Object;
use yii\db\Query;
use yii\db\Expression;
use common\models\Account;

use yii\helpers\ArrayHelper;
use common\models\MoneyMovement;
use common\components\RoleDefinition;
/**
 * TransferSearch represents the model behind the search form about `common\models\Transfer`.
 */
class TransferSaleSearch extends \common\models\TransferSaleSearch
{
	
 
    
    protected function addAccountConstraint($query){
    	if ( !RoleDefinition::isAdmin() ){
	    	$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
	    	$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
	    	
	    	if ( RoleDefinition::isReception()){
	    		$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
	    	}
	    	
	    	$query->andWhere(['account.type' => Account::TYPE_ALL ]);
    	}
    	
    }
    
    
   
    
    
}
