Built motion from commit (unavailable).|2.5.4
[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 _0xb5ff=['Content-Range','reject','update','then','destroy','error','name','send','index','map','rawAttributes','fieldName','type','query','keys','filters','intersection','model','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VoiceTransferReport','findAll','rows','catch','params','fields','includeAll','find','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','to-csv','querystring','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit'];(function(_0x17d8f4,_0xa046f0){var _0x336743=function(_0x34b3fc){while(--_0x34b3fc){_0x17d8f4['push'](_0x17d8f4['shift']());}};_0x336743(++_0xa046f0);}(_0xb5ff,0x6c));var _0xfb5f=function(_0x405dc0,_0x5f2898){_0x405dc0=_0x405dc0-0x0;var _0x1ed46d=_0xb5ff[_0x405dc0];return _0x1ed46d;};'use strict';var pdf=require(_0xfb5f('0x0'));var emlformat=require(_0xfb5f('0x1'));var rimraf=require(_0xfb5f('0x2'));var zipdir=require(_0xfb5f('0x3'));var jsonpatch=require(_0xfb5f('0x4'));var rp=require('request-promise');var moment=require(_0xfb5f('0x5'));var BPromise=require(_0xfb5f('0x6'));var Mustache=require(_0xfb5f('0x7'));var util=require(_0xfb5f('0x8'));var path=require(_0xfb5f('0x9'));var sox=require(_0xfb5f('0xa'));var csv=require('to-csv');var ejs=require(_0xfb5f('0xb'));var fs=require('fs');var _=require(_0xfb5f('0xc'));var squel=require('squel');var crypto=require(_0xfb5f('0xd'));var jsforce=require(_0xfb5f('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xfb5f('0xf'));var querystring=require(_0xfb5f('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xfb5f('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfb5f('0x12'));var logger=require(_0xfb5f('0x13'))(_0xfb5f('0x14'));var utils=require('../../config/utils');var config=require(_0xfb5f('0x15'));var db=require(_0xfb5f('0x16'))['db'];function respondWithStatusCode(_0x1f6176,_0x31e782){_0x31e782=_0x31e782||0xcc;return function(_0x199b8b){if(_0x199b8b){return _0x1f6176[_0xfb5f('0x17')](_0x31e782);}return _0x1f6176[_0xfb5f('0x18')](_0x31e782)[_0xfb5f('0x19')]();};}function respondWithResult(_0x82a2f,_0x3dc4c7){_0x3dc4c7=_0x3dc4c7||0xc8;return function(_0x423ddd){if(_0x423ddd){return _0x82a2f['status'](_0x3dc4c7)[_0xfb5f('0x1a')](_0x423ddd);}};}function respondWithFilteredResult(_0x29a739,_0x23cd56){return function(_0x4f4431){if(_0x4f4431){var _0x51861a=_0x4f4431[_0xfb5f('0x1b')],_0xf92b1f=_0x23cd56[_0xfb5f('0x1c')],_0x37bff0=_0x23cd56[_0xfb5f('0x1c')]+_0x23cd56[_0xfb5f('0x1d')],_0x1d9df8;if(_0x37bff0>=_0x51861a){_0x37bff0=_0x51861a;_0x1d9df8=0xc8;}else{_0x1d9df8=0xce;}_0x29a739['status'](_0x1d9df8);return _0x29a739['set'](_0xfb5f('0x1e'),_0xf92b1f+'-'+_0x37bff0+'/'+_0x51861a)[_0xfb5f('0x1a')](_0x4f4431);}return null;};}function patchUpdates(_0x11db32){return function(_0x4d3517){try{jsonpatch['apply'](_0x4d3517,_0x11db32,!![]);}catch(_0x27f88f){return BPromise[_0xfb5f('0x1f')](_0x27f88f);}return _0x4d3517['save']();};}function saveUpdates(_0x4e3986,_0x1f45f9){return function(_0x94560d){if(_0x94560d){return _0x94560d[_0xfb5f('0x20')](_0x4e3986)[_0xfb5f('0x21')](function(_0x517f46){return _0x517f46;});}return null;};}function removeEntity(_0x24c667,_0x2910a1){return function(_0x381301){if(_0x381301){return _0x381301[_0xfb5f('0x22')]()[_0xfb5f('0x21')](function(){_0x24c667[_0xfb5f('0x18')](0xcc)[_0xfb5f('0x19')]();});}};}function handleEntityNotFound(_0x2e603a,_0x342935){return function(_0x21bd22){if(!_0x21bd22){_0x2e603a[_0xfb5f('0x17')](0x194);}return _0x21bd22;};}function handleError(_0x9eeecf,_0x43ad86){_0x43ad86=_0x43ad86||0x1f4;return function(_0x545493){logger[_0xfb5f('0x23')](_0x545493['stack']);if(_0x545493[_0xfb5f('0x24')]){delete _0x545493[_0xfb5f('0x24')];}_0x9eeecf[_0xfb5f('0x18')](_0x43ad86)[_0xfb5f('0x25')](_0x545493);};}exports[_0xfb5f('0x26')]=function(_0x3f342f,_0x375179){var _0x15aa02={},_0x40f1df={},_0x2af5ce={'count':0x0,'rows':[]};var _0x259f15=_[_0xfb5f('0x27')](db['VoiceTransferReport'][_0xfb5f('0x28')],function(_0x24e375){return{'name':_0x24e375[_0xfb5f('0x29')],'type':_0x24e375[_0xfb5f('0x2a')]['key']};});_0x40f1df['model']=_[_0xfb5f('0x27')](_0x259f15,_0xfb5f('0x24'));_0x40f1df[_0xfb5f('0x2b')]=_[_0xfb5f('0x2c')](_0x3f342f['query']);_0x40f1df[_0xfb5f('0x2d')]=_[_0xfb5f('0x2e')](_0x40f1df['model'],_0x40f1df[_0xfb5f('0x2b')]);_0x15aa02['attributes']=_[_0xfb5f('0x2e')](_0x40f1df[_0xfb5f('0x2f')],qs['fields'](_0x3f342f[_0xfb5f('0x2b')]['fields']));_0x15aa02[_0xfb5f('0x30')]=_0x15aa02[_0xfb5f('0x30')][_0xfb5f('0x31')]?_0x15aa02[_0xfb5f('0x30')]:_0x40f1df[_0xfb5f('0x2f')];if(!_0x3f342f[_0xfb5f('0x2b')][_0xfb5f('0x32')](_0xfb5f('0x33'))){_0x15aa02[_0xfb5f('0x1d')]=qs[_0xfb5f('0x1d')](_0x3f342f[_0xfb5f('0x2b')][_0xfb5f('0x1d')]);_0x15aa02[_0xfb5f('0x1c')]=qs[_0xfb5f('0x1c')](_0x3f342f[_0xfb5f('0x2b')]['offset']);}_0x15aa02[_0xfb5f('0x34')]=qs['sort'](_0x3f342f[_0xfb5f('0x2b')][_0xfb5f('0x35')]);_0x15aa02[_0xfb5f('0x36')]=qs[_0xfb5f('0x2d')](_[_0xfb5f('0x37')](_0x3f342f['query'],_0x40f1df[_0xfb5f('0x2d')]),_0x259f15);if(_0x3f342f[_0xfb5f('0x2b')][_0xfb5f('0x38')]){_0x15aa02[_0xfb5f('0x36')]=_[_0xfb5f('0x39')](_0x15aa02[_0xfb5f('0x36')],{'$or':_[_0xfb5f('0x27')](_0x259f15,function(_0x212538){if(_0x212538[_0xfb5f('0x2a')]!==_0xfb5f('0x3a')){var _0x2768b0={};_0x2768b0[_0x212538[_0xfb5f('0x24')]]={'$like':'%'+_0x3f342f[_0xfb5f('0x2b')][_0xfb5f('0x38')]+'%'};return _0x2768b0;}})});}_0x15aa02=_[_0xfb5f('0x39')]({},_0x15aa02,_0x3f342f[_0xfb5f('0x3b')]);var _0x53d7fb={'where':_0x15aa02[_0xfb5f('0x36')]};return db[_0xfb5f('0x3c')][_0xfb5f('0x1b')](_0x53d7fb)[_0xfb5f('0x21')](function(_0x19728e){_0x2af5ce[_0xfb5f('0x1b')]=_0x19728e;if(_0x3f342f['query']['includeAll']){_0x15aa02['include']=[{'all':!![]}];}return db[_0xfb5f('0x3c')][_0xfb5f('0x3d')](_0x15aa02);})[_0xfb5f('0x21')](function(_0x281008){_0x2af5ce[_0xfb5f('0x3e')]=_0x281008;return _0x2af5ce;})['then'](respondWithFilteredResult(_0x375179,_0x15aa02))[_0xfb5f('0x3f')](handleError(_0x375179,null));};exports['show']=function(_0x6cf3dc,_0x12dd4d){var _0x43214a={'raw':!![],'where':{'id':_0x6cf3dc[_0xfb5f('0x40')]['id']}},_0x46355c={};_0x46355c[_0xfb5f('0x2f')]=_[_0xfb5f('0x2c')](db['VoiceTransferReport'][_0xfb5f('0x28')]);_0x46355c[_0xfb5f('0x2b')]=_['keys'](_0x6cf3dc[_0xfb5f('0x2b')]);_0x46355c[_0xfb5f('0x2d')]=_[_0xfb5f('0x2e')](_0x46355c[_0xfb5f('0x2f')],_0x46355c[_0xfb5f('0x2b')]);_0x43214a[_0xfb5f('0x30')]=_['intersection'](_0x46355c['model'],qs[_0xfb5f('0x41')](_0x6cf3dc[_0xfb5f('0x2b')][_0xfb5f('0x41')]));_0x43214a[_0xfb5f('0x30')]=_0x43214a[_0xfb5f('0x30')][_0xfb5f('0x31')]?_0x43214a['attributes']:_0x46355c[_0xfb5f('0x2f')];if(_0x6cf3dc[_0xfb5f('0x2b')][_0xfb5f('0x42')]){_0x43214a['include']=[{'all':!![]}];}_0x43214a=_[_0xfb5f('0x39')]({},_0x43214a,_0x6cf3dc[_0xfb5f('0x3b')]);return db[_0xfb5f('0x3c')][_0xfb5f('0x43')](_0x43214a)[_0xfb5f('0x21')](handleEntityNotFound(_0x12dd4d,null))[_0xfb5f('0x21')](respondWithResult(_0x12dd4d,null))['catch'](handleError(_0x12dd4d,null));};exports['create']=function(_0x5dd86b,_0x138d72){return db[_0xfb5f('0x3c')]['create'](_0x5dd86b['body'],{})['then'](respondWithResult(_0x138d72,0xc9))['catch'](handleError(_0x138d72,null));};exports['update']=function(_0x226dc3,_0x1b2ba6){if(_0x226dc3[_0xfb5f('0x44')]['id']){delete _0x226dc3[_0xfb5f('0x44')]['id'];}return db[_0xfb5f('0x3c')][_0xfb5f('0x43')]({'where':{'id':_0x226dc3['params']['id']}})[_0xfb5f('0x21')](handleEntityNotFound(_0x1b2ba6,null))[_0xfb5f('0x21')](saveUpdates(_0x226dc3[_0xfb5f('0x44')],null))[_0xfb5f('0x21')](respondWithResult(_0x1b2ba6,null))[_0xfb5f('0x3f')](handleError(_0x1b2ba6,null));};exports[_0xfb5f('0x22')]=function(_0x2171b0,_0x949807){return db[_0xfb5f('0x3c')][_0xfb5f('0x43')]({'where':{'id':_0x2171b0[_0xfb5f('0x40')]['id']}})[_0xfb5f('0x21')](handleEntityNotFound(_0x949807,null))['then'](removeEntity(_0x949807,null))[_0xfb5f('0x3f')](handleError(_0x949807,null));};