471 lines
13 KiB
PHP
Executable File
471 lines
13 KiB
PHP
Executable File
<style>
|
||
th {
|
||
background-color: #ddd;
|
||
}
|
||
</style>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
|
||
|
||
<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">Add Config 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" style="padding: 1rem 2rem !important;">
|
||
<form role="form" id="addconfig" action="<?php echo base_url() ?>configurationctrl/saveconfig" method="post">
|
||
<div class="form-row" style="margin-top:10px">
|
||
<div class=" col-md-3">
|
||
<label class="col-form-label" for="ConfigurationName">Configuration Name</label>
|
||
<font color="Red">*</font>
|
||
<?php
|
||
$data = array('name' => 'configurationname', 'value' => set_value('configurationname'), 'id' => 'configurationname', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
|
||
echo form_input($data); ?>
|
||
</div>
|
||
<div class=" col-md-3">
|
||
<label class="col-form-label" for="Comments">Comments</label>
|
||
<font color="Red">*</font>
|
||
<?php
|
||
$data = array('name' => 'Comments', 'value' => set_value('Comments'), 'id' => 'Comments', '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> Add Configuration</a>
|
||
</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>
|
||
<th>S.NO</th>
|
||
<th>Configuration Value</th>
|
||
<th>Action</th>
|
||
</thead>
|
||
|
||
<tbody id="tempAppend">
|
||
<!--<tr>
|
||
<td>001</td>
|
||
<td>100</td>
|
||
|
||
<td>
|
||
<a data-toggle="modal" href="#Edit"><i class="fa fa-pencil"></i> </a>
|
||
<a><i class="fa fa-trash"></i> </a>
|
||
</td>
|
||
</tr>-->
|
||
</tbody>
|
||
|
||
</table>
|
||
<input type="hidden" name="newhidden" id="newhidden" />
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12 text-right">
|
||
<input type="hidden" name="txtRowCount" id="txtRowCount" />
|
||
<a class="btn btn-secondary" href="<?php echo base_url() ?>configlisting" class="btn btn-secondary">Cancel</a>
|
||
<input type="button" id="addConFigBtnId" value="Submit" class="btn btn-success">
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<!-- end row -->
|
||
</div>
|
||
</div> <!-- end card -->
|
||
</div><!-- end col -->
|
||
<?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"><3E></button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
</div> <!-- end row -->
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
|
||
<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="ConfigValue" class="form-control" required="true" id="ConfigValue" 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" value="Cancel">Cancel</a>
|
||
<a class="btn btn-success font tempClickAdd" ID="tempClickAdd"><i class="fa fa-plus"></i> <span class="bold">Add</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<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">
|
||
<center> Edit Configuration</center>
|
||
</h4>
|
||
|
||
<button type="button" class="close" data-dismiss="modal">
|
||
<span aria-hidden="true">×</span>
|
||
<span class="sr-only">Close</span>
|
||
</button>
|
||
|
||
</div>
|
||
<!-- Modal Body -->
|
||
<div class="modal-body">
|
||
<div class="row">
|
||
<div class="col-md-3 col-md-offset-2">
|
||
Configuration Value :
|
||
</div>
|
||
<div class="col-md-5">
|
||
<?php
|
||
$data = array('name' => 'EditConfigValue', 'value' => set_value('EditConfigValue'), 'id' => 'EditConfigValue', 'class' => 'form-control');
|
||
echo form_input($data);
|
||
?>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
|
||
<a class="btn btn-success tempClickEdit" style="background-color: light-blue;border: none;margin-right:10px"#addconfigID="tempClickEdit" ><span class="bold">Edit</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script type="text/html" id="tempList">
|
||
<tr id="<%=index%>">
|
||
|
||
<?php
|
||
$data = array('name' => '"ConfigValue[<%=index%>][index]"', 'value' => set_value('<%=index%>'), 'id' => '"ConfigValue[<%=index%>][index]"', 'class' => 'form-control', 'type' => 'hidden');
|
||
echo form_input($data);
|
||
?>
|
||
<td align="left"><%=index%></td>
|
||
<td align="left"><%=ConfigValue%></td>
|
||
|
||
|
||
<td>
|
||
<a class="editConfig" data-target='#Edit' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#Edit"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <%=ConfigValue%> Budget details"></i> </a>
|
||
|
||
|
||
</td>
|
||
</tr>
|
||
</script>
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
var index = '1';
|
||
var numbers = /^[0-9]+$/;
|
||
var userid = '';
|
||
|
||
$("#Edit").on("shown.bs.modal", function(e) {
|
||
userid = $(e.relatedTarget).data('userid');
|
||
|
||
var s = $('#configtable tr:eq(' + userid + ') td:eq(1)').text()
|
||
$("#EditConfigValue").val(s);
|
||
});
|
||
|
||
|
||
$('.tempClickAdd').click(function() {
|
||
if ($("#ConfigValue").val() != '-1' && $("#ConfigValue").val() != null && $("#ConfigValue").val() != '') {
|
||
|
||
$('#ConfigValue').show();
|
||
var temp = index;
|
||
var ConfigValue = $("#ConfigValue").val();
|
||
|
||
|
||
|
||
$('#ConfigValue').val('');
|
||
|
||
|
||
index = parseInt(index) + 1;
|
||
|
||
|
||
|
||
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>
|
||
|
||
</a>
|
||
</td>
|
||
</tr>`;
|
||
$('#tempAppend').append(html);
|
||
|
||
var theForm = $("#addconfig");
|
||
|
||
addHidden(theForm, "ConfigValue" + temp, ConfigValue);
|
||
|
||
|
||
$('#txtRowCount').val(temp);
|
||
|
||
$('#AddConfiguration').modal('hide');
|
||
//CountRows();
|
||
} else {
|
||
alert('Please enter a value');
|
||
|
||
}
|
||
|
||
});
|
||
|
||
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;
|
||
input.id = key;
|
||
$(theForm).append(input);
|
||
}
|
||
|
||
|
||
$('.tempClickEdit').click(function() {
|
||
|
||
|
||
if ($("#EditConfigValue").val() != '') {
|
||
|
||
|
||
var temp = index;
|
||
var ConfigValue = $("#EditConfigValue").val();
|
||
//alert(userid);
|
||
|
||
$('#configtable tr:eq(' + userid + ') td:eq(1)').text(ConfigValue);
|
||
|
||
//alert($('#hConfigValue'+userid).val());
|
||
//$('#hConfigValue'+userid).val(ConfigValue);
|
||
$("#ConfigValue" + userid).val(ConfigValue); //ConfigValue2
|
||
|
||
|
||
|
||
$("#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;
|
||
}
|
||
|
||
|
||
function Rowcount() {
|
||
var rowCount = $('#configtable').length;
|
||
if (rowCount == '4') {
|
||
$("#AddConfiguration").modal('hide');
|
||
|
||
} else {
|
||
|
||
$("#AddConfiguration").modal('show');
|
||
}
|
||
|
||
}
|
||
|
||
|
||
var totalRowCount = 0;
|
||
var rowCount = 0;
|
||
var table = document.getElementById("configtable");
|
||
var rows = table.getElementsByTagName("tr");
|
||
|
||
function CountRows() {
|
||
totalRowCount = 0;
|
||
rowCount = 0;
|
||
table = document.getElementById("ConfigValue");
|
||
rows = table.getElementsByTagName("tr")
|
||
for (var i = 0; i < rows.length; i++) {
|
||
totalRowCount++;
|
||
if (rows[i].getElementsByTagName("td").length > 0) {
|
||
rowCount++;
|
||
}
|
||
}
|
||
|
||
|
||
var message = "Total Row Count: " + totalRowCount;
|
||
message += "\nRow Count: " + rowCount;
|
||
//alert(message);
|
||
if (totalRowCount > "4") {
|
||
$("#AddConfiguration").modal('hide');
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<script>
|
||
$('#addConFigBtnId').click(function (){
|
||
|
||
|
||
|
||
if($('#configurationname').val().trim() == ''){
|
||
alert('Please enter Configuration Name..!!');
|
||
return;
|
||
}
|
||
|
||
if($('#Comments').val().trim() == ''){
|
||
alert('Please enter comments..!!');
|
||
return;
|
||
}
|
||
|
||
|
||
$('#loader').show();
|
||
$.ajax({
|
||
|
||
data: {configName: $('#configurationname').val().trim() , configId : $('#ConfigId').val()??''},
|
||
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..!!");
|
||
$('#configurationname').val('');
|
||
return;
|
||
}else{
|
||
alert("This Configuration Name is already present in deleted section. kindly reactivate it If needed..!!");
|
||
$('#configurationname').val('');
|
||
return;
|
||
}
|
||
}else{
|
||
$('#addconfig').submit();
|
||
}
|
||
|
||
},
|
||
error:function(error){
|
||
console.log("error occured..!!" ,error);
|
||
},
|
||
complete:function(){
|
||
$('#loader').hide();
|
||
console.log('ajax call completed..!!');
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
</script>
|
||
|
||
<script>
|
||
$('#ConfigValue , #EditConfigValue').change(function(){
|
||
let configValue = $(this).val();
|
||
let configTable = $('#configtable').tableToJSON();
|
||
let configValueExisting = configTable.map(element => element['Configuration Value']);
|
||
let result = configValueExisting.includes(configValue);
|
||
|
||
if(result){
|
||
alert('configuration value is already present..!!');
|
||
$(this).val('');
|
||
return false;
|
||
}
|
||
|
||
})
|
||
</script>
|
||
|
||
|
||
|
||
<script>
|
||
|
||
$(document).on('keydown', function(event) {
|
||
if (event.key === 'Enter') {
|
||
event.preventDefault(); // Prevent default Enter key behavior
|
||
}
|
||
});
|
||
|
||
</script>
|