Built motion from commit d6d69adf.|2.6.33
[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 _0xf996=['limit','set','Content-Range','reject','save','update','then','destroy','stack','name','send','map','FaxQueueReport','rawAttributes','fieldName','type','query','keys','filters','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','includeAll','include','findAll','catch','options','find','create','body','params','describe','eml-format','rimraf','zip-dir','request-promise','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','status','end','json','offset','undefined','count'];(function(_0x1f5458,_0x3d32a0){var _0x5d05b6=function(_0x1ffa32){while(--_0x1ffa32){_0x1f5458['push'](_0x1f5458['shift']());}};_0x5d05b6(++_0x3d32a0);}(_0xf996,0x74));var _0x6f99=function(_0xdad312,_0x46fdb7){_0xdad312=_0xdad312-0x0;var _0x196872=_0xf996[_0xdad312];return _0x196872;};'use strict';var emlformat=require(_0x6f99('0x0'));var rimraf=require(_0x6f99('0x1'));var zipdir=require(_0x6f99('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6f99('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x6f99('0x4'));var util=require(_0x6f99('0x5'));var path=require(_0x6f99('0x6'));var sox=require(_0x6f99('0x7'));var csv=require(_0x6f99('0x8'));var ejs=require(_0x6f99('0x9'));var fs=require('fs');var fs_extra=require(_0x6f99('0xa'));var _=require(_0x6f99('0xb'));var squel=require(_0x6f99('0xc'));var crypto=require(_0x6f99('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x6f99('0xe'));var toCsv=require('to-csv');var querystring=require(_0x6f99('0xf'));var Papa=require(_0x6f99('0x10'));var Redis=require(_0x6f99('0x11'));var authService=require(_0x6f99('0x12'));var qs=require(_0x6f99('0x13'));var as=require(_0x6f99('0x14'));var hardwareService=require(_0x6f99('0x15'));var logger=require(_0x6f99('0x16'))(_0x6f99('0x17'));var utils=require('../../config/utils');var config=require(_0x6f99('0x18'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x55e7f0,_0x12081d){_0x12081d=_0x12081d||0xcc;return function(_0xa1af95){if(_0xa1af95){return _0x55e7f0[_0x6f99('0x19')](_0x12081d);}return _0x55e7f0[_0x6f99('0x1a')](_0x12081d)[_0x6f99('0x1b')]();};}function respondWithResult(_0x7aea00,_0xf5d4df){_0xf5d4df=_0xf5d4df||0xc8;return function(_0xb9874a){if(_0xb9874a){return _0x7aea00[_0x6f99('0x1a')](_0xf5d4df)[_0x6f99('0x1c')](_0xb9874a);}};}function respondWithFilteredResult(_0x1534e9,_0x1c7733){return function(_0x537f3d){if(_0x537f3d){var _0x293937=typeof _0x1c7733[_0x6f99('0x1d')]==='undefined'&&typeof _0x1c7733['limit']===_0x6f99('0x1e');var _0x5b3638=_0x537f3d[_0x6f99('0x1f')];var _0x210360=_0x293937?0x0:_0x1c7733[_0x6f99('0x1d')];var _0x25d50b=_0x293937?_0x537f3d[_0x6f99('0x1f')]:_0x1c7733['offset']+_0x1c7733[_0x6f99('0x20')];var _0x5377cb;if(_0x25d50b>=_0x5b3638){_0x25d50b=_0x5b3638;_0x5377cb=0xc8;}else{_0x5377cb=0xce;}_0x1534e9[_0x6f99('0x1a')](_0x5377cb);return _0x1534e9[_0x6f99('0x21')](_0x6f99('0x22'),_0x210360+'-'+_0x25d50b+'/'+_0x5b3638)[_0x6f99('0x1c')](_0x537f3d);}return null;};}function patchUpdates(_0x1dc9e5){return function(_0xf66bde){try{jsonpatch['apply'](_0xf66bde,_0x1dc9e5,!![]);}catch(_0x4c4d00){return BPromise[_0x6f99('0x23')](_0x4c4d00);}return _0xf66bde[_0x6f99('0x24')]();};}function saveUpdates(_0x4974ff,_0x497fd7){return function(_0x1d4dc3){if(_0x1d4dc3){return _0x1d4dc3[_0x6f99('0x25')](_0x4974ff)[_0x6f99('0x26')](function(_0xe3e6ab){return _0xe3e6ab;});}return null;};}function removeEntity(_0x290c88,_0x1174a2){return function(_0x2e7b94){if(_0x2e7b94){return _0x2e7b94[_0x6f99('0x27')]()[_0x6f99('0x26')](function(){_0x290c88[_0x6f99('0x1a')](0xcc)[_0x6f99('0x1b')]();});}};}function handleEntityNotFound(_0x1f8078,_0x21a5c8){return function(_0x381e92){if(!_0x381e92){_0x1f8078['sendStatus'](0x194);}return _0x381e92;};}function handleError(_0x1aff24,_0x201070){_0x201070=_0x201070||0x1f4;return function(_0x4c9572){logger['error'](_0x4c9572[_0x6f99('0x28')]);if(_0x4c9572[_0x6f99('0x29')]){delete _0x4c9572['name'];}_0x1aff24[_0x6f99('0x1a')](_0x201070)[_0x6f99('0x2a')](_0x4c9572);};}exports['index']=function(_0x45fe22,_0x3c1012){var _0x513519={},_0x21eb46={},_0x3ef6c5={'count':0x0,'rows':[]};var _0x5e10e2=_[_0x6f99('0x2b')](db[_0x6f99('0x2c')][_0x6f99('0x2d')],function(_0x4aa40c){return{'name':_0x4aa40c[_0x6f99('0x2e')],'type':_0x4aa40c[_0x6f99('0x2f')]['key']};});_0x21eb46['model']=_[_0x6f99('0x2b')](_0x5e10e2,_0x6f99('0x29'));_0x21eb46[_0x6f99('0x30')]=_[_0x6f99('0x31')](_0x45fe22[_0x6f99('0x30')]);_0x21eb46[_0x6f99('0x32')]=_['intersection'](_0x21eb46['model'],_0x21eb46[_0x6f99('0x30')]);_0x513519[_0x6f99('0x33')]=_[_0x6f99('0x34')](_0x21eb46[_0x6f99('0x35')],qs[_0x6f99('0x36')](_0x45fe22[_0x6f99('0x30')][_0x6f99('0x36')]));_0x513519[_0x6f99('0x33')]=_0x513519[_0x6f99('0x33')][_0x6f99('0x37')]?_0x513519[_0x6f99('0x33')]:_0x21eb46['model'];if(!_0x45fe22[_0x6f99('0x30')][_0x6f99('0x38')](_0x6f99('0x39'))){_0x513519[_0x6f99('0x20')]=qs[_0x6f99('0x20')](_0x45fe22['query'][_0x6f99('0x20')]);_0x513519[_0x6f99('0x1d')]=qs['offset'](_0x45fe22[_0x6f99('0x30')][_0x6f99('0x1d')]);}_0x513519[_0x6f99('0x3a')]=qs[_0x6f99('0x3b')](_0x45fe22[_0x6f99('0x30')][_0x6f99('0x3b')]);_0x513519[_0x6f99('0x3c')]=qs[_0x6f99('0x32')](_['pick'](_0x45fe22[_0x6f99('0x30')],_0x21eb46['filters']),_0x5e10e2);if(_0x45fe22[_0x6f99('0x30')][_0x6f99('0x3d')]){_0x513519[_0x6f99('0x3c')]=_[_0x6f99('0x3e')](_0x513519['where'],{'$or':_[_0x6f99('0x2b')](_0x5e10e2,function(_0x4ee7ce){if(_0x4ee7ce[_0x6f99('0x2f')]!==_0x6f99('0x3f')){var _0x2c26a1={};_0x2c26a1[_0x4ee7ce[_0x6f99('0x29')]]={'$like':'%'+_0x45fe22[_0x6f99('0x30')][_0x6f99('0x3d')]+'%'};return _0x2c26a1;}})});}_0x513519=_[_0x6f99('0x3e')]({},_0x513519,_0x45fe22['options']);var _0x35fb0a={'where':_0x513519[_0x6f99('0x3c')]};return db[_0x6f99('0x2c')]['count'](_0x35fb0a)[_0x6f99('0x26')](function(_0x327e98){_0x3ef6c5[_0x6f99('0x1f')]=_0x327e98;if(_0x45fe22[_0x6f99('0x30')][_0x6f99('0x40')]){_0x513519[_0x6f99('0x41')]=[{'all':!![]}];}return db[_0x6f99('0x2c')][_0x6f99('0x42')](_0x513519);})['then'](function(_0x206bc8){_0x3ef6c5['rows']=_0x206bc8;return _0x3ef6c5;})[_0x6f99('0x26')](respondWithFilteredResult(_0x3c1012,_0x513519))[_0x6f99('0x43')](handleError(_0x3c1012,null));};exports['show']=function(_0x26e091,_0x27ae7f){var _0x1934c4={'raw':!![],'where':{'id':_0x26e091['params']['id']}},_0x1fd388={};_0x1fd388[_0x6f99('0x35')]=_[_0x6f99('0x31')](db[_0x6f99('0x2c')]['rawAttributes']);_0x1fd388[_0x6f99('0x30')]=_[_0x6f99('0x31')](_0x26e091[_0x6f99('0x30')]);_0x1fd388[_0x6f99('0x32')]=_[_0x6f99('0x34')](_0x1fd388[_0x6f99('0x35')],_0x1fd388[_0x6f99('0x30')]);_0x1934c4[_0x6f99('0x33')]=_['intersection'](_0x1fd388[_0x6f99('0x35')],qs['fields'](_0x26e091[_0x6f99('0x30')]['fields']));_0x1934c4[_0x6f99('0x33')]=_0x1934c4[_0x6f99('0x33')][_0x6f99('0x37')]?_0x1934c4[_0x6f99('0x33')]:_0x1fd388[_0x6f99('0x35')];if(_0x26e091[_0x6f99('0x30')][_0x6f99('0x40')]){_0x1934c4['include']=[{'all':!![]}];}_0x1934c4=_[_0x6f99('0x3e')]({},_0x1934c4,_0x26e091[_0x6f99('0x44')]);return db['FaxQueueReport'][_0x6f99('0x45')](_0x1934c4)[_0x6f99('0x26')](handleEntityNotFound(_0x27ae7f,null))[_0x6f99('0x26')](respondWithResult(_0x27ae7f,null))[_0x6f99('0x43')](handleError(_0x27ae7f,null));};exports[_0x6f99('0x46')]=function(_0x51fd93,_0x118e87){return db[_0x6f99('0x2c')][_0x6f99('0x46')](_0x51fd93[_0x6f99('0x47')],{})[_0x6f99('0x26')](respondWithResult(_0x118e87,0xc9))[_0x6f99('0x43')](handleError(_0x118e87,null));};exports[_0x6f99('0x25')]=function(_0x20c80d,_0x2c6cd8){if(_0x20c80d[_0x6f99('0x47')]['id']){delete _0x20c80d[_0x6f99('0x47')]['id'];}return db[_0x6f99('0x2c')]['find']({'where':{'id':_0x20c80d[_0x6f99('0x48')]['id']}})[_0x6f99('0x26')](handleEntityNotFound(_0x2c6cd8,null))[_0x6f99('0x26')](saveUpdates(_0x20c80d[_0x6f99('0x47')],null))[_0x6f99('0x26')](respondWithResult(_0x2c6cd8,null))[_0x6f99('0x43')](handleError(_0x2c6cd8,null));};exports['destroy']=function(_0x321944,_0x2ee25e){return db['FaxQueueReport'][_0x6f99('0x45')]({'where':{'id':_0x321944[_0x6f99('0x48')]['id']}})[_0x6f99('0x26')](handleEntityNotFound(_0x2ee25e,null))[_0x6f99('0x26')](removeEntity(_0x2ee25e,null))[_0x6f99('0x43')](handleError(_0x2ee25e,null));};exports['describe']=function(_0x572aea,_0x3d82c4){return db['FaxQueueReport'][_0x6f99('0x49')]()[_0x6f99('0x26')](respondWithResult(_0x3d82c4,null))[_0x6f99('0x43')](handleError(_0x3d82c4,null));};