Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
index 9d0d10f..0018c6f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf109=['limit','order','sort','where','pick','filter','merge','VIRTUAL','count','includeAll','include','findAll','then','rows','catch','params','options','find','describe','body','uniqueid','countContactsQueueCampaignHopperFinal','sequelize','COUNT','literal','noSuchContacts','`state`\x20=\x203,\x201,\x20null','busyContacts','`state`\x20=\x208,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','reCallContacts','`state`\x20=\x2019,\x201,\x20null','countContactsIvrCampaignHopperFinal','`state`\x20=\x200,\x201,\x20null','noAnswerContacts','congestionContacts','`state`\x20=\x2022,\x201,\x20null','moveContactsQueueCampaignHopperFinal','into','phone','scheduledAt','ContactId','ListId','VoiceQueueId','createdAt','updatedAt','field','ANY_VALUE(calleridnum)','NOW()','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','ANY_VALUE(VoiceQueueId)','from','cm_hopper_final','VoiceQueueId\x20=\x20?','toString','state\x20=\x20?','state','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','cm_hopper','select','calleridnum','state\x20=\x204','moveContactsIvrCampaignHopperFinal','Campaign','insert','fromQuery','CampaignId','CampaignId\x20=\x20?','group','checkContactHopper','CmHopper','findOne','html-pdf','eml-format','rimraf','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','status','end','offset','Content-Range','reject','save','update','destroy','sendStatus','error','stack','name','index','CmHopperFinal','rawAttributes','fieldName','type','key','map','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty'];(function(_0x5cfc87,_0x3efea7){var _0x3c19f2=function(_0x2f06ec){while(--_0x2f06ec){_0x5cfc87['push'](_0x5cfc87['shift']());}};_0x3c19f2(++_0x3efea7);}(_0xf109,0xce));var _0x9f10=function(_0x2b9b7f,_0x4d47df){_0x2b9b7f=_0x2b9b7f-0x0;var _0x4ed19a=_0xf109[_0x2b9b7f];return _0x4ed19a;};'use strict';var pdf=require(_0x9f10('0x0'));var emlformat=require(_0x9f10('0x1'));var rimraf=require(_0x9f10('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9f10('0x3'));var BPromise=require(_0x9f10('0x4'));var Mustache=require(_0x9f10('0x5'));var util=require(_0x9f10('0x6'));var path=require(_0x9f10('0x7'));var sox=require(_0x9f10('0x8'));var csv=require(_0x9f10('0x9'));var ejs=require(_0x9f10('0xa'));var fs=require('fs');var _=require(_0x9f10('0xb'));var squel=require(_0x9f10('0xc'));var crypto=require(_0x9f10('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x9f10('0xe'));var toCsv=require(_0x9f10('0x9'));var querystring=require(_0x9f10('0xf'));var Papa=require(_0x9f10('0x10'));var Redis=require(_0x9f10('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x9f10('0x12'));var as=require(_0x9f10('0x13'));var hardwareService=require(_0x9f10('0x14'));var logger=require('../../config/logger')('api');var utils=require(_0x9f10('0x15'));var config=require(_0x9f10('0x16'));var licenseUtil=require(_0x9f10('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x289164,_0x260606){_0x260606=_0x260606||0xcc;return function(_0x35c529){if(_0x35c529){return _0x289164['sendStatus'](_0x260606);}return _0x289164[_0x9f10('0x18')](_0x260606)[_0x9f10('0x19')]();};}function respondWithResult(_0x5be443,_0x40a48a){_0x40a48a=_0x40a48a||0xc8;return function(_0x236e28){if(_0x236e28){return _0x5be443['status'](_0x40a48a)['json'](_0x236e28);}};}function respondWithFilteredResult(_0x2b6c4c,_0x177918){return function(_0x549217){if(_0x549217){var _0x11154b=_0x549217['count'],_0x5ae255=_0x177918[_0x9f10('0x1a')],_0x14d3fe=_0x177918[_0x9f10('0x1a')]+_0x177918['limit'],_0x1f68d8;if(_0x14d3fe>=_0x11154b){_0x14d3fe=_0x11154b;_0x1f68d8=0xc8;}else{_0x1f68d8=0xce;}_0x2b6c4c[_0x9f10('0x18')](_0x1f68d8);return _0x2b6c4c['set'](_0x9f10('0x1b'),_0x5ae255+'-'+_0x14d3fe+'/'+_0x11154b)['json'](_0x549217);}return null;};}function patchUpdates(_0x2c5064){return function(_0x56fb44){try{jsonpatch['apply'](_0x56fb44,_0x2c5064,!![]);}catch(_0x3d216b){return BPromise[_0x9f10('0x1c')](_0x3d216b);}return _0x56fb44[_0x9f10('0x1d')]();};}function saveUpdates(_0x3a78be,_0xa810c){return function(_0x332575){if(_0x332575){return _0x332575[_0x9f10('0x1e')](_0x3a78be)['then'](function(_0x366044){return _0x366044;});}return null;};}function removeEntity(_0x58e6ba,_0x293990){return function(_0x36ace4){if(_0x36ace4){return _0x36ace4[_0x9f10('0x1f')]()['then'](function(){_0x58e6ba[_0x9f10('0x18')](0xcc)[_0x9f10('0x19')]();});}};}function handleEntityNotFound(_0x213567,_0x4d21c5){return function(_0x36821e){if(!_0x36821e){_0x213567[_0x9f10('0x20')](0x194);}return _0x36821e;};}function handleError(_0x44b99d,_0x4c531e){_0x4c531e=_0x4c531e||0x1f4;return function(_0x2ec07d){logger[_0x9f10('0x21')](_0x2ec07d[_0x9f10('0x22')]);if(_0x2ec07d[_0x9f10('0x23')]){delete _0x2ec07d['name'];}_0x44b99d['status'](_0x4c531e)['send'](_0x2ec07d);};}exports[_0x9f10('0x24')]=function(_0x4a0407,_0x314794){var _0x1de75a={},_0x45fffc={},_0x2ed95b={'count':0x0,'rows':[]};var _0x2e11b1=_['map'](db[_0x9f10('0x25')][_0x9f10('0x26')],function(_0x40f96b){return{'name':_0x40f96b[_0x9f10('0x27')],'type':_0x40f96b[_0x9f10('0x28')][_0x9f10('0x29')]};});_0x45fffc['model']=_[_0x9f10('0x2a')](_0x2e11b1,_0x9f10('0x23'));_0x45fffc[_0x9f10('0x2b')]=_[_0x9f10('0x2c')](_0x4a0407['query']);_0x45fffc[_0x9f10('0x2d')]=_[_0x9f10('0x2e')](_0x45fffc[_0x9f10('0x2f')],_0x45fffc['query']);_0x1de75a[_0x9f10('0x30')]=_['intersection'](_0x45fffc[_0x9f10('0x2f')],qs[_0x9f10('0x31')](_0x4a0407[_0x9f10('0x2b')]['fields']));_0x1de75a[_0x9f10('0x30')]=_0x1de75a[_0x9f10('0x30')][_0x9f10('0x32')]?_0x1de75a[_0x9f10('0x30')]:_0x45fffc[_0x9f10('0x2f')];if(!_0x4a0407['query'][_0x9f10('0x33')]('nolimit')){_0x1de75a[_0x9f10('0x34')]=qs[_0x9f10('0x34')](_0x4a0407[_0x9f10('0x2b')][_0x9f10('0x34')]);_0x1de75a[_0x9f10('0x1a')]=qs[_0x9f10('0x1a')](_0x4a0407['query'][_0x9f10('0x1a')]);}_0x1de75a[_0x9f10('0x35')]=qs[_0x9f10('0x36')](_0x4a0407['query'][_0x9f10('0x36')]);_0x1de75a[_0x9f10('0x37')]=qs['filters'](_[_0x9f10('0x38')](_0x4a0407['query'],_0x45fffc[_0x9f10('0x2d')]),_0x2e11b1);if(_0x4a0407[_0x9f10('0x2b')][_0x9f10('0x39')]){_0x1de75a[_0x9f10('0x37')]=_[_0x9f10('0x3a')](_0x1de75a[_0x9f10('0x37')],{'$or':_[_0x9f10('0x2a')](_0x2e11b1,function(_0x1db955){if(_0x1db955['type']!==_0x9f10('0x3b')){var _0x622030={};_0x622030[_0x1db955[_0x9f10('0x23')]]={'$like':'%'+_0x4a0407['query'][_0x9f10('0x39')]+'%'};return _0x622030;}})});}_0x1de75a=_[_0x9f10('0x3a')]({},_0x1de75a,_0x4a0407['options']);var _0x30b04b={'where':_0x1de75a[_0x9f10('0x37')]};return db[_0x9f10('0x25')]['count'](_0x30b04b)['then'](function(_0x2e4e2d){_0x2ed95b[_0x9f10('0x3c')]=_0x2e4e2d;if(_0x4a0407[_0x9f10('0x2b')][_0x9f10('0x3d')]){_0x1de75a[_0x9f10('0x3e')]=[{'all':!![]}];}return db[_0x9f10('0x25')][_0x9f10('0x3f')](_0x1de75a);})[_0x9f10('0x40')](function(_0x7fe320){_0x2ed95b[_0x9f10('0x41')]=_0x7fe320;return _0x2ed95b;})[_0x9f10('0x40')](respondWithFilteredResult(_0x314794,_0x1de75a))[_0x9f10('0x42')](handleError(_0x314794,null));};exports['show']=function(_0x5e3f06,_0x4bb805){var _0x24700a={'raw':!![],'where':{'id':_0x5e3f06[_0x9f10('0x43')]['id']}},_0x5c8c44={};_0x5c8c44[_0x9f10('0x2f')]=_[_0x9f10('0x2c')](db['CmHopperFinal'][_0x9f10('0x26')]);_0x5c8c44[_0x9f10('0x2b')]=_[_0x9f10('0x2c')](_0x5e3f06[_0x9f10('0x2b')]);_0x5c8c44[_0x9f10('0x2d')]=_['intersection'](_0x5c8c44['model'],_0x5c8c44['query']);_0x24700a[_0x9f10('0x30')]=_['intersection'](_0x5c8c44[_0x9f10('0x2f')],qs['fields'](_0x5e3f06[_0x9f10('0x2b')][_0x9f10('0x31')]));_0x24700a[_0x9f10('0x30')]=_0x24700a[_0x9f10('0x30')]['length']?_0x24700a[_0x9f10('0x30')]:_0x5c8c44[_0x9f10('0x2f')];if(_0x5e3f06['query'][_0x9f10('0x3d')]){_0x24700a[_0x9f10('0x3e')]=[{'all':!![]}];}_0x24700a=_[_0x9f10('0x3a')]({},_0x24700a,_0x5e3f06[_0x9f10('0x44')]);return db[_0x9f10('0x25')][_0x9f10('0x45')](_0x24700a)[_0x9f10('0x40')](handleEntityNotFound(_0x4bb805,null))[_0x9f10('0x40')](respondWithResult(_0x4bb805,null))[_0x9f10('0x42')](handleError(_0x4bb805,null));};exports[_0x9f10('0x46')]=function(_0x552588,_0x181eab){return db[_0x9f10('0x25')]['describe']()[_0x9f10('0x40')](respondWithResult(_0x181eab,null))[_0x9f10('0x42')](handleError(_0x181eab,null));};exports[_0x9f10('0x1e')]=function(_0x1807b3,_0x58b5b5){if(_0x1807b3[_0x9f10('0x47')][_0x9f10('0x48')]){delete _0x1807b3[_0x9f10('0x47')][_0x9f10('0x48')];}return db[_0x9f10('0x25')][_0x9f10('0x45')]({'where':{'uniqueid':_0x1807b3['params']['id']}})[_0x9f10('0x40')](handleEntityNotFound(_0x58b5b5,null))[_0x9f10('0x40')](saveUpdates(_0x1807b3[_0x9f10('0x47')],null))[_0x9f10('0x40')](respondWithResult(_0x58b5b5,null))[_0x9f10('0x42')](handleError(_0x58b5b5,null));};exports[_0x9f10('0x49')]=function(_0x52c069,_0x3ec147,_0x1bbf92){return db[_0x9f10('0x25')][_0x9f10('0x3f')]({'raw':![],'where':{'VoiceQueueId':_0x52c069[_0x9f10('0x43')]['id']},'attributes':[[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db['sequelize'][_0x9f10('0x4c')]('`state`\x20=\x200,\x201,\x20null'))),_0x9f10('0x4d')],[db['sequelize']['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x4e')))),'noAnswerContacts'],[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')]['literal']('`state`\x20=\x205,\x201,\x20null'))),_0x9f10('0x4f')],[db[_0x9f10('0x4a')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x50')))),'congestionContacts'],[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db['sequelize'][_0x9f10('0x4c')](_0x9f10('0x51')))),_0x9f10('0x52')],[db['sequelize']['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db['sequelize'][_0x9f10('0x4c')](_0x9f10('0x53')))),_0x9f10('0x54')],[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db['sequelize']['fn']('IF',db[_0x9f10('0x4a')]['literal']('`state`\x20=\x2022,\x201,\x20null'))),_0x9f10('0x55')],[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x56')))),'answeringMachine']]})['then'](handleEntityNotFound(_0x3ec147,null))[_0x9f10('0x40')](respondWithResult(_0x3ec147,null))[_0x9f10('0x42')](handleError(_0x3ec147,null));};exports[_0x9f10('0x57')]=function(_0x40f845,_0x2625ca,_0x2094c9){return db[_0x9f10('0x25')]['findAll']({'raw':![],'where':{'CampaignId':_0x40f845[_0x9f10('0x43')]['id']},'attributes':[[db[_0x9f10('0x4a')]['fn']('COUNT',db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')]['literal'](_0x9f10('0x58')))),_0x9f10('0x4d')],[db['sequelize']['fn'](_0x9f10('0x4b'),db['sequelize']['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x4e')))),_0x9f10('0x59')],[db[_0x9f10('0x4a')]['fn']('COUNT',db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')]('`state`\x20=\x205,\x201,\x20null'))),'busyContacts'],[db[_0x9f10('0x4a')]['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x50')))),_0x9f10('0x5a')],[db['sequelize']['fn'](_0x9f10('0x4b'),db[_0x9f10('0x4a')]['fn']('IF',db['sequelize'][_0x9f10('0x4c')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0x9f10('0x52')],[db[_0x9f10('0x4a')]['fn']('COUNT',db[_0x9f10('0x4a')]['fn']('IF',db['sequelize'][_0x9f10('0x4c')](_0x9f10('0x53')))),_0x9f10('0x54')],[db['sequelize']['fn'](_0x9f10('0x4b'),db['sequelize']['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x5b')))),'reCallContacts'],[db[_0x9f10('0x4a')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x9f10('0x4a')][_0x9f10('0x4c')](_0x9f10('0x56')))),'answeringMachine']]})[_0x9f10('0x40')](handleEntityNotFound(_0x2625ca,null))['then'](respondWithResult(_0x2625ca,null))['catch'](handleError(_0x2625ca,null));};exports[_0x9f10('0x5c')]=function(_0x551a5d,_0x4e7b27,_0x13a2cb){return db['VoiceQueue'][_0x9f10('0x45')]({'where':{'id':_0x551a5d[_0x9f10('0x43')]['id']}})[_0x9f10('0x40')](handleEntityNotFound(_0x4e7b27,null))['then'](function(_0x30b571){var _0x1cbcf3;if(_0x30b571){_0x1cbcf3=squel['insert']()[_0x9f10('0x5d')]('cm_hopper')['fromQuery']([_0x9f10('0x5e'),_0x9f10('0x5f'),_0x9f10('0x60'),_0x9f10('0x61'),_0x9f10('0x62'),_0x9f10('0x63'),_0x9f10('0x64')],squel['select']()[_0x9f10('0x65')](_0x9f10('0x66'),_0x9f10('0x5e'))[_0x9f10('0x65')](_0x9f10('0x67'),_0x9f10('0x5f'))[_0x9f10('0x65')](_0x9f10('0x68'),_0x9f10('0x60'))['field'](_0x9f10('0x69'),_0x9f10('0x61'))[_0x9f10('0x65')](_0x9f10('0x6a'),'VoiceQueueId')[_0x9f10('0x65')](_0x9f10('0x67'),_0x9f10('0x63'))[_0x9f10('0x65')]('NOW()','updatedAt')[_0x9f10('0x6b')](_0x9f10('0x6c'))[_0x9f10('0x37')](_0x9f10('0x6d'),_0x551a5d[_0x9f10('0x43')]['id'][_0x9f10('0x6e')]())[_0x9f10('0x37')](_0x9f10('0x6f'),_0x551a5d[_0x9f10('0x47')][_0x9f10('0x70')][_0x9f10('0x6e')]())[_0x9f10('0x37')](_0x9f10('0x71'))[_0x9f10('0x37')](_0x9f10('0x72'),squel['select']()[_0x9f10('0x65')](_0x9f10('0x5e'))['from'](_0x9f10('0x73'))[_0x9f10('0x37')](_0x9f10('0x6d'),_0x551a5d[_0x9f10('0x43')]['id']['toString']()))[_0x9f10('0x37')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x9f10('0x74')]()[_0x9f10('0x65')](_0x9f10('0x75'))['from'](_0x9f10('0x6c'))[_0x9f10('0x37')](_0x9f10('0x6d'),_0x551a5d['params']['id'][_0x9f10('0x6e')]())[_0x9f10('0x37')](_0x9f10('0x76')))['group']('ContactId'))['toString']();return db['sequelize']['query'](_0x1cbcf3);}return[];})['then'](respondWithResult(_0x4e7b27,null))['catch'](handleError(_0x4e7b27,null));};exports[_0x9f10('0x77')]=function(_0x2571a6,_0x4dc5d5,_0xa0988b){return db[_0x9f10('0x78')][_0x9f10('0x45')]({'where':{'id':_0x2571a6[_0x9f10('0x43')]['id']}})[_0x9f10('0x40')](handleEntityNotFound(_0x4dc5d5,null))[_0x9f10('0x40')](function(_0x45ebcc){var _0x27a67c;if(_0x45ebcc){_0x27a67c=squel[_0x9f10('0x79')]()[_0x9f10('0x5d')]('cm_hopper')[_0x9f10('0x7a')]([_0x9f10('0x5e'),'scheduledAt',_0x9f10('0x60'),'ListId','CampaignId',_0x9f10('0x63'),_0x9f10('0x64')],squel['select']()[_0x9f10('0x65')](_0x9f10('0x66'),'phone')[_0x9f10('0x65')](_0x9f10('0x67'),_0x9f10('0x5f'))['field'](_0x9f10('0x68'),_0x9f10('0x60'))['field']('ANY_VALUE(ListId)',_0x9f10('0x61'))[_0x9f10('0x65')]('ANY_VALUE(CampaignId)',_0x9f10('0x7b'))[_0x9f10('0x65')]('NOW()','createdAt')[_0x9f10('0x65')](_0x9f10('0x67'),'updatedAt')['from'](_0x9f10('0x6c'))[_0x9f10('0x37')]('CampaignId\x20=\x20?',_0x2571a6[_0x9f10('0x43')]['id'][_0x9f10('0x6e')]())[_0x9f10('0x37')](_0x9f10('0x6f'),_0x2571a6[_0x9f10('0x47')]['state']['toString']())['where'](_0x9f10('0x71'))[_0x9f10('0x37')](_0x9f10('0x72'),squel['select']()[_0x9f10('0x65')]('phone')[_0x9f10('0x6b')]('cm_hopper')['where']('CampaignId\x20=\x20?',_0x2571a6[_0x9f10('0x43')]['id'][_0x9f10('0x6e')]()))[_0x9f10('0x37')](_0x9f10('0x72'),squel[_0x9f10('0x74')]()[_0x9f10('0x65')](_0x9f10('0x75'))[_0x9f10('0x6b')]('cm_hopper_final')[_0x9f10('0x37')](_0x9f10('0x7c'),_0x2571a6[_0x9f10('0x43')]['id']['toString']())[_0x9f10('0x37')](_0x9f10('0x76')))[_0x9f10('0x7d')](_0x9f10('0x60')))[_0x9f10('0x6e')]();return db['sequelize'][_0x9f10('0x2b')](_0x27a67c);}return[];})['then'](respondWithResult(_0x4dc5d5,null))[_0x9f10('0x42')](handleError(_0x4dc5d5,null));};exports[_0x9f10('0x7e')]=function(_0x559701,_0x25698c,_0x331330){return db[_0x9f10('0x7f')][_0x9f10('0x80')]({'where':{'VoiceQueueId':_0x559701['body'][_0x9f10('0x62')],'CampaignId':_0x559701['body'][_0x9f10('0x7b')],'ContactId':_0x559701[_0x9f10('0x47')]['ContactId']}})['then'](handleEntityNotFound(_0x25698c,null))[_0x9f10('0x40')](function(_0x52f70c){if(_0x52f70c){return _0x52f70c;}return null;})['then'](respondWithResult(_0x25698c,null))['catch'](handleError(_0x25698c,null));};
\ No newline at end of file
+var _0xb43b=['includeAll','include','findAll','rows','catch','show','params','find','describe','body','uniqueid','countContactsQueueCampaignHopperFinal','sequelize','COUNT','literal','`state`\x20=\x200,\x201,\x20null','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','`state`\x20=\x205,\x201,\x20null','`state`\x20=\x208,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','`state`\x20=\x2022,\x201,\x20null','`state`\x20=\x2019,\x201,\x20null','answeringMachine','noSuchContacts','busyContacts','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','reCallContacts','moveContactsQueueCampaignHopperFinal','VoiceQueue','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','ListId','VoiceQueueId','createdAt','updatedAt','select','field','ANY_VALUE(calleridnum)','NOW()','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','from','cm_hopper_final','toString','state\x20=\x20?','calleridnum\x20NOT\x20IN\x20(?)','calleridnum','VoiceQueueId\x20=\x20?','state\x20=\x204','group','moveContactsIvrCampaignHopperFinal','Campaign','CampaignId','ANY_VALUE(CampaignId)','calleridnum\x20IS\x20NOT\x20NULL','CampaignId\x20=\x20?','CmHopper','findOne','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','status','end','json','count','offset','limit','Content-Range','apply','save','update','then','destroy','name','index','map','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','VIRTUAL','options','CmHopperFinal'];(function(_0x32e54a,_0x59fc0d){var _0x109af4=function(_0x564be8){while(--_0x564be8){_0x32e54a['push'](_0x32e54a['shift']());}};_0x109af4(++_0x59fc0d);}(_0xb43b,0xbf));var _0xbb43=function(_0x276eaf,_0x541331){_0x276eaf=_0x276eaf-0x0;var _0x161262=_0xb43b[_0x276eaf];return _0x161262;};'use strict';var pdf=require(_0xbb43('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xbb43('0x1'));var zipdir=require(_0xbb43('0x2'));var jsonpatch=require(_0xbb43('0x3'));var rp=require(_0xbb43('0x4'));var moment=require(_0xbb43('0x5'));var BPromise=require(_0xbb43('0x6'));var Mustache=require(_0xbb43('0x7'));var util=require(_0xbb43('0x8'));var path=require(_0xbb43('0x9'));var sox=require(_0xbb43('0xa'));var csv=require(_0xbb43('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xbb43('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbb43('0xd'));var deskjs=require(_0xbb43('0xe'));var toCsv=require(_0xbb43('0xb'));var querystring=require(_0xbb43('0xf'));var Papa=require(_0xbb43('0x10'));var Redis=require('ioredis');var authService=require(_0xbb43('0x11'));var qs=require(_0xbb43('0x12'));var as=require(_0xbb43('0x13'));var hardwareService=require(_0xbb43('0x14'));var logger=require('../../config/logger')(_0xbb43('0x15'));var utils=require(_0xbb43('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2867fb,_0x5d0ccc){_0x5d0ccc=_0x5d0ccc||0xcc;return function(_0x6be368){if(_0x6be368){return _0x2867fb['sendStatus'](_0x5d0ccc);}return _0x2867fb[_0xbb43('0x17')](_0x5d0ccc)[_0xbb43('0x18')]();};}function respondWithResult(_0x3ce968,_0x3327bc){_0x3327bc=_0x3327bc||0xc8;return function(_0x2e2517){if(_0x2e2517){return _0x3ce968['status'](_0x3327bc)[_0xbb43('0x19')](_0x2e2517);}};}function respondWithFilteredResult(_0x4ac25c,_0x199726){return function(_0x32425c){if(_0x32425c){var _0x15182b=_0x32425c[_0xbb43('0x1a')],_0x10c91b=_0x199726[_0xbb43('0x1b')],_0x3be44b=_0x199726[_0xbb43('0x1b')]+_0x199726[_0xbb43('0x1c')],_0x126f61;if(_0x3be44b>=_0x15182b){_0x3be44b=_0x15182b;_0x126f61=0xc8;}else{_0x126f61=0xce;}_0x4ac25c[_0xbb43('0x17')](_0x126f61);return _0x4ac25c['set'](_0xbb43('0x1d'),_0x10c91b+'-'+_0x3be44b+'/'+_0x15182b)['json'](_0x32425c);}return null;};}function patchUpdates(_0x44fd04){return function(_0x5f4b4f){try{jsonpatch[_0xbb43('0x1e')](_0x5f4b4f,_0x44fd04,!![]);}catch(_0x27579a){return BPromise['reject'](_0x27579a);}return _0x5f4b4f[_0xbb43('0x1f')]();};}function saveUpdates(_0x6cdc26,_0x398ce5){return function(_0x6f34d6){if(_0x6f34d6){return _0x6f34d6[_0xbb43('0x20')](_0x6cdc26)[_0xbb43('0x21')](function(_0xee1084){return _0xee1084;});}return null;};}function removeEntity(_0x1e83cd,_0x3409d0){return function(_0x3cb6d1){if(_0x3cb6d1){return _0x3cb6d1[_0xbb43('0x22')]()[_0xbb43('0x21')](function(){_0x1e83cd[_0xbb43('0x17')](0xcc)[_0xbb43('0x18')]();});}};}function handleEntityNotFound(_0x500af4,_0x28b3e4){return function(_0x326864){if(!_0x326864){_0x500af4['sendStatus'](0x194);}return _0x326864;};}function handleError(_0x464b4a,_0x2b07d8){_0x2b07d8=_0x2b07d8||0x1f4;return function(_0x25279b){logger['error'](_0x25279b['stack']);if(_0x25279b[_0xbb43('0x23')]){delete _0x25279b[_0xbb43('0x23')];}_0x464b4a['status'](_0x2b07d8)['send'](_0x25279b);};}exports[_0xbb43('0x24')]=function(_0xb9fe3b,_0x268fb5){var _0x4bb859={},_0x27bb65={},_0x426cec={'count':0x0,'rows':[]};var _0x2dcc60=_[_0xbb43('0x25')](db['CmHopperFinal'][_0xbb43('0x26')],function(_0x170e7a){return{'name':_0x170e7a[_0xbb43('0x27')],'type':_0x170e7a[_0xbb43('0x28')][_0xbb43('0x29')]};});_0x27bb65[_0xbb43('0x2a')]=_[_0xbb43('0x25')](_0x2dcc60,'name');_0x27bb65[_0xbb43('0x2b')]=_[_0xbb43('0x2c')](_0xb9fe3b[_0xbb43('0x2b')]);_0x27bb65['filters']=_[_0xbb43('0x2d')](_0x27bb65[_0xbb43('0x2a')],_0x27bb65[_0xbb43('0x2b')]);_0x4bb859[_0xbb43('0x2e')]=_[_0xbb43('0x2d')](_0x27bb65[_0xbb43('0x2a')],qs[_0xbb43('0x2f')](_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x2f')]));_0x4bb859['attributes']=_0x4bb859['attributes']['length']?_0x4bb859['attributes']:_0x27bb65[_0xbb43('0x2a')];if(!_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x30')](_0xbb43('0x31'))){_0x4bb859[_0xbb43('0x1c')]=qs[_0xbb43('0x1c')](_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x1c')]);_0x4bb859['offset']=qs[_0xbb43('0x1b')](_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x1b')]);}_0x4bb859[_0xbb43('0x32')]=qs['sort'](_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x33')]);_0x4bb859[_0xbb43('0x34')]=qs[_0xbb43('0x35')](_['pick'](_0xb9fe3b[_0xbb43('0x2b')],_0x27bb65['filters']),_0x2dcc60);if(_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x36')]){_0x4bb859[_0xbb43('0x34')]=_[_0xbb43('0x37')](_0x4bb859[_0xbb43('0x34')],{'$or':_[_0xbb43('0x25')](_0x2dcc60,function(_0x316ab1){if(_0x316ab1[_0xbb43('0x28')]!==_0xbb43('0x38')){var _0xa48590={};_0xa48590[_0x316ab1[_0xbb43('0x23')]]={'$like':'%'+_0xb9fe3b[_0xbb43('0x2b')]['filter']+'%'};return _0xa48590;}})});}_0x4bb859=_[_0xbb43('0x37')]({},_0x4bb859,_0xb9fe3b[_0xbb43('0x39')]);var _0x363e1a={'where':_0x4bb859[_0xbb43('0x34')]};return db[_0xbb43('0x3a')][_0xbb43('0x1a')](_0x363e1a)[_0xbb43('0x21')](function(_0x3d7d56){_0x426cec[_0xbb43('0x1a')]=_0x3d7d56;if(_0xb9fe3b[_0xbb43('0x2b')][_0xbb43('0x3b')]){_0x4bb859[_0xbb43('0x3c')]=[{'all':!![]}];}return db[_0xbb43('0x3a')][_0xbb43('0x3d')](_0x4bb859);})[_0xbb43('0x21')](function(_0x4a76a8){_0x426cec[_0xbb43('0x3e')]=_0x4a76a8;return _0x426cec;})[_0xbb43('0x21')](respondWithFilteredResult(_0x268fb5,_0x4bb859))[_0xbb43('0x3f')](handleError(_0x268fb5,null));};exports[_0xbb43('0x40')]=function(_0x60a465,_0x4b32c9){var _0x5e942e={'raw':!![],'where':{'id':_0x60a465[_0xbb43('0x41')]['id']}},_0x13e9f7={};_0x13e9f7['model']=_['keys'](db[_0xbb43('0x3a')][_0xbb43('0x26')]);_0x13e9f7[_0xbb43('0x2b')]=_[_0xbb43('0x2c')](_0x60a465[_0xbb43('0x2b')]);_0x13e9f7['filters']=_['intersection'](_0x13e9f7[_0xbb43('0x2a')],_0x13e9f7[_0xbb43('0x2b')]);_0x5e942e[_0xbb43('0x2e')]=_[_0xbb43('0x2d')](_0x13e9f7[_0xbb43('0x2a')],qs[_0xbb43('0x2f')](_0x60a465[_0xbb43('0x2b')][_0xbb43('0x2f')]));_0x5e942e[_0xbb43('0x2e')]=_0x5e942e[_0xbb43('0x2e')]['length']?_0x5e942e['attributes']:_0x13e9f7[_0xbb43('0x2a')];if(_0x60a465[_0xbb43('0x2b')]['includeAll']){_0x5e942e[_0xbb43('0x3c')]=[{'all':!![]}];}_0x5e942e=_[_0xbb43('0x37')]({},_0x5e942e,_0x60a465[_0xbb43('0x39')]);return db[_0xbb43('0x3a')][_0xbb43('0x42')](_0x5e942e)[_0xbb43('0x21')](handleEntityNotFound(_0x4b32c9,null))[_0xbb43('0x21')](respondWithResult(_0x4b32c9,null))['catch'](handleError(_0x4b32c9,null));};exports[_0xbb43('0x43')]=function(_0x229928,_0x5970cc){return db[_0xbb43('0x3a')][_0xbb43('0x43')]()['then'](respondWithResult(_0x5970cc,null))[_0xbb43('0x3f')](handleError(_0x5970cc,null));};exports[_0xbb43('0x20')]=function(_0xd1f32b,_0x15fab6){if(_0xd1f32b[_0xbb43('0x44')][_0xbb43('0x45')]){delete _0xd1f32b[_0xbb43('0x44')][_0xbb43('0x45')];}return db[_0xbb43('0x3a')][_0xbb43('0x42')]({'where':{'uniqueid':_0xd1f32b[_0xbb43('0x41')]['id']}})[_0xbb43('0x21')](handleEntityNotFound(_0x15fab6,null))['then'](saveUpdates(_0xd1f32b[_0xbb43('0x44')],null))[_0xbb43('0x21')](respondWithResult(_0x15fab6,null))[_0xbb43('0x3f')](handleError(_0x15fab6,null));};exports[_0xbb43('0x46')]=function(_0x4ab63b,_0x33d21b,_0x4998fb){return db[_0xbb43('0x3a')]['findAll']({'raw':![],'where':{'VoiceQueueId':_0x4ab63b[_0xbb43('0x41')]['id']},'attributes':[[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db['sequelize']['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x4a')))),'noSuchContacts'],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db['sequelize']['fn']('IF',db[_0xbb43('0x47')]['literal'](_0xbb43('0x4b')))),_0xbb43('0x4c')],[db['sequelize']['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')]['literal'](_0xbb43('0x4d')))),'busyContacts'],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db['sequelize'][_0xbb43('0x49')](_0xbb43('0x4e')))),'congestionContacts'],[db['sequelize']['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db['sequelize']['literal'](_0xbb43('0x4f')))),'dropContacts'],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x2011\x20,\x201,\x20null'))),'abandonedContacts'],[db['sequelize']['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x50')))),'reCallContacts'],[db[_0xbb43('0x47')]['fn']('COUNT',db[_0xbb43('0x47')]['fn']('IF',db['sequelize'][_0xbb43('0x49')](_0xbb43('0x51')))),_0xbb43('0x52')]]})[_0xbb43('0x21')](handleEntityNotFound(_0x33d21b,null))['then'](respondWithResult(_0x33d21b,null))[_0xbb43('0x3f')](handleError(_0x33d21b,null));};exports['countContactsIvrCampaignHopperFinal']=function(_0x3f3292,_0x213747,_0x512619){return db[_0xbb43('0x3a')][_0xbb43('0x3d')]({'raw':![],'where':{'CampaignId':_0x3f3292['params']['id']},'attributes':[[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x4a')))),_0xbb43('0x53')],[db[_0xbb43('0x47')]['fn']('COUNT',db[_0xbb43('0x47')]['fn']('IF',db['sequelize'][_0xbb43('0x49')](_0xbb43('0x4b')))),'noAnswerContacts'],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x4d')))),_0xbb43('0x54')],[db[_0xbb43('0x47')]['fn']('COUNT',db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x4e')))),'congestionContacts'],[db[_0xbb43('0x47')]['fn']('COUNT',db[_0xbb43('0x47')]['fn']('IF',db['sequelize'][_0xbb43('0x49')](_0xbb43('0x4f')))),_0xbb43('0x55')],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x56')))),_0xbb43('0x57')],[db['sequelize']['fn'](_0xbb43('0x48'),db['sequelize']['fn']('IF',db[_0xbb43('0x47')][_0xbb43('0x49')](_0xbb43('0x50')))),_0xbb43('0x58')],[db[_0xbb43('0x47')]['fn'](_0xbb43('0x48'),db[_0xbb43('0x47')]['fn']('IF',db[_0xbb43('0x47')]['literal'](_0xbb43('0x51')))),'answeringMachine']]})['then'](handleEntityNotFound(_0x213747,null))[_0xbb43('0x21')](respondWithResult(_0x213747,null))['catch'](handleError(_0x213747,null));};exports[_0xbb43('0x59')]=function(_0x212dc9,_0x4eb58f,_0x221727){return db[_0xbb43('0x5a')]['find']({'where':{'id':_0x212dc9[_0xbb43('0x41')]['id']}})[_0xbb43('0x21')](handleEntityNotFound(_0x4eb58f,null))[_0xbb43('0x21')](function(_0x14678c){var _0x40ac8c;if(_0x14678c){_0x40ac8c=squel[_0xbb43('0x5b')]()[_0xbb43('0x5c')](_0xbb43('0x5d'))[_0xbb43('0x5e')]([_0xbb43('0x5f'),_0xbb43('0x60'),_0xbb43('0x61'),_0xbb43('0x62'),_0xbb43('0x63'),_0xbb43('0x64'),_0xbb43('0x65')],squel[_0xbb43('0x66')]()[_0xbb43('0x67')](_0xbb43('0x68'),_0xbb43('0x5f'))[_0xbb43('0x67')](_0xbb43('0x69'),_0xbb43('0x60'))[_0xbb43('0x67')](_0xbb43('0x6a'),_0xbb43('0x61'))[_0xbb43('0x67')](_0xbb43('0x6b'),_0xbb43('0x62'))[_0xbb43('0x67')]('ANY_VALUE(VoiceQueueId)',_0xbb43('0x63'))[_0xbb43('0x67')](_0xbb43('0x69'),_0xbb43('0x64'))[_0xbb43('0x67')](_0xbb43('0x69'),'updatedAt')[_0xbb43('0x6c')](_0xbb43('0x6d'))['where']('VoiceQueueId\x20=\x20?',_0x212dc9['params']['id'][_0xbb43('0x6e')]())[_0xbb43('0x34')](_0xbb43('0x6f'),_0x212dc9[_0xbb43('0x44')]['state']['toString']())[_0xbb43('0x34')]('calleridnum\x20IS\x20NOT\x20NULL')[_0xbb43('0x34')](_0xbb43('0x70'),squel['select']()[_0xbb43('0x67')](_0xbb43('0x5f'))[_0xbb43('0x6c')]('cm_hopper')[_0xbb43('0x34')]('VoiceQueueId\x20=\x20?',_0x212dc9[_0xbb43('0x41')]['id'][_0xbb43('0x6e')]()))['where'](_0xbb43('0x70'),squel[_0xbb43('0x66')]()[_0xbb43('0x67')](_0xbb43('0x71'))[_0xbb43('0x6c')]('cm_hopper_final')['where'](_0xbb43('0x72'),_0x212dc9[_0xbb43('0x41')]['id'][_0xbb43('0x6e')]())[_0xbb43('0x34')](_0xbb43('0x73')))[_0xbb43('0x74')](_0xbb43('0x61')))[_0xbb43('0x6e')]();return db['sequelize'][_0xbb43('0x2b')](_0x40ac8c);}return[];})['then'](respondWithResult(_0x4eb58f,null))[_0xbb43('0x3f')](handleError(_0x4eb58f,null));};exports[_0xbb43('0x75')]=function(_0x4cee24,_0x371a7c,_0x1ba677){return db[_0xbb43('0x76')][_0xbb43('0x42')]({'where':{'id':_0x4cee24[_0xbb43('0x41')]['id']}})[_0xbb43('0x21')](handleEntityNotFound(_0x371a7c,null))['then'](function(_0x3d0182){var _0x2d18e7;if(_0x3d0182){_0x2d18e7=squel['insert']()[_0xbb43('0x5c')]('cm_hopper')[_0xbb43('0x5e')]([_0xbb43('0x5f'),_0xbb43('0x60'),_0xbb43('0x61'),_0xbb43('0x62'),_0xbb43('0x77'),_0xbb43('0x64'),_0xbb43('0x65')],squel[_0xbb43('0x66')]()[_0xbb43('0x67')](_0xbb43('0x68'),'phone')[_0xbb43('0x67')]('NOW()',_0xbb43('0x60'))[_0xbb43('0x67')](_0xbb43('0x6a'),_0xbb43('0x61'))[_0xbb43('0x67')]('ANY_VALUE(ListId)',_0xbb43('0x62'))[_0xbb43('0x67')](_0xbb43('0x78'),_0xbb43('0x77'))[_0xbb43('0x67')]('NOW()',_0xbb43('0x64'))['field'](_0xbb43('0x69'),_0xbb43('0x65'))[_0xbb43('0x6c')](_0xbb43('0x6d'))[_0xbb43('0x34')]('CampaignId\x20=\x20?',_0x4cee24[_0xbb43('0x41')]['id']['toString']())[_0xbb43('0x34')]('state\x20=\x20?',_0x4cee24[_0xbb43('0x44')]['state'][_0xbb43('0x6e')]())[_0xbb43('0x34')](_0xbb43('0x79'))['where'](_0xbb43('0x70'),squel['select']()[_0xbb43('0x67')](_0xbb43('0x5f'))['from'](_0xbb43('0x5d'))[_0xbb43('0x34')](_0xbb43('0x7a'),_0x4cee24[_0xbb43('0x41')]['id']['toString']()))[_0xbb43('0x34')](_0xbb43('0x70'),squel['select']()['field']('calleridnum')[_0xbb43('0x6c')]('cm_hopper_final')[_0xbb43('0x34')](_0xbb43('0x7a'),_0x4cee24[_0xbb43('0x41')]['id']['toString']())['where'](_0xbb43('0x73')))[_0xbb43('0x74')](_0xbb43('0x61')))[_0xbb43('0x6e')]();return db['sequelize'][_0xbb43('0x2b')](_0x2d18e7);}return[];})[_0xbb43('0x21')](respondWithResult(_0x371a7c,null))[_0xbb43('0x3f')](handleError(_0x371a7c,null));};exports['checkContactHopper']=function(_0x202f08,_0xc9623,_0x75999e){return db[_0xbb43('0x7b')][_0xbb43('0x7c')]({'where':{'VoiceQueueId':_0x202f08['body'][_0xbb43('0x63')],'CampaignId':_0x202f08['body'][_0xbb43('0x77')],'ContactId':_0x202f08[_0xbb43('0x44')][_0xbb43('0x61')]}})[_0xbb43('0x21')](handleEntityNotFound(_0xc9623,null))['then'](function(_0x3174ea){if(_0x3174ea){return _0x3174ea;}return null;})['then'](respondWithResult(_0xc9623,null))[_0xbb43('0x3f')](handleError(_0xc9623,null));};
\ No newline at end of file