Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / faxTransferReport / faxTransferReport.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 _0x15ae=['find','create','body','describe','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','error','stack','name','send','index','map','FaxTransferReport','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','include','rows','catch','show','params','rawAttributes'];(function(_0x13d0b3,_0x120924){var _0x2e4530=function(_0x1d0355){while(--_0x1d0355){_0x13d0b3['push'](_0x13d0b3['shift']());}};_0x2e4530(++_0x120924);}(_0x15ae,0x9e));var _0xe15a=function(_0x302df3,_0x2e359d){_0x302df3=_0x302df3-0x0;var _0x5743ab=_0x15ae[_0x302df3];return _0x5743ab;};'use strict';var emlformat=require(_0xe15a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe15a('0x1'));var jsonpatch=require(_0xe15a('0x2'));var rp=require(_0xe15a('0x3'));var moment=require('moment');var BPromise=require(_0xe15a('0x4'));var Mustache=require(_0xe15a('0x5'));var util=require(_0xe15a('0x6'));var path=require(_0xe15a('0x7'));var sox=require(_0xe15a('0x8'));var csv=require(_0xe15a('0x9'));var ejs=require(_0xe15a('0xa'));var fs=require('fs');var fs_extra=require(_0xe15a('0xb'));var _=require(_0xe15a('0xc'));var squel=require(_0xe15a('0xd'));var crypto=require(_0xe15a('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xe15a('0xf'));var toCsv=require(_0xe15a('0x9'));var querystring=require('querystring');var Papa=require(_0xe15a('0x10'));var Redis=require(_0xe15a('0x11'));var authService=require(_0xe15a('0x12'));var qs=require(_0xe15a('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xe15a('0x14'))(_0xe15a('0x15'));var utils=require('../../config/utils');var config=require(_0xe15a('0x16'));var licenseUtil=require(_0xe15a('0x17'));var db=require(_0xe15a('0x18'))['db'];function respondWithStatusCode(_0x341e6b,_0x486d18){_0x486d18=_0x486d18||0xcc;return function(_0x2952f1){if(_0x2952f1){return _0x341e6b[_0xe15a('0x19')](_0x486d18);}return _0x341e6b[_0xe15a('0x1a')](_0x486d18)[_0xe15a('0x1b')]();};}function respondWithResult(_0x30d7d0,_0x5f4c3d){_0x5f4c3d=_0x5f4c3d||0xc8;return function(_0x238007){if(_0x238007){return _0x30d7d0[_0xe15a('0x1a')](_0x5f4c3d)[_0xe15a('0x1c')](_0x238007);}};}function respondWithFilteredResult(_0x1fd5ce,_0x3694ff){return function(_0x5e6f0e){if(_0x5e6f0e){var _0x542588=typeof _0x3694ff[_0xe15a('0x1d')]===_0xe15a('0x1e')&&typeof _0x3694ff[_0xe15a('0x1f')]===_0xe15a('0x1e');var _0xc88111=_0x5e6f0e[_0xe15a('0x20')];var _0x57cb7f=_0x542588?0x0:_0x3694ff[_0xe15a('0x1d')];var _0x26ef0e=_0x542588?_0x5e6f0e[_0xe15a('0x20')]:_0x3694ff['offset']+_0x3694ff['limit'];var _0x120d44;if(_0x26ef0e>=_0xc88111){_0x26ef0e=_0xc88111;_0x120d44=0xc8;}else{_0x120d44=0xce;}_0x1fd5ce[_0xe15a('0x1a')](_0x120d44);return _0x1fd5ce[_0xe15a('0x21')](_0xe15a('0x22'),_0x57cb7f+'-'+_0x26ef0e+'/'+_0xc88111)[_0xe15a('0x1c')](_0x5e6f0e);}return null;};}function patchUpdates(_0x495100){return function(_0xf34c94){try{jsonpatch[_0xe15a('0x23')](_0xf34c94,_0x495100,!![]);}catch(_0x54461e){return BPromise[_0xe15a('0x24')](_0x54461e);}return _0xf34c94['save']();};}function saveUpdates(_0x435689,_0x54d48c){return function(_0x1bfaaa){if(_0x1bfaaa){return _0x1bfaaa[_0xe15a('0x25')](_0x435689)['then'](function(_0x590e26){return _0x590e26;});}return null;};}function removeEntity(_0x4ea961,_0x118827){return function(_0x4f8bcc){if(_0x4f8bcc){return _0x4f8bcc[_0xe15a('0x26')]()['then'](function(){_0x4ea961[_0xe15a('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2c9fc3,_0x9bc7be){return function(_0x3a5d1d){if(!_0x3a5d1d){_0x2c9fc3[_0xe15a('0x19')](0x194);}return _0x3a5d1d;};}function handleError(_0x52fd22,_0x18d137){_0x18d137=_0x18d137||0x1f4;return function(_0x4d7d55){logger[_0xe15a('0x27')](_0x4d7d55[_0xe15a('0x28')]);if(_0x4d7d55[_0xe15a('0x29')]){delete _0x4d7d55[_0xe15a('0x29')];}_0x52fd22[_0xe15a('0x1a')](_0x18d137)[_0xe15a('0x2a')](_0x4d7d55);};}exports[_0xe15a('0x2b')]=function(_0x11e89b,_0x5e9417){var _0x849c71={},_0xa53bde={},_0x20a837={'count':0x0,'rows':[]};var _0x498516=_[_0xe15a('0x2c')](db[_0xe15a('0x2d')]['rawAttributes'],function(_0x49abe3){return{'name':_0x49abe3['fieldName'],'type':_0x49abe3[_0xe15a('0x2e')][_0xe15a('0x2f')]};});_0xa53bde[_0xe15a('0x30')]=_[_0xe15a('0x2c')](_0x498516,'name');_0xa53bde[_0xe15a('0x31')]=_['keys'](_0x11e89b['query']);_0xa53bde[_0xe15a('0x32')]=_[_0xe15a('0x33')](_0xa53bde[_0xe15a('0x30')],_0xa53bde[_0xe15a('0x31')]);_0x849c71[_0xe15a('0x34')]=_[_0xe15a('0x33')](_0xa53bde[_0xe15a('0x30')],qs[_0xe15a('0x35')](_0x11e89b['query']['fields']));_0x849c71[_0xe15a('0x34')]=_0x849c71[_0xe15a('0x34')][_0xe15a('0x36')]?_0x849c71[_0xe15a('0x34')]:_0xa53bde[_0xe15a('0x30')];if(!_0x11e89b['query'][_0xe15a('0x37')](_0xe15a('0x38'))){_0x849c71['limit']=qs[_0xe15a('0x1f')](_0x11e89b[_0xe15a('0x31')][_0xe15a('0x1f')]);_0x849c71[_0xe15a('0x1d')]=qs['offset'](_0x11e89b[_0xe15a('0x31')][_0xe15a('0x1d')]);}_0x849c71[_0xe15a('0x39')]=qs['sort'](_0x11e89b['query'][_0xe15a('0x3a')]);_0x849c71[_0xe15a('0x3b')]=qs['filters'](_[_0xe15a('0x3c')](_0x11e89b[_0xe15a('0x31')],_0xa53bde[_0xe15a('0x32')]),_0x498516);if(_0x11e89b['query'][_0xe15a('0x3d')]){_0x849c71[_0xe15a('0x3b')]=_[_0xe15a('0x3e')](_0x849c71['where'],{'$or':_[_0xe15a('0x2c')](_0x498516,function(_0x238d35){if(_0x238d35[_0xe15a('0x2e')]!==_0xe15a('0x3f')){var _0x498af2={};_0x498af2[_0x238d35[_0xe15a('0x29')]]={'$like':'%'+_0x11e89b['query'][_0xe15a('0x3d')]+'%'};return _0x498af2;}})});}_0x849c71=_['merge']({},_0x849c71,_0x11e89b[_0xe15a('0x40')]);var _0x1514cc={'where':_0x849c71[_0xe15a('0x3b')]};return db['FaxTransferReport'][_0xe15a('0x20')](_0x1514cc)[_0xe15a('0x41')](function(_0x21ab06){_0x20a837[_0xe15a('0x20')]=_0x21ab06;if(_0x11e89b[_0xe15a('0x31')][_0xe15a('0x42')]){_0x849c71[_0xe15a('0x43')]=[{'all':!![]}];}return db[_0xe15a('0x2d')]['findAll'](_0x849c71);})['then'](function(_0x4c49fa){_0x20a837[_0xe15a('0x44')]=_0x4c49fa;return _0x20a837;})[_0xe15a('0x41')](respondWithFilteredResult(_0x5e9417,_0x849c71))[_0xe15a('0x45')](handleError(_0x5e9417,null));};exports[_0xe15a('0x46')]=function(_0x5c1a0d,_0x165792){var _0x267934={'raw':!![],'where':{'id':_0x5c1a0d[_0xe15a('0x47')]['id']}},_0x43e016={};_0x43e016[_0xe15a('0x30')]=_['keys'](db[_0xe15a('0x2d')][_0xe15a('0x48')]);_0x43e016[_0xe15a('0x31')]=_['keys'](_0x5c1a0d[_0xe15a('0x31')]);_0x43e016[_0xe15a('0x32')]=_[_0xe15a('0x33')](_0x43e016['model'],_0x43e016['query']);_0x267934['attributes']=_[_0xe15a('0x33')](_0x43e016['model'],qs['fields'](_0x5c1a0d[_0xe15a('0x31')]['fields']));_0x267934[_0xe15a('0x34')]=_0x267934[_0xe15a('0x34')][_0xe15a('0x36')]?_0x267934[_0xe15a('0x34')]:_0x43e016[_0xe15a('0x30')];if(_0x5c1a0d[_0xe15a('0x31')]['includeAll']){_0x267934[_0xe15a('0x43')]=[{'all':!![]}];}_0x267934=_[_0xe15a('0x3e')]({},_0x267934,_0x5c1a0d[_0xe15a('0x40')]);return db[_0xe15a('0x2d')][_0xe15a('0x49')](_0x267934)[_0xe15a('0x41')](handleEntityNotFound(_0x165792,null))[_0xe15a('0x41')](respondWithResult(_0x165792,null))[_0xe15a('0x45')](handleError(_0x165792,null));};exports[_0xe15a('0x4a')]=function(_0x4049ef,_0x357f91){return db[_0xe15a('0x2d')]['create'](_0x4049ef['body'],{})[_0xe15a('0x41')](respondWithResult(_0x357f91,0xc9))[_0xe15a('0x45')](handleError(_0x357f91,null));};exports['update']=function(_0x21aaee,_0x529803){if(_0x21aaee[_0xe15a('0x4b')]['id']){delete _0x21aaee[_0xe15a('0x4b')]['id'];}return db[_0xe15a('0x2d')][_0xe15a('0x49')]({'where':{'id':_0x21aaee[_0xe15a('0x47')]['id']}})[_0xe15a('0x41')](handleEntityNotFound(_0x529803,null))[_0xe15a('0x41')](saveUpdates(_0x21aaee[_0xe15a('0x4b')],null))[_0xe15a('0x41')](respondWithResult(_0x529803,null))['catch'](handleError(_0x529803,null));};exports[_0xe15a('0x26')]=function(_0x28253c,_0x4453ee){return db[_0xe15a('0x2d')][_0xe15a('0x49')]({'where':{'id':_0x28253c[_0xe15a('0x47')]['id']}})[_0xe15a('0x41')](handleEntityNotFound(_0x4453ee,null))[_0xe15a('0x41')](removeEntity(_0x4453ee,null))[_0xe15a('0x45')](handleError(_0x4453ee,null));};exports['describe']=function(_0x5acce3,_0x327a56){return db[_0xe15a('0x2d')][_0xe15a('0x4c')]()['then'](respondWithResult(_0x327a56,null))[_0xe15a('0x45')](handleError(_0x327a56,null));};