public function find_department()
 {
     $db = new data_base(tpl_department::department(), array(tpl_department::id(), tpl_department::active(), tpl_department::name()), array(tpl_department::active() => 1));
     $data = $db->get_where();
     $w = '';
     foreach ($data as $row) {
         $w = $w . '<option value="' . $row[tpl_department::id()] . '">' . $row[tpl_department::name()] . '</option>';
     }
     return $w;
 }
 public function update_status()
 {
     $id = $_POST[tpl_department::department() . '_' . tpl_department::id()];
     $status = $_POST[tpl_department::department() . '_' . tpl_department::active()];
     $db = new data_base(tpl_department::department(), array(tpl_department::active() => $status), array(tpl_department::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_department()
 {
     $db = new data_base(tpl_department::department(), array(tpl_department::id()), array(tpl_department::active() => 1));
     return count($db->get_where());
 }
 public function find_department()
 {
     if (isset($_POST[tpl_companies::id() . '_' . tpl_companies::companies()])) {
         $id = $_POST[tpl_companies::id() . '_' . tpl_companies::companies()];
         if (!empty($id)) {
             $db = new data_base(tpl_department::department(), array(tpl_department::id(), tpl_department::name()), array(tpl_department::active() => 1, tpl_department::id_companies() => $id));
             $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 'error';
             exit;
         }
     } else {
         echo 'error';
         exit;
     }
 }
 public function get_all_department()
 {
     if (isset($_POST['id_companies'])) {
         $id = $_POST['id_companies'];
         if (!empty($id)) {
             $db = new data_base(tpl_department::department(), array(tpl_department::id(), tpl_department::name()), array(tpl_department::id_companies() => $id, tpl_department::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_department::department() . '/update_status');
?>
',
                {
                    '<?php 
echo tpl_department::department() . '_' . tpl_department::id();
?>
': id,
                    '<?php 
echo tpl_department::department() . '_' . tpl_department::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');