var myresponse = ''; function profil_new(){ var mylocation = window.location.href+'&profil=new'; window.location.href = mylocation; } function profil_show(){ if ($F('profil_select') != ''){ var myprofil = $F('profil_select'); new Ajax.Updater($('myselectedprofil'), 'inc_ajax/profil_reponses.php', { evalScripts: true, parameters: 'action=showprofil&profil_id='+myprofil, onComplete: function(transport){ var response = transport.responseText; $('profil_Delete_btn').show(); $('profil_Delete_btn').observe('click', profil_delete, false); if ($('profil_insertReponse_btn')){ $('profil_insertReponse_btn').observe('click', profilInsertResponse, false); } } }); } else{ $('myselectedprofil').update(''); } } function profil_delete(){ if ($F('profil_select') != ''){ var myprofil = $F('profil_select'); new Ajax.Request('inc_ajax/profil_action.php', { evalScripts: true, parameters : 'action=profil_delete&profil_id='+myprofil, onComplete : function(){ window.location.reload(); } }); } } function profil_form_next(){ myerror(); if ($('profil_id') != ''){ // input not complete - profil not registred if ($F('libelle') == ''){ // empty profil name myerror('libelle', 'formulaireincomplet'); } else{ // insert new profil var libelle = $F('libelle'); new Ajax.Request('inc_ajax/profil_action.php', { parameters:'action=profil_new&libelle='+libelle, onComplete: function(transport){ var response = transport.responseText; $('profil_id').value = response; new Ajax.Updater($('deficiencesTable'), 'inc_ajax/profil_deficiences.php',{ evalScripts: true, parameters: 'profil_id='+response, onSuccess: function(){ $('next_tr').hide(); $('libelle').disable(); } }); } }); } } } function deficienceUpdateForProfil(obj){ if (this != window) { myobj = this; } else if(obj != undefined) { myobj = obj; } var profil = myobj.profil_id; var deficience = myobj.deficience_id; var deficience_value = $F('deficience_'+deficience); if (deficience_value == null){ var params = 'action=removeDeficienceToProfil&profil_id='+profil+'&deficience_id='+deficience; } else{ var params = 'action=addDeficienceToProfil&profil_id='+profil+'&deficience_id='+deficience; } new Ajax.Request('inc_ajax/profil_action.php', { evalScripts : true, parameters: params, onComplete: function(){ Fillresponse(profil); } }); } function Fillresponse(obj){ /* if ($$('response')){ var myinputs = $$('response'); var ArrayInput = new Array(); myinputs.each(function(s){ if ($(s.id)){ ArrayInput[s.id] = $F(s.id); } }); } if ($$('response_radio')){ var myradios = $$('response_radio'); var ArrayRadios = new Array(); } */ if (this != window){ myobj = this; } else if (obj != undefined){ myobj = obj; } new Ajax.Updater($('fillResponseForProfil'),'inc_ajax/profil_questions.php', { evalScripts : true, parameters:'profil_id='+myobj, onComplete: function(transport){ var response = transport.responseText; $('questionprofil').show(); if ($('profil_insertReponse_btn')){ $('profil_insertReponse_btn').observe('click', profilInsertResponse, false); } } }); } function profilInsertResponse(){ new Ajax.Request('inc_ajax/profil_action.php', { evalScripts: true, parameters: $('profil_reponses').serialize(true), onComplete: function(transport){ var response = transport.responseText; if (response == 1){ refreshParent(); } else{ window.location.reload(); } } }); }