Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short leave #278

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion application/views/leaves/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
<option value="Afternoon"><?php echo lang('Afternoon');?></option>
</select><br />

<label for="viz_enddate"><?php echo lang('leaves_create_field_end');?></label>
<label for="viz_enddate" id="enddatelabel"><?php echo lang('leaves_create_field_end');?></label>
<input type="text" name="viz_enddate" id="viz_enddate" value="<?php echo set_value('enddate'); ?>" autocomplete="off" />
<input type="hidden" name="enddate" id="enddate" />
<select name="enddatetype" id="enddatetype">
<option value="Morning"><?php echo lang('Morning');?></option>
<option value="Afternoon" selected><?php echo lang('Afternoon');?></option>
</select><br />
<!-- Show input field for start time -->
<label for="shorttime" id="timelabel"><?php echo 'Start time (24 hours format)';?></label>
<input type="time" name="shorttime" id="shorttime">

<label for="duration"><?php echo lang('leaves_create_field_duration');?> <span id="tooltipDayOff"></span></label>
<?php if ($this->config->item('disable_edit_leave_duration') == TRUE) { ?>
Expand All @@ -53,6 +56,10 @@
<?php } ?>

<span style="margin-left: 2px;position: relative;top: -5px;" id="spnDayType"></span>
<!-- show duration fo short leave -->
<p id="showduration" >2 hours</p>



<div class="alert hide alert-error" id="lblCreditAlert" onclick="$('#lblCreditAlert').hide();">
<button type="button" class="close">&times;</button>
Expand Down Expand Up @@ -108,6 +115,62 @@
$(document).on("click", "#showNoneWorkedDay", function(e) {
showListDayOffHTML();
});
</script>

<script>
// this will hide or show enddate , Startdatetype , enddatetype, enddatelabel, duration etc.
// accordimg to type of leave (Short Leave or not).
$(document).ready(function(){
$("#shorttime").hide();
$("#timelabel").hide();
$('#showduration').hide();

$("#type").change(function(){

var type= $(this).children("option:selected").text();
if (type == "Short Leave")
{ $("#startdatetype" ).hide();
$("#enddatetype").hide();
$("#duration" ).hide();
$("#enddatelabel" ).hide();


$("#viz_enddate" ).hide();
$("#shorttime").show();
$("#timelabel").show();
$('#showduration').show();
}
else
{ $("#shorttime").hide();
$("#timelabel").hide();
$('#showduration').hide();
$("#startdatetype" ).show();
$("#enddatetype").show();
$("#duration" ).show();
$("#viz_enddate" ).show();
$("#enddatelabel" ).show();


}
});
});

// this function set end date and end time for short leave
//
function shortleave(){
$("#startdatetype option:selected").val($("#shorttime").val());
var time= $('#shorttime').val().split(':');;
var h=parseInt(time[0]);
h=h+2;
var endtime = h+ ":"+time[1];

$("#enddatetype option:selected").val(endtime);
$("#duration" ).val(0.33);
var sd=$("#startdate").val();
$("#viz_enddate" ).datepicker('setDate', new Date(sd));

}

</script>
<script type="text/javascript">
var baseURL = '<?php echo base_url();?>';
Expand Down
4 changes: 2 additions & 2 deletions application/views/leaves/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
<?php } ?>
</div>
</td>
<td data-order="<?php echo $tmpStartDate; ?>"><?php echo $startdate . ' (' . lang($leave['startdatetype']). ')'; ?></td>
<td data-order="<?php echo $tmpEndDate; ?>"><?php echo $enddate . ' (' . lang($leave['enddatetype']) . ')'; ?></td>
<td data-order="<?php echo $tmpStartDate; ?>"><?php echo $startdate . ' (' . $leave['startdatetype']. ')'; ?></td>
<td data-order="<?php echo $tmpEndDate; ?>"><?php echo $enddate . ' (' . $leave['enddatetype'] . ')'; ?></td>
<td><?php echo $leave['cause']; ?></td>
<td><?php echo $leave['duration']; ?></td>
<td><?php echo $leave['type_name']; ?></td>
Expand Down
4 changes: 2 additions & 2 deletions application/views/requests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
</div>
</td>
<td><?php echo $request['firstname'] . ' ' . $request['lastname']; ?></td>
<td data-order="<?php echo $tmpStartDate; ?>"><?php echo $startdate . ' (' . lang($request['startdatetype']). ')'; ?></td>
<td data-order="<?php echo$tmpEndDate; ?>"><?php echo $enddate . ' (' . lang($request['enddatetype']) . ')'; ?></td>
<td data-order="<?php echo $tmpStartDate; ?>"><?php echo $startdate . ' (' . $request['startdatetype']. ')'; ?></td>
<td data-order="<?php echo$tmpEndDate; ?>"><?php echo $enddate . ' (' . $request['enddatetype'] . ')'; ?></td>
<td><?php echo $request['duration']; ?></td>
<td><?php echo $request['type_name']; ?></td>
<?php
Expand Down
25 changes: 23 additions & 2 deletions assets/js/lms/leave.edit-0.7.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,19 @@ $(function () {
$("#days").val(value);
});

$('#viz_startdate').change(function() {getLeaveLength(true);});
$('#viz_startdate').change(function() {
// set end date equal to start date for Short Leave
if ($("#type option:selected").text() == "Short Leave")
{

var sd=$("#startdate").val();

$("#viz_enddate" ).datepicker('setDate', new Date(sd));
}

getLeaveLength(true);

});
$('#viz_enddate').change(function() {getLeaveLength();});
$('#startdatetype').change(function() {getLeaveLength();});
$('#enddatetype').change(function() {getLeaveLength();});
Expand All @@ -284,11 +296,20 @@ $(function () {
$("#duration").keyup(function() {getLeaveInfos(true);});

$("#frmLeaveForm").submit(function(e) {
if (validate_form()) {
// To vaildate enddate , duration if Leave type is not equal to Short Leave
if ($("#type option:selected").text() != "Short Leave")
{
if (validate_form()) {
return true;
} else {
e.preventDefault();
return false;
}
}else{
shortleave();
return true;

}

});
});