Example #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOffer()
 {
     return $this->hasOne(Offers::className(), ['activity_id' => 'id']);
 }
 protected function savePresentation($model, $user, $service, $proserv)
 {
     if ($model && $user && $service && $proserv) {
         $activity = Activities::loadActivity($user->id, 'presentation');
         if ($activity->save()) {
             $offer = Offers::loadOffer($activity->id);
             if ($offer->save()) {
                 $model->activity_id = $activity->id;
                 $model->offer_id = $offer->id;
                 $model->provider_service_id = $proserv->id;
                 $model->provider_id = $proserv->provider_id;
                 $model->service_id = $service->id;
                 $model->object_id = $service->object_id;
                 $model->price = 0;
                 $model->loc_id = 1;
                 $model->status = 'draft';
                 $model->save();
                 return true;
                 /*if($model->save()){
                                         // Presentation Object Models
                                         if($object_model){
                                             foreach($object_model as $ob_model){
                                                 $model_object_models = new \common\models\PresentationObjectModels();
                                                 $model_object_models->presentation_id = $model->id;
                                                 $model_object_models->object_model_id = $ob_model;
                                                 $model_object_models->save();
                                             }
                                         }                        
                 
                                         return true; 
                                     } else {
                                         echo '<pre>';
                                         print_r($model); die();
                                     }*/
             }
         }
     }
     return false;
 }
Example #3
0
 public static function getAppliedOfferCount($userId)
 {
     $appledOfferData = \common\models\OfferApplied::findAppliedOffersByAttr(['user_id' => $userId, 'status' => 'active']);
     $idsArray = [];
     foreach ($appledOfferData as $offerData) {
         $idsArray[] = $offerData->offer_id;
     }
     $currentDate = date('Y-m-d');
     $result = \common\models\Offers::find()->select('offers.*')->where(['offers.id' => $idsArray, 'offers.status' => 'active'])->leftJoin('user_profile', 'user_profile.user_id = offers.user_id')->andWhere('dateframe >= :currentDate', ['currentDate' => $currentDate])->andWhere(['offers.status' => 'active', 'user_profile.status' => ['active']])->all();
     return count($result);
 }