File: /home/cafsindia/hrms_cafsinfotech_in/application/views/tax_proof_entry/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";
$start_date = $financial_info[0]->start_date;
$end_date = $financial_info[0]->end_date;
$logged_role = $this->logged_role;
$logged_emp_code = $this->logged_emp_code;
$logged_user_role= $this->logged_user_role;
$validate_rule = "";
if((int)$logged_user_role === 1 || (int)$logged_user_role === 4 || (int)$logged_user_role === 12){
$validate_rule = 'rules: {
category : "required",
emp_code : "required"
},';
}
?>
<link href="dist/dropzone/dropzone.min.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="dist/dropzone/dropzone.min.js"></script>
<script type="text/javascript">
//Dropzone.autoDiscover = false;
$(document).ready(function (){
$(function(){
$(".datepicker").datetimepicker({
format: 'MM-YYYY'
});
});
$('#section_details').hide();
$('#submit').hide();
$('#delete').hide();
var logged_role = "<?php echo $logged_role;?>";
var logged_user_role = "<?php echo $logged_user_role;?>";
var logged_emp_code = "<?php echo $logged_emp_code;?>";
if(parseInt(logged_user_role) !== 1 && parseInt(logged_user_role) !== 4 && parseInt(logged_user_role) !== 12){
get_sec_sub_list(logged_emp_code);
// $('#category option[value="'+logged_role+'"]').attr('selected','selected');
// get_employee_data(logged_role);
// $('#category').attr('readonly', true);
}
//Date validation of change this updates
$("#effective_month").datetimepicker({
format: 'MM-YYYY',
minDate: moment('<?php echo $start_date; ?>'),
maxDate: moment('<?php echo $end_date; ?>')
});
$(function(){
$('.select2').select2({
placeholder: '---- Select ----',
});
$('.select2-tags').select2({
tags: true,
tokenSeparators: [',']
});
});
$("#category").on('change', function(e){
var category = $("#category").val();
get_employee_data(category);
});
$("#emp_code").on('change', function(e){
var emp_code = $("#emp_code").val();
get_sec_sub_list(emp_code);
});
$("#proof_entry").validate({
<?php echo $validate_rule; ?>
submitHandler: function(form) {
$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#submit').attr('disabled','disabled');
//var proof_entry_data = JSON.stringify($("#proof_entry").serializeArray());
let formData = new FormData($('#proof_entry')[0]);
// Convert FormData to JSON object
let jsonData = Object.fromEntries(formData.entries());
var encKey = '<?php echo $encKey; ?>';
var encData = encrypt(encKey,jsonData);
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/save_section"); ?>',
data:encData,
contentType: 'text/plain',
success: function (data) {
var rslt = JSON.parse(data);
if(rslt.success){
toastr.success(rslt.message);
$('#submit').attr('disabled',false);
$("#submit").html("Save");
}else{
toastr.success(rslt.message);
$('#submit').attr('disabled',false);
$("#submit").html("Save");
}
$(function(){
$('.select2').select2({
placeholder: '---- Select ----',
});
$('.select2-tags').select2({
tags: true,
tokenSeparators: [',']
});
});
}
});
}
});
$("#delete").click(function(){
var category = $('#category').val();
var emp_code = $('#emp_code').val();
if(confirm("Are you sure to delete?")){
if(emp_code){
var encKey = '<?php echo $encKey; ?>';
var encData = encrypt(encKey,{category:category,emp_code:emp_code});
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/delete_section"); ?>',
data:encData,
contentType: 'text/plain',
success: function (data) {
var rslt = JSON.parse(data);
toastr.success(rslt.message);
location.reload(true);
}
});
}
}
});
});
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
parallelUploads:10,
addRemoveLinks: true,
acceptedFiles: "image/*,application/pdf,.doc,.docx,.xls,.xlsx,.csv",
init: function() {
var submitButton = document.querySelector("#submit_dropzone_form");
myDropzone = this; // closure
submitButton.addEventListener("click", function() {
if(myDropzone.getQueuedFiles().length > 0){
myDropzone.processQueue();
$("#submit_dropzone_form").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
}else{
toastr.warning('Add files and try again');
}
});
myDropzone.on("complete", function(file) {
$("#submit_dropzone_form").html("Submit");
$('#upload_modal').modal('hide');
});
myDropzone.on("maxfilesexceeded", function (data) {
myDropzone.removeFile(data);
});
myDropzone.on("queuecomplete", function(progress) {
toastr.success("All File uploaded...");
myDropzone.removeAllFiles();
});
}
};
function load_modal(cal_name,emp_code){
if(cal_name){
$("#cal_name").val(cal_name);
$("#emp_code_val").val(emp_code);
$('#upload_modal').modal('show');
}else{
toastr.error("Please refresh page and retry");
}
}
function load_list_modal(cal_name,emp_code,fin_id){
$('#list_modal').modal('show');
if((cal_name !== "") && (emp_code !== "") && (fin_id !== "")){
var encKey = '<?php echo $encKey; ?>';
var encData = encrypt(encKey,{cal_name:cal_name,emp_code:emp_code,fin_id:fin_id});
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/upload_doc_lists"); ?>',
data: encData,
contentType: 'text/plain',
success: function (response){
var rslt = JSON.parse(response);
$('#list_table').html(rslt.table_info);
}
});
}
}
function delete_doc(imp_id){
if(imp_id){
if(confirm("Are you sure to delete?")){
var encKey = '<?php echo $encKey; ?>';
var encData = encrypt(encKey,{imp_id:imp_id});
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/delete_doc"); ?>',
data: encData,
contentType: 'text/plain',
success: function (response){
var rslt = JSON.parse(response);
$('#'+imp_id).remove();
toastr.success(rslt.message);
}
});
}
}
}
function openfile(url,status){
if(parseInt(status) === 1){
var w=window.open(url, '_blank');
w.focus();
}else{
toastr.error('Link Expried');
}
}
function get_employee_data(category){
if(category){
var key = '<?php echo $encKey; ?>';
var encData = encrypt(key,{category:category});
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_employee_list"); ?>',
data: encData,
contentType: 'text/plain',
beforeSend: function(){
$("#emp_code").parent().append('<span id="span_employee_data" style="color:#CC3366;"><i class="fa fa-spinner fa-spin fa-2x fa-fw"></i><br/>Loading...</span>');
},
success: function(data){
$("#span_employee_data").remove('');
$('#emp_code').html(data);
var logged_user_role = "<?php echo $logged_user_role;?>";
var logged_role = "<?php echo $logged_role;?>";
if(parseInt(logged_user_role) !== 1 && parseInt(logged_user_role) !== 4 && parseInt(logged_user_role) !== 12){
var logged_emp_code = "<?php echo $logged_emp_code;?>";
$('#emp_code option[value="'+logged_emp_code+'"]').attr('selected','selected');
$("#emp_code").trigger("change");
$('#emp_code').attr('readonly', true);
}
if(parseInt(logged_role) === 4 || parseInt(logged_role === 1) || parseInt(logged_role === 12)){
$('#emp_code').attr('readonly', false); // [MS 16-08-2024]
}
},
});
}
}
function get_sec_sub_list(emp_code){
if(emp_code){
var key = '<?php echo $encKey; ?>';
var encData = encrypt(key,{emp_code:emp_code});
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_sec_sub_list"); ?>',
data: encData,
contentType: 'text/plain',
success: function(data){
$('#section_details').show();
$('#section_details').html(data);
$('#submit').show();
$('#delete').show();
},
});
$('#section_details').hide();
}
}
</script>
<div class='row title_content'>
<div class='col-md-2 col-xs-4'>
<h1 class='page_txt'><?php echo $page_name;?></h1>
</div>
<div class='col-md-10 col-xs-8'>
</div>
</div>
<div id="holder" class="form-inline" style="margin-top:20px;">
<div class="row" style='margin-bottom:0px;'>
<div class="col-md-12">
<form id='proof_entry'>
<?php if((int)$logged_user_role === 1 || (int)$logged_user_role === 4 || (int)$logged_user_role === 12){ ?>
<div class="form-group">
<?php
echo form_label('Category', 'category', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'category', 'id' => 'category', 'class' => 'form-control input-sm select2'), $category_list);
?>
</div>
<div class="form-group">
<?php
echo form_label('Employee Code', 'emp_code', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'emp_code', 'id' => 'emp_code', 'class' => 'form-control input-sm select2'));
?>
</div>
<?php } ?>
<div id="section_details" style="margin:20px !important; padding:15px;background-color: #f2f2f2;"></div>
<div class="tax_btn">
<button class='btn btn-primary btn-sm' id="submit">Save</button>
<!-- <a class='btn btn-danger btn-sm' id="delete">Delete</a> -->
</div>
</form>
</div>
</div>
</div>
<div id="upload_modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Documents Upload</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12" style="padding:30px;">
<form method="post" action="<?php echo site_url($controller_name . "/upload_documents"); ?>" enctype="multipart/form-data" class="dropzone" id="myAwesomeDropzone">
<div class="form-group">
<input type='hidden' value="" name='cal_name' id='cal_name'>
<input type='hidden' value="" name='emp_code_val' id='emp_code_val'>
</div>
<div class="dz-message needsclick">
<h5>Drop files here or click to upload.</h5>
</div>
</form>
<div class="form-group">
<button type="button" class="btn btn-primary btn-sm" id="submit_dropzone_form" style="display: inline-block;margin-top:20px;">Submit</button>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="list_modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Documents List</h4>
</div>
<div class="modal-body">
<div id="list_table" style="margin:20px !important; padding:15px;"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<style>
.tax_btn{
width: 15%;
float: right;
}
.pull-right.search {
display: none !important;
}
.columns.columns-right.btn-group.pull-right {
display: none !important;
}
<?php
if($access_search === 1){
echo ".pull-right.search { display: block !important; }";
}
if($access_export === 1){
echo ".columns.columns-right.btn-group.pull-right{display: block !important;}";
}
?>
</style>
<?php $this->load->view("partial/footer"); ?>