public function actionAjaxGetChannels()
 {
     $pointId = Yii::app()->request->getPost('pointId');
     $pointDateStr = date('Y-m-d');
     $requestTime = date('H:i:s');
     $pointDatetimeStr = $pointDateStr . " 23:59:59";
     $pointDateTimestamp = strtotime($pointDateStr);
     $weekDay = strtolower(date('D', $pointDateTimestamp));
     $Playlist = new Playlists();
     $pointChannels = Channel::model()->findAll('id_point=:id_point AND window_id IS NOT NULL', array(':id_point' => $pointId));
     $resp = array();
     foreach ($pointChannels as $pointChannel) {
         $pointChannelId = $pointChannel->internalId;
         $windowId = $pointChannel->window_id;
         if (!is_null($windowId)) {
             $bg = $Playlist->GetBGContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $adv = $Playlist->GetAdvContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $blockStructedContent = $Playlist->BuildBlockStructedContent($bg, $adv);
             $straightTimeContent = $Playlist->ConverBlockStructedToStraightTimeContent($blockStructedContent);
             $straightTimeContentHisToSecs = $this->ConvertHisToSecsInStraightTime($straightTimeContent, $requestTime);
             $url = Yii::app()->request->getBaseUrl(true) . '/spool/points/' . $pointId . '/' . $pointChannelId;
             $straightTimeContentWithURLPath = $this->UpdateContentPathes($straightTimeContentHisToSecs, $url);
             $window = Window::model()->findByPK($windowId);
             $widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $pointChannel->id));
             $widget = '';
             if (count($widgetToChannel) > 0) {
                 $widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
                 $widget = $widgetModel['content'];
             }
             $resp[] = array('width' => $window->width, 'height' => $window->height, 'top' => $window->top, 'left' => $window->left, 'content' => $straightTimeContentWithURLPath, 'widget' => $widget);
         }
     }
     echo json_encode($resp);
     exit;
 }
 public function actionDetachWidget()
 {
     $request = Yii::app()->request;
     if ($channelId = $request->getParam('channelId')) {
         if (WidgetToChannel::model()->deleteAll("channel_id = :channel_id", array("channel_id" => $channelId))) {
             echo json_encode(array('status' => 'ok'));
         } else {
             echo json_encode(array('status' => 'err', 'error' => 'Error during detaching widget'));
         }
     } else {
         echo json_encode(array('status' => 'err', 'error' => 'Incorrect POST data during DetachWidget action'));
     }
 }
Пример #3
0
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']);
                        }
                        echo "</div>";
                    }
                }
            }
        }
    }
}
printf("</div>");