Untitled
raw download clone
JAVASCRIPT
views 57
,
size 1444 b
regOdoo("out",scannedResult);
function regOdoo(tadaact,tadano){
    var tadaodoo_act = tadaact;
    var tadaodoo_no = tadano;
    var data={
        username: GLOBAL_ODOO_USER,
        password: GLOBAL_ODOO_PWD,
        db: GLOBAL_ODOO_DB
    };

    var Url_auth        = GLOBAL_ODOO_API+'/auth/get_tokens';
    var Url_checkin     = GLOBAL_ODOO_API+'/attendance/checkin/'+GLOBAL_CENTER_ID+'/'+tadaodoo_no;
    var Url_checkout    = GLOBAL_ODOO_API+'/attendance/checkout/'+GLOBAL_CENTER_ID+'/'+tadaodoo_no;
    var Url_act         = '';
    var this_token      = '';

    if (tadaodoo_act==='in') {
        Url_act = Url_checkin;
    } else {
        Url_act = Url_checkout;
    }

    $.ajax({
        url: Url_auth,
        type: "POST",
        data: data,
        dataType:"json",
        success: function (response) {
            console.log('access_token: '+response.access_token);
        },
        error: function(error){
            console.log("Something went wrong", error);
        }
    });

    $.ajax({
        url: Url_act,
        headers: {
            "access_token" : this_token
        },
        type: "POST",
        ata: '',
        dataType:'jsonp',
        success: function (responseAct) {
            console.log('responseAct: '+responseAct);
        },
        error: function(error){
            console.log("Something went wrong", error);
        }
    });

}
close fullscreen
Login or Register to edit or fork this paste. It's free.