Built motion from commit (unavailable).|2.3.8
[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 _0xf109=['body','describe','html-pdf','eml-format','rimraf','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','json','count','offset','limit','Content-Range','apply','save','update','then','destroy','stack','name','OpenchannelTransferReport','rawAttributes','keys','query','filters','intersection','attributes','model','fields','length','hasOwnProperty','order','sort','where','merge','map','type','key','VIRTUAL','field','filter','includeAll','include','rows','catch','show','params','find','create'];(function(_0x5f1ac0,_0x5c3111){var _0x6ecff7=function(_0x11c246){while(--_0x11c246){_0x5f1ac0['push'](_0x5f1ac0['shift']());}};_0x6ecff7(++_0x5c3111);}(_0xf109,0xce));var _0x9f10=function(_0x1deb03,_0xd05ad8){_0x1deb03=_0x1deb03-0x0;var _0x189fe7=_0xf109[_0x1deb03];return _0x189fe7;};'use strict';var pdf=require(_0x9f10('0x0'));var emlformat=require(_0x9f10('0x1'));var rimraf=require(_0x9f10('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9f10('0x3'));var BPromise=require(_0x9f10('0x4'));var Mustache=require(_0x9f10('0x5'));var util=require(_0x9f10('0x6'));var path=require(_0x9f10('0x7'));var sox=require(_0x9f10('0x8'));var csv=require(_0x9f10('0x9'));var ejs=require(_0x9f10('0xa'));var fs=require('fs');var _=require(_0x9f10('0xb'));var squel=require(_0x9f10('0xc'));var crypto=require(_0x9f10('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x9f10('0xe'));var toCsv=require(_0x9f10('0x9'));var querystring=require(_0x9f10('0xf'));var Papa=require(_0x9f10('0x10'));var authService=require(_0x9f10('0x11'));var hardwareService=require('../../config/license/hardware');var Redis=require(_0x9f10('0x12'));var qs=require(_0x9f10('0x13'));var logger=require(_0x9f10('0x14'))('api');var utils=require('../../config/utils');var config=require(_0x9f10('0x15'));var db=require(_0x9f10('0x16'))['db'];function respondWithStatusCode(_0x407336,_0x56780e){_0x56780e=_0x56780e||0xcc;return function(_0x289164){if(_0x289164){return _0x407336[_0x9f10('0x17')](_0x56780e);}return _0x407336[_0x9f10('0x18')](_0x56780e)['end']();};}function respondWithResult(_0x9a3ae6,_0x309f27){_0x309f27=_0x309f27||0xc8;return function(_0x5be443){if(_0x5be443){return _0x9a3ae6[_0x9f10('0x18')](_0x309f27)[_0x9f10('0x19')](_0x5be443);}};}function respondWithFilteredResult(_0x507e1a,_0x59bcad){return function(_0x2b6c4c){if(_0x2b6c4c){var _0x177918=_0x2b6c4c[_0x9f10('0x1a')],_0x549217=_0x59bcad[_0x9f10('0x1b')],_0x11154b=_0x59bcad['offset']+_0x59bcad[_0x9f10('0x1c')],_0x5ae255;if(_0x11154b>=_0x177918){_0x11154b=_0x177918;_0x5ae255=0xc8;}else{_0x5ae255=0xce;}_0x507e1a[_0x9f10('0x18')](_0x5ae255);return _0x507e1a['set'](_0x9f10('0x1d'),_0x549217+'-'+_0x11154b+'/'+_0x177918)['json'](_0x2b6c4c);}return null;};}function patchUpdates(_0xe221d0){return function(_0x51ce03){try{jsonpatch[_0x9f10('0x1e')](_0x51ce03,_0xe221d0,!![]);}catch(_0x56fb44){return BPromise['reject'](_0x56fb44);}return _0x51ce03[_0x9f10('0x1f')]();};}function saveUpdates(_0x1a1e7e,_0x25f870){return function(_0x3a78be){if(_0x3a78be){return _0x3a78be[_0x9f10('0x20')](_0x1a1e7e)[_0x9f10('0x21')](function(_0x27843d){return _0x27843d;});}return null;};}function removeEntity(_0x4cdc00,_0x366044){return function(_0x58e6ba){if(_0x58e6ba){return _0x58e6ba[_0x9f10('0x22')]()[_0x9f10('0x21')](function(){_0x4cdc00[_0x9f10('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2f31fb,_0x3dde2e){return function(_0x213567){if(!_0x213567){_0x2f31fb['sendStatus'](0x194);}return _0x213567;};}function handleError(_0x36821e,_0x37e9ac){_0x37e9ac=_0x37e9ac||0x1f4;return function(_0x44b99d){logger['error'](_0x44b99d[_0x9f10('0x23')]);if(_0x44b99d[_0x9f10('0x24')]){delete _0x44b99d[_0x9f10('0x24')];}_0x36821e[_0x9f10('0x18')](_0x37e9ac)['send'](_0x44b99d);};}exports['index']=function(_0x5c1800,_0x385a39){var _0x4a0407={},_0x314794={},_0x1de75a={'count':0x0,'rows':[]};var _0x45fffc=db[_0x9f10('0x25')][_0x9f10('0x26')];_0x314794['model']=_[_0x9f10('0x27')](_0x45fffc);_0x314794[_0x9f10('0x28')]=_[_0x9f10('0x27')](_0x5c1800[_0x9f10('0x28')]);_0x314794[_0x9f10('0x29')]=_[_0x9f10('0x2a')](_0x314794['model'],_0x314794[_0x9f10('0x28')]);_0x4a0407[_0x9f10('0x2b')]=_[_0x9f10('0x2a')](_0x314794[_0x9f10('0x2c')],qs['fields'](_0x5c1800[_0x9f10('0x28')][_0x9f10('0x2d')]));_0x4a0407[_0x9f10('0x2b')]=_0x4a0407['attributes'][_0x9f10('0x2e')]?_0x4a0407['attributes']:_0x314794[_0x9f10('0x2c')];if(!_0x5c1800[_0x9f10('0x28')][_0x9f10('0x2f')]('nolimit')){_0x4a0407[_0x9f10('0x1c')]=qs[_0x9f10('0x1c')](_0x5c1800[_0x9f10('0x28')][_0x9f10('0x1c')]);_0x4a0407[_0x9f10('0x1b')]=qs['offset'](_0x5c1800[_0x9f10('0x28')]['offset']);}_0x4a0407[_0x9f10('0x30')]=qs[_0x9f10('0x31')](_0x5c1800[_0x9f10('0x28')][_0x9f10('0x31')]);_0x4a0407[_0x9f10('0x32')]=qs[_0x9f10('0x29')](_['pick'](_0x5c1800[_0x9f10('0x28')],_0x314794[_0x9f10('0x29')]));if(_0x5c1800[_0x9f10('0x28')]['filter']){_0x4a0407[_0x9f10('0x32')]=_[_0x9f10('0x33')](_0x4a0407['where'],{'$or':_[_0x9f10('0x34')](_0x45fffc,function(_0x5671fe){if(_0x5671fe[_0x9f10('0x35')][_0x9f10('0x36')]!==_0x9f10('0x37')){var _0xc17ea2={};_0xc17ea2[_0x5671fe[_0x9f10('0x38')]]={'$like':'%'+_0x5c1800[_0x9f10('0x28')][_0x9f10('0x39')]+'%'};return _0xc17ea2;}})});}_0x4a0407=_[_0x9f10('0x33')]({},_0x4a0407,_0x5c1800['options']);var _0x36b1e2={'where':_0x4a0407[_0x9f10('0x32')]};return db[_0x9f10('0x25')]['count'](_0x36b1e2)[_0x9f10('0x21')](function(_0x193b59){_0x1de75a['count']=_0x193b59;if(_0x5c1800[_0x9f10('0x28')][_0x9f10('0x3a')]){_0x4a0407[_0x9f10('0x3b')]=[{'all':!![]}];}return db['OpenchannelTransferReport']['findAll'](_0x4a0407);})[_0x9f10('0x21')](function(_0x2ff98d){_0x1de75a[_0x9f10('0x3c')]=_0x2ff98d;return _0x1de75a;})[_0x9f10('0x21')](respondWithFilteredResult(_0x385a39,_0x4a0407))[_0x9f10('0x3d')](handleError(_0x385a39,null));};exports[_0x9f10('0x3e')]=function(_0x15929f,_0x34869c){var _0x7fe320={'raw':!![],'where':{'id':_0x15929f[_0x9f10('0x3f')]['id']}},_0x149f8f={};_0x149f8f[_0x9f10('0x2c')]=_['keys'](db['OpenchannelTransferReport']['rawAttributes']);_0x149f8f[_0x9f10('0x28')]=_['keys'](_0x15929f[_0x9f10('0x28')]);_0x149f8f[_0x9f10('0x29')]=_[_0x9f10('0x2a')](_0x149f8f['model'],_0x149f8f[_0x9f10('0x28')]);_0x7fe320[_0x9f10('0x2b')]=_[_0x9f10('0x2a')](_0x149f8f[_0x9f10('0x2c')],qs[_0x9f10('0x2d')](_0x15929f['query']['fields']));_0x7fe320['attributes']=_0x7fe320[_0x9f10('0x2b')]['length']?_0x7fe320[_0x9f10('0x2b')]:_0x149f8f['model'];if(_0x15929f[_0x9f10('0x28')][_0x9f10('0x3a')]){_0x7fe320[_0x9f10('0x3b')]=[{'all':!![]}];}_0x7fe320=_[_0x9f10('0x33')]({},_0x7fe320,_0x15929f['options']);return db[_0x9f10('0x25')][_0x9f10('0x40')](_0x7fe320)['then'](handleEntityNotFound(_0x34869c,null))[_0x9f10('0x21')](respondWithResult(_0x34869c,null))[_0x9f10('0x3d')](handleError(_0x34869c,null));};exports[_0x9f10('0x41')]=function(_0x1bd37c,_0x1b3529){return db[_0x9f10('0x25')][_0x9f10('0x41')](_0x1bd37c[_0x9f10('0x42')],{})[_0x9f10('0x21')](respondWithResult(_0x1b3529,0xc9))[_0x9f10('0x3d')](handleError(_0x1b3529,null));};exports['update']=function(_0x181eab,_0x102730){if(_0x181eab['body']['id']){delete _0x181eab[_0x9f10('0x42')]['id'];}return db[_0x9f10('0x25')][_0x9f10('0x40')]({'where':{'id':_0x181eab[_0x9f10('0x3f')]['id']}})['then'](handleEntityNotFound(_0x102730,null))[_0x9f10('0x21')](saveUpdates(_0x181eab[_0x9f10('0x42')],null))[_0x9f10('0x21')](respondWithResult(_0x102730,null))[_0x9f10('0x3d')](handleError(_0x102730,null));};exports[_0x9f10('0x22')]=function(_0x43cb31,_0x479b46){return db[_0x9f10('0x25')][_0x9f10('0x40')]({'where':{'id':_0x43cb31[_0x9f10('0x3f')]['id']}})[_0x9f10('0x21')](handleEntityNotFound(_0x479b46,null))[_0x9f10('0x21')](removeEntity(_0x479b46,null))[_0x9f10('0x3d')](handleError(_0x479b46,null));};exports['describe']=function(_0x3ec147,_0x1bbf92){return db[_0x9f10('0x25')][_0x9f10('0x43')]()[_0x9f10('0x21')](respondWithResult(_0x1bbf92,null))[_0x9f10('0x3d')](handleError(_0x1bbf92,null));};