public function run($isTab = false) { /** @var TourBuilderForm $tourForm */ $tourForm = Yii::app()->user->getState('tourForm'); $eventId = $tourForm->eventId; $startCities = Yii::app()->user->getState('startCities'); $currentStartCityIndex = Yii::app()->user->getState('startCitiesIndex') - 1; $currentStartCity = City::model()->findByPk($startCities[$currentStartCityIndex]->id); $startCityId = $currentStartCity->id; $event = Event::model()->findByPk($eventId); $tripStorage = new TripStorage(); $order = $tripStorage->saveOrder($event, $startCityId, 'Тур для события "' . $event->title . '" из ' . $currentStartCity->caseGen); $eventOrder = new EventOrder(); $eventOrder->startCityId = $startCityId; $eventOrder->orderId = $order->id; $eventOrder->eventId = $event->id; $eventOrder->save(); $eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $startCityId)); if (!$eventPrice) { $eventPrice = new EventPrice(); } $eventPrice->eventId = $event->id; $eventPrice->cityId = $startCityId; $eventPrice->bestPrice = $tripStorage->getPrice(); if (!$eventPrice->save()) { throw new CHttpException('Could not save price for event - city.' . CVarDumper::dumpAsString($eventPrice)); } $this->controller->redirect($this->controller->createUrl('showEventTrip')); }
/** * Get the table rows that need to be printed in the pdf * * @return array */ public function getRows() { if (empty($this->_rows)) { foreach ($this->calendars as $calendar) { $row = array('name' => $calendar->name); // foreach($this->categories as $category){ $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->select('COUNT(*) as count, category_id')->group('category_id'); // $findParams->ignoreAcl(); // Only count items that are visible for this user. // $findParams->group('calendar_id'); $findCriteria = \GO\Base\Db\FindCriteria::newInstance(); $findCriteria->addCondition('calendar_id', $calendar->id); $findCriteria->addCondition('start_time', strtotime($this->startDate), '>'); $findCriteria->addCondition('end_time', strtotime($this->endDate), '<'); $findParams->criteria($findCriteria); $catRecord = array(); foreach (Event::model()->find($findParams) as $record) { $catRecord[intval($record->category_id)] = $record->count; } foreach ($this->categories as $category) { $row[] = isset($catRecord[$category->id]) ? $catRecord[$category->id] : 0; } $this->_rows[] = $row; } // } } return $this->_rows; }
/** * Convenience wrapper to retrieve the API relevant to the given event id * * @param $event_id * @return BaseAPI|bool */ public function getForEventId($event_id) { if ($event = Event::model()->with('eventType')->findByPk($event_id)) { return $this->get($event->eventType->class_name); } return false; }
public function actionRss() { // disabling web log foreach (Yii::app()->log->routes as $route) { if ($route instanceof CWebLogRoute) { $route->enabled = false; } } Yii::import('ext.feed.*'); $feed = new EFeed(); $feed->title = Yii::app()->name . ' | ' . Yii::t('eventModule.common', 'Événements'); $feed->description = Yii::app()->name . ' | ' . Yii::t('eventModule.common', 'meta_description'); $feed->addChannelTag('language', Yii::app()->language); $feed->addChannelTag('pubDate', date(DATE_RSS, time())); $feed->addChannelTag('link', $this->createAbsoluteUrl('index')); if ($events = Event::model()->findAll(array('order' => 'date_start ASC, date_end ASC', 'limit' => 25, 'condition' => "date_end >= '" . date('Y-m-d H:i:s') . "' AND section_id = " . Yii::app()->cms->currentSectionId))) { foreach ($events as $event) { $item = $feed->createNewItem(); $item->title = $event->title; $item->link = $this->createAbsoluteUrl('detail', array('n' => $event->title_url)); $item->date = $event->date_created; if (!empty($event->image)) { $item->description = '<div style="margin-bottom: 1em;"><img src="' . Yii::app()->request->hostInfo . Yii::app()->request->baseUrl . '/' . $event->imageHandler->dir . '/' . Helper::encodeFileName(Helper::fileSuffix($event->image, 's')) . '" alt="' . CHtml::encode($event->title) . '" /></div><div>' . CHtml::encode($event->summary) . '</div>'; } else { $item->description = CHtml::encode($event->summary); } $feed->addItem($item); } } $feed->generateFeed(); Yii::app()->end(); }
/** * Shows payment action */ public function actionPayment() { $eventFound = false; $request = Yii::app()->getRequest(); $eventId = $request->getParam('id', null); $eventLocationId = $request->getParam('evloc', null); $tickets = $request->getParam('tickets', null); if ($eventId !== null && is_numeric($eventId)) { $event = Event::model()->find('id = :id', array(':id' => $eventId)); if ($event !== null) { if ($eventLocationId !== null && is_numeric($eventLocationId)) { $eventLocation = EventLocation::model()->find('id = :id', array(':id' => $eventLocationId)); if ($eventLocation !== null) { if ($tickets !== null && is_numeric($tickets) && $tickets > 0) { $this->render('payment', array('event' => $event, 'eventLocation' => $eventLocation, 'tickets' => $tickets)); $eventFound = true; } } } } } if (!$eventFound) { $this->redirect('/site/search'); } }
/** * Handle the selection of a booking for creating an op note. * * (non-phpdoc) * * @see parent::actionCreate() */ public function actionCreate() { $errors = array(); // if we are after the submit we need to check if any event is selected if (preg_match('/^biometry([0-9]+)$/', Yii::app()->request->getPost('SelectBiometry'), $m)) { $importedEvent = OphInBiometry_Imported_Events::model()->findByPk($m[1]); $this->updateImportedEvent(Event::model()->findByPk($importedEvent->event_id), $importedEvent); $this->redirect(array('/OphInBiometry/default/view/' . $importedEvent->event_id . '?autosaved=1')); } $criteria = new CDbCriteria(); // we are looking for the unlinked imported events in the database $criteria->addCondition('patient_id = :patient_id'); $criteria->addCondition('is_linked = 0'); $criteria->addCondition('event.deleted = 0'); $criteria->params = array(':patient_id' => $this->patient->id); $unlinkedEvents = OphInBiometry_Imported_Events::model()->with(array('patient', 'event'))->findAll($criteria); // if we have 0 unlinked event we follow the manual process if (sizeof($unlinkedEvents) == 0 || Yii::app()->request->getQuery('force_manual') == '1') { Yii::app()->user->setFlash('issue.formula', $this->flash_message); parent::actionCreate(); } else { // if we have more than 1 event we render the selection screen $this->title = 'Please Select a Biometry Report'; $this->event_tabs = array(array('label' => 'The following Biometry reports are available for this patient:', 'active' => true)); $cancel_url = $this->episode ? '/patient/episode/' . $this->episode->id : '/patient/episodes/' . $this->patient->id; $this->event_actions = array(EventAction::link('Cancel', Yii::app()->createUrl($cancel_url), null, array('class' => 'button small warning'))); $this->render('select_imported_event', array('errors' => $errors, 'imported_events' => $unlinkedEvents)); } }
/** * Display page by url. * Example url: /page/some-page-url * @param string $url page url */ public function actionView($url) { $model = Event::model()->withUrl($url)->find(array('limit' => 1)); if (!$model) { throw new CHttpException(404, Yii::t('EventsModule.core', 'Страница не найдена.')); } $this->render('view', array('model' => $model)); }
public function actionDelete($id) { if (null === ($model = Event::model()->findByPk($id))) { throw new CHttpException(404); } if (!$model->delete()) { throw new CException('Cannot delete event'); } }
public function updateForks($src_type) { $time = StatTime::create(__METHOD__); $events = Event::model()->with(['events', 'forks'])->findAllByAttributes(['src_type' => Event::SRCTYPE_COMBINE]); foreach ($events as $event) { /* @var $event Event */ $event->updateForks(); } $time->saveTime(); }
public function findAll($attributes = '', $values = array()) { // because we are working with a view, we should present the event as the last Biometry from the view // we need the patient ID and the last_modified date of the current event // $attributes == "event_id = ?" in this case $eventData = Event::model()->findByPk($values[0]); $episodeData = Episode::model()->findByPk($eventData->episode_id); $latestData = $this->findAllBySql("\n\t\t\t\t\t\tSELECT eob.*, '" . $values[0] . "' AS event_id FROM et_ophtroperationnote_biometry eob\n\t\t\t\t\t\t\t\t\t\tWHERE eob.patient_id=" . $episodeData->patient_id . "\n\t\t\t\t\t\t\t\t\t\tAND eob.last_modified_date <= '" . $eventData->last_modified_date . "'\n\t\t\t\t\t\t\t\t\t\tORDER BY eob.last_modified_date\n\t\t\t\t\t\t\t\t\t\tDESC LIMIT 1; "); return $latestData; }
public function run() { Yii::app()->clientScript->registerCssFile(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('event.assets'), false, -1, YII_DEBUG) . '/css/event.css'); if ($this->sectionId === null) { $events = Event::model()->findAll(array('order' => 'date_start ASC, date_end ASC', 'limit' => $this->maxNbrEntries)); } else { $events = Event::model()->findAll(array('order' => 'date_start ASC, date_end ASC', 'condition' => 'section_id = ' . $this->sectionId, 'limit' => $this->maxNbrEntries)); } $this->render('recentEventsWidget', array('events' => $events)); }
/** * Collate the data and persist it to the table. * * @param $id * * @throws CHttpException * @throws Exception */ public function loadData($id) { $booking = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($id)); $eye = Eye::model()->findByPk($booking->eye_id); if ($eye->name === 'Both') { throw new CHttpException(400, 'Can\'t display whiteboard for dual eye bookings'); } $eyeLabel = strtolower($eye->name); $event = Event::model()->findByPk($id); $episode = Episode::model()->findByPk($event->episode_id); $patient = Patient::model()->findByPk($episode->patient_id); $contact = Contact::model()->findByPk($patient->contact_id); $biometryCriteria = new CDbCriteria(); $biometryCriteria->addCondition('patient_id = :patient_id'); $biometryCriteria->params = array('patient_id' => $patient->id); $biometryCriteria->order = 'last_modified_date DESC'; $biometryCriteria->limit = 1; $biometry = Element_OphTrOperationnote_Biometry::model()->find($biometryCriteria); $examination = $event->getPreviousInEpisode(EventType::model()->findByAttributes(array('name' => 'Examination'))->id); //$management = new \OEModule\OphCiExamination\models\Element_OphCiExamination_Management(); //$anterior = new \OEModule\OphCiExamination\models\Element_OphCiExamination_AnteriorSegment(); $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk(); if ($examination) { //$management = $management->findByAttributes(array('event_id' => $examination->id)); //$anterior = $anterior->findByAttributes(array('event_id' => $examination->id)); $risks = $risks->findByAttributes(array('event_id' => $examination->id)); } $labResult = Element_OphInLabResults_Inr::model()->findPatientResultByType($patient->id, '1'); $allergies = Yii::app()->db->createCommand()->select('a.name as name')->from('patient_allergy_assignment pas')->leftJoin('allergy a', 'pas.allergy_id = a.id')->where("pas.patient_id = {$episode->patient_id}")->order('a.name')->queryAll(); $allergyString = 'None'; if ($allergies) { $allergyString = implode(',', array_column($allergies, 'name')); } $operation = Yii::app()->db->createCommand()->select('proc.term as term')->from('et_ophtroperationbooking_operation op')->leftJoin('ophtroperationbooking_operation_procedures_procedures opp', 'opp.element_id = op.id')->leftJoin('proc', 'opp.proc_id = proc.id')->where("op.event_id = {$id}")->queryAll(); $this->event_id = $id; $this->booking = $booking; $this->eye_id = $eye->id; $this->eye = $eye; $this->predicted_additional_equipment = $booking->special_equipment_details; $this->comments = ''; $this->patient_name = $contact['title'] . ' ' . $contact['first_name'] . ' ' . $contact['last_name']; $this->date_of_birth = $patient['dob']; $this->hos_num = $patient['hos_num']; $this->procedure = implode(',', array_column($operation, 'term')); $this->allergies = $allergyString; $this->iol_model = $biometry ? $biometry->attributes['lens_description_' . $eyeLabel] : 'Unknown'; $this->iol_power = $biometry ? $biometry->attributes['iol_power_' . $eyeLabel] : 'none'; $this->predicted_refractive_outcome = $biometry ? $biometry->attributes['predicted_refraction_' . $eyeLabel] : 'Unknown'; $this->alpha_blockers = $patient->hasRisk('Alpha blockers'); $this->anticoagulants = $patient->hasRisk('Anticoagulants'); $this->alpha_blocker_name = $risks ? $risks->alpha_blocker_name : ''; $this->anticoagulant_name = $risks ? $risks->anticoagulant_name : ''; $this->inr = $labResult ? $labResult : 'None'; $this->save(); }
private function saveEvents($events) { foreach ($events as $item) { $event = Event::model()->findByAttributes(['src_type' => Event::SRCTYPE_PINNACLESPORTS, 'int_id' => $item['int_id']]); $event = $event ? $event : new Event(); /* @var $event Event */ $event->dropEventIdIfChanged($item); $event->setAttributes($item, false); $event->save(); } }
public function run() { if ($this->sectionId !== null && isset($_POST['eventsCalendarWidgetDate']) && (!isset($_POST['eventsCalendarWidgetSectionId']) || $_POST['eventsCalendarWidgetSectionId'] != $this->sectionId)) { return; } Yii::app()->clientScript->registerCssFile(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('event.assets'), false, -1, YII_DEBUG) . '/css/events-calendar-widget.css'); if (Yii::app()->request->isAjaxRequest && isset($_POST['eventsCalendarWidgetDate'])) { $date = getdate(strtotime($_POST['eventsCalendarWidgetDate'])); } else { $date = getdate(); } $dateSqlStart = $date['year'] . '-' . str_pad($date['mon'], 2, '0', STR_PAD_LEFT) . '-01'; $nextMonth = getDate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year'])); $dateSqlEnd = $date['year'] . '-' . str_pad($nextMonth['mon'], 2, '0', STR_PAD_LEFT) . '-01'; if ($this->sectionId !== null) { $eventModels = Event::model()->findAll(array('condition' => 't.date_start < :dateend AND t.date_end >= :datestart AND t.section_id = :sectionId', 'params' => array(':datestart' => $dateSqlStart, ':dateend' => $dateSqlEnd, ':sectionId' => $this->sectionId))); } else { $eventModels = Event::model()->findAll(array('condition' => 't.date_start < :dateend AND t.date_end >= :datestart', 'params' => array(':datestart' => $dateSqlStart, ':dateend' => $dateSqlEnd))); } $events = array(); foreach ($eventModels as $eventModel) { $monthStart = substr($eventModel->date_start, 5, 2); $yearStart = substr($eventModel->date_start, 0, 4); $dayStart = substr($eventModel->date_start, 8, 2); $dayEnd = substr($eventModel->date_end, 8, 2); $monthEnd = substr($eventModel->date_end, 5, 2); $yearEnd = substr($eventModel->date_end, 0, 4); if ($monthStart == $monthEnd && $yearStart == $yearEnd) { $dayEnd = substr($eventModel->date_end, 8, 2); } elseif (($monthStart < $monthEnd || $yearStart < $yearEnd) && ($date['mon'] == $monthEnd && $date['year'] == $yearEnd)) { $dayStart = 1; } elseif (($monthStart < $monthEnd || $yearStart < $yearEnd) && ($date['mon'] == $monthStart && $date['year'] == $yearStart)) { $dayEnd = 31; } else { $dayStart = 1; $dayEnd = 31; } for ($i = (int) $dayStart; $i <= $dayEnd; $i++) { if (!isset($events[$i])) { $events[$i] = array(); } $events[$i][] = $eventModel; } } $render = $this->render('eventsCalendarWidget', array('events' => $events, 'date' => $date), true); if (Yii::app()->request->isAjaxRequest) { echo "\n" . '<div id="events-calendar-widget-render">' . "\n"; echo $render; echo "\n" . '</div>' . "\n"; Yii::app()->end(); } else { echo $render; } }
public function run() { $criteria = new CDbCriteria(); $count = Event::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = $this->count; $pages->applyLimit($criteria); $events = Event::model()->findAll($criteria); $this->provider = new CActiveDataProvider('Event', array('id' => false, 'pagination' => array('pageSize' => $this->count))); $this->render($this->view, array('events' => $events, 'pages' => $pages, 'provider' => $this->provider)); }
public function actionGetAllEvents() { $events = Event::model()->findAll(array('select' => array('id', 'title', 'startDate'))); $response = array(); foreach ($events as $event) { $element = array(); $element['id'] = $event->id; $element['title'] = $event->title; $element['startDate'] = DateTimeHelper::formatForEventForm($event->startDate); $response[] = $element; } $this->send($response); }
public function run() { $criteria = new CDbCriteria(); $criteria->compare('episode_id', $this->episode->id); $criteria->compare('event_type_id', $this->event_type->id); $criteria->order = 'event_date'; $iop = null; foreach (Event::model()->findAll($criteria) as $event) { if ($iop = models\Element_OphCiExamination_IntraocularPressure::model()->find('event_id=?', array($event->id))) { break; } } $this->render('OphCiExamination_Episode_IOP', array('iop' => $iop)); }
/** * Delete event by Pk */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { $model = Event::model()->findAllByPk($_REQUEST['id']); if (!empty($model)) { foreach ($model as $event) { $event->delete(); } } if (!Yii::app()->request->isAjaxRequest) { $this->redirect('index'); } } }
private function saveEvents($events) { $ids = []; foreach ($events as $item) { $event = Event::model()->findByAttributes(['src_type' => Event::SRCTYPE_WILLIAMHILL, 'int_id' => $item['int_id']]); $event = $event ? $event : new Event(); /* @var $event Event */ $event->dropEventIdIfChanged($item); $event->setAttributes($item, false); $event->save(); // Запоминаем id событий $ids[] = $event->id; } return $ids; }
/** * return only previous injections given a starting event id. */ public function previousInjectionsByEvent($event_id, $side, $drug) { $event = Event::model()->find('id = :id', array(':id' => $event_id)); $episode = $event->episode; $patient = $event->episode->patient; $injections = $this->previousInjections($patient, $episode, $side, $drug); //remove this event and events in the future $previousInjections = array(); foreach ($injections as $injection) { if ($event_id > $injection['event_id']) { $previousInjections[] = $injection; } } return $previousInjections; }
/** * Omnibox search handler */ public function actionSearch() { if (isset($_POST['query']) && ($query = trim($_POST['query']))) { // Event ID if (preg_match('/^(E|Event)\\s*[:;]\\s*([0-9]+)$/i', $query, $matches)) { $event_id = $matches[2]; if ($event = Event::model()->findByPk($event_id)) { $event_class_name = $event->eventType->class_name; $this->redirect(array($event_class_name . '/default/view/' . $event_id)); } else { Yii::app()->user->setFlash('warning.search_error', 'Event ID not found'); $this->redirect('/'); } return; } // NHS number (assume 10 digit number is an NHS number) if (preg_match('/^(N|NHS)\\s*[:;]\\s*([0-9\\- ]+)$/i', $query, $matches) || preg_match('/^([0-9]{3}[- ]?[0-9]{3}[- ]?[0-9]{4})$/i', $query, $matches)) { $nhs = isset($matches[2]) ? $matches[2] : $matches[1]; $nhs = str_replace(array('-', ' '), '', $nhs); $this->redirect(array('patient/search', 'nhs_num' => $nhs)); return; } // Hospital number (assume a < 10 digit number is a hosnum) if (preg_match('/^(H|Hosnum)\\s*[:;]\\s*([0-9a-zA-Z\\-]+)$/i', $query, $matches) || preg_match(Yii::app()->params['hos_num_regex'], $query, $matches)) { $hosnum = isset($matches[2]) ? $matches[2] : $matches[1]; $this->redirect(array('patient/search', 'hos_num' => $hosnum)); return; } // Patient name if (preg_match('/^(?:P(?:atient)?[:;\\s]*)?(.*[ ,].*)$/', $query, $m)) { $name = $m[1]; if (strpos($name, ',') !== false) { list($surname, $firstname) = explode(',', $name, 2); } else { list($firstname, $surname) = explode(' ', $name, 2); } $this->redirect(array('patient/search', 'first_name' => trim($firstname), 'last_name' => trim($surname))); } } if (isset($query)) { if (strlen($query) == 0) { Yii::app()->user->setFlash('warning.search_error', "Please enter either a hospital number or a firstname and lastname."); } else { Yii::app()->user->setFlash('warning.search_error', '<strong>"' . CHtml::encode($query) . '"</strong> is not a valid search.'); } } $this->redirect('/'); }
public function actionInfo($eventId) { $event = Event::model()->findByPk($eventId); $defaultCityId = 4466; $pricesData = array(); $this->layout = 'static'; foreach ($event->prices as $price) { $pricesData[$price->city->id] = array('price' => floor($price->bestPrice), 'cityName' => $price->city->localRu, 'cityId' => $price->city->id, 'updateTime' => str_replace(' ', 'T', $price->updated)); } $tours = array(); $dataProvider = new TripDataProvider(); $cities = array(); foreach ($event->tours as $tour) { $tours[$tour->startCityId] = array(); $dataProvider->restoreFromDb($tour->orderId); //echo $tour->orderId.'dsf'; //print_r($dataProvider->getSortedCartItemsOnePerGroup(false));//die(); $items = $dataProvider->getWithAdditionalInfo($dataProvider->getSortedCartItemsOnePerGroup(false)); //print_r($items);die(); $tours[$tour->startCityId] = $items; $tours[$tour->startCityId]['city'] = City::getCityByPk($tour->startCityId)->getAttributes(); $eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $tour->startCityId)); if ($eventPrice) { $tours[$tour->startCityId]['price'] = ceil($eventPrice->bestPrice); } $cities[$tour->startCityId] = City::getCityByPk($tour->startCityId)->getAttributes(); } //die(); if (!isset($cities[$defaultCityId])) { foreach ($cities as $defaultCityId => $city) { break; } } //need search params $twoCities = array(); $twoCities[$defaultCityId] = $cities[$defaultCityId]; foreach ($cities as $cityId => $city) { if (!isset($twoCities[$cityId])) { $twoCities[$cityId] = $city; break; } } $pictures = array(); foreach ($event->pictures as $picture) { $pictures[] = array('url' => $picture->getUrl()); } $this->render('info', array('event' => $event, 'priceData' => $pricesData, 'defaultCity' => $defaultCityId, 'tours' => $tours, 'cities' => $cities, 'twoCities' => $twoCities, 'pictures' => $pictures)); }
public function actionIndex() { if (isset($_GET['id'])) { $model = Event::model()->findByPk($_GET['id']); $this->render('detail', array('model' => $model)); } else { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = "event_start >= " . date('Y-m-d') . " AND event_status = 1"; $criteria->order = "event_start ,event_id"; $event_total = Event::model()->count($criteria); $pages = new CPagination($event_total); $pages->setPageSize(10); $pages->applyLimit($criteria); $model = Event::model()->findAll($criteria); $this->render('index', array('model' => $model, 'pages' => $pages)); } }
public function actionIndex() { $feed_title = Awecms::getSiteName(); $feed_description = Settings::get('site', 'tagline'); //provide model name or array of models, implementing page behavior $pageModels = array('Page', 'News', Event::model()->findAll()); //for models other than implementing Page behavior $otherModels = array(array('Album', 'title', 'content', '/gallery/album/view/id/{id}'), array('Business', 'title', 'content', '/directory/business/view/id/{id}'), array('Image', 'title', 'description', '/gallery/image/view/id/{id}')); foreach ($otherModels as $otherModel) { $link = isset($otherModel[3]) ? $otherModel[3] : NULL; $this->addToFeed($otherModel[0], $otherModel[1], $otherModel[2], $link); } foreach ($pageModels as $model) { $this->addToFeed($model, 'title', 'content'); } // generate and render RSS feed $feed = Zend_Feed::importArray(array('title' => $feed_title, 'description' => $feed_description, 'link' => $this->createUrl(''), 'charset' => 'UTF-8', 'generator' => 'AweCMS', 'entries' => $this->entries), 'rss'); $feed->send(); }
public function actionCreate() { //provide model name or array of models, implementing page behavior $pageModels = array('Page', 'News', Event::model()->findAll()); //for models other than implementing Page behavior $otherModels = array(array('Album', 'title', 'content', '/gallery/album/view/id/{id}'), array('Business', 'title', 'content', '/directory/business/view/id/{id}'), array('Image', 'title', 'description', '/gallery/image/view/id/{id}')); echo "Search index creation started.<br/>"; echo "Creating indices on {$this->_indexFile}<br/><br/>"; $this->index = new Zend_Search_Lucene($this->_indexFile, true); foreach ($otherModels as $otherModel) { $link = isset($otherModel[3]) ? $otherModel[3] : NULL; $this->addIndex($otherModel[0], $otherModel[1], $otherModel[2], $link); } echo '<br/>'; echo "Creating indices for models with Page behavior...<br/>"; foreach ($pageModels as $model) { $this->addIndex($model, 'title', 'content'); } self::printInfoFromIndex($this->index); }
public function getFooterProcedures($event_id) { if (!($event = Event::model()->findByPk($event_id))) { throw new Exception("Event not found: {$event_id}"); } if (!($element = Element_OphTrConsent_Procedure::model()->find('event_id=?', array($event->id)))) { throw new Exception("Procedure element not found, possibly not a consent event: {$event_id}"); } $return = 'Procedure(s): '; foreach ($element->procedures as $i => $proc) { if ($i >= 2) { $return .= '...'; break; } elseif ($i) { $return .= ', '; } $return .= $proc->term; } return $return; }
public function run($args) { $event_type_id = EventType::model()->find('class_name = :classname', array(':classname' => 'OphInVisualfields'))->id; $patient_ids = Yii::app()->db->createCommand()->selectDistinct('patient_id')->from('measurement_reference mr')->join('patient_measurement pm', 'pm.id = mr.patient_measurement_id')->queryColumn(); foreach ($patient_ids as $patient_id) { $criteria = new CDbCriteria(); $criteria->condition = 'event_type_id = :event_type_id AND patient_id = :patient_id'; $criteria->join = 'join episode ep on ep.id = t.episode_id'; $criteria->order = 'event_date desc'; $criteria->limit = '3'; $criteria->params = array(':patient_id' => $patient_id, ':event_type_id' => $event_type_id); $events = Event::model()->findAll($criteria); foreach ($events as $event) { echo ' - ' . $event->id . "\n"; MeasurementReference::model()->deleteAll('event_id = ?', array($event->id)); $event->deleted = 1; $event->save(); } echo "{$patient_id}\n"; } }
public function run() { $data = array(); $events = Event::model()->findAll(array('join' => 'inner join episode ep on ep.id = t.episode_id', 'condition' => 't.event_type_id = :event_type_id and ep.patient_id = :patient_id', 'order' => 't.event_date', 'params' => array(':event_type_id' => $this->event_type->id, ':patient_id' => $this->episode->patient->id))); if ($events) { $data['start_date'] = strtotime(reset($events)->created_date); $data['end_date'] = strtotime(end($events)->created_date); } $data['elements'] = array(); $element_ids = array(); foreach ($events as $event) { if ($element = $event->getElementByClass('Element_OphInVisualfields_Image')) { $data['elements'][] = $element; $element_ids[] = $element->id; } else { Yii::log("Visual Field Event {$event->id} has no Image element"); } } Yii::app()->assetManager->registerScriptFile('jquery-mousewheel/jquery.mousewheel.js', 'application.assets.components'); Yii::app()->assetManager->registerScriptFile('js/module.js', 'application.modules.OphInVisualfields.assets'); Yii::app()->clientScript->registerScript('OphInVisualfields_Episode_VisualFieldsHistory_element_ids', 'var OphInVisualfields_Episode_VisualFieldsHistory_element_ids = ' . CJSON::encode($element_ids), CClientScript::POS_END); $this->render(__CLASS__, $data); }
/** * Resize event via AJAX */ public function actionResize() { if (!Yii::app()->user->hasState('calUserId')) { Yii::app()->end(); } $delta = $_POST['delta']; $eventId = $_POST['eventId']; if (Yii::app()->request->isAjaxRequest and !empty($eventId)) { $event = Event::model()->findByPk($eventId); $event->end += $delta; $event->save(); Yii::app()->end(); } }
/** * Sets a letter element to print when it's next viewed. * * @param $id * * @return bool * * @throws Exception */ protected function setPrintForEvent($id) { if (!($letter = ElementLetter::model()->find('event_id=?', array($id)))) { throw new Exception("Letter not found for event id: {$id}"); } $letter->print = 1; $letter->draft = 0; if (@$_GET['all']) { $letter->print_all = 1; } if (!$letter->save()) { throw new Exception('Unable to save letter: ' . print_r($letter->getErrors(), true)); } if (!($event = Event::model()->findByPk($id))) { throw new Exception("Event not found: {$id}"); } $event->info = ''; if (!$event->save()) { throw new Exception('Unable to save event: ' . print_r($event->getErrors(), true)); } return true; }