fleetmap-reports 1.0.628 → 1.0.629

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/idle-report.js +14 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.628",
3
+ "version": "1.0.629",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  const jsPDF = require('jspdf')
2
2
  const { headerFromUser, AmiriRegular } = require('./util/pdfDocument')
3
- const { convertToLocaleString, convertMS, getTranslations, getLanguage } = require('./util/utils')
3
+ const { convertToLocaleString, convertMS, getTranslations, getLanguage, convertToLocaleDateString, convertToLocaleTimeString } = require('./util/utils')
4
4
  const { getStyle } = require('./reportStyle')
5
5
  const { getUserPartner } = require('fleetmap-partners')
6
6
  const { devicesToProcess } = require('./util/device')
@@ -195,6 +195,7 @@ async function exportIdleReportToPDF (userData, reportData) {
195
195
  const idleData = userData.byDriver ? reportData.drivers : reportData.devices
196
196
 
197
197
  const headers = [
198
+ translations.report.date,
198
199
  translations.report.start,
199
200
  translations.report.end,
200
201
  translations.report.address,
@@ -236,7 +237,8 @@ async function exportIdleReportToPDF (userData, reportData) {
236
237
  d.idleEvents.forEach(a => {
237
238
  const temp = [
238
239
  getIdleEventDate(a.position, userData.user),
239
- getIdleEventDate(a.lastPosition, userData.user),
240
+ getIdleEventTime(a.position, userData.user),
241
+ getIdleEventTime(a.lastPosition, userData.user),
240
242
  a.position.address,
241
243
  convertMS(a.idleTime, true),
242
244
  userData.byDriver ? a.deviceName : getDriver(a, userData.drivers)
@@ -306,6 +308,7 @@ function exportIdleReportToExcel (userData, reportData) {
306
308
  }
307
309
  const headers = [
308
310
  { label: userData.byDriver ? translations.report.driver : translations.report.vehicle, value: 'name' },
311
+ { label: translations.report.date, value: 'date' },
309
312
  { label: translations.report.start, value: 'start' },
310
313
  { label: translations.report.end, value: 'end' },
311
314
  { label: translations.report.address, value: 'address' },
@@ -321,8 +324,9 @@ function exportIdleReportToExcel (userData, reportData) {
321
324
  return {
322
325
  name: userData.byDriver ? d.driver.name : d.device.name,
323
326
  duration: convertMS(a.idleTime, true),
324
- start: getIdleEventDate(a.position, userData.user),
325
- end: getIdleEventDate(a.lastPosition, userData.user),
327
+ date: getIdleEventDate(a.position, userData.user),
328
+ start: getIdleEventTime(a.position, userData.user),
329
+ end: getIdleEventTime(a.lastPosition, userData.user),
326
330
  subname: userData.byDriver ? a.deviceName : getDriver(a, userData.drivers),
327
331
  address: a.position.address + (a.geofenceName ? ' - ' + a.geofenceName : '')
328
332
  }
@@ -347,8 +351,12 @@ function deviceName (device) {
347
351
  return device.name + (device.attributes.license_plate ? ', ' + device.attributes.license_plate : '') + (device.model ? ', ' + device.model : '')
348
352
  }
349
353
 
350
- function getIdleEventDate (position, user) {
351
- return convertToLocaleString(position.fixTime, user.attributes.lang, user.attributes.timezone)
354
+ function getIdleEventDate (user, position) {
355
+ return convertToLocaleDateString(position.fixTime, user.attributes.lang, user.attributes.timezone)
356
+ }
357
+
358
+ function getIdleEventTime (user, position) {
359
+ return convertToLocaleTimeString(position.fixTime, user.attributes.lang, user.attributes.timezone)
352
360
  }
353
361
 
354
362
  exports.createIdleReport = createIdleReport