Beispiel #1
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         // PROVIDER CONTACT
         $providerContact = new \common\models\ProviderContact();
         $providerContact->provider_id = $this->id;
         $providerContact->contact_type = 'e-mail';
         $providerContact->value = $this->user->email;
         $providerContact->save();
         // PROVIDER INDUSTRY
         $providerIndustry = new \common\models\ProviderIndustries();
         $providerIndustry->provider_id = $this->id;
         $providerIndustry->industry_id = $this->industry_id;
         $providerIndustry->main = 1;
         $providerIndustry->save();
         // PROVIDER LANGUAGES
         $providerLanguage = new \common\models\ProviderLanguages();
         $providerLanguage->provider_id = $this->id;
         $providerLanguage->lang_code = 'SR';
         $providerLanguage->save();
         // PROVIDER PORTFOLIO
         $providerPortfolio = new \common\models\ProviderPortfolio();
         $providerPortfolio->provider_id = $this->id;
         $providerPortfolio->name = 'Moj portfolio';
         $providerPortfolio->save();
         // PROVIDER TERMS
         $providerTerms = new \common\models\ProviderTerms();
         $providerTerms->provider_id = $this->id;
         $providerTerms->update_time = date('Y-m-d H:i:s');
         $providerTerms->save();
         // PROVIDER NOTIFICATIONS
         $providerNotifications = new \common\models\ProviderNotifications();
         $providerNotifications->provider_id = $this->id;
         $providerNotifications->notification_type = 'matching';
         $providerNotifications->time = date('Y-m-d H:i:s');
         $providerNotifications->save();
     }
 }
 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)
 {
     $user = \common\models\User::findOne(Yii::$app->user->id);
     // 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
         $providerIndustry = new \common\models\ProviderIndustries();
         $providerIndustry->provider_id = $provider->id;
         $providerIndustry->industry_id = $model->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 = $model->industry_id;
             $proserv->service_id = $model->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 $user;
 }