//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").show();
}
}
});
$("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');
});
}
}
});
}
/***COMPRA CERTIFICAZIONI****/
if($('#js_buypack').length){
$('#js_eye_password').bind('click',function(e) {
e.preventDefault();
var input = $("#password");
if (input.attr("type") === "password") {
input.attr("type", "text");
$(".eye-icon").fadeTo(500, 1.0);
} else {
input.attr("type", "password");
$(".eye-icon").fadeTo(500, 0.5);
}
});
$('#js_aumenta_pacchetti').bind('click',function(e) {
e.preventDefault();
var pacchetto=$(this).data("pacchetto");
var q=$(this).data("q");
addremoveQuantity(pacchetto,q,1);
});
$('#js_diminuisci_pacchetti').bind('click',function(e) {
e.preventDefault();
var pacchetto=$(this).data("pacchetto");
var q=$(this).data("q");
addremoveQuantity(pacchetto,q,0);
});
function addremoveQuantity(pacchetto,q,aumenta){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/get_quantpack",
type: 'POST',
data: 'pacchetto=' + pacchetto+'&q=' + q+'&aumenta=' + aumenta+'&csfrtok='+csfrtok,
success: function (data) {
$("#js_pack_container").html(data);
$('#js_aumenta_pacchetti').bind('click',function(e) {
e.preventDefault();
var pacchetto=$(this).data("pacchetto");
var q=$(this).data("q");
addremoveQuantity(pacchetto,q,1);
});
$('#js_diminuisci_pacchetti').bind('click',function(e) {
e.preventDefault();
var pacchetto=$(this).data("pacchetto");
var q=$(this).data("q");
addremoveQuantity(pacchetto,q,0);
});
var actualq=$("#js_actual_q").val();
$("#js_actual_q_reg").val(actualq);
$("#js_actual_q_login").val(actualq);
}
});
}
$('.js_switch_view').bind('click',function(e) {
e.preventDefault();
$('#js_buypack_registration_container').toggle();
$('#js_buypack_login_container').toggle();
$('#js_open_registration').toggle();
$('#js_open_login').toggle();
});
$('#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_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();
}
}*/
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("nameRegex", function(value, element) {
return this.optional(element) || /^[a-z0-9\-\s]+$/i.test(value);
}, "Username must contain only letters, numbers, or dashes.");
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
$('#buypack_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 $('#buypack_form').find( "#email" ).val();
},
id:function() {
return 0;
},
csfrtok: function() {
return $( "#csfrtok" ).val();
}
}
},
email:true,
required:true,
},
password : {
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z-@!£$#%_*/()|?]{8,}$/,
minlength : 8,
required: true
},
conferma_password : {
minlength : 8,
equalTo : "#password"
},
privacy_policy_check: {
required:true
},
nome: {
nameRegex: true,
required:true
},
cognome: {
nameRegex: true,
required:false
},
telefono: {
digits: true
},
cf_azienda: {
required:true,
minlength: 11,
maxlength: 16
},
piva: {
required:true
},
indirizzo: {
required:true
},
ragione_sociale: {
required:true
},
codice_univoco: {
required: false,
minlength:7,
maxlength:7
},
id_provincia: {
required:true,
min:1
},
id_comune: {
required:true,
min:1
},
cap: {
required:true,
digits:true,
minlength:5,
maxlength:5
},
},
messages: {
email: {
remote: "Questa email è già presente nei nostri sistemi, sei hai già un account usa la sezione Accedi.",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
},
password: {
regex: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero 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."
},
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"
},
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_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"
},
}
});
////
}
/***COMPLETA REGISTRAZIONE****/
if($('#comp_reg_container').length){
function convertDateForIos(date) {
var arr = date.split(/[- :]/);
date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
return date;
}
function makeTimer() {
var converted=convertDateForIos($("#data_scadenza").val());
var endTime = new Date(converted);
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])[0-9a-zA-Z-@!£$#%_*/()|?]{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, sei hai già un account usa la sezione Accedi.",
email: "Inserisci un indirizzo email valido",
required: "Inserisci un indirizzo email valido"
},*/
password: {
regex: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero 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) {
$('#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();
});
$('#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])[0-9a-zA-Z]{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 compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e 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) {
//$('.lazy').Lazy();
$('.lazy').Lazy({
// your configuration goes here
scrollDirection: 'vertical',
effect: 'fadeIn',
visibleOnly: true,
});
$.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_email').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_email='+$('#ricerca_email').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_email').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_email='+$('#ricerca_email').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();
});
}
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]');
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."
);
$('#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])[0-9a-zA-Z-@!£$#%_*/()|?]{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 di minimo 8 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci la tua password attuale",
//minlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
//maxlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola"
},
password: {
remote: "Password errata",
regex: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola"
},
conferma_password: {
required: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password di minimo 8 caratteri contenente almeno un numero e una maiuscola"
}
}
});
}
if($('#recupera_password_page').length>0) {
$.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])[0-9a-zA-Z]{8,}$/,
minlength : 8,
maxlength : 12,
required:true
},
conferma_password : {
minlength : 8,
maxlength : 12,
equalTo : "#password",
required:true
}
},
messages: {
password: {
regex: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola"
},
conferma_password: {
required: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola"
}
}
});
}
if($('#nuova_password_page').length>0) {
$.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])[0-9a-zA-Z]{8,}$/,
minlength : 8,
maxlength : 12,
required:true
},
conferma_password : {
minlength : 8,
maxlength : 12,
equalTo : "#password",
required:true
}
},
messages: {
password: {
regex: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
required: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
minlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola"
},
conferma_password: {
required: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
equalTo: "Le password non coincidono",
minlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero e una maiuscola",
maxlength: "Inserisci una password compresa tra 8 e 12 caratteri contenente almeno un numero 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($('#dettaglio_conv').length>0) {
$('#js_filtra_x_codice').focusout(function() {
if($('#js_filtra_x_codice').val()!=""){
var trimcodice = $.trim($('#js_filtra_x_codice').val());
$('#js_filtra_x_codice').val(trimcodice);
$('#js_filtra_x_email').val("");
}
})
$('#js_filtra_x_email').focusout(function() {
if($('#js_filtra_x_email').val()!=""){
$('#js_filtra_x_codice').val("");
}
})
function isEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
$( "#js_filtro_data_from").datepicker({
altField: "#data_from",
altFormat: "yy-mm-dd",
maxDate: new Date(),
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 200);
}, 0);
},
onClose: function () {
if($( "#js_filtro_data_from").val()==""){
$("#js_filtro_data_from").datepicker('setDate', null);
}
},
onSelect: function(selectedDate) {
$('#js_filtro_data_to').datepicker('option', 'minDate', selectedDate );
}
});
$( "#js_filtro_data_to").datepicker({
altField: "#data_to",
altFormat: "yy-mm-dd",
maxDate: new Date(),
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 200);
}, 0);
},
onClose: function () {
if($( "#js_filtro_data_to").val()==""){
$("#js_filtro_data_to").datepicker('setDate', null);
}
},
onSelect: function(selectedDate) {
$('#js_filtro_data_from').datepicker('option', 'maxDate', selectedDate );
}
});
$('#js_reset_btn').bind('click',function(e) {
e.preventDefault();
startLoader();
$.ajax({
url: $('#base_url').val() + "ajax/reset_conv_filter",
type: 'POST',
data: 'csfrtok='+csfrtok,
success: function (data) {
document.location.reload();
}
});
});
function startLoader() {
$('body').prepend('');
$('#modal_loading').fadeIn();
}
function stopLoader() {
$('#modal_loading').fadeOut();
$('#sfondo').remove();
}
$('#js_filtra_btn').bind('click',function(e) {
e.preventDefault();
var js_filtra_x_codice=$('#js_filtra_x_codice').val();
var js_filtra_x_email=$('#js_filtra_x_email').val();
var js_filtra_x_tipo=$('#js_filtra_x_tipo').val();
var js_filtra_data_from=$('#data_from').val();
var js_filtra_data_to=$('#data_to').val();
if(js_filtra_x_codice!="" || js_filtra_x_email!="" || js_filtra_data_from!="" || js_filtra_data_to!="" || js_filtra_x_tipo!="0" ){
startLoader();
$.ajax({
url: $('#base_url').val() + "ajax/dettaglio_conv_filter",
type: 'POST',
data: 'js_filtra_x_codice=' + js_filtra_x_codice+'&js_filtra_x_email='+js_filtra_x_email+'&js_filtra_x_tipo='+js_filtra_x_tipo+'&js_filtra_data_from='+js_filtra_data_from+'&js_filtra_data_to='+js_filtra_data_to+'&csfrtok='+csfrtok,
success: function (data) {
document.location.reload();
}
});
} else {
alert("Attenzione.\nInserire almeno un parametro per effettuare la ricerca");
}
});
$('#select_all_checkbox').bind('click',function(e) {
//e.preventDefault();
var checked=$('#select_all_checkbox').is(":checked");
if(checked==1){
$(".js_checkbox_codice").prop('checked', true);
$("#select_all_checkbox").prop('checked', true);//true to check else false uncheck
} else {
$(".js_checkbox_codice").prop('checked', false);
$("#select_all_checkbox").prop('checked', false);//true to check else false uncheck
}
});
$(".js_libera_codice").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var codice_id=$(this).attr("data-codice_id");
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/libera_codice",
type: 'POST',
data: 'id_codice='+codice_id+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice liberato con successo");
document.location.reload();
} else {
alert("Non è stato possibile liberare questo codice.");
document.location.reload();
}
}
});
});
});
$(".js_azzera_codice").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var codice_id=$(this).attr("data-codice_id");
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/azzera_codice",
type: 'POST',
data: 'id_codice='+codice_id+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice azzerato con successo");
document.location.reload();
} else {
alert("Non è stato possibile azzerare questo codice.");
document.location.reload();
}
}
});
});
});
$(".js_reinvia_credenziali").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var email=$(this).attr("data-email");
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/re_invia_credenziali_per_email",
type: 'POST',
data: 'email='+email+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Credenziali inviate");
//document.location.reload();
} else {
alert("Non è stato possibile inviare le credenziali.");
//document.location.reload();
}
}
});
});
});
$(".js_re_invia_codice").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var codice_id=$(this).attr("data-codice_id");
var assigned_email_value=$(this).attr("data-codice_attivato_a");
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/re_invia_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&id_codice='+codice_id+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice inviato con successo");
document.location.reload();
}
}
});
} else {
alert("Inserisci un indirizzo email valido");
}
});
});
$('#js_attiva_codice_multi').bind('click',function(e) {
e.preventDefault();
var assigned_email_value=$('#email_codice_all').val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
var selected_array = []; // more efficient than new Array()
$(".js_checkbox_codice").each(function () {
var checked=$(this).is(":checked");
if(checked==1){
var codice_id=$(this).attr("data-codice_id");
selected_array.push(codice_id);
}
});
if(selected_array.length>0){
$.ajax({
url: $('#base_url').val() + "ajax/attiva_multi_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&codici_array='+selected_array+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){ //all code inviati
alert("I codici sono stati attivati");
document.location.reload();
} else if(data==2){ //solo alcuni inviati
alert("E' stato possibile attivare solo alcuni codici.");
document.location.reload();
} else { //errore
alert("Attenzione si è verificato un errore durante l'attivazione");
}
}
});
} else {
alert("Seleziona almeno un codice");
}
} else {
alert("Inserisci un indirizzo email valido");
}
});
$('#js_invia_codice_multi').bind('click',function(e) {
e.preventDefault();
var assigned_email_value=$('#email_codice_all').val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
var selected_array = []; // more efficient than new Array()
$(".js_checkbox_codice").each(function () {
var checked=$(this).is(":checked");
if(checked==1){
var codice_id=$(this).attr("data-codice_id");
selected_array.push(codice_id);
}
});
if(selected_array.length>0){
$.ajax({
url: $('#base_url').val() + "ajax/invia_multi_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&codici_array='+selected_array+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){ //all code inviati
alert("I codici sono stati inviati");
document.location.reload();
} else if(data==2){ //solo alcuni inviati
alert("E' stato possibile inviare solo alcuni codici.");
document.location.reload();
} else { //errore
alert("Attenzione si è verificato un errore durante l'invio");
}
}
});
} else {
alert("Seleziona almeno un codice");
}
} else {
alert("Inserisci un indirizzo email valido");
}
});
$(".js_attiva_codice").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var codice_id=$(this).attr("data-codice_id");
var assigned_email_value=$('#email_codice_'+codice_id).val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/attiva_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&id_codice='+codice_id+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice attivato con successo");
document.location.reload();
/* var id_right_box="#js_email_codice_right_container_"+codice_id;
var id_checkbox="#js_left_checkbox_container_"+codice_id;
$(id_right_box).hide();
$(id_checkbox).hide();
var id_active_right_box="#js_attivato_a_"+codice_id;
$(id_active_right_box).html(assigned_email_value);
$(id_active_right_box).fadeIn();*/
}
}
});
} else {
alert("Inserisci un indirizzo email valido");
}
});
});
$(".js_invia_codice").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var codice_id=$(this).attr("data-codice_id");
var assigned_email_value=$('#email_codice_'+codice_id).val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/invia_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&id_codice='+codice_id+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice inviato con successo");
document.location.reload();
}
}
});
} else {
alert("Inserisci un indirizzo email valido");
}
});
});
$("#js_invia_codice_all").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var conv=$('#conv').val();
var assigned_email_value=$('#email_codice_all').val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/invia_all_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&conv='+conv+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice inviato con successo");
document.location.reload();
}
if(data==5){
alert("Attenzione: Questa funzionalità è utilizzabile in convenzioni con un numero di codici inferiore o uguale a 50");
}
}
});
} else {
alert("Inserisci un indirizzo email valido");
}
});
});
$("#js_attiva_codice_all").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
var conv=$('#conv').val();
var assigned_email_value=$('#email_codice_all').val();
if(isEmail(assigned_email_value)){
var csfrtok=$('#csfrtok').val();
$.ajax({
url: $('#base_url').val() + "ajax/attiva_all_codice_per_email",
type: 'POST',
data: 'email=' + assigned_email_value+'&conv='+conv+'&csfrtok='+csfrtok,
success: function (data) {
if(data==1){
alert("Codice attivato con successo");
document.location.reload();
}
if(data==5){
alert("Attenzione: Questa funzionalità è utilizzabile in convenzioni con un numero di codici inferiore o uguale a 50");
}
}
});
} else {
alert("Inserisci un indirizzo email valido");
}
});
});
/////// upload immagine
$('.js_elimina_conv_btn').each(function() {
$(this).bind('click',function() {
var immagine="#immagine_conv_img";
var preview="#preview_conv";
var substitution_url="";
var def_azienda_img=$("#immagine_default_azienda").val();
var def_img=$("#immagine_default").val();
if(def_azienda_img!=""){
substitution_url=def_azienda_img;
$('#js_elimina_def_azienda_img').show();
} else {
substitution_url=def_img;
}
$(immagine).val('');
//$(preview).attr('src','');
$(preview).attr('src',substitution_url);
$(this).hide();
$("#immagine_conv_delete").val("1");
$("#submit_convimgform").show();
//alert(select_id);
});
});
$('.js_elimina_def_azienda_btn').each(function() {
$(this).bind('click',function() {
var immagine="#immagine_conv_img";
var preview="#preview_conv";
$(immagine).val('');
var def_img=$("#immagine_default").val();
$(preview).attr('src',def_img);
$("#immagine_conv_delete_def_img").val("1");
$(this).hide();
$("#submit_convimgform").show();
});
});
$('#headerModalConv').imgPicker({
url: $('#base_url').val()+"ajax/upload_immagine_conv",
aspectRatio: 570/180,
minSize: [570,180],
maxSize: [1710,540],
csfrtok:csfrtok,
uploadSuccess: function(image) {
var select = [0, 0, 570, 180];
// Set the setSelect option
this.options.setSelect = select;
},
deleteComplete: function() {
$('#preview_conv').attr('src','');
this.modal('hide');
},
cropSuccess: function(image) {
//console.log(image);
$('#preview_conv').attr('src', image.versions[''].url);
this.modal('hide');
$('#immagine_conv_img').val(image.name);
$('#js_elimina_conv_img').show();
$("#immagine_conv_delete").val("0");
$('#js_elimina_def_azienda_img').hide();
$("#immagine_conv_delete_def_img").val("0");
$("#submit_convimgform").show();
}
});
$("#convimgform").submit(function(){
$('body').prepend('');
$('#modal_loading').fadeIn();
});
////// upload immagine
}
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($('#promo_container').length>0) {
$(".js_show_codice").each(function () {
var codice_id=$(this).attr("data-codice_id");
$( this ).on('click', function(d) {
d.preventDefault();
visualizzaCodice(codice_id);
});
});
function visualizzaCodice(codice) {
if($('#codice_'+codice).css('display') == 'none') {
$('#codice_'+codice).fadeIn();
$('#link_codice_'+codice).removeClass('fal fa-angle-right').addClass('fal fa-angle-up');
} else {
$('#codice_'+codice).fadeOut();
$('#link_codice_'+codice).removeClass('fal fa-angle-up').addClass('fal fa-angle-right');
}
}
}
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";
if(prezzo_netto_per_quantita.includes(",00")){
prezzo_netto_per_quantita=prezzo_netto_per_quantita.replace(",00", "");
}
$(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($('#acquisto_pacchetti_audio_container').length>0) {
$('#js_aumenta_codici_7').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(7);
});
$('#js_diminuisci_codici_7').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(7);
});
$('#js_aumenta_codici_8').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(8);
});
$('#js_diminuisci_codici_8').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(8);
});
$('#js_aumenta_codici_9').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(9);
});
$('#js_diminuisci_codici_9').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(9);
});
$('#js_aumenta_codici_10').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(10);
});
$('#js_diminuisci_codici_10').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(10);
});
$('#js_aumenta_codici_11').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(11);
});
$('#js_diminuisci_codici_11').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(11);
});
$('#js_aumenta_codici_12').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(12);
});
$('#js_diminuisci_codici_12').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(12);
});
$('#js_aumenta_pacchetti_7').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(7);
change_select_values(7);
});
$('#js_diminuisci_pacchetti_7').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(7);
change_select_values(7);
});
$('#js_aumenta_pacchetti_8').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(8);
change_select_values(8);
});
$('#js_diminuisci_pacchetti_8').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(8);
change_select_values(8);
});
$('#js_aumenta_pacchetti_9').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(9);
change_select_values(9);
});
$('#js_diminuisci_pacchetti_9').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(9);
change_select_values(9);
});
$('#js_aumenta_pacchetti_10').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(10);
change_select_values(10);
});
$('#js_diminuisci_pacchetti_10').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(10);
change_select_values(10);
});
$('#js_aumenta_pacchetti_11').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(11);
change_select_values(11);
});
$('#js_diminuisci_pacchetti_11').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(11);
change_select_values(11);
});
$('#js_aumenta_pacchetti_12').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(12);
change_select_values(12);
});
$('#js_diminuisci_pacchetti_12').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(12);
change_select_values(12);
});
$(".js_email_da_verificare").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
AlertEmailDaVerificare()
});
});
$('#js_submit_acquista_7').bind('click',function(e) {
e.preventDefault();
submit_acquista(7);
});
$('#js_submit_acquista_8').bind('click',function(e) {
e.preventDefault();
submit_acquista(8);
});
$('#js_submit_acquista_9').bind('click',function(e) {
e.preventDefault();
submit_acquista(9);
});
$('#js_submit_acquista_10').bind('click',function(e) {
e.preventDefault();
submit_acquista(10);
});
$('#js_submit_acquista_11').bind('click',function(e) {
e.preventDefault();
submit_acquista(11);
});
$('#js_submit_acquista_12').bind('click',function(e) {
e.preventDefault();
submit_acquista(12);
});
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_7=$("#js_get_foto_in_pacchetto_per_id_7").val();
var get_foto_in_pacchetto_per_id_8=$("#js_get_foto_in_pacchetto_per_id_8").val();
var get_foto_in_pacchetto_per_id_9=$("#js_get_foto_in_pacchetto_per_id_9").val();
var get_foto_in_pacchetto_per_id_10=$("#js_get_foto_in_pacchetto_per_id_10").val();
var get_foto_in_pacchetto_per_id_11=$("#js_get_foto_in_pacchetto_per_id_11").val();
var get_foto_in_pacchetto_per_id_12=$("#js_get_foto_in_pacchetto_per_id_12").val();
var foto_acquistate=0;
if(pacchetto==7){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_7;
}
if(pacchetto==8){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_8;
}
if(pacchetto==9){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_9;
}
if(pacchetto==10){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_10;
}
if(pacchetto==11){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_11;
}
if(pacchetto==12){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_12;
}
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_7=$("#js_get_foto_in_pacchetto_per_id_7").val();
var get_foto_in_pacchetto_per_id_8=$("#js_get_foto_in_pacchetto_per_id_8").val();
var get_foto_in_pacchetto_per_id_9=$("#js_get_foto_in_pacchetto_per_id_9").val();
var get_foto_in_pacchetto_per_id_10=$("#js_get_foto_in_pacchetto_per_id_10").val();
var get_foto_in_pacchetto_per_id_11=$("#js_get_foto_in_pacchetto_per_id_11").val();
var get_foto_in_pacchetto_per_id_12=$("#js_get_foto_in_pacchetto_per_id_12").val();
if(pacchetto==7){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_7;
}
if(pacchetto==8){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_8;
}
if(pacchetto==9){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_9;
}
if(pacchetto==10){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_10;
}
if(pacchetto==11){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_11;
}
if(pacchetto==12){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_12;
}
return quantita;
}
function checkMaxNumberReturn(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=$(pacchetto_id).val();
var get_foto_in_pacchetto_per_id_7=$("#js_get_foto_in_pacchetto_per_id_7").val();
var get_foto_in_pacchetto_per_id_8=$("#js_get_foto_in_pacchetto_per_id_8").val();
var get_foto_in_pacchetto_per_id_9=$("#js_get_foto_in_pacchetto_per_id_9").val();
var get_foto_in_pacchetto_per_id_10=$("#js_get_foto_in_pacchetto_per_id_10").val();
var get_foto_in_pacchetto_per_id_11=$("#js_get_foto_in_pacchetto_per_id_11").val();
var get_foto_in_pacchetto_per_id_12=$("#js_get_foto_in_pacchetto_per_id_12").val();
if(pacchetto==7){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_7;
}
if(pacchetto==8){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_8;
}
if(pacchetto==9){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_9;
}
if(pacchetto==10){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_10;
}
if(pacchetto==11){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_11;
}
if(pacchetto==12){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_12;
}
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_7=$("#js_get_foto_in_pacchetto_per_id_7").val();
var get_foto_in_pacchetto_per_id_8=$("#js_get_foto_in_pacchetto_per_id_8").val();
var get_foto_in_pacchetto_per_id_9=$("#js_get_foto_in_pacchetto_per_id_9").val();
var get_foto_in_pacchetto_per_id_10=$("#js_get_foto_in_pacchetto_per_id_10").val();
var get_foto_in_pacchetto_per_id_11=$("#js_get_foto_in_pacchetto_per_id_11").val();
var get_foto_in_pacchetto_per_id_12=$("#js_get_foto_in_pacchetto_per_id_12").val();
var get_pacchetto_prezzo_netto_per_id_7=$("#js_pacchetto_prezzo_netto_per_id_7").val();
var get_pacchetto_prezzo_netto_per_id_8=$("#js_pacchetto_prezzo_netto_per_id_8").val();
var get_pacchetto_prezzo_netto_per_id_9=$("#js_pacchetto_prezzo_netto_per_id_9").val();
var get_pacchetto_prezzo_netto_per_id_10=$("#js_pacchetto_prezzo_netto_per_id_10").val();
var get_pacchetto_prezzo_netto_per_id_11=$("#js_pacchetto_prezzo_netto_per_id_11").val();
var get_pacchetto_prezzo_netto_per_id_12=$("#js_pacchetto_prezzo_netto_per_id_12").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_netto_per_id_7=get_pacchetto_prezzo_netto_per_id_7.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_8=get_pacchetto_prezzo_netto_per_id_8.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_9=get_pacchetto_prezzo_netto_per_id_9.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_10=get_pacchetto_prezzo_netto_per_id_10.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_11=get_pacchetto_prezzo_netto_per_id_11.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_12=get_pacchetto_prezzo_netto_per_id_12.replace(",", ".");
var get_pacchetto_prezzo_per_id_7=$("#js_pacchetto_prezzo_per_id_7").val();
var get_pacchetto_prezzo_per_id_8=$("#js_pacchetto_prezzo_per_id_8").val();
var get_pacchetto_prezzo_per_id_9=$("#js_pacchetto_prezzo_per_id_9").val();
var get_pacchetto_prezzo_per_id_10=$("#js_pacchetto_prezzo_per_id_10").val();
var get_pacchetto_prezzo_per_id_11=$("#js_pacchetto_prezzo_per_id_11").val();
var get_pacchetto_prezzo_per_id_12=$("#js_pacchetto_prezzo_per_id_12").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_per_id_7=get_pacchetto_prezzo_per_id_7.replace(",", ".");
var get_pacchetto_prezzo_per_id_8=get_pacchetto_prezzo_per_id_8.replace(",", ".");
var get_pacchetto_prezzo_per_id_9=get_pacchetto_prezzo_per_id_9.replace(",", ".");
var get_pacchetto_prezzo_per_id_10=get_pacchetto_prezzo_per_id_10.replace(",", ".");
var get_pacchetto_prezzo_per_id_11=get_pacchetto_prezzo_per_id_11.replace(",", ".");
var get_pacchetto_prezzo_per_id_12=get_pacchetto_prezzo_per_id_12.replace(",", ".");
if(pacchetto==7){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_7;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_7;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_7;
}
if(pacchetto==8){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_8;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_8;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_8;
}
if(pacchetto==9){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_9;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_9;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_9;
}
if(pacchetto==10){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_10;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_10;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_10;
}
if(pacchetto==11){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_11;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_11;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_11;
}
if(pacchetto==12){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_12;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_12;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_12;
}
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";
if(prezzo_netto_per_quantita.includes(",00")){
prezzo_netto_per_quantita=prezzo_netto_per_quantita.replace(",00", "");
}
$(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_7=$("#js_get_foto_in_pacchetto_per_id_7").val();
var get_foto_in_pacchetto_per_id_8=$("#js_get_foto_in_pacchetto_per_id_8").val();
var get_foto_in_pacchetto_per_id_9=$("#js_get_foto_in_pacchetto_per_id_9").val();
var get_foto_in_pacchetto_per_id_10=$("#js_get_foto_in_pacchetto_per_id_10").val();
var get_foto_in_pacchetto_per_id_11=$("#js_get_foto_in_pacchetto_per_id_11").val();
var get_foto_in_pacchetto_per_id_12=$("#js_get_foto_in_pacchetto_per_id_12").val();
var foto_acquistate=0;
if(pacchetto==7){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_7;
}
if(pacchetto==8){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_8;
}
if(pacchetto==9){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_9;
}
if(pacchetto==10){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_10;
}
if(pacchetto==11){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_11;
}
if(pacchetto==12){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_12;
}
var remainder = foto_acquistate % cq; //0== è un multiplo preciso
if(pacchetto>6 && pacchetto<13 && 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($('#acquisto_pacchetti_video_container').length>0) {
$('#js_aumenta_codici_13').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(13);
});
$('#js_diminuisci_codici_13').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(13);
});
$('#js_aumenta_codici_14').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(14);
});
$('#js_diminuisci_codici_14').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(14);
});
$('#js_aumenta_codici_15').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(15);
});
$('#js_diminuisci_codici_15').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(15);
});
$('#js_aumenta_codici_16').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(16);
});
$('#js_diminuisci_codici_16').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(16);
});
$('#js_aumenta_codici_17').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(17);
});
$('#js_diminuisci_codici_17').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(17);
});
$('#js_aumenta_codici_18').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_codici(18);
});
$('#js_diminuisci_codici_18').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_codici(18);
});
$('#js_aumenta_pacchetti_13').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(13);
change_select_values(13);
});
$('#js_diminuisci_pacchetti_13').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(13);
change_select_values(13);
});
$('#js_aumenta_pacchetti_14').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(14);
change_select_values(14);
});
$('#js_diminuisci_pacchetti_14').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(14);
change_select_values(14);
});
$('#js_aumenta_pacchetti_15').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(15);
change_select_values(15);
});
$('#js_diminuisci_pacchetti_15').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(15);
change_select_values(15);
});
$('#js_aumenta_pacchetti_16').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(16);
change_select_values(16);
});
$('#js_diminuisci_pacchetti_16').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(16);
change_select_values(16);
});
$('#js_aumenta_pacchetti_17').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(17);
change_select_values(17);
});
$('#js_diminuisci_pacchetti_17').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(17);
change_select_values(17);
});
$('#js_aumenta_pacchetti_18').bind('click',function(e) {
e.preventDefault();
Aumenta_quantita_pacchetti(18);
change_select_values(18);
});
$('#js_diminuisci_pacchetti_18').bind('click',function(e) {
e.preventDefault();
Diminuisci_quantita_pacchetti(18);
change_select_values(18);
});
$(".js_email_da_verificare").each(function () {
$( this ).on('click', function(d) {
d.preventDefault();
AlertEmailDaVerificare()
});
});
$('#js_submit_acquista_13').bind('click',function(e) {
e.preventDefault();
submit_acquista(13);
});
$('#js_submit_acquista_14').bind('click',function(e) {
e.preventDefault();
submit_acquista(14);
});
$('#js_submit_acquista_15').bind('click',function(e) {
e.preventDefault();
submit_acquista(15);
});
$('#js_submit_acquista_16').bind('click',function(e) {
e.preventDefault();
submit_acquista(16);
});
$('#js_submit_acquista_17').bind('click',function(e) {
e.preventDefault();
submit_acquista(17);
});
$('#js_submit_acquista_18').bind('click',function(e) {
e.preventDefault();
submit_acquista(18);
});
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_13=$("#js_get_foto_in_pacchetto_per_id_13").val();
var get_foto_in_pacchetto_per_id_14=$("#js_get_foto_in_pacchetto_per_id_14").val();
var get_foto_in_pacchetto_per_id_15=$("#js_get_foto_in_pacchetto_per_id_15").val();
var get_foto_in_pacchetto_per_id_16=$("#js_get_foto_in_pacchetto_per_id_16").val();
var get_foto_in_pacchetto_per_id_17=$("#js_get_foto_in_pacchetto_per_id_17").val();
var get_foto_in_pacchetto_per_id_18=$("#js_get_foto_in_pacchetto_per_id_18").val();
var foto_acquistate=0;
if(pacchetto==13){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_13;
}
if(pacchetto==14){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_14;
}
if(pacchetto==15){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_15;
}
if(pacchetto==16){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_16;
}
if(pacchetto==17){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_17;
}
if(pacchetto==18){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=quantita*get_foto_in_pacchetto_per_id_18;
}
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_13=$("#js_get_foto_in_pacchetto_per_id_13").val();
var get_foto_in_pacchetto_per_id_14=$("#js_get_foto_in_pacchetto_per_id_14").val();
var get_foto_in_pacchetto_per_id_15=$("#js_get_foto_in_pacchetto_per_id_15").val();
var get_foto_in_pacchetto_per_id_16=$("#js_get_foto_in_pacchetto_per_id_16").val();
var get_foto_in_pacchetto_per_id_17=$("#js_get_foto_in_pacchetto_per_id_17").val();
var get_foto_in_pacchetto_per_id_18=$("#js_get_foto_in_pacchetto_per_id_18").val();
if(pacchetto==13){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_13;
}
if(pacchetto==14){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_14;
}
if(pacchetto==15){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_15;
}
if(pacchetto==16){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_16;
}
if(pacchetto==17){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_17;
}
if(pacchetto==18){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_18;
}
return quantita;
}
function checkMaxNumberReturn(pacchetto){
var pacchetto_id="#pacchetto_"+pacchetto+"_quantita";
var quantita=$(pacchetto_id).val();
var get_foto_in_pacchetto_per_id_13=$("#js_get_foto_in_pacchetto_per_id_13").val();
var get_foto_in_pacchetto_per_id_14=$("#js_get_foto_in_pacchetto_per_id_14").val();
var get_foto_in_pacchetto_per_id_15=$("#js_get_foto_in_pacchetto_per_id_15").val();
var get_foto_in_pacchetto_per_id_16=$("#js_get_foto_in_pacchetto_per_id_16").val();
var get_foto_in_pacchetto_per_id_17=$("#js_get_foto_in_pacchetto_per_id_17").val();
var get_foto_in_pacchetto_per_id_18=$("#js_get_foto_in_pacchetto_per_id_18").val();
if(pacchetto==13){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_13;
}
if(pacchetto==14){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_14;
}
if(pacchetto==15){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_15;
}
if(pacchetto==16){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_16;
}
if(pacchetto==17){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_17;
}
if(pacchetto==18){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
quantita=quantita*get_foto_in_pacchetto_per_id_18;
}
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_13=$("#js_get_foto_in_pacchetto_per_id_13").val();
var get_foto_in_pacchetto_per_id_14=$("#js_get_foto_in_pacchetto_per_id_14").val();
var get_foto_in_pacchetto_per_id_15=$("#js_get_foto_in_pacchetto_per_id_15").val();
var get_foto_in_pacchetto_per_id_16=$("#js_get_foto_in_pacchetto_per_id_16").val();
var get_foto_in_pacchetto_per_id_17=$("#js_get_foto_in_pacchetto_per_id_17").val();
var get_foto_in_pacchetto_per_id_18=$("#js_get_foto_in_pacchetto_per_id_18").val();
var get_pacchetto_prezzo_netto_per_id_13=$("#js_pacchetto_prezzo_netto_per_id_13").val();
var get_pacchetto_prezzo_netto_per_id_14=$("#js_pacchetto_prezzo_netto_per_id_14").val();
var get_pacchetto_prezzo_netto_per_id_15=$("#js_pacchetto_prezzo_netto_per_id_15").val();
var get_pacchetto_prezzo_netto_per_id_16=$("#js_pacchetto_prezzo_netto_per_id_16").val();
var get_pacchetto_prezzo_netto_per_id_17=$("#js_pacchetto_prezzo_netto_per_id_17").val();
var get_pacchetto_prezzo_netto_per_id_18=$("#js_pacchetto_prezzo_netto_per_id_18").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_netto_per_id_13=get_pacchetto_prezzo_netto_per_id_13.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_14=get_pacchetto_prezzo_netto_per_id_14.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_15=get_pacchetto_prezzo_netto_per_id_15.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_16=get_pacchetto_prezzo_netto_per_id_16.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_17=get_pacchetto_prezzo_netto_per_id_17.replace(",", ".");
var get_pacchetto_prezzo_netto_per_id_18=get_pacchetto_prezzo_netto_per_id_18.replace(",", ".");
var get_pacchetto_prezzo_per_id_13=$("#js_pacchetto_prezzo_per_id_13").val();
var get_pacchetto_prezzo_per_id_14=$("#js_pacchetto_prezzo_per_id_14").val();
var get_pacchetto_prezzo_per_id_15=$("#js_pacchetto_prezzo_per_id_15").val();
var get_pacchetto_prezzo_per_id_16=$("#js_pacchetto_prezzo_per_id_16").val();
var get_pacchetto_prezzo_per_id_17=$("#js_pacchetto_prezzo_per_id_17").val();
var get_pacchetto_prezzo_per_id_18=$("#js_pacchetto_prezzo_per_id_18").val();
//rimetto i punti dove trovo virgole
var get_pacchetto_prezzo_per_id_13=get_pacchetto_prezzo_per_id_13.replace(",", ".");
var get_pacchetto_prezzo_per_id_14=get_pacchetto_prezzo_per_id_14.replace(",", ".");
var get_pacchetto_prezzo_per_id_15=get_pacchetto_prezzo_per_id_15.replace(",", ".");
var get_pacchetto_prezzo_per_id_16=get_pacchetto_prezzo_per_id_16.replace(",", ".");
var get_pacchetto_prezzo_per_id_17=get_pacchetto_prezzo_per_id_17.replace(",", ".");
var get_pacchetto_prezzo_per_id_18=get_pacchetto_prezzo_per_id_18.replace(",", ".");
if(pacchetto==13){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_13;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_13;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_13;
}
if(pacchetto==14){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_14;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_14;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_14;
}
if(pacchetto==15){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_15;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_15;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_15;
}
if(pacchetto==16){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_16;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_16;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_16;
}
if(pacchetto==17){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_17;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_17;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_17;
}
if(pacchetto==18){ //
prezzo_con_iva=get_pacchetto_prezzo_per_id_18;
prezzo_senza_iva=get_pacchetto_prezzo_netto_per_id_18;
num_foto=quantita_pacchetti*get_foto_in_pacchetto_per_id_18;
}
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";
if(prezzo_netto_per_quantita.includes(",00")){
prezzo_netto_per_quantita=prezzo_netto_per_quantita.replace(",00", "");
}
$(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_13=$("#js_get_foto_in_pacchetto_per_id_13").val();
var get_foto_in_pacchetto_per_id_14=$("#js_get_foto_in_pacchetto_per_id_14").val();
var get_foto_in_pacchetto_per_id_15=$("#js_get_foto_in_pacchetto_per_id_15").val();
var get_foto_in_pacchetto_per_id_16=$("#js_get_foto_in_pacchetto_per_id_16").val();
var get_foto_in_pacchetto_per_id_17=$("#js_get_foto_in_pacchetto_per_id_17").val();
var get_foto_in_pacchetto_per_id_18=$("#js_get_foto_in_pacchetto_per_id_18").val();
var foto_acquistate=0;
if(pacchetto==13){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_13;
}
if(pacchetto==14){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_14;
}
if(pacchetto==15){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_15;
}
if(pacchetto==16){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_16;
}
if(pacchetto==17){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_17;
}
if(pacchetto==18){ //moltiplico per 10 la quantità. Perchè ogni pacchetto 1 contiene 10 foto
foto_acquistate=q*get_foto_in_pacchetto_per_id_18;
}
var remainder = foto_acquistate % cq; //0== è un multiplo preciso
if(pacchetto>12 && pacchetto<19 && 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();
document.location.href="";
});
}
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($('#codici_pacchetto_container').length>0) {
$(".js_visualizza_codice").each(function () {
var id_codice=$(this).attr("data-codice");
$( this ).on('click', function(d) {
d.preventDefault();
visualizzaCodice(id_codice);
});
});
function startLoader() {
$('body').prepend('');
$('#modal_loading').fadeIn();
}
function stopLoader() {
$('#modal_loading').fadeOut();
$('#sfondo').remove();
}
function visualizzaCodice(codice) {
if($('#codice_'+codice).css('display') == 'none') {
$('#codice_'+codice).fadeIn();
$('#link_codice_'+codice).removeClass('fa-eye').addClass('fa-times-circle');
} else {
$('#codice_'+codice).fadeOut();
$('#link_codice_'+codice).removeClass('fa-times-circle').addClass('fa-eye');
}
}
}
if($('#inserisci_foto_pacchetto_container').length>0) {
var file_caricato=$("#file_caricato").val();
var convenzione_id_upload=$("#convenzione_id_upload").val();
if(file_caricato!=1){
var risultato_upload=$("#risultato_upload").val();
if(risultato_upload==1){
$('body').prepend('');
$('#modal_loading').fadeIn();
document.location.href=$('#base_url').val() +"/profilo_api/codici_pacchetto/"+convenzione_id_upload;
} else if(risultato_upload==2){
alert("si è verificato un errore durante l\'upload. Riprova.");
}
//binding
$('#js_close_anteprima').bind('click',function(e) {
e.preventDefault();
closeAnteprima();
});
$('.js_bind_showform').bind('click',function(e) {
e.preventDefault();
showForm();
});
$('#js_bind_anteprima').bind('click',function(e) {
e.preventDefault();
anteprimaFoto();
});
$('#js_bind_modifica').bind('click',function(e) {
e.preventDefault();
modificaFoto();
});
$('#js_bind_annulla').bind('click',function(e) {
e.preventDefault();
annullaInserimento();
});
$('#js_bind_reset').bind('click',function(e) {
e.preventDefault();
resetFotoImg();
});
$('#js_bind_toollink').bind('click',function(e) {
e.preventDefault();
showToolsLink();
});
$('#sfondo').bind('click',function(e) {
e.preventDefault();
closeAnteprima();
});
//binding
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '',
all[0]
);
return v > 4 ? v : undef;
}());
var userAgent = navigator.userAgent.toLowerCase();
window.browser = '';
window.version = 0;
var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
// Is this a version of Safari?
if (is_safari) {
userAgent = userAgent.substring(userAgent.indexOf('version/') + 8);
arrAgent = userAgent.split('.');
userAgent = arrAgent[0]+""+arrAgent[1];
window.version = userAgent;
window.browser = "Safari";
}
//check browser
//alert(window.version);
if(ie < 10 || (parseInt(window.version) >0 && parseInt(window.version)<71)) {
$('#inserisci_container').css('display','none');
if(window.browser == 'Safari') {
$('#warning_browser').fadeIn(0);
}
}
function checkFotoData(frm) {
with(frm) {
$('body').prepend('');
$('#modal_loading').fadeIn();
return true;
}
}
function showInfo() {
if($('#info_insert').css('display') == 'none') {
$('#info_insert').fadeIn();
} else {
$('#info_insert').fadeOut();
}
}
function emptyFile() {
$('#allegato').val('');
$('#elimina_button').fadeOut();
$('#allega_file').fadeIn();
}
function showFile() {
$('#elimina_button').fadeOut();
$('#allega_file').fadeIn();
}
function showButton() {
$('#allega_file').fadeOut();
$('#elimina_button').fadeIn();
$('#attached_file').html($('#allegato').val());
}
function startLoaderFoto() {
$('body').prepend('');
$('#modal_loading').fadeIn();
}
function stopLoaderFoto() {
$('#modal_loading').fadeOut();
$('#sfondo').remove();
}
var jcrop_api_foto;
//////////////////////
window.boxWidth = 950;
var windowWidth = $(window).width();
if(windowWidth < 1200) {
window.boxWidth = 780;
}
if(windowWidth < 1024) {
window.boxWidth = 680;
}
if(windowWidth < 900) {
window.boxWidth = 580;
}
$('#aggiungi_immagine').on('change',function() {
startLoaderFoto();
var oFileFoto = $('#aggiungi_immagine')[0].files[0];
// check for image type (jpg and png are allowed)
var rFilterFoto = /^(image\/jpeg|image\/png)$/i;
if (! rFilterFoto.test(oFileFoto.type)) {
alert('Puoi caricare solo file jpg, jpeg o png');
stopLoaderFoto();
return;
}
// check for file size
if (oFileFoto.size > 2000 * 1024) {
alert('Attenzione, la foto che stai cercando di caricare è troppo pesante e supera i limiti consentiti');
stopLoaderFoto();
return;
}
// preview element
var oImageFoto = document.getElementById('target_avatar_foto');
// prepare HTML5 FileReader
var oReaderFoto = new FileReader();
oReaderFoto.onload = function(e) {
// e.target.result contains the DataURL which we can use as a source of the image
oImageFoto.src = e.target.result;
stopLoaderFoto();
oImageFoto.onload = function () { // onload event handler
// display some basic image info
/*var sResultFileSize = bytesToSize(oFileFoto.size);
$('#filesize').val(sResultFileSize);
$('#filetype').val(oFileFoto.type);
$('#filedim').val(oImageFoto.naturalWidth + ' x ' + oImageFoto.naturalHeight);*/
var boundxFoto, boundyFoto;
if (typeof jcrop_api_foto != 'undefined') {
jcrop_api_foto.destroy();
}
// initialize Jcrop
$('#target_avatar_foto').Jcrop({
minSize: [580, 180], // min crop size
maxSize: [2000, 2000], // max crop size// min crop size
aspectRatio : 19/6, // keep aspect ratio 1:1
bgFade: true, // use fade effect
bgOpacity: .3, // fade opacity
boxWidth: window.boxWidth,
onChange: updateInfoFoto,
onSelect: updateInfoFoto
}, function(){
// use the Jcrop API to get the real image size
var boundsFoto = this.getBounds();
boundxFoto = boundsFoto[0];
boundyFoto = boundsFoto[1];
// Store the Jcrop API in the jcrop_api_foto variable
jcrop_api_foto = this;
});
if(oImageFoto.naturalWidth < 570 || oImageFoto.naturalHeight < 180) {
alert("L\'immagine caricata è troppo piccola, le dimensioni minime consentite sono 640px per 640px");
oImageFoto.removeAttribute("src");
$('#upload_result_foto').fadeOut(0);
$('#aggiungi_immagine').val('');
if (typeof jcrop_api_foto != 'undefined') {
jcrop_api_foto.destroy();
}
resetFotoImg();
return false;
} else if(oImageFoto.naturalWidth >2000 || oImageFoto.naturalHeight > 2000) {
alert("L\'immagine caricata è troppo grande, ricorda che le dimensioni massime sono 2000px per 2000px");
oImageFoto.removeAttribute("src");
$('#upload_result_foto').fadeOut(0);
$('#aggiungi_immagine').val('');
if (typeof jcrop_api_foto != 'undefined') {
jcrop_api_foto.destroy();
}
resetFotoImg();
return false;
} else {
$('#aggiungi_immagine').fadeOut();
}
$('#img_width_foto').val(oImageFoto.naturalWidth);
$('#img_height_foto').val(oImageFoto.naturalHeight);
};
};
// read selected file as DataURL
oReaderFoto.readAsDataURL(oFileFoto);
$('#upload_result_foto').fadeIn();
});
///////////////////////////
function resetFotoImg() {
var oImageFoto = document.getElementById('target_avatar_foto');
oImageFoto.removeAttribute('src');
$('#target_avatar_foto').css({'height':'auto','width':'auto'});
$('#upload_result_foto').fadeOut();
$('#aggiungi_immagine').val('');
$('#aggiungi_immagine').fadeIn();
jcrop_api_foto.destroy();
}
function updateInfoFoto(e) {
$('#x1_foto').val(e.x);
$('#y1_foto').val(e.y);
$('#x2_foto').val(e.x2);
$('#y2_foto').val(e.y2);
$('#w_foto').val(e.w);
$('#h_foto').val(e.h);
$('#procedi_button_foto').fadeIn();
}
function chiudi() {
document.location.href=$('#base_url').val() +"/profilo_api/inserisci_foto_pacchetto/redirect";
}
function showForm() {
$('#upload_result_foto').fadeOut(0);
$('#compila_foto').css('background-image','url('+$('#target_avatar_foto').attr('src')+')');
$('#compila_foto').css('background-position',"-"+(570*parseInt($('#x1_foto').val())/$('#w_foto').val())+"px -"+(180*parseInt($('#y1_foto').val())/$('#h_foto').val())+"px");
$('#compila_foto').css('background-size',(570*parseInt($('#img_width_foto').val())/$('#w_foto').val())+'px '+(180*parseInt($('#img_height_foto').val())/$('#h_foto').val())+'px');
$('#compila_foto_grande').css('background-image','url('+$('#target_avatar_foto').attr('src')+')');
$('#compila_foto_grande').css('background-position',"-"+(570*parseInt($('#x1_foto').val())/$('#w_foto').val())+"px -"+(180*parseInt($('#y1_foto').val())/$('#h_foto').val())+"px");
$('#compila_foto_grande').css('background-size',(570*parseInt($('#img_width_foto').val())/$('#w_foto').val())+'px '+(180*parseInt($('#img_height_foto').val())/$('#h_foto').val())+'px');
$('#titolo').html('');
$('#spiegazione').fadeOut(0);
$('#aggiungi_immagine').fadeOut(0);
$('#compila').fadeIn();
$('#step_2').removeClass('mark_fff').removeClass('bg_ddd').addClass('bg_rosso');
//console.log("showform");
//document.location.href="#";
}
function modificaFoto() {
$('#compila').fadeOut(0);
$('#upload_result_foto').fadeIn();
$('#titolo').html('CARICAMENTO FOTO');
$('#spiegazione').fadeIn();
$('#step_2').removeClass('bg_rosso').addClass('bg_ddd').addClass('mark_fff');
$('#foto_riepilogo').fadeOut(0);
$('#foto_form').fadeIn(0);
$('#step_3').removeClass('bg_rosso').addClass('bg_ddd').addClass('mark_fff');
console.log("modifica foto");
//document.location.href="#";
}
function annullaInserimento() {
if(confirm("Sarai riportato alla pagina di inserimento foto e i dati inseriti non saranno salvati.")) {
document.location.href="";
}
}
function anteprimaFoto() {
$('body').prepend('');
$('#anteprima_foto').fadeIn();
}
function closeAnteprima() {
$('#sfondo').remove();
$('#anteprima_foto').fadeOut();
}
function showToolsLink() {
if($('#tools_link').css('display') == 'none') {
$('#tools_link').fadeIn();
} else {
$('#tools_link').fadeOut();
}
}
}
}
/****FORMS*****/
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;
}
}
});
}