<?php



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);





if($_POST['action']=="editarvehiculo"){

	

	$dts=$oCliente->filtrarvehiculo_uno($_POST['clivei_id']);

	$dt = mysqli_fetch_array($dts);

	$pla=$dt['tb_clientevehiculo_pla'];

	$mod=$dt['tb_clientevehiculo_mod'];

	$mot=$dt['tb_clientevehiculo_mot'];

	$caj=$dt['tb_clientevehiculo_caj'];

	$mar=$dt['tb_clientevehiculo_mar'];

	$cha=$dt['tb_clientevehiculo_cha'];

	mysqli_free_result($dts);

			

	

}

	

?>



<div class="modal-header">

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

</div>



 <input name="action_veh" id="action_veh" type="hidden" value="<?php echo $_POST['action']; ?>">

 

<div class="row">

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

          <label for="txt_cli_pla">Placa:</label>      

		   <input name="txt_cli_pla" id="txt_cli_pla" type="text" value="<?php echo $pla?>" class="form-control">

		  

	</div>

	

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

          <label for="txt_cli_mar">Marca:</label>      

		   <input name="txt_cli_mar" id="txt_cli_mar" type="text" value="<?php echo $mar?>" class="form-control">

	</div>

	

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

          <label for="txt_cli_pla">Modelo:</label>      

		   <input name="txt_cli_mod" id="txt_cli_mod" type="text" value="<?php echo $mod?>" class="form-control">

		  

	</div>

	

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

          <label for="txt_cli_cha">Chasis/Vin:</label>      

		   <input name="txt_cli_cha" id="txt_cli_cha" type="text" value="<?php echo $cha?>" class="form-control">

	</div>

	

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

          <label for="txt_cli_pla">Motor:</label>      

		   <input name="txt_cli_mot" id="txt_cli_mot" type="text" value="<?php echo $mot?>" class="form-control">

		  

	</div>

	

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

          <label for="txt_cli_pla">Caja:</label>      

		   <input name="txt_cli_caj" id="txt_cli_caj" type="text" value="<?php echo $caj?>" class="form-control">

		  

	</div>

</div>





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

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

	<button type="button" class="btn btn-primary pull-left" onclick="agregarvehiculo('','<?php echo $_POST['clivei_id']; ?>','<?php echo $_POST['cli_id']; ?>');" data-dismiss="modal">Guardar</button>

	

</div>





<script type="text/javascript">



	$('#txt_cli_pla,#txt_cli_mod,#txt_cli_mot,#txt_cli_caj').change(function(){

		$(this).val($(this).val().toUpperCase());

	});

	



	$('#txt_cli_pla').keydown(function(ev){

		if(ev.keyCode==13){			

			$('#txt_cli_mod').focus();			

			return false;}		

	});

	

	$('#txt_cli_mod').keydown(function(ev){

		if(ev.keyCode==13){			

			$('#txt_cli_mot').focus();

			return false;}

	});

	

	$('#txt_cli_mot').keydown(function(ev){

		if(ev.keyCode==13){			

			$('#txt_cli_caj').focus();

			return false;}

	});



		

function agregarvehiculo(act,cliveiid,cli_id){			

	$.ajax({	

		type: "POST",					

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

		async:true,

		dataType: "json",                      

		data: ({

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

			clivei_id: cliveiid,

			cli_id: cli_id,

			pla:$('#txt_cli_pla').val(),

			mod:$('#txt_cli_mod').val(),

			mot:$('#txt_cli_mot').val(),

			caj:$('#txt_cli_caj').val(),

			mar:$('#txt_cli_mar').val(),

			cha:$('#txt_cli_cha').val()

		}),

		beforeSend: function() {

			

		},

		success: function(data){

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

				

		},

		complete: function(){	

			

			<?php if($_POST['vista']=="ventas"){

			?>	

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

			$('#div_clientevehiculos_form_dialog').modal('hide');

			<?php	

			}else{?>

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

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

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

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

			

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

		

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

			<?php }?>

		}

	});        

}

</script>