Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme

This commit is contained in:
vadivelJ96 2025-02-12 18:16:53 +05:30
commit 9908ebeb2f
9 changed files with 189 additions and 149 deletions

View File

@ -65,7 +65,6 @@ $routes->get('viewRawmaterial', 'Rawmaterialdetails::viewRawmaterial');
$routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial'); $routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial');
$routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories'); $routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories');
$routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial'); $routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial');
$routes->get('rawmaterialdetailsautocomplete', 'Rawmaterialdetails::autocomplete');
$routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial'); $routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial');
$routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial');
@ -144,6 +143,7 @@ $routes->post('configurationctrl/saveconfig', 'Configurationctrl::saveconfig');
$routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configValueCheck'); $routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configValueCheck');
$routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue'); $routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue');
$routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue'); $routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue');
$routes->get('activeInactiveConfigValue', 'Configurationctrl::activeInactiveConfigValue');
$routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig'); $routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig');
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig'); $routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck'); $routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');

View File

@ -182,6 +182,16 @@ class Configurationctrl extends BaseController
} }
public function activeInactiveConfigValue(){
$key = $this->request->getVar('key');
$value = $this->request->getVar('value');
$where = ['isActive'=> $value];
$result = $this->configmodel->activeInactiveConfigValue($key, $where);
return redirect()->back();
}
public function deleteConfigValue(){ public function deleteConfigValue(){
$configId = $this->request->getVar('ConfigID'); $configId = $this->request->getVar('ConfigID');

View File

@ -69,6 +69,7 @@ class Rawmaterialdetails extends BaseController
$this->rawmaterialdetails_model = new rawmaterialdetails_model();; $this->rawmaterialdetails_model = new rawmaterialdetails_model();;
$data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing(); $data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing();
$data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll();
$this->global['pageTitle'] = 'RawMaterial Listing'; $this->global['pageTitle'] = 'RawMaterial Listing';
$this->loadViews("rawmaterialListing", $this->global, $data, NULL); $this->loadViews("rawmaterialListing", $this->global, $data, NULL);
@ -133,7 +134,7 @@ class Rawmaterialdetails extends BaseController
$this->rawmaterialdetails_model = new rawmaterialdetails_model();; $this->rawmaterialdetails_model = new rawmaterialdetails_model();;
$data['material'] = $this->rawmaterialdetails_model->getmaterialType(); $data['material'] = $this->rawmaterialdetails_model->getmaterialType();
$data['materialcategory'] = $this->rawmaterialdetails_model->getmaterialCategory(); $data['materialcategory'] = $this->rawmaterialdetails_model->getmaterialCategory();
$data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); // $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll();
$data['UOM'] = $this->rawmaterialdetails_model->getUOM(); $data['UOM'] = $this->rawmaterialdetails_model->getUOM();
$data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode(); $data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode();
$data['costcentercode'] = $this->rawmaterialdetails_model->getcostcentercode(); $data['costcentercode'] = $this->rawmaterialdetails_model->getcostcentercode();
@ -283,7 +284,7 @@ class Rawmaterialdetails extends BaseController
$data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate); $data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate);
$data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType); $data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType);
$data['materialCategory'] = $this->rawmaterialdetails_model->getmaterialCategory($MaterialCategory); $data['materialCategory'] = $this->rawmaterialdetails_model->getmaterialCategory($MaterialCategory);
$data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll(); // Told by Pavithra
$data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM); $data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM);
$data['costcentercode'] = $this->rawmaterialdetails_model->getCostCenterCode(); $data['costcentercode'] = $this->rawmaterialdetails_model->getCostCenterCode();
$data['cfUOM'] = $this->rawmaterialdetails_model->getConversionfactorUOM(); $data['cfUOM'] = $this->rawmaterialdetails_model->getConversionfactorUOM();
@ -353,11 +354,10 @@ class Rawmaterialdetails extends BaseController
function addMaterialCategories(){ function addMaterialCategories(){
$data['category_name']=$this->request->getpost('category_name'); $configCode = 'C023';
$configVal = $this->request->getpost('category_name');
$existingCategory = $this->materialCategories_model $configArr = array('Config_ID' => $configCode, 'ConfigValue' => $configVal);
->where('category_name', $data['category_name']) $existingCategory = $this->rawmaterialdetails_model->checkMaterialCategory($configVal);
->first();
if ($existingCategory) { if ($existingCategory) {
// Data already exists, handle this case (e.g., return an error or ignore the insert) // Data already exists, handle this case (e.g., return an error or ignore the insert)
@ -367,8 +367,7 @@ class Rawmaterialdetails extends BaseController
]); ]);
} }
$insertResult=$this->rawmaterialdetails_model->insertvalueintoconfig($configArr);
$insertResult=$this->materialCategories_model->insert($data);
if ($insertResult) { if ($insertResult) {
// Send a success response as JSON // Send a success response as JSON
@ -386,19 +385,6 @@ class Rawmaterialdetails extends BaseController
} }
function autocomplete()
{
$mc = $this->request->getGet('query');
//echo $mc;die;
$query = $this->rawmaterialdetails_model->checkMaterialCategory($mc);
echo json_encode($query);
// foreach($query->result() as $row):
// echo "<li id='$row->id'>".$row->Category."</li>";
// endforeach;
}
function insertvalueintoconfig() function insertvalueintoconfig()
{ {

View File

@ -202,6 +202,14 @@ class Config_model extends Model
return $query->getResultArray(); return $query->getResultArray();
} }
public function activeInactiveConfigValue($key, $value){
$builder = $this->db->table('t_configdetails')
->where('Key',$key)
->update($value);
$res = $this->db->affectedRows();
return $res;
}
public function deleteConfigValue($configId, $configValue){ public function deleteConfigValue($configId, $configValue){
$builder = $this->db->table('t_configdetails') $builder = $this->db->table('t_configdetails')
->where('Config_ID',$configId) ->where('Config_ID',$configId)

View File

@ -77,6 +77,7 @@ class Rawmaterialdetails_model extends Model
$Config_ID = 'C023'; $Config_ID = 'C023';
$builder = $this->db->table('t_configdetails') $builder = $this->db->table('t_configdetails')
->select('Config_ID,ConfigValue') ->select('Config_ID,ConfigValue')
->where('isActive', 1)
->where('Config_id', $Config_ID); ->where('Config_id', $Config_ID);
if ($MaterialCategory != '') { if ($MaterialCategory != '') {
$builder->where('ConfigValue !=', $MaterialCategory); $builder->where('ConfigValue !=', $MaterialCategory);
@ -348,22 +349,12 @@ class Rawmaterialdetails_model extends Model
function checkMaterialCategory($mc) function checkMaterialCategory($mc)
{ {
$temp = [];
$builder = $this->db->table('t_configdetails') $builder = $this->db->table('t_configdetails')
->distinct()
->select('ConfigValue') ->select('ConfigValue')
->where('Config_ID', 'C023') ->where('Config_ID', 'C023')
->like('ConfigValue', $mc); ->like('ConfigValue', $mc);
$query = $builder->get(); $query = $builder->get()->getRow();
return $query;
$temparr = [];
foreach ($query->getResult() as $arr) {
$temparr[] = $arr->ConfigValue;
}
$temp['suggestions'] = $temparr;
return $temp;
} }

View File

@ -1,11 +1,11 @@
<style> <!-- <style>
.autocomplete-suggestion { .autocomplete-suggestion {
cursor: pointer; cursor: pointer;
background-color: skyblue; background-color: skyblue;
/* background-color: darkgrey; */ /* background-color: darkgrey; */
outline: 1px solid slategrey; outline: 1px solid slategrey;
} }
</style> </style> -->
<script> <script>
$(function() { $(function() {
$("#Date").datepicker({ $("#Date").datepicker({
@ -18,7 +18,7 @@
}); });
}); });
</script> </script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script> <!-- <script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script> -->
<div class="content-page"> <div class="content-page">
@ -75,12 +75,12 @@
title="Add Material Caterogy"> title="Add Material Caterogy">
</i> </i>
<select class="form-control select2" required id="MatCate" name="MatCate"> <select class="form-control select2" required id="MatCate" name="MatCate">
<option value="" required>Select Material Caterogy </option> <option value="" required>Select Material Category </option>
<?php <?php
if (!empty($materialCategoryList)) { if (!empty($materialcategory)) {
foreach ($materialCategoryList as $record) { foreach ($materialcategory as $SID) {
?> ?>
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option> <option value="<?php echo $SID->ConfigValue ?>"><?php echo $SID->ConfigValue ?></option>
<?php <?php
} }
} }
@ -416,7 +416,7 @@
}, },
success: function(response) { success: function(response) {
if(response.status=="201"){ if(response.status == 201){
$("#addMaterialCaterogyModal").modal('hide'); $("#addMaterialCaterogyModal").modal('hide');
$("#MatCate").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`); $("#MatCate").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`);
@ -425,7 +425,7 @@
$("#addMaterialCaterogyModal").modal('hide'); $("#addMaterialCaterogyModal").modal('hide');
$('#MatCate').val(materialCategory); // $('#MatCate').val(materialCategory);
$('#MatCate').trigger('change'); $('#MatCate').trigger('change');

View File

@ -91,7 +91,7 @@ if ($total <= $reorder) {
}); });
}); });
</script> </script>
<style> <!-- <style>
.autocomplete-suggestion { .autocomplete-suggestion {
cursor: pointer; cursor: pointer;
background-color: skyblue; background-color: skyblue;
@ -99,7 +99,7 @@ if ($total <= $reorder) {
outline: 1px solid slategrey; outline: 1px solid slategrey;
} }
</style> </style>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script> <script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script> -->
<div class="content-page"> <div class="content-page">
@ -171,17 +171,15 @@ if ($total <= $reorder) {
title="Add Material Caterogy"> title="Add Material Caterogy">
</i> </i>
<select class="form-control select2" id="MaterialCategory" name="MaterialCategory" required> <select class="form-control select2" id="MaterialCategory" name="MaterialCategory" required>
<?php <?php
if (!empty($materialCategoryList)) { if (!empty($materialCategory)) {
foreach ($materialCategoryList as $record) { foreach ($materialCategory as $SID) {
?> ?>
<option value="<?= $record['category_name'] ?>" <?php if ($record['category_name'] === $MaterialCategory) echo "selected"; ?>> <option value="<?php echo $SID->ConfigValue ?>" <?php if ($MaterialCategory === $SID->ConfigValue) echo "selected"; ?>><?php echo $SID->ConfigValue ?></option>
<?php echo $record['category_name'] ?> <?php
</option> }
<?php
} }
} ?>
?>
</select> </select>
</div> </div>
</div> </div>
@ -331,43 +329,6 @@ if ($total <= $reorder) {
</div> </div>
<script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script> <script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
@ -377,21 +338,21 @@ if ($total <= $reorder) {
$("#MaterialType").select2(); $("#MaterialType").select2();
$("#MaterialCategory").select2(); $("#MaterialCategory").select2();
/** ---- auto search code -------- */ /** ---- auto search code -------- */
$('#MaterialCategory').autocomplete({ // $('#MaterialCategory').autocomplete({
onSearchStart: function(query) { // onSearchStart: function(query) {
$('#MaterialCategory').autocomplete("option", "minLength", 0); // $('#MaterialCategory').autocomplete("option", "minLength", 0);
}, // },
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete", // serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete",
onSelect: function(suggestion) { // onSelect: function(suggestion) {
var data = suggestion.ConfigValue; // var data = suggestion.ConfigValue;
var selectedvalue = $('input[name=MaterialCategory]').val(); // var selectedvalue = $('input[name=MaterialCategory]').val();
} // }
}); // });
}); });
@ -526,16 +487,17 @@ if ($total <= $reorder) {
}, },
success: function(response) { success: function(response) {
if(response.status=="201"){ if(response.status== 201 ){
$("#addMaterialCaterogyModal").modal('hide'); $("#addMaterialCaterogyModal").modal('hide');
$("#materialCategoryInput").val('');
$("#MaterialCategory").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`) $("#MaterialCategory").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`)
} }
else if(response.status=="409"){ else if(response.status=="409"){
$("#addMaterialCaterogyModal").modal('hide'); $("#addMaterialCaterogyModal").modal('hide');
$("#materialCategoryInput").val('');
$('#MaterialCategory').val(materialCategory); // $('#MaterialCategory').val(materialCategory);
$('#MaterialCategory').trigger('change'); $('#MaterialCategory').trigger('change');
@ -543,6 +505,7 @@ if ($total <= $reorder) {
} }
else{ else{
$("#addMaterialCaterogyModal").modal('hide'); $("#addMaterialCaterogyModal").modal('hide');
$("#materialCategoryInput").val('');
setTimeout(()=>{ alert('Error Adding Category..!!'); },1000) setTimeout(()=>{ alert('Error Adding Category..!!'); },1000)

View File

@ -153,9 +153,9 @@ if (!empty($master)) {
<td> <td>
<?php if ($con->isActive == 0) { ?> <?php if ($con->isActive == 0) { ?>
<a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'configurationctrl/reActivateConfigValue <a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'activeInactiveConfigValue
?ConfigValue=' . $con->ConfigValue . ' ?key=' . $con->Key . '
&ConfigID=' . $con->Config_ID; ?>" &value=1'; ?>"
data-toggle="tooltip" title="<?php echo $con->Config_ID ?> - Click here to Re data-toggle="tooltip" title="<?php echo $con->Config_ID ?> - Click here to Re
activate Config Details"><i class="fas fa-key"></i> activate Config Details"><i class="fas fa-key"></i>
</a> </a>
@ -170,9 +170,9 @@ if (!empty($master)) {
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
<a onclick="confirmDeleteConfig(event)" href="<?php echo base_url() . 'configurationctrl/deleteConfigValue <a onclick="confirmDeleteConfig(event)" href="<?php echo base_url() . 'activeInactiveConfigValue
?ConfigValue=' . $con->ConfigValue . ' ?key=' . $con->Key . '
&ConfigID=' . $con->Config_ID; ?>"> &value=0'; ?>">
<i class="fas fa-trash" data-toggle="tooltip" <i class="fas fa-trash" data-toggle="tooltip"
title="Click here to Delete the Config Value"></i> title="Click here to Delete the Config Value"></i>
</a> </a>

View File

@ -67,19 +67,33 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<form class="Date-filter-form" id="DateRangeFilter" <form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px; margin-bottom: -11px; margin-left: 33px;">
style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition"> <input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label> <label for="fromDate">From:</label>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" <input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
placeholder="Select From Date" autocomplete="off" required> placeholder="Select From Date" autocomplete="off">
<label for="toDate">To:</label> <label for="toDate">To:</label>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" <input class="form-control date_range to-date-search" id="toDate" name="toDate"
placeholder="Select To Date" autocomplete="off" required> placeholder="Select To Date" autocomplete="off">
<!-- New Category Field -->
<label for="category">Category:</label>
<select class="form-control" style="width: auto !important;" autocomplete="off" id="category" name="category">
<option value="">Select Category </option>
<?php
if (!empty($materialCategoryList)) {
foreach ($materialCategoryList as $record) {
?>
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
<?php } } ?>
</select>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" <button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true"
class="icon-button" title="Search"></i></button> class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" <i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton"
title="Reset"></i> title="Reset"></i>
@ -91,11 +105,11 @@
Show Archive Show Archive
</label> </label>
</div> </div>
</div> </div>
<div class="error" id="error"></div> <div class="error" id="error"></div>
</form> </form>
<div class="card-body" style="overflow-x:scroll;"> <div class="card-body" style="overflow-x:scroll;">
<table id="raw_material_list_table" class="table dt-responsive nowrap w-100"> <table id="raw_material_list_table" class="table dt-responsive nowrap w-100">
<thead> <thead>
@ -357,52 +371,119 @@ $(document).ready(function () {
}); });
// Date range filter function // Date range filter function
$.fn.dataTable.ext.search.push( // $.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) { // function (settings, data, dataIndex) {
var fromDate = $('#fromDate').val(); // var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val(); // var toDate = $('#toDate').val();
if (!fromDate || !toDate) { // if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter // return true; // If no dates selected, don't filter
} // }
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects // // Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-"); // var fromParts = fromDate.split("-");
var toParts = toDate.split("-"); // var toParts = toDate.split("-");
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day // var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]); // var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate // // Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1); // startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day // // Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999); // endDate.setHours(23, 59, 59, 999);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format) // // Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0]; // var dateStr = data[0];
var dateParts = dateStr.split("-"); // var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range // // Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate; // return rowDate >= startDate && rowDate <= endDate;
} // }
); // );
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
var selectedCategory = $('#category').val(); // Get selected category
var isDateValid = true;
var isCategoryValid = true;
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
if (fromDate && toDate) {
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]);
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
startDate.setDate(startDate.getDate() - 1);
endDate.setHours(23, 59, 59, 999);
var dateStr = data[0]; // Assuming date is in the first column
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
isDateValid = rowDate >= startDate && rowDate <= endDate;
}
// Category filter (Assuming category is in the 8th column - index 7)
var rowCategory = data[7] || "";
if (selectedCategory) {
isCategoryValid = rowCategory === selectedCategory;
}
// Return true only if both conditions are met
return isDateValid && isCategoryValid;
}
);
// Handle form submission for the date range filter
// $("#DateRangeFilter").submit(function (e) {
// e.preventDefault();
// table.draw(); // Redraw the table to apply the filter
// });
// Handle form submission for the date range filter // Handle form submission for the date range filter
$("#DateRangeFilter").submit(function (e) { $("#DateRangeFilter").submit(function (e) {
var fromDate = $("#fromDate").val();
var toDate = $("#toDate").val();
if (fromDate && !toDate) {
alert("Please select 'To Date' if 'From Date' is chosen.");
e.preventDefault(); e.preventDefault();
table.draw(); // Redraw the table to apply the filter return false;
}); }
if (!fromDate && toDate) {
alert("Please select 'From Date' if 'To Date' is chosen.");
e.preventDefault();
return false;
}
var table = $('#raw_material_list_table').DataTable();
table.draw(false);
return false;
// table.draw(); // Apply filters
});
// $('#category, #fromDate, #toDate').change(function () {
// $('#raw_material_list_table').DataTable().draw();
// });
// Reset button functionality // Reset button functionality
$("#resetButton").click(function () { $("#resetButton").click(function () {
$("#fromDate").val(''); $("#fromDate").val('');
$("#toDate").val(''); $("#toDate").val('');
$("#category").val('');
table.draw(); // Redraw the table to clear the filter table.draw(); // Redraw the table to clear the filter
}); });
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function () { document.getElementById('fromDate').addEventListener('change', function () {
var fromDate = this.value; var fromDate = this.value;
var toDateInput = document.getElementById('toDate'); var toDateInput = document.getElementById('toDate');
@ -415,6 +496,7 @@ $(document).ready(function () {
toDateInput.value = fromDate; toDateInput.value = fromDate;
} }
}); });
}); });
</script> </script>