65d3e099c2352f57d5f66daaa6c9d5b5dac8d7fa
[motion2.git] / server / api / voiceTransferReport / voiceTransferReport.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 _0x776f=['keys','intersection','attributes','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','fields','length','find','create','body','params','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','sox','ejs','lodash','crypto','jsforce','to-csv','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','status','count','offset','set','Content-Range','json','apply','reject','save','update','then','destroy','end','sendStatus','error','name','send','index','map','VoiceTransferReport','rawAttributes','fieldName','type','key','model','query'];(function(_0x31ced5,_0x5d5415){var _0x10d9e5=function(_0x2e51a5){while(--_0x2e51a5){_0x31ced5['push'](_0x31ced5['shift']());}};_0x10d9e5(++_0x5d5415);}(_0x776f,0x68));var _0xf776=function(_0x567ad7,_0x4f55e0){_0x567ad7=_0x567ad7-0x0;var _0x338c0e=_0x776f[_0x567ad7];return _0x338c0e;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xf776('0x0'));var zipdir=require(_0xf776('0x1'));var jsonpatch=require(_0xf776('0x2'));var rp=require(_0xf776('0x3'));var moment=require(_0xf776('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf776('0x5'));var util=require('util');var path=require(_0xf776('0x6'));var sox=require(_0xf776('0x7'));var csv=require('to-csv');var ejs=require(_0xf776('0x8'));var fs=require('fs');var _=require(_0xf776('0x9'));var squel=require('squel');var crypto=require(_0xf776('0xa'));var jsforce=require(_0xf776('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xf776('0xc'));var querystring=require(_0xf776('0xd'));var Papa=require('papaparse');var Redis=require(_0xf776('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xf776('0xf'));var as=require(_0xf776('0x10'));var hardwareService=require(_0xf776('0x11'));var logger=require(_0xf776('0x12'))(_0xf776('0x13'));var utils=require(_0xf776('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xf776('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x43ddb9,_0x1dc676){_0x1dc676=_0x1dc676||0xcc;return function(_0x3af2c3){if(_0x3af2c3){return _0x43ddb9['sendStatus'](_0x1dc676);}return _0x43ddb9[_0xf776('0x16')](_0x1dc676)['end']();};}function respondWithResult(_0x126991,_0x46b002){_0x46b002=_0x46b002||0xc8;return function(_0x24b946){if(_0x24b946){return _0x126991['status'](_0x46b002)['json'](_0x24b946);}};}function respondWithFilteredResult(_0x2eff1a,_0x288543){return function(_0x5740ff){if(_0x5740ff){var _0xcca8ef=_0x5740ff[_0xf776('0x17')],_0x4161f8=_0x288543[_0xf776('0x18')],_0x1c0f6b=_0x288543['offset']+_0x288543['limit'],_0xd5f3c2;if(_0x1c0f6b>=_0xcca8ef){_0x1c0f6b=_0xcca8ef;_0xd5f3c2=0xc8;}else{_0xd5f3c2=0xce;}_0x2eff1a[_0xf776('0x16')](_0xd5f3c2);return _0x2eff1a[_0xf776('0x19')](_0xf776('0x1a'),_0x4161f8+'-'+_0x1c0f6b+'/'+_0xcca8ef)[_0xf776('0x1b')](_0x5740ff);}return null;};}function patchUpdates(_0x5628b0){return function(_0x3dd749){try{jsonpatch[_0xf776('0x1c')](_0x3dd749,_0x5628b0,!![]);}catch(_0x34d876){return BPromise[_0xf776('0x1d')](_0x34d876);}return _0x3dd749[_0xf776('0x1e')]();};}function saveUpdates(_0x5bcb1f,_0x1abb03){return function(_0x4c7dc8){if(_0x4c7dc8){return _0x4c7dc8[_0xf776('0x1f')](_0x5bcb1f)[_0xf776('0x20')](function(_0x368684){return _0x368684;});}return null;};}function removeEntity(_0x3521e3,_0x54bc24){return function(_0x24fbf7){if(_0x24fbf7){return _0x24fbf7[_0xf776('0x21')]()[_0xf776('0x20')](function(){_0x3521e3[_0xf776('0x16')](0xcc)[_0xf776('0x22')]();});}};}function handleEntityNotFound(_0x23e01b,_0x12cebb){return function(_0x487d2a){if(!_0x487d2a){_0x23e01b[_0xf776('0x23')](0x194);}return _0x487d2a;};}function handleError(_0x3bd9a9,_0x1ebb90){_0x1ebb90=_0x1ebb90||0x1f4;return function(_0x43d056){logger[_0xf776('0x24')](_0x43d056['stack']);if(_0x43d056[_0xf776('0x25')]){delete _0x43d056[_0xf776('0x25')];}_0x3bd9a9[_0xf776('0x16')](_0x1ebb90)[_0xf776('0x26')](_0x43d056);};}exports[_0xf776('0x27')]=function(_0xc14b80,_0x15399e){var _0x223160={},_0x966847={},_0x9ea20={'count':0x0,'rows':[]};var _0x11ff73=_[_0xf776('0x28')](db[_0xf776('0x29')][_0xf776('0x2a')],function(_0x3ae8bc){return{'name':_0x3ae8bc[_0xf776('0x2b')],'type':_0x3ae8bc[_0xf776('0x2c')][_0xf776('0x2d')]};});_0x966847[_0xf776('0x2e')]=_[_0xf776('0x28')](_0x11ff73,_0xf776('0x25'));_0x966847[_0xf776('0x2f')]=_[_0xf776('0x30')](_0xc14b80['query']);_0x966847['filters']=_[_0xf776('0x31')](_0x966847[_0xf776('0x2e')],_0x966847[_0xf776('0x2f')]);_0x223160[_0xf776('0x32')]=_[_0xf776('0x31')](_0x966847['model'],qs['fields'](_0xc14b80[_0xf776('0x2f')]['fields']));_0x223160['attributes']=_0x223160[_0xf776('0x32')]['length']?_0x223160[_0xf776('0x32')]:_0x966847[_0xf776('0x2e')];if(!_0xc14b80[_0xf776('0x2f')][_0xf776('0x33')](_0xf776('0x34'))){_0x223160[_0xf776('0x35')]=qs['limit'](_0xc14b80[_0xf776('0x2f')][_0xf776('0x35')]);_0x223160['offset']=qs[_0xf776('0x18')](_0xc14b80[_0xf776('0x2f')][_0xf776('0x18')]);}_0x223160[_0xf776('0x36')]=qs['sort'](_0xc14b80[_0xf776('0x2f')][_0xf776('0x37')]);_0x223160[_0xf776('0x38')]=qs[_0xf776('0x39')](_[_0xf776('0x3a')](_0xc14b80[_0xf776('0x2f')],_0x966847[_0xf776('0x39')]),_0x11ff73);if(_0xc14b80[_0xf776('0x2f')][_0xf776('0x3b')]){_0x223160['where']=_[_0xf776('0x3c')](_0x223160['where'],{'$or':_[_0xf776('0x28')](_0x11ff73,function(_0xf07e03){if(_0xf07e03['type']!==_0xf776('0x3d')){var _0x2fce52={};_0x2fce52[_0xf07e03[_0xf776('0x25')]]={'$like':'%'+_0xc14b80[_0xf776('0x2f')][_0xf776('0x3b')]+'%'};return _0x2fce52;}})});}_0x223160=_[_0xf776('0x3c')]({},_0x223160,_0xc14b80[_0xf776('0x3e')]);var _0x46c262={'where':_0x223160[_0xf776('0x38')]};return db[_0xf776('0x29')][_0xf776('0x17')](_0x46c262)[_0xf776('0x20')](function(_0x38724e){_0x9ea20[_0xf776('0x17')]=_0x38724e;if(_0xc14b80[_0xf776('0x2f')][_0xf776('0x3f')]){_0x223160[_0xf776('0x40')]=[{'all':!![]}];}return db[_0xf776('0x29')][_0xf776('0x41')](_0x223160);})['then'](function(_0x5c4713){_0x9ea20[_0xf776('0x42')]=_0x5c4713;return _0x9ea20;})['then'](respondWithFilteredResult(_0x15399e,_0x223160))[_0xf776('0x43')](handleError(_0x15399e,null));};exports[_0xf776('0x44')]=function(_0x28925c,_0x362fb7){var _0x54df7c={'raw':!![],'where':{'id':_0x28925c['params']['id']}},_0x1e1910={};_0x1e1910[_0xf776('0x2e')]=_[_0xf776('0x30')](db[_0xf776('0x29')][_0xf776('0x2a')]);_0x1e1910[_0xf776('0x2f')]=_[_0xf776('0x30')](_0x28925c[_0xf776('0x2f')]);_0x1e1910['filters']=_[_0xf776('0x31')](_0x1e1910[_0xf776('0x2e')],_0x1e1910['query']);_0x54df7c[_0xf776('0x32')]=_[_0xf776('0x31')](_0x1e1910[_0xf776('0x2e')],qs[_0xf776('0x45')](_0x28925c[_0xf776('0x2f')][_0xf776('0x45')]));_0x54df7c[_0xf776('0x32')]=_0x54df7c[_0xf776('0x32')][_0xf776('0x46')]?_0x54df7c[_0xf776('0x32')]:_0x1e1910[_0xf776('0x2e')];if(_0x28925c[_0xf776('0x2f')][_0xf776('0x3f')]){_0x54df7c[_0xf776('0x40')]=[{'all':!![]}];}_0x54df7c=_['merge']({},_0x54df7c,_0x28925c[_0xf776('0x3e')]);return db['VoiceTransferReport'][_0xf776('0x47')](_0x54df7c)[_0xf776('0x20')](handleEntityNotFound(_0x362fb7,null))['then'](respondWithResult(_0x362fb7,null))[_0xf776('0x43')](handleError(_0x362fb7,null));};exports[_0xf776('0x48')]=function(_0x315fe6,_0x5121a2){return db['VoiceTransferReport'][_0xf776('0x48')](_0x315fe6['body'],{})[_0xf776('0x20')](respondWithResult(_0x5121a2,0xc9))[_0xf776('0x43')](handleError(_0x5121a2,null));};exports[_0xf776('0x1f')]=function(_0x1b207a,_0x38a69e){if(_0x1b207a[_0xf776('0x49')]['id']){delete _0x1b207a[_0xf776('0x49')]['id'];}return db[_0xf776('0x29')][_0xf776('0x47')]({'where':{'id':_0x1b207a[_0xf776('0x4a')]['id']}})[_0xf776('0x20')](handleEntityNotFound(_0x38a69e,null))[_0xf776('0x20')](saveUpdates(_0x1b207a[_0xf776('0x49')],null))[_0xf776('0x20')](respondWithResult(_0x38a69e,null))['catch'](handleError(_0x38a69e,null));};exports['destroy']=function(_0x1752e9,_0x41f67b){return db[_0xf776('0x29')][_0xf776('0x47')]({'where':{'id':_0x1752e9[_0xf776('0x4a')]['id']}})[_0xf776('0x20')](handleEntityNotFound(_0x41f67b,null))[_0xf776('0x20')](removeEntity(_0x41f67b,null))[_0xf776('0x43')](handleError(_0x41f67b,null));};exports[_0xf776('0x4b')]=function(_0x2af9cc,_0x159a72){return db[_0xf776('0x29')][_0xf776('0x4b')]()[_0xf776('0x20')](respondWithResult(_0x159a72,null))[_0xf776('0x43')](handleError(_0x159a72,null));};