<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class M_slider extends Main_model {

    function __construct() {
        parent::__construct();
        $this->table = array(
            'name'  => 'tbl_slider',
            'coloumn'               => array(
                    'slider_id'   => array('id'=>'slider_id', 'label'=>'ID', 'idkey'=>true, 'visible'=>false, 'field_visible'=>true, 'format'=>'HIDDEN'),
                    'slider_name'      => array('id'=>'slider_name', 'label'=>'Slider Name', 'idkey'=>false, 'visible'=>true, 'field_visible'=>true,  'format'=>'TEXT'),
                    'slider_publish'      => array('id'=>'slider_publish', 'label'=>'Date Publish', 'idkey'=>false, 'visible'=>true, 'field_visible'=>true,  'format'=>'TEXT'),
                    'slider_expire'      => array('id'=>'slider_expire', 'label'=>'Date Expired', 'idkey'=>false, 'visible'=>true, 'field_visible'=>true,  'format'=>'TEXT'),
                    'slider_images'      => array('id'=>'slider_images', 'label'=>'Image', 'idkey'=>false, 'visible'=>false, 'field_visible'=>true,  'format'=>'FILE'),
            ), 
            'join'  =>array(
                
            ),    
            'where'         => array(),
            'keys'          => 'slider_id',
            'option_name'   => ''
        );                
    }
    
    function fields()
    {
        $data = array();
        return $data;
    }
    
    
    function getlist($params)
    {
        
        $list = $this->getListData($params);
        $nomor = $params['start'];
        $data['records'] = array();
        foreach($list['records']->result() as $row):
            $actions = '';
            $actions .= '<a data-id="'.$row->slider_id.'" data-target="form_modal_slider" data-toggle="modal" class="btn btn-xs btn-success btn-editable"><i class="glyphicon glyphicon-edit"></i>Ubah</a>';
            $actions .= '<a data-id="'.$row->slider_id.'" class="btn btn-xs btn-danger btn-removable"><i class="glyphicon glyphicon-trash"></i>Hapus</a>';
            
            $data['records'][] = array(
                $nomor+1,
                $row->slider_name,
                $row->slider_publish,
                $row->slider_expire,
                $actions
            );
            $nomor++;
        endforeach;
        $data['total']  = $list['total'];
        $data['total_filter']  = $list['total_filter'];
        
        return $data;
    }
    
}  