418 lines
12 KiB
PHP
418 lines
12 KiB
PHP
<div class="content-wrapper" style="min-height: 537px;">
|
||
<!-- Content Header (Page header) -->
|
||
<section class="content-header">
|
||
<center><b>
|
||
<h3> Add Config</h3>
|
||
</b></center>
|
||
</section>
|
||
<section class="content">
|
||
|
||
|
||
<div style="text-align:right;">
|
||
<a href="<?php echo base_url() ?>configlisting" class="btn btn-success" value="Back">Back</a>
|
||
</div>
|
||
<br>
|
||
<div class="row">
|
||
<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>
|
||
<!-- left column -->
|
||
<div class="col-md-12">
|
||
<div class="box box-success">
|
||
<?php
|
||
$attributes = ['class' => 'form-label-left addconfig', 'name' => 'addconfig', 'id' => 'addconfig'];
|
||
$route = base_url('configurationctrl/saveconfig');
|
||
echo form_open($route, $attributes);
|
||
?>
|
||
|
||
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label>Configuration Name</label>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'configurationname', 'value' => set_value('configurationname'), 'id' => 'configurationname', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label>Comments</label>
|
||
<div class="form-group">
|
||
<?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>
|
||
</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="ConfigValue" class="form-control" id="ConfigValue" type="text">
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Modal Footer -->
|
||
<div class="modal-footer">
|
||
<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>
|
||
<a class="btn btn-success" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">cancel</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>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" />
|
||
|
||
<!-- 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 Configuration</center>
|
||
</h4>
|
||
</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 font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i> <span class="bold">Edit</span></a>
|
||
|
||
<a class="btn btn-success" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">cancel</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="content"></div>
|
||
<div class="box-footer" style="text-align:right">
|
||
<!--<input type="text" name="txtRowCount" id="txtRowCount" />-->
|
||
<input type="hidden" name="txtRowCount" id="txtRowCount" />
|
||
<input type="submit" class="btn btn-success" value="Submit" />
|
||
|
||
<a href="" class="btn btn-success" id="cancel" value="Cancel">Cancel</a>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<?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 class="row">
|
||
<div class="col-md-12">
|
||
<?php //echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button></div>');
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
</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 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 = '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').show();
|
||
var temp = index;
|
||
var ConfigValue = $("#ConfigValue").val();
|
||
|
||
|
||
|
||
$('#ConfigValue').val('');
|
||
|
||
|
||
index = parseInt(index) + 1;
|
||
|
||
|
||
|
||
var template = jQuery("#tempList").html();
|
||
|
||
|
||
$('#tempAppend').append(_.template(template, {
|
||
index: temp,
|
||
ConfigValue: ConfigValue
|
||
}));
|
||
|
||
|
||
var theForm = $(".addconfig");
|
||
|
||
addHidden(theForm, "ConfigValue" + 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;
|
||
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
|
||
|
||
|
||
|
||
|
||
} 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>
|
||
|