<?php
$s_Border = "0";
$s_Width  = "";
?>
<?php if( $b_NoExpExcel ){ ?>
<style>
    label
    {
        margin-right: 0;
    }
    .grid
    {
        border: 1px solid #77d5f7;
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;
        border-bottom-right-radius: 5px;
        border-bottom-left-radius: 5px;
    }
    .grid th
    {
        border-color: #77d5f7;
        background-color: #0a7db1;
        font-weight: normal;
        font-size: 11px;
        font-family: Verdana,Arial,sans-serif;
        height: 24px;
        padding: 0 2px;
    }
    .grid td
    {
        border-left: 0 none;
        border-right-color: #77d5f7;
        border-right-style: solid;
        border-right-width: 1px;
        border-bottom-color: #77d5f7;
        border-bottom-style: solid;
        border-bottom-width: 1px;
        padding: 0 2px;
        /*white-space: pre;*/
        height: 22px;
        /*border: 1px solid #77d5f7;*/
    }
</style>
<?php } ?>
<?php
if( !$b_NoExpExcel )
{
    $s_Border = "1";
    $s_Width  = "10px";
}
?>
<table>
    <tr>
        <th colspan="2">FORMATO 8.1: REGISTRO DE COMPRAS</th>
    </tr>
    <tr>
        <th>Ejercicio :</th>
        <td><?=$s_Ejercicio?></td>
    </tr>
    <tr>
        <th>Periodo :</th>
        <td><?=Constantes::$a_meses[$s_Periodo]?></td>
    </tr>
    <tr>
        <th>Nombre de la Empresa:</th>
        <td><?=$o_GSS_CompaniaBN->getDescripcionCorta()?></td>
    </tr>
    <tr>
        <th>RUC:</th>
        <td><?=$o_GSS_CompaniaBN->getRuc()?></td>
    </tr>
</table>

<table class="grid" cellspacing="0" cellpadding="0" border="<?=$s_Border?>" align="center" width="" style="border-bottom: medium none; margin-top: 10px; table-layout: fixed;">
    <thead>
    <tr>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">N&deg; OPERACI&Oacute;N</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">FECHA EMISI&Oacute;N</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">FECHA VENCIMIENTO</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="3">COMPROBANTE DE PAGO</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">N&deg; COMP PAGO</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="3">INFORMACION DEL PROVEEDOR</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="2"> ADQUISICIONES GRAVADAS DESTINADAS A OPERACIONES GRAVADAS Y/O DE EXPORTACION </th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="2"> ADQUISICIONES GRAVADAS DESTINADAS A OPERACIONES GRAVADAS Y/O DE EXPORTACION Y A OPERACIONES NO GRAVADAS </th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="2">  ADQUISICIONES GRAVADAS DESTINADAS A OPERACIONES NO GRAVADAS </th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">VALOR ADQUISICIONES NO GRAVADAS</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">I.S.C</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">OTROS TRIBUTOS</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">IMPORTE TOTAL</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">N&deg; COMP PAGO NO DOMICILIADO </th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="2"> CONSTANCIA DEPOSITO DE DETRACCION </th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">TIPO DE CAMBIO</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" colspan="4">REFERENCIA DEL COMPROBANTE DE PAGO</th>

        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">TOTAL US$</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">CTA. CLIENTE</th>
        <th style="text-align:center; border-bottom: 1px solid #77d5f7; border-right: 1px solid #77d5f7;" rowspan="2">CONCEPTO</th>
    </tr>
    <tr>
        <th width="<?=$s_Width?>" style="text-align:center; border-right: 1px solid #77d5f7;">TIPO</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">SERIE O ADUANA</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">A&Ntilde;O DUA</th>

        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">TIPO</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">NUMERO</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;" nowrap="">RAZ&Oacute;N SOCIAL</th>

        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">B. IMPONIBLE</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">I.G.V.</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">B. IMPONIBLE</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">I.G.V.</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">B. IMPONIBLE</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">I.G.V.</th>

        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">NUMERO</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;" nowrap="">F. EMISION</th>

        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">FECHA</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">TIPO</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">SERIE</th>
        <th width="<?=$s_Width?>" style="text-align:center;  border-right: 1px solid #77d5f7;">NUMERO</th>
    </tr>
    </thead>
    <tbody>
        <?php
        $f_SumaTotalBaseImponible = 0;
        $f_SumaTotalImpuesto      = 0;
        $f_SumaTotalImporteTotal  = 0;
        $f_SumaTotalImporteDolar  = 0;
        ?>
        <?php foreach ( $a_CP_Obligaciones as $i_Key => $o_CP_ObligacionesBN ){ ?>
            <?php
            $f_MontoBaseImponible = $o_CP_ObligacionesBN->getMontoAfectoMN();
            $f_MontoIGV           = $o_CP_ObligacionesBN->getMontoIGVMN();
            $f_MontoTotal         = $o_CP_ObligacionesBN->getMontoTotalMN();

            $f_SumaTotalBaseImponible = $f_SumaTotalBaseImponible + $f_MontoBaseImponible;
            $f_SumaTotalImpuesto      = $f_SumaTotalImpuesto + $f_MontoIGV;
            $f_SumaTotalImporteTotal  = $f_SumaTotalImporteTotal + $f_MontoTotal;

            ?>
        <tr class="content_row">
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getObligacionesId()?></label></td>
            <td align="center" nowrap=""><label class="labelData"><?=$o_CP_ObligacionesBN->getFechaEmision()?></label></td>
            <td align="center" nowrap=""><label class="labelData"><?=$o_CP_ObligacionesBN->getFechaVencimiento()?></label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getObjectTipoDocumento()->getCodigoFiscal()?></label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getDocumentoSerie()?></label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getDocumentoNumero()?></label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getSunatTipoDocumentoProv()?></label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getProveedorDocNum()?></label></td>
            <td align="center"><label class="labelData"><?=$o_CP_ObligacionesBN->getProveedorNombre()?></label></td>
            <td align="center"><label class="labelData"><?=number_format( $f_MontoBaseImponible, 2 )?></label></td>
            <td align="center"><label class="labelData"><?=number_format( $f_MontoIGV, 2 )?></label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData"><?=number_format( $f_MontoTotal, 2 )?></label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData"><?=number_format( $o_CP_ObligacionesBN->getTipoCambio(), 2 )?></label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
            <td align="center"><label class="labelData">&nbsp;</label></td>
        </tr>
        <?php } ?>

        <tr>
            <td colspan="10" align="right"><b>TOTALES</b></td>
            <td align="center"><?=number_format( $f_SumaTotalBaseImponible, 2 )?></td>
            <td align="center"><?=number_format( $f_SumaTotalImpuesto, 2 )?></td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center"><?=number_format( $f_SumaTotalImporteTotal, 2 )?></td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
            <td align="center">&nbsp;</td>
        </tr>
    </tbody>
</table>
