File: /home/cafsindia/.trash/application/views/work_sheet/manage_08mar2024.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));
$prime_id = "prime_".$controller_name."_id";
$search_url = site_url($controller_name ."/search");
$view_url = site_url($controller_name ."/view/");
$import_url = site_url($controller_name ."/import/");
$category = $this->session->userdata('logged_role');
$employee_code = $this->session->userdata('logged_emp_code');
$user_role = $this->session->userdata('logged_user_role');
$year = date('Y');
$year1 = date('Y')-1;
$year2 = date('Y')+1;
$fin_start_date = "";
$fin_end_date = "";
if (date('m') > 03){
$fin_start_date = "04"."-".$year;
$fin_end_date = "03"."-".$year2;
}else{
$fin_start_date = "04"."-".$year1;
$fin_end_date = "03"."-".$year;
}
$user_read_only = "";
if((int)$user_role !== 1){
$user_read_only = "$('#employee_name').attr('readonly','readonly')";
}else{
$user_read_only = "$('#emp_hid_div').show()";
}
?>
<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="holder" class="form-inline" style="margin-top:20px;">
<div class="col-md-12" style="margin-bottom:10px;">
<div class="form-group" id="emp_hid_div" style="display:none;">
<?php
echo form_label("Employee Name", 'employee_name', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'employee_name', 'id' => 'employee_name', 'class' => 'form-control input-sm select2'), $employee_list);
?>
</div>
<div class="form-group">
<?php
echo form_label('From Month', 'from_month', array('class' => 'required'));
echo form_input(array('name' => 'from_month', 'id' => 'from_month', 'class' => 'form-control input-sm datepicker', 'value'=>$fin_start_date));
?>
</div>
<div class="form-group">
<?php
echo form_label('To Month', 'to_month', array('class' => ''));
echo form_input(array('name' => 'to_month', 'id' => 'to_month', 'class' => 'form-control input-sm datepicker', 'value'=>$fin_end_date));
?>
</div>
<div class="form-group">
<button class='btn btn-primary btn-sm' id="search">View</button>
</div>
</div>
</div>
<div class="col-md-12" id="employee_table_view" style="margin:10px;padding:10px;background-color: #f2f2f2;"></div>
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Worksheet</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body" id="example1">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function (){
<?php echo $user_read_only; ?>
<?php echo $hid_div; ?>
var employee_code = '<?php echo $employee_code; ?>';
var user_role = '<?php echo $user_role; ?>';
$(function () {
$(".datepicker").datetimepicker({
format: 'MM-YYYY',
//debug: true
});
});
select_call();
$('#employee_table_view').hide();
$('#from_month,#to_month').on("dp.hide",function (e) {
var from_month = $('#from_month').val();
var to_month = $('#to_month').val();
if(toPartialIso(from_month) > toPartialIso(to_month) ){
toastr.error("To Month should be Greater than From Month!!");
$('#to_month').val('');
}
});
if(parseInt(user_role) !== 1) {
//FOR READ ONLY(AUTO SELECT EMP CODE WITH NAME) NOT APPLY FOR USER ROLE 1 and 2
$('#employee_name').val(employee_code);
var employee_code = $('#employee_name').val();
var from_month = $('#from_month').val();
var to_month = $('#to_month').val();
check_worksheet(employee_code,from_month,to_month);
}
$("#search").on('click', function(e){
var employee_code = $('#employee_name').val();
var from_month = $('#from_month').val();
var to_month = $('#to_month').val();
if(!employee_code){
toastr.error('Please choose employee?');
return false;
}
check_worksheet(employee_code,from_month,to_month);
});
});
function check_worksheet(employee_code,from_month,to_month){
var send_url = '<?php echo site_url("$controller_name/check_worksheet");?>'
if(employee_code){
$("#search").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#search').attr('disabled','disabled');
$.ajax({
type: 'POST',
url: send_url,
data:{emp_code:employee_code,from_month:from_month,to_month:to_month},
success: function(data) {
var rslt = JSON.parse(data);
$('#employee_table_view').show();
$('#employee_table_view').html(rslt.table_data);
$('#search').attr('disabled',false);
$("#search").html("View");
}
});
}
}
function select_call(){
$(function(){
$('.select2').select2({
placeholder: '---- Select ----',
});
$('.select2-tags').select2({
tags: true,
tokenSeparators: [',']
});
});
}
function pdf_viewer(url){
PDFObject.embed(url, "#example1");
$("#myModal").modal("show");
}
//from and to month validation
function toPartialIso(month) {
var m = month.match(/(\d{2})-(\d{4})/);
if (m) {
return m[2] + "-" + m[1]
}
throw "Choose Correct Date!"
}
</script>
<style>
.pdfobject-container { height: 70rem; border: 1rem solid rgba(0,0,0,.1); }
.modal-dialog {
width: 100% !important;
//height: 100% !important;
margin: 0;
padding: 0;
}
.modal-content {
height: 850px!important;
//min-height: 100% !important;
border-radius: 0;
}
.modal .modal-body div {
//height: 100% !important;
overflow-y: auto;
width: 100%;
}
</style>
<?php $this->load->view("partial/footer"); ?>