Built motion from commit (unavailable).|2.4.2
[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 _0x3ace=['hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','field','options','FaxTransferReport','count','includeAll','include','findAll','rows','catch','show','params','length','find','create','body','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','Content-Range','apply','save','update','then','destroy','error','name','send','rawAttributes','model','query','filters','attributes','intersection','fields'];(function(_0x2db667,_0x193cf5){var _0x83ff9=function(_0x5da022){while(--_0x5da022){_0x2db667['push'](_0x2db667['shift']());}};_0x83ff9(++_0x193cf5);}(_0x3ace,0x1d6));var _0xe3ac=function(_0xee3e3f,_0x3e65d1){_0xee3e3f=_0xee3e3f-0x0;var _0x1967b3=_0x3ace[_0xee3e3f];return _0x1967b3;};'use strict';var pdf=require(_0xe3ac('0x0'));var emlformat=require(_0xe3ac('0x1'));var rimraf=require(_0xe3ac('0x2'));var zipdir=require(_0xe3ac('0x3'));var jsonpatch=require(_0xe3ac('0x4'));var rp=require(_0xe3ac('0x5'));var moment=require(_0xe3ac('0x6'));var BPromise=require(_0xe3ac('0x7'));var Mustache=require(_0xe3ac('0x8'));var util=require(_0xe3ac('0x9'));var path=require('path');var sox=require(_0xe3ac('0xa'));var csv=require(_0xe3ac('0xb'));var ejs=require(_0xe3ac('0xc'));var fs=require('fs');var _=require(_0xe3ac('0xd'));var squel=require(_0xe3ac('0xe'));var crypto=require(_0xe3ac('0xf'));var jsforce=require(_0xe3ac('0x10'));var deskjs=require(_0xe3ac('0x11'));var toCsv=require(_0xe3ac('0xb'));var querystring=require(_0xe3ac('0x12'));var Papa=require('papaparse');var Redis=require(_0xe3ac('0x13'));var authService=require('../../components/auth/service');var qs=require(_0xe3ac('0x14'));var hardwareService=require(_0xe3ac('0x15'));var logger=require(_0xe3ac('0x16'))(_0xe3ac('0x17'));var utils=require(_0xe3ac('0x18'));var config=require(_0xe3ac('0x19'));var db=require(_0xe3ac('0x1a'))['db'];function respondWithStatusCode(_0x36d7dc,_0x29d88c){_0x29d88c=_0x29d88c||0xcc;return function(_0xe9ba97){if(_0xe9ba97){return _0x36d7dc[_0xe3ac('0x1b')](_0x29d88c);}return _0x36d7dc[_0xe3ac('0x1c')](_0x29d88c)[_0xe3ac('0x1d')]();};}function respondWithResult(_0x1fdd1f,_0x456b5a){_0x456b5a=_0x456b5a||0xc8;return function(_0x49dd65){if(_0x49dd65){return _0x1fdd1f[_0xe3ac('0x1c')](_0x456b5a)[_0xe3ac('0x1e')](_0x49dd65);}};}function respondWithFilteredResult(_0x3c7fd2,_0xc257e2){return function(_0x49538b){if(_0x49538b){var _0x5f253b=_0x49538b['count'],_0x518332=_0xc257e2['offset'],_0x4c926=_0xc257e2[_0xe3ac('0x1f')]+_0xc257e2['limit'],_0x209b8e;if(_0x4c926>=_0x5f253b){_0x4c926=_0x5f253b;_0x209b8e=0xc8;}else{_0x209b8e=0xce;}_0x3c7fd2['status'](_0x209b8e);return _0x3c7fd2['set'](_0xe3ac('0x20'),_0x518332+'-'+_0x4c926+'/'+_0x5f253b)[_0xe3ac('0x1e')](_0x49538b);}return null;};}function patchUpdates(_0x48945a){return function(_0x4e8ab4){try{jsonpatch[_0xe3ac('0x21')](_0x4e8ab4,_0x48945a,!![]);}catch(_0x3488cc){return BPromise['reject'](_0x3488cc);}return _0x4e8ab4[_0xe3ac('0x22')]();};}function saveUpdates(_0x35f1f3,_0xad8f93){return function(_0x295e58){if(_0x295e58){return _0x295e58[_0xe3ac('0x23')](_0x35f1f3)[_0xe3ac('0x24')](function(_0xf66f09){return _0xf66f09;});}return null;};}function removeEntity(_0x267045,_0x5b00a3){return function(_0x337373){if(_0x337373){return _0x337373[_0xe3ac('0x25')]()[_0xe3ac('0x24')](function(){_0x267045[_0xe3ac('0x1c')](0xcc)[_0xe3ac('0x1d')]();});}};}function handleEntityNotFound(_0x144a83,_0x3ceb96){return function(_0xc4376){if(!_0xc4376){_0x144a83[_0xe3ac('0x1b')](0x194);}return _0xc4376;};}function handleError(_0x3d4e8d,_0x16e208){_0x16e208=_0x16e208||0x1f4;return function(_0x39f085){logger[_0xe3ac('0x26')](_0x39f085['stack']);if(_0x39f085[_0xe3ac('0x27')]){delete _0x39f085[_0xe3ac('0x27')];}_0x3d4e8d[_0xe3ac('0x1c')](_0x16e208)[_0xe3ac('0x28')](_0x39f085);};}exports['index']=function(_0x1a9284,_0x2c5fb9){var _0x1fcb73={},_0x629ec4={},_0x1c266b={'count':0x0,'rows':[]};var _0x4d5c6a=db['FaxTransferReport'][_0xe3ac('0x29')];_0x629ec4[_0xe3ac('0x2a')]=_['keys'](_0x4d5c6a);_0x629ec4[_0xe3ac('0x2b')]=_['keys'](_0x1a9284[_0xe3ac('0x2b')]);_0x629ec4[_0xe3ac('0x2c')]=_['intersection'](_0x629ec4[_0xe3ac('0x2a')],_0x629ec4[_0xe3ac('0x2b')]);_0x1fcb73[_0xe3ac('0x2d')]=_[_0xe3ac('0x2e')](_0x629ec4[_0xe3ac('0x2a')],qs[_0xe3ac('0x2f')](_0x1a9284[_0xe3ac('0x2b')]['fields']));_0x1fcb73[_0xe3ac('0x2d')]=_0x1fcb73[_0xe3ac('0x2d')]['length']?_0x1fcb73[_0xe3ac('0x2d')]:_0x629ec4[_0xe3ac('0x2a')];if(!_0x1a9284[_0xe3ac('0x2b')][_0xe3ac('0x30')](_0xe3ac('0x31'))){_0x1fcb73['limit']=qs['limit'](_0x1a9284[_0xe3ac('0x2b')][_0xe3ac('0x32')]);_0x1fcb73['offset']=qs[_0xe3ac('0x1f')](_0x1a9284[_0xe3ac('0x2b')]['offset']);}_0x1fcb73[_0xe3ac('0x33')]=qs[_0xe3ac('0x34')](_0x1a9284['query'][_0xe3ac('0x34')]);_0x1fcb73[_0xe3ac('0x35')]=qs[_0xe3ac('0x2c')](_[_0xe3ac('0x36')](_0x1a9284[_0xe3ac('0x2b')],_0x629ec4[_0xe3ac('0x2c')]));if(_0x1a9284['query'][_0xe3ac('0x37')]){_0x1fcb73[_0xe3ac('0x35')]=_[_0xe3ac('0x38')](_0x1fcb73[_0xe3ac('0x35')],{'$or':_['map'](_0x4d5c6a,function(_0x1f1ad5){if(_0x1f1ad5['type']['key']!==_0xe3ac('0x39')){var _0x107686={};_0x107686[_0x1f1ad5[_0xe3ac('0x3a')]]={'$like':'%'+_0x1a9284['query'][_0xe3ac('0x37')]+'%'};return _0x107686;}})});}_0x1fcb73=_[_0xe3ac('0x38')]({},_0x1fcb73,_0x1a9284[_0xe3ac('0x3b')]);var _0x137d3e={'where':_0x1fcb73[_0xe3ac('0x35')]};return db[_0xe3ac('0x3c')][_0xe3ac('0x3d')](_0x137d3e)['then'](function(_0x247b6d){_0x1c266b[_0xe3ac('0x3d')]=_0x247b6d;if(_0x1a9284[_0xe3ac('0x2b')][_0xe3ac('0x3e')]){_0x1fcb73[_0xe3ac('0x3f')]=[{'all':!![]}];}return db[_0xe3ac('0x3c')][_0xe3ac('0x40')](_0x1fcb73);})[_0xe3ac('0x24')](function(_0x4938e0){_0x1c266b[_0xe3ac('0x41')]=_0x4938e0;return _0x1c266b;})[_0xe3ac('0x24')](respondWithFilteredResult(_0x2c5fb9,_0x1fcb73))[_0xe3ac('0x42')](handleError(_0x2c5fb9,null));};exports[_0xe3ac('0x43')]=function(_0x1e6279,_0xaf21b5){var _0x331a89={'raw':!![],'where':{'id':_0x1e6279[_0xe3ac('0x44')]['id']}},_0x2c5f7b={};_0x2c5f7b[_0xe3ac('0x2a')]=_['keys'](db[_0xe3ac('0x3c')][_0xe3ac('0x29')]);_0x2c5f7b[_0xe3ac('0x2b')]=_['keys'](_0x1e6279[_0xe3ac('0x2b')]);_0x2c5f7b[_0xe3ac('0x2c')]=_[_0xe3ac('0x2e')](_0x2c5f7b[_0xe3ac('0x2a')],_0x2c5f7b['query']);_0x331a89[_0xe3ac('0x2d')]=_[_0xe3ac('0x2e')](_0x2c5f7b[_0xe3ac('0x2a')],qs['fields'](_0x1e6279[_0xe3ac('0x2b')][_0xe3ac('0x2f')]));_0x331a89[_0xe3ac('0x2d')]=_0x331a89[_0xe3ac('0x2d')][_0xe3ac('0x45')]?_0x331a89['attributes']:_0x2c5f7b[_0xe3ac('0x2a')];if(_0x1e6279['query'][_0xe3ac('0x3e')]){_0x331a89[_0xe3ac('0x3f')]=[{'all':!![]}];}_0x331a89=_[_0xe3ac('0x38')]({},_0x331a89,_0x1e6279[_0xe3ac('0x3b')]);return db[_0xe3ac('0x3c')][_0xe3ac('0x46')](_0x331a89)[_0xe3ac('0x24')](handleEntityNotFound(_0xaf21b5,null))[_0xe3ac('0x24')](respondWithResult(_0xaf21b5,null))[_0xe3ac('0x42')](handleError(_0xaf21b5,null));};exports['create']=function(_0x16390e,_0x3c99bf){return db[_0xe3ac('0x3c')][_0xe3ac('0x47')](_0x16390e[_0xe3ac('0x48')],{})[_0xe3ac('0x24')](respondWithResult(_0x3c99bf,0xc9))[_0xe3ac('0x42')](handleError(_0x3c99bf,null));};exports['update']=function(_0x1034a8,_0x382510){if(_0x1034a8[_0xe3ac('0x48')]['id']){delete _0x1034a8[_0xe3ac('0x48')]['id'];}return db[_0xe3ac('0x3c')][_0xe3ac('0x46')]({'where':{'id':_0x1034a8[_0xe3ac('0x44')]['id']}})[_0xe3ac('0x24')](handleEntityNotFound(_0x382510,null))[_0xe3ac('0x24')](saveUpdates(_0x1034a8[_0xe3ac('0x48')],null))[_0xe3ac('0x24')](respondWithResult(_0x382510,null))[_0xe3ac('0x42')](handleError(_0x382510,null));};exports[_0xe3ac('0x25')]=function(_0xf2bcc0,_0x20b427){return db[_0xe3ac('0x3c')][_0xe3ac('0x46')]({'where':{'id':_0xf2bcc0[_0xe3ac('0x44')]['id']}})[_0xe3ac('0x24')](handleEntityNotFound(_0x20b427,null))['then'](removeEntity(_0x20b427,null))[_0xe3ac('0x42')](handleError(_0x20b427,null));};exports[_0xe3ac('0x49')]=function(_0x46274,_0xbb980a){return db['FaxTransferReport'][_0xe3ac('0x49')]()[_0xe3ac('0x24')](respondWithResult(_0xbb980a,null))['catch'](handleError(_0xbb980a,null));};