2013-08-13 17:27:17 +02:00
|
|
|
var path = location.pathname.split('/');
|
|
|
|
var service = path[1];
|
2014-01-16 17:18:54 +01:00
|
|
|
var app_name = path[2];
|
2013-08-13 17:27:17 +02:00
|
|
|
var current_date = path[3];
|
2013-08-09 14:46:57 +02:00
|
|
|
COOKIE_PATH = '/' + service + '/agenda';
|
2013-08-06 17:25:46 +02:00
|
|
|
|
2014-04-10 15:38:52 +02:00
|
|
|
function get_initial_fields(button, base) {
|
2014-03-27 09:42:10 +01:00
|
|
|
var participants = new Array();
|
2014-04-14 16:12:50 +02:00
|
|
|
var ressource = null;
|
|
|
|
if ($.cookie('active-agenda')) {
|
|
|
|
var active_agenda = $.cookie('active-agenda').split('-');
|
|
|
|
if (active_agenda[0] == 'ressource') {
|
|
|
|
ressource = active_agenda[1];
|
|
|
|
} else {
|
|
|
|
ressource = $.cookie('last-ressource');
|
|
|
|
}
|
2014-03-27 09:42:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($.cookie('agenda-tabs')) {
|
|
|
|
participants = $.cookie('agenda-tabs').filter(function(v) {
|
|
|
|
var data = v.split('-');
|
|
|
|
if(data[0]=='worker')
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
participants = participants.map(function(v) {
|
|
|
|
var data = v.split('-'); return data[1]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return $.param({participants: $.makeArray(participants),
|
2014-04-08 11:07:58 +02:00
|
|
|
ressource: ressource,
|
2014-04-10 15:38:52 +02:00
|
|
|
time: $(button).data('hour'),
|
|
|
|
duration: $(button).data('duration')}, true);
|
2014-03-27 09:42:10 +01:00
|
|
|
}
|
|
|
|
|
2014-03-25 19:15:20 +01:00
|
|
|
function enable_new_appointment(base) {
|
|
|
|
var base = base || 'body';
|
|
|
|
$(base).find('.newrdv').click(function() {
|
2014-04-24 17:41:31 +02:00
|
|
|
add_dialog('#ajax-dlg', $(this).data('url') + "?" + get_initial_fields(this, base), 'Nouveau rendez-vous', '880px', 'Ajouter');
|
2014-03-25 19:15:20 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function enable_new_event(base) {
|
|
|
|
var base = base || 'body';
|
|
|
|
$(base).find('.newevent').click(function() {
|
2014-04-24 17:41:31 +02:00
|
|
|
add_dialog('#ajax-dlg', $(this).data('url') + "?" + get_initial_fields(this, base), 'Nouvel événement', '850px', 'Ajouter');
|
2014-03-25 19:15:20 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-21 23:39:37 +01:00
|
|
|
function enable_events(base) {
|
|
|
|
$(base).find('.textedit').on('keydown', function() {
|
|
|
|
$('button', this).removeAttr("disabled");
|
|
|
|
});
|
|
|
|
$(base).find('.textedit button').on('click', function() {
|
|
|
|
var textarea = $(this).prev();
|
2014-05-30 11:18:47 +02:00
|
|
|
var span = textarea.prev();
|
|
|
|
var btn = $(this);
|
2014-07-02 11:48:10 +02:00
|
|
|
var comment = {description: textarea.val()};
|
2014-06-18 14:12:38 +02:00
|
|
|
var data = JSON.stringify(comment);
|
2013-12-03 11:04:18 +01:00
|
|
|
$.ajax({
|
2013-01-23 14:27:07 +01:00
|
|
|
url: '/api/v1/event/' + $(this).data("event-id") + '/?format=json&date=' + $(this).data('date'),
|
2012-12-21 23:39:37 +01:00
|
|
|
type: 'PATCH',
|
|
|
|
contentType: 'application/json',
|
2013-02-14 16:39:39 +01:00
|
|
|
data: data,
|
2014-05-28 19:48:16 +02:00
|
|
|
success: function(response) {
|
2013-12-03 11:04:18 +01:00
|
|
|
btn.attr('disabled', 'disabled');
|
2014-07-02 11:48:10 +02:00
|
|
|
if (comment['description'])
|
2014-05-28 19:48:16 +02:00
|
|
|
$('h3#' + btn.data("event-id") + ' span.icon-comment').fadeIn();
|
|
|
|
else
|
|
|
|
$('h3#' + btn.data("event-id") + ' span.icon-comment').fadeOut();
|
2013-12-03 11:04:18 +01:00
|
|
|
span.html('Commentaire modifié avec succès');
|
2012-12-21 23:39:37 +01:00
|
|
|
}
|
2013-12-03 11:04:18 +01:00
|
|
|
});
|
2012-12-21 23:39:37 +01:00
|
|
|
});
|
2013-01-11 18:16:15 +01:00
|
|
|
/* TODO: put this in a generic function */
|
|
|
|
$('.input_is_billable').click(function() {
|
2013-01-25 18:21:38 +01:00
|
|
|
if ($(this).data("switch-billable") == "True") {
|
2013-01-11 18:16:15 +01:00
|
|
|
var value = "false";
|
2013-01-25 18:21:38 +01:00
|
|
|
} else {
|
|
|
|
var value = "true";
|
2013-01-11 18:16:15 +01:00
|
|
|
}
|
|
|
|
$.ajax({
|
|
|
|
url: '/api/v1/act/' + $(this).data("id") + '/?format=json',
|
|
|
|
type: 'PATCH',
|
|
|
|
contentType: 'application/json',
|
|
|
|
data: '{"switch_billable": ' + value + '}',
|
|
|
|
success: function(data) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('.input_is_lost').click(function() {
|
|
|
|
if ((this.checked) == true) {
|
|
|
|
var value = "true";
|
|
|
|
} else {
|
|
|
|
var value = "false";
|
|
|
|
}
|
|
|
|
$.ajax({
|
|
|
|
url: '/api/v1/act/' + $(this).data("id") + '/?format=json',
|
|
|
|
type: 'PATCH',
|
|
|
|
contentType: 'application/json',
|
|
|
|
data: '{"is_lost": ' + value + '}',
|
|
|
|
success: function(data) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-03-25 19:15:20 +01:00
|
|
|
enable_new_appointment(base);
|
|
|
|
enable_new_event(base);
|
|
|
|
|
2012-12-21 23:39:37 +01:00
|
|
|
$(base).find('.appointment').on('click', function() {
|
|
|
|
$('.textedit span', this).html('');
|
|
|
|
});
|
|
|
|
|
|
|
|
$(base).find('.remove-appointment').on('click', function() {
|
2013-01-29 16:26:42 +01:00
|
|
|
var r = delete_prompt("Etes-vous sûr de vouloir supprimer le rendez-vous " + $(this).data('rdv') + " ?");
|
2012-12-21 23:39:37 +01:00
|
|
|
if (r == true)
|
|
|
|
{
|
|
|
|
$.ajax({
|
2013-01-08 00:49:20 +01:00
|
|
|
url: $(this).data('url'),
|
2012-12-21 23:39:37 +01:00
|
|
|
type: 'DELETE',
|
|
|
|
success: function(data) {
|
|
|
|
window.location.reload(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2014-03-25 19:15:20 +01:00
|
|
|
|
2012-12-21 23:39:37 +01:00
|
|
|
$(base).find('.edit-appointment').click(function() {
|
2013-12-17 19:41:46 +01:00
|
|
|
id = $(this).data("event-id");
|
|
|
|
$.getJSON("/api/v1/eventwithact/" + id + "/?format=json")
|
|
|
|
.done(function () {
|
|
|
|
event_dialog("/" + service + "/agenda/" + current_date + "/update-rdv/" + id,
|
|
|
|
'Modifier rendez-vous', '850px', 'Modifier');
|
|
|
|
})
|
|
|
|
.fail(function() {
|
|
|
|
window.location.reload(true);
|
|
|
|
$('.messages').html("Le rendez-vous n'existe plus");
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return false;
|
2012-12-21 23:39:37 +01:00
|
|
|
});
|
|
|
|
$(base).find('.edit-event').click(function() {
|
2013-12-16 11:47:00 +01:00
|
|
|
event_dialog("/" + service + "/agenda/" + current_date + "/update-event/" + $(this).data('event-id') , 'Modifier un événement', '850px', 'Modifier');
|
2012-12-21 23:39:37 +01:00
|
|
|
return false;
|
|
|
|
});
|
2012-12-27 11:48:33 +01:00
|
|
|
|
|
|
|
$('.generate-mail-btn', base).click(function() {
|
2013-01-04 01:52:31 +01:00
|
|
|
var url = '../../dossiers/' + $(this).data('dossier-id') + '/generate?event-id=' + $(this).data('event-id') + '&date=' + $(this).data('date');
|
2012-12-27 11:48:33 +01:00
|
|
|
$('#ajax-dlg').load(url,
|
|
|
|
function () {
|
|
|
|
$(this).dialog({title: 'Générer un courrier', width: '500px',
|
|
|
|
buttons: [ { text: "Fermer",
|
|
|
|
click: function() { $(this).dialog("close"); } },
|
|
|
|
{ text: "Générer",
|
|
|
|
click: function() { $("#ajax-dlg form").submit(); $(this).dialog("close"); } }]});
|
|
|
|
$(this).find('.addresses input[type=radio]').change(function() {
|
2013-05-02 15:07:38 +02:00
|
|
|
var address = '';
|
|
|
|
if ($(this).data('contact-gender')){address += $(this).data('contact-gender') + ' ';}
|
|
|
|
if ($(this).data('contact-first-name')){address += $(this).data('contact-first-name') + ' ';}
|
|
|
|
if ($(this).data('contact-last-name')){address += $(this).data('contact-last-name') + '\n';}
|
2014-04-10 16:56:48 +02:00
|
|
|
if ($(this).data('address-recipient')){address += $(this).data('address-recipient') + '\n';}
|
2013-05-02 15:07:38 +02:00
|
|
|
if ($(this).data('address-number')){address += $(this).data('address-number') + ' ';}
|
|
|
|
if ($(this).data('address-street')){address += $(this).data('address-street') + '\n';}
|
|
|
|
if ($(this).data('address-address-complement')){address += $(this).data('address-address-complement') + '\n';}
|
|
|
|
if ($(this).data('address-zip-code')){address += $(this).data('address-zip-code') + ' ';}
|
|
|
|
if ($(this).data('address-city')){address += $(this).data('address-city') + '\n';}
|
2012-12-27 11:48:33 +01:00
|
|
|
$('#id_address').val(address);
|
2013-05-13 12:16:34 +02:00
|
|
|
$('#id_phone_address').val($(this).attr('data-address-phone'));
|
2012-12-27 11:48:33 +01:00
|
|
|
});
|
|
|
|
$('.addresses input[type=radio]').first().click();
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
2012-12-21 23:39:37 +01:00
|
|
|
}
|
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
function toggle_ressource(ressource) {
|
2012-11-15 10:36:12 +01:00
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
var ressource_id = $(ressource).attr('id');
|
|
|
|
|
|
|
|
var ressource_target = $(ressource).data('target');
|
|
|
|
if (!ressource_target) {
|
2012-12-22 14:53:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
$(ressource).toggleClass('active');
|
|
|
|
if (!($.cookie('agenda-tabs'))) {
|
|
|
|
$.cookie('agenda-tabs', new Array(), { path: COOKIE_PATH });
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
2014-03-27 00:32:53 +01:00
|
|
|
if ($(ressource).hasClass('active')) {
|
|
|
|
var tabs = $.cookie('agenda-tabs');
|
|
|
|
if ($.inArray(ressource_id, tabs) == -1)
|
2012-12-22 14:53:31 +01:00
|
|
|
{
|
2014-03-27 00:32:53 +01:00
|
|
|
tabs.push(ressource_id);
|
|
|
|
$.cookie('agenda-tabs', tabs, { path: COOKIE_PATH });
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-03-27 00:32:53 +01:00
|
|
|
var agendatabs = $.cookie('agenda-tabs');
|
2014-04-07 18:39:54 +02:00
|
|
|
if ($('#users li.item.ressource.active:last').attr('id'))
|
|
|
|
$.cookie('last-ressource', $('#users li.item.ressource.active:last').attr('id').split('-')[1], { path: COOKIE_PATH });
|
2014-09-19 15:29:33 +02:00
|
|
|
else {
|
|
|
|
$.cookie('active-agenda', '', {path: COOKIE_PATH})
|
2014-04-07 18:39:54 +02:00
|
|
|
$.cookie('last-ressource', '', {path: COOKIE_PATH});
|
2014-09-19 15:29:33 +02:00
|
|
|
}
|
2014-04-07 18:39:54 +02:00
|
|
|
|
2012-12-22 14:53:31 +01:00
|
|
|
$.each(agendatabs, function (i, value) {
|
2014-03-27 00:32:53 +01:00
|
|
|
if (value == ressource_id) {
|
2012-12-22 14:53:31 +01:00
|
|
|
agendatabs.splice(i, 1);
|
|
|
|
}
|
|
|
|
});
|
2014-03-27 00:32:53 +01:00
|
|
|
$.cookie('agenda-tabs', agendatabs, { path: COOKIE_PATH });
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
2014-04-07 18:39:54 +02:00
|
|
|
$(ressource_target).toggle();
|
2014-03-24 11:07:12 +01:00
|
|
|
$('#close-all-agendas').toggle($('#users li.active').length != 0);
|
|
|
|
if (! $('#users li.active').length) {
|
|
|
|
$('#agendas #tabs div').hide();
|
|
|
|
}
|
2012-12-22 14:53:31 +01:00
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
var tab = $(ressource_target);
|
2012-12-22 14:53:31 +01:00
|
|
|
var tab_list = $(tab).parent().get(0);
|
|
|
|
$(tab).detach().appendTo(tab_list);
|
2014-03-16 16:39:10 +01:00
|
|
|
|
2013-10-15 10:50:11 +02:00
|
|
|
var url = $("#date-selector").data('url');
|
2014-03-27 00:32:53 +01:00
|
|
|
var tab_selector = '#' + ressource_id + '.active';
|
2013-10-21 14:45:06 +02:00
|
|
|
|
|
|
|
if ($(tab_selector).length) {
|
2014-03-16 16:39:10 +01:00
|
|
|
/* load disponibility column */
|
2014-03-27 13:00:59 +01:00
|
|
|
$.ajaxSetup({async:false});
|
2014-03-27 00:32:53 +01:00
|
|
|
$.get(url + 'disponibility/' + ressource_id,
|
2012-12-22 14:53:31 +01:00
|
|
|
function(data) {
|
2014-02-07 19:16:49 +01:00
|
|
|
if ($(tab_selector).hasClass('active')) {
|
2014-03-21 19:47:50 +01:00
|
|
|
var availability_block = $('ul#availability');
|
|
|
|
availability_block.append($(data));
|
2014-02-07 19:16:49 +01:00
|
|
|
}
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
|
|
|
);
|
2014-03-27 13:00:59 +01:00
|
|
|
$.ajaxSetup({async:true});
|
2012-12-22 14:53:31 +01:00
|
|
|
} else {
|
2013-10-21 14:45:06 +02:00
|
|
|
// remove hidden ressource availability
|
2014-03-27 00:32:53 +01:00
|
|
|
$('ul#availability li.' + ressource_id).remove();
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
2014-03-27 00:32:53 +01:00
|
|
|
return $(ressource_target).find('a.tab');
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
|
|
|
|
2012-11-07 17:46:57 +01:00
|
|
|
function event_dialog(url, title, width, btn_text) {
|
2014-04-11 12:03:13 +02:00
|
|
|
function add_periodic_events(base) {
|
2014-07-02 11:04:00 +02:00
|
|
|
init_datepickers(base);
|
2014-04-11 12:03:13 +02:00
|
|
|
$(base).on('click', '.update-periodic-event', function () {
|
|
|
|
$('.ui-icon-closethick').click();
|
|
|
|
// remove the form from previous hidden layer in order to prevent two
|
|
|
|
// elements with 'id_date' id on the page
|
|
|
|
$(this).parent().remove();
|
|
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
var delete_url = $(this).data('delete-url');
|
2014-04-13 23:57:25 +02:00
|
|
|
var delete_button = {
|
|
|
|
text: "Supprimer",
|
|
|
|
id: "delete-btn",
|
|
|
|
click: function () {
|
2014-04-11 12:03:13 +02:00
|
|
|
var r = delete_prompt("Etes-vous sûr de vouloir supprimer cet évènement récurrent ?");
|
|
|
|
if (r == true)
|
|
|
|
{
|
|
|
|
$.ajax({
|
|
|
|
url: delete_url,
|
|
|
|
type: 'DELETE',
|
|
|
|
success: function(data) {
|
|
|
|
window.location.reload(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2014-04-11 16:48:38 +02:00
|
|
|
};
|
2014-08-08 11:35:03 +02:00
|
|
|
$(base).unbind('click');
|
2014-04-13 23:57:25 +02:00
|
|
|
generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-event/' + id,
|
2014-07-01 14:47:31 +02:00
|
|
|
'Modifier un évènement périodique', '#ajax-dlg', '900px', 'Modifier', null, init_datepickers, null, delete_button);
|
2014-04-11 12:03:13 +02:00
|
|
|
});
|
2014-08-08 11:35:03 +02:00
|
|
|
|
|
|
|
$(base).on('click', '.update-periodic-rdv', function (event) {
|
2014-04-11 12:03:13 +02:00
|
|
|
$('.ui-icon-closethick').click();
|
|
|
|
var id = $(this).data('id');
|
2014-08-01 00:12:53 +02:00
|
|
|
var one_act_already_billed = $(this).data('one_act_already_billed');
|
2014-08-08 11:35:03 +02:00
|
|
|
var delete_button = null;
|
2014-08-01 00:12:53 +02:00
|
|
|
if (one_act_already_billed == 'False') {
|
|
|
|
var delete_url = $(this).data('delete-url');
|
|
|
|
var delete_button = {
|
|
|
|
text: "Supprimer",
|
|
|
|
id: "delete-btn",
|
|
|
|
click: function () {
|
|
|
|
var r = delete_prompt("Etes-vous sûr de vouloir supprimer ce rendez-vous récurrent ?");
|
|
|
|
if (r == true)
|
|
|
|
{
|
|
|
|
$.ajax({
|
|
|
|
url: delete_url,
|
|
|
|
type: 'DELETE',
|
|
|
|
success: function(data) {
|
|
|
|
window.location.reload(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2014-04-11 12:03:13 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-01 00:12:53 +02:00
|
|
|
};
|
|
|
|
}
|
2014-08-08 11:35:03 +02:00
|
|
|
$(base).unbind('click')
|
2014-04-13 23:57:25 +02:00
|
|
|
generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-rdv/' + id,
|
2014-07-01 14:47:31 +02:00
|
|
|
'Modifier un rendez-vous périodique', '#ajax-dlg', '900px', 'Modifier', null, init_datepickers, null, delete_button);
|
2014-04-11 12:03:13 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
generic_ajaxform_dialog(url, title, '#ajax-dlg', width, btn_text, null,
|
|
|
|
add_periodic_events);
|
|
|
|
|
2012-11-07 17:46:57 +01:00
|
|
|
}
|
|
|
|
|
2012-11-07 10:52:15 +01:00
|
|
|
(function($) {
|
|
|
|
$(function() {
|
2014-03-16 16:39:10 +01:00
|
|
|
$('#tabs').tabs({
|
|
|
|
load: function(event, ui) {
|
2014-03-27 10:01:42 +01:00
|
|
|
var tab = $(ui.tab).attr('id').split('-');
|
|
|
|
if(tab[0] == 'ressource')
|
|
|
|
$.cookie('last-ressource', tab[1], { path: COOKIE_PATH });
|
|
|
|
|
2014-03-20 19:07:40 +01:00
|
|
|
$('#tabs > div > div').accordion({active: false,
|
|
|
|
autoHeight: false,
|
|
|
|
collapsible: true});
|
2014-03-25 19:15:20 +01:00
|
|
|
enable_events('#tabs');
|
2014-03-16 16:39:10 +01:00
|
|
|
},
|
|
|
|
selected: -1,
|
2014-03-20 19:07:40 +01:00
|
|
|
collapsible: true,
|
2014-03-16 16:39:10 +01:00
|
|
|
});
|
2012-10-29 16:43:16 +01:00
|
|
|
|
2014-04-15 12:01:34 +02:00
|
|
|
$('button#print-button').click(function() { window.print();});
|
2014-04-11 16:48:38 +02:00
|
|
|
|
2014-09-14 10:38:57 +02:00
|
|
|
$('#actes .frame select').on('change', function() {
|
|
|
|
$('#actes .frame').removeClass('changed');
|
2014-09-26 09:30:42 +02:00
|
|
|
if (window.location.hash)
|
|
|
|
$(window.location.hash).css('box-shadow', 'none');
|
2014-09-14 10:38:57 +02:00
|
|
|
$(this).closest('.frame').addClass('changed');
|
|
|
|
});
|
|
|
|
|
2014-03-25 19:15:20 +01:00
|
|
|
enable_new_event();
|
|
|
|
enable_new_appointment();
|
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
if ($('#users .item').length) {
|
|
|
|
$('#users .item').on('click', function() {
|
|
|
|
var target = toggle_ressource(this);
|
2014-03-16 16:39:10 +01:00
|
|
|
|
2012-12-22 14:53:31 +01:00
|
|
|
if ($(target).is(':visible')) {
|
|
|
|
$(target).click();
|
|
|
|
}
|
|
|
|
if ($('#filtre input').val()) {
|
|
|
|
$('#filtre input').val('');
|
|
|
|
$('#filtre input').keyup();
|
|
|
|
$('#filtre input').focus();
|
|
|
|
}
|
2013-01-10 17:36:27 +01:00
|
|
|
if (! ($('li.agenda:visible').hasClass('ui-state-active'))) {
|
|
|
|
$('li.agenda:visible:last a.tab').click();
|
|
|
|
}
|
2012-12-22 14:53:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('a.tab').click(function() {
|
2014-03-27 00:32:53 +01:00
|
|
|
$.cookie('active-agenda', $(this).attr('id'), { path: COOKIE_PATH });
|
2012-12-22 14:53:31 +01:00
|
|
|
});
|
2013-09-20 16:43:04 +02:00
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
if ($.cookie('agenda-tabs')) {
|
|
|
|
$.each($.cookie('agenda-tabs'), function (i, selector) {
|
|
|
|
toggle_ressource($('#' + selector));
|
2013-09-20 16:43:04 +02:00
|
|
|
});
|
2012-11-09 10:31:29 +01:00
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
if ($.cookie('active-agenda'))
|
2012-12-22 14:53:31 +01:00
|
|
|
{
|
2014-03-27 00:32:53 +01:00
|
|
|
var target = $("#" + $.cookie('active-agenda')).data('target');
|
|
|
|
if (!$('#tabs ' + target).hasClass('ui-state-active')) {
|
|
|
|
$("#tabs " + target + ' a.tab').click();
|
2012-12-22 14:53:31 +01:00
|
|
|
}
|
2012-11-09 10:31:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-22 14:53:31 +01:00
|
|
|
$('a.close-tab').click(function() {
|
2013-07-19 16:28:38 +02:00
|
|
|
var target = '#' + $(this).data('target');
|
|
|
|
$(target).click();
|
2014-03-27 00:32:53 +01:00
|
|
|
if ($.cookie('active-agenda') == $(target).attr('id')) {
|
|
|
|
$.cookie('active-agenda', '', { path: COOKIE_PATH });
|
2013-07-19 16:28:38 +02:00
|
|
|
}
|
|
|
|
|
2012-12-22 14:53:31 +01:00
|
|
|
});
|
|
|
|
|
2012-11-07 10:52:15 +01:00
|
|
|
/* Gestion du filtre sur les utilisateurs */
|
|
|
|
$('#filtre input').keyup(function() {
|
|
|
|
var filtre = $(this).val();
|
2013-01-10 17:36:27 +01:00
|
|
|
if ($('#show-everybody').length) {
|
2012-12-22 14:53:31 +01:00
|
|
|
var everybody = $('#show-everybody').is(':checked');
|
2013-01-10 17:36:27 +01:00
|
|
|
} else {
|
2012-12-22 14:53:31 +01:00
|
|
|
var everybody = true;
|
|
|
|
}
|
2012-11-07 10:52:15 +01:00
|
|
|
if (filtre) {
|
2012-12-21 22:13:34 +01:00
|
|
|
$('#show-everybody').attr('checked', true);
|
2012-11-07 10:52:15 +01:00
|
|
|
$('#users li').each(function() {
|
|
|
|
if ($(this).text().match(new RegExp(filtre, "i"))) {
|
|
|
|
$(this).show();
|
|
|
|
} else {
|
|
|
|
$(this).hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('#users li').show();
|
2012-12-21 22:13:34 +01:00
|
|
|
if (! everybody) {
|
2014-03-27 00:32:53 +01:00
|
|
|
$('.item.worker:not(.in_service)').hide();
|
|
|
|
$('.item.worker:not(.intervenant)').hide();
|
2012-12-11 11:53:22 +01:00
|
|
|
}
|
2012-11-07 10:52:15 +01:00
|
|
|
}
|
2012-12-11 11:53:22 +01:00
|
|
|
/* hide worker type titles that do not have a single visible person */
|
|
|
|
$("#users ul:has(*):has(:visible)").parent().prev().show();
|
|
|
|
$("#users ul:has(*):not(:has(:visible))").parent().prev().hide();
|
2012-11-07 10:52:15 +01:00
|
|
|
});
|
2012-12-11 11:53:22 +01:00
|
|
|
|
2012-11-07 10:52:15 +01:00
|
|
|
$('.date').datepicker({showOn: 'button'});
|
|
|
|
$('#add-intervenant-btn').click(function() {
|
|
|
|
var text = $(this).prev().val();
|
|
|
|
$('#intervenants ul').append('<li><input type="checkbox" value="' + text + '" checked="checked">' + text + '</input></li>');
|
|
|
|
$(this).prev().val('').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2012-12-21 22:36:51 +01:00
|
|
|
$('#show-everybody').change(function() {
|
2012-12-21 22:13:34 +01:00
|
|
|
if (! $(this).is(':checked')) {
|
2012-12-11 11:53:22 +01:00
|
|
|
$('#filtre input').val('');
|
2012-12-10 18:38:01 +01:00
|
|
|
}
|
2012-12-11 11:53:22 +01:00
|
|
|
$('#filtre input').keyup();
|
|
|
|
return;
|
2012-12-10 18:38:01 +01:00
|
|
|
});
|
2012-12-11 09:35:03 +01:00
|
|
|
$('select[name^="act_state"]').on('change', function () {
|
|
|
|
$(this).next('button').prop('disabled',
|
|
|
|
($(this).data('previous') == $(this).val()));
|
|
|
|
})
|
2012-12-11 11:53:22 +01:00
|
|
|
$('#filtre input').keyup();
|
2013-10-07 14:55:54 +02:00
|
|
|
|
2014-03-27 00:32:53 +01:00
|
|
|
$.each({'persons': 'worker',
|
2014-04-08 11:07:58 +02:00
|
|
|
'ressources': 'ressource'},
|
2013-10-07 14:55:54 +02:00
|
|
|
function(key, value) {
|
2014-03-21 19:47:50 +01:00
|
|
|
$('#close-all-agendas').click(function() {
|
2014-03-27 00:32:53 +01:00
|
|
|
$.cookie('active-agenda', '', {path: COOKIE_PATH});
|
|
|
|
$('#users .item.active').each(function (i, v) {
|
|
|
|
toggle_ressource(v, value);
|
2013-10-07 14:55:54 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2012-11-07 17:46:57 +01:00
|
|
|
});
|
2012-11-07 10:52:15 +01:00
|
|
|
})(window.jQuery)
|