Built motion from commit (unavailable).|2.5.6
[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 _0x7f81=['end','status','count','offset','set','apply','reject','save','update','destroy','then','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','nolimit','limit','sort','filter','merge','where','VIRTUAL','options','includeAll','FaxQueueReport','findAll','rows','show','filtears','length','include','find','catch','create','body','params','describe','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus'];(function(_0x16d442,_0x482943){var _0xe372ae=function(_0x42fa35){while(--_0x42fa35){_0x16d442['push'](_0x16d442['shift']());}};_0xe372ae(++_0x482943);}(_0x7f81,0x1a9));var _0x17f8=function(_0x2eb7b1,_0x2da97c){_0x2eb7b1=_0x2eb7b1-0x0;var _0x361934=_0x7f81[_0x2eb7b1];return _0x361934;};'use strict';var pdf=require(_0x17f8('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x17f8('0x1'));var zipdir=require(_0x17f8('0x2'));var jsonpatch=require(_0x17f8('0x3'));var rp=require(_0x17f8('0x4'));var moment=require(_0x17f8('0x5'));var BPromise=require(_0x17f8('0x6'));var Mustache=require(_0x17f8('0x7'));var util=require(_0x17f8('0x8'));var path=require(_0x17f8('0x9'));var sox=require(_0x17f8('0xa'));var csv=require(_0x17f8('0xb'));var ejs=require(_0x17f8('0xc'));var fs=require('fs');var _=require('lodash');var squel=require(_0x17f8('0xd'));var crypto=require('crypto');var jsforce=require(_0x17f8('0xe'));var deskjs=require(_0x17f8('0xf'));var toCsv=require(_0x17f8('0xb'));var querystring=require(_0x17f8('0x10'));var Papa=require('papaparse');var Redis=require(_0x17f8('0x11'));var authService=require(_0x17f8('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x17f8('0x13'))('api');var utils=require(_0x17f8('0x14'));var config=require(_0x17f8('0x15'));var licenseUtil=require(_0x17f8('0x16'));var db=require(_0x17f8('0x17'))['db'];function respondWithStatusCode(_0x4b557a,_0x4982d5){_0x4982d5=_0x4982d5||0xcc;return function(_0x1aa5db){if(_0x1aa5db){return _0x4b557a[_0x17f8('0x18')](_0x4982d5);}return _0x4b557a['status'](_0x4982d5)[_0x17f8('0x19')]();};}function respondWithResult(_0x13325e,_0x1d327e){_0x1d327e=_0x1d327e||0xc8;return function(_0xfffda8){if(_0xfffda8){return _0x13325e[_0x17f8('0x1a')](_0x1d327e)['json'](_0xfffda8);}};}function respondWithFilteredResult(_0x481342,_0x41e5d7){return function(_0x2646a0){if(_0x2646a0){var _0x3b32b7=_0x2646a0[_0x17f8('0x1b')],_0x5c17d8=_0x41e5d7[_0x17f8('0x1c')],_0x5ab6d9=_0x41e5d7[_0x17f8('0x1c')]+_0x41e5d7['limit'],_0x2f7ad5;if(_0x5ab6d9>=_0x3b32b7){_0x5ab6d9=_0x3b32b7;_0x2f7ad5=0xc8;}else{_0x2f7ad5=0xce;}_0x481342[_0x17f8('0x1a')](_0x2f7ad5);return _0x481342[_0x17f8('0x1d')]('Content-Range',_0x5c17d8+'-'+_0x5ab6d9+'/'+_0x3b32b7)['json'](_0x2646a0);}return null;};}function patchUpdates(_0x59eb5d){return function(_0x9ca37c){try{jsonpatch[_0x17f8('0x1e')](_0x9ca37c,_0x59eb5d,!![]);}catch(_0x106f9d){return BPromise[_0x17f8('0x1f')](_0x106f9d);}return _0x9ca37c[_0x17f8('0x20')]();};}function saveUpdates(_0x2c3a69,_0x218d2d){return function(_0x3d7836){if(_0x3d7836){return _0x3d7836[_0x17f8('0x21')](_0x2c3a69)['then'](function(_0x42e6d3){return _0x42e6d3;});}return null;};}function removeEntity(_0x49e48d,_0x4e8953){return function(_0x14d290){if(_0x14d290){return _0x14d290[_0x17f8('0x22')]()[_0x17f8('0x23')](function(){_0x49e48d[_0x17f8('0x1a')](0xcc)[_0x17f8('0x19')]();});}};}function handleEntityNotFound(_0x1adc7c,_0x553820){return function(_0x13e456){if(!_0x13e456){_0x1adc7c[_0x17f8('0x18')](0x194);}return _0x13e456;};}function handleError(_0x571641,_0x457177){_0x457177=_0x457177||0x1f4;return function(_0x3f8ea8){logger[_0x17f8('0x24')](_0x3f8ea8[_0x17f8('0x25')]);if(_0x3f8ea8[_0x17f8('0x26')]){delete _0x3f8ea8[_0x17f8('0x26')];}_0x571641['status'](_0x457177)[_0x17f8('0x27')](_0x3f8ea8);};}exports[_0x17f8('0x28')]=function(_0x52e101,_0x1c8ec9){var _0x154c3a={},_0x43b206={},_0x543d7c={'count':0x0,'rows':[]};var _0x3ca1f2=_[_0x17f8('0x29')](db['FaxQueueReport'][_0x17f8('0x2a')],function(_0x5108a7){return{'name':_0x5108a7[_0x17f8('0x2b')],'type':_0x5108a7[_0x17f8('0x2c')][_0x17f8('0x2d')]};});_0x43b206[_0x17f8('0x2e')]=_[_0x17f8('0x29')](_0x3ca1f2,_0x17f8('0x26'));_0x43b206['query']=_[_0x17f8('0x2f')](_0x52e101[_0x17f8('0x30')]);_0x43b206[_0x17f8('0x31')]=_['intersection'](_0x43b206['model'],_0x43b206['query']);_0x154c3a[_0x17f8('0x32')]=_[_0x17f8('0x33')](_0x43b206['model'],qs[_0x17f8('0x34')](_0x52e101[_0x17f8('0x30')][_0x17f8('0x34')]));_0x154c3a[_0x17f8('0x32')]=_0x154c3a[_0x17f8('0x32')]['length']?_0x154c3a[_0x17f8('0x32')]:_0x43b206[_0x17f8('0x2e')];if(!_0x52e101['query']['hasOwnProperty'](_0x17f8('0x35'))){_0x154c3a[_0x17f8('0x36')]=qs[_0x17f8('0x36')](_0x52e101['query'][_0x17f8('0x36')]);_0x154c3a[_0x17f8('0x1c')]=qs[_0x17f8('0x1c')](_0x52e101[_0x17f8('0x30')]['offset']);}_0x154c3a['order']=qs['sort'](_0x52e101[_0x17f8('0x30')][_0x17f8('0x37')]);_0x154c3a['where']=qs[_0x17f8('0x31')](_['pick'](_0x52e101[_0x17f8('0x30')],_0x43b206[_0x17f8('0x31')]),_0x3ca1f2);if(_0x52e101[_0x17f8('0x30')][_0x17f8('0x38')]){_0x154c3a['where']=_[_0x17f8('0x39')](_0x154c3a[_0x17f8('0x3a')],{'$or':_['map'](_0x3ca1f2,function(_0x42e513){if(_0x42e513[_0x17f8('0x2c')]!==_0x17f8('0x3b')){var _0x1af720={};_0x1af720[_0x42e513['name']]={'$like':'%'+_0x52e101[_0x17f8('0x30')][_0x17f8('0x38')]+'%'};return _0x1af720;}})});}_0x154c3a=_[_0x17f8('0x39')]({},_0x154c3a,_0x52e101[_0x17f8('0x3c')]);var _0x30d5b7={'where':_0x154c3a[_0x17f8('0x3a')]};return db['FaxQueueReport'][_0x17f8('0x1b')](_0x30d5b7)['then'](function(_0x4af801){_0x543d7c['count']=_0x4af801;if(_0x52e101[_0x17f8('0x30')][_0x17f8('0x3d')]){_0x154c3a['include']=[{'all':!![]}];}return db[_0x17f8('0x3e')][_0x17f8('0x3f')](_0x154c3a);})[_0x17f8('0x23')](function(_0x2f47c7){_0x543d7c[_0x17f8('0x40')]=_0x2f47c7;return _0x543d7c;})[_0x17f8('0x23')](respondWithFilteredResult(_0x1c8ec9,_0x154c3a))['catch'](handleError(_0x1c8ec9,null));};exports[_0x17f8('0x41')]=function(_0x2c414e,_0x3b4b44){var _0x57be1f={'raw':!![],'where':{'id':_0x2c414e['params']['id']}},_0x2d1716={};_0x2d1716[_0x17f8('0x2e')]=_[_0x17f8('0x2f')](db['FaxQueueReport'][_0x17f8('0x2a')]);_0x2d1716['query']=_[_0x17f8('0x2f')](_0x2c414e['query']);_0x2d1716[_0x17f8('0x42')]=_[_0x17f8('0x33')](_0x2d1716[_0x17f8('0x2e')],_0x2d1716[_0x17f8('0x30')]);_0x57be1f[_0x17f8('0x32')]=_[_0x17f8('0x33')](_0x2d1716[_0x17f8('0x2e')],qs[_0x17f8('0x34')](_0x2c414e['query'][_0x17f8('0x34')]));_0x57be1f['attributes']=_0x57be1f[_0x17f8('0x32')][_0x17f8('0x43')]?_0x57be1f[_0x17f8('0x32')]:_0x2d1716[_0x17f8('0x2e')];if(_0x2c414e[_0x17f8('0x30')][_0x17f8('0x3d')]){_0x57be1f[_0x17f8('0x44')]=[{'all':!![]}];}_0x57be1f=_['merge']({},_0x57be1f,_0x2c414e[_0x17f8('0x3c')]);return db['FaxQueueReport'][_0x17f8('0x45')](_0x57be1f)['then'](handleEntityNotFound(_0x3b4b44,null))[_0x17f8('0x23')](respondWithResult(_0x3b4b44,null))[_0x17f8('0x46')](handleError(_0x3b4b44,null));};exports[_0x17f8('0x47')]=function(_0x56d9d3,_0x1891ad){return db[_0x17f8('0x3e')]['create'](_0x56d9d3[_0x17f8('0x48')],{})[_0x17f8('0x23')](respondWithResult(_0x1891ad,0xc9))[_0x17f8('0x46')](handleError(_0x1891ad,null));};exports[_0x17f8('0x21')]=function(_0x26ad4d,_0x707b77){if(_0x26ad4d[_0x17f8('0x48')]['id']){delete _0x26ad4d[_0x17f8('0x48')]['id'];}return db[_0x17f8('0x3e')][_0x17f8('0x45')]({'where':{'id':_0x26ad4d[_0x17f8('0x49')]['id']}})[_0x17f8('0x23')](handleEntityNotFound(_0x707b77,null))[_0x17f8('0x23')](saveUpdates(_0x26ad4d[_0x17f8('0x48')],null))[_0x17f8('0x23')](respondWithResult(_0x707b77,null))['catch'](handleError(_0x707b77,null));};exports[_0x17f8('0x22')]=function(_0x279b64,_0x45d839){return db[_0x17f8('0x3e')][_0x17f8('0x45')]({'where':{'id':_0x279b64[_0x17f8('0x49')]['id']}})[_0x17f8('0x23')](handleEntityNotFound(_0x45d839,null))['then'](removeEntity(_0x45d839,null))[_0x17f8('0x46')](handleError(_0x45d839,null));};exports['describe']=function(_0x2e0ff2,_0x251bab){return db[_0x17f8('0x3e')][_0x17f8('0x4a')]()[_0x17f8('0x23')](respondWithResult(_0x251bab,null))[_0x17f8('0x46')](handleError(_0x251bab,null));};