diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index 8235d5092..3d8edf608 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -40,7 +40,8 @@ module.exports = Self => { IFNULL(sc.workerSubstitute, c.salesPersonFk) AS salesPersonFk, c.id AS clientFk, c.name AS clientName, - s.lastUpdate AS dated, + TIME(v.stamp) AS hour, + DATE(v.stamp) AS dated, wtc.workerFk FROM hedera.userSession s JOIN hedera.visitUser v ON v.id = s.userVisitFk diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html index 9786404fd..35b52fa09 100644 --- a/modules/monitor/front/index/clients/index.html +++ b/modules/monitor/front/index/clients/index.html @@ -2,7 +2,8 @@ vn-id="model" url="SalesMonitors/clientsFilter" limit="6" - order="dated DESC" + filter="$ctrl.filter" + order="dated DESC, hour DESC" auto-load="true"> @@ -15,87 +16,85 @@ vn-tooltip="Minimize/Maximize" ng-click="$ctrl.main.toggle()"> - - - - - - Hour - Salesperson - Client - - - - - - - {{::visit.dated | date: 'HH:mm'}} - - - - - {{::visit.salesPerson | dashIfEmpty}} - - - - - {{::visit.clientName}} - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Date + + Hour + + Salesperson + + Client +
+ + {{::visit.dated | date:'dd/MM/yy'}} + + + + {{::visit.hour | date: 'HH:mm'}} + + + + {{::visit.salesPerson | dashIfEmpty}} + + + + {{::visit.clientName}} + +
+ + - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/monitor/front/index/clients/index.js b/modules/monitor/front/index/clients/index.js index 3a69c597b..58613f09d 100644 --- a/modules/monitor/front/index/clients/index.js +++ b/modules/monitor/front/index/clients/index.js @@ -2,26 +2,89 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; export default class Controller extends Section { + constructor($element, $) { + super($element, $); + + const date = new Date(); + this.dateFrom = date; + this.dateTo = date; + this.filter = { + where: { + 'v.stamp': { + between: this.dateRange() + } + } + }; + + this.smartTableOptions = { + activeButtons: { + search: true + }, + columns: [ + { + field: 'clientFk', + autocomplete: { + url: 'Clients', + showField: 'name', + valueField: 'id' + } + }, + { + field: 'salesPersonFk', + autocomplete: { + url: 'Workers/activeWithInheritedRole', + where: `{role: 'salesPerson'}`, + searchFunction: '{firstName: $search}', + showField: 'nickname', + valueField: 'id', + } + }, + { + field: 'dated', + searchable: false + }, + { + field: 'hour', + searchable: false + } + ] + }; + } + exprBuilder(param, value) { switch (param) { - case 'dated': - return {'s.lastUpdate': { - between: this.dateRange(value)} - }; case 'clientFk': + return {[`c.id`]: value}; case 'salesPersonFk': return {[`c.${param}`]: value}; } } - dateRange(value) { - const minHour = new Date(value); + dateRange() { + let from = this.dateFrom; + let to = this.dateTo; + if (!from) + from = new Date(); + if (!to) + to = new Date(); + const minHour = new Date(from); minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); + const maxHour = new Date(to); maxHour.setHours(23, 59, 59, 59); return [minHour, maxHour]; } + + addFilterDate() { + this.$.model.filter = { + where: { + 'v.stamp': { + between: this.dateRange() + } + } + }; + this.$.model.refresh(); + } } ngModule.vnComponent('vnMonitorSalesClients', {