siddharth_application/application/views/addconfig.php
2017-09-06 14:42:18 +05:30

618 lines
18 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear() ;
var SIAStartYear = year - 2015;
var mindt = year-70;
var maxdt = year-15;
$("#AddYear").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :new Date(year+3,1,1),
dateFormat: 'yy', changeYear: true,
});
$("#EditYear").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :new Date(year+3,1,1),
dateFormat: 'yy', changeYear: true,
});
//$('#selectDistriList').multiSelect();
});
</script>
<style>
.ui-datepicker-month {
display: none;
}
.ui-datepicker-prev{
display: none;
}
.ui-datepicker-next{
display: none;
}
</style>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Siddharth Industries - Add Configuration List</center>
</h1>
</section>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url() ?>configlisting" class="btn btn-primary" value="Back">Back</a>
</div>
<br>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<div class="box box-primary">
<?php
$attributes = array('class' => 'form-label-left addconfig ','name' => 'addconfig','id' => 'addconfig');
echo form_open($this->config->base_url().'addNewconfig/',$attributes); ?>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<!-- <div class="col-md-4">
<div class="form-group">
<label>Configuration ID</label>
<div class="form-group">
<?php
$data = array('name' => 'Configid','value' => set_value('Configid'),'id'=>'Configid', 'class' => 'form-control' );
echo form_input($data);
?>
</div>
</div>
</div> -->
<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-primary"><i class="fa fa-plus"></i>&nbsp;&nbsp;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">&times;</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-primary font tempClick" ID="tempClick" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
<a class="btn btn-primary" 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-striped responsive-utilities jambo_table" >
<thead style="background-color: #CFCFCF;">
<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>&nbsp;&nbsp;&nbsp;</a>
<a><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</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">&times;</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">
Budget Amount :
</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>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-primary font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
<a class="btn btn-primary" 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-primary" value="Submit" />
<a href="" class="btn btn-primary" id="cancel" value="Cancel">Cancel</a>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-4">
<?php
$this->load->helper('form');
$error = $this->session->flashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = $this->session->flashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo $this->session->flashdata('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">×</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>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>
</script>
<script>
var index = '1';
var numbers = /^[0-9]+$/;
var userid = '';
$("#Edit").on("shown.bs.modal", function(e) {
//alert();
userid = $(e.relatedTarget).data('userid');
var s = $('#ConfigValue').val($('#configtable tr:eq('+ userid +') td:eq(0)').text());
alert(s);
});
$('.tempClick').click(function(){
// if ($("#Addbudget option:selected").val() =='-1' )
// {
// alert('Please Select the Budget Type ');
// //return;
// }
// if(document.getElementById('AddYear').value == '' )
// {
// alert('Please Enter the Budget Year');
// //return;
// }
// if(document.getElementById('AddAmout').value == '' )
// {
// alert('Please Enter the Budget Amount');
// // return;
// }
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;
theForm.append(input);
}
$('.tempClickEdit').click(function(){
// if(document.getElementById('EditYear').value == '' )
// {
// alert('Please Enter the Budget Year');
// //return;
// }
// if(document.getElementById('EditAmout').value == '' )
// {
// alert('Please Enter the Budget Amount');
// // return;
// }
if ( $('#EditAmout').val() != '' && $('#EditYear').val() != '' )
{
var temp = index;
var ConfigValue = $("#ConfigValue").val();
$('#configtable tr:eq('+ userid +') td:eq(1)').text(ConfigValue);
$('#ConfigValue'+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;
}
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>
$('#addPop').click(function () {
if ($('#distriList option:selected').val() != null) {
var tempSelect = $('#distriList option:selected').val();
var tempText = $('#distriList option:selected').text();
var o = new Option(tempText,tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
var Selectedval = ''
if(orgVal != '')
{
Selectedval = orgVal + ':' + hidval;
}
else
{
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
$(o).html(tempText);
$("#selectDistriList").append(o);
$('#distriList option:selected').remove();
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
tempSelect = '';
tempText = '';
Selectedval = '';
} else {
alert("Before add please select any position.");
}
});
$('#removePop').click(function () {
if ($('#selectDistriList option:selected').val() != null) {
Selectedval ='';
$('#txtSelectedDepartment').val(Selectedval);
var tempSelect = $('#selectDistriList option:selected').val();
$('#selectDistriList option:selected').remove().appendTo('#distriList');
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#distriList").val(tempSelect);
tempSelect = '';
} else {
alert("Before remove please select any position.");
}
});
var baseurl = "<?php print base_url(); ?>";
$(".addCost").submit(function(e) {
e.preventDefault();
if(validate())
{
$('#content').loader('show');
$.ajax({
data:$('.addCost').serialize(),
type:"POST",
url:"<?php echo base_url() ?>configurationctrl/addNewconfig",
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
window.location = baseurl + 'CostCenter/CostListing';
}
else
{
alert("Error");
}
}
});
}
});
function validate()
{
if($("#txtSelectedDepartment").val().length < 1)
{
alert('Please Select Department');
return false;
}
else if($("#txtRowCount").val().length < 1)
{
alert('Please Add Budget');
return false;
}
else if($("option:selected", $("#ApprovedBy")).val() == '-1')
{
alert('Please Select Approver Names');
return false;
}
else
{
return true;
}
}
</script>