public function actionTest($id)
 {
     // renders the view file 'protected/views/screen/display.php'
     // using the default layout 'protected/views/layouts/billboard.php'
     $this->screen_id = $id;
     $screen = Screen::model()->findByPk($id);
     if ($screen === null) {
         throw new CHttpException(404, Yii::t('error', 'The requested screen does not exist.'));
     }
     Yii::app()->theme = count($screen->themes) == 0 ? 'he' : $screen->themes[0]->theme;
     $conditions = array();
     $conditions[] = 'ads.expire>=:now';
     $conditions[] = 'ads.start<=:now';
     $conditions[] = 'ads.' . date('D', strtotime('now')) . '=1';
     $ads = $screen->ads(array('condition' => implode(' AND ', $conditions), 'params' => array(':now' => date('Y-m-d', strtotime('now')))));
     $yeshuv = $screen->yeshuv->name_heb;
     $commercial = $screen->commercials[0]->file_name;
     date_default_timezone_set('Asia/Jerusalem');
     if ($this->isweekend()) {
         $holiday = Holiday::model()->find(array('condition' => 'name = :name', 'params' => array(':name' => 'friday')));
     } else {
         $holiday = Holiday::model()->find(array('condition' => 'end_date >= :now && start_date <= :now', 'params' => array(':now' => date('Y-m-d H:i:s', strtotime('now')))));
     }
     $this->render('test', array('ads' => $ads, 'screen' => $screen, 'yeshuv' => $yeshuv, 'commercial' => 5, 'holiday' => $holiday));
 }
Beispiel #2
0
 public function CreateChannelsForWindows($screenId, $netId)
 {
     $Screen = Screen::model()->findByPk($screenId);
     $windows = $Screen->windows;
     NetChannel::model()->deleteAll("net_id = :net_id", array('net_id' => $netId));
     foreach ($windows as $window) {
         $channel = new NetChannel();
         $channel->attributes = array('net_id' => $netId, 'window_id' => $window->id);
         $channel->save();
     }
 }
Beispiel #3
0
$ScreenModels = $userModel->screens;
$selectedItems = array();
foreach ($ScreenModels as $val) {
    $dropDown[$val->id] = $val->name;
}
if (!$model->isNewRecord) {
    $ScreenModelId = $model->screen_id;
    $selectedItems[$ScreenModelId] = array('selected' => 'selected');
}
echo $form->dropDownList($model, 'screen_id', $dropDown, array('options' => $selectedItems, 'multiple' => false, 'class' => 'form-control', 'size' => '10'));
printf("<div id='windowsList'>");
if (!$model->isNewRecord) {
    $channels = $model->channels;
    $ScreenModelId = $model->screen_id;
    if ($ScreenModelId != null) {
        $ScreenModel = Screen::model()->findByPk($ScreenModelId);
        if (isset($ScreenModel->windows)) {
            $windows = $ScreenModel->windows;
            foreach ($windows as $window) {
                $windowId = $window->id;
                $windowName = $window->name;
                foreach ($channels as $channel) {
                    if ($channel->id_point === $model->id && $channel->window_id === $window->id) {
                        printf("<div class='ChannelsContainer btn-toolbar' data-channelid='%s' role='toolbar' aria-label=''>", $channel['id']);
                        $widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $channel['id']));
                        printf("<div class='btn-group' role='group' aria-label=''>" . "<button type='button' class='btn btn-default ChannelButt' disabled='disabled'>Screen %s</button>", $windowName);
                        if (count($widgetToChannel) > 0) {
                            $widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
                            printf("<button type='button' class='detach-widget btn btn-warning' data-channelid='%s'>" . "<span class='glyphicon glyphicon-off'></span> Detach widget " . $widgetModel['name'] . "</button>", $channel['id']);
                        } else {
                            printf("<button type='button' class='attach-widget btn btn-success' data-channelid='%s'>" . "<span class='glyphicon glyphicon-paperclip'></span> Attach widget" . "</button>", $channel['id']);
Beispiel #4
0
<?php

/* @var $this ThemeController */
/* @var $model Theme */
/* @var $form CActiveForm */
?>

<div class="form">
<?php 
$form = $this->beginWidget('booster.widgets.TbActiveForm', array('id' => 'CreateScreenForm', 'type' => 'horizontal'));
?>

<fieldset>
    <?php 
echo $form->dropDownListGroup($model, 'theme', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Screen::model()->getAvailiableTheme(), 'htmlOptions' => array())));
?>

    <?php 
echo $form->textAreaGroup($model, 'description', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('htmlOptions' => array('rows' => 4))));
?>
</fieldset>

<div class="form-actions">
        <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'submit', 'context' => 'primary', 'label' => YII::t('default', 'Submit')));
?>
        <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'reset', 'label' => YII::t('default', 'Reset')));
