wip populate total worked hours and leave hours on each day of the thanato stat
This commit is contained in:
parent
bcc48b37bb
commit
c21c0b41dd
@ -310592,4 +310592,4 @@ appointmentsConfigsStore.addInitialConfigs((0,_nextcloud_initial_state__WEBPACK_
|
||||
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=calendar-main.js.map?v=0c744d586e9279b15833
|
||||
//# sourceMappingURL=calendar-main.js.map?v=ce56abf83284e7541471
|
||||
File diff suppressed because one or more lines are too long
@ -8865,7 +8865,7 @@ window._registerCustomPickerElement = _;
|
||||
/******/ // This function allow to reference async chunks
|
||||
/******/ __webpack_require__.u = (chunkId) => {
|
||||
/******/ // return url for filenames based on template
|
||||
/******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_autosize_dist_autosize_esm_js-node_modules_html-entities_lib_index_js-no-4072c5":"7212b31e059bc10c256e","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254":"ab7be1676f2641f652aa","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","src_store_index_js":"e380346f21f6daf64ba8","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","public-calendar-subscription-picker":"2315e24e67ebf6e4b6db","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + "";
|
||||
/******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_autosize_dist_autosize_esm_js-node_modules_html-entities_lib_index_js-no-4072c5":"7212b31e059bc10c256e","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254":"1cab553461635c83e77d","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","src_store_index_js":"b849999ea9c39f367cf5","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","public-calendar-subscription-picker":"2315e24e67ebf6e4b6db","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + "";
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
@ -9115,4 +9115,4 @@ __webpack_require__.p = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.linkTo
|
||||
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=calendar-reference.js.map?v=d5f4bdadf4e197003d50
|
||||
//# sourceMappingURL=calendar-reference.js.map?v=7e08db02f5011dc82999
|
||||
File diff suppressed because one or more lines are too long
@ -27693,4 +27693,4 @@ module.exports = "data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/sv
|
||||
/***/ })
|
||||
|
||||
}]);
|
||||
//# sourceMappingURL=calendar-src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254.js.map?v=ab7be1676f2641f652aa
|
||||
//# sourceMappingURL=calendar-src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254.js.map?v=1cab553461635c83e77d
|
||||
File diff suppressed because one or more lines are too long
@ -9,4 +9,6 @@ abstract class BddConstant
|
||||
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann";
|
||||
|
||||
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
|
||||
}
|
||||
@ -17,7 +17,7 @@ class Bdd {
|
||||
private String $charset = 'utf8mb4';
|
||||
|
||||
public const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
|
||||
public const CALENDAR_TABLE_PREFIX = "*PREFIX*";
|
||||
public const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||
public const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||
public const DEFAULT_CLIENT_GROUP_FACTURATION_NAME = "Nom du groupe";
|
||||
private IDbConnection $pdo;
|
||||
@ -2191,23 +2191,82 @@ class Bdd {
|
||||
return $devisList;
|
||||
}
|
||||
|
||||
private function getThanatoNameByThanatoIds(array $thanatoIds){
|
||||
$thanatoIdsPlaceholder = implode(',', array_fill(0, count($thanatoIds), '?'));
|
||||
$sql = "SELECT id, nom, prenom FROM ".$this->tableprefix."thanato WHERE id IN ($thanatoIdsPlaceholder);";
|
||||
$thanatos = $this->execSQLNoJsonReturn($sql,$thanatoIds);
|
||||
$result = [];
|
||||
foreach($thanatos as $thanato){
|
||||
$thanatoId = $thanato['id'];
|
||||
$result["$thanatoId"] = $thanato['nom'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getCalendarByThanatoIdNextcloud($idNextCloud){
|
||||
$searchString = "%principals/users/$idNextCloud%";
|
||||
$sql = "SELECT * FROM ".self::DEFAULT_TABLE_PREFIX."calendars as calendar WHERE calendar.principaluri LIKE ? LIMIT 1;";
|
||||
$calendar = $this->execSQLNoJsonReturn($sql,[$searchString]);
|
||||
if(!empty($calendar)){
|
||||
return $calendar[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getThanatoLeaveByCalendarAndDate($calendarId,$date){
|
||||
$datetimeFormatted = $date->format('Ymd');
|
||||
$dateCondition = "%DTSTART%".$datetimeFormatted."%";
|
||||
$isLeaveConditionAsString = "%".BddConstant::ISLEAVEPROPERTYONVCALENDAR.":1%";
|
||||
$sql = "SELECT * FROM ".self::DEFAULT_TABLE_PREFIX."calendarobjects as calendarobject WHERE
|
||||
calendarobject.calendarid = ? AND
|
||||
calendarobject.calendardata LIKE ? AND
|
||||
calendarobject.calendardata LIKE ? AND
|
||||
calendarobject.deleted_at IS NULL;";
|
||||
$leaves = $this->execSQLNoJsonReturn($sql,[$calendarId,$isLeaveConditionAsString,$dateCondition]);
|
||||
return $leaves;
|
||||
}
|
||||
public function getThanatoDevisPerDateInAMonthYear(array $thanatoIds,$month,$year){
|
||||
$dateOfMonths = DateHelpers::getDatesOfMonth($year,$month);
|
||||
$devisListPerThanatoPerDate = [];
|
||||
$thanatosName = $this->getThanatoNameByThanatoIds($thanatoIds);
|
||||
$thanatoCalendarIds = [];
|
||||
foreach($thanatosName as $thanatoId => $thanatoName){
|
||||
$calendar = $this->getCalendarByThanatoIdNextcloud($thanatoName);
|
||||
$thanatoCalendarIds[$thanatoId] = $calendar['id'];
|
||||
}
|
||||
foreach($dateOfMonths as $currentDate){
|
||||
$currentDateFormatted = $currentDate->format('Y-m-d');
|
||||
$devisList = $this->getThanatosDevisListByDate($thanatoIds,$currentDate);
|
||||
if(empty($devisList)){
|
||||
//get if on leave
|
||||
//if on leave set hours
|
||||
//else set
|
||||
$thereIsNoDevisForCurrentDate = empty($devisList);
|
||||
if($thereIsNoDevisForCurrentDate){
|
||||
foreach($thanatoIds as $thanatoId){
|
||||
$devisListPerThanatoPerDate[$thanatoId][$currentDateFormatted] = [
|
||||
$thanatoName = $thanatosName[$thanatoId];
|
||||
$devisListPerThanatoPerDate[$thanatoId][$currentDateFormatted]["hasDevis"] = false;
|
||||
$thanatoLeavesThisDay = $this->getThanatoLeaveByCalendarAndDate($thanatoCalendarIds[$thanatoId],$currentDate);
|
||||
if(empty($thanatoLeavesThisDay)){
|
||||
$devisListPerThanatoPerDate[$thanatoId][$currentDateFormatted]["leaves"][] = [
|
||||
"onLeave" => false,
|
||||
"leaveTimeStart" => null,
|
||||
"leaveTimeEnd" => null
|
||||
"startTime" => null,
|
||||
"endTime" => null,
|
||||
"thanatoName"=>$thanatosName[$thanatoId],
|
||||
"date" => $currentDateFormatted,
|
||||
"totalHours" => 0
|
||||
];
|
||||
}
|
||||
else{
|
||||
foreach($thanatoLeavesThisDay as $currentLeave){
|
||||
$leaveTime = VCalendarHelpers::GetStartAndEndTimeFromVCalendarString($currentLeave['calendardata']);
|
||||
$devisListPerThanatoPerDate[$thanatoId][$currentDateFormatted]["leaves"][] = [
|
||||
"onLeave" => true,
|
||||
"startTime" => $leaveTime["startTime"],
|
||||
"endTime" => $leaveTime["endTime"],
|
||||
"thanatoName"=>$thanatosName[$thanatoId],
|
||||
"date" => $currentDateFormatted,
|
||||
"totalHours" => $leaveTime["totalHours"]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
foreach($devisList as $devis){
|
||||
@ -2223,11 +2282,25 @@ class Bdd {
|
||||
$devisListPerThanatoPerDate[$devisThanatoId][$currentDateFormatted] = [
|
||||
'total_distance' => 0,
|
||||
"devis" => [],
|
||||
"devisId" => []
|
||||
"devisId" => [],
|
||||
"hasDevis" => true,
|
||||
"leaves" => []
|
||||
];
|
||||
}
|
||||
$devisListPerThanatoPerDate[$devisThanatoId][$currentDateFormatted]["devis"][] = $devis;
|
||||
$devisListPerThanatoPerDate[$devisThanatoId][$currentDateFormatted]["devisId"][] = $devis['id'];
|
||||
$thanatoLeavesThisDay = $this->getThanatoLeaveByCalendarAndDate($thanatoCalendarIds[$thanatoId],$currentDate);
|
||||
foreach($thanatoLeavesThisDay as $currentLeave){
|
||||
$leaveTime = VCalendarHelpers::GetStartAndEndTimeFromVCalendarString($currentLeave['calendardata']);
|
||||
$devisListPerThanatoPerDate[$thanatoId][$currentDateFormatted]["leaves"][] = [
|
||||
"onLeave" => true,
|
||||
"startTime" => $leaveTime["startTime"],
|
||||
"endTime" => $leaveTime["endTime"],
|
||||
"thanatoName"=>$thanatosName[$thanatoId],
|
||||
"date" => $currentDateFormatted,
|
||||
"totalHours" => $leaveTime["totalHours"]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2393,7 +2466,7 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getCalendarDataByCalendarObjectUuid(string $calendarObjectUuid){
|
||||
$sql = "SELECT * FROM ".self::CALENDAR_TABLE_PREFIX."calendarobjects WHERE uid = ?;";
|
||||
$sql = "SELECT * FROM ".self::DEFAULT_TABLE_PREFIX."calendarobjects WHERE uid = ?;";
|
||||
$calendarObjectList = $this->execSQLNoJsonReturn($sql, [$calendarObjectUuid]);
|
||||
if(!empty($calendarObjectList)){
|
||||
$calendarDataBlob = $calendarObjectList[0]['calendardata'];
|
||||
@ -2418,7 +2491,7 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getCalendarObjectByUuid(string $calendarObjectUuid){
|
||||
$sql = "SELECT * FROM ".self::CALENDAR_TABLE_PREFIX."calendarobjects WHERE uid = ?;";
|
||||
$sql = "SELECT * FROM ".self::DEFAULT_TABLE_PREFIX."calendarobjects WHERE uid = ?;";
|
||||
$calendarObjectList = $this->execSQLNoJsonReturn($sql, [$calendarObjectUuid]);
|
||||
if(!empty($calendarObjectList)){
|
||||
$calendarData = $calendarObjectList[0];
|
||||
@ -2428,7 +2501,7 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getCalendarById(int $calendarId){
|
||||
$sql = "SELECT * FROM ".self::CALENDAR_TABLE_PREFIX."calendars WHERE id = ?;";
|
||||
$sql = "SELECT * FROM ".self::DEFAULT_TABLE_PREFIX."calendars WHERE id = ?;";
|
||||
$calendarList = $this->execSQLNoJsonReturn($sql, [$calendarId]);
|
||||
if(!empty($calendarList)){
|
||||
$calendarData = $calendarList[0];
|
||||
|
||||
@ -80,4 +80,13 @@ class DateHelpers
|
||||
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
|
||||
}
|
||||
|
||||
public static function getHoursBetweenTwoDatetime($datetimeEnd,$datetimeStart){
|
||||
if($datetimeEnd == null || $datetimeStart == null){
|
||||
return 0;
|
||||
}
|
||||
$interval = $datetimeStart->diff($datetimeEnd);
|
||||
$hours = $interval->h + ($interval->days * 24) + ($interval->i / 60);
|
||||
return $hours;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ class VCalendarHelpers
|
||||
public static function GetStartAndEndTimeFromVCalendarString(string $vCalendarString){
|
||||
$startTimeValue = "";
|
||||
$endTimeValue = "";
|
||||
$totalHours = 0;
|
||||
if($vCalendarString != ""){
|
||||
$dateStart = self::GetDateStartOrDateEndFromVCalendarString("DTSTART", $vCalendarString);
|
||||
if($dateStart != null){
|
||||
@ -48,10 +49,12 @@ class VCalendarHelpers
|
||||
if($dateEnd != null){
|
||||
$endTimeValue = $dateEnd->format("H") . "h";
|
||||
}
|
||||
$totalHours = DateHelpers::getHoursBetweenTwoDatetime($dateEnd,$dateStart);
|
||||
}
|
||||
return [
|
||||
"startTime" => $startTimeValue,
|
||||
"endTime" => $endTimeValue
|
||||
"endTime" => $endTimeValue,
|
||||
"totalHours" => $totalHours
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -76,13 +76,20 @@ class ExportThanatoStatisticService {
|
||||
return $fileHeader;
|
||||
}
|
||||
|
||||
private function populateNoDevisDataInADay(string $fileContent,string $dateAsString){
|
||||
private function populateNoDevisDataInADay(string $fileContent,$leave){
|
||||
// var_dump($devisData);die;
|
||||
$startTimeValue = "";
|
||||
$endTimeValue = "";
|
||||
if($leave["onLeave"]){
|
||||
$startTimeValue = $leave["startTime"];
|
||||
$endTimeValue = $leave["endTime"];
|
||||
}
|
||||
$fileContent = $fileContent.
|
||||
''.';'.
|
||||
''.';'.
|
||||
$dateAsString.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
FileExportHelpers::FormatTextForExport($leave['thanatoName']).';'.
|
||||
$leave['date'].';'.
|
||||
$startTimeValue.';'.
|
||||
$endTimeValue.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
@ -98,18 +105,29 @@ class ExportThanatoStatisticService {
|
||||
// die;
|
||||
foreach($exportData as $thanatoId => $devisPerThanato){
|
||||
foreach($devisPerThanato as $devisDate => $devisData){
|
||||
$currentDevisIsNotDevis = array_key_exists('onLeave',$devisData);
|
||||
if($currentDevisIsNotDevis){
|
||||
$fileContent = $this->populateNoDevisDataInADay($fileContent,$devisDate);
|
||||
$hasDevisInTheCurrentDate = $devisData['hasDevis'];
|
||||
if($hasDevisInTheCurrentDate === false){
|
||||
$totalLeaveHours = 0;
|
||||
$totalWorkedHours = 0;
|
||||
$leaves = $devisData["leaves"];
|
||||
foreach($leaves as $leave){
|
||||
$fileContent = $this->populateNoDevisDataInADay($fileContent,$leave);
|
||||
if($leave["onLeave"]){
|
||||
$totalLeaveHours += $leave["totalHours"];
|
||||
}
|
||||
}
|
||||
$totalWorkedHours = 8 - $totalLeaveHours;
|
||||
}
|
||||
else{
|
||||
$distanceTotal = $this->gestionBdd->getDistanceTotalByDevisIdList($devisData["devisId"]);
|
||||
$totalWorkedHours = 0;
|
||||
$devisList = $devisData["devis"];
|
||||
if(!empty($devisList)){
|
||||
foreach($devisList as $devis){
|
||||
$fileContent = $this->populateDevisDataIntoThanatoExportFileContent($fileContent,$devis);
|
||||
$totalWorkedHours += $devis["totalHours"];
|
||||
}
|
||||
$fileContent = $this->populateDistanceTotalIntoThanatoExportFileContent($fileContent,$distanceTotal);
|
||||
$fileContent = $this->populateLastRecapForTheLine($fileContent,$distanceTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +135,7 @@ class ExportThanatoStatisticService {
|
||||
return $fileContent;
|
||||
}
|
||||
|
||||
private function populateDistanceTotalIntoThanatoExportFileContent(string $fileContent,$distance){
|
||||
private function populateLastRecapForTheLine(string $fileContent,$distance){
|
||||
$fileContent = $fileContent.
|
||||
''.';'.
|
||||
''.';'.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user