<?php

session_start();

require_once("../../config/Cado.php");

require_once("../cliente/cCliente.php");

$oCliente = new cCliente();



$dts=$oCliente->mostrarUno($_POST['cli_id']);

	$dt = mysqli_fetch_array($dts);

	$tip=$dt['tb_cliente_tip'];

	$nom=$dt['tb_cliente_nom'];

	$doc=$dt['tb_cliente_doc'];

	$con=$dt['tb_cliente_con'];

	$tel=$dt['tb_cliente_tel'];

	$ema=$dt['tb_cliente_ema'];

	mysqli_free_result($dts);



?>



<div class="modal-header">

	<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

	<h4 class="modal-title" id="titlemodal">CONTACTOS DEL CLIENTE </strong> <strong class="text-red" ><?php echo $nom;?></strong></h4> 

</div>





<div class="row">



	<div class="col-lg-12 col-xs-12" style="height:20px;" ></div>

	

	<?php #if ($_SESSION['usuariogrupo_id']=='6'){

	#}else{	?>

	<div class="col-lg-6 col-xs-6">

		  <button id="btn_agregar" onClick="clientecorr_form('insertarcorreo',<?php echo $_POST['cli_id']; ?>)" class="btn btn-primary">Agregar</button>

	</div>

	<?php #}?>

	<div class="col-lg-12 col-xs-12" style="height:20px;" ></div>

 

	<div class="col-lg-12 col-xs-12" id="div_tabla_correo"> 

  

  

	</div>



</div>





<div class="modal-footer pull-right">	 

	<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancelar</button>

</div>





<script type="text/javascript">





cliente_tablacorreo(<?php echo $_POST['cli_id']; ?>);



function cliente_tablacorreo(cliid){			

	$.ajax({	

		type: "POST",					

		url: "../cliente/cliente_tablacorreo.php",

		async:true,

		dataType: "html",                      

		data: ({

			cli_id: cliid

		}),

		beforeSend: function() {

			$('#div_tabla_correo').addClass("ui-state-disabled");

    },

		success: function(html){

			$('#div_tabla_correo').html(html);

		},

		complete: function(){			

			$('#div_tabla_correo').removeClass("ui-state-disabled");

		}

	});        

}

	

function agregarcorreo(act,cliid){			

	$.ajax({	

		type: "POST",					

		url: "../cliente/cliente_reg.php",

		async:true,

		dataType: "json",                      

		data: ({

			action:$("#action_con").val(),

			cli_id: cliid,

			nom:$('#txt_cli_emanom').val(),

			tel:$('#txt_cli_ematel').val(),

			ema:$('#txt_cli_emacor').val()

		}),

		beforeSend: function() {

			

		},

		success: function(data){

			toastr["success"](data.cli_msj);	

				

		},

		complete: function(){	

			

			$('#txt_cli_ematel').val();

			$('#txt_cli_emanom').val();

			$('#txt_cli_emacor').val();

			

			//$('#div_clientevehi_form_dialog2').modal('hide');

		

			cliente_tablacorreo(<?php echo $_POST['cli_id']; ?>);

			

		}

	});        

}







function eliminar_clientecorreo(cliemaid)

{      

	if(confirm("Realmente desea eliminar?")){

		$.ajax({

			type: "POST",

			url: "../cliente/cliente_reg.php",

			async:true,

			dataType: "html",

			data: ({

				action: "eliminarcorreo",

				cliemaid:	cliemaid

			}),

			beforeSend: function() {

				

			},

			success: function(html){

				toastr["success"](html);

			},

			complete: function(){

				

				cliente_tablacorreo(<?php echo $_POST['cli_id']; ?>);

			}

		});

	}

}











function clientecorr_form(act,idf){

	$('#div_clientecorreo_form_dialog2').modal();

	$.ajax({

		type: "POST",

		url: "../cliente/clientecorr_form.php",

		async:true,

		dataType: "html",                      

		data: ({

			action: act,

			cli_id:	idf,

			vista:	'tabla'

		}),

		beforeSend: function() {

			var div = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> </div>  </center>";	

			$('.div_clientecorreo_form2').html(div);

        },

		success: function(html){

			$('.div_clientecorreo_form2').html(html);		

		}

	});

}







function clientevehi_form(act,idf){

	$('#div_clientevehi_form_dialog2').modal();

	$.ajax({

		type: "POST",

		url: "../cliente/clientevehi_form.php",

		async:true,

		dataType: "html",                      

		data: ({

			action: act,

			cli_id:	idf,

			vista:	'tabla'

		}),

		beforeSend: function() {

			var div = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> </div>  </center>";	

			$('.div_clientevehi_form2').html(div);

        },

		success: function(html){

			$('.div_clientevehi_form2').html(html);		

		}

	});

}









</script>