<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Persona</title>
<link href="../../maincss.css" rel="stylesheet" type="text/css" />
<link href="../../printcss.css" rel="stylesheet" type="text/css" media="print" />

<script language="JavaScript"> 
 
function oculta(id){
	 var elDiv = document.getElementById(id); //se define la variable "elDiv" igual a nuestro div
	 elDiv.style.display='none'; //damos un atributo display:none que oculta el div	 
	}
 
function muestra(id){
	 var elDiv = document.getElementById(id); //se define la variable "elDiv" igual a nuestro div
	 elDiv.style.display='block';//damos un atributo display:block que  el div	 
	}
 
window.onload = function(){/*hace que se cargue la función */
/* "Mandamos como parametro el nombre de la Div para ocultar" */
oculta('Pcomision');
}
</script>
</head>
<?php
include "../../conn.php";
include "../../class.nroenletraver2.php";
include "../../general.php";
include "../../token.php";

//index.php?pkyPerson=2&user=Luigi&token=123456

$cod_persona = $_GET["pkyPerson"];
//$usuario = $_GET["user"];

?>
<body>

<?php

// Inicio impresion Persona

$result = mysqli_query($link, "select a.pkyPerson as codigo, b.fldName as titulo, a.fldFirstName as nombre, a.fldLastName as ap_pat, a.fldMiddleName as ap_mat, c.fldName as genero, a.codCityLocation as cod_ciu, d.fldName as ciudad, a.fldWebSite as sitio_web, a.fldZipCode as casilla, a.fldAlternativeKey as cod_alt, a.fldIsEmployee as es_empleado, a.codJob as cod_cargo, a.codBirthCity as cod_ciu_nac, a.fldBirthDate as fecha_nac, a.fldHiringDate as fecha_cont, a.fldCanSell as puede_vender, g.fldName as usuario_reg, a.fldActive as esta_activo, e.fldName as tipo_emp, a.fldHealthFundCode as cod_caja_salud, a.fldRetirementPensionCode as cod_fondo_pensiones, a.fldBasicSalary as sueldo_basico, a.fldRetirementAge as edad_jubila, a.codBranch as cod_sucursal, f.fldName as estado_civil, a.fldMinimumUnit as hora_dia, a.fldBankAccount as cuenta_banco, 
case when a.codWagesExpenseConcept is null then NULL else (select h1.fldName from payExpensesConcept h1 where a.codWagesExpenseConcept = h1.pkyExpensesConcept) end as con_gastos_sueldos_x_pagar, 
case when a.codSecondBonusExpenseConcept is null then NULL else (select h2.fldName from payExpensesConcept h2 where a.codSecondBonusExpenseConcept = h2.pkyExpensesConcept) end as con_gasto_aguinaldo_2, 
case when a.codBonusExpenseConcept is null then NULL else (select h3.fldName from payExpensesConcept h3 where a.codBonusExpenseConcept = h3.pkyExpensesConcept) end as con_gasto_aguinaldo, 
case when a.codCompensationExpenseConcept is null then NULL else (select h4.fldName from payExpensesConcept h4 where a.codCompensationExpenseConcept = h4.pkyExpensesConcept) end as con_gasto_indem, 
case when a.codEmployerContributionsExpenseConcept is null then NULL else (select h5.fldName from payExpensesConcept h5 where a.codEmployerContributionsExpenseConcept = h5.pkyExpensesConcept) end as con_gasto_ap_pat, 
case when a.codSalaryReimbursementExpenseConcept is null then NULL else (select h6.fldName from payExpensesConcept h6 where a.codSalaryReimbursementExpenseConcept = h6.pkyExpensesConcept) end as con_gasto_reintegro, 
case when a.codExtraHoursExpenseConcept is null then NULL else (select h7.fldName from payExpensesConcept h7 where a.codExtraHoursExpenseConcept = h7.pkyExpensesConcept) end as con_gasto_hrs_extra, 
case when a.codChargeHoursExpenseConcept is null then NULL else (select h8.fldName from payExpensesConcept h8 where a.codChargeHoursExpenseConcept = h8.pkyExpensesConcept) end as con_gasto_hrs_recargo, 
case when a.codSundayHoursExpenseConcept is null then NULL else (select h9.fldName from payExpensesConcept h9 where a.codSundayHoursExpenseConcept = h9.pkyExpensesConcept) end as con_gasto_hrs_domingo, 
case when a.codExtraordinaryHoursExpenseConcept is null then NULL else (select h10.fldName from payExpensesConcept h10 where a.codExtraordinaryHoursExpenseConcept = h10.pkyExpensesConcept) end as con_gasto_hrs_extraor, 
case when a.codHolidayHoursExpenseConcept is null then NULL else (select h11.fldName from payExpensesConcept h11 where a.codHolidayHoursExpenseConcept = h11.pkyExpensesConcept) end as con_gasto_hrs_feriado, 
case when a.codSeniorityExpenseConcept is null then NULL else (select h12.fldName from payExpensesConcept h12 where a.codSeniorityExpenseConcept = h12.pkyExpensesConcept) end as con_gasto_bono_ant, 
a.fldAccumulatedVacation as vacaciones_acum, a.fldAccumulatedVAT as iva_acum, a.codBank as cod_banco, a.fldMarriedLastName as ap_casada, a.fldOtherNames as nombre_otro, a.fldRetired as cod_jubilado  
from 
agnPerson a, agnTitle b, agnGender c, regCity d, agnEmployeeType e, agnMaritalStatus f, accGroup g
where
a.pkyPerson = '$cod_persona' and 
a.codTitle = b.pkyTitle and 
a.codGender = c.pkyGender and 
a.codCityLocation = d.pkyCity and 
a.codEmployeeType = e.pkyEmployeeType and 
a.codMaritalStatus = f.pkyMaritalStatus and 
a.sysAuthorizationGroup = g.pkyGroup;");
	while ($row = mysqli_fetch_array($result)) {
		$codigo = $row['codigo'];
		$titulo = $row['titulo'];
		$nombre = $row['nombre'];
		$ap_pat = $row['ap_pat'];
		$ap_mat = $row['ap_mat'];
		$genero = $row['genero'];
		$ciudad = $row['ciudad'];
		$sitio_web = $row['sitio_web'];
		$casilla = $row['casilla'];
		$cod_alt = $row['cod_alt'];
		$fecha_nac = $row['fecha_nac'];
		$fecha_cont = $row['fecha_cont'];
		if($row['es_empleado'] == 1) {
		$es_empleado = 'Si';
		} else {
		$es_empleado = 'No';	
		$fecha_nac = ' ';
		$fecha_cont = ' ';
		}
		if($row['puede_vender'] == 1) {
		$puede_vender = 'Si';
		} else {
		$puede_vender = 'No';	
		}
		$cod_cargo = $row['cod_cargo'];
		$cod_ciu_nac = $row['cod_ciu_nac'];
		$usuario_reg = $row['usuario_reg'];
		if($row['esta_activo'] == 1) {
		$esta_activo = 'Si';
		} else {
		$esta_activo = 'No';
		}
		$tipo_emp = $row['tipo_emp'];
		$cod_caja_salud = $row['cod_caja_salud'];
		$cod_fondo_pensiones = $row['cod_fondo_pensiones'];
		$sueldo_basico = $row['sueldo_basico'];
		$edad_jubila = $row['edad_jubila'];
		$cod_sucursal = $row['cod_sucursal'];
		$estado_civil = $row['estado_civil'];
		if($row['hora_dia'] == 1) {
		$hora_dia = 'Hora';
		} else {
		$hora_dia = 'D&iacute;a';
		}
		$cuenta_banco = $row['cuenta_banco'];
		$con_gastos_sueldos_x_pagar = $row['con_gastos_sueldos_x_pagar']; 
		$con_gasto_aguinaldo_2 = $row['con_gasto_aguinaldo_2'];   
		$con_gasto_aguinaldo = $row['con_gasto_aguinaldo']; 
		$con_gasto_indem = $row['con_gasto_indem'];  
		$con_gasto_ap_pat = $row['con_gasto_ap_pat'];   
		$con_gasto_reintegro = $row['con_gasto_reintegro'];  
		$con_gasto_hrs_extra = $row['con_gasto_hrs_extra'];
		$con_gasto_hrs_recargo = $row['con_gasto_hrs_recargo'];  
		$con_gasto_hrs_domingo = $row['con_gasto_hrs_domingo']; 
		$con_gasto_hrs_extraor = $row['con_gasto_hrs_extraor'];
		$con_gasto_hrs_feriado = $row['con_gasto_hrs_feriado'];
		$con_gasto_bono_ant = $row['con_gasto_bono_ant'];
		$vacaciones_acum = $row['vacaciones_acum'];
		$iva_acum = $row['iva_acum'];
		$cod_banco = $row['cod_banco'];
		$ap_casada = $row['ap_casada'];
		$nombre_otro = $row['nombre_otro'];
		$cod_jubilado = $row['cod_jubilado'];//0=no, 1=si
		if($row['cod_jubilado'] == 1) {
		$jubilado = 'Si';
		} else {
		$jubilado = 'No';	
		}
		 
	}
	mysqli_free_result($result);
	
$resultcargo = mysqli_query($link, "select pkyJob as cod_cargo, fldName as cargo
from hrsJob
where
pkyJob = '$cod_cargo';");
while ($row = mysqli_fetch_array($resultcargo)) {
	$cargo = $row['cargo'];
}
mysqli_free_result($resultcargo);

$resultciunac = mysqli_query($link, "select pkyCity as cod_ciu, fldName as ciudad
from regCity
where
pkyCity = '$cod_ciu_nac';");
while ($row = mysqli_fetch_array($resultciunac)) {
	$ciudad_nac = $row['ciudad'];
}
mysqli_free_result($resultciunac);

$resultsuc = mysqli_query($link, "select pkyCompanyBranch as cod_suc, fldName as sucursal
from agnCompanyBranch 
where 
pkyCompanyBranch = '$cod_sucursal';");
while ($row = mysqli_fetch_array($resultsuc)) {
	$sucursal = $row['sucursal'];
}
mysqli_free_result($resultsuc);

$resultdescuento = mysqli_query($link, "select a.pkyDiscountException as cod_exc, b.fldName as descuento, b.fldFormat as cod_afp
from
hrsDiscountException a, hrsFixedDiscounts b
where
a.codFixedDiscount = b.pkyFixedDiscounts and 
a.codEmployee = '$cod_persona' 
order by descuento;");
$ma_des = array();
$de = 1;
while ($row = mysqli_fetch_array($resultdescuento)) {
	$ma_des [$de][1] = $row['descuento'];
	$cod_afp = $row['cod_afp'];//se supone que se repiten
	$de++;
}
$hay_descuento = mysqli_num_rows($resultdescuento);
mysqli_free_result($resultdescuento);
$fin_de = $de - 1;

if($cod_afp == 0) { $afp = 'No Asignado'; }
if($cod_afp == 1) { $afp = 'Previsi&oacute;n'; }
if($cod_afp == 2) { $afp = 'Futuro'; }

$resultcurso = mysqli_query($link, "select pkyEmployeeCourse as cod_cur, fldCourse as curso, txtDescription as glosa 
from
hrsEmployeeCourse 
where
codPerson = '$cod_persona' 
order by curso;");
$ma_cur = array();
$cu = 1;
while ($row = mysqli_fetch_array($resultcurso)) {
	$ma_cur [$cu][1] = $row['curso'];
	$ma_cur [$cu][2] = $row['glosa'];
	$cu++;
}
$hay_curso = mysqli_num_rows($resultcurso);
mysqli_free_result($resultcurso);
$fin_cu = $cu - 1;


$resultdepen = mysqli_query($link, "select a.pkyEmployeeDependent as cod_dep, case when b.fldMiddleName is NULL then concat(b.fldLastName,', ',b.fldFirstName) else concat(b.fldLastName,' ',b.fldMiddleName,', ',b.fldFirstName) end as dependiente
from
hrsEmployeeDependent a, agnPerson b 
where
a.codPerson = '$cod_persona' and 
a.codDependent = b.pkyPerson 
order by dependiente;");
$ma_depen = array();
$dep = 1;
while ($row = mysqli_fetch_array($resultdepen)) {
	$ma_depen [$dep][1] = $row['dependiente'];
	$dep++;
}
$hay_dependiente = mysqli_num_rows($resultdepen);
mysqli_free_result($resultdepen);
$fin_dep = $dep - 1;


$resultdoc = mysqli_query($link, "select a.pkyEmployeeDocument as cod_doc, b.fldName as documento, a.fldNumber as numero, c.fldName as ciudad, a.txtDescription as glosa
from
hrsEmployeeDocument a, agnIdentityDocumentType b, regCity c 
where
a.codPerson = '$cod_persona' and 
a.codIdentityDocumentType = b.pkyIdentityDocumentType and 
a.codCity = c.pkyCity
order by documento;");
$ma_doc = array();
$doc = 1;
while ($row = mysqli_fetch_array($resultdoc)) {
	$ma_doc [$doc][1] = $row['documento'];
	$ma_doc [$doc][2] = $row['numero'];
	$ma_doc [$doc][3] = $row['ciudad'];
	$ma_doc [$doc][4] = $row['glosa'];
	$doc++;
}
$hay_documento = mysqli_num_rows($resultdoc);
mysqli_free_result($resultdoc);
$fin_doc = $doc - 1;


$resultidioma = mysqli_query($link, "select a.pkyEmployeeLanguage as cod_idi, b.fldName as idioma, a.txtDescription as glosa
from
hrsEmployeeLanguage a, regLanguage b 
where
a.codPerson = '$cod_persona' and 
a.codLanguage = b.pkyLanguage 
order by idioma;");
$ma_idi = array();
$idi = 1;
while ($row = mysqli_fetch_array($resultidioma)) {
	$ma_idi [$idi][1] = $row['idioma'];
	$ma_idi [$idi][2] = $row['glosa'];
	$idi++;
}
$hay_idioma = mysqli_num_rows($resultidioma);
mysqli_free_result($resultidioma);
$fin_idi = $idi - 1;


$resultdir = mysqli_query($link, "select a.fldAddress as direccion, b.fldName as tipo_dir, a.fldDefault as principal, a.txtDescription as glosa
from
agnPersonAddress a, agnAddressType b
where
a.codType = b.pkyAddressType and 
a.codPerson = '$cod_persona' 
order by principal desc, direccion;");
$ma_dir = array();
$d = 1;
while ($row = mysqli_fetch_array($resultdir)) {
	$ma_dir [$d][1] = $row['direccion'];
	$ma_dir [$d][2] = $row['tipo_dir'];
	if($row['principal'] == 1) {
	$ma_dir [$d][3] = 'Si';
	} else {
	$ma_dir [$d][3] = ' ';	
	}
	$ma_dir [$d][4] = $row['glosa'];
	$d++;
}
$hay_direccion = mysqli_num_rows($resultdir);
mysqli_free_result($resultdir);
$fin_d = $d - 1;


$resultmail = mysqli_query($link, "select a.fldMail as correo, b.fldName as tipo, a.fldDefault as principal, a.txtDescription as glosa 
from agnPersonMail a, agnMailType b
where 
a.codType = b.pkyMailType and 
a.codPerson = '$cod_persona' 
order by principal desc, tipo, correo;");
$ma_mail = array();
$m = 1;
while ($row = mysqli_fetch_array($resultmail)) {
	$ma_mail [$m][1] = $row['correo'];
	$ma_mail [$m][2] = $row['tipo'];
	if($row['principal'] == 1) {
	$ma_mail [$m][3] = 'Si';
	} else {
	$ma_mail [$m][3] = ' ';	
	}
	$ma_mail [$m][4] = $row['glosa'];
	$m++;
}
$hay_mail = mysqli_num_rows($resultmail);
mysqli_free_result($resultmail);
$fin_m = $m - 1;

$resulttel = mysqli_query($link, "select a.fldPhone as telefono, b.fldName as tipo, a.fldDefault as principal, a.txtDescription as glosa 
from agnPersonPhone a, agnPhoneType b
where 
a.codType = b.pkyPhoneType and 
a.codPerson = '$cod_persona' 
order by principal desc, tipo, telefono;");
$ma_tel = array();
$te = 1;
while ($row = mysqli_fetch_array($resulttel)) {
	$ma_tel [$te][1] = $row['telefono'];
	$ma_tel [$te][2] = $row['tipo'];
	if($row['principal'] == 1) {
	$ma_tel [$te][3] = 'Si';
	} else {
	$ma_tel [$te][3] = ' ';
	}
	$ma_tel [$te][4] = $row['glosa'];
	$te++;
}
$hay_telefono = mysqli_num_rows($resulttel);
mysqli_free_result($resulttel);
$fin_te = $te - 1;


//comision	
$resultcom = mysqli_query($link, "select a.codItem as cod_item, b.fldName as item, a.fldCommission as comision 
from hrsSalesCommission a, invItem b
where 
a.codItem = b.pkyItem and 
a.codEmployee = '$cod_persona' 
order by item;");
$ma_com = array();
$co = 1;
while ($row = mysqli_fetch_array($resultcom)) {
	$ma_com [$co][1] = $row['cod_item'];
	$ma_com [$co][2] = $row['item'];
	$ma_com [$co][3] = $row['comision'];
	$co++;
}
$hay_comision = mysqli_num_rows($resultcom);
mysqli_free_result($resultcom);
$fin_co = $co - 1;

$resultbanco = mysqli_query($link, "select b.pkyCompany as cod_banco, b.fldName as banco
from tryBank a, agnCompany b
where
a.pkyBank = '$cod_banco' and 
a.codCompany = b.pkyCompany;");
while ($row = mysqli_fetch_array($resultbanco)) {
	$banco = $row['banco'];
}
mysqli_free_result($resultbanco);
?>

<table border="0" align="left" width="100%" cellpadding="5">
<tr><td><?php echo $mostrar_logo_reportes; ?>
</td><td align="right"><b>Fecha: <?php echo date("Y-m-d"); ?><br/>Hora: <?php echo date("H:i:s"); ?><br/>Usuario: <?php echo $usuario; ?></b>
</td></tr></table>
<p><br /><center><font color="#000099" size="+1"><b>Persona</b></font></center></p>

<table border="0" cellpadding="2" align="center" width="100%">
<tr>
<td>  
    <table border="1" align="center" cellpadding="2" width="100%">
        <TR> 
        <TD width="33%"><b>Cod.: </b><?php echo $cod_persona; ?></TD>
        <TD width="33%"><b>Cod. Alt.: </b><?php echo $cod_alt; ?></TD>
        <TD width="33%"><b>Ciudad: </b><?php echo $ciudad; ?></TD>
        </TR>
        <TR>
        <TD><b>Titulo: </b><?php echo $titulo; ?></TD>
        <TD><b>G&eacute;nero: </b><?php echo $genero; ?></TD>
        <TD><b>Casilla Postal: </b><?php echo $casilla; ?></a></TD>
        </TR>
        <TR>
        <TD><b>Nombre: </b><?php echo $nombre; ?></TD>
        <TD><b>Otros Nombres: </b><?php echo $nombre_otro; ?></TD>
        <TD><b>Ap. Paterno: </b><?php echo $ap_pat; ?></TD>
        </TR>
        <TR>
        <TD><b>Ap. Materno: </b><?php echo $ap_mat; ?></a></TD>
        <TD><b>Ap. Casada: </b><?php echo $ap_casada; ?></a></TD>
        <TD><b>Jubilado(a): </b><?php echo $jubilado; ?></a></TD>
        </TR>
        <TR>
        <TD><b>Lugar Nac.: </b><?php echo $ciudad_nac; ?></TD>
        <TD><b>Fecha Nac.: </b><?php echo $fecha_nac; ?></TD>
        <TD><b>Sitio Web: </b><?php echo $sitio_web; ?></TD>
        </TR>
        <TR>
        <TD><b>Es Empleado: </b><?php echo $es_empleado; ?></TD>
        <TD><b>Activo: </b><?php echo $esta_activo; ?></TD>
        <TD><b>Autorizado a Vender: </b><?php echo $puede_vender; ?></TD>
        </TR>
        <TR>
        <TD><b>Cargo: </b><?php echo $cargo; ?></TD>
        <TD><b>Contrataci&oacute;n: </b><?php echo $fecha_cont; ?></TD>
        <TD><b>Sucursal: </b><?php echo $sucursal; ?></TD>
        </TR>
        <TR>
        <TD><b>Tipo de Empleado: </b><?php echo $tipo_emp; ?></TD>
        <TD><b>C&oacute;digo Caja de Salud: </b><?php echo $cod_caja_salud; ?></TD>
        <TD><b>C&oacute;digo Fondo de Pensiones: </b><?php echo $cod_fondo_pensiones; ?></TD>
        </TR>
        <TR>
        <TD><b>Sueldo B&aacute;sico: </b><?php echo number_format($sueldo_basico, $n_decimales); ?></TD>
        <TD><b>Estado Civil: </b><?php echo $estado_civil; ?></TD>
        <TD><b>Edad de Jubilaci&oacute;n: </b><?php echo $edad_jubila; ?></TD>
        </TR>
        <TR>
        <TD><b>Medida de Tiempo de Trabajo: </b><?php echo $hora_dia; ?></TD>
        <TD><b>Vacaciones Acumuladas en Alta: </b><?php echo number_format($vacaciones_acum, $n_decimales); ?></TD>
        <TD><b>RC IVA Acumulado: </b><?php echo number_format($iva_acum, $n_decimales); ?></TD>
        </TR>
        <TR>
        <TD colspan="3" align="center"><b>Informaci&oacute;n Para Planillas </b></TD>
        </TR>
        <TR>
        <TD><b>Concepto Gasto Sueldos x Pagar: </b><?php echo $con_gastos_sueldos_x_pagar; ?></TD>
        <TD><b>Concepto Gasto Indemnizaci&oacute;n: </b><?php echo $con_gasto_indem; ?></TD>
        <TD><b>Concepto Gasto Reintegro: </b><?php echo $con_gasto_reintegro; ?></TD>
        </TR>
        <TR>
        <TD><b>Concepto Gasto Aportes Patronales: </b><?php echo $con_gasto_ap_pat; ?></TD>
        <TD><b>Concepto Gasto Aguinaldos: </b><?php echo $con_gasto_aguinaldo; ?></TD>
        <TD><b>Concepto Gasto 2do. Aguinaldo: </b><?php echo $con_gasto_aguinaldo_2; ?></TD>
        </TR>
        <TR>
        <TD><b>Concepto Gasto Horas Extra: </b><?php echo $con_gasto_hrs_extra; ?></TD>
        <TD><b>Concepto Gasto Horas Recargo: </b><?php echo $con_gasto_hrs_recargo; ?></TD>
        <TD><b>Concepto Gasto Horas Domingo: </b><?php echo $con_gasto_hrs_domingo; ?></TD>
        </TR>
        <TR>
        <TD><b>Concepto Gasto Horas Extraordinarias: </b><?php echo $con_gasto_hrs_extraor; ?></TD>
        <TD><b>Concepto Gasto Horas Feriado: </b><?php echo $con_gasto_hrs_feriado; ?></TD>
        <TD><b>Concepto Gasto Bono Antig&uuml;edad: </b><?php echo $con_gasto_bono_ant; ?></TD>
        </TR>
        <TR>
        <TD><b>Banco: </b><?php echo $banco; ?></TD>
        <TD><b>Cuenta Banco: </b><?php echo $cuenta_banco; ?></TD>
        <TD><b>AFP: </b><?php echo $afp; ?></TD>
        </TR>
    </table>
</td>
</tr>

<?php if($hay_descuento != 0) { //if hay_descuento ?>
<tr>
<td>
	<b>Descuentos Fijos AFP: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	</thead>
    <tr>
    <TD align="center"><b>Descuento</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($de = 1; $de <= $fin_de; $de++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td></tr>", $ma_des [$de][1]);//descuento
		} else {
		printf("<tr><td align='left'>%s</td></tr>", $ma_des [$de][1]);//descuento
		} //fin if color
    	$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>

<?php } //fin if hay_descuento ?>


<?php if($hay_curso != 0) { //if hay_curso ?>
<tr>
<td>
	<b>Cursos: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Curso</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($cu = 1; $cu <= $fin_cu; $cu++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_cur [$cu][1]);//curso
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_cur [$cu][1]);//curso
		} //fin if color
		printf("<td align='left'>%s</td></tr>", $ma_cur [$cu][2]);//descripcion
    	$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_curso ?>

<?php if($hay_dependiente != 0) { //if hay_dependiente ?>
<tr>
<td>
	<b>Dependientes: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Dependiente</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($dep = 1; $dep <= $fin_dep; $dep++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_depen [$dep][1]);//dependiente
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_depen [$dep][1]);//dependiente
		} //fin if color
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_dependiente ?>


<?php if($hay_documento != 0) { //if hay_documento ?>
<tr>
<td>
	<b>Documentos: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Documento</b></TD>
    <TD align="center"><b>N&uacute;mero</b></TD>
    <TD align="center"><b>Origen</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($doc = 1; $doc <= $fin_doc; $doc++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_doc [$doc][1]);//documento
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_doc [$doc][1]);//documento
		} //fin if color
		printf("<td align='left'>%s</td>", $ma_doc [$doc][2]);//numero
		printf("<td align='left'>%s</td>", $ma_doc [$doc][3]);//origen
		printf("<td align='left'>%s</td></tr>", $ma_doc [$doc][4]);//descripcion
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_documento ?>


<?php if($hay_idioma != 0) { //if hay_idioma ?>
<tr>
<td>
	<b>Idiomas: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Idioma</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($idi = 1; $idi <= $fin_idi; $idi++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_idi [$idi][1]);//idioma
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_idi [$idi][1]);//idioma
		} //fin if color
		printf("<td align='left'>%s</td></tr>", $ma_idi [$idi][2]);//descripcion
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_idioma ?>


<?php if($hay_direccion != 0) { //if hay_direccion ?>
<tr>
<td>
	<b>Direcci&oacute;n: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Direcci&oacute;n</b></TD>
    <TD align="center"><b>Tipo</b></TD>
    <TD align="center"><b>Principal</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($d = 1; $d <= $fin_d; $d++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_dir [$d][1]);//direccion
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_dir [$d][1]);//direccion
		} //fin if color
    	printf("<td align='left'>%s</td>", $ma_dir [$d][2]);//tipo
    	printf("<td align='center'>%s</td>", $ma_dir [$d][3]);//principal
        printf("<td align='left'>%s</td></tr>", $ma_dir [$d][4]);//descripcion
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_direccion ?>


<?php if($hay_mail != 0) { //if hay_mail ?>
<tr>
<td>
	<b>Mail: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Correo</b></TD>
    <TD align="center"><b>Tipo</b></TD>
    <TD align="center"><b>Principal</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($m = 1; $m <= $fin_m; $m++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_mail [$m][1]);//correo
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_mail [$m][1]);//correo
		} //fin if color
    	printf("<td align='left'>%s</td>", $ma_mail [$m][2]);//tipo
    	printf("<td align='center'>%s</td>", $ma_mail [$m][3]);//principal
        printf("<td align='left'>%s</td></tr>", $ma_mail [$m][4]);//descripcion
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_mail ?>

<?php if($hay_telefono != 0) { //if hay_telefono ?>
<tr>
<td>
	<b>Tel&eacute;fonos: </b>
    <table border="1" align="center" cellpadding="2" width="100%">
	<thead>
    <tr>
    <TD align="center"><b>Tel&eacute;fono</b></TD>
    <TD align="center"><b>Tipo</b></TD>
    <TD align="center"><b>Principal</b></TD>
    <TD align="center"><b>Descripci&oacute;n</b></TD>
	</tr>
	</thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($te = 1; $te <= $fin_te; $te++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='left'>%s</td>", $ma_tel [$te][1]);//telef
		} else {
		printf("<tr><td align='left'>%s</td>", $ma_tel [$te][1]);//telef
		} //fin if color
    	printf("<td align='left'>%s</td>", $ma_tel [$te][2]);//tipo
    	printf("<td align='center'>%s</td>", $ma_tel [$te][3]);//principal
        printf("<td align='left'>%s</td></tr>", $ma_tel [$te][4]);//descripcion
		$color++;
    }
	?>
	</tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_telefono ?>

<?php if($hay_comision != 0) { //if hay_comision ?>
<tr>
<td>
	<b>Comisiones: </b><button onclick="muestra('Pcomision')" class="boton">Mostrar</button> <button onclick="oculta('Pcomision')" class="boton">Ocultar</button> 
    <table border="1" align="center" cellpadding="2" width="100%" id="Pcomision">
    <thead>
    <tr>
    <TD align="center" width="10%"><b>Cod.</b></TD>
    <TD align="center" width="85%"><b>Item</b></TD>
    <TD align="center" width="10%"><b>Comisi&oacute;n (%)</b></TD>
    </tr>
    </thead>
    <tbody class="marcafila">
    <?php
	$color = 2;
    for($co = 1; $co <= $fin_co; $co++) {
		if($color % 2 == 0) { //if color
    	printf("<tr BGCOLOR='#e2e7fa'><td align='right'>%s</td>", $ma_com [$co][1]);//cod item
		} else {
		printf("<tr><td align='right'>%s</td>", $ma_com [$co][1]);//cod item
		} //fin if color
    	printf("<td align='left'>%s</td>", $ma_com [$co][2]);//item
    	printf("<td align='right'>%s</td></tr>", number_format($ma_com [$co][3],$n_decimales));//comi
		$color++;
    }
    ?>
    </tbody>
    </table>
</td>
</tr>
<?php } //fin if hay_comision ?>

</table>

<br /><br />
<b>Registrado por: </b> <?php echo $usuario_reg; ?>

</body>
</html>
