Built motion from commit 2b9af5da.|2.6.26
[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 _0x4f6f=['name','send','map','FaxQueueReport','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','options','includeAll','include','rows','catch','show','merge','find','create','body','params','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','path','sox','ejs','fs-extra','lodash','crypto','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack'];(function(_0x389c7e,_0xc6654f){var _0xda780b=function(_0x1a44f4){while(--_0x1a44f4){_0x389c7e['push'](_0x389c7e['shift']());}};_0xda780b(++_0xc6654f);}(_0x4f6f,0x157));var _0xf4f6=function(_0x6ca7f4,_0x51a5df){_0x6ca7f4=_0x6ca7f4-0x0;var _0x494fa6=_0x4f6f[_0x6ca7f4];return _0x494fa6;};'use strict';var emlformat=require(_0xf4f6('0x0'));var rimraf=require(_0xf4f6('0x1'));var zipdir=require(_0xf4f6('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf4f6('0x3'));var moment=require('moment');var BPromise=require(_0xf4f6('0x4'));var Mustache=require(_0xf4f6('0x5'));var util=require('util');var path=require(_0xf4f6('0x6'));var sox=require(_0xf4f6('0x7'));var csv=require('to-csv');var ejs=require(_0xf4f6('0x8'));var fs=require('fs');var fs_extra=require(_0xf4f6('0x9'));var _=require(_0xf4f6('0xa'));var squel=require('squel');var crypto=require(_0xf4f6('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xf4f6('0xc'));var querystring=require(_0xf4f6('0xd'));var Papa=require(_0xf4f6('0xe'));var Redis=require(_0xf4f6('0xf'));var authService=require(_0xf4f6('0x10'));var qs=require(_0xf4f6('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf4f6('0x12'));var logger=require(_0xf4f6('0x13'))(_0xf4f6('0x14'));var utils=require(_0xf4f6('0x15'));var config=require(_0xf4f6('0x16'));var licenseUtil=require(_0xf4f6('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5ea38b,_0x107046){_0x107046=_0x107046||0xcc;return function(_0x4976f5){if(_0x4976f5){return _0x5ea38b['sendStatus'](_0x107046);}return _0x5ea38b[_0xf4f6('0x18')](_0x107046)[_0xf4f6('0x19')]();};}function respondWithResult(_0x33492d,_0x4e623b){_0x4e623b=_0x4e623b||0xc8;return function(_0x3f314c){if(_0x3f314c){return _0x33492d[_0xf4f6('0x18')](_0x4e623b)[_0xf4f6('0x1a')](_0x3f314c);}};}function respondWithFilteredResult(_0x51c4c3,_0xfdf7ae){return function(_0x5ba4c4){if(_0x5ba4c4){var _0x1f06b6=typeof _0xfdf7ae[_0xf4f6('0x1b')]===_0xf4f6('0x1c')&&typeof _0xfdf7ae['limit']===_0xf4f6('0x1c');var _0x310845=_0x5ba4c4[_0xf4f6('0x1d')];var _0x4e1d2a=_0x1f06b6?0x0:_0xfdf7ae[_0xf4f6('0x1b')];var _0x4cb047=_0x1f06b6?_0x5ba4c4[_0xf4f6('0x1d')]:_0xfdf7ae[_0xf4f6('0x1b')]+_0xfdf7ae[_0xf4f6('0x1e')];var _0x4f0d14;if(_0x4cb047>=_0x310845){_0x4cb047=_0x310845;_0x4f0d14=0xc8;}else{_0x4f0d14=0xce;}_0x51c4c3[_0xf4f6('0x18')](_0x4f0d14);return _0x51c4c3[_0xf4f6('0x1f')](_0xf4f6('0x20'),_0x4e1d2a+'-'+_0x4cb047+'/'+_0x310845)[_0xf4f6('0x1a')](_0x5ba4c4);}return null;};}function patchUpdates(_0x112918){return function(_0x794453){try{jsonpatch[_0xf4f6('0x21')](_0x794453,_0x112918,!![]);}catch(_0x30917b){return BPromise[_0xf4f6('0x22')](_0x30917b);}return _0x794453[_0xf4f6('0x23')]();};}function saveUpdates(_0x3a5e24,_0x4d8497){return function(_0x9148f1){if(_0x9148f1){return _0x9148f1[_0xf4f6('0x24')](_0x3a5e24)[_0xf4f6('0x25')](function(_0x55ac8c){return _0x55ac8c;});}return null;};}function removeEntity(_0x1324f3,_0x45b5fb){return function(_0x5bbc9d){if(_0x5bbc9d){return _0x5bbc9d[_0xf4f6('0x26')]()[_0xf4f6('0x25')](function(){_0x1324f3[_0xf4f6('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x32af7b,_0x224be7){return function(_0x464be1){if(!_0x464be1){_0x32af7b[_0xf4f6('0x27')](0x194);}return _0x464be1;};}function handleError(_0x5f1d69,_0x303e94){_0x303e94=_0x303e94||0x1f4;return function(_0x330ec1){logger[_0xf4f6('0x28')](_0x330ec1[_0xf4f6('0x29')]);if(_0x330ec1[_0xf4f6('0x2a')]){delete _0x330ec1[_0xf4f6('0x2a')];}_0x5f1d69[_0xf4f6('0x18')](_0x303e94)[_0xf4f6('0x2b')](_0x330ec1);};}exports['index']=function(_0x43604d,_0x3fb157){var _0xe13578={},_0x59490b={},_0x3269ac={'count':0x0,'rows':[]};var _0x20faf2=_[_0xf4f6('0x2c')](db[_0xf4f6('0x2d')][_0xf4f6('0x2e')],function(_0x274756){return{'name':_0x274756[_0xf4f6('0x2f')],'type':_0x274756[_0xf4f6('0x30')][_0xf4f6('0x31')]};});_0x59490b['model']=_['map'](_0x20faf2,_0xf4f6('0x2a'));_0x59490b[_0xf4f6('0x32')]=_[_0xf4f6('0x33')](_0x43604d[_0xf4f6('0x32')]);_0x59490b[_0xf4f6('0x34')]=_[_0xf4f6('0x35')](_0x59490b[_0xf4f6('0x36')],_0x59490b[_0xf4f6('0x32')]);_0xe13578[_0xf4f6('0x37')]=_['intersection'](_0x59490b[_0xf4f6('0x36')],qs[_0xf4f6('0x38')](_0x43604d[_0xf4f6('0x32')]['fields']));_0xe13578[_0xf4f6('0x37')]=_0xe13578[_0xf4f6('0x37')][_0xf4f6('0x39')]?_0xe13578[_0xf4f6('0x37')]:_0x59490b[_0xf4f6('0x36')];if(!_0x43604d['query'][_0xf4f6('0x3a')](_0xf4f6('0x3b'))){_0xe13578['limit']=qs[_0xf4f6('0x1e')](_0x43604d[_0xf4f6('0x32')][_0xf4f6('0x1e')]);_0xe13578[_0xf4f6('0x1b')]=qs['offset'](_0x43604d[_0xf4f6('0x32')]['offset']);}_0xe13578[_0xf4f6('0x3c')]=qs[_0xf4f6('0x3d')](_0x43604d[_0xf4f6('0x32')]['sort']);_0xe13578[_0xf4f6('0x3e')]=qs[_0xf4f6('0x34')](_[_0xf4f6('0x3f')](_0x43604d[_0xf4f6('0x32')],_0x59490b['filters']),_0x20faf2);if(_0x43604d[_0xf4f6('0x32')][_0xf4f6('0x40')]){_0xe13578[_0xf4f6('0x3e')]=_['merge'](_0xe13578[_0xf4f6('0x3e')],{'$or':_['map'](_0x20faf2,function(_0x336ef5){if(_0x336ef5[_0xf4f6('0x30')]!==_0xf4f6('0x41')){var _0x4d92ac={};_0x4d92ac[_0x336ef5[_0xf4f6('0x2a')]]={'$like':'%'+_0x43604d[_0xf4f6('0x32')]['filter']+'%'};return _0x4d92ac;}})});}_0xe13578=_['merge']({},_0xe13578,_0x43604d[_0xf4f6('0x42')]);var _0x205fcb={'where':_0xe13578[_0xf4f6('0x3e')]};return db[_0xf4f6('0x2d')][_0xf4f6('0x1d')](_0x205fcb)[_0xf4f6('0x25')](function(_0xaed0b9){_0x3269ac[_0xf4f6('0x1d')]=_0xaed0b9;if(_0x43604d['query'][_0xf4f6('0x43')]){_0xe13578[_0xf4f6('0x44')]=[{'all':!![]}];}return db[_0xf4f6('0x2d')]['findAll'](_0xe13578);})[_0xf4f6('0x25')](function(_0x109f72){_0x3269ac[_0xf4f6('0x45')]=_0x109f72;return _0x3269ac;})['then'](respondWithFilteredResult(_0x3fb157,_0xe13578))[_0xf4f6('0x46')](handleError(_0x3fb157,null));};exports[_0xf4f6('0x47')]=function(_0x5dfd00,_0x1d0f43){var _0x4c4fb1={'raw':!![],'where':{'id':_0x5dfd00['params']['id']}},_0x3e2e13={};_0x3e2e13[_0xf4f6('0x36')]=_[_0xf4f6('0x33')](db[_0xf4f6('0x2d')][_0xf4f6('0x2e')]);_0x3e2e13[_0xf4f6('0x32')]=_[_0xf4f6('0x33')](_0x5dfd00[_0xf4f6('0x32')]);_0x3e2e13[_0xf4f6('0x34')]=_[_0xf4f6('0x35')](_0x3e2e13[_0xf4f6('0x36')],_0x3e2e13[_0xf4f6('0x32')]);_0x4c4fb1[_0xf4f6('0x37')]=_[_0xf4f6('0x35')](_0x3e2e13[_0xf4f6('0x36')],qs['fields'](_0x5dfd00['query']['fields']));_0x4c4fb1[_0xf4f6('0x37')]=_0x4c4fb1[_0xf4f6('0x37')]['length']?_0x4c4fb1[_0xf4f6('0x37')]:_0x3e2e13['model'];if(_0x5dfd00[_0xf4f6('0x32')][_0xf4f6('0x43')]){_0x4c4fb1[_0xf4f6('0x44')]=[{'all':!![]}];}_0x4c4fb1=_[_0xf4f6('0x48')]({},_0x4c4fb1,_0x5dfd00[_0xf4f6('0x42')]);return db['FaxQueueReport'][_0xf4f6('0x49')](_0x4c4fb1)['then'](handleEntityNotFound(_0x1d0f43,null))[_0xf4f6('0x25')](respondWithResult(_0x1d0f43,null))[_0xf4f6('0x46')](handleError(_0x1d0f43,null));};exports['create']=function(_0x42915a,_0x36ad82){return db[_0xf4f6('0x2d')][_0xf4f6('0x4a')](_0x42915a['body'],{})[_0xf4f6('0x25')](respondWithResult(_0x36ad82,0xc9))['catch'](handleError(_0x36ad82,null));};exports[_0xf4f6('0x24')]=function(_0x1c7fb2,_0x23124a){if(_0x1c7fb2['body']['id']){delete _0x1c7fb2['body']['id'];}return db[_0xf4f6('0x2d')][_0xf4f6('0x49')]({'where':{'id':_0x1c7fb2['params']['id']}})[_0xf4f6('0x25')](handleEntityNotFound(_0x23124a,null))['then'](saveUpdates(_0x1c7fb2[_0xf4f6('0x4b')],null))[_0xf4f6('0x25')](respondWithResult(_0x23124a,null))[_0xf4f6('0x46')](handleError(_0x23124a,null));};exports[_0xf4f6('0x26')]=function(_0x195f3e,_0x37480f){return db[_0xf4f6('0x2d')][_0xf4f6('0x49')]({'where':{'id':_0x195f3e[_0xf4f6('0x4c')]['id']}})['then'](handleEntityNotFound(_0x37480f,null))[_0xf4f6('0x25')](removeEntity(_0x37480f,null))[_0xf4f6('0x46')](handleError(_0x37480f,null));};exports['describe']=function(_0x4fb5b9,_0x12aa7b){return db[_0xf4f6('0x2d')]['describe']()['then'](respondWithResult(_0x12aa7b,null))['catch'](handleError(_0x12aa7b,null));};