Built motion from commit (unavailable).|2.5.20
[motion2.git] / server / api / faxQueueReport / faxQueueReport.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 _0x1b63=['save','update','then','stack','name','send','map','FaxQueueReport','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','catch','find','body','params','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject'];(function(_0x367825,_0xba445e){var _0x17e0c2=function(_0x2a16cc){while(--_0x2a16cc){_0x367825['push'](_0x367825['shift']());}};_0x17e0c2(++_0xba445e);}(_0x1b63,0xac));var _0x31b6=function(_0x3f6b1b,_0x58d3d6){_0x3f6b1b=_0x3f6b1b-0x0;var _0x4a3d2b=_0x1b63[_0x3f6b1b];return _0x4a3d2b;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x31b6('0x0'));var zipdir=require(_0x31b6('0x1'));var jsonpatch=require(_0x31b6('0x2'));var rp=require(_0x31b6('0x3'));var moment=require(_0x31b6('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x31b6('0x5'));var sox=require(_0x31b6('0x6'));var csv=require(_0x31b6('0x7'));var ejs=require(_0x31b6('0x8'));var fs=require('fs');var _=require(_0x31b6('0x9'));var squel=require('squel');var crypto=require(_0x31b6('0xa'));var jsforce=require(_0x31b6('0xb'));var deskjs=require(_0x31b6('0xc'));var toCsv=require(_0x31b6('0x7'));var querystring=require(_0x31b6('0xd'));var Papa=require(_0x31b6('0xe'));var Redis=require(_0x31b6('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x31b6('0x10'));var as=require(_0x31b6('0x11'));var hardwareService=require(_0x31b6('0x12'));var logger=require(_0x31b6('0x13'))(_0x31b6('0x14'));var utils=require(_0x31b6('0x15'));var config=require(_0x31b6('0x16'));var licenseUtil=require(_0x31b6('0x17'));var db=require(_0x31b6('0x18'))['db'];function respondWithStatusCode(_0x46a693,_0x2094f6){_0x2094f6=_0x2094f6||0xcc;return function(_0x59e8e3){if(_0x59e8e3){return _0x46a693[_0x31b6('0x19')](_0x2094f6);}return _0x46a693[_0x31b6('0x1a')](_0x2094f6)[_0x31b6('0x1b')]();};}function respondWithResult(_0x2b49fa,_0x3101c9){_0x3101c9=_0x3101c9||0xc8;return function(_0x1c23bd){if(_0x1c23bd){return _0x2b49fa[_0x31b6('0x1a')](_0x3101c9)[_0x31b6('0x1c')](_0x1c23bd);}};}function respondWithFilteredResult(_0x32d996,_0xaac45b){return function(_0x390969){if(_0x390969){var _0x28840d=_0x390969[_0x31b6('0x1d')],_0x46228b=_0xaac45b['offset'],_0x4212e8=_0xaac45b[_0x31b6('0x1e')]+_0xaac45b[_0x31b6('0x1f')],_0x2e65d5;if(_0x4212e8>=_0x28840d){_0x4212e8=_0x28840d;_0x2e65d5=0xc8;}else{_0x2e65d5=0xce;}_0x32d996['status'](_0x2e65d5);return _0x32d996[_0x31b6('0x20')](_0x31b6('0x21'),_0x46228b+'-'+_0x4212e8+'/'+_0x28840d)['json'](_0x390969);}return null;};}function patchUpdates(_0x1eecbe){return function(_0x169228){try{jsonpatch['apply'](_0x169228,_0x1eecbe,!![]);}catch(_0x39a010){return BPromise[_0x31b6('0x22')](_0x39a010);}return _0x169228[_0x31b6('0x23')]();};}function saveUpdates(_0x14399f,_0x1d1924){return function(_0x85c31b){if(_0x85c31b){return _0x85c31b[_0x31b6('0x24')](_0x14399f)[_0x31b6('0x25')](function(_0x1ce2d5){return _0x1ce2d5;});}return null;};}function removeEntity(_0x12c314,_0x3d4bd0){return function(_0x7c2cad){if(_0x7c2cad){return _0x7c2cad['destroy']()[_0x31b6('0x25')](function(){_0x12c314['status'](0xcc)[_0x31b6('0x1b')]();});}};}function handleEntityNotFound(_0x236d7f,_0x343bad){return function(_0x6fcdb9){if(!_0x6fcdb9){_0x236d7f[_0x31b6('0x19')](0x194);}return _0x6fcdb9;};}function handleError(_0x26ece2,_0x515200){_0x515200=_0x515200||0x1f4;return function(_0x1a4275){logger['error'](_0x1a4275[_0x31b6('0x26')]);if(_0x1a4275[_0x31b6('0x27')]){delete _0x1a4275['name'];}_0x26ece2[_0x31b6('0x1a')](_0x515200)[_0x31b6('0x28')](_0x1a4275);};}exports['index']=function(_0x16d4b7,_0x537548){var _0x64fab3={},_0x110d7e={},_0x43a8bc={'count':0x0,'rows':[]};var _0x3af65d=_[_0x31b6('0x29')](db[_0x31b6('0x2a')][_0x31b6('0x2b')],function(_0x42b3d6){return{'name':_0x42b3d6[_0x31b6('0x2c')],'type':_0x42b3d6['type'][_0x31b6('0x2d')]};});_0x110d7e[_0x31b6('0x2e')]=_[_0x31b6('0x29')](_0x3af65d,_0x31b6('0x27'));_0x110d7e[_0x31b6('0x2f')]=_[_0x31b6('0x30')](_0x16d4b7['query']);_0x110d7e[_0x31b6('0x31')]=_['intersection'](_0x110d7e[_0x31b6('0x2e')],_0x110d7e[_0x31b6('0x2f')]);_0x64fab3[_0x31b6('0x32')]=_[_0x31b6('0x33')](_0x110d7e[_0x31b6('0x2e')],qs[_0x31b6('0x34')](_0x16d4b7[_0x31b6('0x2f')][_0x31b6('0x34')]));_0x64fab3[_0x31b6('0x32')]=_0x64fab3[_0x31b6('0x32')][_0x31b6('0x35')]?_0x64fab3['attributes']:_0x110d7e['model'];if(!_0x16d4b7[_0x31b6('0x2f')][_0x31b6('0x36')]('nolimit')){_0x64fab3['limit']=qs[_0x31b6('0x1f')](_0x16d4b7[_0x31b6('0x2f')][_0x31b6('0x1f')]);_0x64fab3[_0x31b6('0x1e')]=qs[_0x31b6('0x1e')](_0x16d4b7[_0x31b6('0x2f')][_0x31b6('0x1e')]);}_0x64fab3[_0x31b6('0x37')]=qs[_0x31b6('0x38')](_0x16d4b7['query'][_0x31b6('0x38')]);_0x64fab3[_0x31b6('0x39')]=qs[_0x31b6('0x31')](_['pick'](_0x16d4b7['query'],_0x110d7e[_0x31b6('0x31')]),_0x3af65d);if(_0x16d4b7[_0x31b6('0x2f')][_0x31b6('0x3a')]){_0x64fab3[_0x31b6('0x39')]=_[_0x31b6('0x3b')](_0x64fab3['where'],{'$or':_['map'](_0x3af65d,function(_0x4e5e7f){if(_0x4e5e7f['type']!==_0x31b6('0x3c')){var _0x3b8ab1={};_0x3b8ab1[_0x4e5e7f[_0x31b6('0x27')]]={'$like':'%'+_0x16d4b7['query'][_0x31b6('0x3a')]+'%'};return _0x3b8ab1;}})});}_0x64fab3=_[_0x31b6('0x3b')]({},_0x64fab3,_0x16d4b7[_0x31b6('0x3d')]);var _0x22b2fc={'where':_0x64fab3[_0x31b6('0x39')]};return db['FaxQueueReport']['count'](_0x22b2fc)['then'](function(_0x18e918){_0x43a8bc['count']=_0x18e918;if(_0x16d4b7['query'][_0x31b6('0x3e')]){_0x64fab3[_0x31b6('0x3f')]=[{'all':!![]}];}return db[_0x31b6('0x2a')]['findAll'](_0x64fab3);})[_0x31b6('0x25')](function(_0x52936b){_0x43a8bc['rows']=_0x52936b;return _0x43a8bc;})[_0x31b6('0x25')](respondWithFilteredResult(_0x537548,_0x64fab3))[_0x31b6('0x40')](handleError(_0x537548,null));};exports['show']=function(_0x36ed7b,_0x26e1d7){var _0xcd1c0b={'raw':!![],'where':{'id':_0x36ed7b['params']['id']}},_0x160605={};_0x160605[_0x31b6('0x2e')]=_[_0x31b6('0x30')](db['FaxQueueReport']['rawAttributes']);_0x160605[_0x31b6('0x2f')]=_[_0x31b6('0x30')](_0x36ed7b[_0x31b6('0x2f')]);_0x160605[_0x31b6('0x31')]=_['intersection'](_0x160605[_0x31b6('0x2e')],_0x160605[_0x31b6('0x2f')]);_0xcd1c0b[_0x31b6('0x32')]=_['intersection'](_0x160605[_0x31b6('0x2e')],qs[_0x31b6('0x34')](_0x36ed7b['query'][_0x31b6('0x34')]));_0xcd1c0b[_0x31b6('0x32')]=_0xcd1c0b[_0x31b6('0x32')][_0x31b6('0x35')]?_0xcd1c0b[_0x31b6('0x32')]:_0x160605[_0x31b6('0x2e')];if(_0x36ed7b[_0x31b6('0x2f')][_0x31b6('0x3e')]){_0xcd1c0b[_0x31b6('0x3f')]=[{'all':!![]}];}_0xcd1c0b=_[_0x31b6('0x3b')]({},_0xcd1c0b,_0x36ed7b[_0x31b6('0x3d')]);return db[_0x31b6('0x2a')][_0x31b6('0x41')](_0xcd1c0b)['then'](handleEntityNotFound(_0x26e1d7,null))['then'](respondWithResult(_0x26e1d7,null))[_0x31b6('0x40')](handleError(_0x26e1d7,null));};exports['create']=function(_0x31733c,_0x2b3ef1){return db['FaxQueueReport']['create'](_0x31733c['body'],{})['then'](respondWithResult(_0x2b3ef1,0xc9))[_0x31b6('0x40')](handleError(_0x2b3ef1,null));};exports[_0x31b6('0x24')]=function(_0x3fcb59,_0x341f34){if(_0x3fcb59[_0x31b6('0x42')]['id']){delete _0x3fcb59[_0x31b6('0x42')]['id'];}return db[_0x31b6('0x2a')][_0x31b6('0x41')]({'where':{'id':_0x3fcb59['params']['id']}})[_0x31b6('0x25')](handleEntityNotFound(_0x341f34,null))[_0x31b6('0x25')](saveUpdates(_0x3fcb59['body'],null))[_0x31b6('0x25')](respondWithResult(_0x341f34,null))[_0x31b6('0x40')](handleError(_0x341f34,null));};exports['destroy']=function(_0x57a79e,_0x15d73b){return db[_0x31b6('0x2a')][_0x31b6('0x41')]({'where':{'id':_0x57a79e[_0x31b6('0x43')]['id']}})['then'](handleEntityNotFound(_0x15d73b,null))[_0x31b6('0x25')](removeEntity(_0x15d73b,null))[_0x31b6('0x40')](handleError(_0x15d73b,null));};exports[_0x31b6('0x44')]=function(_0x31beb1,_0x4a8576){return db[_0x31b6('0x2a')][_0x31b6('0x44')]()[_0x31b6('0x25')](respondWithResult(_0x4a8576,null))['catch'](handleError(_0x4a8576,null));};