Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / voiceTransferReport / voiceTransferReport.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xbf38=['../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','count','offset','limit','Content-Range','apply','destroy','then','end','error','stack','name','send','index','VoiceTransferReport','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filter','VIRTUAL','options','include','rows','catch','show','params','rawAttributes','includeAll','merge','create','body','update','find','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x1eb9a2,_0x1b8f63){var _0x5aa1ee=function(_0x3b39bc){while(--_0x3b39bc){_0x1eb9a2['push'](_0x1eb9a2['shift']());}};_0x5aa1ee(++_0x1b8f63);}(_0xbf38,0x118));var _0x8bf3=function(_0x7a8ee9,_0x39028f){_0x7a8ee9=_0x7a8ee9-0x0;var _0x30e5a7=_0xbf38[_0x7a8ee9];return _0x30e5a7;};'use strict';var pdf=require(_0x8bf3('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x8bf3('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8bf3('0x2'));var rp=require(_0x8bf3('0x3'));var moment=require(_0x8bf3('0x4'));var BPromise=require(_0x8bf3('0x5'));var Mustache=require(_0x8bf3('0x6'));var util=require(_0x8bf3('0x7'));var path=require('path');var sox=require(_0x8bf3('0x8'));var csv=require(_0x8bf3('0x9'));var ejs=require(_0x8bf3('0xa'));var fs=require('fs');var _=require(_0x8bf3('0xb'));var squel=require(_0x8bf3('0xc'));var crypto=require(_0x8bf3('0xd'));var jsforce=require(_0x8bf3('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x8bf3('0x9'));var querystring=require(_0x8bf3('0xf'));var Papa=require(_0x8bf3('0x10'));var Redis=require(_0x8bf3('0x11'));var authService=require(_0x8bf3('0x12'));var qs=require(_0x8bf3('0x13'));var as=require(_0x8bf3('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8bf3('0x15'))(_0x8bf3('0x16'));var utils=require(_0x8bf3('0x17'));var config=require(_0x8bf3('0x18'));var licenseUtil=require(_0x8bf3('0x19'));var db=require(_0x8bf3('0x1a'))['db'];function respondWithStatusCode(_0x2f3e48,_0x30831c){_0x30831c=_0x30831c||0xcc;return function(_0x41cdda){if(_0x41cdda){return _0x2f3e48[_0x8bf3('0x1b')](_0x30831c);}return _0x2f3e48[_0x8bf3('0x1c')](_0x30831c)['end']();};}function respondWithResult(_0x338165,_0x264168){_0x264168=_0x264168||0xc8;return function(_0x4acc62){if(_0x4acc62){return _0x338165[_0x8bf3('0x1c')](_0x264168)[_0x8bf3('0x1d')](_0x4acc62);}};}function respondWithFilteredResult(_0x533c8d,_0x2ec636){return function(_0x38776b){if(_0x38776b){var _0x1ca69e=_0x38776b[_0x8bf3('0x1e')],_0x9ea987=_0x2ec636[_0x8bf3('0x1f')],_0x5b6fa2=_0x2ec636[_0x8bf3('0x1f')]+_0x2ec636[_0x8bf3('0x20')],_0x5d721a;if(_0x5b6fa2>=_0x1ca69e){_0x5b6fa2=_0x1ca69e;_0x5d721a=0xc8;}else{_0x5d721a=0xce;}_0x533c8d[_0x8bf3('0x1c')](_0x5d721a);return _0x533c8d['set'](_0x8bf3('0x21'),_0x9ea987+'-'+_0x5b6fa2+'/'+_0x1ca69e)[_0x8bf3('0x1d')](_0x38776b);}return null;};}function patchUpdates(_0x2f4e15){return function(_0x4398fa){try{jsonpatch[_0x8bf3('0x22')](_0x4398fa,_0x2f4e15,!![]);}catch(_0x4bb453){return BPromise['reject'](_0x4bb453);}return _0x4398fa['save']();};}function saveUpdates(_0xfe755f,_0x3f0687){return function(_0x2f301e){if(_0x2f301e){return _0x2f301e['update'](_0xfe755f)['then'](function(_0x4c9567){return _0x4c9567;});}return null;};}function removeEntity(_0x4ce9af,_0x3a7f16){return function(_0x3ec4fd){if(_0x3ec4fd){return _0x3ec4fd[_0x8bf3('0x23')]()[_0x8bf3('0x24')](function(){_0x4ce9af[_0x8bf3('0x1c')](0xcc)[_0x8bf3('0x25')]();});}};}function handleEntityNotFound(_0x2699b8,_0x291c1d){return function(_0x3ac8d6){if(!_0x3ac8d6){_0x2699b8[_0x8bf3('0x1b')](0x194);}return _0x3ac8d6;};}function handleError(_0x2ca912,_0x132acf){_0x132acf=_0x132acf||0x1f4;return function(_0x437792){logger[_0x8bf3('0x26')](_0x437792[_0x8bf3('0x27')]);if(_0x437792[_0x8bf3('0x28')]){delete _0x437792[_0x8bf3('0x28')];}_0x2ca912[_0x8bf3('0x1c')](_0x132acf)[_0x8bf3('0x29')](_0x437792);};}exports[_0x8bf3('0x2a')]=function(_0x257c77,_0x21336a){var _0x5988d1={},_0x217bc3={},_0xcf9f4b={'count':0x0,'rows':[]};var _0x42d3f8=_['map'](db[_0x8bf3('0x2b')]['rawAttributes'],function(_0x55cd84){return{'name':_0x55cd84[_0x8bf3('0x2c')],'type':_0x55cd84[_0x8bf3('0x2d')][_0x8bf3('0x2e')]};});_0x217bc3[_0x8bf3('0x2f')]=_[_0x8bf3('0x30')](_0x42d3f8,_0x8bf3('0x28'));_0x217bc3[_0x8bf3('0x31')]=_[_0x8bf3('0x32')](_0x257c77[_0x8bf3('0x31')]);_0x217bc3[_0x8bf3('0x33')]=_[_0x8bf3('0x34')](_0x217bc3[_0x8bf3('0x2f')],_0x217bc3[_0x8bf3('0x31')]);_0x5988d1[_0x8bf3('0x35')]=_[_0x8bf3('0x34')](_0x217bc3['model'],qs['fields'](_0x257c77[_0x8bf3('0x31')][_0x8bf3('0x36')]));_0x5988d1['attributes']=_0x5988d1[_0x8bf3('0x35')][_0x8bf3('0x37')]?_0x5988d1[_0x8bf3('0x35')]:_0x217bc3[_0x8bf3('0x2f')];if(!_0x257c77[_0x8bf3('0x31')][_0x8bf3('0x38')]('nolimit')){_0x5988d1[_0x8bf3('0x20')]=qs[_0x8bf3('0x20')](_0x257c77[_0x8bf3('0x31')][_0x8bf3('0x20')]);_0x5988d1['offset']=qs['offset'](_0x257c77[_0x8bf3('0x31')][_0x8bf3('0x1f')]);}_0x5988d1[_0x8bf3('0x39')]=qs[_0x8bf3('0x3a')](_0x257c77[_0x8bf3('0x31')]['sort']);_0x5988d1[_0x8bf3('0x3b')]=qs[_0x8bf3('0x33')](_['pick'](_0x257c77[_0x8bf3('0x31')],_0x217bc3[_0x8bf3('0x33')]),_0x42d3f8);if(_0x257c77[_0x8bf3('0x31')][_0x8bf3('0x3c')]){_0x5988d1[_0x8bf3('0x3b')]=_['merge'](_0x5988d1[_0x8bf3('0x3b')],{'$or':_[_0x8bf3('0x30')](_0x42d3f8,function(_0x442791){if(_0x442791[_0x8bf3('0x2d')]!==_0x8bf3('0x3d')){var _0xfe395a={};_0xfe395a[_0x442791[_0x8bf3('0x28')]]={'$like':'%'+_0x257c77['query'][_0x8bf3('0x3c')]+'%'};return _0xfe395a;}})});}_0x5988d1=_['merge']({},_0x5988d1,_0x257c77[_0x8bf3('0x3e')]);var _0x39c39c={'where':_0x5988d1[_0x8bf3('0x3b')]};return db[_0x8bf3('0x2b')][_0x8bf3('0x1e')](_0x39c39c)[_0x8bf3('0x24')](function(_0x5c43f7){_0xcf9f4b[_0x8bf3('0x1e')]=_0x5c43f7;if(_0x257c77[_0x8bf3('0x31')]['includeAll']){_0x5988d1[_0x8bf3('0x3f')]=[{'all':!![]}];}return db[_0x8bf3('0x2b')]['findAll'](_0x5988d1);})[_0x8bf3('0x24')](function(_0x25ae23){_0xcf9f4b[_0x8bf3('0x40')]=_0x25ae23;return _0xcf9f4b;})[_0x8bf3('0x24')](respondWithFilteredResult(_0x21336a,_0x5988d1))[_0x8bf3('0x41')](handleError(_0x21336a,null));};exports[_0x8bf3('0x42')]=function(_0x504510,_0xb56dc2){var _0x42acb2={'raw':!![],'where':{'id':_0x504510[_0x8bf3('0x43')]['id']}},_0x191994={};_0x191994[_0x8bf3('0x2f')]=_[_0x8bf3('0x32')](db['VoiceTransferReport'][_0x8bf3('0x44')]);_0x191994[_0x8bf3('0x31')]=_[_0x8bf3('0x32')](_0x504510['query']);_0x191994[_0x8bf3('0x33')]=_[_0x8bf3('0x34')](_0x191994[_0x8bf3('0x2f')],_0x191994['query']);_0x42acb2[_0x8bf3('0x35')]=_[_0x8bf3('0x34')](_0x191994[_0x8bf3('0x2f')],qs[_0x8bf3('0x36')](_0x504510[_0x8bf3('0x31')][_0x8bf3('0x36')]));_0x42acb2[_0x8bf3('0x35')]=_0x42acb2['attributes']['length']?_0x42acb2['attributes']:_0x191994['model'];if(_0x504510[_0x8bf3('0x31')][_0x8bf3('0x45')]){_0x42acb2[_0x8bf3('0x3f')]=[{'all':!![]}];}_0x42acb2=_[_0x8bf3('0x46')]({},_0x42acb2,_0x504510[_0x8bf3('0x3e')]);return db[_0x8bf3('0x2b')]['find'](_0x42acb2)['then'](handleEntityNotFound(_0xb56dc2,null))[_0x8bf3('0x24')](respondWithResult(_0xb56dc2,null))['catch'](handleError(_0xb56dc2,null));};exports[_0x8bf3('0x47')]=function(_0x28d988,_0x4a98f0){return db[_0x8bf3('0x2b')][_0x8bf3('0x47')](_0x28d988[_0x8bf3('0x48')],{})['then'](respondWithResult(_0x4a98f0,0xc9))[_0x8bf3('0x41')](handleError(_0x4a98f0,null));};exports[_0x8bf3('0x49')]=function(_0x48e2dd,_0x23f002){if(_0x48e2dd[_0x8bf3('0x48')]['id']){delete _0x48e2dd[_0x8bf3('0x48')]['id'];}return db[_0x8bf3('0x2b')][_0x8bf3('0x4a')]({'where':{'id':_0x48e2dd[_0x8bf3('0x43')]['id']}})[_0x8bf3('0x24')](handleEntityNotFound(_0x23f002,null))[_0x8bf3('0x24')](saveUpdates(_0x48e2dd[_0x8bf3('0x48')],null))[_0x8bf3('0x24')](respondWithResult(_0x23f002,null))['catch'](handleError(_0x23f002,null));};exports[_0x8bf3('0x23')]=function(_0x55398f,_0x2c0a13){return db[_0x8bf3('0x2b')][_0x8bf3('0x4a')]({'where':{'id':_0x55398f[_0x8bf3('0x43')]['id']}})[_0x8bf3('0x24')](handleEntityNotFound(_0x2c0a13,null))['then'](removeEntity(_0x2c0a13,null))[_0x8bf3('0x41')](handleError(_0x2c0a13,null));};