Postingan lainnya
tidak mau ngeload halaman pada folder view ( codeigniter )
ada yg bisa bantu url udah bener, model udah bener, controller udah bner.. tapi gak mau ngeload halaman yg dinginkan...malah masih dihalaman dasbord
penampakan... terima kasih
header (menu)
<li class="treeview">
<a href="<?php echo base_url(); ?>kategoriobat" >
<i class="fa fa-users"></i>
<span>Manajemen kategori obat</span>
</a>
</li>
model
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class kategoriobat_model extends CI_Model
{
function kategoriobatCount($searchText = '')
{
$this->db->select('BaseTbl.id_kategori, BaseTbl.kategori, Role.role');
$this->db->from('tbl_kategori as BaseTbl');
$this->db->join('tbl_roles as Role', 'Role.roleId = BaseTbl.roleId','left');
if(!empty($searchText)) {
$likeCriteria = "(BaseTbl.kategori LIKE '%".$searchText."%')";
$this->db->where($likeCriteria);
}
$this->db->where('BaseTbl.isDeleted', 0);
$this->db->where('BaseTbl.roleId !=', 1);
$query = $this->db->get();
return count($query->result());
}
function kategoriobat($searchText = '', $page, $segment)
{
$this->db->select('BaseTbl.id_kategori, BaseTbl.kategori, Role.role');
$this->db->from('tbl_kategori as BaseTbl');
$this->db->join('tbl_roles as Role', 'Role.roleId = BaseTbl.roleId','left');
if(!empty($searchText)) {
$likeCriteria = "(BaseTbl.kategori LIKE '%".$searchText."%')";
$this->db->where($likeCriteria);
}
$this->db->where('BaseTbl.isDeleted', 0);
$this->db->where('BaseTbl.roleId !=', 1);
$this->db->limit($page, $segment);
$query = $this->db->get();
$result = $query->result();
return $result;
}
}
controller
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
class kategoriobat extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('kategoriobat_model');
$this->isLoggedIn();
}
public function index()
{
$this->global['pageTitle'] = 'CodeInsect : Dashboard';
$this->loadViews("dashboard", $this->global, NULL , NULL);
}
function kategoriobat()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$this->load->model('kategoriobat_model');
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
$this->load->library('pagination');
$count = $this->kategoriobat_model->kategoriobatCount($searchText);
$returns = $this->paginationCompress ( "kategoriobat/", $count, 5 );
$data['kategoriobatRecords'] = $this->kategoriobat_model->kategoriobat($searchText, $returns["page"], $returns["segment"]);
$this->global['pageTitle'] = 'CodeInsect : kategoriobat';
$this->loadViews("kategoriobat", $this->global, $data, NULL);
}
}
function pageNotFound()
{
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>
view
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Kategori Obat
<small>Add, Edit, Delete</small>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12 text-right">
<div class="form-group">
<a class="btn btn-primary" href="<?php echo base_url(); ?>addNew"><i class="fa fa-plus"></i> Add New</a>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title">Kategori Obat List</h3>
<div class="box-tools">
<form action="<?php echo base_url() ?>kategoriobat" method="POST" id="searchList">
<div class="input-group">
<input type="text" name="searchText" value="<?php echo $searchText; ?>" class="form-control input-sm pull-right" style="width: 150px;" placeholder="Search"/>
<div class="input-group-btn">
<button class="btn btn-sm btn-default searchList"><i class="fa fa-search"></i></button>
</div>
</div>
</form>
</div>
</div><!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tr>
<th>Id</th>
<th>kategori obat</th>
<th>Role</th>
<th class="text-center">Actions</th>
</tr>
<?php
if(!empty($kategoriobatRecords))
{
foreach($kategoriobatRecords as $record)
{
?>
<tr>
<td><?php echo $record->id_kategori ?></td>
<td><?php echo $record->kategori ?></td>
<td><?php echo $record->role ?></td>
<td class="text-center">
<a class="btn btn-sm btn-info" href="<?php echo base_url().'editOld/'.$record->id_kategori; ?>"><i class="fa fa-pencil"></i></a>
<a class="btn btn-sm btn-danger deletekategori" href="#" data-id_kategori="<?php echo $record->id_kategori; ?>"><i class="fa fa-trash"></i></a>
</td>
</tr>
<?php
}
}
?>
</table>
</div><!-- /.box-body -->
<div class="box-footer clearfix">
<?php echo $this->pagination->create_links(); ?>
</div>
</div><!-- /.box -->
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('ul.pagination li a').click(function (e) {
e.preventDefault();
var link = jQuery(this).get(0).href;
var value = link.substring(link.lastIndexOf('/') + 1);
jQuery("#searchList").attr("action", baseURL + "kategoriobat/" + value);
jQuery("#searchList").submit();
});
});
</script>
1
3 Jawaban:
mungkin di letak kesalahannya pada settingan base_url nya gak gan
0
perhatikan di base_url. yang agan buat lokasi folder js nya tidak didalam kurung base_url. kemungkinan kesalahan disana. coba cek coding dibawah
0
thanks u gan.. udah fix, ternyata harus tambahin di routernya
0