Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
9908ebeb2f
@ -65,7 +65,6 @@ $routes->get('viewRawmaterial', 'Rawmaterialdetails::viewRawmaterial');
|
||||
$routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial');
|
||||
$routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories');
|
||||
$routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial');
|
||||
$routes->get('rawmaterialdetailsautocomplete', 'Rawmaterialdetails::autocomplete');
|
||||
$routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial');
|
||||
$routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial');
|
||||
|
||||
@ -144,6 +143,7 @@ $routes->post('configurationctrl/saveconfig', 'Configurationctrl::saveconfig');
|
||||
$routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configValueCheck');
|
||||
$routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue');
|
||||
$routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue');
|
||||
$routes->get('activeInactiveConfigValue', 'Configurationctrl::activeInactiveConfigValue');
|
||||
$routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig');
|
||||
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
|
||||
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');
|
||||
|
||||
@ -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(){
|
||||
|
||||
$configId = $this->request->getVar('ConfigID');
|
||||
|
||||
@ -69,6 +69,7 @@ class Rawmaterialdetails extends BaseController
|
||||
$this->rawmaterialdetails_model = new rawmaterialdetails_model();;
|
||||
|
||||
$data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing();
|
||||
$data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll();
|
||||
$this->global['pageTitle'] = 'RawMaterial Listing';
|
||||
|
||||
$this->loadViews("rawmaterialListing", $this->global, $data, NULL);
|
||||
@ -133,7 +134,7 @@ class Rawmaterialdetails extends BaseController
|
||||
$this->rawmaterialdetails_model = new rawmaterialdetails_model();;
|
||||
$data['material'] = $this->rawmaterialdetails_model->getmaterialType();
|
||||
$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['assetcode'] = $this->rawmaterialdetails_model->getAssetcode();
|
||||
$data['costcentercode'] = $this->rawmaterialdetails_model->getcostcentercode();
|
||||
@ -283,7 +284,7 @@ class Rawmaterialdetails extends BaseController
|
||||
$data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate);
|
||||
$data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType);
|
||||
$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['costcentercode'] = $this->rawmaterialdetails_model->getCostCenterCode();
|
||||
$data['cfUOM'] = $this->rawmaterialdetails_model->getConversionfactorUOM();
|
||||
@ -351,13 +352,12 @@ class Rawmaterialdetails extends BaseController
|
||||
|
||||
}
|
||||
|
||||
function addMaterialCategories(){
|
||||
function addMaterialCategories(){
|
||||
|
||||
$data['category_name']=$this->request->getpost('category_name');
|
||||
|
||||
$existingCategory = $this->materialCategories_model
|
||||
->where('category_name', $data['category_name'])
|
||||
->first();
|
||||
$configCode = 'C023';
|
||||
$configVal = $this->request->getpost('category_name');
|
||||
$configArr = array('Config_ID' => $configCode, 'ConfigValue' => $configVal);
|
||||
$existingCategory = $this->rawmaterialdetails_model->checkMaterialCategory($configVal);
|
||||
|
||||
if ($existingCategory) {
|
||||
// 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->materialCategories_model->insert($data);
|
||||
$insertResult=$this->rawmaterialdetails_model->insertvalueintoconfig($configArr);
|
||||
|
||||
if ($insertResult) {
|
||||
// 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()
|
||||
{
|
||||
|
||||
@ -202,6 +202,14 @@ class Config_model extends Model
|
||||
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){
|
||||
$builder = $this->db->table('t_configdetails')
|
||||
->where('Config_ID',$configId)
|
||||
|
||||
@ -77,6 +77,7 @@ class Rawmaterialdetails_model extends Model
|
||||
$Config_ID = 'C023';
|
||||
$builder = $this->db->table('t_configdetails')
|
||||
->select('Config_ID,ConfigValue')
|
||||
->where('isActive', 1)
|
||||
->where('Config_id', $Config_ID);
|
||||
if ($MaterialCategory != '') {
|
||||
$builder->where('ConfigValue !=', $MaterialCategory);
|
||||
@ -348,22 +349,12 @@ class Rawmaterialdetails_model extends Model
|
||||
|
||||
function checkMaterialCategory($mc)
|
||||
{
|
||||
$temp = [];
|
||||
$builder = $this->db->table('t_configdetails')
|
||||
->distinct()
|
||||
->select('ConfigValue')
|
||||
->where('Config_ID', 'C023')
|
||||
->like('ConfigValue', $mc);
|
||||
$query = $builder->get();
|
||||
|
||||
$temparr = [];
|
||||
foreach ($query->getResult() as $arr) {
|
||||
$temparr[] = $arr->ConfigValue;
|
||||
}
|
||||
|
||||
$temp['suggestions'] = $temparr;
|
||||
|
||||
return $temp;
|
||||
$query = $builder->get()->getRow();
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<style>
|
||||
<!-- <style>
|
||||
.autocomplete-suggestion {
|
||||
cursor: pointer;
|
||||
background-color: skyblue;
|
||||
/* background-color: darkgrey; */
|
||||
outline: 1px solid slategrey;
|
||||
}
|
||||
</style>
|
||||
</style> -->
|
||||
<script>
|
||||
$(function() {
|
||||
$("#Date").datepicker({
|
||||
@ -18,7 +18,7 @@
|
||||
});
|
||||
});
|
||||
</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">
|
||||
@ -75,12 +75,12 @@
|
||||
title="Add Material Caterogy">
|
||||
</i>
|
||||
<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
|
||||
if (!empty($materialCategoryList)) {
|
||||
foreach ($materialCategoryList as $record) {
|
||||
if (!empty($materialcategory)) {
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -416,8 +416,8 @@
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
if(response.status=="201"){
|
||||
|
||||
if(response.status == 201){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
$("#MatCate").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`);
|
||||
|
||||
@ -425,7 +425,7 @@
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
|
||||
$('#MatCate').val(materialCategory);
|
||||
// $('#MatCate').val(materialCategory);
|
||||
|
||||
$('#MatCate').trigger('change');
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ if ($total <= $reorder) {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
<!-- <style>
|
||||
.autocomplete-suggestion {
|
||||
cursor: pointer;
|
||||
background-color: skyblue;
|
||||
@ -99,7 +99,7 @@ if ($total <= $reorder) {
|
||||
outline: 1px solid slategrey;
|
||||
}
|
||||
</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">
|
||||
@ -164,24 +164,22 @@ if ($total <= $reorder) {
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="MaterialCategory">Material Category
|
||||
<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)) {
|
||||
foreach ($materialCategoryList as $record) {
|
||||
?>
|
||||
<option value="<?= $record['category_name'] ?>" <?php if ($record['category_name'] === $MaterialCategory) echo "selected"; ?>>
|
||||
<?php echo $record['category_name'] ?>
|
||||
</option>
|
||||
<?php
|
||||
<select class="form-control select2" id="MaterialCategory" name="MaterialCategory" required>
|
||||
<?php
|
||||
if (!empty($materialCategory)) {
|
||||
foreach ($materialCategory as $SID) {
|
||||
?>
|
||||
<option value="<?php echo $SID->ConfigValue ?>" <?php if ($MaterialCategory === $SID->ConfigValue) echo "selected"; ?>><?php echo $SID->ConfigValue ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -331,43 +329,6 @@ if ($total <= $reorder) {
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@ -377,21 +338,21 @@ if ($total <= $reorder) {
|
||||
$("#MaterialType").select2();
|
||||
$("#MaterialCategory").select2();
|
||||
/** ---- 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",
|
||||
onSelect: function(suggestion) {
|
||||
// serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete",
|
||||
// onSelect: function(suggestion) {
|
||||
|
||||
var data = suggestion.ConfigValue;
|
||||
var selectedvalue = $('input[name=MaterialCategory]').val();
|
||||
}
|
||||
// var data = suggestion.ConfigValue;
|
||||
// var selectedvalue = $('input[name=MaterialCategory]').val();
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
});
|
||||
|
||||
@ -526,16 +487,17 @@ if ($total <= $reorder) {
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
if(response.status=="201"){
|
||||
if(response.status== 201 ){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
$("#materialCategoryInput").val('');
|
||||
$("#MaterialCategory").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`)
|
||||
}
|
||||
else if(response.status=="409"){
|
||||
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
|
||||
$('#MaterialCategory').val(materialCategory);
|
||||
$("#materialCategoryInput").val('');
|
||||
// $('#MaterialCategory').val(materialCategory);
|
||||
|
||||
$('#MaterialCategory').trigger('change');
|
||||
|
||||
@ -543,6 +505,7 @@ if ($total <= $reorder) {
|
||||
}
|
||||
else{
|
||||
$("#addMaterialCaterogyModal").modal('hide');
|
||||
$("#materialCategoryInput").val('');
|
||||
|
||||
setTimeout(()=>{ alert('Error Adding Category..!!'); },1000)
|
||||
|
||||
|
||||
@ -153,9 +153,9 @@ if (!empty($master)) {
|
||||
<td>
|
||||
<?php if ($con->isActive == 0) { ?>
|
||||
|
||||
<a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'configurationctrl/reActivateConfigValue
|
||||
?ConfigValue=' . $con->ConfigValue . '
|
||||
&ConfigID=' . $con->Config_ID; ?>"
|
||||
<a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'activeInactiveConfigValue
|
||||
?key=' . $con->Key . '
|
||||
&value=1'; ?>"
|
||||
data-toggle="tooltip" title="<?php echo $con->Config_ID ?> - Click here to Re
|
||||
activate Config Details"><i class="fas fa-key"></i>
|
||||
</a>
|
||||
@ -170,9 +170,9 @@ if (!empty($master)) {
|
||||
|
||||
|
||||
|
||||
<a onclick="confirmDeleteConfig(event)" href="<?php echo base_url() . 'configurationctrl/deleteConfigValue
|
||||
?ConfigValue=' . $con->ConfigValue . '
|
||||
&ConfigID=' . $con->Config_ID; ?>">
|
||||
<a onclick="confirmDeleteConfig(event)" href="<?php echo base_url() . 'activeInactiveConfigValue
|
||||
?key=' . $con->Key . '
|
||||
&value=0'; ?>">
|
||||
<i class="fas fa-trash" data-toggle="tooltip"
|
||||
title="Click here to Delete the Config Value"></i>
|
||||
</a>
|
||||
|
||||
@ -67,19 +67,33 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<form class="Date-filter-form" id="DateRangeFilter"
|
||||
style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
|
||||
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px; margin-bottom: -11px; margin-left: 33px;">
|
||||
|
||||
<input type="hidden" name="table" value="requisition">
|
||||
|
||||
<label for="fromDate">From:</label>
|
||||
<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>
|
||||
<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"
|
||||
class="icon-button" title="Search"></i></button>
|
||||
|
||||
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton"
|
||||
title="Reset"></i>
|
||||
|
||||
@ -91,11 +105,11 @@
|
||||
Show Archive
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="error" id="error"></div>
|
||||
</form>
|
||||
|
||||
<div class="card-body" style="overflow-x:scroll;">
|
||||
<table id="raw_material_list_table" class="table dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
@ -357,52 +371,119 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
// Date range filter function
|
||||
$.fn.dataTable.ext.search.push(
|
||||
function (settings, data, dataIndex) {
|
||||
var fromDate = $('#fromDate').val();
|
||||
var toDate = $('#toDate').val();
|
||||
// $.fn.dataTable.ext.search.push(
|
||||
// function (settings, data, dataIndex) {
|
||||
// var fromDate = $('#fromDate').val();
|
||||
// var toDate = $('#toDate').val();
|
||||
|
||||
if (!fromDate || !toDate) {
|
||||
return true; // If no dates selected, don't filter
|
||||
}
|
||||
// if (!fromDate || !toDate) {
|
||||
// return true; // If no dates selected, don't filter
|
||||
// }
|
||||
|
||||
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
|
||||
var fromParts = fromDate.split("-");
|
||||
var toParts = toDate.split("-");
|
||||
// // Convert the fromDate and toDate from dd-mm-yyyy to Date objects
|
||||
// var fromParts = fromDate.split("-");
|
||||
// var toParts = toDate.split("-");
|
||||
|
||||
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 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]);
|
||||
|
||||
// Adjust startDate to include the day before the selected fromDate
|
||||
startDate.setDate(startDate.getDate() - 1);
|
||||
// // Adjust startDate to include the day before the selected fromDate
|
||||
// startDate.setDate(startDate.getDate() - 1);
|
||||
|
||||
// Ensure endDate includes the entire end date by setting time to the end of the day
|
||||
endDate.setHours(23, 59, 59, 999);
|
||||
// // Ensure endDate includes the entire end date by setting time to the end of the day
|
||||
// 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)
|
||||
var dateStr = data[0];
|
||||
var dateParts = dateStr.split("-");
|
||||
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
|
||||
// // Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
|
||||
// var dateStr = data[0];
|
||||
// var dateParts = dateStr.split("-");
|
||||
// var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
|
||||
|
||||
// Return true if the row date is within the range
|
||||
return rowDate >= startDate && rowDate <= endDate;
|
||||
}
|
||||
);
|
||||
// // Return true if the row date is within the range
|
||||
// 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
|
||||
$("#DateRangeFilter").submit(function (e) {
|
||||
e.preventDefault();
|
||||
table.draw(); // Redraw the table to apply the filter
|
||||
});
|
||||
var fromDate = $("#fromDate").val();
|
||||
var toDate = $("#toDate").val();
|
||||
|
||||
if (fromDate && !toDate) {
|
||||
alert("Please select 'To Date' if 'From Date' is chosen.");
|
||||
e.preventDefault();
|
||||
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
|
||||
$("#resetButton").click(function () {
|
||||
$("#fromDate").val('');
|
||||
$("#toDate").val('');
|
||||
$("#category").val('');
|
||||
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 () {
|
||||
var fromDate = this.value;
|
||||
var toDateInput = document.getElementById('toDate');
|
||||
@ -415,6 +496,7 @@ $(document).ready(function () {
|
||||
toDateInput.value = fromDate;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user