File: //home/cafsindia/groups_cafsindia_com/application/views/increment_report/manage.php
<?php
$this->load->view("partial/header");
$access_data = $this->session->userdata('access_data');
$access_add = (int)$access_data[$controller_name]['access_add'];
$access_update = (int)$access_data[$controller_name]['access_update'];
$access_delete = (int)$access_data[$controller_name]['access_delete'];
$access_search = (int)$access_data[$controller_name]['access_search'];
$access_export = (int)$access_data[$controller_name]['access_export'];
$access_import = (int)$access_data[$controller_name]['access_import'];
$page_name = ucwords(str_replace("_"," ",$controller_name));
$uniqueId = "prime_".$controller_name."_id";
?>
<div class='row title_content'>
<div class='col-md-2 col-xs-4'>
<h1 class='page_txt'><?php echo $page_name;?></h1>
</div>
</div>
<div id="toolbar">
<div class="col-md-12">
<!-- <div class="col-md-2">
<?php echo form_label("From Month Year", 'from_mon_year', array('class' => 'required'));
echo form_input(array("name"=>'from_mon_year', "id"=>'from_mon_year',"value"=>'',"placeholder"=>'Month Year', "class"=>"form-control input-sm datepicker")); ?>
</div> -->
<div class="col-md-3">
<?php echo form_label("Month Year", 'mon_year', array('class' => 'required'));
echo form_input(array("name"=>'mon_year', "id"=>'mon_year',"value"=>'',"placeholder"=>'Month Year', "class"=>"form-control input-sm datepicker")); ?>
</div>
<div class="col-md-3">
<?php echo form_label("Select Branch", 'branch', array('class' => 'required'));
echo form_dropdown(array('name' => 'branch[]','multiple id' =>'branch','class' => 'form-control input-sm select2'), $branch_list);
echo "<label><input name='branch_to_select' id='branch_to_select' type='checkbox'> Select All</label>"; ?>
</div>
<div class="col-md-3">
<?php echo form_label("Select Channel", 'channel', array('class' => 'required'));
echo form_dropdown(array('name' => 'channel[]','multiple id' =>'channel','class' => 'form-control input-sm select2'), $channel_list);
echo "<label><input name='channel_to_select' id='channel_to_select' type='checkbox'> Select All</label>"; ?>
</div>
<div class="col-md-3">
<?php echo form_label("Select Designation", 'designation', array('class' => 'required'));
echo form_dropdown(array('name' => 'designation[]','multiple id' =>'designation','class' => 'form-control input-sm select2'), $designation_list);
echo "<label><input name='designation_to_select' id='designation_to_select' type='checkbox'> Select All</label>"; ?>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<?php echo form_label("Select Level 1 Reporting", 'level1', array('class' => 'required'));
echo form_dropdown(array('name' => 'level1[]','multiple id' =>'level1','class' => 'form-control input-sm select2'), $level_1_list);
echo "<label><input name='level1_to_select' id='level1_to_select' type='checkbox'> Select All</label>"; ?>
</div>
<div class="col-md-3">
<?php echo form_label("Select Level 2 Reporting", 'level2', array('class' => 'required'));
echo form_dropdown(array('name' => 'level2[]','multiple id' =>'level2','class' => 'form-control input-sm select2'), $level_2_list);
echo "<label><input name='level2_to_select' id='level2_to_select' type='checkbox'> Select All</label>"; ?>
</div>
<div class="col-md-3" style="margin-top: 24px;">
<button class='btn btn-primary btn-sm' id="search">Search</button>
</div>
</div>
<div style="padding:15px;" id="increment_report" class="col-md-12">
</div>
</div>
<script type="text/javascript">
$(document).ready(function (){
$(function(){
$(".datepicker").datetimepicker({
format: 'MM-YYYY',
//debug: true
});
});
$(function(){
$('.select2').select2({
allowClear : true,
placeholder: "--- Select ---"
// tags: true
});
$('.select2-tags').select2({
allowClear: true,
tags: true,
placeholder: "--- Select ---",
tokenSeparators: [',']
});
$(".select2_user").select2({
placeholder: "--- Select ---",
allowClear: true,
tags: true
});
});
$("#branch_to_select").click(function(){
if($("#branch_to_select").is(':checked') ){
$("#branch > option").prop("selected","selected");
$('#branch option:first-child').removeAttr('selected');
$("#branch").trigger("change");
}else{
$("#branch > option").removeAttr("selected");
$("#branch").trigger("change");
}
});
$("#channel_to_select").click(function(){
if($("#channel_to_select").is(':checked') ){
$("#channel > option").prop("selected","selected");
$('#channel option:first-child').removeAttr('selected');
$("#channel").trigger("change");
}else{
$("#channel > option").removeAttr("selected");
$("#channel").trigger("change");
}
});
$("#designation_to_select").click(function(){
if($("#designation_to_select").is(':checked') ){
$("#designation > option").prop("selected","selected");
$('#designation option:first-child').removeAttr('selected');
$("#designation").trigger("change");
}else{
$("#designation > option").removeAttr("selected");
$("#designation").trigger("change");
}
});
$("#level1_to_select").click(function(){
if($("#level1_to_select").is(':checked') ){
$("#level1 > option").prop("selected","selected");
$('#level1 option:first-child').removeAttr('selected');
$("#level1").trigger("change");
}else{
$("#level1 > option").removeAttr("selected");
$("#level1").trigger("change");
}
});
$("#level2_to_select").click(function(){
if($("#level2_to_select").is(':checked') ){
$("#level2 > option").prop("selected","selected");
$('#level2 option:first-child').removeAttr('selected');
$("#level2").trigger("change");
}else{
$("#level2 > option").removeAttr("selected");
$("#level2").trigger("change");
}
});
$('#branch option:first-child').prop('disabled',true);
$('#channel option:first-child').prop('disabled',true);
$('#designation option:first-child').prop('disabled',true);
$('#level1 option:first-child').prop('disabled',true);
$('#level2 option:first-child').prop('disabled',true);
// $('#branch').each(function(){
// $(this).children(':nth-child(1)').addClass('first');
// });
// $('.first').click(function(){
// $( '#branch > option' ).prop("selected","selected");
// });
// $( "#branch option:first-child" ).hover(function() {
// $( '#branch option:last-child' ).prop("selected","selected");
// });
// $("#channel").click(function(){
// $("#channel option:first-child").click(function(){
// // $('#channel option:first-child').removeAttr('selected');
// $("#channel > option").prop("selected","selected");
// });
// });
// $("#designation option:first-child").click(function(){
// // $('#designation option:first-child').removeAttr('selected');
// $("#designation > option").prop("selected","selected");
// });
// $("#level1 option:first-child").click(function(){
// // $('#level1 option:first-child').removeAttr('selected');
// $("#level1 > option").prop("selected","selected");
// });
// $("#level2 option:first-child").click(function(){
// // $('#level2 option:first-child').removeAttr('selected');
// $("#level2 > option").prop("selected","selected");
// });
$("#search").on('click', function(e){
var branch = $('#branch').val();
var channel = $('#channel').val();
var designation = $('#designation').val();
// var from_mon_year = $('#from_mon_year').val();
// var to_mon_year = $('#to_mon_year').val();
var mon_year = $('#mon_year').val();
var level1 = $('#level1').val();
var level2 = $('#level2').val();
// var from_mon = moment("01-"+from_mon_year, "DD-MM-YYYY").format('YYYY-MM');
// var to_mon = moment("01-"+to_mon_year, "DD-MM-YYYY").format('YYYY-MM');
var send_url = '<?php echo site_url("$controller_name/get_increment");?>';
if(!mon_year){
toastr.error('Please choose Month Year?');
return false;
}else
if(!branch){
toastr.error('Please choose any one Branch?');
return false;
}else
if(!channel){
toastr.error('Please choose any one Channel?');
return false;
}else
if(!designation){
toastr.error('Please choose any one Designation?');
return false;
}else
if(!level1){
toastr.error('Please choose Level1 Designation?');
return false;
}else
if(!level2){
toastr.error('Please Level2 Designation?');
return false;
}
// else
// if(!from_mon_year){
// toastr.error('Please choose From Month?');
// return false;
// }else
// if(!to_mon_year){
// toastr.error('Please choose To Month?');
// return false;
// }else
// if(from_mon > to_mon){
// toastr.error('To Month should be Equal or Greater than From Month?');
// $('#to_mon_year').val('');
// return false;
// }
else{
$("#search").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#search').attr('disabled','disabled');
$.ajax({
type: 'POST',
url: send_url,
data:{mon_year:mon_year,designation:designation,branch:branch,channel:channel,level1:level1,level2:level2},
success: function(data) {
var rslt = JSON.parse(data);
if(rslt.success){
$('#increment_report').html(rslt.table_info);
$table = $('#increment_promotion_table').DataTable({
destroy: true,
// scrollY: 200,
lengthMenu: [[25,50,100],[25,50,100,"All"]],
language:{
searchPlaceholder: "Search records",
search: "",
},
scrollX:true,
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'pdfHtml5'
]
});
$("input[type='search']").addClass('form-control');
}else{
toastr.error(rslt.message);
}
$('#search').attr('disabled',false);
$("#search").html("Search");
}
});
}
});
});
function increment_promotion_log(login_code){
var send_url = '<?php echo site_url("$controller_name/increment_promotion_log");?>'
$.ajax({
type: 'POST',
url: send_url,
data: {login_code:login_code},
success: function(data) {
var rslt = JSON.parse(data);
if(rslt.success){
//DR CODE FOR USING DYNAMIC TABLE HEADERS AND ROWS BY DATATABLE COLUMNS
//MODAL BODY LOADING FOR SHOW A TABLE
$('.modal').modal({backdrop: 'static', keyboard: false});
$('.modal-title').html('<h4 class="modal-title">Increment Promotion Log</h4>');
$('.modal-body').html('<div style="text-align: center;padding:50px;color:#4b6fa2;"><i class="fa fa-spinner fa-spin fa-2x fa-fw"></i><br/>Please wait processing....</div>');
$('.modal-body').html("<ul class='nav nav-tabs' data-tabs='tabs'><li class='active' role='presentation'><a data-toggle='tab' href='#increment_view'>Increment Log</a></li><li role='presentation'><a data-toggle='tab' href='#promotion_view'>Promotion Log</a></li></ul><div class='tab-content'><div class='tab-pane fade in active' id='increment_view'><table id='increment_log_table' width='100%' class='table table-hover'></table></div><div class='tab-pane fade' id='promotion_view'><table id='promotion_log_table' width='100%' class='table table-hover'></table></div></div>");
$hike_table = $('#increment_log_table').DataTable( {
destroy: true,
// scrollY: 200,
lengthMenu: [[25,50,100],[25,50,100,"All"]],
language:{
lengthMenu:"<span style='margin-top:8px;margin-left:10px;'>Display</span> _MENU_ <span style='margin-top:8px;'>Records</span>",
searchPlaceholder: "Search records",
search: "",
},
data: rslt.increment_info,
columns: [
{ title: "Login Code" , data: "login_code" },
{ title: "Increment Month" , data: "increment_month" ,
render:function(value) {
if (value === null) return '';
return moment(value ,"YYYY-MM-DD").format('MM-YYYY')}},
{ title: "Previous Ctc" , data: "previous_ctc" },
{ title: "Hike Ctc" , data: "hike_ctc" },
{ title: "Percentage" , data: "percentage" },
{ title: "Current Grade" , data: "current_grade" },
{ title: "Promoted Grade" , data: "promoted_grade" },
{ title: "Tenure" , data: "tenure" }
],
// footerCallback: function (tfoot, data, start, end, display) {
// var api = this.api();
// // var footer = $(this).append('<tfoot><tr></tr></tfoot>');
// var prev_hike = api.column(2).data().reduce(function (a, b) {
// var x = parseFloat(a) || 0;
// var y = parseFloat(b) || 0;
// return x + y;
// }, 0);
// var current_hike = api.column(3).data().reduce(function (a, b) {
// var x = parseFloat(a) || 0;
// var y = parseFloat(b) || 0;
// return x + y;
// }, 0);
// $(this).append('<tfoot><tr><th></th><th style="text-align:right">Total:</th><th>'+prev_hike+'</th><th>'+current_hike+'</th></tr></tfoot>');
// }
} );
$promo_table = $('#promotion_log_table').DataTable( {
destroy: true,
// scrollY: 200,
lengthMenu: [[25,50,100],[25,50,100,"All"]],
language:{
lengthMenu:"<span style='margin-top:8px;margin-left:10px;'>Display</span> _MENU_ <span style='margin-top:8px;'>Records</span>",
searchPlaceholder: "Search records",
search: "",
},
data: rslt.promotion_info,
columns: [
{ title: "Login Code" , data: "login_code" },
{ title: "Promotion Month" , data: "promotion_month" ,
render:function(value) {
if (value === null) return '';
return moment(value ,"YYYY-MM-DD").format('MM-YYYY')}},
{ title: "Previous Designation" , data: "previous_designation" },
{ title: "Promoted Designation" , data: "promoted_designation" },
{ title: "Current Grade" , data: "current_grade" },
{ title: "Promoted Grade" , data: "promoted_grade" },
{ title: "Tenure" , data: "tenure" }
]
} );
$("input[type='search']").addClass('form-control');
}else{
toastr.error(rslt.message);
return false;
}
}
});
}
</script>
<style>
.buttons-html5{
padding: inherit!important;
}
.buttons-html5 > span{
background-color: #f75940;
color: #FFFFFF;
}
ul.select2-selection__rendered{
max-height: 102px;
overflow-y: auto !important;
}
</style>
<?php $this->load->view("partial/footer"); ?>