Example #1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('username', $this->username, true);
     $criteria->compare('password', $this->password, true);
     $criteria->compare('email', $this->email, true);
     $criteria->compare('login_attempts', $this->login_attempts);
     $criteria->compare('last_login_time', $this->last_login_time, true);
     $criteria->compare('create_time', $this->create_time, true);
     $criteria->compare('update_time', $this->update_time, true);
     $group = CommonFunctions::getCurrentGroup();
     if (null === $group) {
         throw new CHttpException(404, 'The current group is not specified.');
     }
     $criteria->compare('group_id', $group->id);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => false));
 }
Example #2
0
<?php

/* @var $this EventController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs = array('Events');
$this->menu = array(array('label' => 'Create Event', 'url' => array('create')), array('label' => 'Manage Event', 'url' => array('admin')));
?>

<h1>Matches</h1>
<h3>Group: <?php 
echo CommonFunctions::getCurrentGroup()->name;
?>
</h3>
<div>
<table id="table_events" class="table">
    <?php 
foreach ($data as $d) {
    if ($d['type'] == 'date') {
        echo '<tr class="date">' . '<td colspan="4"><h3>' . $d['data'] . '</h3></td>' . '</tr>';
    } else {
        if ($d['type'] == 'event') {
            $event = $d['data'];
            echo '<tr class="event">' . '<td></td>' . '<td>' . date('h:i A', strtotime($event->start_time)) . '</td>' . '<td>' . $event->name . '</td>' . '<td><button type="button" class="btn btn-primary" id="' . $event->id . '">Show Bets</button></td>' . '</tr>';
        } else {
            if ($d['type'] == 'bet') {
                echo '<tr class="bet">' . '<td colspan="4">' . $d['type'] . '</td>' . '</tr>';
            }
        }
    }
}
?>
Example #3
0
 public static function getEventsList()
 {
     // select all matches starting in next 2 days
     //$gid = CommonFunctions::getCurrentGroup()->id;
     $group = CommonFunctions::getCurrentGroup();
     if (null === $group) {
         throw new CHttpException(404, 'The current group is not specified.');
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("start_time BETWEEN '" . date('Y-m-d') . "' AND '" . date('Y-m-d', strtotime('5 days')) . "'");
     $criteria->addColumnCondition(array("group_id" => $group->id, "status" => Event::STATUS_PUBLISHED));
     $criteria->order = 'start_time';
     $events = Event::model()->findAll($criteria);
     $result = new CList();
     $last_date = NULL;
     $format = "d_m_y";
     foreach ($events as $e) {
         // date row
         $current_date = date('m/d/y', strtotime($e->start_time));
         if ($current_date != $last_date) {
             $data = new CMap();
             $data['type'] = 'date';
             $data['data'] = $current_date;
             $result[] = $data;
             $last_date = $current_date;
         }
         // event data row
         $data = new CMap();
         $data['type'] = 'event';
         $data['data'] = $e;
         $result[] = $data;
         // bet detail row
         $data = new CMap();
         $data['type'] = 'bet';
         $data['data'] = $e;
         $result[] = $data;
     }
     return $result;
 }