mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
161 lines
5.1 KiB
JavaScript
Vendored
161 lines
5.1 KiB
JavaScript
Vendored
function initScheduleEditor(id, eventType)
|
|
{
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/api/schedule/editor/init/'+eventType+'?api_token='+api_token,
|
|
success: function (template) {
|
|
$("#"+id).html(template);
|
|
for (let pniveau = 1; pniveau <= 3; pniveau++) {
|
|
for (let pperiode = 1; pperiode <= 3; pperiode++) {
|
|
loadCourse(pniveau,pperiode);
|
|
}
|
|
}
|
|
initAutoComplete("AutoComplete");
|
|
},
|
|
error: function () {
|
|
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
|
|
}
|
|
})
|
|
$('.datetimepicker').datetimepicker({
|
|
icons: {
|
|
time: "fa fa-clock-o",
|
|
date: "fa fa-calendar",
|
|
up: "fa fa-chevron-up",
|
|
down: "fa fa-chevron-down",
|
|
previous: 'fa fa-chevron-left',
|
|
next: 'fa fa-chevron-right',
|
|
today: 'fa fa-screenshot',
|
|
clear: 'fa fa-trash',
|
|
close: 'fa fa-remove'
|
|
}
|
|
});
|
|
$('.richeditor').trumbowyg({
|
|
lang: 'fr'
|
|
});
|
|
$('select').selectpicker();
|
|
}
|
|
|
|
function switchUseWeeklyMsg()
|
|
{
|
|
|
|
if($('#use_weekly_msg').is(":checked"))
|
|
{
|
|
$('#collmessagedelasemaine').removeClass('d-none');
|
|
}
|
|
else
|
|
{
|
|
$('#collmessagedelasemaine').addClass('d-none');
|
|
}
|
|
|
|
}
|
|
|
|
function switchUseSchedule()
|
|
{
|
|
if($('#use_schedule').is(":checked"))
|
|
{
|
|
$('#collschedule').removeClass('d-none');
|
|
}
|
|
else
|
|
{
|
|
$('#collschedule').addClass('d-none');
|
|
}
|
|
}
|
|
|
|
function loadCourse(periode,niveau)
|
|
{
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/api/schedule/editor/course/'+niveau+'/'+periode+'?api_token='+api_token,
|
|
success: function (course) {
|
|
$("#container-"+niveau+"-"+periode).html(course);
|
|
},
|
|
error: function () {
|
|
showNotification('error','Impossible de charger les cours ...','top', 'center')
|
|
}
|
|
})
|
|
}
|
|
|
|
function loadEventType(date)
|
|
{
|
|
var selectInput = $('#type');
|
|
var id = selectInput.val();
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/api/schedule/editor/template/'+id+'?api_token='+api_token,
|
|
success: function (data) {
|
|
var result = JSON.parse(data);
|
|
initScheduleEditor("scheduleEditor",id)
|
|
$.each(result, function (i, val) {
|
|
if(i == "is_mandatory" || i == "use_schedule" || i == "use_weekly_msg")
|
|
{
|
|
if(val == 1)
|
|
{
|
|
$('#'+i).prop( "checked", true );
|
|
}
|
|
else
|
|
{
|
|
$('#'+i).prop( "checked", false );
|
|
}
|
|
switchUseSchedule();
|
|
switchUseWeeklyMsg();
|
|
}
|
|
else if(i == "begin_time" || i == "end_time")
|
|
{
|
|
var foo = $('#'+i);
|
|
var mdate = moment(date+" "+val);
|
|
foo.data("DateTimePicker").destroy();
|
|
foo.datetimepicker({
|
|
icons: {
|
|
time: "fa fa-clock-o",
|
|
date: "fa fa-calendar",
|
|
up: "fa fa-chevron-up",
|
|
down: "fa fa-chevron-down",
|
|
previous: 'fa fa-chevron-left',
|
|
next: 'fa fa-chevron-right',
|
|
today: 'fa fa-screenshot',
|
|
clear: 'fa fa-trash',
|
|
close: 'fa fa-remove'
|
|
},
|
|
date: new Date(mdate)
|
|
});
|
|
|
|
}
|
|
else if(i == "weekly_msg_publication_time")
|
|
{
|
|
var foo = $('#'+i);
|
|
var mdate = moment(date+" "+result["begin_time"]);
|
|
mdate.subtract(5, 'days');
|
|
foo.data("DateTimePicker").destroy();
|
|
foo.datetimepicker({
|
|
icons: {
|
|
time: "fa fa-clock-o",
|
|
date: "fa fa-calendar",
|
|
up: "fa fa-chevron-up",
|
|
down: "fa fa-chevron-down",
|
|
previous: 'fa fa-chevron-left',
|
|
next: 'fa fa-chevron-right',
|
|
today: 'fa fa-screenshot',
|
|
clear: 'fa fa-trash',
|
|
close: 'fa fa-remove'
|
|
},
|
|
date: new Date(mdate)
|
|
});
|
|
|
|
}
|
|
else if(i == "location" || i == "name")
|
|
{
|
|
var foo = $('#'+i);
|
|
foo.val(val);
|
|
}
|
|
else if(i == "admin_desc")
|
|
{
|
|
var foo = $('#'+i);
|
|
foo.trumbowyg('html', val);
|
|
}
|
|
});
|
|
},
|
|
error: function () {
|
|
showNotification('error','Impossible de charger le type d\'évenement ...','top', 'center')
|
|
}
|
|
})
|
|
} |