Loading module/Oscar/src/Oscar/Controller/TimesheetController.php +8 −1 Original line number Diff line number Diff line Loading @@ -2012,14 +2012,21 @@ class TimesheetController extends AbstractOscarController public function resumeAction() { $personId = $this->params()->fromQuery('person_id', null); $url = $this->url()->fromRoute('timesheet/resume').'?f=json'; if ($personId) { $url .= '&person_id=' . $personId; $person = $this->getPersonService()->getPerson($personId); } else { $person = $this->getCurrentPerson(); } if( $this->isAjax() || $this->getRequest()->getQuery('f') == 'json' ){ $datas = $this->getTimesheetService()->getResumePerson($person); return $this->jsonOutput($datas); } return [ 'datas' => $this->getTimesheetService()->getResumePerson($person), 'url' => $url, 'person' => $personId ? $person : null ]; } Loading module/Oscar/src/Oscar/Service/TimesheetService.php +24 −0 Original line number Diff line number Diff line Loading @@ -2684,6 +2684,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'current' => $period == $periodNow, 'futur' => $period > $periodNow, 'activities_id' => [], 'activities_details' => [], 'workpackages_id' => [], 'unexpected' => false, 'total' => 0.0, Loading Loading @@ -2724,6 +2725,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'year' => $year, 'periodDuration' => $this->getPeriodDuration($person, $year, $month), 'activities_id' => [], 'activities_details' => [], 'workpackages_id' => [], 'unexpected' => true, 'total' => 0.0, Loading @@ -2732,12 +2734,34 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'validations_id' => [] ]; } $day = $timesheet->getDateFrom()->format('d'); $total = $timesheet->getDuration(); $periodsDetails[$period]['total'] += $total; if ($timesheet->getActivity()) { $activityId = $timesheet->getActivity()->getId(); if(!array_key_exists($activityId, $periodsDetails[$period]['activities_details'])) { $periodsDetails[$period]['activities_details'][$activityId] = [ 'total' => 0.0, 'days' => [], 'events' => 0 ]; } // if(!array_key_exists($day, $periodsDetails[$period]['activities_details'])) { // $periodsDetails[$period]['activities_details'][$day] = [ // 'total' => 0.0, // 'events' => 0 // ]; // } $periodsDetails[$period]['total_activities'] += $total; $periodsDetails[$period]['total_activities_details'][$timesheet->getActivity()->getId()] += $total; $periodsDetails[$period]['activities_details'][$activityId]['total'] += $total; $periodsDetails[$period]['activities_details'][$activityId]['events']++; if( !in_array($day, $periodsDetails[$period]['activities_details'][$activityId]['days']) ){ $periodsDetails[$period]['activities_details'][$activityId]['days'][] = $day; } } else { $periodsDetails[$period]['total_horslots'] += $total; } Loading module/Oscar/view/oscar/timesheet/resume.phtml +5 −34 Original line number Diff line number Diff line Loading @@ -5,38 +5,9 @@ pour <strong><?= $person ?></strong> <?php endif; ?> </h1> <div id="app">Chargement</div> <script> require(['vue', 'TimesheetPersonResume', 'mm'], function(Vue, TimesheetPersonResume, moment){ // Affichage des périodes Vue.filter('period', function(value){ return moment(value+"-01").format("MMMM YYYY"); }); // Affichage des périodes Vue.filter('heures', function(value){ let heures = Math.floor(value); let minutes = Math.round((value - heures)*60); if( minutes == 0 ){ minutes = ""; } else if(minutes < 10){ minutes = '0'+minutes; } return heures+'h'+minutes; }); new Vue({ el: "#app", render: function(h){ return h(TimesheetPersonResume.default, { props: { datas: <?= json_encode($datas) ?>, timesheetpreview: <?= $this->options()->hasTimesheetPreview() ? 'true':'false' ?>, timesheetexcel: <?= $this->options()->allowTimesheetExcel() ? 'true':'false' ?> }}); } }) }); </script> <div class="timesheet-resume" id="timesheet-resume" <?php if( DEBUG_OSCAR ) echo 'data-debug-enabled="true"' ?> data-url="<?= $url ?>" ></div> <?= $this->Vite()->addJs('src/TimesheetPersonResume.js'); ?> </div> No newline at end of file ui/src/TimesheetPersonResume.js 0 → 100644 +38 −0 Original line number Diff line number Diff line import { createApp } from "vue"; import TimesheetPersonResume from "./views/TimesheetPersonResume.vue"; import momentFilter from "./utils/MomentFilter.js"; import DurationFilter from "./utils/DurationFilter.js"; let elemDatas = document.querySelector("#timesheet-resume"); const app = createApp(TimesheetPersonResume, { "url": elemDatas.dataset.url }); app.config.globalProperties.$filters = { period(period) { return momentFilter.period(period); }, formatDuration(heure) { return DurationFilter.formatDuration(heure); } // timeAgo(date) { // return momentFilter.timeAgo(date); // }, // date(date) { // return momentFilter.date(date); // }, // dateFull(date) { // return momentFilter.dateFull(date); // }, // filesize(size) { // return filesize.filesize(size); // }, // money(amount) { // return money.money(amount); // }, // log(message) { // return traces.log(message); // } }; app.mount("#timesheet-resume"); No newline at end of file ui/src/utils/MomentFilter.js +7 −0 Original line number Diff line number Diff line Loading @@ -72,5 +72,12 @@ export default { }, dateFull(date, nullDisplay = 'Non définie') { return date ? (this.date(date) + " (" + this.timeAgo(date) + ")") : nullDisplay; }, period(str){ let s = str.split('-'); let y = s[0]; let m = parseInt(s[1]) - 1; let mn = moment.months()[m]; return mn +" " +y; } } Loading
module/Oscar/src/Oscar/Controller/TimesheetController.php +8 −1 Original line number Diff line number Diff line Loading @@ -2012,14 +2012,21 @@ class TimesheetController extends AbstractOscarController public function resumeAction() { $personId = $this->params()->fromQuery('person_id', null); $url = $this->url()->fromRoute('timesheet/resume').'?f=json'; if ($personId) { $url .= '&person_id=' . $personId; $person = $this->getPersonService()->getPerson($personId); } else { $person = $this->getCurrentPerson(); } if( $this->isAjax() || $this->getRequest()->getQuery('f') == 'json' ){ $datas = $this->getTimesheetService()->getResumePerson($person); return $this->jsonOutput($datas); } return [ 'datas' => $this->getTimesheetService()->getResumePerson($person), 'url' => $url, 'person' => $personId ? $person : null ]; } Loading
module/Oscar/src/Oscar/Service/TimesheetService.php +24 −0 Original line number Diff line number Diff line Loading @@ -2684,6 +2684,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'current' => $period == $periodNow, 'futur' => $period > $periodNow, 'activities_id' => [], 'activities_details' => [], 'workpackages_id' => [], 'unexpected' => false, 'total' => 0.0, Loading Loading @@ -2724,6 +2725,7 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'year' => $year, 'periodDuration' => $this->getPeriodDuration($person, $year, $month), 'activities_id' => [], 'activities_details' => [], 'workpackages_id' => [], 'unexpected' => true, 'total' => 0.0, Loading @@ -2732,12 +2734,34 @@ class TimesheetService implements UseOscarUserContextService, UseOscarConfigurat 'validations_id' => [] ]; } $day = $timesheet->getDateFrom()->format('d'); $total = $timesheet->getDuration(); $periodsDetails[$period]['total'] += $total; if ($timesheet->getActivity()) { $activityId = $timesheet->getActivity()->getId(); if(!array_key_exists($activityId, $periodsDetails[$period]['activities_details'])) { $periodsDetails[$period]['activities_details'][$activityId] = [ 'total' => 0.0, 'days' => [], 'events' => 0 ]; } // if(!array_key_exists($day, $periodsDetails[$period]['activities_details'])) { // $periodsDetails[$period]['activities_details'][$day] = [ // 'total' => 0.0, // 'events' => 0 // ]; // } $periodsDetails[$period]['total_activities'] += $total; $periodsDetails[$period]['total_activities_details'][$timesheet->getActivity()->getId()] += $total; $periodsDetails[$period]['activities_details'][$activityId]['total'] += $total; $periodsDetails[$period]['activities_details'][$activityId]['events']++; if( !in_array($day, $periodsDetails[$period]['activities_details'][$activityId]['days']) ){ $periodsDetails[$period]['activities_details'][$activityId]['days'][] = $day; } } else { $periodsDetails[$period]['total_horslots'] += $total; } Loading
module/Oscar/view/oscar/timesheet/resume.phtml +5 −34 Original line number Diff line number Diff line Loading @@ -5,38 +5,9 @@ pour <strong><?= $person ?></strong> <?php endif; ?> </h1> <div id="app">Chargement</div> <script> require(['vue', 'TimesheetPersonResume', 'mm'], function(Vue, TimesheetPersonResume, moment){ // Affichage des périodes Vue.filter('period', function(value){ return moment(value+"-01").format("MMMM YYYY"); }); // Affichage des périodes Vue.filter('heures', function(value){ let heures = Math.floor(value); let minutes = Math.round((value - heures)*60); if( minutes == 0 ){ minutes = ""; } else if(minutes < 10){ minutes = '0'+minutes; } return heures+'h'+minutes; }); new Vue({ el: "#app", render: function(h){ return h(TimesheetPersonResume.default, { props: { datas: <?= json_encode($datas) ?>, timesheetpreview: <?= $this->options()->hasTimesheetPreview() ? 'true':'false' ?>, timesheetexcel: <?= $this->options()->allowTimesheetExcel() ? 'true':'false' ?> }}); } }) }); </script> <div class="timesheet-resume" id="timesheet-resume" <?php if( DEBUG_OSCAR ) echo 'data-debug-enabled="true"' ?> data-url="<?= $url ?>" ></div> <?= $this->Vite()->addJs('src/TimesheetPersonResume.js'); ?> </div> No newline at end of file
ui/src/TimesheetPersonResume.js 0 → 100644 +38 −0 Original line number Diff line number Diff line import { createApp } from "vue"; import TimesheetPersonResume from "./views/TimesheetPersonResume.vue"; import momentFilter from "./utils/MomentFilter.js"; import DurationFilter from "./utils/DurationFilter.js"; let elemDatas = document.querySelector("#timesheet-resume"); const app = createApp(TimesheetPersonResume, { "url": elemDatas.dataset.url }); app.config.globalProperties.$filters = { period(period) { return momentFilter.period(period); }, formatDuration(heure) { return DurationFilter.formatDuration(heure); } // timeAgo(date) { // return momentFilter.timeAgo(date); // }, // date(date) { // return momentFilter.date(date); // }, // dateFull(date) { // return momentFilter.dateFull(date); // }, // filesize(size) { // return filesize.filesize(size); // }, // money(amount) { // return money.money(amount); // }, // log(message) { // return traces.log(message); // } }; app.mount("#timesheet-resume"); No newline at end of file
ui/src/utils/MomentFilter.js +7 −0 Original line number Diff line number Diff line Loading @@ -72,5 +72,12 @@ export default { }, dateFull(date, nullDisplay = 'Non définie') { return date ? (this.date(date) + " (" + this.timeAgo(date) + ")") : nullDisplay; }, period(str){ let s = str.split('-'); let y = s[0]; let m = parseInt(s[1]) - 1; let mn = moment.months()[m]; return mn +" " +y; } }