added material category addition in add material section -vadivel J
This commit is contained in:
parent
3d3e1ff37c
commit
0493499da7
@ -318,6 +318,19 @@ class Rawmaterialdetails extends BaseController
|
||||
|
||||
$data['category_name']=$this->request->getpost('category_name');
|
||||
|
||||
$existingCategory = $this->materialCategories_model
|
||||
->where('category_name', $data['category_name'])
|
||||
->first();
|
||||
|
||||
if ($existingCategory) {
|
||||
// Data already exists, handle this case (e.g., return an error or ignore the insert)
|
||||
return $this->response->setJSON([
|
||||
'status' => '409',
|
||||
'message' => 'Category Already Exists..!!',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$insertResult=$this->materialCategories_model->insert($data);
|
||||
|
||||
if ($insertResult) {
|
||||
|
||||
@ -152,8 +152,8 @@ class Rawmaterialdetails_model extends Model
|
||||
|
||||
|
||||
$subquery = "SELECT SUM(IF(Transaction_type='Add',Quantity,0)) - SUM(IF(Transaction_type='Reduce',Quantity,0))as remainingqty
|
||||
FROM t_material_stock_history
|
||||
WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? ";
|
||||
FROM t_material_stock_history
|
||||
WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? ";
|
||||
$query = $this->db->query($subquery, array($MaterialCode, $startdate, $newdate));
|
||||
|
||||
|
||||
|
||||
@ -195,7 +195,8 @@
|
||||
|
||||
|
||||
|
||||
<!-- Modal -->
|
||||
<!-- addMaterialCaterogyModal -->
|
||||
|
||||
<div class="modal fade" id="addMaterialCaterogyModal" tabindex="-1" aria-labelledby="addMaterialCaterogyModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
@ -237,9 +238,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
|
||||
<script>
|
||||
//var tempARRAY = [];
|
||||
@ -393,10 +391,25 @@
|
||||
if(response.status=="201"){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
$("#MatCate").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`)
|
||||
}else{
|
||||
$("#MatCate").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`);
|
||||
|
||||
}else if(response.status=="409"){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
alert('Error Adding Category..!!');
|
||||
|
||||
$('#MatCate').val(materialCategory);
|
||||
|
||||
$('#MatCate').trigger('change');
|
||||
|
||||
setTimeout(()=>{ alert(`${response.message}`) },1000)
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
|
||||
setTimeout(()=>{ alert('Error Adding Category..!!'); },1000)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -162,7 +162,12 @@ if ($total <= $reorder) {
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="MaterialCategory">Material Category <span class="text-danger">*</span></label>
|
||||
<label for="MaterialCategory">Material Category
|
||||
<span class="badge">*</span></label>
|
||||
<i type="button" class="fe-plus-circle" id="addMaterialCaterogyModalButton"
|
||||
style="font-size: 16px; color:rgb(15, 155, 218);" data-toggle="modal" data-target="#addMaterialCaterogyModal"
|
||||
title="Add Material Caterogy">
|
||||
</i>
|
||||
<select class="form-control select2" id="MaterialCategory" name="MaterialCategory" required>
|
||||
<?php
|
||||
if (!empty($materialCategoryList)) {
|
||||
@ -290,6 +295,71 @@ if ($total <= $reorder) {
|
||||
</div><!-- /.container-fluid -->
|
||||
</div><!-- /.content -->
|
||||
</div><!-- /.content-page -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- modal -->
|
||||
|
||||
<div class="modal fade" id="addMaterialCaterogyModal" tabindex="-1" aria-labelledby="addMaterialCaterogyModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addMaterialCaterogyModalLabel">Add Material Category</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addMaterialCategoryForm">
|
||||
<div class="form-group">
|
||||
<label for="materialCategoryInput">Material Category</label>
|
||||
<input type="text" class="form-control" id="materialCategoryInput" placeholder="Enter material category">
|
||||
</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" onclick="addMaterialCategory()">Save Category</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -408,4 +478,65 @@ if ($total <= $reorder) {
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function addMaterialCategory (){
|
||||
|
||||
$('#materialCategoryInput').val()
|
||||
|
||||
let materialCategory = $('#materialCategoryInput').val().trim();
|
||||
|
||||
if (materialCategory.length <= 2) {
|
||||
alert('Material Category should have more than 2 letters.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (materialCategory.length > 20) {
|
||||
alert('Material Category should have fewer than 20 letters.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo base_url('/rawmaterialdetails/addMaterialCategories'); ?>",
|
||||
type: 'POST',
|
||||
data: {
|
||||
category_name: materialCategory
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
if(response.status=="201"){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
$("#MaterialCategory").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`)
|
||||
}
|
||||
else if(response.status=="409"){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
|
||||
$('#MaterialCategory').val(materialCategory);
|
||||
|
||||
$('#MaterialCategory').trigger('change');
|
||||
|
||||
setTimeout(()=>{ alert(`${response.message}`) },1000)
|
||||
}
|
||||
else{
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
|
||||
setTimeout(()=>{ alert('Error Adding Category..!!'); },1000)
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle errors
|
||||
alert('Error adding category');
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
@ -82,13 +82,16 @@ $energyType=$masterData['energy_type']??'';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" >
|
||||
<br>
|
||||
|
||||
<div class="form-group" >
|
||||
<!-- submit and cancel button section -->
|
||||
<div class="form-row" align="right" >
|
||||
|
||||
<div class="form-group col" >
|
||||
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
<button type="submit" class="btn btn-info waves-effect waves-light">Submit</button>
|
||||
|
||||
<button type="button" class="btn btn-danger" onclick="window.history.back();">
|
||||
<button type="button" class="btn btn-secondary" onclick="window.history.back();">
|
||||
Cancel</button>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user