1017 lines
28 KiB
PHP
1017 lines
28 KiB
PHP
<?php
|
|
|
|
$CostCenterCode = '';
|
|
$CostCenterName = '';
|
|
$ApprovedBy = '';
|
|
$FirstName = '';
|
|
$Designation = '';
|
|
$BudYr = '';
|
|
$FYStart = '';
|
|
$FYEnd = '';
|
|
$FYear = '';
|
|
|
|
//print_r($opt);
|
|
$a = 0;
|
|
|
|
|
|
$BudgetTypeAdd = [];
|
|
foreach ($CostBudget as $record) {
|
|
$a = +1;
|
|
$BudgetTypeAdd[$a] = $record->BudgetType;
|
|
//print_r($BudgetTypeAdd);
|
|
}
|
|
|
|
//print_r($BudgetTypeAdd);
|
|
|
|
if (!empty($CostMaster)) {
|
|
foreach ($CostMaster as $Cost) {
|
|
|
|
$CostCenterCode = $Cost->CostCenterCode;
|
|
|
|
$CostCenterName = $Cost->CostCenterName;
|
|
$ApprovedBy = $Cost->ApprovedBy;
|
|
//echo $ApprovedBy;
|
|
$FirstName = $Cost->FirstName;
|
|
$Designation = $Cost->Designation;
|
|
$BudYr = $Cost->BudYear;;
|
|
}
|
|
}
|
|
$optYear = array($BudYr => $BudYr);
|
|
if (!empty($FiscalYear)) {
|
|
foreach ($FiscalYear as $Fy) {
|
|
$FYStart = $Fy->StartYear;
|
|
$FYEnd = $Fy->EndYear;
|
|
}
|
|
//$FYear = $FYStart." - ".$FYEnd ;
|
|
|
|
}
|
|
|
|
for ($i = 1; $i < 5; $i++) {
|
|
|
|
$FYear = $FYStart . " - " . $FYEnd;
|
|
$optYear[$FYear] = $FYear;
|
|
$FYStart++;
|
|
$FYEnd++;
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<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,
|
|
|
|
|
|
|
|
//});
|
|
|
|
$(document).ready(function() {
|
|
//console.log( "ready!" );
|
|
var id = $('#drpBudget').val();
|
|
var code = $('#CostCode').val();
|
|
$.ajax({
|
|
data: {
|
|
id: id
|
|
},
|
|
dataType: 'json',
|
|
type: "POST",
|
|
url: "<?php echo base_url(); ?>CostCenter/GetBudgetForYear?BudYear=" + id + "&CostCode=" + code,
|
|
success: function(json) {
|
|
|
|
$("#Addbudget").empty();
|
|
$("#Addbudget").append(json.BudYear);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#drpBudget').change(function() {
|
|
|
|
|
|
|
|
var id = $('#drpBudget').val();
|
|
var code = $('#CostCode').val();
|
|
|
|
if (id != '-1') {
|
|
$('#content').loader('show');
|
|
|
|
$.ajax({
|
|
//data:{id:id},
|
|
dataType: 'json',
|
|
type: "POST",
|
|
url: "<?php echo base_url(); ?>CostCenter/GetBudgetForYear?BudYear=" + id + "&CostCode=" + code,
|
|
success: function(json) {
|
|
|
|
//alert('success');
|
|
//alert(JSON.stringify(json));
|
|
//alert(json.BudYear);
|
|
$("#tempAppend").empty();
|
|
$('#tempAppend').append(json.Html);
|
|
$("#Addbudget").empty();
|
|
$("#Addbudget").append(json.BudYear);
|
|
//$("#Addbudget").append(json.BudYear);
|
|
$('#content').loader('hide');
|
|
//$("#Employee").append(result);
|
|
index = $('#txtRowCount').val();
|
|
|
|
}
|
|
|
|
});
|
|
//$('#content').loader('hide');
|
|
} else {
|
|
alert('Please select the PayOn');
|
|
return false;
|
|
}
|
|
|
|
});
|
|
});
|
|
</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> Edit Cost Center</center>
|
|
|
|
</h1>
|
|
|
|
</section>
|
|
|
|
<section class="content">
|
|
<div style="text-align:right;">
|
|
<a href="<?php echo base_url() ?>costListing" 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">
|
|
|
|
<!-- form start -->
|
|
<?php
|
|
$attributes = array('class' => 'form-label-left EditCost ', 'name' => 'EditCost', 'id' => 'EditCost');
|
|
|
|
echo form_open(base_url() . 'saveCostCenter/', $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">Cost Center Code </label>
|
|
<font color="Red">*</font>
|
|
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'CostCode', 'value' => set_value('CostCode', $CostCenterCode), 'id' => 'CostCode', 'class' => 'form-control', 'readonly' => 'true', 'maxlength' => '10');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="Description">Cost Center Name </label>
|
|
<font color="Red">*</font>
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'CostName', 'value' => set_value('CostName', $CostCenterName), 'id' => 'CostName', 'class' => 'form-control', 'required' => 'true', 'style' => 'text-transform:uppercase;', 'maxlength' => '100');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3 ">
|
|
<label for="CostName">Budget Year </label>
|
|
<font color="Red">*</font>
|
|
|
|
<div class="form-group">
|
|
<?php
|
|
|
|
|
|
|
|
echo form_dropdown('drpBudget', $optYear, set_value('drpBudget'), 'id="drpBudget"', 'class = "form-control "'); ?>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<!-- <div class="col-md-3 ">
|
|
<label for="CostName">Approved By </label>
|
|
<font color="Red">*</font>
|
|
|
|
<div class="form-group">
|
|
<?php
|
|
|
|
$Approved[$ApprovedBy] = $ApprovedBy . " - " . $FirstName . " - " . $Designation;
|
|
|
|
|
|
if (!empty($Approver)) {
|
|
foreach ($Approver as $SID) :
|
|
|
|
|
|
$Approved[$SID->EmpID] = $SID->EmpID . " - " . $SID->FirstName . " - " . $SID->Designation;
|
|
|
|
endforeach;
|
|
}
|
|
|
|
// echo form_dropdown('ApprovedBy', $Approved, set_value('ApprovedBy'), 'id="ApprovedBy"', 'class = "form-control "'); ?>
|
|
|
|
|
|
|
|
</div>
|
|
</div> -->
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="col-md-6">
|
|
<div class="col-md-4">
|
|
<label>Department</label>
|
|
<div>
|
|
<?php
|
|
|
|
$opt = array("0" => 'Select Department');
|
|
//print_r( $options);
|
|
|
|
if (!empty($DeptList)) {
|
|
foreach ($DeptList as $SID) :
|
|
|
|
$opt[$SID->DEPCode] = $SID->DEPCode . ' ' . ' - ' . ' ' . $SID->DepartmentName;
|
|
|
|
endforeach;
|
|
}
|
|
echo form_multiselect('distriList', $opt, set_value('distriList',$opt), 'id="distriList"', 'class="form-control required"', 'required="true"');
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<center>
|
|
<a style="color:white" href="javascript:void(0);" id="addPop"><button type="button" style="margin: 30px 0px 0px 15px;" class="btn btn-primary">Add</button></a><br>
|
|
<a style="color:white" href="javascript:void(0);" id="removePop"><button type="button" style="margin: 10px 0px 0px 15px;" class="btn btn-primary">Remove</button></a><br>
|
|
|
|
</center>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<b> </b>
|
|
|
|
<?php
|
|
$options["0"] = 'Selected Department';
|
|
if (!empty($CostDepts)) {
|
|
foreach ($CostDepts as $SID) :
|
|
|
|
$options[$SID->DEPCode] = $SID->DEPCode . ' ' . ' - ' . ' ' . $SID->DepartmentName;
|
|
|
|
endforeach;
|
|
}
|
|
echo form_multiselect('selectDistriList[]', $options, set_value('selectDistriList[]',$options), 'id="selectDistriList"', 'size="10"');
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
|
|
<br />
|
|
<input class="IsApproved" type="checkbox" name="IsApproved" id="IsApproved"> IsApproved<br>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<div col="row">
|
|
<div class="col-md-12">
|
|
<div style="text-align:right">
|
|
|
|
|
|
|
|
<a data-toggle="modal" href="#addbudgetmodel" ID="ButtonAdd" class="btn btn-primary"><i class="fa fa-plus"></i> Add Budget</a>
|
|
|
|
|
|
<!-- <a class="btn btn-primary" ID="EditImport" ><i class="fa fa-plus" ></i> <span class="bold">Edit Import</span></a> -->
|
|
</div>
|
|
</div>
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="addbudgetmodel" 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 Budget</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">
|
|
Budget Type :
|
|
</div>
|
|
<div class="col-md-5">
|
|
|
|
<?php
|
|
|
|
$Budget = array("-1" => 'Select Budget Type');
|
|
//print_r( $options);
|
|
$i = 0;
|
|
if (!empty($BudType)) {
|
|
|
|
//print_r($BudgetTypeAdd);
|
|
//print_r($BudType);
|
|
foreach ($BudType as $SID) :
|
|
|
|
foreach ($BudgetTypeAdd as $BUD) {
|
|
|
|
|
|
if ($SID->ConfigValue != $BUD) {
|
|
//print_r($BUD);
|
|
|
|
$Budget[$SID->ConfigValue] = $SID->ConfigValue;
|
|
}
|
|
}
|
|
endforeach;
|
|
$i = +1;
|
|
}
|
|
|
|
|
|
|
|
echo form_dropdown('Addbudget', $Budget, set_value('Addbudget'), 'id="Addbudget"', 'class = "form-control "'); ?>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="row">
|
|
<div class="col-md-3 col-md-offset-2">
|
|
Budget Year :
|
|
</div>
|
|
<div class="col-md-5">
|
|
|
|
<!-- <input name="AddYear" class="form-control required" id="AddYear" type="text" ,'required="true"' value=""> -->
|
|
<input type="text" name="AddYear" id="AddYear" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- <div class="form-group"> -->
|
|
<!-- <div class="row"> -->
|
|
<!-- <div class="col-md-3 col-md-offset-2">
|
|
Budget Amount :
|
|
</div> -->
|
|
<!-- <div class="col-md-5"> -->
|
|
|
|
<input class="form-control" onkeypress="return isNumberKey(event);" name="AddAmout" class="form-control" id="AddAmout" type="hidden" value=0>
|
|
|
|
<!-- </div> -->
|
|
<!-- </div> -->
|
|
<!-- </div> -->
|
|
<div class="form-group">
|
|
<div class="row">
|
|
<div class="col-md-3 col-md-offset-2">
|
|
Remarks :
|
|
</div>
|
|
<div class="col-md-5">
|
|
|
|
<input class="form-control" name="AddRemarks" class="form-control" id="AddRemarks" 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> <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="BudgetTable" class="table table-striped responsive-utilities jambo_table">
|
|
<thead style="background-color: #CFCFCF;">
|
|
|
|
<th>Budget Type</th>
|
|
<th>Budget Year</th>
|
|
<!-- <th>Budget Amount</th> -->
|
|
<th>Remarks</th>
|
|
<th>Action</th>
|
|
</thead>
|
|
<tbody id="tempAppend">
|
|
<?php
|
|
$index = 0;
|
|
if (!empty($CostBudget)) {
|
|
|
|
foreach ($CostBudget as $record) {
|
|
$index = $index + 1;
|
|
// $BudgetTypeAdd=[];
|
|
// $BudgetTypeAdd[$index]=$record->BudgetType;
|
|
// print_r($BudgetTypeAdd);
|
|
?>
|
|
<tr id="<?php echo $index ?>">
|
|
|
|
<td align="left"><?php echo $record->BudgetType ?></td>
|
|
<input type="hidden" name="<?php echo 'BudgetType' . $index ?>" id="<?php echo 'BudgetType' . $index ?> " value="<?php echo $record->BudgetType; ?>" />
|
|
<input type="hidden" name="<?php echo 'BudgetYear' . $index ?>" id="<?php echo 'BudgetYear' . $index ?>" value="<?php echo $record->BudgetYear; ?>" />
|
|
<input type="hidden" name="<?php echo 'BudgetAmount' . $index ?>" id="<?php echo 'BudgetAmount' . $index ?>" value="<?php echo $record->BudgetAmount; ?>" />
|
|
<input type="hidden" name="<?php echo 'Remarks' . $index ?>" id="<?php echo 'Remarks' . $index ?>" value="<?php echo $record->Remarks; ?>" />
|
|
|
|
<td align="left"><?php echo $record->BudgetYear ?></td>
|
|
|
|
<td align="left"><?php echo $record->BudgetAmount ?></td>
|
|
|
|
<td align="left"><?php echo $record->Remarks ?></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 <?php echo $record->BudgetType ?> 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 Budget</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">
|
|
Budget Type :
|
|
</div>
|
|
<div class="col-md-5">
|
|
<?php
|
|
$data = array('name' => 'Editbudget', 'value' => set_value('Editbudget'), 'id' => 'Editbudget', '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">
|
|
Budget Year :
|
|
</div>
|
|
<div class="col-md-5">
|
|
<input type="text" class="form-control" readonly id="EditYear" name="EditYear">
|
|
|
|
<!-- <input name="EditYear" class="form-control required" id="EditYear" type="text" ,'required="true"'> -->
|
|
|
|
<!-- <?php
|
|
$data = array('name' => '', 'value' => set_value(''), 'id' => 'EditYear', 'class' => 'form-control',);
|
|
echo form_input($data);
|
|
?> -->
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- <div class="form-group"> -->
|
|
<!-- <div class="row"> -->
|
|
<!-- <div class="col-md-3 col-md-offset-2">
|
|
Budget Amount :
|
|
</div> -->
|
|
<!-- <div class="col-md-5"> -->
|
|
<?php
|
|
$data = array('name' => 'EditAmout', 'value' => set_value('EditAmout'), 'id' => 'EditAmout', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);');
|
|
echo form_hidden($data);
|
|
?>
|
|
|
|
|
|
<!-- </div> -->
|
|
<!-- </div> -->
|
|
<!-- </div> -->
|
|
<div class="form-group">
|
|
<div class="row">
|
|
<div class="col-md-3 col-md-offset-2">
|
|
Remarks :
|
|
</div>
|
|
<div class="col-md-5">
|
|
<?php
|
|
$data = array('name' => 'EditRemarks', 'value' => set_value('EditRemarks'), 'id' => 'EditRemarks', 'class' => 'form-control');
|
|
echo form_input($data);
|
|
?>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</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> <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="hidden" name="txtSelectedDepartment" id="txtSelectedDepartment" />
|
|
<input type="submit" class="btn btn-primary" value="Update" />
|
|
<a href="<?php echo base_url() ?>costListing" class="btn btn-primary" id="cancel" value="Cancel">Cancel</a>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
</div>
|
|
<script type="text/html" id="tempList">
|
|
<tr id="<%=index%>">
|
|
<input type="hidden" name="BudgetType<%=index%>" id="BudgetType<%=index%>" value="<%=BudgetType%>" />
|
|
<input type="hidden" name="BudgetYear<%=index%>" id="BudgetYear<%=index%>" value="<%=BudgetYear%>" />
|
|
<input type="hidden" name="BudgetAmount<%=index%>" id="BudgetAmount<%=index%>" value="<%=BudgetAmount%>" />
|
|
<input type="hidden" name="Remarks<%=index%>" id="Remarks<%=index%>" value="<%=Remarks%>" />
|
|
<td align="left"><%=BudgetType%></td>
|
|
|
|
<td align="left"><%=BudgetYear%></td>
|
|
|
|
<td align="left"><%=BudgetAmount%></td>
|
|
|
|
<td align="left"><%=Remarks%></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 <%=BudgetType%> Budget details"></i> </a>
|
|
|
|
|
|
</td>
|
|
</tr>
|
|
</script>
|
|
<script>
|
|
var index = $('#txtRowCount').val();
|
|
var numbers = /^[0-9]+$/;
|
|
var userid = '';
|
|
|
|
$("#Edit").on("shown.bs.modal", function(e) {
|
|
|
|
userid = $(e.relatedTarget).data('userid');
|
|
|
|
$('#Editbudget').val($('#BudgetTable tr:eq(' + userid + ') td:eq(0)').text());
|
|
$('#EditYear').val($('#BudgetTable tr:eq(' + userid + ') td:eq(1)').text());
|
|
$('#EditAmout').val($('#BudgetTable tr:eq(' + userid + ') td:eq(2)').text());
|
|
$('#EditRemarks').val($('#BudgetTable tr:eq(' + userid + ') td:eq(3)').text());
|
|
});
|
|
|
|
$("#addbudgetmodel").on("shown.bs.modal", function() {
|
|
//userid = $(e.relatedTarget).data('userid');
|
|
|
|
$('#AddYear').val($('#drpBudget').val());
|
|
|
|
});
|
|
|
|
var typeArray = [];
|
|
var typeflag = 0;
|
|
var iflag = 0;
|
|
|
|
$('.tempClick').click(function() {
|
|
|
|
|
|
if ($("#Addbudget option:selected").val() == '-1') {
|
|
alert('Please Select the Budget Type ');
|
|
//return;
|
|
}
|
|
|
|
if ($('#AddYear').val() == '0') {
|
|
alert('Please Enter the Budget Year');
|
|
//return;
|
|
}
|
|
// if (document.getElementById('AddAmout').value == '') {
|
|
// alert('Please Enter the Budget Amount');
|
|
// // return;
|
|
// }
|
|
|
|
|
|
if ($("#Addbudget option:selected").val() != '-1' && $('#AddYear').val() != '0' && $('#AddAmout').val() != '') {
|
|
|
|
// $('#BudgetTable').show();
|
|
|
|
var BudType = $("#Addbudget option:selected").val();
|
|
var BudYear = $("#drpBudget option:selected").val();
|
|
var BudAmount = $("#AddAmout").val();
|
|
//$('#Addbudget option[value='+BudType+']').remove();
|
|
var BudRemarks = $('#AddRemarks').val();
|
|
//$('#AddYear').val('');
|
|
$('#AddAmout').val('');
|
|
$('#AddRemarks').val('');
|
|
|
|
var str = (BudType.concat(BudYear));
|
|
//alert('outsideeachfunction'+str);
|
|
$.each(typeArray, function(i, item) {
|
|
|
|
//alert('each'+item+'input'+BudType);
|
|
//alert('str'+str);
|
|
if (str == item) {
|
|
iflag = iflag + 1;
|
|
//alert('iflag'+iflag);
|
|
}
|
|
|
|
});
|
|
//alert('i value'+iflag);
|
|
//alert('array'+typeArray);
|
|
if (iflag == 0) {
|
|
typeArray.push(str);
|
|
typeflag = 1;
|
|
|
|
index = parseInt(index) + 1;
|
|
var temp = index;
|
|
|
|
|
|
var template = jQuery("#tempList").html();
|
|
|
|
|
|
$('#tempAppend').append(_.template(template, {
|
|
index: temp,
|
|
BudgetType: BudType,
|
|
BudgetYear: BudYear,
|
|
BudgetAmount: BudAmount,
|
|
Remarks: BudRemarks
|
|
}));
|
|
} else {
|
|
alert(" Budget Type and Budget Year values Already Exsits in our database!");
|
|
iflag = 0;
|
|
}
|
|
|
|
//alert($('#txtRowCount').val());
|
|
|
|
//var theForm = $(".addCost");
|
|
|
|
// addHidden(theForm,"BudgetType"+temp,BudType);
|
|
//addHidden(theForm,"BudgetYear"+temp,BudYear);
|
|
// addHidden(theForm,"BudgetAmount"+temp,BudAmount);
|
|
//addHidden(theForm,"Remarks"+temp,BudRemarks);
|
|
|
|
$('#txtRowCount').val(temp);
|
|
|
|
CountRows();
|
|
|
|
// var a= CountRowsbutton();
|
|
// alert(a);
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
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 BudYear = $("#EditYear").val();
|
|
var BudAmount = $("#EditAmout").val();
|
|
|
|
var BudRemarks = $('#EditRemarks').val();
|
|
var BudType = $('#Editbudget').val();
|
|
|
|
$('#BudgetTable tr:eq(' + userid + ') td:eq(1)').text(BudYear);
|
|
$('#BudgetTable tr:eq(' + userid + ') td:eq(2)').text(BudAmount);
|
|
$('#BudgetTable tr:eq(' + userid + ') td:eq(3)').text(BudRemarks);
|
|
|
|
$('#BudgetType' + userid).val(BudType);
|
|
$('#BudgetYear' + userid).val(BudYear);
|
|
$('#BudgetAmount' + userid).val(BudAmount);
|
|
$('#Remarks' + userid).val(BudRemarks);
|
|
} 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>
|
|
$('#addPop').click(function() {
|
|
if ($('#distriList option:selected').val() != null) {
|
|
if ($('#distriList option:selected').val() == 0) {
|
|
alert('please select Department');
|
|
} else {
|
|
var tempSelect = $('#distriList option:selected').val();
|
|
var tempText = $('#distriList option:selected').text();
|
|
//alert(tempSelect);
|
|
var o = new Option(tempText, tempSelect);
|
|
var hidval = tempSelect;
|
|
var orgVal = $('#txtSelectedDepartment').val();
|
|
//alert(orgVal);
|
|
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");
|
|
|
|
|
|
if (validate()) {
|
|
$('#content').loader('show');
|
|
$.ajax({
|
|
data: $('.EditCost').serialize(),
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>CostCenter/AddCostDepartment",
|
|
success: function(data) {
|
|
if (data) {
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
$('#txtSelectedDepartment').val('');
|
|
$('#txtRowCount').val('');
|
|
|
|
window.location = baseurl + 'costListing';
|
|
}
|
|
|
|
}
|
|
});
|
|
//$('#content').loader('hide');
|
|
}
|
|
|
|
|
|
tempSelect = '';
|
|
tempText = '';
|
|
Selectedval = '';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
} else {
|
|
alert("Before add please select any position.");
|
|
}
|
|
});
|
|
|
|
$('#removePop').click(function() {
|
|
if ($('#selectDistriList option:selected').val() != null) {
|
|
if ($('#selectDistriList option:selected').val() == 0) {
|
|
//alert('cannot removed');
|
|
} else {
|
|
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);
|
|
$('#txtSelectedDepartment').val(tempSelect);
|
|
tempSelect = '';
|
|
|
|
|
|
|
|
if (validate()) {
|
|
$('#content').loader('show');
|
|
$.ajax({
|
|
data: $('.EditCost').serialize(),
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>CostCenter/DeleteCostDepartment",
|
|
success: function(data) {
|
|
if (data) {
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
$('#txtSelectedDepartment').val('');
|
|
$('#txtRowCount').val('');
|
|
|
|
window.location = baseurl + 'costListing';
|
|
}
|
|
|
|
}
|
|
});
|
|
//$('#content').loader('hide');
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
alert("Before remove please select any position.");
|
|
}
|
|
});
|
|
|
|
var baseurl = "<?php print base_url(); ?>";
|
|
$(".EditCost").submit(function(e) {
|
|
|
|
e.preventDefault();
|
|
if (validate()) {
|
|
$('#content').loader('show');
|
|
$.ajax({
|
|
data: $('.EditCost').serialize(),
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>updateCostCenter",
|
|
success: function(data) {
|
|
if (data) {
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
$('#txtSelectedDepartment').val('');
|
|
$('#txtRowCount').val('');
|
|
|
|
window.location = baseurl + 'costListing';
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
//$('#content').loader('hide');
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var totalRowCount = 0;
|
|
var rowCount = 0;
|
|
var table = document.getElementById("BudgetTable");
|
|
var rows = table.getElementsByTagName("tr");
|
|
//console.log(rows.length);
|
|
|
|
|
|
//if(rows.length>=5)
|
|
//{
|
|
|
|
// $('#ButtonAdd').hide();
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
//$('#ButtonAdd').show();
|
|
//}
|
|
|
|
function CountRows() {
|
|
|
|
totalRowCount = 0;
|
|
rowCount = 0;
|
|
table = document.getElementById("BudgetTable");
|
|
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") {
|
|
$("#addbudgetmodel").modal('hide');
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
}*/
|
|
return true
|
|
}
|
|
</script>
|