Gridview data by logged user

hi everyone, I’m showing my GridView data according to the user who is logged in, but now does not filter my gridview. Which may be ?? Here I attached my code

PlanificacionSearch:




 if(\Yii::$app->authManager->checkAccess(Yii::$app->user->getId(),'managePR'))       

        {

            $PR="SELECT 

              planificacion.*

            FROM

              planificacion

              INNER JOIN dic ON (planificacion.dic_fk = dic.id_dic)

            WHERE

              dic_siglas = 'CP PR'";

        $query = Planificacion::findBySql($PR);

        }

        if(\Yii::$app->authManager->checkAccess(Yii::$app->user->getId(),'manageART'))       

        {

            $ART="SELECT 

              planificacion.*

            FROM

              planificacion

              INNER JOIN dic ON (planificacion.dic_fk = dic.id_dic)

            WHERE

              dic_siglas = 'CP ART'";

        $query = Planificacion::findBySql($ART);

        }

        if(\Yii::$app->authManager->checkAccess(Yii::$app->user->getId(),'manageMAY'))       

        {

            $MAY="SELECT 

              planificacion.*

            FROM

              planificacion

              INNER JOIN dic ON (planificacion.dic_fk = dic.id_dic)

            WHERE

              dic_siglas = 'CP MAY'";

        $query = Planificacion::findBySql($MAY);

        }


if(\Yii::$app->authManager->checkAccess(Yii::$app->user->getId(),'manageUsers'))       

        {            

           $query = Planificacion::find();

        }        

        

        $dataProvider = new ActiveDataProvider([

            'query' => $query,

        ]);

        

        $dataProvider->sort->attributes['orga_siglas'] = [

        // The tables are the ones our relation are configured to

        // in my case they are prefixed with "tbl_"

        'asc' => ['planificacion.orga_fk' => SORT_ASC],

        'desc' => ['planificacion.orga_fk' => SORT_DESC],

    ];

        $dataProvider->sort->attributes['entidad_nombre'] = [

        // The tables are the ones our relation are configured to

        // in my case they are prefixed with "tbl_"

        'asc' => ['planificacion.entidad_fk' => SORT_ASC],

        'desc' => ['planificacion.entidad_fk' => SORT_DESC],

    ];

        $dataProvider->sort->attributes['dic_desc'] = [

        // The tables are the ones our relation are configured to

        // in my case they are prefixed with "tbl_"

        'asc' => ['planificacion.dic_fk' => SORT_ASC],

        'desc' => ['planificacion.dic_fk' => SORT_DESC],

    ];


        $this->load($params);


        if (!$this->validate()) {

            // uncomment the following line if you do not want to any records when validation fails

            // $query->where('0=1');

            return $dataProvider;

        }

        

        $query->joinWith(['orgaFk','entidadFk','dicFk']);


        /*$query->andFilterWhere([

            //'id_planificacion' => $this->id_planificacion,

            //'plan_fecha' => $this->plan_fecha,

            //'n_orga.orga_siglas' => $this->orga_siglas,

            //'entidad.entidad_nombre' => $this->entidad_nombre,

           // 'dic.dic_desc' => $this->dic_desc,

        ]);*/


        $query->andFilterWhere(['like', 'plan_cod', $this->plan_cod])

            ->andFilterWhere(['like', 'plan_desc', $this->plan_desc])

            ->andFilterWhere(['like', 'plan_fecha', $this->plan_fecha])

            ->andFilterWhere(['like', 'n_orga.orga_siglas', $this->orga_siglas])

            ->andFilterWhere(['like', 'plan_acc_extra', $this->plan_acc_extra])

            ->andFilterWhere(['like', 'dic.dic_desc', $this->dic_desc])

            ->andFilterWhere(['like', 'entidad.entidad_nombre', $this->entidad_nombre])

            ->andFilterWhere(['like', 'plan_orden', $this->plan_orden])

            ->andFilterWhere(['like', 'plan_reg_por', $this->plan_reg_por]);


        return $dataProvider;

    }

}