Upgrade to v15.0.OS
This commit is contained in:
@@ -64,6 +64,13 @@ class Time_sheetsActionManager extends SubActionManager{
|
||||
|
||||
$oldStatus = $timeSheet->status;
|
||||
$timeSheet->status = $req->status;
|
||||
|
||||
|
||||
//Auto approve admin timesheets
|
||||
if($req->status == 'Submitted' && BaseService::getInstance()->getCurrentUser()->user_level == "Admin"){
|
||||
$timeSheet->status = 'Approved';
|
||||
}
|
||||
|
||||
|
||||
if($oldStatus == $req->status){
|
||||
return new IceResponse(IceResponse::SUCCESS,"");
|
||||
|
||||
@@ -23,6 +23,39 @@ if (!class_exists('Time_sheetsModulesManager')) {
|
||||
|
||||
}
|
||||
|
||||
public function getDashboardItemData(){
|
||||
$data = array();
|
||||
$data['timeSheetHoursWorked'] = $this->getLastTimeSheetHours()->getData();
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
private function getLastTimeSheetHours(){
|
||||
$timeSheet = new EmployeeTimeSheet();
|
||||
$timeSheet->Load("employee = ? order by date_end desc limit 1",array(BaseService::getInstance()->getCurrentProfileId()));
|
||||
|
||||
if(empty($timeSheet->employee)){
|
||||
return new IceResponse(IceResponse::SUCCESS,"0:00");
|
||||
}
|
||||
|
||||
$timeSheetEntry = new EmployeeTimeEntry();
|
||||
$list = $timeSheetEntry->Find("timesheet = ?",array($timeSheet->id));
|
||||
|
||||
$seconds = 0;
|
||||
foreach($list as $entry){
|
||||
$seconds += (strtotime($entry->date_end) - strtotime($entry->date_start));
|
||||
}
|
||||
|
||||
$minutes = (int)($seconds/60);
|
||||
$rem = $minutes % 60;
|
||||
$hours = ($minutes - $rem)/60;
|
||||
if($rem < 10){
|
||||
$rem ="0".$rem;
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS,$hours.":".$rem);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +79,41 @@ if (!class_exists('EmployeeTimeSheet')) {
|
||||
public function getUserOnlyMeAccess(){
|
||||
return array("element","save","delete");
|
||||
}
|
||||
|
||||
public function getTotalTime()
|
||||
{
|
||||
|
||||
$start = $this->date_start . " 00:00:00";
|
||||
$end = $this->date_end . " 23:59:59";
|
||||
|
||||
$timeEntry = new EmployeeTimeEntry();
|
||||
$list = $timeEntry->Find("employee = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?))", array($this->employee, $start, $end, $start, $end));
|
||||
|
||||
|
||||
$seconds = 0;
|
||||
|
||||
foreach ($list as $entry) {
|
||||
|
||||
$secondsTemp = (strtotime($entry->date_end) - strtotime($entry->date_start));
|
||||
if ($secondsTemp < 0) {
|
||||
$secondsTemp = 0;
|
||||
}
|
||||
|
||||
|
||||
$seconds += $secondsTemp;
|
||||
}
|
||||
|
||||
$totMinutes = round($seconds / 60);
|
||||
$minutes = $totMinutes % 60;
|
||||
$hours = ($totMinutes - $minutes) / 60;
|
||||
|
||||
return CalendarTools::addLeadingZero($hours) . ":" . CalendarTools::addLeadingZero($minutes);
|
||||
}
|
||||
|
||||
public function postProcessGetData($entry){
|
||||
$entry->total_time = $this->getTotalTime();
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
class EmployeeTimeEntry extends ICEHRM_Record {
|
||||
|
||||
17
ext/modules/time_sheets/dashboard.html
Normal file
17
ext/modules/time_sheets/dashboard.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-yellow">
|
||||
<div class="inner">
|
||||
<h3>#_timeSheetHoursWorked_#</h3>
|
||||
<p>
|
||||
Hours worked Last Week
|
||||
</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-clock"></i>
|
||||
</div>
|
||||
<a href="#_moduleLink_#" class="small-box-footer" id="timesheetLink">
|
||||
Update Time Sheet <i class="fa fa-arrow-circle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -34,6 +34,7 @@ EmployeeTimeSheetAdapter.method('getDataMapping', function() {
|
||||
"id",
|
||||
"date_start",
|
||||
"date_end",
|
||||
"total_time",
|
||||
"status"
|
||||
];
|
||||
});
|
||||
@@ -43,6 +44,7 @@ EmployeeTimeSheetAdapter.method('getHeaders', function() {
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Start Date"},
|
||||
{ "sTitle": "End Date"},
|
||||
{ "sTitle": "Total Time"},
|
||||
{ "sTitle": "Status"}
|
||||
];
|
||||
});
|
||||
@@ -533,14 +535,16 @@ EmployeeTimeEntryAdapter.method('renderForm', function(object) {
|
||||
|
||||
//append dates
|
||||
|
||||
var dateStart = new Date(this.currentTimesheet.date_start.replace(" ","T"));
|
||||
var dateStop = new Date(this.currentTimesheet.date_end.replace(" ","T"));
|
||||
var dateStart = new Date(this.currentTimesheet.date_start);
|
||||
var dateStop = new Date(this.currentTimesheet.date_end);
|
||||
|
||||
var datesArray = this.getDates(dateStart, dateStop);
|
||||
|
||||
var optionList = "";
|
||||
for(var i=0; i<datesArray.length; i++){
|
||||
optionList += '<option value="'+datesArray[i].toString("yyyy-MM-dd")+'">'+datesArray[i].toString("d-MMM-yyyy")+'</option>';
|
||||
var k = datesArray[i];
|
||||
//optionList += '<option value="'+datesArray[i].toString("yyyy-MM-dd")+'">'+datesArray[i].toString("d-MMM-yyyy")+'</option>';
|
||||
optionList += '<option value="'+k.getUTCFullYear()+"-"+(k.getUTCMonth()+1)+"-"+k.getUTCDate()+'">'+k.toUTCString().slice(0, -13)+'</option>';
|
||||
}
|
||||
|
||||
|
||||
@@ -665,8 +669,8 @@ EmployeeTimeEntryAdapter.method('save', function() {
|
||||
});
|
||||
|
||||
EmployeeTimeEntryAdapter.method('doCustomValidation', function(params) {
|
||||
var st = Date.parse(params.date_start.replace(" ","T"));
|
||||
var et = Date.parse(params.date_end.replace(" ","T"));
|
||||
var st = Date.parse(params.date_start);
|
||||
var et = Date.parse(params.date_end);
|
||||
if(st.compareTo(et) != -1){
|
||||
return "Start time should be less than End time";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"order":"3",
|
||||
"icon":"fa-check-circle-o",
|
||||
"user_levels":["Admin","Manager","Employee"],
|
||||
"dashboardPosition":104,
|
||||
|
||||
"permissions":
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user