fleetmap-reports 1.0.719 → 1.0.721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.719",
3
+ "version": "1.0.721",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  const automaticReports = require('./automaticReports')
2
- const { convertMS, getDates, getTranslations, weekDaySelected } = require('./util/utils')
2
+ const { convertMS, getDates, getTranslations, weekDaySelected, convertToLocaleString } = require('./util/utils')
3
3
  const jsPDF = require('jspdf')
4
4
  require('jspdf-autotable')
5
5
  const {
@@ -338,6 +338,9 @@ async function exportActivityReportToPDF (userData, reportData) {
338
338
  }
339
339
 
340
340
  function exportActivityReportToPDFDriver (doc, translations, reportData, userData) {
341
+ const timezone = userData.user.attributes.timezone
342
+ const lang = userData.user.attributes.lang || (navigator && navigator.language)
343
+
341
344
  const headers = [translations.report.driver,
342
345
  translations.report.start,
343
346
  translations.report.end,
@@ -347,7 +350,8 @@ function exportActivityReportToPDFDriver (doc, translations, reportData, userDat
347
350
  translations.report.driverHours]
348
351
 
349
352
  doc.setFontSize(10)
350
- doc.text(new Date(reportData.from).toLocaleString() + ' - ' + new Date(reportData.to).toLocaleString(), 20, 30)
353
+ doc.text(convertToLocaleString(reportData.from, lang, timezone) + ' - ' + convertToLocaleString(reportData.to, lang, timezone), 20, 30)
354
+ doc.text()
351
355
 
352
356
  const data = []
353
357
  reportData.drivers.forEach(d => {
@@ -375,6 +379,9 @@ function exportActivityReportToPDFDriver (doc, translations, reportData, userDat
375
379
  }
376
380
 
377
381
  function exportActivityReportToPDFVehicle (doc, translations, reportData, userData) {
382
+ const timezone = userData.user.attributes.timezone
383
+ const lang = userData.user.attributes.lang || (navigator && navigator.language)
384
+
378
385
  const headers = [translations.report.vehicle,
379
386
  translations.report.group,
380
387
  translations.report.start,
@@ -388,14 +395,14 @@ function exportActivityReportToPDFVehicle (doc, translations, reportData, userDa
388
395
  translations.report.spentFuel]
389
396
 
390
397
  doc.setFontSize(10)
391
- doc.text(new Date(reportData.from).toLocaleString() + ' - ' + new Date(reportData.to).toLocaleString(), 20, 30)
398
+ doc.text(convertToLocaleString(reportData.from, lang, timezone) + ' - ' + convertToLocaleString(reportData.to, lang, timezone), 20, 30)
392
399
 
393
400
  const data = []
394
401
  reportData.devices.forEach(d => {
395
402
  const group = userData.groups.find(g => d.device.groupId === g.id)
396
403
 
397
404
  const temp = [
398
- d.summary[0].deviceName,
405
+ d.device.name,
399
406
  group ? group.name : '',
400
407
  d.summary[0].startTime ? new Date(d.summary[0].startTime).toLocaleString() : '',
401
408
  d.summary[0].endTime ? new Date(d.summary[0].endTime).toLocaleString() : '',
@@ -513,7 +520,7 @@ function exportActivityReportToExcelVehicleGroupByDay (settings, translations, r
513
520
  data = data.concat([{}])
514
521
  data = data.concat(d.summary.map(s => {
515
522
  return {
516
- name: s.deviceName,
523
+ name: d.device.name,
517
524
  group: group ? group.name : '',
518
525
  date: new Date(s.date).toLocaleDateString(),
519
526
  weekday: weekDays[s.date.getDay()],
@@ -713,7 +720,7 @@ function exportActivityReportToExcelVehicle (settings, translations, reportData,
713
720
  const group = userData.groups.find(g => d.device.groupId === g.id)
714
721
 
715
722
  data = data.concat([{
716
- name: d.summary[0].deviceName,
723
+ name: d.device.name,
717
724
  group: group ? group.name : '',
718
725
  start: d.summary[0].startTime ? new Date(d.summary[0].startTime).toLocaleString() : '',
719
726
  end: d.summary[0].endTime ? new Date(d.summary[0].endTime).toLocaleString() : '',