Beispiel #1
0
 /**
  *  onRun function
  */
 public function onRun()
 {
     // $this->prepareVars();
     $this->courses = $this->page['courses'] = $this->listCourses();
     // $order_messages = Session::get('order_messages');
     $this->order_state = $this->page['order_state'] = Session::get('order_state');
     \CW::info(['Session' => $this->order_state]);
 }
Beispiel #2
0
 /**
  *  onRun function
  */
 public function onRun()
 {
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/transition.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/dropdown.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/checkbox.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/form.css');
     $this->addCss('/themes/mrc/assets/vendor/semantic/components/button.css');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/transition.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/dropdown.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/checkbox.js');
     $this->addJs('/themes/mrc/assets/vendor/semantic/components/form.js');
     // $this->addJs('/themes/mrc/assets/vendor/semantic/components/button.js');
     \CW::info([$this->user()->profile]);
     $this->profile = $this->page['profile'] = $this->user()->profile;
 }
Beispiel #3
0
 protected function loadPost()
 {
     $slug = $this->property('slug');
     $post = PostModel::isPublished()->where('slug', $slug)->first();
     if (!$post) {
         return null;
     }
     $prev = PostModel::isPublished()->where('published_at', '<', $post->published_at)->orderBy('published_at', 'desc')->first();
     $next = PostModel::isPublished()->where('published_at', '>', $post->published_at)->orderBy('published_at', 'asc')->first();
     if (!is_null($prev)) {
         $this->prev = $this->page['prev'] = $prev->setUrl('news/post', $this->controller);
     }
     if (!is_null($next)) {
         $this->next = $this->page['next'] = $next->setUrl('news/post', $this->controller);
     }
     \CW::info([$this->prev, $this->next]);
     // CW::info(['News' => $post]);
     return $post;
 }
Beispiel #4
0
 /**
  * Update Events from CRM
  */
 public function onUpdateFromCrm()
 {
     $crmuserevents = CRMUserEvent::isNotUpdated()->with(['user', 'event'])->get();
     \CW::info(['userevents' => $crmuserevents]);
     if (count($crmuserevents) == 0) {
         Flash::info("No UserEvents to Create/Update");
         // echo "ERROR!";
         return;
     }
     $crmuserevents->each(function ($userevent) {
         if ($userevent->user && $userevent->event) {
             \CW::info([$userevent]);
             $cmsuser = User::where('email', $userevent->user->email)->first();
             $cmsevent = Event::where('crm_event_id', $userevent->event->id)->with('course')->first();
             $cmscourse = $cmsevent->course;
             $cmsusereventstate = UserEventState::where('crm_state_id', $userevent->state_id)->first();
             // $cmsuserevent = UserEvent::firstOrNew(['crm_event_id' => $userevent->event->id, 'user_id' => $cmsuser->id]);
             // $cmsuserevent = $cmsuser->userevents()
             // $cmsuserevent = $cmsuserevent
             $cmsuserevent = UserEvent::where('user_id', $cmsuser->id)->where('event_id', $cmsevent->id)->first();
             if (!$cmsuserevent) {
                 $cmsuserevent = new UserEvent();
             }
             \CW::info([$cmsuser, $cmsevent, $cmscourse, $cmsuserevent, $cmsusereventstate]);
             // if (!$cmsuser) {
             //     Log::warning("CMSUser is NULL\n");
             // }
             // if (!$cmsevent) {
             //     Log::warning("CMSEvent is NULL\n");
             // }
             // if (!$cmscourse) {
             //     Log::warning("CMSCourse is NULL\n");
             // }
             // if (!$cmsuserevent) {
             //     Log::warning("CMSUserEvent is NULL\n");
             // }
             // if (!$cmsusereventstate) {
             //     Log::warning("CMSUserEventState is NULL\n");
             // }
             $cmsuserevent->user()->associate($cmsuser);
             $cmsuserevent->course()->associate($cmscourse);
             $cmsuserevent->state()->associate($cmsusereventstate);
             $cmsuserevent->event()->associate($cmsevent);
             $cmsuserevent->fill(['course_type_id' => $cmscourse->course_type_id, 'course_category_id' => $cmscourse->course_category_id, 'crm_event_id' => $userevent->event->id]);
             \CW::info([$cmsuserevent]);
             $cmsuserevent->save();
             $userevent->update(['is_updated' => true]);
         }
     });
     Flash::success("UserEvents is update");
 }