//Main admin JS file
$(function() {
jQuery.validator.addMethod("noSpace", function(value, element) {
return value.indexOf(" ") < 0 && value != "";
}, "Space are not allowed");
jQuery.validator.addMethod("invalidUsername", function(value, element) {
return value != "" && value.toUpperCase() != "ROOT" && value.toUpperCase() != "ADMIN";
}, "Invalid username");
jQuery.validator.addMethod("numericField", function(value, element) {
var myregExp = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
return value == "" || (value != "" && myregExp.test(value));
}, "Invalid number");
jQuery.validator.addMethod("requiredTinyMCE", function(value, element) {
return tinyMCE.get($(element).attr('id')).getContent() != '';
//return Trim(tinyMCE.get(element.attr('id')).getContent()) == '';
//return value.indexOf(" ") < 0 && value != "";
}, "Required");
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_last_cookie_key",
type: 'POST',
data: 'lang=' + lang+'&csfrtok='+csfrtok,
success: function (data) {
var actual_key=data;
var cookie_url=$('#base_url').val()+"cookie";
$.cookieBar({
message: "I cookies servono a migliorare i servizi che offriamo e a ottimizzare l\'esperienza dell\'utente. Per saperne di piú accedi alla cookie policy.
Se chiudi il presente banner o prosegui la navigazione del sito, acconsenti all\'utilizzo dei cookie.
",
acceptText: "Ok, chiudi banner",
policyURL: cookie_url,
cookieName: actual_key
});
}
});
/*aggiungi ombra sotto header allo scroll*/
$(window).scroll(function() {
var wScroll = $(this).scrollTop();
if (wScroll ==0){
$(".header_container_main").css({"box-shadow":"none"});
} else {
$(".header_container_main").css({"box-shadow":"0px 0px 2px #666"});
}
});
/*badge container*/
$.ajax({
url: $('#base_url').val() + "ajax/get_badge_number",
type: 'POST',
data: 'csfrtok='+csfrtok,
success: function (data) {
if(data!=""){
$("#js_badge_container").html(data);
$("#js_badge_container").fadeIn();
}
}
});
$("img.lazy").lazyload({
effect : "fadeIn",
skip_invisible : false
});
$("div.lazy").lazyload({
effect : "fadeIn"
});
setLang('',0);
$('#lang_switcher').bind('click',function(e) {
e.preventDefault();
setLang($(this).data('lang'),1);
});
//fa apparire i filtri
$('#js_show_filter').bind('click',function(e) {
// e.preventDefault();
if($('.js_filter_container').css('display') == 'none') {
$('.js_filter_container').fadeIn();
$('#js_show_filter_i').removeClass('fal fa-angle-right').addClass('fal fa-angle-up');
} else {
$('.js_filter_container').fadeOut();
$('#js_show_filter_i').removeClass('fal fa-angle-up').addClass('fal fa-angle-right');
}
});
var genericForm = 1;
/****MENU MOBILE***/
if($('#menu_laterale').length>0) {
$('.menu_btn').bind('click',function(e) {
e.preventDefault();
if(!$('#menu_laterale').hasClass('open')) {
$('#menu_laterale').animate({'right':'0'},500,function() {
$('#menu_laterale').addClass('open');
});
$('body').prepend('
');
$('#sfondo').bind('click',function() {
$('#sfondo').remove();
if($('#menu_laterale').hasClass('open')) {
$('#menu_laterale').animate({'right': '-270px'}, 500, function () {
$('#menu_laterale').removeClass('open');
});
}
});
} else {
$('#sfondo').remove();
if($('#menu_laterale').hasClass('open')) {
$('#menu_laterale').animate({'right': '-270px'}, 500, function () {
$('#menu_laterale').removeClass('open');
});
}
}
});
}
/***COMPLETA REGISTRAZIONE****/
if($('#comp_reg_container').length){
function makeTimer() {
var endTime = new Date($("#data_scadenza").val());
endTime = (Date.parse(endTime) / 1000);
var now = new Date();
now = (Date.parse(now) / 1000);
var timeLeft = endTime - now;
if(timeLeft<=0){ //scaduto
$("#timer").fadeOut(); //offerta scaduta, nascondo il timer
} else {
//var days = Math.floor(timeLeft / 86400);
var hours = Math.floor((timeLeft ) / 3600);
var minutes = Math.floor((timeLeft - (hours * 3600 )) / 60);
var seconds = Math.floor((timeLeft - (hours * 3600) - (minutes * 60)));
if (hours < "10") { hours = "0" + hours; }
if (minutes < "10") { minutes = "0" + minutes; }
if (seconds < "10") { seconds = "0" + seconds; }
//$("#days").html(days + "Days");
$("#hours").html(hours);
$("#minutes").html(minutes);
$("#seconds").html(seconds);
}
}
makeTimer();
setInterval(function() { makeTimer(); }, 1000);
function hasNumber(myString) {
return /\d/.test(myString);
}
$('#password').on('input',function(e){
var actual_pass=$('#password').val();
var upperCase= new RegExp('[A-Z]');
if(actual_pass.match(upperCase)){
$('#js_pwd_val_upper').css('color', 'green');
} else {
$('#js_pwd_val_upper').css('color', '#ccc');
}
if(hasNumber(actual_pass)){
$('#js_pwd_val_num').css('color', 'green');
} else {
$('#js_pwd_val_num').css('color', '#ccc');
}
if(actual_pass.length>=8){
$('#js_pwd_val_otchr').css('color', 'green');
} else {
$('#js_pwd_val_otchr').css('color', '#ccc');
}
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#comp_reg_form').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
/*email: {
remote: {
url: $('#base_url').val()+"ajax/check_email",
type: "post",
data: {
email: function() {
return $('#comp_reg_form').find( "#email" ).val();
},
id:function() {
return 0;
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
email:true,
required:true,
},*/
password : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[^\s]{8,}$/,
minlength : 8,
required: true
},
conferma_password : {
minlength : 8,
equalTo : "#password"
},
privacy_policy_check: {
required:true
},
telefono: {
digits:true
},
piva: {
required:true
},
ragione_sociale: {
required:true
}
},
messages: {
/*email: {
remote: "Questa email è già presente nei nostri sistemi,scegli un altro indirizzo",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
},*/
password: {
regex: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
},
conferma_password: {
equalTo: "le password non coincidono",
minlength: "le password non coincidono",
maxlength: "le password non coincidono"
},
privacy_policy_check: {
required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati."
},
telefono: {
digits: "Inserisci solo numeri"
},
piva: {
required: "Inserisci la tua partita iva"
},
ragione_sociale: {
required: "Inserisci la tua ragione sociale"
}
}
});
}
/***HOME***/
if($('.js_home_block').length) {
$('#recupera').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
email_recupero: {
email:true,
required:true
}
},
messages: {
email_recupero: {
required: "Inserisci un indirizzo email valido",
email: "Inserisci un indirizzo email valido",
},
},
submitHandler: function(form) {
$('#js_form_recupero_container').hide();
$('#js_recupero_loader_container').show();
setTimeout(
function()
{
form.submit();
}, 1000);
}
});
$('#js_chiudi_from_result').bind('click',function(e) {
e.preventDefault();
$('#js_form_recupero_container').show();
$('#js_recupero_loader_container').hide();
$('#js_recupero_result_container').hide();
});
$('#show_password_form').bind('click',function(e) {
e.preventDefault();
$('#login_form').fadeOut(0);
$('#recupera_password').fadeIn();
});
$('#hide_password_form').bind('click',function(e) {
e.preventDefault();
$('#recupera_password').fadeOut(0);
$('#login_form').fadeIn();
});
$('#show_recupero_error').bind('click',function(e) {
e.preventDefault();
$('#recupero_error').fadeIn();
});
$('#hide_recupero_error').bind('keyup',function(e) {
e.preventDefault();
$('#recupero_error').fadeOut();
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#js_open_registrazione').bind('click',function(e) {
e.preventDefault();
$('#login_form').hide();
$('#js_form_registrazione').fadeIn();
});
$('#js_close_registrazione').bind('click',function(e) {
e.preventDefault();
$('#js_form_registrazione').hide();
$('#login_form').fadeIn();
});
function hasNumber(myString) {
return /\d/.test(myString);
}
$('#password_registrazione').on('input',function(e){
var actual_pass=$('#password_registrazione').val();
var upperCase= new RegExp('[A-Z]');
var lowerCase= new RegExp('[a-z]');
if(actual_pass.match(upperCase)){
$('#js_pwd_val_upper').css('color', 'green');
} else {
$('#js_pwd_val_upper').css('color', '#ccc');
}
if(actual_pass.match(lowerCase)){
$('#js_pwd_val_lower').css('color', 'green');
} else {
$('#js_pwd_val_lower').css('color', '#ccc');
}
if(hasNumber(actual_pass)){
$('#js_pwd_val_num').css('color', 'green');
} else {
$('#js_pwd_val_num').css('color', '#ccc');
}
if(actual_pass.length>=8){
$('#js_pwd_val_otchr').css('color', 'green');
} else {
$('#js_pwd_val_otchr').css('color', '#ccc');
}
});
$('#registrazione_form').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
email_registrazione: {
remote: {
url: $('#base_url').val()+"ajax/check_email",
type: "post",
data: {
email: function() {
return $('#registrazione_form').find( "#email_registrazione" ).val();
},
id:function() {
return 0;
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
email:true,
required:true
},
password_registrazione : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[^\s]{8,}$/,
minlength : 8,
//maxlength : 12,
required:true
},
conferma_password_registrazione : {
minlength : 8,
//maxlength : 12,
equalTo : "#password_registrazione"
},
privacy_policy_check: {
required:true
}
},
messages: {
email_registrazione: {
remote: "Indirizzo email già in uso",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
},
password_registrazione: {
regex: "Inserisci una password di almeno 8 caratteri contenente almeno un numero e almeno una maiuscola",
required: "Inserisci una password di almeno 8 caratteri contenente almeno un numero e almeno una maiuscola",
minlength: "Inserisci una password di almeno 8 caratteri contenente almeno un numero e almeno una maiuscola",
maxlength: "Inserisci una password di almeno 8 caratteri contenente almeno un numero e almeno una maiuscola"
},
conferma_password_registrazione: {
equalTo: "le password non coincidono",
minlength: "le password non coincidono",
maxlength: "le password non coincidono"
},
privacy_policy_check: {
required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati."
},
}
});
}
if($('#richiesta_pec').length>0) {
$('#richiesta_pec').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
codice: {
required:true
}
},
messages: {
codice: {
required: "Inserisci il codice"
}
}
});
}
/****registrazione****/
if($('#registrazione_container').length>0) {
$('.recupera_link').bind('click',function(e) {
e.preventDefault();
$('#password_container').fadeIn();
});
$('.recupera_chiudi_btn').bind('click',function(e) {
e.preventDefault();
$('#password_container').fadeOut();
});
$('#reg').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
reg_email: {
remote: {
url: $('#base_url').val()+"ajax/check_email",
type: "post",
data: {
email: function() {
return $('#reg').find( "#reg_email" ).val();
},
id:function() {
return 0;
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
email:true,
required:true
},
privacy_policy_check: {
required:true
}
},
messages: {
reg_email: {
remote: "Indirizzo email già in uso",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
},
privacy_policy_check: {
required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati."
}
}
});
}
if($('#le_mie_foto').length>0) {
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
$( "#data_foto_inizio").datepicker({
altField: "#data_inizio",
altFormat: "yy-mm-dd",
maxDate: new Date(),
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 200);
}, 0);
},
onClose: function () {
if($( "#data_foto_inizio").val()==""){
$("#data_foto_inizio").datepicker('setDate', null);
}
}
});
$( "#data_foto_fine").datepicker({
altField: "#data_fine",
altFormat: "yy-mm-dd",
maxDate: new Date(),
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 200);
}, 0);
},
onClose: function () {
if($( "#data_foto_fine").val()==""){
$("#data_foto_fine").datepicker('setDate', null);
}
}
});
$('.fa-calendar_inizio').bind('click',function(e) {
e.preventDefault();
$('#data_foto_inizio').trigger('focus');
});
$('.fa-calendar_fine').bind('click',function(e) {
e.preventDefault();
$('#data_foto_fine').trigger('focus');
});
$('.reload_page').bind('click',function(e) {
e.preventDefault();
var ordinamento=$(this).data("order");
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/set_foto_order",
type: 'POST',
data: 'ordinamento=' + ordinamento+'&csfrtok='+csfrtok,
success: function (data) {
document.location.reload();
}
});
});
$('#ricerca_submit').bind('click',function(e) {
e.preventDefault();
var foto_kind_flag=$("#ricerca_tipo_foto").is(":checked");
var ricerca_tipo_foto=0;
if(foto_kind_flag==true){
ricerca_tipo_foto=1;
}
var audio_kind_flag=$("#ricerca_tipo_audio").is(":checked");
var ricerca_tipo_audio=0;
if(audio_kind_flag==true){
ricerca_tipo_audio=1;
}
var video_kind_flag=$("#ricerca_tipo_video").is(":checked");
var ricerca_tipo_video=0;
if(video_kind_flag==true){
ricerca_tipo_video=1;
}
if($('#ricerca_identificativo').val()!="" || $('#ricerca_annotazione').val()!="" || $('#data_inizio').val()!="" || $('#data_fine').val()!="" || ricerca_tipo_foto!=0 || ricerca_tipo_audio!=0 || ricerca_tipo_video!=0 ){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/cerca_foto",
type: 'POST',
data: 'ricerca_identificativo=' + $('#ricerca_identificativo').val()+'&ricerca_data_inizio='+$('#data_inizio').val()+'&ricerca_data_fine='+$('#data_fine').val()+'&ricerca_annotazione='+$('#ricerca_annotazione').val()+'&ricerca_tipo_foto='+ricerca_tipo_foto+'&ricerca_tipo_audio='+ricerca_tipo_audio+'&ricerca_tipo_video='+ricerca_tipo_video+'&csfrtok='+csfrtok,
success: function (data) {
document.location.reload();
}
});
} else {
alert("Attenzione.\nInserire almeno un parametro per effettuare la ricerca");
}
});
$('#reset_form').bind('click',function(e) {
e.preventDefault();
$('#ricerca_identificativo').val('');
$('#ricerca_annotazione').val('');
$('#data_inizio').val('');
$('#data_fine').val('');
$('#ricerca_tipo_foto').prop('checked', false); // Unchecks it
$('#ricerca_tipo_audio').prop('checked', false); // Unchecks it
$('#ricerca_tipo_video').prop('checked', false); // Unchecks it
var csfrtok=$('#csfrtok').val();
var ricerca_tipo_foto="";
var ricerca_tipo_audio="";
var ricerca_tipo_video="";
$.ajax({
url: $('#base_url').val() + "ajax/cerca_foto",
type: 'POST',
data: 'ricerca_identificativo=' + $('#ricerca_identificativo').val()+'&ricerca_data_inizio='+$('#data_inizio').val()+'&ricerca_data_fine='+$('#data_fine').val()+'&ricerca_annotazione='+$('#ricerca_annotazione').val()+'&ricerca_tipo_foto='+ricerca_tipo_foto+'&ricerca_tipo_audio='+ricerca_tipo_audio+'&ricerca_tipo_video='+ricerca_tipo_video+'&csfrtok='+csfrtok,
success: function (data) {
document.location.reload();
}
});
});
}
if($('#foto').length>0) {
$('#open_anteprima_foto').bind('click',function(e) {
e.preventDefault();
$('body').prepend('');
$('#anteprima_foto').fadeIn();
});
$('#close_anteprima_foto').bind('click',function(e) {
e.preventDefault();
$('#sfondo').remove();
$('#anteprima_foto').fadeOut();
});
$('#js_pec_prob_btn').bind('click',function(e) {
e.preventDefault();
var idf=$(this).data('idf');
$.ajax({
url: $('#base_url').val() + "ajax/send_pec_request",
type: 'POST',
data: 'csfrtok='+csfrtok+'&idf='+idf,
success: function (data) {
if(data=="1"){
alert("richiesta inviata");
document.location.href="";
}
}
});
});
}
if($('#cambia_email').length>0) {
$('#cambia_email').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
email: {
remote: {
url: $('#base_url').val()+"ajax/check_email",
type: "post",
data: {
email: function() {
return $( "#email" ).val();
},
id: function() {
return $( "#utente_id" ).val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
email:true,
required:true
}
},
messages: {
email: {
remote: "Indirizzo email già in uso",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
}
}
});
}
if($('#cambia_password').length>0) {
function hasNumber(myString) {
return /\d/.test(myString);
}
$('#password').on('input',function(e){
var actual_pass=$('#password').val();
var upperCase= new RegExp('[A-Z]');
var lowerCase= new RegExp('[a-z]');
if(actual_pass.match(upperCase)){
$('#js_pwd_val_upper').css('color', 'green');
} else {
$('#js_pwd_val_upper').css('color', '#ccc');
}
if(actual_pass.match(lowerCase)){
$('#js_pwd_val_lower').css('color', 'green');
} else {
$('#js_pwd_val_lower').css('color', '#ccc');
}
if(hasNumber(actual_pass)){
$('#js_pwd_val_num').css('color', 'green');
} else {
$('#js_pwd_val_num').css('color', '#ccc');
}
if(actual_pass.length>=8){
$('#js_pwd_val_otchr').css('color', 'green');
} else {
$('#js_pwd_val_otchr').css('color', '#ccc');
}
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#cambia_password').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
password_corrente: {
remote: {
url: $('#base_url').val()+"ajax/check_old_password",
type: "post",
data: {
password_corrente: function() {
return $( "#password_corrente" ).val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
//regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/,
//minlength : 8,
//maxlength : 12,
required:true
},
password : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[^\s]{8,}$/,
minlength : 8,
//maxlength : 12,
required:true
},
conferma_password : {
minlength : 8,
//maxlength : 12,
equalTo : "#password",
required:true
}
},
messages: {
password_corrente: {
remote: "Password errata",
//regex: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
required: "Inserisci la tua password attuale",
//minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
//maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
},
password: {
remote: "Password errata",
regex: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
},
conferma_password: {
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
}
}
});
}
if($('#recupera_password_page').length>0) {
function hasNumber(myString) {
return /\d/.test(myString);
}
$('#password').on('input',function(e){
var actual_pass=$('#password').val();
var upperCase= new RegExp('[A-Z]');
var lowerCase= new RegExp('[a-z]');
if(actual_pass.match(upperCase)){
$('#js_pwd_val_upper').css('color', 'green');
} else {
$('#js_pwd_val_upper').css('color', '#ccc');
}
if(actual_pass.match(lowerCase)){
$('#js_pwd_val_lower').css('color', 'green');
} else {
$('#js_pwd_val_lower').css('color', '#ccc');
}
if(hasNumber(actual_pass)){
$('#js_pwd_val_num').css('color', 'green');
} else {
$('#js_pwd_val_num').css('color', '#ccc');
}
if(actual_pass.length>=8){
$('#js_pwd_val_otchr').css('color', 'green');
} else {
$('#js_pwd_val_otchr').css('color', '#ccc');
}
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#recupera_password').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
password : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[^\s]{8,}$/,
minlength : 8,
//maxlength : 12,
required:true
},
conferma_password : {
minlength : 8,
//maxlength : 12,
equalTo : "#password",
required:true
}
},
messages: {
password: {
regex: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
// maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
},
conferma_password: {
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
//maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
}
}
});
}
if($('#nuova_password_page').length>0) {
function hasNumber(myString) {
return /\d/.test(myString);
}
$('#password').on('input',function(e){
var actual_pass=$('#password').val();
var upperCase= new RegExp('[A-Z]');
var lowerCase= new RegExp('[a-z]');
if(actual_pass.match(upperCase)){
$('#js_pwd_val_upper').css('color', 'green');
} else {
$('#js_pwd_val_upper').css('color', '#ccc');
}
if(actual_pass.match(lowerCase)){
$('#js_pwd_val_lower').css('color', 'green');
} else {
$('#js_pwd_val_lower').css('color', '#ccc');
}
if(hasNumber(actual_pass)){
$('#js_pwd_val_num').css('color', 'green');
} else {
$('#js_pwd_val_num').css('color', '#ccc');
}
if(actual_pass.length>=8){
$('#js_pwd_val_otchr').css('color', 'green');
} else {
$('#js_pwd_val_otchr').css('color', '#ccc');
}
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#nuova_password').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
password : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[^\s]{8,}$/,
minlength : 8,
//maxlength : 12,
required:true
},
conferma_password : {
minlength : 8,
//maxlength : 12,
equalTo : "#password",
required:true
}
},
messages: {
password: {
regex: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
//maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
},
conferma_password: {
required: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola",
//maxlength: "Inserisci una password senza spazi di minimo 8 caratteri contenente almeno un numero, una minuscola e una maiuscola"
}
}
});
}
/******GDPR*******/
if($('#manage_privacy').length>0) {
$('#edit_policy').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
privacy_policy_check: {
required:true
}
},
messages: {
privacy_policy_check: {
required: "Attenzione, per poterti registrare devi aver letto l\'informativa privacy e acconsentire al trattamento dei tuoi dati."
}
}
});
$('#x_btn_marketing').bind('click',function(e) {
e.preventDefault();
$("#container_marketing_checkbox").show();
$("#container_label_marketing").hide();
$('#marketing_check').attr('checked', false);
});
$('#x_btn_newsletter').bind('click',function(e) {
e.preventDefault();
$("#container_newsletter_checkbox").show();
$("#container_label_newsletter").hide();
$('#newsletter_check').attr('checked', false);
});
}
/****HEADER***/
if($('#assistenza_container').length>0) {
$('#assistenzafrm').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
nome: {
required:true
},
cognome: {
required:true
},
messaggio: {
required:true,
maxlength: 500
},
email: {
required:true,
email:true
},
},
messages: {
nome: {
required: "Inserisci il tuo nome",
},
cognome: {
required: "Inserisci il tuo cognome",
},
messaggio: {
required: "Inserisci un messaggio",
maxlength: "Inserisci un messaggio di max 500 caratteri"
},
email: {
required: "Inserisci un indirizzo email valido",
email: "Inserisci un indirizzo email valido",
},
}
});
$("#assistenzafrm").submit(function(){
$('body').prepend('');
$('#modal_loading').fadeIn();
});
if($('#js_form_result_message').length>0) {
$("#js_form_result_message").delay(1000).fadeOut(800);
}
}
if($('#mod_dati_container').length>0) {
$.validator.addMethod("nameRegex", function(value, element) {
return this.optional(element) || /^[a-z0-9\-\s]+$/i.test(value);
}, "Username must contain only letters, numbers, or dashes.");
$('#modifica_dati').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
nome: {
nameRegex: true,
required:true
},
cognome: {
nameRegex: true,
required:true
},
telefono: {
digits: true
},
/*pseudonimo: {
remote: {
url: $('#base_url').val()+"ajax/check_pseudonimo",
type: "post",
data: {
pseudonimo: function() {
return $( "#pseudonimo" ).val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
required:true,
minlength: 3,
maxlength: 15,
alphanumeric: true
},*/
cf: {
required:true,
minlength: 16,
maxlength: 16
},
cf_azienda: {
required:true,
minlength: 11,
maxlength: 16
},
piva: {
/*remote: {
url: $('#base_url').val()+"ajax/check_partita_iva",
type: "post",
data: {
piva: function() {
return $('#js_piva').val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},*/
required:true
},
indirizzo: {
required:true
},
ragione_sociale: {
required:true
},
codice_univoco: {
required: false,
minlength:7,
maxlength:7
},
/*id_regione: {
required:true,
min:1
},*/
id_provincia: {
required:true,
min:1
},
id_comune: {
required:true,
min:1
},
cap: {
required:true,
digits:true,
minlength:5,
maxlength:5
},
},
messages: {
nome: {
required: "Inserisci il tuo nome",
nameRegex: "non si possono utilizzare caratteri speciali"
},
cognome: {
required: "Inserisci il tuo cognome",
nameRegex: "non si possono utilizzare caratteri speciali"
},
telefono: {
digits: "Inserisci solo numeri"
},
/*pseudonimo: {
required: "Inserisci una denominazione",
remote: "Questa denominazione risulta essere già utilizzata, scegline un altro",
minlength: "La denominazione deve essere compresa tra 3 e 15 caratteri",
maxlength: "La denominazione deve essere compresa tra 3 e 15 caratteri",
alphanumeric: "non si possono utilizzare caratteri speciali"
},*/
cf: {
required: "Inserisci il tuo codice fiscale",
minlength: "il codice fiscale deve essere composto da 16 caratteri",
maxlength: "il codice fiscale deve essere composto da 16 caratteri"
},
cf_azienda: {
required: "Inserisci il codice fiscale della tua azienda",
minlength: "Il codice fiscale deve essere compreso tra 11 e 16 caratteri",
maxlength: "Il codice fiscale deve essere compreso tra 11 e 16 caratteri"
},
piva: {
//remote: "Inserisci una partita IVA valida",
required: "Inserisci la partita IVA o il codice fiscale (in caso di ditta individuale)"
},
indirizzo: {
required: "Inserisci l\'indirizzo"
},
ragione_sociale: {
required: "Inserisci la ragione sociale"
},
codice_univoco: {
minlength: "Inserisci il codice univoco",
maxlength: "Inserisci il codice univoco"
},
/*id_regione: {
required: "Inserisci una regione",
min: "Inserisci una regione"
},*/
id_provincia: {
required: "Inserisci una provincia",
min: "Inserisci una provincia"
},
id_comune: {
required: "Inserisci un comune",
min: "Inserisci un comune"
},
cap: {
required: "Inserisci il cap",
digits: "Inserisci il cap",
minlength: "Inserisci il cap",
maxlength: "Inserisci il cap"
},
}
});
$('input[type=radio][name=tipo]').change(function() {
var type=this.value;
switchType(type);
});
$('#js_fattura').click(function() {
var checked=$('#js_fattura').is(':checked');
var type=1;
if(checked==true){
type=2;
}
switchType(type);
});
function switchType(type) {
if(type==1) {
$('#dati_giuridica').find('input').attr('disabled','disabled');
$('#dati_giuridica').find('textarea').attr('disabled','disabled');
$('#id_regione').attr('disabled','disabled');
$('#id_provincia').attr('disabled','disabled');
$('#id_comune').attr('disabled','disabled');
$('#cap').find('input').attr('disabled','disabled');
$('#dati_giuridica').hide();
} else {
$('#dati_giuridica').find('input').removeAttr('disabled');
$('#dati_giuridica').find('textarea').removeAttr('disabled');
$('#id_regione').removeAttr('disabled');
$('#id_provincia').removeAttr('disabled');
$('#id_comune').removeAttr('disabled');
$('#cap').find('input').removeAttr('disabled');
$('#dati_giuridica').show();
}
}
/*$('#id_regione').on('change', function() {
var id_regione_selected=this.value;
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_regioni_provincia",
type: 'POST',
data: 'id_regione=' + id_regione_selected+'&csfrtok='+csfrtok,
success: function (data) {
var html_result="";
const myArr = JSON.parse(data);
$.each(myArr, function(index, value) {
var id_element=index;
var name=value.nome;
var option_element="";
html_result=html_result+option_element;
});
$("#id_provincia").html(html_result);
$("#id_comune").html("");
}
});
});*/
$('#id_provincia').on('change', function() {
var id_provincia_selected=this.value;
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_comuni_provincia",
type: 'POST',
data: 'id_provincia=' + id_provincia_selected+'&csfrtok='+csfrtok,
success: function (data) {
var html_result="";
const myArr = JSON.parse(data);
$.each(myArr, function(index, value) {
var id_element=index;
var name=value.nome;
var option_element="";
html_result=html_result+option_element;
});
$("#id_comune").html(html_result);
}
});
});
}
if($('#acquisto_pacchetti_container').length>0) {
$('#js_aumenta_codici_1').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(1);
});
$('#js_diminuisci_codici_1').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(1);
});
$('#js_aumenta_codici_2').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(2);
});
$('#js_diminuisci_codici_2').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(2);
});
$('#js_aumenta_codici_3').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(3);
});
$('#js_diminuisci_codici_3').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(3);
});
$('#js_aumenta_codici_4').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(4);
});
$('#js_diminuisci_codici_4').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(4);
});
$('#js_aumenta_codici_5').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(5);
});
$('#js_diminuisci_codici_5').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(5);
});
$('#js_aumenta_codici_6').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(6);
});
$('#js_diminuisci_codici_6').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(6);
});
$('#js_aumenta_pacchetti_1').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(1);
change_select_values(1);
});
$('#js_diminuisci_pacchetti_1').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(1);
change_select_values(1);
});
$('#js_aumenta_pacchetti_2').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(2);
change_select_values(2);
});
$('#js_diminuisci_pacchetti_2').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(2);
change_select_values(2);
});
$('#js_aumenta_pacchetti_3').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(3);
change_select_values(3);
});
$('#js_diminuisci_pacchetti_3').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(3);
change_select_values(3);
});
$('#js_aumenta_pacchetti_4').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(4);
change_select_values(4);
});
$('#js_diminuisci_pacchetti_4').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(4);
change_select_values(4);
});
$('#js_aumenta_pacchetti_5').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(5);
change_select_values(5);
});
$('#js_diminuisci_pacchetti_5').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(5);
change_select_values(5);
});
$('#js_aumenta_pacchetti_6').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(6);
change_select_values(6);
});
$('#js_diminuisci_pacchetti_6').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(6);
change_select_values(6);
});
$(".js_email_da_verificare").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
AlertEmailDaVerificare()
});
});
$('#js_submit_acquista_1').bind('click',function(e) {
e.preventDefault();
submit_acquista(1);
});
$('#js_submit_acquista_2').bind('click',function(e) {
e.preventDefault();
submit_acquista(2);
});
$('#js_submit_acquista_3').bind('click',function(e) {
e.preventDefault();
submit_acquista(3);
});
$('#js_submit_acquista_4').bind('click',function(e) {
e.preventDefault();
submit_acquista(4);
});
$('#js_submit_acquista_5').bind('click',function(e) {
e.preventDefault();
submit_acquista(5);
});
$('#js_submit_acquista_6').bind('click',function(e) {
e.preventDefault();
submit_acquista(6);
});
/*$('#pacchetto_1_codici_number').bind('click',function(e) {
e.preventDefault();
checkLimiteCodice(1);
});
$('#pacchetto_1_codici_number').bind('change',function(e) {
e.preventDefault();
checkLimiteCodice(1);
});
$('#pacchetto_2_codici_number').bind('click',function(e) {
e.preventDefault();
checkLimiteCodice(2);
});
$('#pacchetto_2_codici_number').bind('change',function(e) {
e.preventDefault();
checkLimiteCodice(2);
});
$('#pacchetto_3_codici_number').bind('click',function(e) {
e.preventDefault();
checkLimiteCodice(3);
});
$('#pacchetto_3_codici_number').bind('change',function(e) {
e.preventDefault();
checkLimiteCodice(3);
});
$('#pacchetto_4_codici_number').bind('click',function(e) {
e.preventDefault();
checkLimiteCodice(4);
});
$('#pacchetto_4_codici_number').bind('change',function(e) {
e.preventDefault();
checkLimiteCodice(4);
});*/
function change_select_values(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=parseInt($(pacchetto_id).val());
if(isNaN(quantita)){
quantita=0;
}
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var numero_codici=parseInt($(numero_codici_id).val());
if(isNaN(numero_codici)){
numero_codici=0;
}
var get_foto_in_pacchetto_per_id_1=$("#js_get_foto_in_pacchetto_per_id_1").val();
var get_foto_in_pacchetto_per_id_2=$("#js_get_foto_in_pacchetto_per_id_2").val();
var get_foto_in_pacchetto_per_id_3=$("#js_get_foto_in_pacchetto_per_id_3").val();
var get_foto_in_pacchetto_per_id_4=$("#js_get_foto_in_pacchetto_per_id_4").val();
var get_foto_in_pacchetto_per_id_5=$("#js_get_foto_in_pacchetto_per_id_5").val();
var get_foto_in_pacchetto_per_id_6=$("#js_get_foto_in_pacchetto_per_id_6").val();
var foto_acquistate=0;
if(pacchetto==1){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_1;
}
if(pacchetto==2){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_2;
}
if(pacchetto==3){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_3;
}
if(pacchetto==4){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_4;
}
if(pacchetto==5){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_5;
}
if(pacchetto==6){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_6;
}
var array_multipli=[];
for(var i=1;i<=foto_acquistate;i++){
var remainder = foto_acquistate % i;
if (remainder == 0){ //è un multiplo preciso
array_multipli.push(i);
}
}
var selectCodici = $(numero_codici_id);
selectCodici.find('option').remove();
$(array_multipli).each(function () {
var option = $("");
//Set Customer Name in Text part.
option.html(this);
//Set Customer CustomerId in Value part.
option.val(this);
//Add the Option element to DropDownList.
selectCodici.append(option);
});
}
function checkLimiteCodice(pacchetto){
var superato_limite=checkMaxNumberReturn(pacchetto);
var limite=checkMaxNumberCodici(pacchetto);
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
if(superato_limite==1){ //superato
$(numero_codici_id).val(limite);
}
}
function Aumenta_quantita_pacchetti(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=parseInt($(pacchetto_id).val());
if(isNaN(quantita)){
quantita=0;
}
var nuova_quantita=parseInt(quantita)+parseInt(1);
$(pacchetto_id).val(nuova_quantita);
//aggiorna prezzi
AggiornaLabelPrezziPacchetto(pacchetto);
}
function Diminuisci_quantita_pacchetti(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=parseInt($(pacchetto_id).val());
if(isNaN(quantita)){
quantita=0;
}
var nuova_quantita=quantita-1;
if(nuova_quantita>0){
$(pacchetto_id).val(nuova_quantita);
var limite_codici_pacchetto=checkMaxNumberCodici(pacchetto);
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var quantita_codici_attuali=parseInt($(numero_codici_id).val());
if(quantita_codici_attuali>limite_codici_pacchetto){
$(numero_codici_id).val(limite_codici_pacchetto);
}
}
//aggiorna prezzi
AggiornaLabelPrezziPacchetto(pacchetto);
}
function Aumenta_quantita_codici(pacchetto){
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var quantita=parseInt($(numero_codici_id).val());
if(isNaN(quantita)){
quantita=0;
}
var nuova_quantita=parseInt(quantita)+parseInt(1);
$(numero_codici_id).val(nuova_quantita);
var superato_limite=checkMaxNumberReturn(pacchetto);
if(superato_limite==1){ //superato
$(numero_codici_id).val(quantita);
}
}
function Diminuisci_quantita_codici(pacchetto){
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var quantita=parseInt($(numero_codici_id).val());
if(isNaN(quantita)){
quantita=0;
}
var nuova_quantita=quantita-1;
if(nuova_quantita>0){
$(numero_codici_id).val(nuova_quantita);
}
}
function checkMaxNumberCodici(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=$(pacchetto_id).val();
var get_foto_in_pacchetto_per_id_1=$("#js_get_foto_in_pacchetto_per_id_1").val();
var get_foto_in_pacchetto_per_id_2=$("#js_get_foto_in_pacchetto_per_id_2").val();
var get_foto_in_pacchetto_per_id_3=$("#js_get_foto_in_pacchetto_per_id_3").val();
var get_foto_in_pacchetto_per_id_4=$("#js_get_foto_in_pacchetto_per_id_4").val();
var get_foto_in_pacchetto_per_id_5=$("#js_get_foto_in_pacchetto_per_id_5").val();
var get_foto_in_pacchetto_per_id_6=$("#js_get_foto_in_pacchetto_per_id_6").val();
if(pacchetto==1){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_1;
}
if(pacchetto==2){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_2;
}
if(pacchetto==3){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_3;
}
if(pacchetto==4){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_4;
}
if(pacchetto==5){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_5;
}
if(pacchetto==6){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_6;
}
return quantita;
}
function checkMaxNumberReturn(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=$(pacchetto_id).val();
var get_foto_in_pacchetto_per_id_1=$("#js_get_foto_in_pacchetto_per_id_1").val();
var get_foto_in_pacchetto_per_id_2=$("#js_get_foto_in_pacchetto_per_id_2").val();
var get_foto_in_pacchetto_per_id_3=$("#js_get_foto_in_pacchetto_per_id_3").val();
var get_foto_in_pacchetto_per_id_4=$("#js_get_foto_in_pacchetto_per_id_4").val();
var get_foto_in_pacchetto_per_id_5=$("#js_get_foto_in_pacchetto_per_id_5").val();
var get_foto_in_pacchetto_per_id_6=$("#js_get_foto_in_pacchetto_per_id_6").val();
if(pacchetto==1){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_1;
}
if(pacchetto==2){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_2;
}
if(pacchetto==3){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_3;
}
if(pacchetto==4){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_4;
}
if(pacchetto==5){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_5;
}
if(pacchetto==6){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_6;
}
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var valore_inserito=$(numero_codici_id).val();
//console.log("check max "+quantita+" valore inserito "+valore_inserito);
if(valore_inserito>quantita){
return 1; //superato limite
} else {
return 0; //non ancora superato limite
}
}
function AggiornaLabelPrezziPacchetto(pacchetto){
//quantità pacchetti acquistati
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita_pacchetti=parseInt($(pacchetto_id).val());
if(isNaN(quantita_pacchetti)){
quantita_pacchetti=0;
}
//quantità codici da creare
var prezzo_senza_iva=0;
var prezzo_con_iva=0;
var num_foto=0;
var get_foto_in_pacchetto_per_id_1=$("#js_get_foto_in_pacchetto_per_id_1").val();
var get_foto_in_pacchetto_per_id_2=$("#js_get_foto_in_pacchetto_per_id_2").val();
var get_foto_in_pacchetto_per_id_3=$("#js_get_foto_in_pacchetto_per_id_3").val();
var get_foto_in_pacchetto_per_id_4=$("#js_get_foto_in_pacchetto_per_id_4").val();
var get_foto_in_pacchetto_per_id_5=$("#js_get_foto_in_pacchetto_per_id_5").val();
var get_foto_in_pacchetto_per_id_6=$("#js_get_foto_in_pacchetto_per_id_6").val();
var get_pacchetto_prezzo_netto_per_id_1=$("#js_pacchetto_prezzo_netto_per_id_1").val();
var get_pacchetto_prezzo_netto_per_id_2=$("#js_pacchetto_prezzo_netto_per_id_2").val();
var get_pacchetto_prezzo_netto_per_id_3=$("#js_pacchetto_prezzo_netto_per_id_3").val();
var get_pacchetto_prezzo_netto_per_id_4=$("#js_pacchetto_prezzo_netto_per_id_4").val();
var get_pacchetto_prezzo_netto_per_id_5=$("#js_pacchetto_prezzo_netto_per_id_5").val();
var get_pacchetto_prezzo_netto_per_id_6=$("#js_pacchetto_prezzo_netto_per_id_6").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_netto_per_id_1=get_pacchetto_prezzo_netto_per_id_1.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_2=get_pacchetto_prezzo_netto_per_id_2.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_3=get_pacchetto_prezzo_netto_per_id_3.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_4=get_pacchetto_prezzo_netto_per_id_4.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_5=get_pacchetto_prezzo_netto_per_id_5.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_6=get_pacchetto_prezzo_netto_per_id_6.replace(",", ".");
var get_pacchetto_prezzo_per_id_1=$("#js_pacchetto_prezzo_per_id_1").val();
var get_pacchetto_prezzo_per_id_2=$("#js_pacchetto_prezzo_per_id_2").val();
var get_pacchetto_prezzo_per_id_3=$("#js_pacchetto_prezzo_per_id_3").val();
var get_pacchetto_prezzo_per_id_4=$("#js_pacchetto_prezzo_per_id_4").val();
var get_pacchetto_prezzo_per_id_5=$("#js_pacchetto_prezzo_per_id_5").val();
var get_pacchetto_prezzo_per_id_6=$("#js_pacchetto_prezzo_per_id_6").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_per_id_1=get_pacchetto_prezzo_per_id_1.replace(",", ".");
var get_pacchetto_prezzo_per_id_2=get_pacchetto_prezzo_per_id_2.replace(",", ".");
var get_pacchetto_prezzo_per_id_3=get_pacchetto_prezzo_per_id_3.replace(",", ".");
var get_pacchetto_prezzo_per_id_4=get_pacchetto_prezzo_per_id_4.replace(",", ".");
var get_pacchetto_prezzo_per_id_5=get_pacchetto_prezzo_per_id_5.replace(",", ".");
var get_pacchetto_prezzo_per_id_6=get_pacchetto_prezzo_per_id_6.replace(",", ".");
if(pacchetto==1){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_1;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_1;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_1;
}
if(pacchetto==2){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_2;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_2;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_2;
}
if(pacchetto==3){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_3;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_3;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_3;
}
if(pacchetto==4){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_4;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_4;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_4;
}
if(pacchetto==5){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_5;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_5;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_5;
}
if(pacchetto==6){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_6;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_6;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_6;
}
var test="prezzo con iva "+prezzo_con_iva+" prezzo senza iva "+prezzo_senza_iva+" numero foto "+num_foto;
var prezzo_iva_per_quantita=parseFloat(prezzo_con_iva*quantita_pacchetti).toFixed(2);
var prezzo_netto_per_quantita=parseFloat(prezzo_senza_iva*quantita_pacchetti).toFixed(2);
//rimetto le virgole
prezzo_netto_per_quantita=prezzo_netto_per_quantita.replace(".", ",");
prezzo_iva_per_quantita=prezzo_iva_per_quantita.replace(".", ",");
var prezzo_netto_label_id="#prezzo_"+pacchetto+"_netto";
$(prezzo_netto_label_id).html(prezzo_netto_per_quantita);
var prezzo_ivato_label_id="#prezzo_"+pacchetto+"_ivato";
$(prezzo_ivato_label_id).html(prezzo_iva_per_quantita);
var numero_foto_id="#numero_"+pacchetto+"_foto";
$(numero_foto_id).html(num_foto);
}
function submit_acquista(pacchetto){
var email_verificata=$("#email_verificata").val();
var profilo_completo=$("#profilo_completo").val();
$("#pacchetto").val(pacchetto);
//quantita pacchetti
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var q=parseInt($(pacchetto_id).val());
if(isNaN(q)){
q=0;
}
//quantita codici
var numero_codici_id="#pacchetto_"+pacchetto+"_codici_number";
var cq=parseInt($(numero_codici_id).val());
if(isNaN(cq)){
cq=0;
}
//check se numero codici e numero foto divisibili
var get_foto_in_pacchetto_per_id_1=$("#js_get_foto_in_pacchetto_per_id_1").val();
var get_foto_in_pacchetto_per_id_2=$("#js_get_foto_in_pacchetto_per_id_2").val();
var get_foto_in_pacchetto_per_id_3=$("#js_get_foto_in_pacchetto_per_id_3").val();
var get_foto_in_pacchetto_per_id_4=$("#js_get_foto_in_pacchetto_per_id_4").val();
var get_foto_in_pacchetto_per_id_5=$("#js_get_foto_in_pacchetto_per_id_5").val();
var get_foto_in_pacchetto_per_id_6=$("#js_get_foto_in_pacchetto_per_id_6").val();
var foto_acquistate=0;
if(pacchetto==1){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_1;
}
if(pacchetto==2){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_2;
}
if(pacchetto==3){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_3;
}
if(pacchetto==4){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_4;
}
if(pacchetto==5){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_5;
}
if(pacchetto==6){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_6;
}
var remainder = foto_acquistate % cq; //0== è un multiplo preciso
if(pacchetto>0 && pacchetto<7 && pacchetto!="" && q>0 && cq>0 && remainder == 0){
/*if(email_verificata==1 && profilo_completo==1){
document.location.href=$('#base_url').val() +"profilo_api/pacchetto_payment/"+pacchetto+"/"+q+"/"+cq;
} else {
document.location.href=$('#base_url').val() +"profilo_api/dati_acquisto/"+pacchetto+"/"+q+"/"+cq;
}*/
document.location.href=$('#base_url').val() +"profilo_api/dati_acquisto/"+pacchetto+"/"+q+"/"+cq;
}
}
function AlertEmailDaVerificare(){
alert("Per poter proseguire con l\'acquisto devi prima verificare il tuo indirizzo email.");
}
}
if($('#dati_acquisto_container').length>0) {
$.validator.addMethod("nameRegex", function(value, element) {
return this.optional(element) || /^[a-z0-9\-\s]+$/i.test(value);
}, "Username must contain only letters, numbers, or dashes.");
$('#dati_acquisto').validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name')+'-error');
},
rules: {
nome: {
nameRegex: true,
required:true
},
cognome: {
nameRegex: true,
required:true
},
telefono: {
digits: true
},
/*pseudonimo: {
remote: {
url: $('#base_url').val()+"ajax/check_pseudonimo",
type: "post",
data: {
pseudonimo: function() {
return $( "#pseudonimo" ).val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
required:true,
minlength: 3,
maxlength: 15,
alphanumeric: true
},*/
cf: {
required:true,
minlength: 16,
maxlength: 16
},
cf_azienda: {
required:true,
minlength: 11,
maxlength: 16
},
piva: {
/*remote: {
url: $('#base_url').val()+"ajax/check_partita_iva",
type: "post",
data: {
piva: function() {
return $('#js_piva').val();
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},*/
required:true
},
indirizzo: {
required:true
},
ragione_sociale: {
required:true
},
codice_univoco: {
required: false,
minlength:7,
maxlength:7
},
/*id_regione: {
required:true,
min:1
},*/
id_provincia: {
required:true,
min:1
},
id_comune: {
required:true,
min:1
},
cap: {
required:true,
digits:true,
minlength:5,
maxlength:5
},
},
messages: {
nome: {
required: "Inserisci il tuo nome",
nameRegex: "non si possono utilizzare caratteri speciali"
},
cognome: {
required: "Inserisci il tuo cognome",
nameRegex: "non si possono utilizzare caratteri speciali"
},
telefono: {
digits: "Inserisci solo numeri"
},
/*pseudonimo: {
required: "Inserisci una denominazione",
remote: "Questa denominazione risulta essere già utilizzata, scegline un altro",
minlength: "La denominazione deve essere compresa tra 3 e 15 caratteri",
maxlength: "La denominazione deve essere compresa tra 3 e 15 caratteri",
alphanumeric: "non si possono utilizzare caratteri speciali"
},*/
cf: {
required: "Inserisci il tuo codice fiscale",
minlength: "il codice fiscale deve essere composto da 16 caratteri",
maxlength: "il codice fiscale deve essere composto da 16 caratteri"
},
cf_azienda: {
required: "Inserisci il codice fiscale della tua azienda",
minlength: "Il codice fiscale deve essere compreso tra 11 e 16 caratteri",
maxlength: "Il codice fiscale deve essere compreso tra 11 e 16 caratteri"
},
piva: {
//remote: "Inserisci una partita IVA valida",
required: "Inserisci la partita IVA o il codice fiscale (in caso di ditta individuale)"
},
indirizzo: {
required: "Inserisci l\'indirizzo"
},
ragione_sociale: {
required: "Inserisci la ragione sociale"
},
codice_univoco: {
minlength: "Inserisci il codice univoco",
maxlength: "Inserisci il codice univoco"
},
/*id_regione: {
required: "Inserisci una regione",
min: "Inserisci una regione"
},*/
id_provincia: {
required: "Inserisci una provincia",
min: "Inserisci una provincia"
},
id_comune: {
required: "Inserisci un comune",
min: "Inserisci un comune"
},
cap: {
required: "Inserisci il cap",
digits: "Inserisci il cap",
minlength: "Inserisci il cap",
maxlength: "Inserisci il cap"
},
}
});
$('input[type=radio][name=tipo]').change(function() {
var type=this.value;
switchType(type);
});
$('#js_fattura').click(function() {
var checked=$('#js_fattura').is(':checked');
var type=1;
if(checked==true){
type=2;
}
switchType(type);
});
function switchType(type) {
if(type==1) {
$('#dati_giuridica').find('input').attr('disabled','disabled');
$('#dati_giuridica').find('textarea').attr('disabled','disabled');
$('#id_regione').attr('disabled','disabled');
$('#id_provincia').attr('disabled','disabled');
$('#id_comune').attr('disabled','disabled');
$('#cap').find('input').attr('disabled','disabled');
$('#dati_giuridica').hide();
} else {
$('#dati_giuridica').find('input').removeAttr('disabled');
$('#dati_giuridica').find('textarea').removeAttr('disabled');
$('#id_regione').removeAttr('disabled');
$('#id_provincia').removeAttr('disabled');
$('#id_comune').removeAttr('disabled');
$('#cap').find('input').removeAttr('disabled');
$('#dati_giuridica').show();
}
}
/*$('#id_regione').on('change', function() {
var id_regione_selected=this.value;
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_regioni_provincia",
type: 'POST',
data: 'id_regione=' + id_regione_selected+'&csfrtok='+csfrtok,
success: function (data) {
var html_result="";
const myArr = JSON.parse(data);
$.each(myArr, function(index, value) {
var id_element=index;
var name=value.nome;
var option_element="";
html_result=html_result+option_element;
});
$("#id_provincia").html(html_result);
$("#id_comune").html("");
}
});
});*/
$('#id_provincia').on('change', function() {
var id_provincia_selected=this.value;
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_comuni_provincia",
type: 'POST',
data: 'id_provincia=' + id_provincia_selected+'&csfrtok='+csfrtok,
success: function (data) {
var html_result="";
const myArr = JSON.parse(data);
$.each(myArr, function(index, value) {
var id_element=index;
var name=value.nome;
var option_element="";
html_result=html_result+option_element;
});
$("#id_comune").html(html_result);
}
});
});
$( "#js_modifica_dati_btn" ).on('click', function(d) {
d.preventDefault();
$( "#js_close_modifica_dati_btn" ).show();
$( "#js_modifica_dati_btn" ).hide();
$( "#js_container_riepilogo_dati" ).hide();
$( "#js_container_modifica_dati" ).show();
$( "#js_bottom_btn_container" ).hide();
});
$( "#js_close_modifica_dati_btn" ).on('click', function(d) {
d.preventDefault();
$( "#js_close_modifica_dati_btn" ).hide();
$( "#js_modifica_dati_btn" ).show();
$( "#js_container_riepilogo_dati" ).show();
$( "#js_container_modifica_dati" ).hide();
$( "#js_bottom_btn_container" ).show();
});
}
if($('#pacchetti_acquistati_container').length>0) {
$(".js_genera_fattura").each(function () {
var ricevuta_id=$(this).attr("data-ricevuta");
$( this ).on('click', function(d) {
d.preventDefault();
scaricaFattura(ricevuta_id);
});
});
function scaricaFattura(ricevuta_id) {
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val()+'ajax/genera_fattura/'+ricevuta_id,
type: 'POST',
data: 'csfrtok='+csfrtok,
success: function(data) {
document.location.href=$('#base_url').val()+"ajax/download_ricevuta/"+data;
}
});
}
}
if(genericForm == 1) {
$('form').each(function() {
$(this).validate({
ignore: [],
errorPlacement: function(error, element) {
error.appendTo('#' + element.attr('name').replace('[','').replace(']','')+'-error');
$('#' + element.attr('name').replace('[','').replace(']','')+'-error').fadeIn();
},
success: function(label,element) {
$(label).parent().html('');
},
/*onkeyup: false,
onfocusout: false*/
});
});
}
});
function setLang(lang,redirect) {
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/set_lang",
type: 'POST',
data: 'lang=' + lang+'&csfrtok='+csfrtok,
success: function (data) {
$('#lang').val(data);
if(redirect == 1) {
document.location.href=document.location.href;
}
}
});
}