7c523a85d749ec003cae29dad5a3bdf471a2f7c0
[motion.git] / server / models / report_chat.js
1 /**
2  * Agent Log Model
3  */
4
5 var moment = require('moment');
6
7 module.exports = function(sequelize, DataTypes) {
8
9   var ReportChat = sequelize.define('ReportChat', {
10     uniqueid: DataTypes.STRING,
11     timeslot: DataTypes.INTEGER,
12     websitename: DataTypes.STRING,
13     websiteaddress: DataTypes.STRING,
14     websiteid: DataTypes.INTEGER,
15     application: DataTypes.STRING,
16     memberid: DataTypes.INTEGER,
17     membername: DataTypes.STRING,
18     visitorid: DataTypes.STRING,
19     visitorname: DataTypes.STRING,
20     visitoremail: DataTypes.STRING,
21     queue: DataTypes.INTEGER,
22     queuename: DataTypes.STRING,
23     roomid: DataTypes.INTEGER,
24     reason: {
25       type: DataTypes.STRING,
26       defaultValue: 'called'
27     },
28     connectid: {
29       type: DataTypes.STRING,
30       unique: true,
31       set: function(connectid) {
32         this.setDataValue('connectid', connectid);
33         this.setDataValue('reason', 'connect');
34         this.setDataValue('connectedAt', moment().format("YYYY-MM-DD HH:mm:ss"));
35       }
36     },
37     calledAt: DataTypes.DATE,
38     rejectedAt: {
39       type: DataTypes.DATE,
40       set: function(rejectedAt) {
41         this.setDataValue('rejectedAt', rejectedAt);
42         this.setDataValue('reason', 'rejected');
43       }
44     },
45     connectedAt: DataTypes.DATE
46   }, {
47     tableName: 'report_chat'
48   });
49
50   return ReportChat;
51 };