<?php
	/*-------------------------
	Autor: Obed Alvarado
	Web: obedalvarado.pw
	Mail: info@obedalvarado.pw
	---------------------------*/
	session_start();

	/* Connect To Database*/
	require_once ("../../config/db.php");
	require_once ("../../config/conexion.php");
	if (isset($_GET["id"])){
	$id=$_GET["id"];
	$id=intval($id);
	$sql="select * from customers, contacts where customers.id=contacts.client_id and customers.id='$id'";
	$query=mysqli_query($con,$sql);
	$num=mysqli_num_rows($query);
	if ($num==1){
	$rw=mysqli_fetch_array($query);
	$name=$rw['name'];
	$tax_number=$rw['tax_number'];
	$website=$rw['website'];
	$work_phone=$rw['work_phone'];
	$first_name=$rw['first_name'];
	$last_name=$rw['last_name'];
	$email=$rw['email'];
	$phone=$rw['phone'];
	$address1=$rw['address1'];
	$city=$rw['city'];
	$state=$rw['state'];
	$postal_code=$rw['postal_code'];
	$country_id=$rw['country_id'];
	
	}
	}	
	else {exit;}	
?>
     

	  <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                  <li class="active"><a href="#activity2" data-toggle="tab">Datos del cliente</a></li>
                  <li><a href="#settings2" data-toggle="tab">Dirección</a></li>
                </ul>
                <div class="tab-content">
                  <div class="active tab-pane" id="activity2">
				  
				  <div class="row">
					<div class='col-md-12'>
						<label for="bussines_name">Nombre</label>
						<input type="text" class="form-control" id="bussines_name"  name="bussines_name" required value="<?php echo $name;?>">	
						<input type="hidden" class="form-control" id="client_id"  name="client_id" value="<?php echo $id;?>">						
					</div>
				  </div>
				  
				  
				  <div class="row">
					
					<div class='col-md-5'>
						<label for="website">Sitio web</label>
						<input type="url" class="form-control" id="website" name="website" value="<?php echo $website;?>">						
					</div>
					<div class='col-md-4'>
						<label for="work_phone">Teléfono</label>
						<input type="text" class="form-control" id="work_phone" name="work_phone" required value="<?php echo $work_phone;?>">						
					</div>
					<div class='col-md-3'>
						<label for="tax_number">Registro fiscal Nº</label>
						<input type="text" class="form-control" id="tax_number" name="tax_number" value="<?php echo $tax_number;?>">						
					</div>
				  </div>

				  <div class="row">
				  <div class='col-md-12'>
				  <br>
					<div style="font-size:14px;	font-weight:bold;border-bottom: 1px solid #ddd;padding: 5px 5px 5px 0px;width:100%;margin-bottom:10px">Datos de contacto</div>
				  </div>
					<div class='col-md-6'>
						<label for="first_name">Nombres</label>
						<input type="text" class="form-control" id="first_name" name="first_name" required value="<?php echo $first_name;?>"> 					
					</div>
					<div class='col-md-6'>
						<label for="last_name">Apellidos</label>
						<input type="text" class="form-control" id="last_name" name="last_name" required value="<?php echo $last_name;?>">					
					</div>
					
				  </div>
				  
				  <div class="row">
				  
					<div class='col-md-6'>
						<label for="email">Correo Electrónico</label>
						<input type="email" class="form-control" id="email" name="email" value="<?php echo $email;?>">					
					</div>
					<div class='col-md-6'>
						<label for="phone">Teléfono</label>
						<input type="text" class="form-control" id="phone" name="phone" required value="<?php echo $phone;?>">					
					</div>
					
				  </div>
                    
					
					
                   
                      

                   
                    

                   
                  </div><!-- /.tab-pane -->
                 

                  <div class="tab-pane" id="settings2">
				  
				  
				  <div class="row">
							<div class='col-md-12'>
								<label for="address1">Calle</label>
								<input type="text" class="form-control" id="address1" name="address1" value="<?php echo $address1;?>">
							</div>
							
					</div>

					<div class="row">
							<div class='col-md-6'>
								<label for="city">Ciudad</label>
								<input type="text" class="form-control" id="city" name="city" value="<?php echo $city;?>">
							</div>
							
							<div class='col-md-6'>
								<label for="state">Región/Provincia</label>
								<input type="text" class="form-control" id="state" name="state" value="<?php echo $state;?>">
							</div>
							
					</div>
					
					
					<div class="row">
							
							<div class='col-md-6'>
								<label for="postal_code">Código Postal</label>
								<input type="text" class="form-control" id="postal_code" name="postal_code" value="<?php echo $postal_code;?>">
							</div>
							
							<div class='col-md-6'>
								<label for="country_id">País</label>
								<?php 
								$query_countries=mysqli_query($con,"select * from countries order by name");
								?>
								<select class='form-control' name="country_id" id="country_id">
								<option value="0" >Selecciona</option>
									<?php
										while ($rw_countries=mysqli_fetch_array($query_countries)){
											?>
											<option value="<?php echo $rw_countries['id'];?>" <?php if ($country_id==$rw_countries['id']){echo "selected";}else{echo "";}?>><?php echo utf8_encode($rw_countries['name']);?></option>
											<?php 
										}
									?>
								</select>
							</div>
							
					</div>
					
					
                    
                     
                      
                     
                      
                    
                  </div><!-- /.tab-pane -->
                </div><!-- /.tab-content -->
              </div><!-- /.nav-tabs-custom -->