<?php $titulocabecera = "Colaboradores";if(SYS_ADMIN_PLANTILLA){ ?>
    <!-- begin PAGE TITLE ROW -->
    <div class="row">
        <div class="col-lg-12">
            <div class="page-title">
                <h1><?php echo $titulocabecera; ?></h1>
                <ol class="breadcrumb">
                    <li><i class="fa fa-dashboard"></i>  <a href="<?php echo $this->createUrl('dashboard/'); ?>">Dashboard</a></li>
                    <li class="active"><?php echo $titulocabecera; ?></li>
                </ol>
            </div>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
    <!-- end PAGE TITLE ROW -->
<?php }else{ ?>
<!-- begin PAGE TITLE ROW -->
<div class="row">
    <div class="col-lg-12">
        <h3 class="page-title" style="margin: 0 0 20px;"><?php echo $titulocabecera; ?><small></small></h3>
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><i class="fa fa-dashboard"></i><a href="<?php echo $this->createUrl('dashboard/'); ?>">Inicio</a><i class="fa fa-angle-right"></i></li>
                <li><span><?php echo $titulocabecera; ?></span></li>
            </ul>
        </div>
        <?php } ?>
        <a href="<?php echo $this->createUrl('create');?>"><button class="btn btn-green"><i class="fa fa-plus" style="margin-right:8px;"></i>Nuevo</button></a>
        <div style = "margin:15px;"></div>
        <div class="portlet portlet-default">
            <div class="portlet-heading">
                <div class="portlet-title"><h4><?php echo $titulocabecera; ?></h4></div>
                <div class="clearfix"></div>
            </div>
            <div class="portlet-body">
                <div class="table-responsive">
                    <table id="example-table" class="table table-striped table-bordered table-hover table-green">
                        <thead>
                        <tr>
                            <th><?php echo Colaboladores::model()->getAttributeLabel('nombre_completo') ?></th>
                            <th><center>Tipo Colaborador</center></th>
                            <th><center>Activo</center></th>
                            <th><center>Opciones</center></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        class baseDeDatos{
                            public function connectDBBDD(){
                                $servername = "localhost";
                                $username = "root";
                                $password = "PkJXPQFykKLmS3cWhqmZKNYE";
                                $dbname =   "PPD";
                                $conn = new mysqli($servername, $username, $password, $dbname);
                                $conn->set_charset("utf8");
                                if ($conn->connect_error) {
                                    die("Connection failed: " . $conn->connect_error);
                                }
                                return $conn;
                                return 2;
                            }
                            public function readFieldDB($tbl, $id){
                                $conn = $this->connectDBBDD();
                                $res = mysqli_query($conn,"SELECT nombre FROM ".$tbl." WHERE id = ".$id."");
                                $conn->close();
                                return mysqli_fetch_array($res)[0];
                            }
                            public function readtableDB($tbl){
                                $conn = $this->connectDBBDD();
                                $res = mysqli_query($conn,"SELECT * FROM ".$tbl.";");
                                while($cRow = mysqli_fetch_array($res)){
                                    $info[] = $cRow[0];
                                }
                                $conn->close();
                                //echo "<pre>";print_r($info);echo "</pre>";
                                return $info;
                            }
                            public function createDB($tbl, $clmn, $long){
                                /*$conn = $this->connectDBBDD();
                                $sql = 'CREATE TABLE IF NOT EXISTS '.$tbl.'('.$clmn.' VARCHAR('.$long.') NOT NULL);';
                                if ($conn->query($sql) !== TRUE) {
                                    echo "Error creating database: " . $conn->error;
                                    //echo "Database created successfully";
                                }
                                $conn->close();
                                return true;*/
                            }
                            public function insertDB($tbl, $clmn, $value){
                                /*$conn = $this->connectDBBDD();
                                $sql = 'INSERT INTO '.$tbl.'('.$clmn.') values("'.$value.'")';
                                if ($conn->query($sql) !== TRUE) {
                                    echo "Error: " . $sql . "<br>" . $conn->error;
                                   //echo "New record created successfully";
                                }
                                $conn->close();
                                return true;*/
                            }
                        }
                        $baseDeDatos = new baseDeDatos(); ?>
                        <?php if(isset($model) && !empty($model)){
                            foreach ($model as $item) { ?>
                                <tr>
                                    <td><?php echo $item->nombre_completo?></td>
                                    <td><?php echo $baseDeDatos -> readFieldDB("tbl_tipo_colaboladores",$item->tipo); ?></td>
                                    <td>
                                        <center>
										<span  class="checkslide cambiarActivo"
                                               url="<?php echo $this->createUrl('activo',array('id'=>$item->id_colaborador)) ?>"
                                               name="<?php echo $item->nombre_completo; ?>">
											<input type="checkbox" <?php echo ($item->activo == 1)? 'checked': '';?>>
											<label data-on="SI" data-off="NO"></label>
										</span>
                                        </center>
                                    </td>
                                    <td class="center">
                                        <center>
                                            <!--a href="<?php #echo $this->createUrl('/catalogoGalerias/create',array('id'=>$item->id_producto)) ?>" style="margin-right:15px;">
											<span><i class="fa fa-picture-o"></i></span>
										</a-->
                                            <a href="<?php echo $this->createUrl('update',array('id'=>$item->id_colaborador)) ?>" style="margin-right:15px;"><span><i class="fa fa-pencil"></i></span></a>
                                            <a href="<?php echo $this->createUrl('view',array('id'=>$item->id_colaborador)) ?>" style="margin-right:15px;"><span><i class="fa fa-eye"></i></span></a>
                                            <a  href="javaScript:void(0)"
                                                url="<?php echo $this->createUrl('delete',array('id'=>$item->id_colaborador)) ?>"
                                                class="eliminarRegistro"
                                                name="<?php echo $item->nombre_completo ?>"
                                                data-text = "<?php echo $item->nombre_completo ?>"  >
                                                <span><i class="fa fa-trash"></i></span>
                                            </a>
                                        </center>
                                    </td>
                                </tr>
                            <?php }
                        } ?>
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
            </div>
            <!-- /.portlet-body -->
        </div>
        <!-- /.portlet -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<!-- end PAGE TITLE ROW -->