Built motion from commit (unavailable).|2.5.5
[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 _0x31f5=['hasOwnProperty','nolimit','order','where','VIRTUAL','options','include','findAll','catch','params','keys','rawAttributes','fields','includeAll','merge','create','body','find','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','status','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','end','sendStatus','stack','name','index','map','MemberReport','fieldName','type','key','model','query','filters','intersection','attributes','length'];(function(_0xbfe6b8,_0x3c62cb){var _0x87a60a=function(_0x69b502){while(--_0x69b502){_0xbfe6b8['push'](_0xbfe6b8['shift']());}};_0x87a60a(++_0x3c62cb);}(_0x31f5,0x180));var _0x531f=function(_0x1214a1,_0x3daca0){_0x1214a1=_0x1214a1-0x0;var _0x399681=_0x31f5[_0x1214a1];return _0x399681;};'use strict';var pdf=require(_0x531f('0x0'));var emlformat=require(_0x531f('0x1'));var rimraf=require(_0x531f('0x2'));var zipdir=require(_0x531f('0x3'));var jsonpatch=require(_0x531f('0x4'));var rp=require(_0x531f('0x5'));var moment=require('moment');var BPromise=require(_0x531f('0x6'));var Mustache=require(_0x531f('0x7'));var util=require(_0x531f('0x8'));var path=require(_0x531f('0x9'));var sox=require(_0x531f('0xa'));var csv=require(_0x531f('0xb'));var ejs=require(_0x531f('0xc'));var fs=require('fs');var _=require(_0x531f('0xd'));var squel=require(_0x531f('0xe'));var crypto=require(_0x531f('0xf'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x531f('0xb'));var querystring=require(_0x531f('0x10'));var Papa=require(_0x531f('0x11'));var Redis=require(_0x531f('0x12'));var authService=require(_0x531f('0x13'));var qs=require(_0x531f('0x14'));var as=require(_0x531f('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x531f('0x16'));var utils=require(_0x531f('0x17'));var config=require(_0x531f('0x18'));var licenseUtil=require(_0x531f('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3310f2,_0x26687f){_0x26687f=_0x26687f||0xcc;return function(_0x128300){if(_0x128300){return _0x3310f2['sendStatus'](_0x26687f);}return _0x3310f2[_0x531f('0x1a')](_0x26687f)['end']();};}function respondWithResult(_0x14f02f,_0x1ecff0){_0x1ecff0=_0x1ecff0||0xc8;return function(_0x5b790e){if(_0x5b790e){return _0x14f02f['status'](_0x1ecff0)[_0x531f('0x1b')](_0x5b790e);}};}function respondWithFilteredResult(_0x51d4f8,_0x4d660a){return function(_0x35ba9c){if(_0x35ba9c){var _0x45d08d=_0x35ba9c[_0x531f('0x1c')],_0x567e26=_0x4d660a['offset'],_0x4dd904=_0x4d660a[_0x531f('0x1d')]+_0x4d660a[_0x531f('0x1e')],_0x2a5b41;if(_0x4dd904>=_0x45d08d){_0x4dd904=_0x45d08d;_0x2a5b41=0xc8;}else{_0x2a5b41=0xce;}_0x51d4f8[_0x531f('0x1a')](_0x2a5b41);return _0x51d4f8[_0x531f('0x1f')](_0x531f('0x20'),_0x567e26+'-'+_0x4dd904+'/'+_0x45d08d)['json'](_0x35ba9c);}return null;};}function patchUpdates(_0x109c08){return function(_0x42419d){try{jsonpatch[_0x531f('0x21')](_0x42419d,_0x109c08,!![]);}catch(_0x309e6e){return BPromise[_0x531f('0x22')](_0x309e6e);}return _0x42419d['save']();};}function saveUpdates(_0x263866,_0x85d676){return function(_0x1e3c16){if(_0x1e3c16){return _0x1e3c16[_0x531f('0x23')](_0x263866)[_0x531f('0x24')](function(_0xe198c7){return _0xe198c7;});}return null;};}function removeEntity(_0x1b12be,_0xe08577){return function(_0x2f6492){if(_0x2f6492){return _0x2f6492[_0x531f('0x25')]()['then'](function(){_0x1b12be['status'](0xcc)[_0x531f('0x26')]();});}};}function handleEntityNotFound(_0x5d31fa,_0x3e8939){return function(_0x2628da){if(!_0x2628da){_0x5d31fa[_0x531f('0x27')](0x194);}return _0x2628da;};}function handleError(_0x47f01e,_0x26c694){_0x26c694=_0x26c694||0x1f4;return function(_0x2a5807){logger['error'](_0x2a5807[_0x531f('0x28')]);if(_0x2a5807[_0x531f('0x29')]){delete _0x2a5807[_0x531f('0x29')];}_0x47f01e['status'](_0x26c694)['send'](_0x2a5807);};}exports[_0x531f('0x2a')]=function(_0x31843f,_0x1ad967){var _0xb091fb={},_0x7dc969={},_0x147b0d={'count':0x0,'rows':[]};var _0x560f64=_[_0x531f('0x2b')](db[_0x531f('0x2c')]['rawAttributes'],function(_0x1599b0){return{'name':_0x1599b0[_0x531f('0x2d')],'type':_0x1599b0[_0x531f('0x2e')][_0x531f('0x2f')]};});_0x7dc969[_0x531f('0x30')]=_[_0x531f('0x2b')](_0x560f64,_0x531f('0x29'));_0x7dc969[_0x531f('0x31')]=_['keys'](_0x31843f['query']);_0x7dc969[_0x531f('0x32')]=_[_0x531f('0x33')](_0x7dc969['model'],_0x7dc969[_0x531f('0x31')]);_0xb091fb[_0x531f('0x34')]=_[_0x531f('0x33')](_0x7dc969[_0x531f('0x30')],qs['fields'](_0x31843f[_0x531f('0x31')]['fields']));_0xb091fb[_0x531f('0x34')]=_0xb091fb['attributes'][_0x531f('0x35')]?_0xb091fb['attributes']:_0x7dc969[_0x531f('0x30')];if(!_0x31843f['query'][_0x531f('0x36')](_0x531f('0x37'))){_0xb091fb[_0x531f('0x1e')]=qs[_0x531f('0x1e')](_0x31843f[_0x531f('0x31')][_0x531f('0x1e')]);_0xb091fb[_0x531f('0x1d')]=qs[_0x531f('0x1d')](_0x31843f[_0x531f('0x31')]['offset']);}_0xb091fb[_0x531f('0x38')]=qs['sort'](_0x31843f[_0x531f('0x31')]['sort']);_0xb091fb['where']=qs[_0x531f('0x32')](_['pick'](_0x31843f[_0x531f('0x31')],_0x7dc969[_0x531f('0x32')]),_0x560f64);if(_0x31843f[_0x531f('0x31')]['filter']){_0xb091fb[_0x531f('0x39')]=_['merge'](_0xb091fb['where'],{'$or':_[_0x531f('0x2b')](_0x560f64,function(_0x4d9251){if(_0x4d9251['type']!==_0x531f('0x3a')){var _0x2cafa3={};_0x2cafa3[_0x4d9251['name']]={'$like':'%'+_0x31843f[_0x531f('0x31')]['filter']+'%'};return _0x2cafa3;}})});}_0xb091fb=_['merge']({},_0xb091fb,_0x31843f[_0x531f('0x3b')]);var _0x259de6={'where':_0xb091fb['where']};return db[_0x531f('0x2c')][_0x531f('0x1c')](_0x259de6)['then'](function(_0x526edb){_0x147b0d[_0x531f('0x1c')]=_0x526edb;if(_0x31843f[_0x531f('0x31')]['includeAll']){_0xb091fb[_0x531f('0x3c')]=[{'all':!![]}];}return db[_0x531f('0x2c')][_0x531f('0x3d')](_0xb091fb);})[_0x531f('0x24')](function(_0x12b4a2){_0x147b0d['rows']=_0x12b4a2;return _0x147b0d;})[_0x531f('0x24')](respondWithFilteredResult(_0x1ad967,_0xb091fb))[_0x531f('0x3e')](handleError(_0x1ad967,null));};exports['show']=function(_0xf95b0,_0x4ef0ee){var _0x5d843b={'raw':!![],'where':{'id':_0xf95b0[_0x531f('0x3f')]['id']}},_0x88f9b2={};_0x88f9b2[_0x531f('0x30')]=_[_0x531f('0x40')](db[_0x531f('0x2c')][_0x531f('0x41')]);_0x88f9b2['query']=_[_0x531f('0x40')](_0xf95b0['query']);_0x88f9b2[_0x531f('0x32')]=_[_0x531f('0x33')](_0x88f9b2[_0x531f('0x30')],_0x88f9b2[_0x531f('0x31')]);_0x5d843b[_0x531f('0x34')]=_[_0x531f('0x33')](_0x88f9b2[_0x531f('0x30')],qs[_0x531f('0x42')](_0xf95b0[_0x531f('0x31')][_0x531f('0x42')]));_0x5d843b['attributes']=_0x5d843b['attributes'][_0x531f('0x35')]?_0x5d843b[_0x531f('0x34')]:_0x88f9b2['model'];if(_0xf95b0['query'][_0x531f('0x43')]){_0x5d843b[_0x531f('0x3c')]=[{'all':!![]}];}_0x5d843b=_[_0x531f('0x44')]({},_0x5d843b,_0xf95b0[_0x531f('0x3b')]);return db['MemberReport']['find'](_0x5d843b)['then'](handleEntityNotFound(_0x4ef0ee,null))[_0x531f('0x24')](respondWithResult(_0x4ef0ee,null))[_0x531f('0x3e')](handleError(_0x4ef0ee,null));};exports[_0x531f('0x45')]=function(_0x238e7c,_0x2c2865){return db['MemberReport']['create'](_0x238e7c[_0x531f('0x46')],{})[_0x531f('0x24')](respondWithResult(_0x2c2865,0xc9))['catch'](handleError(_0x2c2865,null));};exports[_0x531f('0x23')]=function(_0x51888d,_0x4d1621){if(_0x51888d['body']['id']){delete _0x51888d[_0x531f('0x46')]['id'];}return db[_0x531f('0x2c')][_0x531f('0x47')]({'where':{'id':_0x51888d['params']['id']}})['then'](handleEntityNotFound(_0x4d1621,null))[_0x531f('0x24')](saveUpdates(_0x51888d['body'],null))[_0x531f('0x24')](respondWithResult(_0x4d1621,null))[_0x531f('0x3e')](handleError(_0x4d1621,null));};exports['destroy']=function(_0x859c1f,_0x191705){return db['MemberReport'][_0x531f('0x47')]({'where':{'id':_0x859c1f[_0x531f('0x3f')]['id']}})[_0x531f('0x24')](handleEntityNotFound(_0x191705,null))[_0x531f('0x24')](removeEntity(_0x191705,null))[_0x531f('0x3e')](handleError(_0x191705,null));};exports[_0x531f('0x48')]=function(_0x1761c9,_0x2ce3ab){return db[_0x531f('0x2c')]['describe']()[_0x531f('0x24')](respondWithResult(_0x2ce3ab,null))[_0x531f('0x3e')](handleError(_0x2ce3ab,null));};