This commit is contained in:
heama 2023-10-13 12:59:24 +05:30
parent c1066b0053
commit 1bfb35e027
3 changed files with 45 additions and 4 deletions

View File

@ -23,7 +23,7 @@ class Books extends BaseController
$model = new BooksModel();
$model->setTable('books');
$book_details = $model->where($where)->orderBy('book_id', 'DESC')->findAll();
$book_details =$model->getnonMembershiplist($session_bid);
$data['page_name'] = 'Book Details';
$data['details'] = $book_details;
$this->render_page('book_list', $data);

View File

@ -27,4 +27,35 @@ class BooksModel extends Model
$this->db->table('book_images')->insertBatch($imgDataArray);
return $this->db->insertID(); // Note: insertID() might not be applicable for batch inserts
}
public function getnonMembershiplist($business_id)
{
$builder = $this->builder();
$builder->select('books.book_id, books.title, books.price, books.duration,books.isactive,books.publisher,books.genre,books.language,books.publication_date,category.name as name');
$builder->join('book_categories', 'book_categories.book_id = books.book_id', 'left');
$builder->join('category', 'category.id = book_categories.category_id', 'left');
$builder->where('books.business_id', $business_id);
$builder->where('category.name !=', 'membership'); // Exclude books with the category name "membership"
$query = $builder->get();
$books = [];
foreach ($query->getResult() as $row) {
$books[$row->book_id] = [
'title' => $row->title,
'price' => $row->price,
'duration' => $row->duration,
'isactive'=>$row->isactive,
'book_id'=>$row->book_id,
'publisher'=>$row->publisher,
'genre'=>$row->genre,
'language'=>$row->language,
'publication_date'=>$row->publication_date,
'name'=>$row->name
];
}
return $books;
}
}

View File

@ -9,9 +9,10 @@
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<table id="scroll-horizontal-datatable_new" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th hidden></th>
<th>Name</th>
<th>Author</th>
<th>Category</th>
@ -34,9 +35,10 @@
$edit_page_route = base_url() . "book_page/" . $row['book_id'];
?>
<tr>
<td hidden><?php echo $row['book_id']; ?></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['publisher']; ?></td>
<td><?php echo $row['genre']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['language']; ?></td>
<td><?php echo date('Y', strtotime($row['publication_date'])); ?></td>
<td> <span data-plugin="counterup"><?php echo $row['price']; ?></span></td>
@ -59,4 +61,12 @@
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->
<!-- end row-->
<script>
$(document).ready(function() {
$('#scroll-horizontal-datatable_new').DataTable({
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
// Other DataTables configuration options
});
});
</script>