?>
</div>
<?php 
Beispiel #5
0
 /**
  * Displays the map with the availiable screens
  */
 public function actionMap()
 {
     $model = Screen::model()->with('geocodes', 'yeshuv', 'commercials')->findAll();
     $array = array();
     date_default_timezone_set('Asia/Jerusalem');
     $now = new DateTime();
     $now = $now->modify("-10 minutes");
     $id = 0;
     $green = 0;
     foreach ($model as $m) {
         $color = "red";
         $screenAjax = ScreenAjax::model()->findByPk($m->id);
         if ($screenAjax) {
             $last = strtotime($screenAjax->last_date);
             if ($last > $now->getTimestamp()) {
                 $color = "green";
                 $green++;
             }
         }
         if (count($m->geocodes) < 1) {
             $geocode = new Geocode();
             $location = Screen::model()->geocodeLookup($m->name . ',' . $m->yeshuv->name_heb);
             $geocode->lat = $location['lat'];
             $geocode->lng = $location['lng'];
             if ($geocode->save()) {
                 $screenGeocode = new ScreenGeocodeAssignment();
                 $screenGeocode->screen_id = $m->id;
                 $screenGeocode->geocode_id = $geocode->id;
                 $screenGeocode->save();
             }
             $marker = array('id' => $id++, 'name' => $m->name . ', ' . $m->yeshuv->name_heb, 'url' => $m->webkey_nickname, 'lat' => $geocode->lat, 'lng' => $geocode->lng, 'commercial' => $m->commercials[0]->name, 'color' => $color);
             array_push($array, $marker);
         } else {
             $marker = array('id' => $id++, 'name' => $m->name . ', ' . $m->yeshuv->name_heb, 'url' => $m->webkey_nickname, 'lat' => $m->geocodes[0]->lat, 'lng' => $m->geocodes[0]->lng, 'commercial' => $m->commercials[0]->name, 'color' => $color);
             array_push($array, $marker);
         }
     }
     $this->render('map', array('markers' => $array, 'green' => $green));
 }
 /**
  * Ajax return the screens for a specific commercial area.
  */
 public function actionGetSearchScreens()
 {
     if (isset($_GET['term'])) {
         $criteria = new CDbCriteria();
         $criteria->select = 'id, name';
         $criteria->condition = 'name LIKE :term OR name_heb LIKE :term';
         $criteria->params = array(':term' => '%' . $_GET['term'] . '%');
         $criteria->with = array('yeshuv' => array('select' => 'name_heb'));
         $criteria->together = true;
         $res = Screen::model()->findAll($criteria);
         if (count($res) > 0) {
             foreach ($res as $item) {
                 $returnVal[] = array('value' => $item->name . ', ' . $item->yeshuv->name_heb, 'id' => $item->id);
             }
             echo CJSON::encode($returnVal);
         } else {
             echo CJSON::encode("");
         }
     }
     Yii::app()->end();
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Screen the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Screen::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #8
0
$userId = Yii::app()->user->getId();
$userModel = User::model()->findByPk($userId);
$screens = $userModel->screens;
$selectedItems = array();
foreach ($screens as $val) {
    $dropDown[$val->id] = $val->name;
}
if (!$model->isNewRecord) {
    $screenId = $model->screen_id;
    $selectedItems[$screenId] = array('selected' => 'selected');
}
echo $form->dropDownList($model, 'screen_id', $dropDown, array('options' => $selectedItems, 'multiple' => false, 'class' => 'form-control', 'size' => '10'));
printf("<div id='windowsList'>");
if (!$model->isNewRecord) {
    $screenId = $model->screen_id;
    $screen = Screen::model()->findByPk($screenId);
    $windows = $screen->windows;
    foreach ($windows as $window) {
        $windowId = $window->id;
        $windowInst = Window::model()->findByPk($windowId);
        $windowName = $windowInst->name;
        $channels = $windowInst->netChannels;
        foreach ($channels as $channel) {
            if ($channel->net_id == $model->id) {
                printf("<div class='ChannelsContainer btn-toolbar' data-channelid='%s' role='toolbar' aria-label=''>", $channel['id']);
                $channelM = NetChannel::model()->findByPk($channel['id']);
                $pls = $channelM->playlists;
                printf("<div class='btn-group' role='group' aria-label=''>" . "<button type='button' class='btn btn-default ChannelButt' disabled='disabled'>Screen %s</button>" . "<button type='button' class='AddPlaylistsBut btn btn-info' data-channelid='%s'>" . "<span class='glyphicon glyphicon-plus'></span> Add playlists" . "</button></div>", $windowName, $channel['id']);
                foreach ($pls as $pl) {
                    echo "<div class='btn-group' role='group' aria-label=''>";
                    printf("<button type='button' class='PlaylistLinks btn btn-default' " . "data-plid='%s'>%s</button>", $pl['id'], CHtml::link($pl['name'], array('playlists/' . $pl['id'])));
Beispiel #9
0
 /**
  * public function to return the bizrule that verifies the user can
  * Administer the Ad.
  */
 public function bizruleCreate()
 {
     if ($this->isUserInRole('Administrator')) {
         return TRUE;
     }
     $auth = Screen::model()->with(array('users' => array('condition' => 'users.id = :user_id', 'params' => array(':user_id' => Yii::app()->user->id)), 'together' => true))->findByPk($this->_screen->id);
     return $auth == null ? FALSE : TRUE;
 }
Beispiel #10
0
 public function CreateChannelsForWindows($screenId, $pointId)
 {
     $Screen = Screen::model()->findByPk($screenId);
     $windows = $Screen->windows;
     Channel::model()->deleteAll("id_point = :id_point AND window_id IS NOT NULL", array('id_point' => $pointId));
     $ii = 0;
     foreach ($windows as $window) {
         $ii++;
         $channel = new Channel();
         $channel->attributes = array('id_point' => $pointId, 'window_id' => $window->id, 'internalId' => $ii);
         $channel->save();
     }
 }