Reorder-list

This commit is contained in:
heama 2024-04-10 14:44:04 +05:30
parent a678ec439d
commit 22efe7dfc2
7 changed files with 328 additions and 2 deletions

View File

@ -42,7 +42,9 @@ $routes->get("new_product/(:any)", "Products::new_product/$1");
$routes->get("delete_product/(:any)", "Products::delete_product/$1");
$routes->post("get_vendors_by_model", "Products::get_vendors_by_model");
$routes->post("get_models", "Products::get_models");
$routes->get("get_makes", "Products::get_makes");
$routes->post("save_make", "Products::save_make");
$routes->post("save_model", "Products::save_model");
//end products//
//Sales order //
@ -120,3 +122,5 @@ $routes->get('purchase_index', 'Purchase::purchase_index');
$routes->get("new_purchase/(:any)", "Purchase::new_purchase/$1");
$routes->get('get_product/(:any)', 'Purchase::get_product/$1');
$routes->post("add_purchase", "Purchase::add_purchase");
// Reorder Level//
$routes->get('reorder_level_index', 'Reorderlevel::reorder_level_index');

View File

@ -294,5 +294,35 @@ public function save_make() {
// Send JSON response back to the client
return $this->response->setJSON($response);
}
public function get_makes()
{
$BikeMakeModel = new BikeMakeModel(); // Adjust this according to your actual model name
$makes = $BikeMakeModel->findAll();
return $this->response->setJSON($makes);
}
public function save_model() {
$response = [];
$BikemodelsModel = new BikemodelsModel();
$make_id = $this->request->getPost('make_id');
$model = $this->request->getPost('modelvalue');
if (!empty($make_id) && !empty($model)) {
$modelData = [
'model_name' => $model,
'make_id' => $make_id,
];
$BikemodelsModel->insert($modelData);
$response['success'] = true;
} else {
$response['success'] = false;
}
return $this->response->setJSON($response);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Controllers;
use App\Models\ProductModel;
class Reorderlevel extends BaseController
{
public $session;
public function __construct()
{
$this->session = session();
}
public function reorder_level_index()
{
$productModel = new ProductModel();
$reorder = $productModel->where('qty_stock <= purchase_order_level')->findAll();
// print_r($reorder);die;
$data['reorder']=$reorder;
return view('reorder_level_list',$data);
}
}
?>

View File

@ -174,6 +174,13 @@
<span> Manufacturer </span>
</a>
</li>
<li>
<a href="<?php echo base_url('reorder_level_index') ?>">
<i class="fas fa-angle-double-up"></i>
<span> Reorder Level Products </span>
</a>
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||

View File

@ -39,7 +39,7 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
<label for="model" class="col-form-label">Model<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i></label>
<select class="form-control SelExample" id="model" name="model[]" required multiple>
<!-- Options for model will be populated dynamically via AJAX -->
<?php if(isset($models) && !empty($models)): ?>
@ -188,6 +188,7 @@
</div>
</div>
<?php include('layout/footer.php'); ?>
<!-- Make popup -->
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -216,6 +217,38 @@
</div>
</div>
</div>
<!-- Modal popup -->
<div class="modal fade" id="addModelModal" tabindex="-1" role="dialog" aria-labelledby="addModelModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addModelModalLabel">Add New Model</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form id="addModelForm">
<div class="form-group">
<label for="makeSelect">Make</label>
<select class="form-control" id="makeSelect" required>
<!-- Options will be populated dynamically via JavaScript -->
</select>
</div>
<div class="form-group">
<label for="modelInput">Model</label>
<input type="text" class="form-control" id="modelInput" placeholder="Enter Model" required>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveModelBtn">Save Model</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// Check SGST checkbox by default
@ -409,6 +442,7 @@ $(document).ready(function() {
</script>
<!-- Save a make and model fun -->
<script>
$('#saveMakeBtn').click(function() {
var make = $('#makes').val();
@ -443,6 +477,63 @@ $('#saveMakeBtn').click(function() {
}
});
</script>
<!-- Save Modal Funxtion -->
<script>
// Populate make dropdown in the add model modal
function populateMakeDropdown() {
$.ajax({
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
type: 'GET',
dataType: 'json',
success: function(response) {
$('#makeSelect').empty().append('<option value="">Select Make</option>');
response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
});
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
}
// Call the function to populate make dropdown initially
$(document).ready(function() {
populateMakeDropdown();
});
// Save model function
$('#saveModelBtn').click(function() {
var makeId = $('#makeSelect').val();
var model = $('#modelInput').val();
console.log(model);
if (makeId != '' && model != '') {
$.ajax({
url: '<?php echo base_url().'save_model'?>',
method: 'POST',
data: {
make_id: makeId,
modelvalue: model
},
success: function(response) {
if (response.success) {
$('#addModelModal').modal('hide');
toastr.success("Model saved successfully");
window.location.reload();
} else {
toastr.error("Failed to save model");
}
},
error: function(xhr, status, error) {
console.error('Error occurred while saving model:', error);
toastr.error("Failed to save model. Please try again");
}
});
} else {
toastr.warning("Please fill in both make and model fields");
}
});
</script>
<style>
.select2-container--default .select2-results__option--highlighted[aria-selected]{
color:#ffffff;

View File

@ -0,0 +1,73 @@
<?php include('layout/header.php'); ?>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Product List </h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
<tr>
<th>Product Name</th>
<th>Unit Price</th>
<th>Qty in Stock</th>
<th>Purchase Order Level</th>
<th>Purchase Re-Order Level</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($reorder as $value) :
?>
<tr>
<td><?= $value['product_name']; ?></td>
<td><?= number_format($value['unit_price']); ?></td>
<td><?= $value['qty_stock']; ?></td>
<td><?= $value['purchase_order_level']; ?></td>
<td><?= $value['reorder_level']; ?></td>
<!-- Call the model method -->
<td>
</td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div> <!-- end card -->
</div> <!-- end col -->
</div>
<?php include('layout/footer.php'); ?>

View File

@ -36,7 +36,7 @@
</select>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span></label>
<label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i></label>
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
<?php if (isset($vehicle["model_name"])) : ?>
<option value="<?= $vehicle["model"] ?>" >
@ -119,6 +119,7 @@
<?php include('layout/footer.php'); ?>
</div>
<!-- ADD MAKE -->
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -176,6 +177,37 @@
</div>
</div>
</div>
<!-- Modal popup -->
<div class="modal fade" id="addModelModal" tabindex="-1" role="dialog" aria-labelledby="addModelModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addModelModalLabel">Add New Model</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form id="addModelForm">
<div class="form-group">
<label for="makeSelect">Make</label>
<select class="form-control" id="makeSelect" required>
<!-- Options will be populated dynamically via JavaScript -->
</select>
</div>
<div class="form-group">
<label for="modelInput">Model</label>
<input type="text" class="form-control" id="modelInput" placeholder="Enter Model" required>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveModelBtn">Save Model</button>
</div>
</div>
</div>
</div>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
<script>
@ -332,6 +364,63 @@ $('#saveMakeBtn').click(function() {
}
});
</script>
<!-- aDD MODEL FUNCTION -->
<script>
// Populate make dropdown in the add model modal
function populateMakeDropdown() {
$.ajax({
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
type: 'GET',
dataType: 'json',
success: function(response) {
$('#makeSelect').empty().append('<option value="">Select Make</option>');
response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
});
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
}
// Call the function to populate make dropdown initially
$(document).ready(function() {
populateMakeDropdown();
});
// Save model function
$('#saveModelBtn').click(function() {
var makeId = $('#makeSelect').val();
var model = $('#modelInput').val();
console.log(model);
if (makeId != '' && model != '') {
$.ajax({
url: '<?php echo base_url().'save_model'?>',
method: 'POST',
data: {
make_id: makeId,
modelvalue: model
},
success: function(response) {
if (response.success) {
$('#addModelModal').modal('hide');
toastr.success("Model saved successfully");
window.location.reload();
} else {
toastr.error("Failed to save model");
}
},
error: function(xhr, status, error) {
console.error('Error occurred while saving model:', error);
toastr.error("Failed to save model. Please try again");
}
});
} else {
toastr.warning("Please fill in both make and model fields");
}
});
</script>
<style>
.select2-container--default .select2-results__option--highlighted[aria-selected]{
color:#ffffff;