Built motion from commit 8271bb6f.|2.6.28
[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 _0x90ff=['count','Content-Range','apply','save','update','then','error','stack','send','index','map','OpenchannelTransferReport','rawAttributes','fieldName','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','pick','filter','VIRTUAL','name','merge','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','destroy','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','ejs','fs-extra','lodash','jsforce','desk.js','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit'];(function(_0x323726,_0x7af501){var _0x1b8691=function(_0xbe7b2b){while(--_0xbe7b2b){_0x323726['push'](_0x323726['shift']());}};_0x1b8691(++_0x7af501);}(_0x90ff,0x111));var _0xf90f=function(_0x23a915,_0x48d215){_0x23a915=_0x23a915-0x0;var _0x1e301d=_0x90ff[_0x23a915];return _0x1e301d;};'use strict';var emlformat=require(_0xf90f('0x0'));var rimraf=require(_0xf90f('0x1'));var zipdir=require(_0xf90f('0x2'));var jsonpatch=require(_0xf90f('0x3'));var rp=require(_0xf90f('0x4'));var moment=require(_0xf90f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xf90f('0x6'));var util=require(_0xf90f('0x7'));var path=require(_0xf90f('0x8'));var sox=require(_0xf90f('0x9'));var csv=require('to-csv');var ejs=require(_0xf90f('0xa'));var fs=require('fs');var fs_extra=require(_0xf90f('0xb'));var _=require(_0xf90f('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf90f('0xd'));var deskjs=require(_0xf90f('0xe'));var toCsv=require(_0xf90f('0xf'));var querystring=require(_0xf90f('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xf90f('0x11'));var qs=require(_0xf90f('0x12'));var as=require(_0xf90f('0x13'));var hardwareService=require(_0xf90f('0x14'));var logger=require(_0xf90f('0x15'))('api');var utils=require(_0xf90f('0x16'));var config=require(_0xf90f('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xf90f('0x18'))['db'];function respondWithStatusCode(_0x15641d,_0x47ea3c){_0x47ea3c=_0x47ea3c||0xcc;return function(_0x1e6ea2){if(_0x1e6ea2){return _0x15641d['sendStatus'](_0x47ea3c);}return _0x15641d[_0xf90f('0x19')](_0x47ea3c)[_0xf90f('0x1a')]();};}function respondWithResult(_0x39769a,_0x4be7ad){_0x4be7ad=_0x4be7ad||0xc8;return function(_0x5a8da2){if(_0x5a8da2){return _0x39769a['status'](_0x4be7ad)[_0xf90f('0x1b')](_0x5a8da2);}};}function respondWithFilteredResult(_0xfb4a45,_0x3d7d34){return function(_0x27c2ff){if(_0x27c2ff){var _0x2c1e99=typeof _0x3d7d34[_0xf90f('0x1c')]===_0xf90f('0x1d')&&typeof _0x3d7d34[_0xf90f('0x1e')]===_0xf90f('0x1d');var _0x4ccddf=_0x27c2ff[_0xf90f('0x1f')];var _0xb68ddd=_0x2c1e99?0x0:_0x3d7d34[_0xf90f('0x1c')];var _0x39c455=_0x2c1e99?_0x27c2ff[_0xf90f('0x1f')]:_0x3d7d34[_0xf90f('0x1c')]+_0x3d7d34[_0xf90f('0x1e')];var _0x3059ff;if(_0x39c455>=_0x4ccddf){_0x39c455=_0x4ccddf;_0x3059ff=0xc8;}else{_0x3059ff=0xce;}_0xfb4a45['status'](_0x3059ff);return _0xfb4a45['set'](_0xf90f('0x20'),_0xb68ddd+'-'+_0x39c455+'/'+_0x4ccddf)[_0xf90f('0x1b')](_0x27c2ff);}return null;};}function patchUpdates(_0x53a9be){return function(_0x4bf4df){try{jsonpatch[_0xf90f('0x21')](_0x4bf4df,_0x53a9be,!![]);}catch(_0x44ff69){return BPromise['reject'](_0x44ff69);}return _0x4bf4df[_0xf90f('0x22')]();};}function saveUpdates(_0x3a0767,_0x512155){return function(_0x46b0c5){if(_0x46b0c5){return _0x46b0c5[_0xf90f('0x23')](_0x3a0767)[_0xf90f('0x24')](function(_0xb84a7f){return _0xb84a7f;});}return null;};}function removeEntity(_0x12ae7c,_0x17835a){return function(_0x614d5f){if(_0x614d5f){return _0x614d5f['destroy']()[_0xf90f('0x24')](function(){_0x12ae7c['status'](0xcc)[_0xf90f('0x1a')]();});}};}function handleEntityNotFound(_0x521e77,_0x41edfc){return function(_0x409e62){if(!_0x409e62){_0x521e77['sendStatus'](0x194);}return _0x409e62;};}function handleError(_0x104d9e,_0x2ac230){_0x2ac230=_0x2ac230||0x1f4;return function(_0x2f448d){logger[_0xf90f('0x25')](_0x2f448d[_0xf90f('0x26')]);if(_0x2f448d['name']){delete _0x2f448d['name'];}_0x104d9e['status'](_0x2ac230)[_0xf90f('0x27')](_0x2f448d);};}exports[_0xf90f('0x28')]=function(_0x4815ef,_0x214ac7){var _0x4cbcfc={},_0x2b7b82={},_0x469307={'count':0x0,'rows':[]};var _0x35d982=_[_0xf90f('0x29')](db[_0xf90f('0x2a')][_0xf90f('0x2b')],function(_0x2bfe61){return{'name':_0x2bfe61[_0xf90f('0x2c')],'type':_0x2bfe61[_0xf90f('0x2d')]['key']};});_0x2b7b82[_0xf90f('0x2e')]=_[_0xf90f('0x29')](_0x35d982,'name');_0x2b7b82[_0xf90f('0x2f')]=_[_0xf90f('0x30')](_0x4815ef[_0xf90f('0x2f')]);_0x2b7b82[_0xf90f('0x31')]=_['intersection'](_0x2b7b82[_0xf90f('0x2e')],_0x2b7b82[_0xf90f('0x2f')]);_0x4cbcfc[_0xf90f('0x32')]=_[_0xf90f('0x33')](_0x2b7b82[_0xf90f('0x2e')],qs['fields'](_0x4815ef[_0xf90f('0x2f')][_0xf90f('0x34')]));_0x4cbcfc[_0xf90f('0x32')]=_0x4cbcfc[_0xf90f('0x32')][_0xf90f('0x35')]?_0x4cbcfc[_0xf90f('0x32')]:_0x2b7b82[_0xf90f('0x2e')];if(!_0x4815ef['query'][_0xf90f('0x36')]('nolimit')){_0x4cbcfc[_0xf90f('0x1e')]=qs[_0xf90f('0x1e')](_0x4815ef[_0xf90f('0x2f')]['limit']);_0x4cbcfc['offset']=qs[_0xf90f('0x1c')](_0x4815ef[_0xf90f('0x2f')][_0xf90f('0x1c')]);}_0x4cbcfc[_0xf90f('0x37')]=qs[_0xf90f('0x38')](_0x4815ef[_0xf90f('0x2f')][_0xf90f('0x38')]);_0x4cbcfc[_0xf90f('0x39')]=qs['filters'](_[_0xf90f('0x3a')](_0x4815ef[_0xf90f('0x2f')],_0x2b7b82[_0xf90f('0x31')]),_0x35d982);if(_0x4815ef['query'][_0xf90f('0x3b')]){_0x4cbcfc[_0xf90f('0x39')]=_['merge'](_0x4cbcfc[_0xf90f('0x39')],{'$or':_[_0xf90f('0x29')](_0x35d982,function(_0x263550){if(_0x263550[_0xf90f('0x2d')]!==_0xf90f('0x3c')){var _0x15d52a={};_0x15d52a[_0x263550[_0xf90f('0x3d')]]={'$like':'%'+_0x4815ef[_0xf90f('0x2f')][_0xf90f('0x3b')]+'%'};return _0x15d52a;}})});}_0x4cbcfc=_[_0xf90f('0x3e')]({},_0x4cbcfc,_0x4815ef[_0xf90f('0x3f')]);var _0x3ba253={'where':_0x4cbcfc['where']};return db[_0xf90f('0x2a')][_0xf90f('0x1f')](_0x3ba253)[_0xf90f('0x24')](function(_0x13ef1a){_0x469307[_0xf90f('0x1f')]=_0x13ef1a;if(_0x4815ef[_0xf90f('0x2f')][_0xf90f('0x40')]){_0x4cbcfc[_0xf90f('0x41')]=[{'all':!![]}];}return db[_0xf90f('0x2a')][_0xf90f('0x42')](_0x4cbcfc);})[_0xf90f('0x24')](function(_0xa110b0){_0x469307[_0xf90f('0x43')]=_0xa110b0;return _0x469307;})[_0xf90f('0x24')](respondWithFilteredResult(_0x214ac7,_0x4cbcfc))[_0xf90f('0x44')](handleError(_0x214ac7,null));};exports[_0xf90f('0x45')]=function(_0x291fbe,_0x1324a9){var _0x19403c={'raw':!![],'where':{'id':_0x291fbe[_0xf90f('0x46')]['id']}},_0x5b13f7={};_0x5b13f7[_0xf90f('0x2e')]=_[_0xf90f('0x30')](db[_0xf90f('0x2a')]['rawAttributes']);_0x5b13f7['query']=_[_0xf90f('0x30')](_0x291fbe[_0xf90f('0x2f')]);_0x5b13f7[_0xf90f('0x31')]=_[_0xf90f('0x33')](_0x5b13f7[_0xf90f('0x2e')],_0x5b13f7[_0xf90f('0x2f')]);_0x19403c[_0xf90f('0x32')]=_[_0xf90f('0x33')](_0x5b13f7[_0xf90f('0x2e')],qs[_0xf90f('0x34')](_0x291fbe[_0xf90f('0x2f')][_0xf90f('0x34')]));_0x19403c[_0xf90f('0x32')]=_0x19403c[_0xf90f('0x32')][_0xf90f('0x35')]?_0x19403c[_0xf90f('0x32')]:_0x5b13f7['model'];if(_0x291fbe[_0xf90f('0x2f')]['includeAll']){_0x19403c['include']=[{'all':!![]}];}_0x19403c=_[_0xf90f('0x3e')]({},_0x19403c,_0x291fbe[_0xf90f('0x3f')]);return db[_0xf90f('0x2a')][_0xf90f('0x47')](_0x19403c)[_0xf90f('0x24')](handleEntityNotFound(_0x1324a9,null))[_0xf90f('0x24')](respondWithResult(_0x1324a9,null))[_0xf90f('0x44')](handleError(_0x1324a9,null));};exports['create']=function(_0x520f60,_0x5361d0){return db[_0xf90f('0x2a')][_0xf90f('0x48')](_0x520f60[_0xf90f('0x49')],{})[_0xf90f('0x24')](respondWithResult(_0x5361d0,0xc9))[_0xf90f('0x44')](handleError(_0x5361d0,null));};exports[_0xf90f('0x23')]=function(_0x2bac92,_0x1d4e47){if(_0x2bac92['body']['id']){delete _0x2bac92[_0xf90f('0x49')]['id'];}return db[_0xf90f('0x2a')][_0xf90f('0x47')]({'where':{'id':_0x2bac92[_0xf90f('0x46')]['id']}})[_0xf90f('0x24')](handleEntityNotFound(_0x1d4e47,null))[_0xf90f('0x24')](saveUpdates(_0x2bac92['body'],null))['then'](respondWithResult(_0x1d4e47,null))['catch'](handleError(_0x1d4e47,null));};exports[_0xf90f('0x4a')]=function(_0x2cb2c1,_0x181d44){return db[_0xf90f('0x2a')][_0xf90f('0x47')]({'where':{'id':_0x2cb2c1['params']['id']}})['then'](handleEntityNotFound(_0x181d44,null))[_0xf90f('0x24')](removeEntity(_0x181d44,null))[_0xf90f('0x44')](handleError(_0x181d44,null));};exports[_0xf90f('0x4b')]=function(_0x1da939,_0x2f3be2){return db['OpenchannelTransferReport'][_0xf90f('0x4b')]()[_0xf90f('0x24')](respondWithResult(_0x2f3be2,null))[_0xf90f('0x44')](handleError(_0x2f3be2,null));};