/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProviderIndustries::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, 'provider_id' => $this->provider_id, 'industry_id' => $this->industry_id, 'main' => $this->main]);
     // grid filtering conditions
     $query->orderBy(['main' => SORT_DESC]);
     return $dataProvider;
 }
 protected function saveProvider($user = null, $service = null)
 {
     if ($user and $service) {
         $provider = new Provider();
         $provider->user_id = $user->id;
         $provider->industry_id = $service->industry_id;
         $provider->loc_id = $user->details->loc_id;
         $provider->legal_form = 'freelancer';
         $provider->type = 'service_provider';
         $provider->department_type = 'hq';
         $provider->status = 'active';
         $provider->registration_time = date('Y-m-d H:i:s');
         if ($provider->save()) {
             $user->is_provider = 1;
             $user->save();
             // provider Contact
             $providerContact = new \common\models\ProviderContact();
             $providerContact->provider_id = $provider->id;
             $providerContact->contact_type = 'e-mail';
             $providerContact->value = $user->email;
             $providerContact->save();
             // provider Industry
             $providerIndustry = new \common\models\ProviderIndustries();
             $providerIndustry->provider_id = $provider->id;
             $providerIndustry->industry_id = $service->industry_id;
             $providerIndustry->main = 1;
             if ($providerIndustry->save()) {
                 $proserv = new \common\models\ProviderServices();
                 $proserv->provider_industry_id = $providerIndustry->id;
                 $proserv->provider_id = $provider->id;
                 $proserv->industry_id = $service->industry_id;
                 $proserv->service_id = $service->id;
                 $proserv->is_set = 1;
                 $proserv->update_time = date('Y-m-d H:i:s');
                 $proserv->save();
             }
             // provider Industry Terms
             $providerIndustryTerm = new \common\models\ProviderIndustryTerms();
             $providerIndustryTerm->provider_industry_id = $providerIndustry->id;
             $providerIndustryTerm->update_time = date('Y-m-d H:i:s');
             $providerIndustryTerm->save();
             // provider Language
             $providerLanguage = new \common\models\ProviderLanguages();
             $providerLanguage->provider_id = $provider->id;
             $providerLanguage->lang_code = 'SR';
             $providerLanguage->save();
             // provider Portfolio
             $providerPortfolio = new \common\models\ProviderPortfolio();
             $providerPortfolio->provider_id = $provider->id;
             $providerPortfolio->name = 'Moj portfolio';
             $providerPortfolio->save();
             // provider Terms
             $providerTerms = new \common\models\ProviderTerms();
             $providerTerms->provider_id = $provider->id;
             $providerTerms->update_time = date('Y-m-d H:i:s');
             $providerTerms->save();
             // provider Notifications
             $providerNotifications = new \common\models\ProviderNotifications();
             $providerNotifications->provider_id = $provider->id;
             $providerNotifications->notification_type = 'matching';
             $providerNotifications->time = date('Y-m-d H:i:s');
             $providerNotifications->save();
             return $proserv;
         }
     }
     return false;
 }
 public function currentProvider($model)
 {
     if ($user = \common\models\User::findOne(Yii::$app->user->id)) {
         $user->is_provider = 1;
         $user->member = 0;
         $user->role = 'provider';
         if ($user->save()) {
             // create temp provider
             $provider = new \common\models\Provider();
             $provider->user_id = $user->id;
             $provider->industry_id = $model->industry_id;
             $provider->loc_id = 1;
             $provider->legal_form = 'freelancer';
             $provider->type = 'service_provider';
             $provider->department_type = 'hq';
             $provider->status = 'inactive';
             $provider->is_active = 0;
             $provider->registration_time = date('Y-m-d H:i:s');
             //$provider->save();
             if ($provider->save()) {
                 // provider Industry
                 if ($providerIndustry = \common\models\ProviderIndustries::findOne($provider->initialIndustry->id)) {
                     $proserv = new \common\models\ProviderServices();
                     $proserv->provider_industry_id = $providerIndustry->id;
                     $proserv->provider_id = $provider->id;
                     $proserv->industry_id = $model->industry_id;
                     $proserv->service_id = $model->id;
                     $proserv->is_set = 1;
                     $proserv->update_time = date('Y-m-d H:i:s');
                     $proserv->save();
                 }
             }
         }
         return $user;
     }
     return false;
 }
 /**
  * Finds the ProviderIndustries model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ProviderIndustries the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProviderIndustries::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIndustries()
 {
     return $this->hasMany(ProviderIndustries::className(), ['provider_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProviderIndustry()
 {
     return $this->hasOne(ProviderIndustries::className(), ['id' => 'provider_industry_id']);
 }