Пример #1
0
 /**
  * Lists all PartnerRequest models.
  * @return mixed
  * @throws ForbiddenHttpException
  */
 public function actionIndex()
 {
     $partners = PartnerRequest::find()->all();
     $searchModel = new SearchPartnerRequest();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['partners' => $partners, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PartnerRequest::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'sender_id' => $this->sender_id, 'created_at' => $this->created_at, 'moderation_status' => $this->moderation_status, 'moderated_by' => $this->moderated_by, 'moderated_at' => $this->moderated_at]);
     $query->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }
Пример #3
0
 public function send($event)
 {
     if (Yii::$app->user->isGuest) {
         $profile = Yii::$app->request->post('Profile');
         $partnerRequest = Yii::$app->request->post('PartnerRequest');
         $partnerEmail = Yii::$app->request->post('register-form')['email'];
     } else {
         $profile = Profile::find()->where(['user_id' => Yii::$app->user->id])->one();
         $partnerRequest = PartnerRequest::find()->where(['sender_id' => $profile->user_id])->one();
         $partnerEmail = $profile->user->email;
     }
     try {
         Yii::$app->partnerMailer->compose('partner-request-manager', ['partnerRequest' => $partnerRequest, 'profile' => $profile])->setFrom($event->sender->module->senderEmail)->setTo($event->sender->module->partnerManagerEmail)->setSubject(Yii::t('shop', 'New partner request'))->send();
     } catch (Exception $ex) {
         throw new Exception($ex);
     }
     try {
         Yii::$app->partnerMailer->compose('partner-request-partner', ['partnerRequest' => $partnerRequest, 'profile' => $profile])->setFrom($event->sender->module->senderEmail)->setTo($partnerEmail)->setSubject(Yii::t('shop', 'Partner request'))->send();
     } catch (Exception $ex) {
         throw new Exception($ex);
     }
 }