public function update_status()
 {
     $id = $_POST[tpl_section::section() . '_' . tpl_section::id()];
     $status = $_POST[tpl_section::section() . '_' . tpl_section::active()];
     $db = new data_base(tpl_section::section(), array(tpl_section::active() => $status), array(tpl_section::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 find_section()
 {
     if (isset($_POST[tpl_department::id() . "_" . tpl_department::department()])) {
         $id = $_POST[tpl_department::id() . "_" . tpl_department::department()];
         if (!empty($_POST[tpl_department::id() . "_" . tpl_department::department()])) {
             $db = new data_base(tpl_section::section(), array(tpl_section::id(), tpl_section::name()), array(tpl_section::active() => 1, tpl_section::id_department() => $id));
             $data = $db->get_where();
             $w = '<option></option>';
             foreach ($data as $row) {
                 $w = $w . '<option value="' . $row[tpl_section::id()] . '">' . $row[tpl_section::name()] . '</option>';
             }
             echo $w;
         } else {
             echo 'error';
             die;
         }
     } else {
         echo 'error';
         die;
     }
 }
 public function get_all_section()
 {
     if (isset($_POST['id_department'])) {
         $id = $_POST['id_department'];
         if (!empty($id)) {
             $db = new data_base(tpl_section::section(), array(tpl_section::id(), tpl_section::name()), array(tpl_section::id_department() => $id, tpl_section::active() => 1));
             $data = $db->get_where();
             $w = '   <option></option>';
             foreach ($data as $row) {
                 $w = $w . '<option value="' . $row[tpl_department::id()] . '">' . $row[tpl_department::name()] . '</option>';
             }
             echo $w;
         } else {
             echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'error empty'));
         }
     } else {
         echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'error isset'));
     }
 }
?>
 + ',1)" type="checkbox"/>';
    }
    function update_status(id, value) {
        $(document).ready(function () {
            $.post('<?php 
echo site_url('admin/' . tpl_section::section() . '/update_status');
?>
',
                {
                    '<?php 
echo tpl_section::section() . '_' . tpl_section::id();
?>
': id,
                    '<?php 
echo tpl_section::section() . '_' . tpl_section::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');