shift_states_not_allowed.js 1.72 KB
Newer Older
Administrator committed
1 2
// Request a delay for the current member
function request_delay() {
3 4 5 6
    //Loading on
    openModal();
    var today = new Date();
    var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
Administrator committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    $.ajaxSetup({headers: {"X-CSRFToken": getCookie('csrftoken')}});
    $.ajax({
        type: 'POST',
        url: '/shifts/request_delay',
        dataType: 'json',
        timeout: 3000,
        data: {
            idPartner: dataPartner.partner_id,
            verif_token: dataPartner.verif_token,
            start_date: date
        },
        success: function(doc) {
            document.location.reload();
        },
        error: function() {
            closeModal();
            alert('Impossible de créer l\'extension. Je dois passer au Bureau des membres pour régler le problème.');
        }
    });
Administrator committed
27 28 29
}

$(document).ready(function() {
30
    $('#'+dataPartner.cooperative_state).removeAttr('hidden');
Administrator committed
31

32
    if (dataPartner.cooperative_state == "suspended") {
Administrator committed
33 34
    // Member can ask for 6 delays, which is 24 weeks after entering alert status
    // 'date_alert_stop' field is begining of alert + 4 weeks
35 36 37
        var date_end_alert = new Date(dataPartner.date_alert_stop);

        date_end_alert.setDate(date_end_alert.getDate()+20*7);
Administrator committed
38

39 40 41 42 43 44 45 46 47
        if (date_end_alert < new Date()) {
            $('#no_delay').removeAttr('hidden');
        } else {
            $('#delay').removeAttr('hidden');
        }
    } else if (dataPartner.cooperative_state == "unsubscribed") {
        $('#unsubscribed').show();
    } else if (dataPartner.cooperative_state == "exempted") {
        $('#exempted').show();
Administrator committed
48
    } else {
49
        $('body').append('Merci de prendre contact avec le Bureau des membres pour examiner votre situation.');
Administrator committed
50 51
    }
});