<table id="list" class="table table-highlight">

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

    <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($this->session->userdata('ubicacion') != 'usuarios' || $row->id != 1): ?>
                <tr data-id="<?php echo $row->id; ?>">

                    <?php foreach ($fields as $field_name => $field_display): ?>

                        <?php if ($field_display == 'Imagen') { ?>

                            <td>

                                <a class="sub_edit"
                                   href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>"><img
                                        class="min-back"
                                        src="<?php echo base_url('assets/archivos/' . $dir . '/original/' . $row->foto); ?>"
                                        alt="" style="opacity: 1;"></a>

                            </td>

                        <?php } else if ($field_display == 'Fecha') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php
                                    $row->$field_name = date("d-m-Y", strtotime($row->$field_name));
                                    echo $row->$field_name;
                                    ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Localidad') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php
                                        if($row->$field_name == null):
                                            echo 'Sin localidad';
                                        else:
                                            echo $row->$field_name;
                                        endif;
                                    ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Domicilio') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php
                                        $domicilio = explode(",", $row->$field_name);
                                        if(isset($row->piso) && $row->piso != ''):
                                            echo $domicilio['0']. " Piso: " .$row->piso;
                                        else:
                                            echo $domicilio['0'];
                                        endif;
                                    ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Principal' || $field_display == 'Habilitado' || $field_display == 'Destacado' || $field_display == 'Newsletter' || $field_display == 'Venta' || $field_display == 'Inmobiliario' || $field_display == 'Inversiones') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php if ($row->$field_name == 1) echo 'Si'; else echo 'No'; ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Creado el' || $field_display == 'Ultimo ingreso') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php echo date("d-m-Y H:i:s", $row->$field_name); ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Creado' || $field_display == 'Modificado') { ?>

                            <td>

                                <a class="sub_edit" href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                    <?php echo date("d-m-Y H:i:s", strtotime($row->$field_name)); ?>
                                </a>

                            </td>

                        <?php } else if ($field_display == 'Sucursal') { ?>

                            <td>
                                <?php if ($row->sucursal == "Master") { ?>
                                    <a class="sub_edit"
                                       href="<?php echo site_url('admin/' . $dir . '/edit/' . $row->id); ?>">
                                        <?php
                                        echo 'Cuenta Master';
                                        ?>
                                    </a>
                                <?php } else { ?>
                                    <a href="<?php echo site_url('admin/' . $dir . '/edit/') . $row->id; ?>"><?php echo character_limiter($row->$field_name, 120); ?></a>
                                <?php } ?>

                            </td>

                        <?php } else { ?>

                            <td>

                                <a href="<?php echo site_url('admin/' . $dir . '/edit/') . $row->id; ?>"><?php echo character_limiter($row->$field_name, 120); ?></a>

                            </td>

                        <?php } ?>

                        <?php

                    endforeach; ?>

                </tr>
            <?php endif; ?>
        <?php endforeach; ?>

        </tbody>

    </form>

</table>