BBnepal-Accounts/application/views/inventory/item-list.php

520 lines
20 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<style>
.bootstrap-select>.dropdown-toggle.bs-placeholder,
.bootstrap-select>.dropdown-toggle.bs-placeholder:hover,
.bootstrap-select>.dropdown-toggle.bs-placeholder:focus,
.bootstrap-select>.dropdown-toggle.bs-placeholder:active {
height: 38px;
}
.bootstrap-select .dropdown-toggle .filter-option-inner {
margin-top: 4px;
margin-left: 4px;
}
.form-group .bootstrap-select>.dropdown-toggle {
height: 38px;
}
</style>
<div class="wraper responsive-width">
<main>
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<div class="subsec_sec">
<div class="subject_r subject_r_lng">
<div class="subject_lsec">
<div class="mb-4">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?= base_url() . 'admin/inventory/dashboard' ?>">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page"><?= $title ?></li>
</ol>
</nav>
</div>
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<p><b> Success !</b> <?php echo $this->session->flashdata('success') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<?php if ($this->session->flashdata('danger')) { ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<p><b> Error !</b> <?php echo $this->session->flashdata('danger') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<div class="d-flex justify-content-end mb-3 small">
<b style="font-weight: 500">Quick Links:</b>
<a href="<?= base_url() ?>admin/inventory/book-publication" class="text-primary px-1"> Publications </a> |
<a href="<?= base_url() ?>admin/inventory/item-categories" class="text-primary px-1"> Item Categories </a> |
<a href="<?= base_url() ?>admin/inventory/items" class="text-primary px-1"> Items </a> |
<a href="<?= base_url() ?>admin/inventory/item-stocks" class="text-primary px-1"> Stocks </a> |
<a href="<?= base_url() ?>admin/inventory/add-edit-new-entry/0" class="text-primary px-1"> New Purchase Entry </a> |
<a href="<?= base_url() ?>admin/inventory/add-new-sales-record/0" class="text-primary px-1"> New Sales Entry </a>
</div>
<div class="row justify-content-center ">
<!-- <div class="row w-100 mb-4">
<div class="col">
<div class="float-right ">
<a class="btn btn-sm btn-outline-success" href="<?= base_url() ?>admin/inventory/item-stocks">Stocks</a>
<a class="btn btn-sm btn-outline-success" href="<?= base_url() ?>admin/inventory/item-categories">Categories</a>
</div>
</div>
</div> -->
<div class="clearfix"></div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Add New Item</h5>
<form method="post" action="<?php echo base_url(); ?>admin/inventory/items" enctype="multipart/form-data">
<div class="form-group mb-0">
<label class="has-float-label">
<input type="text" id="title" name="title" class=" form-control" placeholder='Enter item title' required>
<span>Item Title</span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<select id="item_category" class="form-control selectpicker" name="item_category" data-live-search="true" required>
<option value="">
Select Category
</option>
<?php
foreach ($inventory_categories as $ic_key => $ic_value) {
?>
<option value="<?= $ic_value['id'] ?>">
<?= $ic_value['title'] ?>
</option>
<?php
}
?>
</select>
<span>Category <b class="text-danger">*</b></span>
</label>
</div>
<div class="form-group mt-3" id="course-section">
<label class="has-float-label">
<select id="course_id[]" class="form-control selectpicker" name="course_id[]" multiple data-live-search="true">
<option value="">
Select Course
</option>
<?php
foreach ($courses as $c_key => $course) {
?>
<option value="<?= $course['id'] ?>">
<?= $course['course_name'] ?>
</option>
<?php
}
?>
</select>
<span>Course <b class="text-danger">*</b></span>
</label>
</div>
<div class="form-group mt-3" id="book-detail-section">
<label class="has-float-label">
<select id="publication" class="form-control selectpicker" name="publication" data-live-search="true">
<option value="">
Select Publication
</option>
<?php
foreach ($book_publications as $p_key => $book_publication) {
?>
<option value="<?= $book_publication['id'] ?>">
<?= $book_publication['title'] ?>
</option>
<?php
}
?>
</select>
<span>Publication <b class="text-danger">*</b></span>
</label>
<label class="has-float-label mt-3">
<input type="text" id="edition" name="edition" class=" form-control" placeholder='Enter book edition'>
<span>Edition</span>
</label>
<label class="has-float-label mt-3">
<input type="text" id="isbn" name="isbn" class=" form-control" placeholder='Enter book isbn'>
<span>ISBN</span>
</label>
</div>
<div class="form-group mt-3" id="variant-section">
<label class="has-float-label">
<select id="variant" class="form-control selectpicker" name="variant[]" data-live-search="true" multiple>
<option value="">
Select Variant
</option>
<?php
foreach ($inventory_variants as $iv_key => $inventory_variant) {
?>
<option value="<?= $inventory_variant['id'] ?>">
<?= $inventory_variant['title'] ?>
</option>
<?php
}
?>
</select>
<span>Item Variant <b class="text-danger">*</b></span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<select id="item_measurement_unit" class="form-control selectpicker" name="item_measurement_unit" data-live-search="true">
<option value="">
Select Measurement Unit
</option>
<?php
foreach ($inventory_measurements as $im_key => $im_value) {
?>
<option value="<?= $im_value['id'] ?>">
<?= $im_value['title'] ?>
</option>
<?php
}
?>
</select>
<span>Measurement Unit <b class="text-danger"></b></span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<textarea class="form-control" name="description" rows="4" cols="50"></textarea>
<span>Item Description</span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<input type="file" id="photo" name="photo" class=" form-control" style="padding: 0.75rem 0.75rem;">
<span>Item Photo</span>
</label>
</div>
<div class="mt-4 w-100">
<input type="submit" name="addItem" id="addItem" class="btn btn-sm btn-success w-100" value="Add">
</div>
</form>
</div>
</div>
</div>
<div class="col-md-8 pl-0">
<div class="col-md-12 border rounded py-3">
<!-- -->
<table id="tbl" class="display table-responsive">
<thead>
<tr>
<th class="textCenter">S.No</th>
<th class="textCenter">Title</th>
<th class="textCenter">Category</th>
<th class="textCenter">Class</th>
<th class="textCenter">Measurement Unit</th>
<th class="textCenter">Is Active</th>
<th class="textCenter">Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($inventory_items as $i_key => $i_value) {
echo '<pre>';
print_r($i_value);
?>
<tr>
<td><?= $i_key + 1 ?></td>
<td class="text-left"><?= $i_value['title'] ?></td>
<td class="text-left">
<?php
if ($i_value['category_id'] != 0) {
foreach ($inventory_categories as $ic_key => $ic_value) {
if ($ic_value['id'] == $i_value['category_id']) {
echo $ic_value['title'];
}
}
} else {
echo '-';
}
?>
</td>
<td class="text-left"><?= $i_value['title'] ?></td>
<td class="text-left">
<?php
if ($i_value['measurement_id'] != 0) {
foreach ($inventory_measurements as $im_key => $im_value) {
if ($im_value['id'] == $i_value['measurement_id']) {
echo $im_value['title'];
}
}
} else {
echo '-';
}
?>
</td>
<td>
<?= ucfirst($i_value['is_active']) ?>
</td>
<td>
<a href="<?= base_url() . 'admin/inventory/view-item-detail/' . $i_value['id'] ?>" class="btn btn-sm btn-outline-primary mr-1">
<i class="fa fa-eye"></i>
</a>
<button type="button" class="btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#updateModal<?= $i_value['id'] ?>">
<i class="fa fa-edit"></i>
</button>
<div class="modal fade" id="updateModal<?= $i_value['id'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Update</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="<?= base_url(); ?>admin/inventory/items" method="POST" onkeydown=" return event.key != 'Enter'" enctype="multipart/form-data">
<div class="modal-body">
<input type="hidden" name="recId" value="<?= $i_value['id'] ?>">
<div class="form-group mb-0">
<label class="has-float-label">
<input type="text" id="title" name="title" class=" form-control" value="<?= $i_value['title'] ?>" placeholder='Enter item title' required>
<span>Item Title</span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<select id="item_category<?= $i_value['id'] ?>" class="form-control selectpicker" name="item_category" data-live-search="true" required>
<option value="">
Select Category
</option>
<?php
foreach ($inventory_categories as $ic_key => $ic_value) {
?>
<option value="<?= $ic_value['id'] ?>" <?= $ic_value['id'] == $i_value['category_id'] ? 'selected' : '' ?>>
<?= $ic_value['title'] ?>
</option>
<?php
}
?>
</select>
<span>Category <b class="text-danger">*</b></span>
</label>
</div>
<div class="form-group mt-3" id="course-section<?= $i_value['id'] ?>">
<label class="has-float-label">
<select id="course_id[]" class="form-control selectpicker" name="course_id[]" data-live-search="true">
<option value="">
Select Course
</option>
<?php
foreach ($courses as $c_key => $course) {
?>
<option value="<?= $course['id'] ?>" <?= $course['id'] == $i_value['course_id'] ? 'selected' : '' ?>>
<?= $course['course_name'] ?>
</option>
<?php
}
?>
</select>
<span>Course <b class="text-danger">*</b></span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<select id="item_measurement_unit" class="form-control selectpicker" name="item_measurement_unit" data-live-search="true">
<option value="">
Select Measurement Unit
</option>
<?php
foreach ($inventory_measurements as $im_key => $im_value) {
?>
<option value="<?= $im_value['id'] ?>" <?= $im_value['id'] == $i_value['measurement_id'] ? 'selected' : '' ?>>
<?= $im_value['title'] ?>
</option>
<?php
}
?>
</select>
<span>Measurement Unit <b class="text-danger"></b></span>
</label>
</div>
<div class="form-group mt-3">
<label class="has-float-label">
<textarea class="form-control" name="description" rows="4" cols="50">
<?= $i_value['description'] ?>
</textarea>
<span>Item Description</span>
</label>
</div>
<div class="form-group mt-3 text-left">
<div class="row align-items-center">
<div class="col">
<label class="has-float-label mt-3">
<input type="file" id="photo" name="photo" class=" form-control" style="padding: 0.75rem 0.75rem;">
<input type="hidden" id="photo_name" name="photo_name" value="<?= $i_value['photo'] ?>" class=" form-control" style="padding: 0.75rem 0.75rem;">
<span>Item Photo</span>
</label>
</div>
<div class="col">
<?php
$item_photo = '';
if (!empty($i_value['photo'])) {
if (file_exists('assets_inventory/images/items/' . $i_value['photo'])) {
$item_photo = base_url() . 'assets_inventory/images/items/' . $i_value['photo'];
} else {
$item_photo = base_url() . 'common_assets/' . $i_value['photo'];
}
} else {
$item_photo = base_url() . 'common_assets/No-Image.jpg';
}
?>
<img src="<?= $item_photo ?>" class="img-thumbnail img-fluid" width="100px">
</div>
</div>
</div>
<div class="form-group mt-4">
<label class="has-float-label">
<select id="is_active" class="form-control custom-select" placeholder="Is Active" name="is_active">
<option value="yes" <?= $i_value['is_active'] == 'yes' ? 'selected' : '' ?>>
Yes
</option>
<option value="no" <?= $i_value['is_active'] == 'no' ? 'selected' : '' ?>>
No
</option>
</select>
<span>Is Active</span>
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-danger" data-dismiss="modal">Close</button>
<input type="submit" name="updateItem" class="btn btn-sm btn-success" value="Update">
</div>
</form>
</div>
</div>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
<!--End right-top side-->
<!-- <script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.2.1.slim.min.js"></script> -->
<script>
$(document).ready(function() {
$("#course-section").hide();
$("#book-detail-section").hide();
$("#variant-section").hide();
//table js
$('#tbl').DataTable({
"lengthMenu": [
[25, 50, 100, 150, -1],
[25, 50, 100, 150, "All"]
]
});
//table js end
var items = <?php echo json_encode($inventory_items); ?>;
for (var i = 0; i < items.length; i++) {
$('#item_category' + i).on('change', function() {
var catId = this.value;
var categories = <?php echo json_encode($inventory_categories); ?>;
for (var i = 0; i < categories.length; i++) {
if (catId == categories[i]['id']) {
if ($.trim(categories[i]['class_based']) == "yes") {
console.log(categories[i]['class_based']);
$("#course-section" + i).show();
break;
} else {
$("#course-section" + i).hide();
}
} else {
$("#course-section" + i).hide();
}
}
});
}
});
$('#item_category').on('change', function() {
var catId = this.value;
var categories = <?php echo json_encode($inventory_categories); ?>;
for (var i = 0; i < categories.length; i++) {
console.log(categories[i]);
if (catId == categories[i]['id']) {
if ($.trim(categories[i]['class_based']) == "yes") {
console.log(categories[i]['class_based']);
$("#course-section").show();
break;
} else {
$("#course-section").hide();
}
} else {
$("#course-section").hide();
}
}
if (catId == 1) {
$("#book-detail-section").show();
} else {
$("#book-detail-section").hide();
}
if (catId == 3) {
$("#variant-section").show();
} else {
$("#variant-section").hide();
}
});
</script>