446 lines
14 KiB
PHP
446 lines
14 KiB
PHP
<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-wrapper" style="min-height: 537px;">
|
||
<!-- Content Header (Page header) -->
|
||
<section class="content-header">
|
||
<h1><center> Edit Config Details</center></h1>
|
||
</section>
|
||
|
||
<section class="content">
|
||
<div style="text-align:right;">
|
||
<a href="<?php echo base_url() ?>configlisting" class="btn btn-cancel" value="Back">Back</a>
|
||
</div>
|
||
<br>
|
||
|
||
<div class="row">
|
||
<!-- left column -->
|
||
<div class="col-md-12">
|
||
<?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 } ?>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>');
|
||
?> </div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12">
|
||
<div class="box box-success">
|
||
<!-- form start -->
|
||
<?php
|
||
$attributes = array('class' => 'form-label-left editConfig ', 'name' => 'editConfig', 'id' => 'editConfig');
|
||
|
||
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
|
||
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="CostName">Configuration ID </label><font color="Red">*</font>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'ConfigId', 'value' => set_value('ConfigId', $ConfigId), 'id' => 'ConfigId', 'class' => 'form-control', 'required' => 'true', 'readonly' => 'true', 'onclick' => 'al();');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="Description">Configuration Name</label>
|
||
<font color="Red">*</font>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'ConfigName', 'value' => set_value('ConfigName', $ConfigName), 'id' => 'CostName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20'); //'style'=>'text-transform:uppercase;'
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="Remarks">Comments</label>
|
||
<font color="Red">*</font>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'Remarks', 'value' => set_value('Remarks', $Comments), 'id' => 'CostName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<br>
|
||
<div col="row">
|
||
<div style="text-align:right">
|
||
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i> Add Configuration</a>
|
||
<!-- Modal -->
|
||
<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">
|
||
<button type="button" class="close" data-dismiss="modal">
|
||
<span aria-hidden="true">×</span>
|
||
<span class="sr-only">Close</span>
|
||
</button>
|
||
<h4 class="modal-title" id="myModalLabel">
|
||
<center> Add Configuration</center>
|
||
</h4>
|
||
</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">
|
||
Configuration Value :
|
||
</div>
|
||
<div class="col-md-5">
|
||
|
||
<input class="form-control" name="AddConfigValue" class="form-control" id="AddConfigValue" type="text">
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
|
||
<a class="btn btn-success font tempClickAdd" ID="tempClickAdd" style="margin-top: -24px;"><i class="fa fa-plus"></i> <span class="bold">Add</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><br>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="table-responsive">
|
||
<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>Config Value</th>
|
||
<th>Action</th>
|
||
</thead>
|
||
<tbody id="tempAppend">
|
||
<?php if (!empty($master && $child)) {
|
||
$index = 0;
|
||
foreach ($child as $con) {
|
||
?>
|
||
<?php $index = $index + 1; ?>
|
||
<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="fa fa-pencil" 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>
|
||
<!-- Modal For edit -->
|
||
<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">
|
||
<button type="button" class="close" data-dismiss="modal">
|
||
<span aria-hidden="true">×</span>
|
||
<span class="sr-only">Close</span>
|
||
</button>
|
||
<h4 class="modal-title" id="myModalLabel">
|
||
<center> Edit Config</center>
|
||
</h4>
|
||
</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' => 'EditConfigValue', 'value' => set_value('EditConfigValue'), 'id' => 'EditConfigValue', 'class' => 'form-control');
|
||
echo form_input($data);
|
||
?>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
|
||
<a class="btn btn-success font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i> <span class="bold">Update</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="box-footer" style="text-align:right">
|
||
<a href="<?php echo base_url() ?>configlisting" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
|
||
<input type="submit" class="btn btn-success" value="Update" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</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>
|
||
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());
|
||
$('#EditConfigValue').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').show();
|
||
|
||
|
||
var ConfigValue = $("#AddConfigValue").val();
|
||
|
||
$('#AddConfigValue').val('');
|
||
|
||
|
||
index = parseInt(index) + 1;
|
||
var temp = index;
|
||
|
||
|
||
var template = jQuery("#tempList").html();
|
||
|
||
$('#tempAppend').append(_.template(template, {
|
||
index: temp,
|
||
ConfigValue: ConfigValue,
|
||
}));
|
||
|
||
var theForm = $(".editConfig");
|
||
|
||
addHidden(theForm, "DbKey" + temp, 0);
|
||
addHidden(theForm, "configVal" + temp, ConfigValue);
|
||
|
||
$('#txtRowCount').val(temp);
|
||
|
||
//CountRows();
|
||
} 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);
|
||
}
|
||
|
||
$('.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);
|
||
|
||
$('#Config_ID' + userid).val($('#ConfigId').val());
|
||
$('#EditConfigValue' + userid).val(ConfigValue);
|
||
$("#configVal" + userid).val(ConfigValue);
|
||
|
||
|
||
} 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;
|
||
}
|
||
</script>
|
||
|
||
<script>
|
||
//var baseurl = "<?php print base_url(); ?>";
|
||
$(".editConfig").submit(function(e) {
|
||
if (validate()) {
|
||
|
||
$('#content').loader('show');
|
||
$.ajax({
|
||
data: $('.editConfig').serialize(),
|
||
type: 'POST',
|
||
url: "<?php echo base_url(); ?>configurationctrl/configedit",
|
||
success: function(data) {
|
||
//alert(data);
|
||
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>
|