d1411b2f5f79e512399a48f3e8d56d4edf5798c3
[motion.git] / server / models / history / report_call_history.js
1 /**
2  * CDR Model
3  */
4
5 module.exports = function(sequelize, DataTypes) {
6
7   var ReportCallHistory = sequelize.define('ReportCallHistory', {
8     uniqueid: {
9       type: DataTypes.STRING,
10       unique: true
11     },
12     type: {
13       type: DataTypes.ENUM,
14       values: ['inbound', 'internal', 'outbound', 'inbound-fax', 'outbound-fax', 'tigerdial']
15     },
16     tag: DataTypes.STRING,
17     accountcode: DataTypes.STRING,
18     source: DataTypes.STRING,
19     destination: DataTypes.STRING,
20     destinationcontext: DataTypes.STRING,
21     callerid: DataTypes.STRING,
22     channel: DataTypes.STRING,
23     destinationchannel: DataTypes.STRING,
24     lastapplication: DataTypes.STRING,
25     lastdata: DataTypes.STRING,
26     starttime: DataTypes.DATE,
27     answertime: {
28       type: DataTypes.DATE,
29       set: function(answertime) {
30         if (answertime !== '') {
31           this.setDataValue('answertime', answertime);
32         } else {
33           this.setDataValue('answertime', null);
34         }
35       }
36     },
37     endtime: DataTypes.DATE,
38     duration: DataTypes.INTEGER,
39     billableseconds: DataTypes.INTEGER,
40     disposition: DataTypes.STRING,
41     amaflags: DataTypes.STRING,
42     userfield: DataTypes.STRING
43   }, {
44     tableName: 'report_call_history',
45     associate: function(models) {
46       // ReportCallHistory.hasMany(models.ReportQueueHistory, {
47       //   as: 'HistoryQueueCalls',
48       //   foreignKey: 'uniqueid',
49       //   constraints: false
50       // });
51       // ReportCallHistory.hasMany(models.ReportAgentHistory, {
52       //   as: 'HistoryReportAgents',
53       //   foreignKey: 'uniqueid',
54       //   constraints: false
55       // });
56     }
57   });
58   ReportCallHistory.removeAttribute('id');
59   return ReportCallHistory;
60 };