/**
  * Finds the Activities model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Activities the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Activities::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Activities::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'time' => $this->time]);
     $query->andFilterWhere(['like', 'activity', $this->activity])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActivity()
 {
     return $this->hasOne(Activities::className(), ['id' => 'activity_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;
 }
 public function findBid($id)
 {
     if ($activity = \common\models\Activities::find()->where(['activity' => 'bid', 'user_id' => $id])->one()) {
         if ($bid = \common\models\Bids::find()->where(['activity_id' => $activity->id])->one()) {
             return $bid;
         }
     }
     return null;
 }
Example #6
0
 /**
  * Creates a new Orders model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $industry = Yii::$app->request->get('industry');
     $process = Yii::$app->request->get('process');
     if (Yii::$app->session['cart'] != null && ($industry != null || $process != null)) {
         foreach (Yii::$app->session['cart']['industry'] as $key => $ind) {
             if ($key == $industry) {
                 $cart[$key] = $ind;
             }
         }
         $service = \common\models\CsServices::findOne($cart[$industry]['data'][1]['service']);
         $objects = $this->getObjectModels($cart[$industry]['data'][1]['object_models']);
         $user = !Yii::$app->user->isGuest ? \common\models\User::findOne(Yii::$app->user->id) : null;
         // orderer
         $model = new Orders();
         $model->service = $service;
         // skill model
         $model_skill = $this->loadServiceSkills($service);
         $location = new Locations();
         $location->control = $service->location;
         $location->userControl = Yii::$app->user->isGuest ? 0 : 1;
         $location_end = new Locations();
         $new_user = $user == null ? Yii::createObject(RegistrationProviderForm::className()) : null;
         // register provider
         $returning_user = $user == null ? Yii::createObject(LoginForm::className()) : null;
         // login existing user
         if ($model->load(Yii::$app->request->post())) {
             if (Yii::$app->user->isGuest) {
                 // register $ login user
                 if ($new_user->load(Yii::$app->request->post())) {
                     if ($user = $new_user->signup()) {
                         if (!Yii::$app->getUser()->login($user)) {
                             return $this->goBack();
                         }
                     }
                 }
                 // login user
                 if ($returning_user->load(Yii::$app->request->post())) {
                     if (!$returning_user->login()) {
                         return $this->goBack();
                     }
                 }
             }
             // continue
             $activity = Activities::loadActivity(Yii::$app->user->id);
             if ($activity->save()) {
                 // new activity saved
                 $model->activity_id = $activity->id;
                 $this->saveOrderLocation($model, $location, $service);
                 $this->saveOrderEndLocation($model, $location_end, $service);
                 if ($model->save()) {
                     $this->saveOrderSkills($model, $cart, $service);
                     $this->saveOrderServices($model, $activity, $cart, $service);
                     $this->eraseSessionData($industry);
                     // izbaci snimljene usluge iz korpe
                     return $this->redirect('/order/' . $model->id);
                 }
             } else {
                 return $this->redirect('/services');
             }
             return $this->redirect('/services');
         } else {
             return $this->render('create', ['service' => $service, 'model' => $model, 'model_skills' => $model_skill, 'location' => $location, 'location_end' => $location_end, 'objects' => $objects, 'new_user' => $new_user, 'returning_user' => $returning_user]);
         }
     } else {
         return $this->redirect('/services');
     }
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActivities()
 {
     return $this->hasMany(Activities::className(), ['user_id' => 'id']);
 }
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Activities;
use frontend\widgets\ActivityBox;
?>
<!-- MY EVENTS -->
<div class="featured">
	<h2 style="text-align:center; margin:30px 0 10px 0;">Moj market</h2>
	<hr>
	<p class="paragraph" style="text-align:center; margin:0 0 10px 0; color:#aaa; font-size:11px;"><?php 
echo Yii::t('app', 'Choose category by clicking on the colored boxes and then select one of the service industry from the list below.');
?>
</p>
	<?php 
foreach (Activities::find()->limit(5)->all() as $key => $activity) {
    echo ActivityBox::widget(['boxData' => []]);
}
// foreach ($sektor as $key=>$sek)
?>
	
</div>
<div class="show_more"><?php 
echo Html::a('POKAŽI JOŠ', Url::to('/market'), array('class' => 'btn btn-default'));
?>
</div>
<!-- LATEST -->
<div class="featured">
	<h2 style="text-align:center; margin:30px 0 10px 0;">Najnovije promene na marketu</h2>
	<hr>
	<p class="paragraph" style="text-align:center; margin:0 0 10px 0; color:#aaa; font-size:11px;"><?php