<div class="row-fluid">
<div class="span12">
    <form action="Medico_receta_Excel" method="POST">        
       
       <input type="hidden" name="fecha1" value="<?php echo $fecha1; ?>" /> 
       <input type="hidden" name="fecha2" value="<?php echo $fecha2; ?>" /> 
       <input type="hidden" name="cveMedico" value="<?php echo $cveMedico; ?>" />

       <button type="submit" class="btn btn-success btn-app"><i class="icon-save"></i>Excel</button>       
     
    </form>


<h3><?php echo $cveMedico . ' - ' . $medico . ' Recetas emitidas: '. $recetas;?></h3>

    <table id="detalle" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th>#</th>
                <th>FECHA</th>
                <th>FOLIO</th>
                <th>PROGRAMA</th>
                <th>CLAVE PACIENTE</th>
                <th>PACIENTE</th>
                <th>CLAVE</th>
                <th>DESCRIPCIOM</th>
                <th>REQUERIDAS</th>                
             </tr>
        </thead>
        <tbody>
            <?php 
            
            $req = 0;
            $num = 0;

            foreach($query->result() as $row){
            $num++;    
                                
                                                              
            ?>
            <tr>
                <td><?php echo $num; ?></td>
                <td><?php echo $row->fecha; ?></td>
                <td><?php echo ($row->folioreceta); ?></td>
                <td><?php echo ($row->programa); ?></td>
                <td><?php echo ($row->cvepaciente); ?></td>
                <td><?php echo ($row->paciente); ?></td>
                <td><?php echo ($row->cvearticulo); ?></td>
                <td><?php echo ($row->completo); ?></td>
                <td style="text-align: right;"><?php echo number_format($row->canreq, 0); ?></td>
                </tr>
                
                
            <?php 
            
            $req = $req + $row->canreq;

            
            }
            
            ?>
        </tbody>
        <tfoot>
            <tr>
                <td style="text-align: right;" colspan="8">Totales</td>
                <td style="text-align: right;" id="req"><?php echo number_format ($req, 0); ?></td>
            </tr>
            <tr>
                <th>#</th>
                <th>Fecha</th>
                <th>Folio</th>
                <th>Programa</th>
                <th>Clave Paciente</th>
                <th>Paciente</th>
                <th>Clave</th>
                <th>Descripcion</th>
                <th>Requeridas</th>
             </tr>
        </tfoot>
    </table>

    <h3><?php echo $cveMedico . ' - ' . $medico . ' Recetas emitidas: '. $recetas;?></h3>
    <table id="recetas" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th>#</th>
                <th>FECHA</th>
                <th>PRIMER CONSULTA</th>
                <th>ULTIMA CONSULTA</th>
                <th>TIEMPO CONSULTANDO</th>
                <th>CONSULTAS</th>
                <th>MINUTOS POR CONSULTA</th>            
             </tr>
        </thead>
        <tbody>
            <?php 
            
            $cons = 0;
            $num = 0;

            foreach($query2->result() as $row){
            $num++;    
                                
                                                              
            ?>
            <tr>
                <td><?php echo $num; ?></td>
                <td><?php echo $row->fecha; ?></td>
                <td><?php echo ($row->primera); ?></td>
                <td><?php echo ($row->ultima); ?></td>
                <td><?php echo ($row->tiempo_consutas); ?></td>
                <td style="text-align: right;"><?php echo number_format($row->consultas,0); ?></td>
                <td style="text-align: right;"><?php echo number_format($row->minutos,2); ?></td>            
            </tr>
                
                
            <?php 
            
            $cons = $cons + $row->consultas;

            
            }
            
            ?>
        </tbody>
        <tfoot>
            <tr>
                <td 
                    style="text-align: 
                    right;" colspan="6">
                    Total recetas emitidas:  <?php echo number_format ($cons, 0); ?> 
                    Promedio del periodo:  <?php echo number_format ($cons/$num, 2); ?> 
                    
                </td>
                
                <td></td>                
            </tr>
            <tr>
                <th>#</th>
                <th>FECHA</th>
                <th>PRIMER CONSULTA</th>
                <th>ULTIMA CONSULTA</th>
                <th>TIEMPO CONSULTANDO</th>
                <th>CONSULTAS</th>
                <th>MINUTOS POR CONSULTA</th> 
             </tr>
        </tfoot>
    </table>    
    

</div>
</div>

<div class="row-fluid">
<div class="span12">


</div>
</div>
