');
newWin.document.write(divToPrint.innerHTML);
newWin.document.write('');
newWin.focus();
newWin.document.close();
}
// alert za dodajanje vseh elementov istega tipa v custom report
function addCustomReportAllElementsAlert(type) {
if(type > 0){
$('#fade').fadeTo('slow', 1, function(){
$('#custom_report_alert').show();
$('#custom_report_alert').load('ajax.php?t=custom_report&a=all_elements_alert', {anketa: srv_meta_anketa_id, type:type});
});
}
}
// zapremo alert za dodajanje vseh elementov istega tipa v custom report
function addCustomReportAllElementsClose() {
$('#fade').fadeOut('slow', function(){
$('#custom_report_alert').hide();
});
}
// doda vse elemente istega tipa v custom report (vse grafe, opisne, frekvence, sumarnike)
function addCustomReportAllElements(type) {
// Napolnimo report z vsemi elementi istega tipa - BREAK
if(type == 9){
var sub_type = $('input:radio[name=break_charts]:checked').val();
var spr = $('#breakSpremenljivka').val();
var seq = $('option:selected', '#breakSpremenljivka').attr('seq');
var spr1 = seq + '-' + spr + '-undefined';
$.post('ajax.php?t=custom_report&a=all_elements_add', {anketa: srv_meta_anketa_id, type:type, sub_type:sub_type, spr1:spr1}, function(){
// skocimo na custom report
var srv_site_url = $("#srv_site_url").val();
srv_site_url += 'admin/survey/index.php?anketa='+srv_meta_anketa_id+'&a=analysis&m=analysis_creport';
window.location.href = srv_site_url;
}
);
}
// Napolnimo report z vsemi elementi istega tipa
else{
$.post('ajax.php?t=custom_report&a=all_elements_add', {anketa: srv_meta_anketa_id, type:type}, function(){
// skocimo na custom report
var srv_site_url = $("#srv_site_url").val();
srv_site_url += 'admin/survey/index.php?anketa='+srv_meta_anketa_id+'&a=analysis&m=analysis_creport';
window.location.href = srv_site_url;
}
);
}
}
/**
* nastavi editor na contenteditable element za naslov
*/
function creport_load_editor (_this) {
$(_this).css('display', 'none');
var el = $(_this).parent().find('.creport_text_inline');
var el_id = el.attr('el_id');
el.replaceWith(''+
''+lang['save']+'');
create_editor('report_element_texteditor_'+el_id);
}
/**
* shrani editor in nastavi nazaj contenteditable
*/
function creport_save_editor(el_id) {
get_editor_close('report_element_texteditor_'+el_id);
var el = $('#report_element_texteditor_'+el_id);
var parent = el.parent();
el.replaceWith('
'+el.html+'
');
parent.find('span.buttonwrapper').remove();
editCustomReportElement(el_id, 'text', el.val());
}
function doArchiveCReport() {
//preverimo ali obstaja vsebina breakResults
if ($("#custom_report_elements").length > 0 && $("#custom_report_elements").html() != '') {
$("#fullscreen").load('ajax.php?a=doArchiveAnaliza', {anketa: srv_meta_anketa_id, podstran: srv_meta_podstran}, function() {
$('#fade').fadeTo('slow', 1);
$('#fullscreen').show();
});
} else {
genericAlertPopup('alert_no_archive_tables');
}
}
function submitArchiveCReport() {
//preverimo ali obstaja vsebina meansa
if ($("#custom_report_elements").html().length > 0 ) {
var name = $("#newAnalysisArchiveName").val();
var note = $("#newAnalysisArchiveNote").val();
var access = $("[name=newAnalysisArchiveAccess]:checked").val();
var duration = $("#newAnalysisArchiveDuration").val();
var durationType = $("[name=newAADurationType]:checked").val();
$("#fullscreen").load('ajax.php?a=submitArchiveAnaliza', {anketa: srv_meta_anketa_id, podstran: srv_meta_podstran, name:name, note:note, access:access, duration:duration, durationType:durationType}, function() {
$("#fullscreen").show();
});
}
else {
genericAlertPopup('alert_no_archive_tables');
}
}
function createArchiveCReportBeforeEmail() {
//preverimo ali obstaja vsebina custom_report_elements
if ($("#custom_report_elements").html().length > 0 ) {
//var content = $("#custom_report_elements").html();
$.post('ajax.php?a=createArchiveBeforeEmail', {anketa: srv_meta_anketa_id, podstran: srv_meta_podstran/*, content:content*/}, function(response) {
if (parseInt(response) > 0) {
var aid = parseInt(response);
$("#fullscreen").load('ajax.php?a=emailArchiveAnaliza', {anketa: srv_meta_anketa_id, podstran: srv_meta_podstran, aid:aid}, function() {
$('#fullscreen').show();
});
} else {
if (parseInt(response) == -1) {
genericAlertPopup('alert_no_archive_response',response);
} else {
genericAlertPopup('alert_archive_error_response',response);
}
$('#fullscreen').hide();
$('#fade').fadeOut('slow');
}
});
} else {
genericAlertPopup('alert_no_archive_tables');
}
};
function showCReportPreview() {
var size = "location=0,height=800,scrollbars=1,fullscreen=0,menubar=0,status=0,titlebar=0,toolbar=0,channelmode=0,directories=0";
var recipe = window.open('','RecipeWindow',size);
$.post('ajax.php?t=custom_report&a=report_preview', {anketa: srv_meta_anketa_id}, function(response) {
recipe.document.open();
recipe.document.write('Predogled poročila po meri');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write('');
recipe.document.write(response);
recipe.document.write('');
recipe.document.close();
recipe.focus();
return false;
});
}
function showCReportProfiles(){
$('#fade').fadeTo('slow', 1);
$("#div_creport_settings_profiles").load('ajax.php?t=custom_report&a=creport_show_profiles', {anketa: srv_meta_anketa_id}, function(){
$("#div_creport_settings_profiles").show(200);
});
return false; // "capture" the click
}
function add_creport_profile() {
$('#fade').fadeTo('slow', 1);
$("#newCReportProfile").show();
}
function delete_creport_profile() {
$('#fade').fadeTo('slow', 1);
$("#deleteCReportProfile").show();
}
function close_creport_profile() {
$("#div_creport_settings_profiles").fadeOut();
$("#fade").fadeOut();
}
function use_creport_profile() {
var value = $(".creport_profiles .active").attr('value');
var author = $(".creport_profiles .active").attr('author');
$.post('ajax.php?t=custom_report&a=use_creport_profile', {anketa:srv_meta_anketa_id, id:value, author:author}, function(){
var srv_site_url = $("#srv_site_url").val();
srv_site_url += 'admin/survey/index.php?anketa='+srv_meta_anketa_id+'&a=analysis&m=analysis_creport&expanded='+global_expanded;
window.location.href = srv_site_url;
});
}
// Preklopimo porocilo
function change_creport_profile(profile_id, author) {
$.post('ajax.php?t=custom_report&a=use_creport_profile', {anketa:srv_meta_anketa_id, id:profile_id, author:author}, function(){
var srv_site_url = $("#srv_site_url").val();
srv_site_url += 'admin/survey/index.php?anketa='+srv_meta_anketa_id+'&a=analysis&m=analysis_creport&expanded='+global_expanded;
window.location.href = srv_site_url;
});
}
// popravljamo custom report profil
function creport_profile_action(action){
// Rename actions
if (action == 'show_rename') {
$("#dsp_cover_div").show();
$("#renameCReportProfile").show();
// Popravimo naslov izbranega porocila
var title = $("#creport_profiles").find('.active').html();
$("#renameCReportProfileName").val(title);
}
else if(action == 'cancel_rename'){
$("#dsp_cover_div").hide();
$("#renameCReportProfile").hide();
}
else if(action == 'rename'){
var id = $(".creport_profiles .active").attr('value');
var name = $("#renameCReportProfileName").val();
$("#div_creport_settings_profiles").load('ajax.php?t=custom_report&a=renameProfile', {anketa:srv_meta_anketa_id, id:id, name:name}, function() {
$("#renameCReportProfile").hide();
$("#dsp_cover_div").fadeOut();
});
}
// Delete actions
else if(action == 'show_delete'){
if($("#div_creport_settings_profiles").is(':visible'))
$("#dsp_cover_div").show();
else
$('#fade').fadeTo('slow', 1);
$("#deleteCReportProfile").show();
// Popravimo naslov izbranega porocila
var title = $("#creport_profiles").find('.active').html();
$("#deleteCReportProfileName").html(title);
}
else if(action == 'cancel_delete'){
if($("#div_creport_settings_profiles").is(':visible')){
$("#deleteCReportProfile").hide();
$("#dsp_cover_div").hide();
}
else{
$("#deleteCReportProfile").hide();
$("#fade").fadeOut();
}
}
else if(action == 'delete'){
var id = $(".creport_profiles .active").attr('value');
$("#div_creport_settings_profiles").load('ajax.php?t=custom_report&a=deleteProfile', {anketa:srv_meta_anketa_id, id:id}, function() {
$("#deleteCReportProfile").hide();
$("#dsp_cover_div").fadeOut();
});
}
// Add actions
else if(action == 'show_new'){
if($("#div_creport_settings_profiles").is(':visible'))
$("#dsp_cover_div").show();
else
$('#fade').fadeTo('slow', 1);
$("#newCReportProfile").show();
}
else if(action == 'cancel_new'){
if($("#div_creport_settings_profiles").is(':visible')){
$("#newCReportProfile").hide();
$("#dsp_cover_div").hide();
}
else{
$("#newCReportProfile").hide();
$("#fade").fadeOut();
}
}
else if(action == 'new'){
var name = $("#newCReportProfileName").val();
var comment = $("#newCReportProfileComment").val();
$.post('ajax.php?t=custom_report&a=newProfile', {anketa:srv_meta_anketa_id, name:name, comment:comment}, function() {
var srv_site_url = $("#srv_site_url").val();
srv_site_url += 'admin/survey/index.php?anketa='+srv_meta_anketa_id+'&a=analysis&m=analysis_creport';
window.location.href = srv_site_url;
});
}
// Share actions
if (action == 'show_share') {
var id = $(".creport_profiles .active").attr('value');
$("#dsp_cover_div").show();
$("#shareCReportProfile").load('ajax.php?t=custom_report&a=shareProfileShow', {anketa:srv_meta_anketa_id, id:id}, function(){
$("#shareCReportProfile").show(200);
});
}
else if(action == 'cancel_share'){
$("#dsp_cover_div").hide();
$("#shareCReportProfile").hide();
}
else if(action == 'share'){
var id = $(".creport_profiles .active").attr('value');
var users = [];
$("#shareCReportProfile input:checked").each(function() {
users.push($(this).val());
});
$("#div_creport_settings_profiles").load('ajax.php?t=custom_report&a=shareProfile', {anketa:srv_meta_anketa_id, id:id, users:users}, function() {
$("#shareCReportProfile").hide();
$("#dsp_cover_div").fadeOut();
});
}
}
// urejanje komentarja profila
function creport_profile_comment(value){
$.post('ajax.php?t=custom_report&a=edit_profile_comment', {anketa: srv_meta_anketa_id, value:value});
}