var activeUser = null,
    editUserMode = false,
    id_selectat=0;


$("#btn_adauga").click(function () {
 
    AS.Http.post({
        action: "adaugaAlteServicii",
        denumire: $("#denumire").val(),
        descriere: $("#descriere").val()
    }, function (res) {
        console.log(res.status);
        if(res.status =="success"){
            alert("The information was saved with success!");
             location.reload();
        }else{
            alert("Error!");
        }
       
    });
});

$("#btn_modifica").click(function () {
    AS.Http.post({
        action: "modificaAlteServicii",
        id: id_selectat,
        denumire: $("#denumire_edit").val(),
        descriere: $("#descriere_edit").val()
    }, function (res) {
        console.log(res.status);
        if(res.status =="success"){
            alert("The information was saved with success!");
            location.reload();
        }else{
            alert("Error!");
        }
         
    });
});

/**
 * Show edit user modal.
 */
$(".modifica").click(function () {
    AS.Util.removeErrorMessages();
    id_selectat = $(this).data('id');
    $('#denumire_edit').val($(this).data('denumire'));
    $('#descriere_edit').val($(this).data('descriere'));
    
    $('#modal_modifica').show();
});


/**
 * Delete user button handler. Sends an AJAX request
 * to remove the specified user from the system.
 */
$(".sterge").click(function () {
    if(! confirm($_lang.are_you_sure)) return;
    var $btn = $(this);
    AS.Http.post({
        action: "stergeAlteServicii",
        id: $btn.data('id')
    }, function () {
       location.reload();
    });


});
