protected function findModel($id)
 {
     if (($model = Event::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * Загружает запись модели текущего контроллера по айдишнику
  * @param $id
  * @return null|static
  * @throws \yii\web\HttpException
  */
 public function loadModel($id)
 {
     $model = Event::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #3
0
 public function actionSend()
 {
     //      //broadcast semua
     //      $email = new Email();
     //     if ($email->load(Yii::$app->request->post()) && $email->validate()) {
     //      $peserta = Peserta::find()->all();
     //      foreach($peserta as $key){
     //          $temp = $key->email;
     // echo $temp;
     //          $content_template = $email->content;
     //          //mengambil subjek dari email yang akan dikirimkan
     //          $subject_template = $email->subject;
     //          $subject = str_replace("{nama}", $key->nama, $subject_template);
     //          $content = str_replace("{nama}", $key->nama, $content_template);
     //          echo "</br>";
     //          Yii::$app->mailer
     //                   ->compose()
     //                   ->setFrom(Yii::$app->params['adminEmail'])
     //                   ->setHtmlBody($content)
     //                   ->setSubject($subject)
     //                   ->setTo($temp)
     //                   ->send();
     //          }
     //      }
     //send per event
     $email = new Email();
     if ($email->load(Yii::$app->request->post()) && $email->validate()) {
         //mengambil event yang dipilih
         $event = Event::findOne($email->id_event);
         //mengambil content dari email yang akan dikirimkan
         $content_template = $email->content;
         //mengambil subjek dari email yang akan dikirimkan
         $subject_template = $email->subject;
         foreach ($event->absensis as $absensi) {
             $temp = $absensi->idPeserta->email;
             echo $temp;
             // echo $absensi->idPeserta->email;
             echo "</br>";
             $subject = str_replace("{nama}", $absensi->idPeserta->nama, $subject_template);
             $subject = str_replace("{nama_seminar}", $event->nama, $subject);
             $subject = str_replace("{jadwal}", $event->jadwal, $subject);
             $content = str_replace("{nama}", $absensi->idPeserta->nama, $content_template);
             $content = str_replace("{nama_seminar}", $event->nama, $content);
             $content = str_replace("{jadwal}", $event->jadwal, $content);
             Yii::$app->mailer->compose()->setFrom(Yii::$app->params['adminEmail'])->setHtmlBody($content)->setSubject($subject)->setTo($temp)->send();
         }
     }
 }
Beispiel #4
0
<?php

use app\models\Event;
use app\models\Cart;
$_event = Event::findOne(2);
$carts = Cart::findAll(['status' => Cart::CART_SOLD]);
$sold_tickets = [];
foreach ($carts as $cart) {
    $items = $cart->items;
    foreach ($items as $i) {
        if (!isset($sold_tickets[$i->ticket_id])) {
            $sold_tickets[$i->ticket_id] = 0;
        }
        $sold_tickets[$i->ticket_id] += $i->quantity;
    }
}
$sold_total = 0;
$total_tickets_sold = 0;
$this->title = Yii::t('app', 'Event Summary');
?>
<div class="foxden-default-index">
    <h1><?php 
echo $this->title;
?>
</h1>
    <?php 
foreach ($_event->ticketGroups as $group) {
    if (sizeof($_event->ticketGroups) > 1) {
        ?>
<h2><?php 
        echo $group->name;
 /**
  * Finds the Event model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $slug
  * @return Event the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelBySlug($slug)
 {
     if (($model = Event::findOne(['slug' => $slug])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionEntry()
 {
     $model = new AbsensiForm();
     $data = Event::find()->all();
     if ($model->load(Yii::$app->request->get()) && $model->validate()) {
         $event = Event::findOne($model->id_event);
         return $this->render('absensi-confirm', ['event' => $event]);
     } else {
         return $this->render('absensi', ['model' => $model, 'data' => $data]);
     }
 }
Beispiel #7
0
 /**
  * Поиск Sphinx айтемов и событий
  * @return string
  */
 function actionSearch()
 {
     if (Yii::$app->getRequest()->getQueryParam('user')) {
         $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user'));
         if (!$user) {
             return 'Доступ запрещен!';
         }
         if (Yii::$app->getRequest()->getQueryParam('text')) {
             $items_records = [];
             $events_records = [];
             $query = new Query();
             // $search_result = $query_search->from('siteSearch')->match($q)->all();  // поиск осуществляется по средством метода match с переданной поисковой фразой.
             $query_items_ids = $query->from('items')->match(Yii::$app->getRequest()->getQueryParam('text'))->all();
             foreach ($query_items_ids as $arr_item_rec) {
                 foreach ($arr_item_rec as $id) {
                     $items_records[] = Items::findOne((int) $id);
                 }
             }
             //return $this->renderPartial('searched', ['items_rows' => $items_records, 'events_rows' => 2]);
             $query_events_ids = $query->from('events')->match(Yii::$app->getRequest()->getQueryParam('text'))->all();
             foreach ($query_events_ids as $arr_event_rec) {
                 foreach ($arr_event_rec as $id) {
                     $events_records[] = Event::findOne((int) $id);
                 }
             }
             //var_dump($events_records); exit;
             sort($events_records);
             krsort($events_records);
             return $this->renderPartial('searched', ['items_rows' => is_array($items_records) && !empty($items_records) && $items_records ? $items_records : 'Ничего не найдено', 'events_rows' => is_array($events_records) && !empty($events_records) && $events_records ? $events_records : 'Ничего не найдено']);
         }
         return $this->renderPartial('search_form');
     }
 }