424 lines
19 KiB
PHP
Executable File
424 lines
19 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' => '20');
|
||
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> 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>
|
||
<tr>
|
||
<th>S.NO</th>
|
||
<th>Config 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>
|
||
<td><?php echo $index; ?></td>
|
||
<td><?php echo $con->ConfigValue; ?></td>
|
||
<td><a data-target='#Edit' data-id="<?php echo $index; ?>" data-userid="<?php echo $index; ?>" data-toggle="modal" href="#Edit"><i class="fas fa-pencil-alt" data-toggle="tooltip" title="Click here to view/Edit the Budget details"></i> </a></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="submit" 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"><i class="fa fa-plus"></i> 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 Config</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">
|
||
Config 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="fa fa-pencil"></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="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 = $('#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="ri-pencil-fill"></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>
|