From b40bd3db3ac69cea2d89326da16d6d17080a6a74 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 1 Aug 2019 04:11:18 +1000 Subject: [PATCH] moving client calculation to server for some browser does not support getWeekDay --- UserJob.php | 25 ++++++++++++++++++++++++- js/feedback_card.js | 15 ++++----------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/UserJob.php b/UserJob.php index deffea0..06bf13e 100644 --- a/UserJob.php +++ b/UserJob.php @@ -75,7 +75,7 @@ class UserJob{ if ($this->db->last_error == ""){ $response['status'] = 'success'; foreach( $jobs as $s){ - $response['jobs'][] = array( + $el = array( 'id' => $s->id, 'tos' => $s->tos, 'start'=> $s->start, @@ -89,7 +89,16 @@ class UserJob{ 'rate_str'=> $this->get_rate_str($s->rate), 'tos_str'=> $this->get_tos_str($s->tos), 'staff_name' => $this->get_display_name($s->staff), + //extra field for GUI + 'hl_start_date' => $this->get_date_month($s->start), + 'hl_start' => $this->get_hh_mm($s->start), + 'hl_finish' => $this->get_hh_mm($s->finish), + 'rated' => ($s->rating >=1 && $s->rating<=5)? 'rated': '', + 'start_day' => $this->get_weekday_name($s->start), + 'finish_day' => $this->get_weekday_name($s->finish), ); + $el['checked_' . $s->rating] = 'checked'; + $response['jobs'][]=$el; } }else{ @@ -98,6 +107,20 @@ class UserJob{ } return $response; } + private function get_date_month($strdate){ + $d = new \DateTime($strdate); + return $d->format('d/n'); + } + + private function get_hh_mm($strdate){ + $d = new \DateTime($strdate); + return $d->format('H:i'); + } + + private function get_weekday_name($strdate){ + $d = new \DateTime($strdate); + return $d->format("D"); + } private function get_rate_str($earnings_rate_id) { diff --git a/js/feedback_card.js b/js/feedback_card.js index a44cf35..c11c7ca 100644 --- a/js/feedback_card.js +++ b/js/feedback_card.js @@ -22,7 +22,7 @@ finish: get_finish_date(), }, function(response, status, xhr){ if (response.status == "success"){ - pre_process(response); + //pre_process(response); load_client_jobs(response); }else{ display_error(response); @@ -37,8 +37,8 @@ $.each(response.jobs, function(idx, val){ val.hl_start_date = get_hl_start_date(val.start); - val.hl_start = get_hl_start(val.start); - val.hl_finish = get_hl_finish(val.finish); + val.hl_start = get_hh_mm(val.start); + val.hl_finish = get_hh_mm(val.finish); val.checked_1 = get_checked(1, val.rating); val.checked_2 = get_checked(2, val.rating); @@ -66,14 +66,7 @@ m = s.getMonth() + 1; return dd +"/" + m; } - function get_hl_start(start) - { - return get_hh_mm(start); - } - function get_hl_finish(finish) - { - return get_hh_mm(finish); - } + function get_hh_mm(date){ var s = new Date(date); var hh = s.getHours();