예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Contactos::find();
     $query->joinWith('cuenta');
     // Solo funciona en Contactos
     if ($this->tipo_empresa > 0) {
         $query->where('tipocuenta_id = ' . $this->tipo_empresa);
     }
     // En el caso de que sea Vendedor se muestran solo sus contactos
     if (\common\models\User::isUserVendedor(Yii::$app->user->identity->id)) {
         $query->andWhere('user_id = ' . Yii::$app->user->identity->id);
     }
     $query->orderBy('cuenta');
     /*
             $command = $query->createCommand();
             echo "<pre>";
             print_r($command);
             echo "</pre>";
             exit;
     */
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['cuenta_id' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     //$query->andFilterWhere(['like','cuentas.cab_sector',$this->getAttribute('cuenta.cab_sector')]);
     $query->andFilterWhere(['like', 'user_id', $this->getAttribute('cuenta.user_id')]);
     $query->andFilterWhere(['like', 'estado_id', $this->getAttribute('cuenta.estado_id')]);
     $query->andFilterWhere(['contactosid' => $this->contactosid, 'cuenta_id' => $this->cuenta_id]);
     $query->andFilterWhere(['like', 'puesto', $this->puesto])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido', $this->apellido])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'correo', $this->correo])->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'asistente', $this->asistente])->andFilterWhere(['like', 'sectorcontacto_id', $this->sectorcontacto_id]);
     return $dataProvider;
 }
예제 #2
0
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['iniciativa-privada', 'gobierno-federal', 'gdf', 'estatales', 'partidos', 'delegacion', 'intercambio', 'fundacion', 'view', 'change', 'create', 'delete', 'update'], 'rules' => [['allow' => true, 'actions' => ['iniciativa-privada', 'gobierno-federal', 'gdf', 'estatales', 'partidos', 'delegacion', 'intercambio', 'fundacion', 'view', 'change', 'create', 'delete', 'update'], 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         //Llamada al método que comprueba si es un vendedor
         return \common\models\User::isUserVendedor(Yii::$app->user->identity->id);
     }], ['allow' => true, 'actions' => ['iniciativa-privada', 'view', 'change', 'create', 'delete', 'update'], 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         //Llamada al método que comprueba si es un vendedor
         return \common\models\User::isUserIP(Yii::$app->user->identity->id);
     }], ['allow' => true, 'actions' => ['iniciativa-privada', 'gobierno-federal', 'gdf', 'estatales', 'partidos', 'delegacion', 'intercambio', 'fundacion', 'view', 'change', 'create', 'delete', 'update'], 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         //Llamada al método que comprueba si es un vendedor
         return \common\models\User::isUserSeo(Yii::$app->user->identity->id);
     }]]]];
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
 }
예제 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cuentas::find();
     // En el caso de que sea Vendedor se muestran solo sus contactos
     if (\common\models\User::isUserVendedor(Yii::$app->user->identity->id)) {
         $query->where('user_id = ' . Yii::$app->user->identity->id);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['cuenta' => SORT_ASC, 'subcuenta' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['cuentasid' => $this->cuentasid, 'tipocuenta_id' => $this->tipocuenta_id, 'user_id' => $this->user_id, 'sector_id' => $this->sector_id, 'estado_id' => $this->estado_id, 'categoria_id' => $this->categoria_id, 'freunion' => $this->freunion, 'monto_propuesta' => $this->monto_propuesta, 'fcampana' => $this->fcampana]);
     $query->andFilterWhere(['like', 'cuenta', $this->cuenta])->andFilterWhere(['like', 'subcuenta', $this->subcuenta])->andFilterWhere(['like', 'productos', $this->productos])->andFilterWhere(['like', 'comentario', $this->comentario])->andFilterWhere(['like', 'siglas', $this->siglas])->andFilterWhere(['like', 'cab_sector', $this->cab_sector])->andFilterWhere(['like', 'docto_propuesta', $this->docto_propuesta]);
     return $dataProvider;
 }