Пример #1
0
$timeslots = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23');
$slots = SustainerSlots::get_all();
$i = 0;
echo "<table class=\"table table-striped table-bordered\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th></th>\r\n\t<th>Monday</th>\r\n\t<th>Tuesday</th>\r\n\t<th>Wednesday</th>\r\n\t<th>Thursday</th>\r\n\t<th>Friday</th>\r\n\t<th>Saturday</th>\r\n\t<th>Sunday</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>";
$i = 0;
foreach ($slots as $slot) {
    if ($i < 1) {
        echo "<tr>\r\n\t\t\t<td>" . $slot->get_time() . ":00</td>";
    }
    $thisPlaylist = Playlists::get_by_id($slot->get_playlist_id());
    $thisPlaylistColour = $thisPlaylist->get_colour() == "" ? 'FFFFFF' : $thisPlaylist->get_colour();
    echo "<td class='timeslot' id='slot-" . $slot->get_day() . "-" . $slot->get_time() . "' style='background-color: #" . $thisPlaylistColour . ";'>";
    echo $slot->get_audio_id() == NULL ? '' : "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>";
    echo "</td>";
    $i++;
    if ($i > 6) {
        echo "</tr>";
        $i = 0;
    }
}
echo "</tbody>\r\n\t</table>";
echo "<form>";
foreach ($slots as $slot) {
    echo "<input type=\"hidden\" class=\"field-slots\" id=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" name=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" value=\"" . $slot->get_playlist_id() . "\">";
}
echo "</form>";
$playlistOptions = "";
foreach (Playlists::get_sustainer() as $playlist) {
    $playlistOptions .= "<option value=\"" . $playlist->get_id() . "\">" . $playlist->get_name() . "</option>";
}
echo Bootstrap::modal("update-modal", "\r\n\t\t<p id=\"slot-info\">Current slot information is unavailable.</p>\r\n\t\t<hr>\r\n\t\t<form class=\"form-horizontal\" action=\"?\" method=\"POST\">\r\n\t\t\t<fieldset>\r\n\t\t\t\t<div class=\"control-group\">\r\n\t\t\t\t\t<label class=\"control-label\" for=\"playlist-id\">New Playlist</label>\r\n\t\t\t\t\t<div class=\"controls\">\r\n\t\t\t\t\t\t<select id=\"playlist-id\" name=\"playlist-id\" data-width=\"100%\">\r\n\t\t\t\t\t\t\t" . $playlistOptions . "\r\n\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<p class=\"help-block\">Select the playlist to be scheduled for <hh>.</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t\t<fieldset>\r\n\t\t\t\t<div class=\"control-group\">\r\n\t\t\t\t\t<label class=\"control-label\" for=\"prerecord-id\">Prerecorded File</label>\r\n\t\t\t\t\t<div class=\"controls\">\r\n\t\t\t\t\t\t<select id=\"prerecord-id\" name=\"prerecord-id\" data-width=\"100%\">\r\n\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<p class=\"help-block\">Select the prerecorded content to be played out at <hh>.</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t\t<input type=\"hidden\"class=\"update-id\" name=\"updateid\">\r\n\t\t</form>\r\n\t", "Schedule Prerecorded Content", "<a class=\"btn btn-success\" id=\"update-playlist\" href=\"#\">Update Playlist</a><a class=\"btn btn-primary\" id=\"save-prerecord\" href=\"#\">Schedule Prerecord</a><a class=\"btn btn-danger\" id=\"delete-prerecord\" href=\"#\">Unschedule Prerecord</a><a class=\"btn btn-default\" data-dismiss=\"modal\">Cancel</a>") . "<script type=\"text/javascript\">\r\n\t\tboxes = \$('.timeslot');\r\n\t\tboxes.dblclick(function(){\r\n\t\t\t\$('#update-modal').modal('show');\r\n\t\t\t\$('.update-id').val(\$(this).attr('id'));\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/get-slot-status.php',\r\n\t\t\t\tdata: { updateid: \$('.update-id').val() },\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\tdataType: 'json',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\$('#slot-info').html(data.status);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n</script>";