<?php if( $s_Tipo == "BUSCAR" ){ ?>
    <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.datatables.net/responsive/2.2.5/css/responsive.bootstrap4.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.datatables.net/fixedheader/3.1.7/css/fixedHeader.dataTables.min.css" />

    <!--<link rel="stylesheet" type="text/css" media="screen" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css" />-->

    <script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.5/js/dataTables.responsive.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.5/js/responsive.bootstrap4.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/fixedheader/3.1.7/js/dataTables.fixedHeader.min.js"></script>

    <style type="text/css">
        /*
        #example_wrapper .row
        {
            margin-right: 0;
            margin-left: 0;
        }
        table.dataTable tbody tr:hover
        {
           background-color: #DAE6FE !important;;
        }
        */
        .table td, .table th
        {
            /*padding: 8px;*/
            font-size: 13px;
        }
        th { white-space: nowrap; }

    </style>
<?php } ?>

<?php if( $s_Tipo == "PDF" ){ ?>
    <html>
    <head>
        <style type="text/css">
            @page
            {
                size: A4 landscape;
                margin: 0cm 0cm;
            }

            header
            {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 10px;
            }

            footer
            {
                bottom: 0cm;
                left: 0cm;
                right: 0cm;
            }

            body
            {
                margin : 0.5cm;
                /*margin-top: 1cm;*/
                font-family: Arial, Helvetica, sans-serif;
                font-size: 10px;
                /*margin-top: 0.5cm;
                margin-left: 0.5cm;
                margin-right: 0.5cm;
                margin-bottom: 0.5cm;*/
            }

            table
            {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 10px;
            }

            .new-page{ page-break-before: always; }

            #watermark
            {
                position: fixed;
                opacity: 0.2;
                /**
                    Establece una posición en la página para tu imagen
                    Esto debería centrarlo verticalmente
                **/
                bottom:   6cm;
                left:     11cm;

                /** Cambiar las dimensiones de la imagen **/
                width:    8cm;
                height:   8cm;

                /** Tu marca de agua debe estar detrás de cada contenido **/
                z-index:  -1000;
            }

        </style>
    </head>

    <body>
    <div id="watermark">
        <img src="web/images/logo/<?=$o_GSS_CompaniaBN->getRuc()?>_black.jpg" height="100%" width="100%" >
    </div>

    <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0"  >
        <tr>
            <td style="width: 30%">

                <div style="">
                    <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0"  >
                        <tr>
                            <td style=""> <img src="web/images/logo/<?=$o_GSS_CompaniaBN->getRuc()?>.jpg" style="width: 260px; height: 70px;" > </td>
                        </tr>
                    </table>
                </div>
            </td>
            <td style="width: 38%">
                <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0" >
                    <tr>
                        <td style="font-size: 10px;" align="center">
                            <label><b><?=$o_GSS_CompaniaBN->getDireccionComun()?></b></label>
                        </td>
                    </tr>
                    <tr>
                        <td style="font-size: 10px;" align="center">
                            <label><?=$o_GSS_CompaniaBN->getDireccionAdicional()?></label>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 30%;">

                <div style=" vertical-align: top; background-color: #EDEDED; padding: 5px;
                        border-top-right-radius: 5px; border-top-left-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;
                        border: 1px solid #B9B5B5;
                        ">
                    <div style="text-align: center;"><label style="font-size: 18px; font-weight: bold;">RUC <?=$o_GSS_CompaniaBN->getRuc()?></label></div>
                    <div style="text-align: center;"><label style="font-size: 18px; font-weight: bold;">VALORIZADO REPARACION</label></div>
                    <!--<div style="text-align: center;"> <label style="font-size: 18px; font-weight: bold;">ss</label> </div>-->
                </div>

            </td>
        </tr>
    </table>

    <div style="border-top-right-radius: 5px; border-top-left-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; margin-top: 10px;
                border: 1px solid #B9B5B5; padding: 5px; ">
        <table style="width: 100%;" border="0" cellpadding="1" cellspacing="0">
            <tr>
                <td style="width: 8%; font-weight: bold;" align="left">PROYECTO: </td>
                <td style="width: 25%;"><?=$s_NombreProyecto ?></td>
            </tr>
        </table>
    </div>
    <?php } ?>

    <?php if( $a_DataRs ){ ?>

        <?php
        $f_SumaTotalFinal = 0;
        $f_SumaCantiFinal = 0;
        ?>
        <?php foreach ( $a_DataRs as $s_KeyId => $a_Rows ) { ?>
            <div style="border-top-right-radius: 5px; border-top-left-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; margin-top: 10px;
                border: 1px solid #B9B5B5; padding: 5px; ">

                <table id="example" class="table table-striped table-bordered" style="width:100%" border="0">
                    <thead>
                    <tr class="table-primary" style="background-color: #EEEEEE; border-bottom: 1px solid; border-top: 1px solid; border-color: #B9B5B5;">
                        <th scope="col" style="text-align: center;" > &nbsp; </th>
                        <th scope="col" style="text-align: center;" > FECHA </th>
                        <th scope="col" style="text-align: center;" > TIPO </th>
                        <th scope="col" style="text-align: center;" > ESTADO </th>
                        <th scope="col" style="text-align: center;" > COMENTARIO </th>
                        <th scope="col" style="text-align: center;" > DOCUMENTO </th>
                        <th scope="col" style="text-align: center;" > COD </th>
                        <th scope="col" style="text-align: center;" > DESCRIPCION </th>
                        <th scope="col" style="text-align: center;" > CANT </th>
                        <th scope="col" style="text-align: center;" rowspan=""> PRECIO </th>
                        <th scope="col" style="text-align: center;" rowspan=""> TOTAL </th>
                        <th scope="col" style="text-align: center;" rowspan=""> FACTURACION </th>
                    </tr>
                    </thead>

                    <tbody>
                    <?php
                    $f_CantidadTotal = 0;
                    $f_SumaTotal     = 0;
                    ?>
                    <?php foreach ( $a_Rows as $s_KeyId => $a_Data ) { ?>
                        <?php
                        $s_Tipo = $a_Data['Tipo'];
                        $f_Total = $a_Data['Total'];
                        ?>
                        <tr>
                            <td align="center" nowrap=""> <?=$s_KeyId?> </td>
                            <td align="center" nowrap=""> <?=$a_Data['FechaInicioAlq']?> </td>
                            <td align="center" nowrap=""> <?=$s_Tipo?> </td>
                            <td align="center" nowrap=""> <?=$a_Data['EstadoDesc']?> </td>
                            <td align="center" nowrap=""> <?=$a_Data['ComentarioDevolucion']?> </td>
                            <td align="center" nowrap=""> <?=$a_Data['Documento']?> </td>
                            <td align="center" nowrap=""> '<?=$a_Data['IdItem']?> </td>
                            <td align="center" nowrap=""> <?=$a_Data['Descripcion']?> </td>
                            <td align="center" nowrap=""> <?=number_format( $a_Data['Cantidad'], 0 )?> </td>
                            <td align="center" nowrap=""> <?=number_format( $a_Data['PrecioUnitarioAlq'], 2 )?> </td>
                            <td align="center" nowrap="">
                                <?php if( $a_Data['EstadoFacturacion'] != "R" ){ ?>
                                    <?=number_format( $a_Data['Total'] , 2 )?>
                                <?php }else{ ?>
                                    0
                                <?php } ?>
                            </td>
                            <td align="center" nowrap=""> <?=$a_Data['EstadoFacturacionDesc']?> </td>
                        </tr>
                        <?php
                        if( $a_Data['EstadoFacturacion'] != "R" )
                        {
                            $f_CantidadTotal = $f_CantidadTotal + $a_Data[ 'Cantidad' ];
                            $f_SumaTotal     = $f_SumaTotal + $f_Total;
                        }
                        ?>
                    <?php } ?>
                    </tbody>

                    <tbody>
                    <tr>
                        <td colspan="8" style="text-align: right;">SALDO:</td>
                        <td align="center" nowrap=""> <?=$f_CantidadTotal?> </td>
                        <td colspan="1" style="text-align: right;">SUB-TOTAL:</td>
                        <td align="center" nowrap=""> <?=number_format( $f_SumaTotal, 2 )?> </td>
                        <td>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>

            </div>
            <br>

            <?php
            $f_SumaTotalFinal = $f_SumaTotalFinal + $f_SumaTotal;
            $f_SumaCantiFinal = $f_SumaCantiFinal + $f_CantidadTotal;
            ?>
        <?php } ?>

        <table id="example" class="table table-striped table-bordered" style="width:100%" border="0">
            <thead>
            <tr>
                <td colspan="8" style="text-align: right;">SALDO:</td>
                <td align="center" nowrap=""> <?=$f_SumaCantiFinal?> </td>
                <td colspan="4" style="text-align: right;">SUB-TOTAL:</td>
                <td align="center" nowrap=""> <?=number_format( $f_SumaTotalFinal, 2 )?> </td>
            </tr>
            </thead>
        </table>
        <br>

    <?php }else{ ?>
        <?=pr( "No se encontro resultados." ) ?>
    <?php } ?>



    <?php if( $s_Tipo == "BUSCAR" ){ ?>
        <script type="text/javascript">
            /*
            configurarDataTable = function()
            {
                $( '#example' ).DataTable
                (
                    {
                        language:       { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" },
                        responsive:     false,
                        searching:      false,
                        info:           false,
                        lengthChange:   false,
                        paging:         false,
                        dom:            'lrtip',
                        fixedHeader:
                            {
                                header: true,
                                footer: true
                            }
                    }
                );
            }

            setTimeout
            (
                function ()
                {
                    configurarDataTable();
                },
                1000
            );
            */
        </script>
    <?php } ?>

    <?php if( $s_Tipo == "BUSCAR" ){ ?>
    </body>
    </html>
<?php } ?>