648 lines
27 KiB
PHP
Executable File
648 lines
27 KiB
PHP
Executable File
<script>
|
||
//window.onload=al();
|
||
function al() {
|
||
alert($('#ConfigId').val());
|
||
}
|
||
</script>
|
||
<?php
|
||
$ConfigId = '';
|
||
$ConfigName = '';
|
||
$Comments = '';
|
||
$ConfigValue = '';
|
||
|
||
if (!empty($master)) {
|
||
foreach ($master as $con) {
|
||
$ConfigId = $con->Config_ID;
|
||
$ConfigName = $con->ConfigName;
|
||
$Comments = $con->Comments;
|
||
}
|
||
}
|
||
?>
|
||
|
||
<div class="content-page">
|
||
<div class="content">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<h4 class="page-title">Edit Config <?= ' - ' . $ConfigName; ?> Details</h4>
|
||
<a class="btn btn-secondary" href="<?php echo base_url(); ?>configlisting"><span
|
||
class="bold">Back</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-info alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<!-- end page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<?php
|
||
$attributes = array('class' => 'form-horizontal', 'id' => 'editConfig');
|
||
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
|
||
|
||
<div class="form-row" style="margin-top:10px">
|
||
<div class="col-md-3">
|
||
<label class="col-form-label" for="ConfigId">Configuration ID</label>
|
||
<font color="Red">*</font>
|
||
<?php
|
||
$data = array('name' => 'ConfigId', 'value' => set_value('ConfigId', $ConfigId), 'id' => 'ConfigId', 'class' => 'form-control', 'required' => 'true', 'readonly' => 'true');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<label class="col-form-label" for="ConfigName">Configuration Name</label>
|
||
<font color="Red">*</font>
|
||
<?php
|
||
$data = array('name' => 'ConfigName', 'value' => set_value('ConfigName', $ConfigName), 'id' => 'ConfigName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '30');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<label class="col-form-label" for="Remarks"> Comments </label>
|
||
<font color="Red">*</font>
|
||
<?php
|
||
$data = array('name' => 'Remarks', 'value' => set_value('Remarks', $Comments), 'id' => 'Remarks', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" style="margin-top:10px">
|
||
<div class="col-md-12 text-right">
|
||
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;"
|
||
class="btn btn-success"><i class="fa fa-plus"></i>
|
||
Configuration Value</a>
|
||
</div>
|
||
</div>
|
||
|
||
<br>
|
||
<div>
|
||
<div align="right">
|
||
<div class="form-check" style="margin-right: 25px;">
|
||
<input class="form-check-input" type="checkbox" id="showChildArchiveId"
|
||
name="showChildArchive" value="1" onchange="showChildArchiveList()"
|
||
style="width: 18px; height: 18px;">
|
||
<label class="form-check-label" for="showChildArchiveId"
|
||
style="font-size: 1rem; margin-left: 8px;">
|
||
Show Archive
|
||
</label>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row" style="margin-top:10px">
|
||
<div class="col-md-12">
|
||
<table id="configtable"
|
||
class="table table-bordered table-hover responsive-utilities jambo_table"
|
||
style="background-color:#fff;font-size:12px;">
|
||
<thead>
|
||
<tr>
|
||
<th>S.NO</th>
|
||
<th>Configuration Value</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="tempAppend">
|
||
<?php if (!empty($master && $child)) {
|
||
$index = 0;
|
||
foreach ($child as $con) {
|
||
$index++;
|
||
?>
|
||
|
||
<input type="hidden" name="DbKey<?php echo $index ?>"
|
||
id="DbKey<?php echo $index ?>" value="<?php echo $con->Key ?>">
|
||
<input type="hidden" name="configVal<?php echo $index ?>"
|
||
id="configVal<?php echo $index ?>"
|
||
value="<?php echo $con->ConfigValue ?>">
|
||
|
||
<tr class="<?php if ($con->isActive == 0) {
|
||
echo "deactivatedRow";
|
||
} ?>" style="<?php if ($con->isActive == 0) {
|
||
echo "display:none";
|
||
} ?>">
|
||
|
||
<td><?php echo $index; ?></td>
|
||
<td><?php echo $con->ConfigValue; ?></td>
|
||
<td>
|
||
<?php if ($con->isActive == 0) { ?>
|
||
|
||
<a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'configurationctrl/reActivateConfigValue
|
||
?ConfigValue=' . $con->ConfigValue . '
|
||
&ConfigID=' . $con->Config_ID; ?>"
|
||
data-toggle="tooltip" title="<?php echo $con->Config_ID ?> - Click here to Re
|
||
activate Config Details"><i class="fas fa-key"></i>
|
||
</a>
|
||
|
||
<?php } else { ?>
|
||
|
||
<a data-target='#Edit' data-id="<?php echo $index; ?>"
|
||
data-userid="<?php echo $index; ?>" data-toggle="modal"
|
||
href="#Edit"><i class="fas fa-edit" data-toggle="tooltip"
|
||
title="Click here to Edit Config Value"></i>
|
||
</a>
|
||
|
||
|
||
|
||
<a onclick="confirmDeleteConfig(event)" href="<?php echo base_url() . 'configurationctrl/deleteConfigValue
|
||
?ConfigValue=' . $con->ConfigValue . '
|
||
&ConfigID=' . $con->Config_ID; ?>">
|
||
<i class="fas fa-trash" data-toggle="tooltip"
|
||
title="Click here to Delete the Config Value"></i>
|
||
</a>
|
||
|
||
|
||
<?php } ?>
|
||
|
||
</td>
|
||
</tr>
|
||
<?php }
|
||
} ?>
|
||
<input type="hidden" name="txtRowCount" id="txtRowCount"
|
||
value="<?php echo $index ?>" />
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row text-right" style="margin-top:10px; text-align:right">
|
||
<div class="col-md-12 text-right">
|
||
<a href="<?php echo base_url() ?>configlisting" class="btn btn-secondary">Cancel</a>
|
||
<input type="button" id="updateConfigBtnId" class="btn btn-success" value="Update" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Modal For Add Configuration -->
|
||
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||
aria-hidden="true">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<!-- Modal Header -->
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myModalLabel">Add Configuration</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<!-- Modal Body -->
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" role="form">
|
||
<div class="form-group">
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
Configuration Value :
|
||
</div>
|
||
<div class="col-md-5">
|
||
<input class="form-control" name="AddConfigValue" id="AddConfigValue"
|
||
type="text">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
|
||
data-dismiss="modal">Cancel</a>
|
||
<a class="btn btn-success font tempClickAdd" id="tempClickAdd"> Add </a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Modal For Edit Configuration -->
|
||
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||
aria-hidden="true">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<!-- Modal Header -->
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myModalLabel">Edit Configuration</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<!-- Modal Body -->
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" role="form">
|
||
<div class="form-group">
|
||
<div class="row">
|
||
<div class="col-md-3 col-md-offset-2">
|
||
S.NO :
|
||
</div>
|
||
<div class="col-md-5">
|
||
<?php
|
||
$data = array('name' => 'key', 'value' => set_value('key'), 'id' => 'key', 'class' => 'form-control', 'readonly' => 'true');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<div class="row">
|
||
<div class="col-md-3 col-md-offset-2">
|
||
Config ID :
|
||
</div>
|
||
<div class="col-md-5">
|
||
<?php
|
||
$data = array('name' => 'Config_ID', 'value' => set_value('Config_ID'), 'id' => 'Config_ID', 'class' => 'form-control', 'readonly' => 'true');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<div class="row">
|
||
<div class="col-md-3 col-md-offset-2">
|
||
Configuration Value :
|
||
</div>
|
||
<div class="col-md-5">
|
||
<?php
|
||
$data = array('name' => 'configValue', 'value' => set_value('configValue'), 'id' => 'configValue', 'class' => 'form-control');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
|
||
data-dismiss="modal">Cancel</a>
|
||
<a class="btn btn-success font tempClickUpdate" id="tempClickUpdate"><i
|
||
class="fas fa-edit"></i> Update</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<script type="text/html" id="tempList">
|
||
<tr id="<%=index%>">
|
||
|
||
<?php
|
||
$data = array('name' => '"configVal[<%=index%>][index]"', 'value' => set_value('<%=index%>'), 'id' => '"configVal[<%=index%>][index]"', 'class' => 'form-control', 'type' => 'hidden');
|
||
echo form_input($data);
|
||
?>
|
||
<td align="left"><%=index%></td>
|
||
<td align="left"><%=ConfigValue%></td>
|
||
|
||
|
||
<td>
|
||
<a data-target='#Edit' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#Edit"><i class="fas fa-edit" data-toggle="tooltip" title="Click here to view/Edit the <%=ConfigValue%> Budget details"></i> </a>
|
||
</td>
|
||
</tr>
|
||
</script>
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
var index = $('#txtRowCount').val();
|
||
var userid = '';
|
||
|
||
$("#Edit").on("shown.bs.modal", function(e) {
|
||
userid = $(e.relatedTarget).data('userid');
|
||
$('#key').val($('#configtable tr:eq(' + userid + ') td:eq(0)').text());
|
||
$('#Config_ID').val($('#ConfigId').val());
|
||
$('#configValue').val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
|
||
$('#ConfigVal' + userid).val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
|
||
|
||
});
|
||
|
||
$('.tempClickAdd').click(function() {
|
||
|
||
var cid = $('#ConfigId').val()
|
||
if ($("#AddConfigValue").val() != '-1' && $("#AddConfigValue").val() != null && $("#AddConfigValue").val() != '') {
|
||
|
||
$('#AddConfigValue').show();
|
||
|
||
var ConfigValue = $("#AddConfigValue").val();
|
||
|
||
$('#AddConfigValue').val('');
|
||
|
||
|
||
index = parseInt(index) + 1;
|
||
var temp = index;
|
||
|
||
|
||
var template = jQuery("#tempList").html();
|
||
var html = `
|
||
<tr id="${temp}">
|
||
<td>${temp}</td>
|
||
<td>${ConfigValue}</td>
|
||
<td>
|
||
<a class="editConfig" data-target='#Edit' data-id="${temp}" data-index="${index}" data-userid="${temp}" data-toggle="modal" href="#Edit">
|
||
<i class="fas fa-edit"></i>
|
||
</a>
|
||
|
||
|
||
</td>
|
||
</tr>`;
|
||
$('#tempAppend').append(html);
|
||
|
||
var theForm = $(".editConfig");
|
||
|
||
addHidden(theForm, "DbKey" + temp, 0);
|
||
addHidden(theForm, "configVal" + temp, ConfigValue);
|
||
|
||
$('#txtRowCount').val(temp);
|
||
|
||
//CountRows();
|
||
$('#AddConfiguration').modal('hide');
|
||
|
||
} else {
|
||
alert('Please enter all the values');
|
||
|
||
}
|
||
|
||
});
|
||
|
||
|
||
function addHidden(theForm, key, value) {
|
||
// Create a hidden input element, and append it to the form:
|
||
var input = document.createElement('input');
|
||
input.type = 'hidden';
|
||
input.name = key;
|
||
'name-as-seen-at-the-server';
|
||
input.value = value;
|
||
theForm.append(input);
|
||
}
|
||
|
||
$('.tempClickUpdate').click(function() {
|
||
|
||
|
||
if ($("#configValue").val() != '') {
|
||
|
||
|
||
var temp = index;
|
||
var ConfigValue = $("#configValue").val();
|
||
//alert(userid);
|
||
|
||
$('#configtable tr:eq(' + userid + ') td:eq(1)').text(ConfigValue);
|
||
|
||
//alert($('#hConfigValue'+userid).val());
|
||
//$('#hConfigValue'+userid).val(ConfigValue);
|
||
|
||
$('#Config_ID' + userid).val($('#ConfigId').val());
|
||
$('#configValue' + userid).val(ConfigValue);
|
||
$("#configVal" + userid).val(ConfigValue);
|
||
|
||
$('#Edit').modal('hide');
|
||
} else {
|
||
alert('Please enter all the values');
|
||
|
||
}
|
||
|
||
});
|
||
|
||
|
||
function ConfirmDelete() {
|
||
var x = confirm("Are you sure you want to delete?");
|
||
if (x)
|
||
return true;
|
||
else
|
||
return false;
|
||
}
|
||
|
||
function isNumberKey(evt) {
|
||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||
if (charCode != 46 && charCode > 31 &&
|
||
(charCode < 48 || charCode > 57))
|
||
return false;
|
||
|
||
return true;
|
||
}
|
||
|
||
//var baseurl = "<?php print base_url(); ?>";
|
||
$(".editConfig").submit(function(e) {
|
||
if (validate()) {
|
||
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: $('.editConfig').serialize(),
|
||
type: 'POST',
|
||
url: "<?php echo base_url(); ?>configurationctrl/configedit",
|
||
success: function(data) {
|
||
//alert(data);
|
||
$('#loader').hide();
|
||
|
||
if (data) {
|
||
$('#content').loader('hide');
|
||
//alert(data);
|
||
$('#txtSelectedDepartment').val('');
|
||
$('#txtRowCount').val('');
|
||
|
||
window.location = baseurl + 'CostCenter/CostListing';
|
||
|
||
}
|
||
|
||
}
|
||
});
|
||
//$('#content').loader('hide');
|
||
}
|
||
|
||
});
|
||
|
||
|
||
function validate() {
|
||
if ($("option:selected", $("#ApprovedBy")).val() == '-1') {
|
||
alert('Please Select Approver Names');
|
||
return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<script>
|
||
$('#updateConfigBtnId').click(function() {
|
||
|
||
|
||
|
||
if($('#ConfigName').val().trim() == ''){
|
||
alert('Please enter Configuration Name..!!');
|
||
return;
|
||
}
|
||
|
||
if($('#Remarks').val().trim() == ''){
|
||
alert('Please enter comments..!!');
|
||
return;
|
||
}
|
||
|
||
|
||
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: {
|
||
configName: $('#ConfigName').val().trim(),
|
||
configId: $('#ConfigId').val().trim()
|
||
},
|
||
type: 'POST',
|
||
url: "<?php echo base_url(); ?>configurationctrl/configNameCheck",
|
||
success: function(data) {
|
||
|
||
if (data && data.length > 0) {
|
||
|
||
if (data[0]?.isActive == 1) {
|
||
alert("This Configuration Name is already present. kindly change it..!!");
|
||
$('#ConfigName').val('');
|
||
event.preventDefault();
|
||
return false;
|
||
} else {
|
||
alert("This Configuration Name is already present in deleted section. kindly reactivate it If needed..!!");
|
||
$('#ConfigName').val('');
|
||
event.preventDefault();
|
||
return false;
|
||
}
|
||
}else{
|
||
$('#editConfig').submit();
|
||
}
|
||
|
||
},
|
||
error: function(error) {
|
||
console.log("error occured..!!", error);
|
||
},
|
||
complete: function() {
|
||
$('#loader').hide();
|
||
console.log('ajax call completed..!!');
|
||
}
|
||
});
|
||
|
||
});
|
||
</script>
|
||
|
||
<script>
|
||
$('#AddConfigValue, #configValue').change(function() {
|
||
|
||
let configValue = $(this).val();
|
||
let configTable = customTableToJson();
|
||
let configValueExisting = configTable.filter(element => element['Configuration Value'] == configValue);
|
||
|
||
if (configValueExisting && configValueExisting.length > 0) {
|
||
alert('configuration value is already present , Kindly check in Table and archive too..!!');
|
||
$(this).val('');
|
||
return false;
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<script>
|
||
function customTableToJson() {
|
||
let rows = [];
|
||
let headers = [];
|
||
|
||
// Get table headers
|
||
$(`#configtable thead tr th`).each(function() {
|
||
headers.push($(this).text().trim());
|
||
});
|
||
|
||
// Get table rows including hidden ones
|
||
$(`#configtable tbody tr`).each(function() {
|
||
let row = {};
|
||
$(this).find('td').each(function(index) {
|
||
// Use the headers as keys for JSON
|
||
let header = headers[index];
|
||
row[header] = $(this).text().trim();
|
||
});
|
||
if (Object.keys(row).length > 0) {
|
||
rows.push(row);
|
||
}
|
||
});
|
||
|
||
return rows;
|
||
}
|
||
</script>
|
||
|
||
|
||
<script>
|
||
function showChildArchiveList() {
|
||
let isChecked = $("#showChildArchiveId").prop('checked');
|
||
|
||
// Show or hide the rows based on checkbox status
|
||
$(".deactivatedRow").each(function() {
|
||
if (isChecked) {
|
||
$(this).show();
|
||
} else {
|
||
$(this).hide();
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
|
||
$(document).ready(function() {
|
||
let table = $('#configtable');
|
||
|
||
showChildArchiveList();
|
||
|
||
table.on('draw', function() {
|
||
showChildArchiveList();
|
||
});
|
||
|
||
});
|
||
|
||
function confirmDeleteConfig(event) {
|
||
let result = confirm("Do You want to delete this configuration ?");
|
||
if (result) {
|
||
return;
|
||
} else {
|
||
event.preventDefault();
|
||
}
|
||
}
|
||
|
||
function confirmReActivateConfig(event) {
|
||
let result = confirm("Do You want to Re activate deleted configuration ?");
|
||
if (result) {
|
||
return;
|
||
} else {
|
||
event.preventDefault();
|
||
}
|
||
}
|
||
</script>
|
||
|
||
|
||
<script>
|
||
$(document).on('keydown', function(event) {
|
||
if (event.key === 'Enter') {
|
||
event.preventDefault(); // Prevent default Enter key behavior
|
||
}
|
||
});
|
||
</script>
|