Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / openchannelTransferReport / openchannelTransferReport.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 _0x707b=['../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','count','offset','limit','set','apply','reject','save','then','destroy','end','sendStatus','error','stack','name','send','index','map','OpenchannelTransferReport','rawAttributes','type','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','include','rows','show','includeAll','find','catch','create','update','body','params','describe','html-pdf','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis'];(function(_0x2eb166,_0xd9613c){var _0x1197d6=function(_0x465ab6){while(--_0x465ab6){_0x2eb166['push'](_0x2eb166['shift']());}};_0x1197d6(++_0xd9613c);}(_0x707b,0x11f));var _0xb707=function(_0x30662f,_0x4d202e){_0x30662f=_0x30662f-0x0;var _0x40d038=_0x707b[_0x30662f];return _0x40d038;};'use strict';var pdf=require(_0xb707('0x0'));var emlformat=require(_0xb707('0x1'));var rimraf=require(_0xb707('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb707('0x3'));var rp=require('request-promise');var moment=require(_0xb707('0x4'));var BPromise=require(_0xb707('0x5'));var Mustache=require(_0xb707('0x6'));var util=require('util');var path=require('path');var sox=require(_0xb707('0x7'));var csv=require('to-csv');var ejs=require(_0xb707('0x8'));var fs=require('fs');var _=require(_0xb707('0x9'));var squel=require(_0xb707('0xa'));var crypto=require(_0xb707('0xb'));var jsforce=require(_0xb707('0xc'));var deskjs=require(_0xb707('0xd'));var toCsv=require(_0xb707('0xe'));var querystring=require('querystring');var Papa=require(_0xb707('0xf'));var Redis=require(_0xb707('0x10'));var authService=require(_0xb707('0x11'));var qs=require(_0xb707('0x12'));var as=require(_0xb707('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xb707('0x14'));var utils=require(_0xb707('0x15'));var config=require(_0xb707('0x16'));var licenseUtil=require(_0xb707('0x17'));var db=require(_0xb707('0x18'))['db'];function respondWithStatusCode(_0xd06556,_0x4fd308){_0x4fd308=_0x4fd308||0xcc;return function(_0x38c8b2){if(_0x38c8b2){return _0xd06556['sendStatus'](_0x4fd308);}return _0xd06556[_0xb707('0x19')](_0x4fd308)['end']();};}function respondWithResult(_0xb0c331,_0x43b846){_0x43b846=_0x43b846||0xc8;return function(_0x372482){if(_0x372482){return _0xb0c331[_0xb707('0x19')](_0x43b846)[_0xb707('0x1a')](_0x372482);}};}function respondWithFilteredResult(_0x1190a3,_0xe8cc93){return function(_0x155dfa){if(_0x155dfa){var _0x1fa0ee=_0x155dfa[_0xb707('0x1b')],_0x54bf60=_0xe8cc93['offset'],_0x591978=_0xe8cc93[_0xb707('0x1c')]+_0xe8cc93[_0xb707('0x1d')],_0x42feab;if(_0x591978>=_0x1fa0ee){_0x591978=_0x1fa0ee;_0x42feab=0xc8;}else{_0x42feab=0xce;}_0x1190a3[_0xb707('0x19')](_0x42feab);return _0x1190a3[_0xb707('0x1e')]('Content-Range',_0x54bf60+'-'+_0x591978+'/'+_0x1fa0ee)[_0xb707('0x1a')](_0x155dfa);}return null;};}function patchUpdates(_0x385a20){return function(_0x5a0f10){try{jsonpatch[_0xb707('0x1f')](_0x5a0f10,_0x385a20,!![]);}catch(_0x22821d){return BPromise[_0xb707('0x20')](_0x22821d);}return _0x5a0f10[_0xb707('0x21')]();};}function saveUpdates(_0x522457,_0x5ddbec){return function(_0x19d1a9){if(_0x19d1a9){return _0x19d1a9['update'](_0x522457)[_0xb707('0x22')](function(_0x20fa6f){return _0x20fa6f;});}return null;};}function removeEntity(_0x2e8eca,_0x34a579){return function(_0x11b40b){if(_0x11b40b){return _0x11b40b[_0xb707('0x23')]()[_0xb707('0x22')](function(){_0x2e8eca['status'](0xcc)[_0xb707('0x24')]();});}};}function handleEntityNotFound(_0x3d38c2,_0x361f8d){return function(_0x3c316b){if(!_0x3c316b){_0x3d38c2[_0xb707('0x25')](0x194);}return _0x3c316b;};}function handleError(_0x36a68b,_0x58719e){_0x58719e=_0x58719e||0x1f4;return function(_0xa463df){logger[_0xb707('0x26')](_0xa463df[_0xb707('0x27')]);if(_0xa463df[_0xb707('0x28')]){delete _0xa463df[_0xb707('0x28')];}_0x36a68b['status'](_0x58719e)[_0xb707('0x29')](_0xa463df);};}exports[_0xb707('0x2a')]=function(_0x44ff55,_0x1b275e){var _0xc92d54={},_0x5cf12f={},_0x2ad3c3={'count':0x0,'rows':[]};var _0x2460cc=_[_0xb707('0x2b')](db[_0xb707('0x2c')][_0xb707('0x2d')],function(_0x42b139){return{'name':_0x42b139['fieldName'],'type':_0x42b139[_0xb707('0x2e')]['key']};});_0x5cf12f['model']=_[_0xb707('0x2b')](_0x2460cc,_0xb707('0x28'));_0x5cf12f[_0xb707('0x2f')]=_[_0xb707('0x30')](_0x44ff55[_0xb707('0x2f')]);_0x5cf12f[_0xb707('0x31')]=_[_0xb707('0x32')](_0x5cf12f[_0xb707('0x33')],_0x5cf12f[_0xb707('0x2f')]);_0xc92d54[_0xb707('0x34')]=_['intersection'](_0x5cf12f[_0xb707('0x33')],qs[_0xb707('0x35')](_0x44ff55[_0xb707('0x2f')][_0xb707('0x35')]));_0xc92d54[_0xb707('0x34')]=_0xc92d54[_0xb707('0x34')][_0xb707('0x36')]?_0xc92d54[_0xb707('0x34')]:_0x5cf12f[_0xb707('0x33')];if(!_0x44ff55['query'][_0xb707('0x37')](_0xb707('0x38'))){_0xc92d54['limit']=qs[_0xb707('0x1d')](_0x44ff55[_0xb707('0x2f')][_0xb707('0x1d')]);_0xc92d54[_0xb707('0x1c')]=qs[_0xb707('0x1c')](_0x44ff55[_0xb707('0x2f')][_0xb707('0x1c')]);}_0xc92d54[_0xb707('0x39')]=qs[_0xb707('0x3a')](_0x44ff55[_0xb707('0x2f')][_0xb707('0x3a')]);_0xc92d54['where']=qs[_0xb707('0x31')](_[_0xb707('0x3b')](_0x44ff55[_0xb707('0x2f')],_0x5cf12f[_0xb707('0x31')]),_0x2460cc);if(_0x44ff55[_0xb707('0x2f')][_0xb707('0x3c')]){_0xc92d54[_0xb707('0x3d')]=_[_0xb707('0x3e')](_0xc92d54[_0xb707('0x3d')],{'$or':_[_0xb707('0x2b')](_0x2460cc,function(_0x351927){if(_0x351927[_0xb707('0x2e')]!==_0xb707('0x3f')){var _0x5937bc={};_0x5937bc[_0x351927[_0xb707('0x28')]]={'$like':'%'+_0x44ff55[_0xb707('0x2f')][_0xb707('0x3c')]+'%'};return _0x5937bc;}})});}_0xc92d54=_['merge']({},_0xc92d54,_0x44ff55[_0xb707('0x40')]);var _0x15ad04={'where':_0xc92d54[_0xb707('0x3d')]};return db[_0xb707('0x2c')][_0xb707('0x1b')](_0x15ad04)[_0xb707('0x22')](function(_0x261b89){_0x2ad3c3[_0xb707('0x1b')]=_0x261b89;if(_0x44ff55[_0xb707('0x2f')]['includeAll']){_0xc92d54[_0xb707('0x41')]=[{'all':!![]}];}return db[_0xb707('0x2c')]['findAll'](_0xc92d54);})[_0xb707('0x22')](function(_0x4f9779){_0x2ad3c3[_0xb707('0x42')]=_0x4f9779;return _0x2ad3c3;})[_0xb707('0x22')](respondWithFilteredResult(_0x1b275e,_0xc92d54))['catch'](handleError(_0x1b275e,null));};exports[_0xb707('0x43')]=function(_0x798295,_0x535c25){var _0x72266f={'raw':!![],'where':{'id':_0x798295['params']['id']}},_0x2463c6={};_0x2463c6[_0xb707('0x33')]=_[_0xb707('0x30')](db[_0xb707('0x2c')]['rawAttributes']);_0x2463c6['query']=_[_0xb707('0x30')](_0x798295[_0xb707('0x2f')]);_0x2463c6[_0xb707('0x31')]=_[_0xb707('0x32')](_0x2463c6['model'],_0x2463c6['query']);_0x72266f[_0xb707('0x34')]=_[_0xb707('0x32')](_0x2463c6[_0xb707('0x33')],qs[_0xb707('0x35')](_0x798295[_0xb707('0x2f')][_0xb707('0x35')]));_0x72266f['attributes']=_0x72266f['attributes'][_0xb707('0x36')]?_0x72266f[_0xb707('0x34')]:_0x2463c6[_0xb707('0x33')];if(_0x798295[_0xb707('0x2f')][_0xb707('0x44')]){_0x72266f[_0xb707('0x41')]=[{'all':!![]}];}_0x72266f=_[_0xb707('0x3e')]({},_0x72266f,_0x798295['options']);return db[_0xb707('0x2c')][_0xb707('0x45')](_0x72266f)[_0xb707('0x22')](handleEntityNotFound(_0x535c25,null))[_0xb707('0x22')](respondWithResult(_0x535c25,null))[_0xb707('0x46')](handleError(_0x535c25,null));};exports[_0xb707('0x47')]=function(_0x103120,_0x156b88){return db[_0xb707('0x2c')][_0xb707('0x47')](_0x103120['body'],{})['then'](respondWithResult(_0x156b88,0xc9))[_0xb707('0x46')](handleError(_0x156b88,null));};exports[_0xb707('0x48')]=function(_0x30cccb,_0xb6a19b){if(_0x30cccb[_0xb707('0x49')]['id']){delete _0x30cccb[_0xb707('0x49')]['id'];}return db[_0xb707('0x2c')][_0xb707('0x45')]({'where':{'id':_0x30cccb[_0xb707('0x4a')]['id']}})[_0xb707('0x22')](handleEntityNotFound(_0xb6a19b,null))['then'](saveUpdates(_0x30cccb[_0xb707('0x49')],null))[_0xb707('0x22')](respondWithResult(_0xb6a19b,null))[_0xb707('0x46')](handleError(_0xb6a19b,null));};exports[_0xb707('0x23')]=function(_0x530b82,_0x2204c1){return db[_0xb707('0x2c')][_0xb707('0x45')]({'where':{'id':_0x530b82[_0xb707('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2204c1,null))['then'](removeEntity(_0x2204c1,null))[_0xb707('0x46')](handleError(_0x2204c1,null));};exports[_0xb707('0x4b')]=function(_0x393042,_0x3fdde9){return db[_0xb707('0x2c')][_0xb707('0x4b')]()['then'](respondWithResult(_0x3fdde9,null))['catch'](handleError(_0x3fdde9,null));};