Built motion from commit (unavailable).|2.5.27
[motion2.git] / server / api / memberReport / memberReport.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 _0xf3c1=['../../config/license/util','../../mysqldb','status','end','json','count','offset','limit','set','apply','reject','save','then','destroy','sendStatus','error','stack','name','index','map','MemberReport','rawAttributes','fieldName','key','model','query','filters','attributes','intersection','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','includeAll','include','findAll','catch','show','keys','fields','options','create','body','update','find','params','describe','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xf3c1,0x120));var _0x1f3c=function(_0x2beb70,_0x264e7a){_0x2beb70=_0x2beb70-0x0;var _0x4975b9=_0xf3c1[_0x2beb70];return _0x4975b9;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1f3c('0x0'));var zipdir=require(_0x1f3c('0x1'));var jsonpatch=require(_0x1f3c('0x2'));var rp=require('request-promise');var moment=require(_0x1f3c('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x1f3c('0x4'));var util=require(_0x1f3c('0x5'));var path=require(_0x1f3c('0x6'));var sox=require(_0x1f3c('0x7'));var csv=require(_0x1f3c('0x8'));var ejs=require(_0x1f3c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1f3c('0xa'));var squel=require('squel');var crypto=require(_0x1f3c('0xb'));var jsforce=require(_0x1f3c('0xc'));var deskjs=require(_0x1f3c('0xd'));var toCsv=require('to-csv');var querystring=require(_0x1f3c('0xe'));var Papa=require(_0x1f3c('0xf'));var Redis=require(_0x1f3c('0x10'));var authService=require(_0x1f3c('0x11'));var qs=require(_0x1f3c('0x12'));var as=require(_0x1f3c('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x1f3c('0x14'))(_0x1f3c('0x15'));var utils=require(_0x1f3c('0x16'));var config=require(_0x1f3c('0x17'));var licenseUtil=require(_0x1f3c('0x18'));var db=require(_0x1f3c('0x19'))['db'];function respondWithStatusCode(_0x4923b2,_0x29c457){_0x29c457=_0x29c457||0xcc;return function(_0x34a3f8){if(_0x34a3f8){return _0x4923b2['sendStatus'](_0x29c457);}return _0x4923b2[_0x1f3c('0x1a')](_0x29c457)[_0x1f3c('0x1b')]();};}function respondWithResult(_0x41e9f6,_0x40849b){_0x40849b=_0x40849b||0xc8;return function(_0x2cfbfd){if(_0x2cfbfd){return _0x41e9f6['status'](_0x40849b)[_0x1f3c('0x1c')](_0x2cfbfd);}};}function respondWithFilteredResult(_0x3c6a7f,_0x304d19){return function(_0x163c08){if(_0x163c08){var _0x37929a=_0x163c08[_0x1f3c('0x1d')],_0x9bc13=_0x304d19[_0x1f3c('0x1e')],_0x478a98=_0x304d19['offset']+_0x304d19[_0x1f3c('0x1f')],_0x5c963d;if(_0x478a98>=_0x37929a){_0x478a98=_0x37929a;_0x5c963d=0xc8;}else{_0x5c963d=0xce;}_0x3c6a7f[_0x1f3c('0x1a')](_0x5c963d);return _0x3c6a7f[_0x1f3c('0x20')]('Content-Range',_0x9bc13+'-'+_0x478a98+'/'+_0x37929a)['json'](_0x163c08);}return null;};}function patchUpdates(_0x4416c5){return function(_0x4c13b4){try{jsonpatch[_0x1f3c('0x21')](_0x4c13b4,_0x4416c5,!![]);}catch(_0x245a84){return BPromise[_0x1f3c('0x22')](_0x245a84);}return _0x4c13b4[_0x1f3c('0x23')]();};}function saveUpdates(_0x485e44,_0x1efc69){return function(_0x395d78){if(_0x395d78){return _0x395d78['update'](_0x485e44)[_0x1f3c('0x24')](function(_0x563418){return _0x563418;});}return null;};}function removeEntity(_0x1b7fbe,_0x26ada6){return function(_0x4f73d3){if(_0x4f73d3){return _0x4f73d3[_0x1f3c('0x25')]()[_0x1f3c('0x24')](function(){_0x1b7fbe[_0x1f3c('0x1a')](0xcc)[_0x1f3c('0x1b')]();});}};}function handleEntityNotFound(_0xae6424,_0x543ee7){return function(_0x1c7b34){if(!_0x1c7b34){_0xae6424[_0x1f3c('0x26')](0x194);}return _0x1c7b34;};}function handleError(_0x2ba72d,_0x108c5f){_0x108c5f=_0x108c5f||0x1f4;return function(_0x17696c){logger[_0x1f3c('0x27')](_0x17696c[_0x1f3c('0x28')]);if(_0x17696c[_0x1f3c('0x29')]){delete _0x17696c[_0x1f3c('0x29')];}_0x2ba72d[_0x1f3c('0x1a')](_0x108c5f)['send'](_0x17696c);};}exports[_0x1f3c('0x2a')]=function(_0x98801b,_0x1a83cc){var _0x146be8={},_0x2b802e={},_0x8e4401={'count':0x0,'rows':[]};var _0x4f3cc8=_[_0x1f3c('0x2b')](db[_0x1f3c('0x2c')][_0x1f3c('0x2d')],function(_0x3a0807){return{'name':_0x3a0807[_0x1f3c('0x2e')],'type':_0x3a0807['type'][_0x1f3c('0x2f')]};});_0x2b802e[_0x1f3c('0x30')]=_['map'](_0x4f3cc8,_0x1f3c('0x29'));_0x2b802e[_0x1f3c('0x31')]=_['keys'](_0x98801b['query']);_0x2b802e[_0x1f3c('0x32')]=_['intersection'](_0x2b802e[_0x1f3c('0x30')],_0x2b802e[_0x1f3c('0x31')]);_0x146be8[_0x1f3c('0x33')]=_[_0x1f3c('0x34')](_0x2b802e[_0x1f3c('0x30')],qs['fields'](_0x98801b['query']['fields']));_0x146be8[_0x1f3c('0x33')]=_0x146be8[_0x1f3c('0x33')][_0x1f3c('0x35')]?_0x146be8[_0x1f3c('0x33')]:_0x2b802e[_0x1f3c('0x30')];if(!_0x98801b[_0x1f3c('0x31')][_0x1f3c('0x36')](_0x1f3c('0x37'))){_0x146be8[_0x1f3c('0x1f')]=qs[_0x1f3c('0x1f')](_0x98801b[_0x1f3c('0x31')][_0x1f3c('0x1f')]);_0x146be8[_0x1f3c('0x1e')]=qs['offset'](_0x98801b['query']['offset']);}_0x146be8[_0x1f3c('0x38')]=qs[_0x1f3c('0x39')](_0x98801b[_0x1f3c('0x31')]['sort']);_0x146be8['where']=qs[_0x1f3c('0x32')](_[_0x1f3c('0x3a')](_0x98801b[_0x1f3c('0x31')],_0x2b802e[_0x1f3c('0x32')]),_0x4f3cc8);if(_0x98801b[_0x1f3c('0x31')][_0x1f3c('0x3b')]){_0x146be8[_0x1f3c('0x3c')]=_[_0x1f3c('0x3d')](_0x146be8['where'],{'$or':_[_0x1f3c('0x2b')](_0x4f3cc8,function(_0xdeba71){if(_0xdeba71[_0x1f3c('0x3e')]!==_0x1f3c('0x3f')){var _0xd57df4={};_0xd57df4[_0xdeba71['name']]={'$like':'%'+_0x98801b[_0x1f3c('0x31')]['filter']+'%'};return _0xd57df4;}})});}_0x146be8=_[_0x1f3c('0x3d')]({},_0x146be8,_0x98801b['options']);var _0x4671c8={'where':_0x146be8['where']};return db[_0x1f3c('0x2c')][_0x1f3c('0x1d')](_0x4671c8)[_0x1f3c('0x24')](function(_0x2ced77){_0x8e4401[_0x1f3c('0x1d')]=_0x2ced77;if(_0x98801b[_0x1f3c('0x31')][_0x1f3c('0x40')]){_0x146be8[_0x1f3c('0x41')]=[{'all':!![]}];}return db[_0x1f3c('0x2c')][_0x1f3c('0x42')](_0x146be8);})[_0x1f3c('0x24')](function(_0x48fcad){_0x8e4401['rows']=_0x48fcad;return _0x8e4401;})['then'](respondWithFilteredResult(_0x1a83cc,_0x146be8))[_0x1f3c('0x43')](handleError(_0x1a83cc,null));};exports[_0x1f3c('0x44')]=function(_0x17b60c,_0x5a11a1){var _0x2d77c4={'raw':!![],'where':{'id':_0x17b60c['params']['id']}},_0x1dcc63={};_0x1dcc63[_0x1f3c('0x30')]=_[_0x1f3c('0x45')](db[_0x1f3c('0x2c')][_0x1f3c('0x2d')]);_0x1dcc63[_0x1f3c('0x31')]=_[_0x1f3c('0x45')](_0x17b60c[_0x1f3c('0x31')]);_0x1dcc63[_0x1f3c('0x32')]=_[_0x1f3c('0x34')](_0x1dcc63[_0x1f3c('0x30')],_0x1dcc63[_0x1f3c('0x31')]);_0x2d77c4['attributes']=_[_0x1f3c('0x34')](_0x1dcc63[_0x1f3c('0x30')],qs[_0x1f3c('0x46')](_0x17b60c[_0x1f3c('0x31')][_0x1f3c('0x46')]));_0x2d77c4[_0x1f3c('0x33')]=_0x2d77c4['attributes'][_0x1f3c('0x35')]?_0x2d77c4['attributes']:_0x1dcc63[_0x1f3c('0x30')];if(_0x17b60c[_0x1f3c('0x31')][_0x1f3c('0x40')]){_0x2d77c4[_0x1f3c('0x41')]=[{'all':!![]}];}_0x2d77c4=_['merge']({},_0x2d77c4,_0x17b60c[_0x1f3c('0x47')]);return db[_0x1f3c('0x2c')]['find'](_0x2d77c4)[_0x1f3c('0x24')](handleEntityNotFound(_0x5a11a1,null))[_0x1f3c('0x24')](respondWithResult(_0x5a11a1,null))['catch'](handleError(_0x5a11a1,null));};exports[_0x1f3c('0x48')]=function(_0x2be8d0,_0x2c4ecf){return db[_0x1f3c('0x2c')][_0x1f3c('0x48')](_0x2be8d0[_0x1f3c('0x49')],{})[_0x1f3c('0x24')](respondWithResult(_0x2c4ecf,0xc9))[_0x1f3c('0x43')](handleError(_0x2c4ecf,null));};exports[_0x1f3c('0x4a')]=function(_0x29aedb,_0x4aa24a){if(_0x29aedb[_0x1f3c('0x49')]['id']){delete _0x29aedb['body']['id'];}return db['MemberReport'][_0x1f3c('0x4b')]({'where':{'id':_0x29aedb[_0x1f3c('0x4c')]['id']}})[_0x1f3c('0x24')](handleEntityNotFound(_0x4aa24a,null))[_0x1f3c('0x24')](saveUpdates(_0x29aedb[_0x1f3c('0x49')],null))['then'](respondWithResult(_0x4aa24a,null))[_0x1f3c('0x43')](handleError(_0x4aa24a,null));};exports['destroy']=function(_0x367a38,_0x554d06){return db[_0x1f3c('0x2c')][_0x1f3c('0x4b')]({'where':{'id':_0x367a38[_0x1f3c('0x4c')]['id']}})[_0x1f3c('0x24')](handleEntityNotFound(_0x554d06,null))['then'](removeEntity(_0x554d06,null))[_0x1f3c('0x43')](handleError(_0x554d06,null));};exports[_0x1f3c('0x4d')]=function(_0x3ef9c1,_0x1dcacf){return db[_0x1f3c('0x2c')][_0x1f3c('0x4d')]()[_0x1f3c('0x24')](respondWithResult(_0x1dcacf,null))['catch'](handleError(_0x1dcacf,null));};