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

Adding decimal value leaves #302

Open
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions application/modules/default/forms/addemployeeleaves.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function init()

$emp_leave_limit = new Zend_Form_Element_Text('leave_limit');
$emp_leave_limit->setLabel("Allot Leave Limit");
$emp_leave_limit->setAttrib('maxLength', 3);
$emp_leave_limit->setAttrib('maxLength', 4);
$emp_leave_limit->addFilter(new Zend_Filter_StringTrim());

if($id_val == '') {
Expand Down Expand Up @@ -64,7 +64,7 @@ public function init()

$emp_leave_limit->addValidator("regex",true,array(

'pattern'=>'/^(\-?[1-9]|\-?[1-9][0-9])$/',
'pattern'=>'/^\d{0,2}(\.\d{1,1})?$/',

'messages'=>array(
'regexNotMatch'=>'Leave limit must be in the range of 0 to 100.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function enableLeaves(userid) {
function validateEmployeLeaves() {
var errorcount = 0;
var enabledcount = 0;
var re = /^[0-9]+$/;
var re = /^\d{0,2}(\.\d{1,1})?$/;
$('.emp_leave_cls').each(function(i){
var ele= $(this).find('.add_emp_leaves');
var elementid = $(ele).attr('id');
Expand All @@ -93,7 +93,7 @@ function validateEmployeLeaves() {
}
else if(!re.test(reqValue))
{
$(ele).parent().append("<span class='errors' id='errors-"+elementid+"'>Please enter only number.</span>");
$(ele).parent().append("<span class='errors' id='errors-"+elementid+"'>Only 1 digit allowed after decimal.</span>");
$(ele).addClass('borderclass');
errorcount++;
}else if(!$(ele).is(':disabled'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<td id="empname_<?php echo $val['user_id'];?>" class="check_field"> <?php echo $val['userfullname'];?> </td>
<td class="leaves_edit_field" id="newleavelimit_<?php echo $val['user_id'];?>">
<div class="add-employee-div">
<input type="text" disabled="disabled" class="add_emp_leaves disable_class" maxlength=2 id="user_id_<?php echo $val['user_id'];?>" name="user_id[<?php echo $val['user_id'];?>]" value="<?php echo !empty($val['emp_leave_limit'])?$val['emp_leave_limit']:'';?>" onblur='validateNumberInput(this,"number")' onkeyup='validateNumberInput(this,"number")'>
<input type="text" disabled="disabled" class="add_emp_leaves disable_class" maxlength=4 id="user_id_<?php echo $val['user_id'];?>" name="user_id[<?php echo $val['user_id'];?>]" value="<?php echo !empty($val['emp_leave_limit'])?$val['emp_leave_limit']:'';?>" onblur='validateNumberInputForEmpLeave(this,"number")' onkeyup='validateNumberInputForEmpLeave(this,"number")'>
</div>
<div onclick="enableLeaves('<?php echo $val['user_id'];?>')" class="mrgetop7">
<span class="sprite edit"></span>
Expand Down
25 changes: 25 additions & 0 deletions public/media/js/hrmsv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,31 @@ function validateratingsonsubmit()
}
}

function validateNumberInputForEmpLeave(ele,msg)
{

var elementid = $(ele).attr('id');
var value = $(ele).val();
var re = /^\d{0,2}(\.\d{1,1})?$/;
$('#errors-'+elementid).remove();
$(ele).removeClass('borderclass');
if(value == '')
{
$(ele).parent().append("<span class='errors' id='errors-"+elementid+"'>Please enter leaves.</span>");
$(ele).addClass('borderclass');
}
else if(!re.test(value))
{
$(ele).parent().append("<span class='errors' id='errors-"+elementid+"'>Only 1 digit allowed after decimal.</span>");
$(ele).addClass('borderclass');
}
else
{
$('#errors-'+elementid).remove();
$(ele).removeClass('borderclass');
}
}

function updateleavedetails(leaveid,controllername)
{
if(!leaveid)
Expand Down