Built motion from commit (unavailable).|2.5.15
[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 _0xf360=['sort','filters','filter','where','merge','count','FaxTransferReport','findAll','rows','catch','show','params','includeAll','options','create','body','find','describe','html-pdf','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','status','end','json','offset','set','Content-Range','then','destroy','error','stack','name','index','map','rawAttributes','fieldName','type','key','query','keys','model','attributes','intersection','length','hasOwnProperty','nolimit','limit','order'];(function(_0x57e18a,_0x199383){var _0x1181c7=function(_0x2503e8){while(--_0x2503e8){_0x57e18a['push'](_0x57e18a['shift']());}};_0x1181c7(++_0x199383);}(_0xf360,0x9e));var _0x0f36=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0xf360[_0x17d9e3];return _0x14192d;};'use strict';var pdf=require(_0x0f36('0x0'));var emlformat=require(_0x0f36('0x1'));var rimraf=require(_0x0f36('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0f36('0x3'));var rp=require('request-promise');var moment=require(_0x0f36('0x4'));var BPromise=require(_0x0f36('0x5'));var Mustache=require(_0x0f36('0x6'));var util=require('util');var path=require(_0x0f36('0x7'));var sox=require(_0x0f36('0x8'));var csv=require(_0x0f36('0x9'));var ejs=require(_0x0f36('0xa'));var fs=require('fs');var _=require(_0x0f36('0xb'));var squel=require(_0x0f36('0xc'));var crypto=require(_0x0f36('0xd'));var jsforce=require(_0x0f36('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x0f36('0x9'));var querystring=require(_0x0f36('0xf'));var Papa=require(_0x0f36('0x10'));var Redis=require(_0x0f36('0x11'));var authService=require(_0x0f36('0x12'));var qs=require(_0x0f36('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0f36('0x14'));var logger=require(_0x0f36('0x15'))(_0x0f36('0x16'));var utils=require('../../config/utils');var config=require(_0x0f36('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x478313,_0xea1040){_0xea1040=_0xea1040||0xcc;return function(_0x4e30cc){if(_0x4e30cc){return _0x478313[_0x0f36('0x18')](_0xea1040);}return _0x478313[_0x0f36('0x19')](_0xea1040)[_0x0f36('0x1a')]();};}function respondWithResult(_0xb021c,_0x5dee19){_0x5dee19=_0x5dee19||0xc8;return function(_0x1a06cc){if(_0x1a06cc){return _0xb021c['status'](_0x5dee19)[_0x0f36('0x1b')](_0x1a06cc);}};}function respondWithFilteredResult(_0x19afe8,_0x420baf){return function(_0x38e64a){if(_0x38e64a){var _0x167825=_0x38e64a['count'],_0x41a800=_0x420baf[_0x0f36('0x1c')],_0x3c3b06=_0x420baf[_0x0f36('0x1c')]+_0x420baf['limit'],_0x486739;if(_0x3c3b06>=_0x167825){_0x3c3b06=_0x167825;_0x486739=0xc8;}else{_0x486739=0xce;}_0x19afe8['status'](_0x486739);return _0x19afe8[_0x0f36('0x1d')](_0x0f36('0x1e'),_0x41a800+'-'+_0x3c3b06+'/'+_0x167825)['json'](_0x38e64a);}return null;};}function patchUpdates(_0x3d1fb9){return function(_0x28eaf2){try{jsonpatch['apply'](_0x28eaf2,_0x3d1fb9,!![]);}catch(_0x3349c8){return BPromise['reject'](_0x3349c8);}return _0x28eaf2['save']();};}function saveUpdates(_0x2f7972,_0x1b365a){return function(_0x47cfe8){if(_0x47cfe8){return _0x47cfe8['update'](_0x2f7972)[_0x0f36('0x1f')](function(_0x3c6902){return _0x3c6902;});}return null;};}function removeEntity(_0x5c15d9,_0x249b7a){return function(_0x567814){if(_0x567814){return _0x567814[_0x0f36('0x20')]()['then'](function(){_0x5c15d9[_0x0f36('0x19')](0xcc)[_0x0f36('0x1a')]();});}};}function handleEntityNotFound(_0x15722f,_0x552d90){return function(_0x44c08d){if(!_0x44c08d){_0x15722f[_0x0f36('0x18')](0x194);}return _0x44c08d;};}function handleError(_0x1e87c9,_0x57ea00){_0x57ea00=_0x57ea00||0x1f4;return function(_0x2e7ee5){logger[_0x0f36('0x21')](_0x2e7ee5[_0x0f36('0x22')]);if(_0x2e7ee5[_0x0f36('0x23')]){delete _0x2e7ee5['name'];}_0x1e87c9[_0x0f36('0x19')](_0x57ea00)['send'](_0x2e7ee5);};}exports[_0x0f36('0x24')]=function(_0x481492,_0x186527){var _0x3b8385={},_0x42ed91={},_0x40ca49={'count':0x0,'rows':[]};var _0x4ad99d=_[_0x0f36('0x25')](db['FaxTransferReport'][_0x0f36('0x26')],function(_0x438e29){return{'name':_0x438e29[_0x0f36('0x27')],'type':_0x438e29[_0x0f36('0x28')][_0x0f36('0x29')]};});_0x42ed91['model']=_[_0x0f36('0x25')](_0x4ad99d,_0x0f36('0x23'));_0x42ed91[_0x0f36('0x2a')]=_[_0x0f36('0x2b')](_0x481492[_0x0f36('0x2a')]);_0x42ed91['filters']=_['intersection'](_0x42ed91[_0x0f36('0x2c')],_0x42ed91[_0x0f36('0x2a')]);_0x3b8385[_0x0f36('0x2d')]=_[_0x0f36('0x2e')](_0x42ed91[_0x0f36('0x2c')],qs['fields'](_0x481492[_0x0f36('0x2a')]['fields']));_0x3b8385[_0x0f36('0x2d')]=_0x3b8385['attributes'][_0x0f36('0x2f')]?_0x3b8385['attributes']:_0x42ed91[_0x0f36('0x2c')];if(!_0x481492[_0x0f36('0x2a')][_0x0f36('0x30')](_0x0f36('0x31'))){_0x3b8385[_0x0f36('0x32')]=qs[_0x0f36('0x32')](_0x481492[_0x0f36('0x2a')][_0x0f36('0x32')]);_0x3b8385[_0x0f36('0x1c')]=qs[_0x0f36('0x1c')](_0x481492[_0x0f36('0x2a')][_0x0f36('0x1c')]);}_0x3b8385[_0x0f36('0x33')]=qs[_0x0f36('0x34')](_0x481492[_0x0f36('0x2a')][_0x0f36('0x34')]);_0x3b8385['where']=qs[_0x0f36('0x35')](_['pick'](_0x481492[_0x0f36('0x2a')],_0x42ed91[_0x0f36('0x35')]),_0x4ad99d);if(_0x481492['query'][_0x0f36('0x36')]){_0x3b8385[_0x0f36('0x37')]=_['merge'](_0x3b8385[_0x0f36('0x37')],{'$or':_[_0x0f36('0x25')](_0x4ad99d,function(_0x678ef2){if(_0x678ef2['type']!=='VIRTUAL'){var _0x318720={};_0x318720[_0x678ef2[_0x0f36('0x23')]]={'$like':'%'+_0x481492[_0x0f36('0x2a')][_0x0f36('0x36')]+'%'};return _0x318720;}})});}_0x3b8385=_[_0x0f36('0x38')]({},_0x3b8385,_0x481492['options']);var _0x11bfa8={'where':_0x3b8385['where']};return db['FaxTransferReport'][_0x0f36('0x39')](_0x11bfa8)['then'](function(_0x415807){_0x40ca49[_0x0f36('0x39')]=_0x415807;if(_0x481492['query']['includeAll']){_0x3b8385['include']=[{'all':!![]}];}return db[_0x0f36('0x3a')][_0x0f36('0x3b')](_0x3b8385);})[_0x0f36('0x1f')](function(_0x11536f){_0x40ca49[_0x0f36('0x3c')]=_0x11536f;return _0x40ca49;})[_0x0f36('0x1f')](respondWithFilteredResult(_0x186527,_0x3b8385))[_0x0f36('0x3d')](handleError(_0x186527,null));};exports[_0x0f36('0x3e')]=function(_0x4a8303,_0x25a8ef){var _0x474752={'raw':!![],'where':{'id':_0x4a8303[_0x0f36('0x3f')]['id']}},_0x4cc917={};_0x4cc917[_0x0f36('0x2c')]=_['keys'](db[_0x0f36('0x3a')][_0x0f36('0x26')]);_0x4cc917[_0x0f36('0x2a')]=_['keys'](_0x4a8303[_0x0f36('0x2a')]);_0x4cc917[_0x0f36('0x35')]=_['intersection'](_0x4cc917[_0x0f36('0x2c')],_0x4cc917[_0x0f36('0x2a')]);_0x474752[_0x0f36('0x2d')]=_[_0x0f36('0x2e')](_0x4cc917[_0x0f36('0x2c')],qs['fields'](_0x4a8303['query']['fields']));_0x474752['attributes']=_0x474752[_0x0f36('0x2d')][_0x0f36('0x2f')]?_0x474752['attributes']:_0x4cc917[_0x0f36('0x2c')];if(_0x4a8303[_0x0f36('0x2a')][_0x0f36('0x40')]){_0x474752['include']=[{'all':!![]}];}_0x474752=_['merge']({},_0x474752,_0x4a8303[_0x0f36('0x41')]);return db[_0x0f36('0x3a')]['find'](_0x474752)[_0x0f36('0x1f')](handleEntityNotFound(_0x25a8ef,null))['then'](respondWithResult(_0x25a8ef,null))[_0x0f36('0x3d')](handleError(_0x25a8ef,null));};exports[_0x0f36('0x42')]=function(_0x168c49,_0x501fee){return db['FaxTransferReport'][_0x0f36('0x42')](_0x168c49[_0x0f36('0x43')],{})[_0x0f36('0x1f')](respondWithResult(_0x501fee,0xc9))['catch'](handleError(_0x501fee,null));};exports['update']=function(_0x2895c0,_0x4174ab){if(_0x2895c0[_0x0f36('0x43')]['id']){delete _0x2895c0[_0x0f36('0x43')]['id'];}return db['FaxTransferReport'][_0x0f36('0x44')]({'where':{'id':_0x2895c0[_0x0f36('0x3f')]['id']}})[_0x0f36('0x1f')](handleEntityNotFound(_0x4174ab,null))[_0x0f36('0x1f')](saveUpdates(_0x2895c0[_0x0f36('0x43')],null))[_0x0f36('0x1f')](respondWithResult(_0x4174ab,null))[_0x0f36('0x3d')](handleError(_0x4174ab,null));};exports['destroy']=function(_0x43d75f,_0x520f74){return db[_0x0f36('0x3a')][_0x0f36('0x44')]({'where':{'id':_0x43d75f[_0x0f36('0x3f')]['id']}})[_0x0f36('0x1f')](handleEntityNotFound(_0x520f74,null))[_0x0f36('0x1f')](removeEntity(_0x520f74,null))[_0x0f36('0x3d')](handleError(_0x520f74,null));};exports['describe']=function(_0x2fcf62,_0x5ec7b6){return db[_0x0f36('0x3a')][_0x0f36('0x45')]()[_0x0f36('0x1f')](respondWithResult(_0x5ec7b6,null))[_0x0f36('0x3d')](handleError(_0x5ec7b6,null));};