public function find_category()
 {
     $db = new data_base(tpl_category::category(), array(tpl_category::id(), tpl_category::active(), tpl_category::name()), array(tpl_category::active() => 1));
     $data = $db->get_where();
     $w = '';
     foreach ($data as $row) {
         $w = $w . '<option value="' . $row[tpl_category::id()] . '">' . $row[tpl_category::name()] . '</option>';
     }
     return $w;
 }
 public function update_status()
 {
     $id = $_POST[tpl_category::category() . '_' . tpl_category::id()];
     $status = $_POST[tpl_category::category() . '_' . tpl_category::active()];
     $db = new data_base(tpl_category::category(), array(tpl_category::active() => $status), array(tpl_category::id() => $id));
     $results = $db->change();
     $status_data = $status == 1 ? 'active' : 'dative';
     if ($results) {
         echo json_encode(array('valid' => 1, 'title' => 'Successfully !!', 'massage' => 'I\'ve been Update ' . $status_data));
     } else {
         echo json_encode(array('valid' => 0, 'title' => 'Oops !!', 'massage' => 'Was not Update ' . $status_data . ', please try again'));
     }
 }
 public function count_category()
 {
     $db = new data_base(tpl_category::category(), array(tpl_category::id()), array(tpl_category::active() => 1));
     return count($db->get_where());
 }
?>
 + ',1)" type="checkbox"/>';
    }
    function update_status(id, value) {
        $(document).ready(function () {
            $.post('<?php 
echo site_url('admin/' . tpl_category::category() . '/update_status');
?>
',
                {
                    '<?php 
echo tpl_category::category() . '_' . tpl_category::id();
?>
': id,
                    '<?php 
echo tpl_category::category() . '_' . tpl_category::active();
?>
': value
                }, function (result) {
                    var data = JSON.parse(result);
                    if (data['valid']) {
                        $('#status_massage').html(<?php 
echo class_massage::info('title', 'massage');
?>
);
                        window.setTimeout(function () {
                            $('#status_massage').html('');
                        }, 2000);
                        var $table = $('#table');
                        $table.bootstrapTable('showLoading');
                        $table.bootstrapTable('refresh');