<?php $this->load->view('partials/script_list.php'); ?>

<div id="page-title" class="clearfix">

        <?php 
            $realizadas = 0;
            foreach ($rows as $row): 
                $realizadas = $realizadas + $row->sesiones;
            endforeach;
        ?>

        <span style="font-size:20px;font-weight:bold;float:left;margin-top:5px;">Visitas realizadas: <?php echo $realizadas ?></span>

		<div class="item-content" style="float:right;">
			<button class="btn btn-inverse">
				<a style="text-decoration: none; color: #FFF;" href="javascript:history.go(-1);">Volver</a>
			</button>
		</div>
</div> <!-- /.page-title -->

<div class="row">
    <div class="span12">
        <div class="widget widget-table">
            <div class="widget-content">
                <div id="example_wrapper" class="dataTables_wrapper form-inline" role="grid">
                    <?php // if(isset($message)) echo $message;?>
                    <table id="list" class="table table-highlight">
                        <thead>
                            <?php foreach ($fields as $field_name => $field_display): ?>
                                <th tabindex="0" rowspan="1" colspan="1">
                                    <?php echo $field_display; ?>
                                </th>
                            <?php endforeach; ?>
                        </thead>

                        <form action="<?php echo base_url('admin/' . $dir . '/delete/'); ?>" id="delete-form" method="POST" class="form-horizontal">
                            <tbody>
                                <?php foreach ($rows as $row): ?>
                                    <?php if ($row->idProfesional_Paciente != null): ?>
                                        <?php if ($this->session->userdata('ubicacion') != 'usuarios' || $row->id != 1): ?>
                                            <tr>
                                                <?php foreach ($fields as $field_name => $field_display): ?>
                                                    <?php if ($field_display == 'Cantidad') { ?>
                                                        <td><?php echo $row->sesiones . ' visitas'; ?></td>
                                                    <?php } else { ?>
                                                        <td><a class="reporte" href="<?php echo base_url('admin/' . $dir . '/detalleLocalidad') . '/' . $row->idProfesional_Paciente; echo ($fecha_desde != '' && $fecha_hasta != '') ? '/' . $fecha_desde . '/' . $fecha_hasta : ''; ?>"> <?php echo character_limiter($row->$field_name, 120); ?></a></td>
                                                    <?php } ?>
                                                <?php endforeach; ?>
                                            </tr>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </tbody>
                        </form>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>