Built motion from commit b33b832.|1.0.17
[motion.git] / server / models / report_call.js
index a68ae14..4ae0ed0 100644 (file)
@@ -1 +1,62 @@
-var _0x978a=["\x65\x78\x70\x6F\x72\x74\x73","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x53\x54\x52\x49\x4E\x47","\x44\x41\x54\x45","","\x61\x6E\x73\x77\x65\x72\x74\x69\x6D\x65","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x49\x4E\x54\x45\x47\x45\x52","\x72\x65\x70\x6F\x72\x74\x5F\x63\x61\x6C\x6C","\x51\x75\x65\x75\x65\x43\x61\x6C\x6C\x73","\x75\x6E\x69\x71\x75\x65\x69\x64","\x68\x61\x73\x4D\x61\x6E\x79","\x52\x65\x70\x6F\x72\x74\x41\x67\x65\x6E\x74\x73","\x64\x65\x66\x69\x6E\x65"];module[_0x978a[0]]=function(_0x432fx1,_0x432fx2){var _0x432fx3=_0x432fx1[_0x978a[13]](_0x978a[1],{accountcode:_0x432fx2[_0x978a[2]],source:_0x432fx2[_0x978a[2]],destination:_0x432fx2[_0x978a[2]],destinationcontext:_0x432fx2[_0x978a[2]],callerid:_0x432fx2[_0x978a[2]],channel:_0x432fx2[_0x978a[2]],destinationchannel:_0x432fx2[_0x978a[2]],lastapplication:_0x432fx2[_0x978a[2]],lastdata:_0x432fx2[_0x978a[2]],starttime:_0x432fx2[_0x978a[3]],answertime:{type:_0x432fx2[_0x978a[3]],set:function(_0x432fx4){if(_0x432fx4!==_0x978a[4]){this[_0x978a[6]](_0x978a[5],_0x432fx4)}else {this[_0x978a[6]](_0x978a[5],null)}}},endtime:_0x432fx2[_0x978a[3]],duration:_0x432fx2[_0x978a[7]],billableseconds:_0x432fx2[_0x978a[7]],disposition:_0x432fx2[_0x978a[2]],amaflags:_0x432fx2[_0x978a[2]],uniqueid:{type:_0x432fx2[_0x978a[2]],primaryKey:true},userfield:_0x432fx2[_0x978a[2]]},{tableName:_0x978a[8],associate:function(_0x432fx5){_0x432fx3[_0x978a[11]](_0x432fx5.ReportQueue,{as:_0x978a[9],foreignKey:_0x978a[10],constraints:false});_0x432fx3[_0x978a[11]](_0x432fx5.ReportAgent,{as:_0x978a[12],foreignKey:_0x978a[10],constraints:false});}});return _0x432fx3;};
\ No newline at end of file
+/**
+ * CDR Model
+ */
+
+module.exports = function(sequelize, DataTypes) {
+
+  var ReportCall = sequelize.define('ReportCall', {
+    uniqueid: {
+      type: DataTypes.STRING,
+      unique: 'uniqueid'
+    },
+    type: {
+      type: DataTypes.ENUM,
+      values: ['inbound', 'internal', 'outbound', 'inbound-fax', 'outbound-fax', 'tigerdial', 'chanspy']
+    },
+    tag: DataTypes.STRING,
+    accountcode: DataTypes.STRING,
+    source: DataTypes.STRING,
+    destination: DataTypes.STRING,
+    destinationcontext: DataTypes.STRING,
+    callerid: DataTypes.STRING,
+    channel: DataTypes.STRING,
+    destinationchannel: DataTypes.STRING,
+    lastapplication: DataTypes.STRING,
+    lastdata: DataTypes.STRING,
+    starttime: DataTypes.DATE,
+    answertime: {
+      type: DataTypes.DATE,
+      // set: function(answertime) {
+      //   if (answertime !== '') {
+      //     this.setDataValue('answertime', answertime);
+      //   } else {
+      //     this.setDataValue('answertime', null);
+      //   }
+      // }
+    },
+    endtime: DataTypes.DATE,
+    duration: DataTypes.INTEGER,
+    billableseconds: DataTypes.INTEGER,
+    disposition: DataTypes.STRING,
+    amaflags: DataTypes.STRING,
+    userfield: DataTypes.STRING,
+    agentDisposition: DataTypes.STRING,
+    contactId: DataTypes.INTEGER
+  }, {
+    tableName: 'report_call',
+    associate: function(models) {
+      ReportCall.hasMany(models.ReportQueue, {
+        as: 'QueueCalls',
+        foreignKey: 'uniqueid',
+        constraints: false
+      })
+      ReportCall.hasMany(models.ReportAgent, {
+        as: 'ReportAgents',
+        foreignKey: 'uniqueid',
+        constraints: false
+      })
+    }
+  });
+
+  return ReportCall;
+};