Skip to content

Commit

Permalink
Merge pull request sapplica#49 from go-faustino/employee-timesheet-ho…
Browse files Browse the repository at this point in the history
…lidays-error

Employee timesheet holidays error
  • Loading branch information
go-faustino authored Dec 21, 2016
2 parents c0bb9b6 + 51b828e commit 3aaea43
Showing 1 changed file with 41 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>

$leavesArray = array();
foreach($leavedData as $leavesRow) {
$from = $leavesRow['from_date'];
$from = $leavesRow['from_date'];
$to = $leavesRow['to_date'];
$leaveType = $leavesRow['leavetypeid'];
$leaveType = $leavesRow['leaveday'];
$dTo = date("Y-m-d",strtotime($to));
$dFrom = date("Y-m-d",strtotime($from));
$leaveStatus = $leavesRow['leavestatus'];
$leaveDay = $leavesRow['leaveday'];
$leaveReqId = $leavesRow['leave_req_id'];

$currentMonth;
// $currentMonth;
$monEnd = date("Y-m-d",strtotime($currentMonth."-".$lastday));
$monStart = date("Y-m-d",strtotime($currentMonth."-01"));
if(($dTo > $monEnd ))$to=$monEnd;
Expand All @@ -214,21 +215,26 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>
if($dayNum != $weekend_start && $dayNum != $weekend_end) {
if(!in_array($t, $holidayDates)) {
if($leaveStatus == 'Approved') {
$leaveT = ($leaveType == '1')?'L':'HD';
$leaveT = ($leaveType == '1')?'L':'HD';
$leaveReqId = 'L';
}else if($leaveStatus == 'Pending for approval'){
$leaveT = 'P';
if($leaveDay == 2){
$leaveT = 'PHD';
}
}
$leavesArray[] = (int)date("d",strtotime($t)).'-'.$leaveT;
$leavesArray[] = (int)date("d",strtotime($t)).'-'.$leaveT.'-'.$leaveReqId;
}
}
$t = date("Y-m-d",strtotime('next day',strtotime($t)));

}
}
//print_r($leavesArray);
foreach($holidayDates as $k=>$holDay) {
$holidayDates[$k] = ($holDay != '')?date("d",strtotime($holDay)):'';
}
//print_r($holidayDates);
$weekdays = array( 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
$statusClasses = array('no_entry'=>'no_entry','saved'=>'yet_to_submit','approved'=>'approved',
'submitted'=>'for_approval','enabled'=>'enabled','rejected'=>'rejected','blocked'=>'blocked');
Expand All @@ -254,6 +260,7 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>
$currentDayClass = "";
$inactiveDayClass = "";
$blockedDayClass = "";
$rejectNoteClass = "";
$holName = "";
$holLeaveClass = "";
$curDate = date('Y-m-d',strtotime($cDate));
Expand All @@ -274,15 +281,19 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>

$duration = ($weekData != "")?$weekData[strtolower($dayName).'_duration']:"00:00";
$status = ($weekData != "")?$weekData[strtolower($dayName).'_status']:'no_entry';
$rejected_note = ($weekData != "")?$weekData[strtolower($dayName).'_reject_note']:'';
$rejectNote = ($weekData != "")?$weekData[strtolower($dayName).'_reject_note']:"";
$calDate = $selectedYrMon[0].'-'.$selectedYrMon[1].'-'.$dayCounter;
$holiday = (in_array($calDate,$holidayDates))?"H":"";
if((in_array($calDate,$holidayDates))){
//$holiday = (in_array($calDate,$holidayDates))?"H":"";
$holiday = (in_array($dayCounter,$holidayDates))?"H":"";
//if((in_array($calDate,$holidayDates))){
if((in_array($dayCounter,$holidayDates))){

$holKey = array_search($calDate, $holidayDates);
//$holKey = array_search($calDate, $holidayDates);
$holKey = array_search($dayCounter, $holidayDates);
$holName = $holidayNames[$holKey];

}

$keys = array_keys($weekdays, $day);
//$weekendClass = (in_array($keys[0],$weekendsArray))?" weekend_td":"";
if(!empty($weekendsArray))
Expand Down Expand Up @@ -315,14 +326,17 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>
<?php
//$leave = (in_array($dayCounter, $leavesArray))?"L":"";
$leave = "";
$leaveType = "";
$leaveType = $leaveId = "";
//print_r($leavesArray);
foreach($leavesArray as $k=>$v) {

if(preg_match("/\b$dayCounter\b/i", $v)) {
$keyLeaveData = explode('-',$v);
$leaveType = $keyLeaveData[1];
}
if(preg_match("/\b$dayCounter\b/i", $v)) {
$keyLeaveData = explode('-',$v);
if($keyLeaveData[0] == $dayCounter){
$leaveType = $keyLeaveData[1];
$leaveId = $keyLeaveData[2];
}
}
}

if($leaveType == "L") {
Expand All @@ -347,34 +361,31 @@ if(strlen($empMinsPart.'') == 1) $empMinsPart = '0'.$empMinsPart;?>
else if($leave == 'HD')
$tooltip = 'Half day Leave';

if($holiday != "" || $leave != "" ) {

if($holiday != "" || $leave != "" ) {
?>
<div class="hol_leave <?php echo $holLeaveClass; ?>" title="<?php echo $tooltip;?>"><?php echo $holiday.$leave; ?> </div>
<div class="hol_leave <?php echo $holLeaveClass; ?>" title="<?php echo $tooltip;?>"><?php echo $holiday.$leave; ?> </div>
<?php }

if(!strpos($tdClass, "inactive_td")) {

$rejNoteAttr = "";
if($status == 'rejected'){
$rejectNoteClass = 'rejected_note';
$rejNoteAttr = 'data-powertip="'.$rejectNote.'"';
}

?>
<?php $class = '';
$tdata='';
$span='';
if($status == 'rejected') {
$class = 'rejected_note';
$span = "<span class = 'note_tool_date'>".(isset($rejected_note) && $rejected_note!='')?$rejected_note:''."</span>";
$tdata='data-powertip="'.$span.'"';
}?>
<!--<input type="hidden" name="txt_rej_note" id="txt_rej_note" value="<?php //echo (isset($rejected_note) && $rejected_note!='')?$rejected_note:'';?>">-->
<div class="sheet_status <?php echo $statusClasses[$status];?> <?php echo $class;?>" <?php echo $tdata;?>><?php echo ($statusText[$status] == "Blocked")?"Not Submitted":$statusText[$status];?></div></td>
<div class="sheet_status <?php echo $statusClasses[$status];?> <?php echo $rejectNoteClass?>" <?php echo $rejNoteAttr;?> leaveData = "leave_<?php echo $leaveId;?>"><?php echo ($statusText[$status] == "Blocked")?"Not Submitted":$statusText[$status];?></div></td>
<?php
} else {
?>
<div class="sheet_status <?php echo $statusClasses[$status];?>"></div></td>
<?php
<div class="sheet_status <?php echo $statusClasses[$status];?>" leaveData = "leave_<?php echo $leaveId;?>"></div></td>
<?php
}
$dayCounter ++;
} else {
?>
<td class="no_date"><span class="date">&nbsp;</span></td>
<td class="no_date"><span class="date">&nbsp;</span></a></td>
<?php
}
}
Expand Down

0 comments on commit 3aaea43

Please sign in to comment.