230 lines
6.4 KiB
PHP
Executable File
230 lines
6.4 KiB
PHP
Executable File
<?php
|
||
$monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr", "05" => "May", "06" => "June", "07" => "July", "08" => "Aug", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
|
||
?>
|
||
|
||
<script>
|
||
$(function() {
|
||
$(".select2").select2();
|
||
$('#All').click(function() {
|
||
|
||
if ($('#All').prop('checked')) {
|
||
$('#Driver').attr('disabled', 'true');
|
||
} else {
|
||
$('#Driver').removeAttr('disabled');
|
||
}
|
||
});
|
||
$('#PayOn').change(function() {
|
||
var id = $('#PayOn').val();
|
||
if (id != '-1') {
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: {
|
||
id1: id
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>getDriver",
|
||
success: function(result) {
|
||
if (result) {
|
||
$("#Driver").empty();
|
||
$('#loader').hide();
|
||
$("#Driver").append(result);
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
alert('Please select the PayOn');
|
||
return false;
|
||
}
|
||
});
|
||
|
||
$("#Calculate").click(function() {
|
||
|
||
|
||
var payon = $('#PayOn').val();
|
||
var driver = $('#Driver').val();
|
||
|
||
if (payon != '-1' && driver != '-1') {
|
||
var check = $('#All').is(":checked");
|
||
if (check) {
|
||
var c = 0;
|
||
var time = 0;
|
||
$('#Driver').find('option').each(function() {
|
||
c++;
|
||
var driver = $(this).val();
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: {
|
||
payon: payon,
|
||
driver: driver
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>checkDriverExistPay",
|
||
|
||
success: function(result) {
|
||
if (result != 1) {
|
||
$.ajax({
|
||
data: {
|
||
payon: payon,
|
||
driver: driver
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>driverPayslip",
|
||
success: function(result) {
|
||
console.log(result);
|
||
$('#loader').hide();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
});
|
||
time = (c * 300);
|
||
// alert(time);
|
||
setTimeout(function() {
|
||
alert(c + '-Driver Salary Added Successfully!');
|
||
$('form#PayslipGenerator').submit();
|
||
alert("Please wait while Payslip Downloading...!");
|
||
$('#loader').hide();
|
||
}, time);
|
||
} // else for select all not selected
|
||
else {
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: {
|
||
payon: payon,
|
||
driver: driver
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>checkDriverExistPay",
|
||
|
||
success: function(result) {
|
||
|
||
|
||
if (result == 1) {
|
||
|
||
$('form#PayslipGenerator').submit();
|
||
$('#loader').hide();
|
||
alert("Payslip Downloaded Successfully..!");
|
||
} else {
|
||
|
||
$.ajax({
|
||
data: {
|
||
payon: payon,
|
||
driver: driver
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>driverPayslip",
|
||
success: function(result) {
|
||
$('form#PayslipGenerator').submit();
|
||
$('#loader').hide();
|
||
alert("Salary Calculated Successfully..!");
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
|
||
} // else for select all not selected
|
||
|
||
} // check payon select/not selected
|
||
else {
|
||
alert('Please select the PayOn');
|
||
return false;
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<div class="content-page">
|
||
<!-- Content Header (Page header) -->
|
||
|
||
<div class="container-fluid">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<div class="page-title-right">
|
||
<ol class="breadcrumb m-0">
|
||
<li class="breadcrumb-item"><a href="javascript: void(0);">HR</a></li>
|
||
<li class="breadcrumb-item"><a href="javascript: void(0);">PaySlip</a></li>
|
||
<li class="breadcrumb-item active">
|
||
<h4 class="page-title"> Driver's Pay Slip Generator</h4>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="content">
|
||
<div class="card">
|
||
<div class="card-body" style="padding: 1rem 2rem !important;">
|
||
<form id="PayslipGenerator" action="<?php echo base_url() ?>driverPrintPdf" method="post" role="form" style="border:2px dotted; padding:5%">
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
|
||
<span for="selectmonth">Select Month</span>
|
||
<select id="PayOn" name="PayOn" class="form-control select2" style="width: 100%;">
|
||
<option value="-1">Select Payon Month</option>
|
||
<?php
|
||
if (!empty($Payon)) {
|
||
|
||
foreach ($Payon as $rl) {
|
||
$m = substr($rl->month_year, 0, 2);
|
||
$y = substr($rl->month_year, 3);
|
||
$tot = $monthsoptions[$m] . "-" . $y;
|
||
|
||
echo "<option value=\"" . $rl->month_year . "\">" . $tot . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
<div id="content"></div>
|
||
<div class="col-md-2">
|
||
</div>
|
||
<div class="col-md-4 col-md-offset-2">
|
||
<span>Driver</span>
|
||
<select id="Driver" name="Driver" class="form-control select2" type="text" class="form-control">
|
||
<option value="-1">Select Driver</option>
|
||
</select>
|
||
<br />
|
||
<!-- <input type="checkbox" name="All" id="All"> Select All<br> -->
|
||
</div>
|
||
<div class="col-md-6" align="right">
|
||
</div>
|
||
<div class="col-md-4 col-md-offset-6" align="right">
|
||
<input style="margin-top:10px !important" type="button" class="btn btn-info" id="Calculate" value="Calculate Pay" />
|
||
</div>
|
||
<div class="row">
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<?php // echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button></div>');
|
||
?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|