const qrcodeOptions = { // render method: 'canvas', 'image' or 'div' render: 'div', text: 'https://www.learnsity.com', size: 100 /* // version range somewhere in 1 .. 40 minVersion: 10, maxVersion: 40, // error correction level: 'L', 'M', 'Q' or 'H' ecLevel: 'H', // offset in pixel if drawn onto existing canvas //left: 0, //top: 0, // size in pixel size: 100, // code color or image element fill: '#000', // background color or image element, null for transparent background background: '#fff', // content text: 'https://www.learnsity.com', // corner radius relative to module width: 0.0 .. 0.5 radius: 0, // quiet zone in modules quiet: 4, // modes // 0: normal // 1: label strip // 2: label box // 3: image strip // 4: image box mode: 0, mSize: 0.1, mPosX: 0.5, mPosY: 0.5, label: 'no label', fontname: 'sans', fontcolor: '#000', image: null*/ }; var certificates = { organizationId:0, currentCertificate:0, orgFolder:'', iniDataTable:function(){ hideGenericLoading(); $('#orgCertificates').DataTable().destroy(); var url=PATH_SERVICE_GET_PAGED_ORG_CERTIFICATES()+'?orgId='+certificates.organizationId; var table = $("#orgCertificates").DataTable({ "stripeClasses": [], "orderClasses": false, "destroy": true, "autoWidth": true, "paging": true, "pagingType" : "full_numbers", "pageLength": 10, "lengthMenu": [1, 5, 10, 20, 50, 100], "searching": true, "ordering": true, "language": { "processing": "Processing...", "search": "Search:", "lengthMenu": "Show _MENU_ rows", "info": "Showing _START_ to _END_ of _TOTAL_ rows", "infoEmpty": "Showing 0 to 0 of 0 rows", "infoFiltered": "(filtered _MAX_ filtered)", "infoPostFix": "", "loadingRecords": "Loading...", "zeroRecords": "Not found", "emptyTable": "No results", paginate: { "first": "First", "previous": "Previous", "next": "Next", "last": "Last" } }, "info": true, "columnDefs": [ { "orderable":false, "searchable":false, "targets":3 }, {"className": "text-left", "targets": [0, 1, 2]} ], retrieve : true, "select": { style: 'multi', selector: 'td:first-child' }, "columns": [ { "data": "name"}, { "data": null, render: function (data, type, row) { if(data.sentDate!=''){ return ""+convertDate(data.creationDate,CURRENT_LOCALE)+""; }else{ return ""; } } }, { "data": "coursesQuantity"}, { "data": null, render: function (data, type, row) { var courseId = data.certificateId; var orgFolder = certificates.orgFolder; var btnPreview = ""; var btnEdit = ""; var btnDelete = ""; return "
"+btnPreview+" "+btnEdit+" "+btnDelete+"
"; } }, ], "order": [[ 1, "desc" ]], "processing": true, "serverSide": true, "ajax":url }); }, evtPreviewCertificate:function(cId,orgFolder){ showGenericLoading(); $.when(certificates.setCertificateValuesPreview(cId,orgFolder)).then(function(){ certificates.disableDraggable(true); $("#certificates-step-title").empty(); $("#certificates-step-title").text(''); $("#adminCertificates").hide(); $("#addCertificates #btn-create").hide(); $("#addCertificates #btn-edit").hide(); $("#addCertificates #editBackgroundButton").hide(); $("#addCertificates").show(); hideGenericLoading(); },function(){ redirectToGenericError("organization.evtPreviewCertificate()",null,false); }); //certificates.setCertificateValuesPreview(cId,orgFolder); }, disableDraggable:function(disabled){ $( "#to" ).draggable({disabled: disabled}); $( "#id" ).draggable({disabled: disabled}); $( "#course" ).draggable({disabled: disabled}); $( "#contentText" ).draggable({disabled: disabled}); $( "#instructor" ).draggable({disabled: disabled}); $( "#period" ).draggable({disabled: disabled}); $( "#effort" ).draggable({disabled: disabled}); $( "#certificateImageSignature" ).draggable({disabled: disabled}); $( "#certificateImageLogo" ).draggable({disabled: disabled}); $( "#qrcodeDiv" ).draggable({disabled: disabled}); }, showAddNewCertificate:function(){ $("#certificates-step-title").empty(); $("#certificates-step-title").text('Create new certificate'); $("#adminCertificates").hide(); $("#addCertificates").show(); $("#addCertificates #btn-create").show(); $("#addCertificates #btn-edit").hide(); $("#addCertificates #editBackgroundButton").show(); $( "#addCertificates #certificateName" ).focus(); $("#instructor").empty(); $("#effort").empty(); certificates.resetFields(); certificates.setDefaultValues(); certificates.disableDraggable(false); }, resetFields:function(){ $('#addCertificates #certificateName').val(''); $( '#addCertificates #certificateName' ).prop( "disabled", false ); $('#addCertificates #certificateName').prop('readonly', false); $( "#addCertificates #certName").prop('checked', false); $( '#addCertificates #certName' ).prop( "disabled", false ); $('#addCertificates #certName').prop('readonly', false); $( "#addCertificates #courseName").prop('checked', false); $( '#addCertificates #courseName' ).prop( "disabled", false ); $('#addCertificates #courseName').prop('readonly', false); $( "#addCertificates #creationDate").prop('checked', false); $( '#addCertificates #creationDate' ).prop( "disabled", false ); $('#addCertificates #creationDate').prop('readonly', false); $( "#addCertificates #qr").prop('checked', false); $( '#addCertificates #qr' ).prop( "disabled", false ); $('#addCertificates #qr').prop('readonly', false); $( "#addCertificates #instructorName").prop('checked', false); $( '#addCertificates #instructorName' ).prop( "disabled", false ); $('#addCertificates #instructorName').prop('readonly', false); $( "#addCertificates #hours").prop('checked', false); $( '#addCertificates #hours' ).prop( "disabled", false ); $('#addCertificates #hours').prop('readonly', false); $( "#addCertificates #certContent").prop('checked', false); $( '#addCertificates #certContent' ).prop( "disabled", false ); $('#addCertificates #certContent').prop('readonly', false); $( "#addCertificates #certLogo").prop('checked', false); $( '#addCertificates #certLogo' ).prop( "disabled", false ); $('#addCertificates #certLogo').prop('readonly', false); $( "#addCertificates #certSignature").prop('checked', false); $( '#addCertificates #certSignature' ).prop( "disabled", false ); $('#addCertificates #certSignature').prop('readonly', false); $("#addCertificates #certificateImage").attr("src",""); $("#addCertificates #certificateUrlHidden").val($('#addCertificates #certificateUrlValueDefaultHidden').val()); $("#addCertificates #certificateImageLogo").attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $("#addCertificates #certificateLogoUrlHidden").val(''); $("#addCertificates #certificateImageSignature").attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $("#addCertificates #certificateSignatureUrlHidden").val(''); }, backAdminCertificates:function(){ certificates.resetFields(); $("#adminCertificates").show(); $("#addCertificates").hide(); $("#certificates-step-title").empty(); $("#certificates-step-title").text('Certificates'); }, setDefaultValues:function(){ //nombre participante, nombre curso, fecha y QR $( "#addCertificates #certName").prop('checked', true); $( "#addCertificates #courseName").prop('checked', true); $( "#addCertificates #creationDate").prop('checked', true); $('#qrcode').empty(); $('#to').text('Participant name'); $('#course').text('Course name'); $('#period').text('Date'); $("#addCertificates #certificateImage").attr("src",$('#certificateUrlDefaultHidden').val()); $("#addCertificates #certificateImageLogo").hide(); $("#addCertificates #certificateImageLogo").attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $("#addCertificates #certificateLogoUrlHidden").val(''); $("#addCertificates #certificateImageSignature").hide(); $("#addCertificates #certificateImageSignature").attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $("#addCertificates #certificateSignatureUrlHidden").val(''); $("#logoHelp").hide(); $("#certLogoInput").hide(); $("#signatureHelp").hide(); $("#certSignatureInput").hide(); $('#to').css('top','35%'); $('#to').css('left','34%'); $('#toPosTop').val(35); $('#toPosLeft').val(34); $('#id').css('top','0%'); $('#id').css('left','0%'); $('#idPosTop').val(0); $('#idPosLeft').val(0); $('#course').css('top','50%'); $('#course').css('left','34%'); $('#coursePosTop').val(50); $('#coursePosLeft').val(34); $('#contentText').css('top','0%'); $('#contentText').css('left','0%'); $('#contentTextPosTop').val(0); $('#contentTextPosLeft').val(0); $('#instructor').css('top','60%'); $('#instructor').css('left','34%'); $('#instructorPosTop').val(60); $('#instructorPosLeft').val(34); $('#period').css('top','70%'); $('#period').css('left','34%'); $('#periodPosTop').val(70); $('#periodPosLeft').val(34); $('#effort').css('top','77%'); $('#effort').css('left','34%'); $('#effortPosTop').val(77); $('#effortPosLeft').val(34); $('#qrcodeDiv').css('top','75%'); $('#qrcodeDiv').css('left','81%'); $('#qrcodePosTop').val(75); $('#qrcodePosLeft').val(81); $('#certificateImageLogo').css('top','0%'); $('#certificateImageLogo').css('left','0%'); $('#certificateImageLogoPosTop').val(0); $('#certificateImageLogoPosLeft').val(0); $('#certificateImageSignature').css('top','86%'); $('#certificateImageSignature').css('left','38%'); $('#certificateImageSignatureTop').val(86); $('#certificateImageSignaturePosLeft').val(38); }, setIdPart:function(){ if($('#addCertificates #idParticipant').is(":checked")){ $('#addCertificates #idParticipant').text(' - 4126'); }else{ $('#addCertificates #idParticipant').text(''); } }, setNamePart:function(){ if($('#addCertificates #certName').is(":checked")){ $('#addCertificates #to').text('Participant name'); $('#addCertificates #to').css('top',$('#toPosTop').val()); $('#addCertificates #to').css('left',$('#toPosLeft').val()); }else{ $('#addCertificates #to').text(''); } }, setCourseName:function(){ if($('#addCertificates #courseName').is(":checked")){ $('#addCertificates #course').text('Course name'); $('#addCertificates #course').css('top',$('#coursePosTop').val()); $('#addCertificates #course').css('left',$('#coursePosLeft').val()); }else{ $('#addCertificates #course').text(''); } }, setInstructorName:function(){ if($('#addCertificates #instructorName').is(":checked")){ $('#addCertificates #instructor').text('Instuctor name'); $('#addCertificates #instructor').css('top',$('#instructorPosTop').val()); $('#addCertificates #instructor').css('left',$('#instructorPosLeft').val()); }else{ $('#addCertificates #instructor').text(''); } }, setHours:function(){ if($('#addCertificates #hours').is(":checked")){ $('#addCertificates #effort').text('Hours'); $('#addCertificates #effort').css('top',$('#effortPosTop').val()); $('#addCertificates #effort').css('left',$('#effortPosLeft').val()); }else{ $('#addCertificates #effort').text(''); } }, setCreationDate:function(){ if($('#addCertificates #creationDate').is(":checked")){ $('#addCertificates #period').text('Date'); $('#addCertificates #period').css('top',$('#periodPosTop').val()); $('#addCertificates #period').css('left',$('#periodPosLeft').val()); }else{ $('#addCertificates #period').text(''); } }, setContent:function(){ if($('#addCertificates #certContent').is(":checked")){ $('#addCertificates #contentHelp').show(); }else{ $('#addCertificates #contentText').text(''); $('#addCertificates #contentHelp').hide(); } }, setQR:function(){ if($('#addCertificates #qr').is(":checked")){ $('#addCertificates .qr').show(); $('#qrcode').qrcode(qrcodeOptions); $('#addCertificates #qrHelp').show(); $('#addCertificates #qrcodeDiv').css('top',$('#qrcodePosTop').val()); $('#addCertificates #qrcodeDiv').css('left',$('#qrcodePosLeft').val()); }else{ $('#qrcode').empty(); $('#addCertificates .qr').hide(); $('#addCertificates #qrHelp').hide(); } }, setCertLogoInput:function(){ if($('#addCertificates #certLogo').is(":checked")){ $('#addCertificates #certificateImageLogo').show(); $('#addCertificates #certLogoInput').show(); $('#addCertificates #logoHelp').show(); $('#addCertificates #certificateImageLogo').css('top',$('#certificateImageLogoPosTop').val()); $('#addCertificates #certificateImageLogo').css('left',$('#certificateImageLogoPosLeft').val()); }else{ $('#addCertificates #certificateImageLogo').hide(); $('#addCertificates #certLogoInput').hide(); $('#addCertificates #logoHelp').hide(); $('#addCertificates #certificateImageLogo').attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $('#addCertificates #certificateLogoUrlHidden').val(""); } }, setCertSignatureInput:function(){ if($('#addCertificates #certSignature').is(":checked")){ $('#addCertificates #certificateImageSignature').show(); $('#addCertificates #certSignatureInput').show(); $('#addCertificates #signatureHelp').show(); $('#addCertificates #certificateImageSignature').css('top',$('#certificateImageSignatureLogoPosTop').val()); $('#addCertificates #certificateImageSignature').css('left',$('#certificateImageSignatureLogoPosLeft').val()); }else{ $('#addCertificates #certificateImageSignature').hide(); $('#addCertificates #certSignatureInput').hide(); $('#addCertificates #signatureHelp').hide(); $('#addCertificates #certificateImageSignature').attr("src","data:image/svg+xml;charset=utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E"); $('#addCertificates #certificateSignatureUrlHidden').val(""); } }, create:function(orgFolder){ var param = {}; var valid = true; param.imageSignature = ''; param.imageLogo = ''; $('#addCertificates #certificateName').removeClass('error'); if($('#addCertificates #certSignature').is(":checked")){ if($('#addCertificates #certificateSignatureUrlHidden').val()!= '' && $('#addCertificates #certificateSignatureUrlHidden').val()!= null && $('#addCertificates #certificateSignatureUrlHidden').length != 0){ param.imageSignature = $('#addCertificates #certificateSignatureUrlHidden').val(); }else{ valid = false; showMessage('Upload a Signature image for the certificate', 3000); } } if($('#addCertificates #certLogo').is(":checked")){ if($('#addCertificates #certificateLogoUrlHidden').val()!= '' && $('#addCertificates #certificateLogoUrlHidden').val()!= null && $('#addCertificates #certificateLogoUrlHidden').length != 0){ param.imageLogo = $('#addCertificates #certificateLogoUrlHidden').val(); }else{ valid = false; showMessage('Upload a Logo image for the certificate', 3000); } } if(valid){ if( $('#addCertificates #certificateName').val()!='' && $('#addCertificates #certificateName').val().length > 0 ){ param.name = $('#addCertificates #certificateName').val(); param.textParticipantName = $('#addCertificates #certName').is(":checked"); param.textParticipantId = $('#addCertificates #idParticipant').is(":checked"); param.textCourseName = $('#addCertificates #courseName').is(":checked"); param.textInstructorName = $('#addCertificates #instructorName').is(":checked"); param.textHours = $('#addCertificates #hours').is(":checked"); param.textDate = $('#addCertificates #creationDate').is(":checked"); param.textQrLink = $('#addCertificates #qr').is(":checked"); param.textContent = $('#addCertificates #certContent').is(":checked"); param.image = $('#addCertificates #certificateUrlHidden').val(); param.orgFolder = orgFolder; //posiciones de labels dentro del certificado param.toPosTop = $('#to').css("top");//$('#toPosTop').val(); param.toPosLeft = $('#to').css("left"); param.coursePosTop = $('#course').css("top"); param.coursePosLeft = $('#course').css("left"); param.instructorPosTop = $('#instructor').css("top"); param.instructorPosLeft = $('#instructor').css("left"); param.periodPosTop = $('#period').css("top"); param.periodPosLeft = $('#period').css("left"); param.effortPosTop = $('#effort').css("top"); param.effortPosLeft = $('#effort').css("left"); param.qrcodePosTop = $('#qrcodeDiv').css("top"); param.qrcodePosLeft = $('#qrcodeDiv').css("left"); param.imageSignaturePosTop = $('#certificateImageSignature').css("top"); param.imageSignaturePosLeft = $('#certificateImageSignature').css("left"); param.imageLogoPosTop = $('#certificateImageLogo').css("top"); param.imageLogoPosLeft = $('#certificateImageLogo').css("left"); param.idPosTop = $('#idPosTop').val(); param.contentTextPosTop = $('#contentTextPosTop').val(); showGenericLoading(); requestService(PATH_SERVICE_CERTIFICATES_CREATE(), param, "GET", true, function(data) { hideGenericLoading(); if(data.responseInfoJSON.responseCode == 1){ showMessage('The certificate was saved successfully', 3000); setTimeout(function(){ certificates.backAdminCertificates(); certificates.iniDataTable(); },3000); }else{ showMessage('We are sorry, an error occurred and failed to save your changes.', 3000); } }, function(data) { hideGenericLoading(); if(data.responseInfoJSON.responseCode == 1){ certificates.backAdminCertificates(); certificates.iniDataTable(); }else{ showMessage('We are sorry, an error occurred and failed to save your changes.', 3000); } } ); }else{ $('#addCertificates #certificateName').addClass('error'); } } }, evtDeleteCertificate:function(cId){ var param={}; param.certificateId=cId; var hash = generateHash(); showGenericLoading(); $.when(certificates.delete(param)).then(function(data){ if(hash == currentHash){ hideGenericLoading(); if(data.responseInfoJSON.responseCode=="1"){ showMessage('Certificate deleted', 3000); setTimeout(function(){ certificates.backAdminCertificates(); certificates.iniDataTable(); },3000); } } },function(){ if(hash == currentHash){ hideGenericLoading(); //redirectToGenericError("certificates.evtDeleteApprenticeInvitationSpec('"+token+"')","We are sorry, an error occurred and failed to save your changes.",true); } }); }, edit:function(){ var param = {}; var valid = true; param.imageSignature = ''; param.imageLogo = ''; $('#addCertificates #certificateName').removeClass('error'); if($('#addCertificates #certSignature').is(":checked")){ if($('#addCertificates #certificateSignatureUrlHidden').val()!= '' && $('#addCertificates #certificateSignatureUrlHidden').val()!= null && $('#addCertificates #certificateSignatureUrlHidden').length != 0){ param.imageSignature = $('#addCertificates #certificateSignatureUrlHidden').val(); }else{ valid = false; showMessage('Upload a Signature image for the certificate', 3000); } } if($('#addCertificates #certLogo').is(":checked")){ if($('#addCertificates #certificateLogoUrlHidden').val()!= '' && $('#addCertificates #certificateLogoUrlHidden').val()!= null && $('#addCertificates #certificateLogoUrlHidden').length != 0){ param.imageLogo = $('#addCertificates #certificateLogoUrlHidden').val(); }else{ valid = false; showMessage('Upload a Logo image for the certificate', 3000); } } if(valid){ if( $('#addCertificates #certificateName').val()!='' && $('#addCertificates #certificateName').val().length > 0 ){ param.certificateId = certificates.currentCertificate; param.name = $('#addCertificates #certificateName').val(); param.textParticipantName = $('#addCertificates #certName').is(":checked"); param.textParticipantId = $('#addCertificates #idParticipant').is(":checked"); param.textCourseName = $('#addCertificates #courseName').is(":checked"); param.textInstructorName = $('#addCertificates #instructorName').is(":checked"); param.textHours = $('#addCertificates #hours').is(":checked"); param.textDate = $('#addCertificates #creationDate').is(":checked"); param.textQrLink = $('#addCertificates #qr').is(":checked"); param.textContent = $('#addCertificates #certContent').is(":checked"); param.image = $('#addCertificates #certificateUrlHidden').val(); //posiciones de labels dentro del certificado //posiciones de labels dentro del certificado param.toPosTop = $('#to').css("top");//$('#toPosTop').val(); param.toPosLeft = $('#to').css("left"); param.coursePosTop = $('#course').css("top"); param.coursePosLeft = $('#course').css("left"); param.instructorPosTop = $('#instructor').css("top"); param.instructorPosLeft = $('#instructor').css("left"); param.periodPosTop = $('#period').css("top"); param.periodPosLeft = $('#period').css("left"); param.effortPosTop = $('#effort').css("top"); param.effortPosLeft = $('#effort').css("left"); param.qrcodePosTop = $('#qrcodeDiv').css("top"); param.qrcodePosLeft = $('#qrcodeDiv').css("left"); param.imageSignaturePosTop = $('#certificateImageSignature').css("top"); param.imageSignaturePosLeft = $('#certificateImageSignature').css("left"); param.imageLogoPosTop = $('#certificateImageLogo').css("top"); param.imageLogoPosLeft = $('#certificateImageLogo').css("left"); param.idPosTop = $('#idPosTop').val(); param.contentTextPosTop = $('#contentTextPosTop').val(); var hash = generateHash(); showGenericLoading(); $.when(certificates.editCertificate(param)).then(function(data){ if(hash == currentHash){ hideGenericLoading(); if(data.responseInfoJSON.responseCode=="1"){ showMessage('The certificate was saved successfully', 3000); setTimeout(function(){ certificates.backAdminCertificates(); certificates.iniDataTable(); },3000); } } },function(){ if(hash == currentHash){ hideGenericLoading(); } }); }else{ $('#addCertificates #certificateName').addClass('error'); } } }, showEditCertificate:function(cId,orgFolder){ showGenericLoading(); certificates.currentCertificate = cId; certificates.resetFields(); $.when(certificates.setCertificateValues(cId,orgFolder)).then(function(){ certificates.disableDraggable(false); $("#certificates-step-title").empty(); $("#certificates-step-title").text('Edit certificate'); $("#adminCertificates").hide(); $("#addCertificates #btn-create").hide(); $("#addCertificates #btn-edit").show(); $("#addCertificates #editBackgroundButton").show(); $("#addCertificates").show(); hideGenericLoading(); },function(){ redirectToGenericError("organization.showEditCertificate()",null,false); }); }, setCertificateValuesPreview:function(cId,orgFolder){ var param={}; param.certificateId = cId; return requestService(PATH_SERVICE_CERTIFICATES_GET(), param, "GET", true, function(data) { var dataResponse = data.organizationCertificatesJSON; $('#addCertificates #certificateName').val(dataResponse.name); $( "#addCertificates #certName").prop('checked', dataResponse.textParticipantName); $( "#addCertificates #courseName").prop('checked', dataResponse.textCourseName); $( "#addCertificates #creationDate").prop('checked', dataResponse.textDate); $( "#addCertificates #qr").prop('checked', dataResponse.textQrLink); $( "#addCertificates #instructorName").prop('checked', dataResponse.textInstructorName); $( "#addCertificates #hours").prop('checked', dataResponse.textHours); $( "#addCertificates #certContent").prop('checked', dataResponse.textContent); $("#addCertificates #certificateUrlHidden").val(dataResponse.image); $("#addCertificates #certificateLogoUrlHidden").val(dataResponse.imageLogo); $("#addCertificates #certificateSignatureUrlHidden").val(dataResponse.imageSignature); $.when(getUrlWLImage(dataResponse.image,"false",orgFolder,"certificates","addCertificates")).done(function () { hideGenericLoading(); if(dataResponse.imageLogo != null && dataResponse.imageLogo != ''){ $.when(getUrlWLImageLogo(dataResponse.imageLogo,"false",orgFolder,"certificateslogo","addCertificates")).done(function () { $( "#addCertificates #certLogo").prop('checked', true); $('#addCertificates #certificateImageLogo').show(); $('#certificateImageLogo').css('top',dataResponse.imageLogoPosTop); $('#certificateImageLogo').css('left',dataResponse.imageLogoPosLeft); $('#certificateImageLogoPosTop').val(dataResponse.imageLogoPosTop); $('#certificateImageLogoPosLeft').val(dataResponse.imageLogoPosLeft); }); }else{ $( "#addCertificates #certLogo").prop('checked', false); $('#addCertificates #certificateImageLogo').hide(); } if(dataResponse.imageSignature != null && dataResponse.imageSignature != ''){ $.when(getUrlWLImageSignature(dataResponse.imageSignature,"false",orgFolder,"certificatessignature","addCertificates")).done(function () { $( "#addCertificates #certSignature").prop('checked', true); $('#addCertificates #certificateImageSignature').show(); $('#certificateImageSignature').css('top',dataResponse.imageSignaturePosTop); $('#certificateImageSignature').css('left',dataResponse.imageSignaturePosLeft); $('#certificateImageSignatureLogoPosTop').val(dataResponse.imageSignaturePosTop); $('#certificateImageSignatureLogoPosLeft').val(dataResponse.imageSignaturePosLeft); }); }else{ $( "#addCertificates #certSignature").prop('checked', false); $('#addCertificates #certificateImageSignature').hide(); } if(dataResponse.textQrLink){ $('#qrcode').empty(); $('#addCertificates .qr').show(); $('#qrcode').qrcode(qrcodeOptions); $('#addCertificates #qrHelp').show(); $('#qrcodeDiv').css('top',dataResponse.qrcodePosTop); $('#qrcodeDiv').css('left',dataResponse.qrcodePosLeft); $('#qrcodePosTop').val(dataResponse.qrcodePosTop); $('#qrcodePosLeft').val(dataResponse.qrcodePosLeft); }else{ $('#qrcode').empty(); $('#addCertificates .qr').hide(); $('#addCertificates #qrHelp').hide(); } if(dataResponse.textParticipantName){ $('#to').text('Participant name'); $('#to').css('top',dataResponse.toPosTop); $('#to').css('left',dataResponse.toPosLeft); $('#toPosTop').val(dataResponse.toPosTop); $('#toPosLeft').val(dataResponse.toPosLeft); }else{ $('#to').empty(); } if(dataResponse.textCourseName){ $('#course').text('Course name'); $('#course').css('top',dataResponse.coursePosTop); $('#course').css('left',dataResponse.coursePosLeft); $('#coursePosTop').val(dataResponse.coursePosTop); $('#coursePosLeft').val(dataResponse.coursePosLeft); }else{ $('#course').empty(); } if(dataResponse.textContent){ //$('#contentText').text('Activities List'); $('#addCertificates #contentHelp').show(); }else{ //$('#contentText').empty(); $('#addCertificates #contentHelp').hide(); } if(dataResponse.textDate){ $('#period').text('Date'); $('#period').css('top',dataResponse.periodPosTop); $('#period').css('left',dataResponse.periodPosLeft); $('#periodPosTop').val(dataResponse.periodPosTop); $('#periodPosLeft').val(dataResponse.periodPosLeft); }else{ $('#period').empty(); } if(dataResponse.textInstructorName){ $('#instructor').text('Instuctor name'); $('#instructor').css('top',dataResponse.instructorPosTop); $('#instructor').css('left',dataResponse.instructorPosLeft); $('#instructorPosTop').val(dataResponse.instructorPosTop); $('#instructorPosLeft').val(dataResponse.instructorPosLeft); }else{ $('#instructor').empty(); } if(dataResponse.textHours){ $('#effort').text('Hours'); $('#effort').css('top',dataResponse.effortPosTop); $('#effort').css('left',dataResponse.effortPosLeft); $('#effortPosTop').val(dataResponse.effortPosTop); $('#effortPosLeft').val(dataResponse.effortPosLeft); }else{ $('#effort').empty(); } $("#addCertificates #certificateName").attr('disabled', 'disabled'); $("#addCertificates #certificateName").attr('readonly', 'readonly'); $("#addCertificates #certName").attr('disabled', 'disabled'); $("#addCertificates #certName").attr('readonly', 'readonly'); $("#addCertificates #courseName").attr('disabled', 'disabled'); $("#addCertificates #courseName").attr('readonly', 'readonly'); $("#addCertificates #creationDate").attr('disabled', 'disabled'); $("#addCertificates #creationDate").attr('readonly', 'readonly'); $("#addCertificates #qr").attr('disabled', 'disabled'); $("#addCertificates #qr").attr('readonly', 'readonly'); $("#addCertificates #instructorName").attr('disabled', 'disabled'); $("#addCertificates #instructorName").attr('readonly', 'readonly'); $("#addCertificates #hours").attr('disabled', 'disabled'); $("#addCertificates #hours").attr('readonly', 'readonly'); $("#addCertificates #certContent").attr('disabled', 'disabled'); $("#addCertificates #certContent").attr('readonly', 'readonly'); $("#addCertificates #certLogo").attr('disabled', 'disabled'); $("#addCertificates #certLogo").attr('readonly', 'readonly'); $("#addCertificates #certSignature").attr('disabled', 'disabled'); $("#addCertificates #certSignature").attr('readonly', 'readonly'); $("#logoHelp").hide(); $("#certLogoInput").hide(); $("#signatureHelp").hide(); $("#certSignatureInput").hide(); }) }, function() { }); }, setCertificateValues:function(cId,orgFolder){ var param={}; param.certificateId = cId; return requestService(PATH_SERVICE_CERTIFICATES_GET(), param, "GET", true, function(data) { var dataResponse = data.organizationCertificatesJSON; $("#addCertificates #certificateName").attr('disabled', false); $("#addCertificates #certificateName").attr('readonly', false); $("#addCertificates #certName").attr('disabled', false); $("#addCertificates #certName").attr('readonly', false); $("#addCertificates #courseName").attr('disabled', false); $("#addCertificates #courseName").attr('readonly', false); $("#addCertificates #creationDate").attr('disabled', false); $("#addCertificates #creationDate").attr('readonly', false); $("#addCertificates #qr").attr('disabled', false); $("#addCertificates #qr").attr('readonly', false); $("#addCertificates #instructorName").attr('disabled', false); $("#addCertificates #instructorName").attr('readonly', false); $("#addCertificates #hours").attr('disabled', false); $("#addCertificates #hours").attr('readonly', false); $("#addCertificates #certContent").attr('disabled', false); $("#addCertificates #certContent").attr('readonly', false); $("#addCertificates #certLogo").attr('disabled', false); $("#addCertificates #certLogo").attr('readonly', false); $("#addCertificates #certSignature").attr('disabled', false); $("#addCertificates #certSignature").attr('readonly', false); $("#logoHelp").hide(); $("#certLogoInput").hide(); $("#signatureHelp").hide(); $("#certSignatureInput").hide(); $('#addCertificates #certificateName').val(dataResponse.name); $( "#addCertificates #certName").prop('checked', dataResponse.textParticipantName); $( "#addCertificates #courseName").prop('checked', dataResponse.textCourseName); $( "#addCertificates #creationDate").prop('checked', dataResponse.textDate); $( "#addCertificates #qr").prop('checked', dataResponse.textQrLink); $( "#addCertificates #instructorName").prop('checked', dataResponse.textInstructorName); $( "#addCertificates #hours").prop('checked', dataResponse.textHours); $( "#addCertificates #certContent").prop('checked', dataResponse.textContent); $("#addCertificates #certificateUrlHidden").val(dataResponse.image); $("#addCertificates #certificateLogoUrlHidden").val(dataResponse.imageLogo); $("#addCertificates #certificateSignatureUrlHidden").val(dataResponse.imageSignature); $.when(getUrlWLImage(dataResponse.image,"false",orgFolder,"certificates","addCertificates")).done(function () { hideGenericLoading(); if(dataResponse.imageLogo != null && dataResponse.imageLogo != ''){ $.when(getUrlWLImageLogo(dataResponse.imageLogo,"false",orgFolder,"certificateslogo","addCertificates")).done(function () { $( "#addCertificates #certLogo").prop('checked', true); $('#addCertificates #certificateImageLogo').show(); $('#certificateImageLogo').css('top',dataResponse.imageLogoPosTop); $('#certificateImageLogo').css('left',dataResponse.imageLogoPosLeft); $('#certificateImageLogoPosTop').val(dataResponse.imageLogoPosTop); $('#certificateImageLogoPosLeft').val(dataResponse.imageLogoPosLeft); }); }else{ $( "#addCertificates #certLogo").prop('checked', false); $('#addCertificates #certificateImageLogo').hide(); } if(dataResponse.imageSignature != null && dataResponse.imageSignature != ''){ $.when(getUrlWLImageSignature(dataResponse.imageSignature,"false",orgFolder,"certificatessignature","addCertificates")).done(function () { $( "#addCertificates #certSignature").prop('checked', true); $('#addCertificates #certificateImageSignature').show(); $('#certificateImageSignature').css('top',dataResponse.imageSignaturePosTop); $('#certificateImageSignature').css('left',dataResponse.imageSignaturePosLeft); $('#certificateImageSignatureLogoPosTop').val(dataResponse.imageSignaturePosTop); $('#certificateImageSignatureLogoPosLeft').val(dataResponse.imageSignaturePosLeft); }); }else{ $( "#addCertificates #certSignature").prop('checked', false); $('#addCertificates #certificateImageSignature').hide(); } if(dataResponse.textQrLink){ $('#qrcode').empty(); $('#addCertificates .qr').show(); $('#qrcode').qrcode(qrcodeOptions); $('#addCertificates #qrHelp').show(); $('#qrcodeDiv').css('top',dataResponse.qrcodePosTop); $('#qrcodeDiv').css('left',dataResponse.qrcodePosLeft); $('#qrcodePosTop').val(dataResponse.qrcodePosTop); $('#qrcodePosLeft').val(dataResponse.qrcodePosLeft); }else{ $('#qrcode').empty(); $('#addCertificates .qr').hide(); $('#addCertificates #qrHelp').hide(); } if(dataResponse.textParticipantName){ $('#to').text('Participant name'); $('#to').css('top',dataResponse.toPosTop); $('#to').css('left',dataResponse.toPosLeft); $('#toPosTop').val(dataResponse.toPosTop); $('#toPosLeft').val(dataResponse.toPosLeft); }else{ $('#to').empty(); } if(dataResponse.textCourseName){ $('#course').text('Course name'); $('#course').css('top',dataResponse.coursePosTop); $('#course').css('left',dataResponse.coursePosLeft); $('#coursePosTop').val(dataResponse.coursePosTop); $('#coursePosLeft').val(dataResponse.coursePosLeft); }else{ $('#course').empty(); } if(dataResponse.textContent){ //$('#contentText').text('Activities List'); $('#addCertificates #contentHelp').show(); }else{ //$('#contentText').empty(); $('#addCertificates #contentHelp').hide(); } if(dataResponse.textDate){ $('#period').text('Date'); $('#period').css('top',dataResponse.periodPosTop); $('#period').css('left',dataResponse.periodPosLeft); $('#periodPosTop').val(dataResponse.periodPosTop); $('#periodPosLeft').val(dataResponse.periodPosLeft); }else{ $('#period').empty(); } if(dataResponse.textInstructorName){ $('#instructor').text('Instuctor name'); $('#instructor').css('top',dataResponse.instructorPosTop); $('#instructor').css('left',dataResponse.instructorPosLeft); $('#instructorPosTop').val(dataResponse.instructorPosTop); $('#instructorPosLeft').val(dataResponse.instructorPosLeft); }else{ $('#instructor').empty(); } if(dataResponse.textHours){ $('#effort').text('Hours'); $('#effort').css('top',dataResponse.effortPosTop); $('#effort').css('left',dataResponse.effortPosLeft); $('#effortPosTop').val(dataResponse.effortPosTop); $('#effortPosLeft').val(dataResponse.effortPosLeft); }else{ $('#effort').empty(); } }); }, function() { }); }, delete:function(param){ return requestService(PATH_SERVICE_CERTIFICATES_DELETE(), param, "GET", true, function(data) {}, function() {}); }, sendOrgImageAddCertificateSetup:function(orgFolder,selector){ var urlForm = $("#orgCertificateForm").attr("action"); var oldUrlForm = urlForm; $("#orgCertificateForm").attr("action",urlForm); $("#orgCertificateForm").ajaxSubmit({ dataType:"json", success:function(data){ if(!data.error){ var fileName = data.fileName; showGenericLoading(); $.when(getUrlWLImage(fileName,"false",orgFolder,"certificates")).done(function (x) { console.log('Cargada'); hideGenericLoading(); }); //certificates.getUrlWLImage(fileName,"false",orgFolder,"certificates"); } }, error:function(data){ } }); }, getUrlWLImage : function(fileName,isMp4OrHtml5,orgFolder,orgChildFolder) { var param = {}; param.fileName = fileName; param.isMp4OrHtml5 = isMp4OrHtml5; param.orgFolder = orgFolder; param.orgChildFolder = orgChildFolder; var urlWLImage = ''; showGenericLoading(); requestService(PATH_SERVICE_GET_URL_WL_BADGEIMAGE(), param, "GET", true,function(data) { urlWLImage = data.responseText; if( data.responseText == '-1' || data.responseText == ''){ $('#'+selector+' #badgeIcon').parent().parent().hide(); }else{ $('#'+selector+' #previewBadgeImage').attr('src', data.responseText); $('#'+selector+' #badgeIcon').attr('src', data.responseText); badges.addBadgeIcon(data.responseText,selector); badges.checkImgSize(); } //hideGenericLoading(); }, function(data){ urlWLImage = data.responseText; if( data.responseText == '-1'){ $('#'+selector+' #badgeIcon').parent().parent().hide(); }else{ $('#'+selector+' #previewBadgeImage').attr('src', data.responseText); $('#'+selector+' #badgeIcon').attr('src', data.responseText); badges.addBadgeIcon(data.responseText,selector); badges.checkImgSize(); } //hideGenericLoading(); }); return urlWLImage; }, previewSetupAddCertificateOrg:function(input,orgFolder) { ext = (getExt($(input).val())).toLowerCase(); if(ext == "jpg" || ext == "jpeg" || ext == "png"){ certificates.sendOrgImageAddCertificateSetup(orgFolder); }else{ showMessage($.i18n._("error.div.invalidImage")+": .png .jpg"); $(input).val(""); } }, editCertificate:function(param){ return requestService(PATH_SERVICE_CERTIFICATES_EDIT(), param, "GET", true, function(data) {}, function() {}); }, };