Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- //$("#firma, #firma-anexo, #firma-tutor").jSignature();
- //Webcam.attach('#div-carnClienteFrontal');
- });
- $('#btn-guardar').click(function() {
- var sign = $('#signature').jSignature('getData', 'base30');
- console.log(sign);
- alert(sign);
- });
- $('#btn-borrar-firma').click(function(e) {
- e.preventDefault();
- $('#firma').jSignature('reset');
- $('#Formulario_firmaExoneracionCliente').removeAttr('value');
- });
- $('#btn-borrar-firma-anexo').click(function(e) {
- e.preventDefault();
- $('#firma-anexo').jSignature('reset');
- $('#Formulario_firmaAnexo').removeAttr('value');
- });
- $('#btn-borrar-firma-tutor').click(function(e) {
- e.preventDefault();
- $('#firma-tutor').jSignature('reset');
- $('#Formulario_firmaTutor').removeAttr('value');
- });
- $('#btn-sgte-anexo').click(function() {
- var firma = $('#firma').jSignature('getData', 'base30');
- if (firma != null) {
- if (firma[1] != '') {
- $('#input-firma').val(firma[1]);
- $('#form-firma').submit();
- } else alert('Debe firmar en el recuadro para continuar.');
- }
- });
- /*$("#btn-finalizar").click(function(){
- var firmaAnexo = $("#firma-anexo").jSignature("getData","base30");
- console.log(firmaAnexo);
- if(firmaAnexo != null){
- if(firmaAnexo[1] != ''){
- $('#input-firma-anexo').val(firmaAnexo[1]);
- }
- }
- });*/
- function consultaCliente(rut) {
- //alert(rut);
- $.ajax({
- type: 'POST',
- url: 'ConsultaCliente/',
- data: { rut: rut },
- success: function(data) {
- var json = JSON.parse(data);
- console.log(json);
- if (json != null) {
- if (json.status != 'ERROR') {
- var datosCliente = json.cliente;
- $('#Cliente_nombreCompletoCliente').val(
- datosCliente.nombreCompletoCliente
- );
- $('#Cliente_domicilioCliente').val(datosCliente.domicilioCliente);
- $('#Cliente_fechaNacCliente').val(datosCliente.fechaNacCliente);
- $('#Cliente_emailCliente').val(datosCliente.emailCliente);
- $('#contratoRut').html($('#Cliente_rutCliente').val());
- $('#contratoNombre').html($('#Cliente_nombreCompletoCliente').val());
- $('#contratoDomicilio').html($('#Cliente_domicilioCliente').val());
- //$('#btn-sgte').focus();
- $('#div-rut-firma').html(rut);
- if (!json.mayorEdad) {
- $('#div-menor').show();
- $('#firma-tutor').jSignature();
- } else {
- $('#div-menor').hide();
- $('#firma-tutor').html('');
- }
- } else {
- $('#Cliente_nombreCompletoCliente').val('');
- $('#Cliente_domicilioCliente').val('');
- $('#Cliente_fechaNacCliente').val('');
- $('#Cliente_emailCliente').val('');
- $('#div-rut-firma').html('');
- $('#contratoRut').html($('#Cliente_rutCliente').val());
- }
- }
- }
- });
- }
- $(":radio[value='1']").click(function() {
- //alert("Usted no puede tatuarse si padece de esa condición");
- $.Zebra_Dialog(
- 'Usted <strong>NO</strong> puede tatuarse si padece de esa condición.Consulte con el <strong>TATUADOR</strong>.',
- {
- type: 'warning',
- title: 'Aviso',
- position: ['center', 'top + 50']
- }
- );
- });
- $('#email1,#email2').change(function() {
- //alert( "Handler for .change() called." );
- // juntando email
- var email1 = $('#email1').val();
- console.log(email1);
- var email2 = $('#email2').val();
- console.log(email2);
- if (email1 && email2) {
- $('#Cliente_emailCliente').val(email1 + '@' + email2);
- } else {
- $('#Cliente_emailCliente').val('');
- }
- console.log('archivado');
- });
- $('#month_start,#day_start,#year_start').change(function() {
- //alert( "Handler for .change() called." );
- var dia = $('#day_start').val();
- var mes = $('#month_start').val();
- var anio = $('#year_start').val();
- var guion = '-';
- var cero = '0';
- if (dia < 10) {
- dia = cero + dia;
- }
- var fecha = anio + guion + mes + guion + dia;
- $('#Cliente_fechaNacCliente').val(fecha);
- console.log(fecha);
- var hoy = new Date();
- var dia = $('#day_start').val();
- var mes = $('#month_start').val();
- var anio = $('#year_start').val();
- var today = new Date();
- var anionac = new Date(anio, mes - 1, dia);
- var edad = today.getFullYear() - anionac.getFullYear();
- var month = today.getMonth() - anionac.getMonth();
- if (month < 0 || (month === 0 && today.getDate() < anionac.getDate())) {
- edad--;
- }
- console.log('la edad es +' + edad);
- //var diff = hoy.getFullYear() - anio;
- var diff = edad;
- console.log(diff + guion);
- if (diff < 18) {
- $('#div-menor').show();
- $('#firma-tutor').html('');
- $('#firma-tutor').jSignature({ width: 768, height: 250 });
- //$('#Formulario_firmaExoneracionCliente').val('');
- } else {
- $('#div-menor').hide();
- $('#firma-tutor').html('');
- }
- });
- $('#chbk-aceptar').click(function(e) {
- if ($('#chbk-aceptar').prop('checked') == true) {
- // Se activí
- $('#formularios').css('display: visible');
- $('#formularios, #btn-finalizar').fadeIn();
- //$('#firma-anexo, #firma').jSignature('reset');
- $('#firma-anexo, #firma').jSignature({ width: 768, height: 250 });
- $('html, body').animate(
- {
- scrollTop: $('#formularios').offset().top
- },
- 1000
- );
- } else {
- //alert('adasd');
- $('#firma-anexo, #firma').html('');
- $('#formularios').css('display: none');
- $('#formularios, #btn-finalizar').fadeOut();
- }
- });
- $('.btn-foto').click(function(e) {
- var div = $(this).data('value');
- Webcam.snap(function(data_uri) {
- document.getElementById(div).innerHTML = '<img src="' + data_uri + '"/>';
- });
- });
- $('.btn-webcam').click(function(e) {
- var divCam = $(this).data('value');
- var divFoto = $(this).data('foto');
- var estado = $(this).data('estado');
- if (estado == 0) {
- // se activa la webcam
- $('#' + divCam).show();
- $('#' + divFoto).hide();
- Webcam.attach('#' + divCam);
- $(this).data('estado', '1');
- $(this).html('<i class="icon-camera icon-white"></i> Tomar foto');
- $(this).removeClass('btn-success');
- $(this).addClass('btnrojo');
- } else {
- // se toma la foto
- var datos_foto = '';
- Webcam.snap(function(data_uri) {
- document.getElementById(divFoto).innerHTML =
- '<img src="' + data_uri + '"/>';
- datos_foto = data_uri;
- });
- var input_foto = $(this).data('input');
- var base64_foto = datos_foto.replace(/^data\:image\/\w+\;base64\,/, '');
- $('#Formulario_' + input_foto).val(base64_foto);
- $('#' + divCam).hide();
- $('#' + divFoto).show();
- $(this).data('estado', '0');
- $(this).html('<i class="icon-off icon-white"></i> Activar Cámara');
- Webcam.off('#' + divCam);
- $(this).addClass('btn-success');
- $(this).removeClass('btnrojo');
- }
- });
- function getAge(birthDateString) {
- var today = new Date();
- var birthDate = new Date(birthDateString);
- var age = today.getFullYear() - birthDate.getFullYear();
- var m = today.getMonth() - birthDate.getMonth();
- if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
- age--;
- }
- return age;
- }
- $('#btn-finalizar').click(function(e) {
- /*var firmaAnexo = $("#firma-anexo").jSignature("getData","base30");
- console.log(firmaAnexo);
- if(firmaAnexo != null){
- if(firmaAnexo[1] != ''){
- $('#input-firma-anexo').val(firmaAnexo[1]);
- }
- }*/
- var dia = $('#day_start').val();
- var mes = $('#month_start').val();
- var anio = $('#year_start').val();
- var today = new Date();
- var anionac = new Date(anio, mes - 1, dia);
- var edad = today.getFullYear() - anionac.getFullYear();
- var month = today.getMonth() - anionac.getMonth();
- if (month < 0 || (month === 0 && today.getDate() < anionac.getDate())) {
- edad--;
- }
- // console.log('la edad es +' + edad);
- if ($(":radio[value='1']:checked").length > 0) {
- e.preventDefault();
- //alert("Ud. no puede tatuarse si tiene una de las enfermedades listadas anteriormente");
- $.Zebra_Dialog(
- 'Usted <strong>NO</strong> puede tatuarse si padece de esa condición.Consulte con el <strong>TATUADOR</strong>.',
- {
- type: 'warning',
- title: 'Aviso',
- position: ['center', 'top + 50']
- }
- );
- $('html, body').animate(
- {
- scrollTop: $('#enfermedades').offset().top
- },
- 1000
- );
- } else {
- // juntando email
- var email1 = $('#email1').val();
- var email2 = $('#email2').val();
- if (email1 && email2) {
- $('#Cliente_emailCliente').val(email1 + '@' + email2);
- } else {
- $('#Cliente_emailCliente').val('');
- }
- console.log('holi');
- var rutCliente = $('#Cliente_rutCliente').val();
- var rutClienteSinNada = rutCliente.replace(/[\. ,:-\_]+/g, '');
- // console.log(rutCliente);
- // console.log(rutClienteSinNada);
- // return;
- if (
- // rutClienteSinNada.length > 10 ||
- // $.validateRut(rutCliente) ||
- // !rutCliente
- rutClienteSinNada.length > 0
- ) {
- //e.preventDefault();
- var anio = $('#year_start').val();
- var hoy = new Date();
- //var diff = hoy.getFullYear() - anio;
- var diff = edad;
- // console.log($.validateRut($('#Formulario_rutTutor').val()));
- // console.log('asdas');
- // console.log($('#Formulario_rutTutor').val());
- if (edad < 18) {
- if (
- // $.validateRut($('#Formulario_rutTutor').val()) ||
- // !$('#Formulario_rutTutor').val()
- true
- ) {
- var haynombre = $('#Formulario_nombreTutor').val();
- var hayrut = $('#Formulario_rutTutor').val();
- var hayfirma = $('#Formulario_firmaTutor').val();
- var hayfotoCFT = $('#Formulario_fotoCarnetFrontalTutor').val();
- var hayfotoCTT = $('#Formulario_fotoCarnetTraseroTutor').val();
- if (hayfirma && hayrut && haynombre && hayfotoCFT && hayfotoCTT) {
- $('#modal-cargando').modal('show');
- } else {
- e.preventDefault();
- $.Zebra_Dialog('Falta en la sección del tutor ', {
- type: 'warning',
- title: 'Aviso',
- position: ['center', 'top + 50']
- });
- $('html, body').animate(
- {
- scrollTop: $('#div-menor').offset().top
- },
- 1000
- );
- }
- } else {
- e.preventDefault();
- //alert("Ud. no puede tatuarse si tiene una de las enfermedades listadas anteriormente");
- $.Zebra_Dialog(
- '<strong>RUT TUTOR</strong> Incorrecto. Ingrese nuevamente el RUT ',
- {
- type: 'warning',
- title: 'Aviso',
- position: ['center', 'top + 50']
- }
- );
- $('html, body').animate(
- {
- scrollTop: $('#div-menor').offset().top
- },
- 1000
- );
- }
- } else {
- $('#modal-cargando').modal('show');
- }
- } else {
- console.log('RUt Incorrecto');
- e.preventDefault();
- $('html, body').animate(
- {
- scrollTop: $('#formularios').offset().top
- },
- 1000
- );
- //alert("Ud. no puede tatuarse si tiene una de las enfermedades listadas anteriormente");
- $.Zebra_Dialog('Ingrese el R.U.T. ', {
- type: 'warning',
- title: 'Aviso',
- position: ['center', 'top + 50']
- });
- }
- }
- });
- $('#firma, #firma-anexo, #firma-tutor').mouseout(function(e) {
- var firma = $(this).jSignature('getData', 'base30');
- var input = $(this).data('input');
- console.log(input);
- console.log(firma);
- if (firma != null) {
- if (firma[1] != '') {
- $('#Formulario_' + input).val(firma[1]);
- console.log(firma[1]);
- console.log(input);
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment