Beispiel #1
0
 public function email_notifications()
 {
     if (\WebAPL\Modules::checkInstance('person')) {
         $events = \CalendarModel::join(CalendarLangModel::getTableName(), \CalendarModel::getField('id'), '=', CalendarLangModel::getField('calendar_item_id'))->join(\CalendarGroup::getTableName(), \CalendarGroup::getField('id'), '=', \CalendarModel::getField('calendar_group_id'))->join(\CalendarPostModel::getTableName(), \CalendarPostModel::getField('calendar_group_id'), '=', \CalendarGroup::getField('id'))->where(CalendarLangModel::getField('lang_id'), \WebAPL\Language::getId())->where(\CalendarModel::getField('enabled'), 1)->where(\CalendarModel::getField('person_id'), '<>', 0)->select(CalendarLangModel::getField("*"), \CalendarModel::getField('event_date'), \CalendarModel::getField('repeat_frequency'), \CalendarModel::getField('repeat_to_date'), \CalendarModel::getField('person_id'), \CalendarModel::getField('post_id'), \CalendarModel::getField('period'))->orderBy(\CalendarModel::getField('event_date'), 'asc')->where(function ($query) {
             $query->where(function ($query) {
                 $query->where(DB::raw("DATE(" . CalendarModel::getField('event_date') . ")"), '=', DB::raw('DATE(CURRENT_TIMESTAMP)'));
             })->orWhere(function ($query) {
                 $query->where(\CalendarModel::getField('event_date'), '<=', DB::raw('CURRENT_TIMESTAMP'))->where(\CalendarModel::getField('repeat_to_date'), '>=', DB::raw('CURRENT_TIMESTAMP'))->where(\CalendarModel::getField('repeat_frequency'), '<>', 'none');
             });
         })->get();
         $event_list = \CalendarModel::generateEvents($events, false);
         $today_events = [];
         foreach ($event_list as $event) {
             if (date("Y-m-d", strtotime($event['event_date'])) === date("Y-m-d") && strtotime($event['event_date']) >= time()) {
                 echo " sendone ";
                 $today_events[] = $event;
                 $this->loadClass(['PersonModel'], 'person');
                 $person = \PersonModel::getPerson($event['person_id']);
                 if (isset($person->email) && $person->email) {
                     Template::viewModule($this->module_name, function () use($person, $event) {
                         \EmailModel::sendToAddress($person->email, "Do you have an event today", 'views.calendarEmail', ['person' => $person, 'event' => $event]);
                     });
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function vicemayor($data)
 {
     $item = Input::get('item');
     if ($item) {
         $person = \PersonModel::getPerson($item);
         if ($person) {
             $groups = [['persons' => [$person]]];
             $data["page"]->text = View::make(Person::$view_persons_secretar, array('groups' => $groups));
             return PageView::defaultView($data);
         }
     }
     $groups = PersonModel::getPostPersonGroups($data['page']->id);
     if ($groups) {
         $data["page"]->text = View::make(Person::$view_persons_big, array('groups' => $groups, 'page_url' => $data['page_url']));
     }
     return PageView::defaultView($data);
 }