Built motion from commit (unavailable).|2.3.0
[motion2.git] / server / api / jscriptyQuestionReport / jscriptyQuestionReport.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 _0xb62e=['filters','intersection','model','fields','attributes','length','nolimit','order','sort','where','merge','map','type','key','VIRTUAL','field','options','includeAll','include','findAll','rows','catch','show','find','create','body','params','describe','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','../../components/auth/service','../../config/license/hardware','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','count','offset','limit','set','Content-Range','json','reject','save','update','destroy','then','stack','name','send','index','JscriptyQuestionReport','rawAttributes','keys','query'];(function(_0x493c8c,_0x470567){var _0x17344b=function(_0x47aee7){while(--_0x47aee7){_0x493c8c['push'](_0x493c8c['shift']());}};_0x17344b(++_0x470567);}(_0xb62e,0x1de));var _0xeb62=function(_0x160c73,_0x2ee678){_0x160c73=_0x160c73-0x0;var _0xd9302=_0xb62e[_0x160c73];return _0xd9302;};'use strict';var pdf=require(_0xeb62('0x0'));var emlformat=require(_0xeb62('0x1'));var rimraf=require(_0xeb62('0x2'));var zipdir=require(_0xeb62('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xeb62('0x4'));var moment=require(_0xeb62('0x5'));var BPromise=require(_0xeb62('0x6'));var Mustache=require(_0xeb62('0x7'));var util=require(_0xeb62('0x8'));var path=require(_0xeb62('0x9'));var sox=require('sox');var csv=require(_0xeb62('0xa'));var ejs=require(_0xeb62('0xb'));var fs=require('fs');var _=require(_0xeb62('0xc'));var squel=require('squel');var crypto=require(_0xeb62('0xd'));var jsforce=require(_0xeb62('0xe'));var deskjs=require(_0xeb62('0xf'));var toCsv=require(_0xeb62('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var authService=require(_0xeb62('0x10'));var hardwareService=require(_0xeb62('0x11'));var Redis=require(_0xeb62('0x12'));var qs=require(_0xeb62('0x13'));var logger=require(_0xeb62('0x14'))(_0xeb62('0x15'));var utils=require(_0xeb62('0x16'));var config=require(_0xeb62('0x17'));var db=require(_0xeb62('0x18'))['db'];function respondWithStatusCode(_0x17724e,_0x4a493c){_0x4a493c=_0x4a493c||0xcc;return function(_0x422daf){if(_0x422daf){return _0x17724e[_0xeb62('0x19')](_0x4a493c);}return _0x17724e[_0xeb62('0x1a')](_0x4a493c)[_0xeb62('0x1b')]();};}function respondWithResult(_0x55a629,_0x333126){_0x333126=_0x333126||0xc8;return function(_0x2fbad2){if(_0x2fbad2){return _0x55a629[_0xeb62('0x1a')](_0x333126)['json'](_0x2fbad2);}};}function respondWithFilteredResult(_0x26c3fd,_0x195837){return function(_0x2fd4c7){if(_0x2fd4c7){var _0x4ce9fa=_0x2fd4c7[_0xeb62('0x1c')],_0x1f6a1f=_0x195837[_0xeb62('0x1d')],_0x15b3e8=_0x195837[_0xeb62('0x1d')]+_0x195837[_0xeb62('0x1e')],_0x184106;if(_0x15b3e8>=_0x4ce9fa){_0x15b3e8=_0x4ce9fa;_0x184106=0xc8;}else{_0x184106=0xce;}_0x26c3fd[_0xeb62('0x1a')](_0x184106);return _0x26c3fd[_0xeb62('0x1f')](_0xeb62('0x20'),_0x1f6a1f+'-'+_0x15b3e8+'/'+_0x4ce9fa)[_0xeb62('0x21')](_0x2fd4c7);}return null;};}function patchUpdates(_0x11d516){return function(_0x3cdf76){try{jsonpatch['apply'](_0x3cdf76,_0x11d516,!![]);}catch(_0x38c5e4){return BPromise[_0xeb62('0x22')](_0x38c5e4);}return _0x3cdf76[_0xeb62('0x23')]();};}function saveUpdates(_0xb44905,_0x425817){return function(_0x24cbf3){if(_0x24cbf3){return _0x24cbf3[_0xeb62('0x24')](_0xb44905)['then'](function(_0x599d0b){return _0x599d0b;});}return null;};}function removeEntity(_0x1fbfaa,_0x154451){return function(_0x11ed9c){if(_0x11ed9c){return _0x11ed9c[_0xeb62('0x25')]()[_0xeb62('0x26')](function(){_0x1fbfaa['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x4664ce,_0x132861){return function(_0x182781){if(!_0x182781){_0x4664ce[_0xeb62('0x19')](0x194);}return _0x182781;};}function handleError(_0x55a169,_0x4e92f5){_0x4e92f5=_0x4e92f5||0x1f4;return function(_0x3ef988){logger['error'](_0x3ef988[_0xeb62('0x27')]);if(_0x3ef988['name']){delete _0x3ef988[_0xeb62('0x28')];}_0x55a169['status'](_0x4e92f5)[_0xeb62('0x29')](_0x3ef988);};}exports[_0xeb62('0x2a')]=function(_0x46d1bb,_0x4e4268){var _0x3ef784={},_0x3ae031={},_0x5222f4={'count':0x0,'rows':[]};var _0xe8872c=db[_0xeb62('0x2b')][_0xeb62('0x2c')];_0x3ae031['model']=_[_0xeb62('0x2d')](_0xe8872c);_0x3ae031[_0xeb62('0x2e')]=_['keys'](_0x46d1bb[_0xeb62('0x2e')]);_0x3ae031[_0xeb62('0x2f')]=_[_0xeb62('0x30')](_0x3ae031[_0xeb62('0x31')],_0x3ae031[_0xeb62('0x2e')]);_0x3ef784['attributes']=_['intersection'](_0x3ae031[_0xeb62('0x31')],qs[_0xeb62('0x32')](_0x46d1bb[_0xeb62('0x2e')][_0xeb62('0x32')]));_0x3ef784[_0xeb62('0x33')]=_0x3ef784[_0xeb62('0x33')][_0xeb62('0x34')]?_0x3ef784['attributes']:_0x3ae031[_0xeb62('0x31')];if(!_0x46d1bb['query']['hasOwnProperty'](_0xeb62('0x35'))){_0x3ef784[_0xeb62('0x1e')]=qs['limit'](_0x46d1bb[_0xeb62('0x2e')]['limit']);_0x3ef784[_0xeb62('0x1d')]=qs[_0xeb62('0x1d')](_0x46d1bb['query'][_0xeb62('0x1d')]);}_0x3ef784[_0xeb62('0x36')]=qs['sort'](_0x46d1bb[_0xeb62('0x2e')][_0xeb62('0x37')]);_0x3ef784[_0xeb62('0x38')]=qs[_0xeb62('0x2f')](_['pick'](_0x46d1bb[_0xeb62('0x2e')],_0x3ae031[_0xeb62('0x2f')]));if(_0x46d1bb['query']['filter']){_0x3ef784[_0xeb62('0x38')]=_[_0xeb62('0x39')](_0x3ef784['where'],{'$or':_[_0xeb62('0x3a')](_0xe8872c,function(_0x30cff0){if(_0x30cff0[_0xeb62('0x3b')][_0xeb62('0x3c')]!==_0xeb62('0x3d')){var _0x15387a={};_0x15387a[_0x30cff0[_0xeb62('0x3e')]]={'$like':'%'+_0x46d1bb['query']['filter']+'%'};return _0x15387a;}})});}_0x3ef784=_[_0xeb62('0x39')]({},_0x3ef784,_0x46d1bb[_0xeb62('0x3f')]);var _0x21772a={'where':_0x3ef784[_0xeb62('0x38')]};return db['JscriptyQuestionReport'][_0xeb62('0x1c')](_0x21772a)['then'](function(_0x20fd7a){_0x5222f4[_0xeb62('0x1c')]=_0x20fd7a;if(_0x46d1bb[_0xeb62('0x2e')][_0xeb62('0x40')]){_0x3ef784[_0xeb62('0x41')]=[{'all':!![]}];}return db[_0xeb62('0x2b')][_0xeb62('0x42')](_0x3ef784);})[_0xeb62('0x26')](function(_0x5e8ef8){_0x5222f4[_0xeb62('0x43')]=_0x5e8ef8;return _0x5222f4;})[_0xeb62('0x26')](respondWithFilteredResult(_0x4e4268,_0x3ef784))[_0xeb62('0x44')](handleError(_0x4e4268,null));};exports[_0xeb62('0x45')]=function(_0x5dd0e3,_0x4eda8b){var _0x46a560={'raw':!![],'where':{'id':_0x5dd0e3['params']['id']}},_0x41fb7d={};_0x41fb7d[_0xeb62('0x31')]=_[_0xeb62('0x2d')](db['JscriptyQuestionReport'][_0xeb62('0x2c')]);_0x41fb7d['query']=_[_0xeb62('0x2d')](_0x5dd0e3['query']);_0x41fb7d[_0xeb62('0x2f')]=_['intersection'](_0x41fb7d[_0xeb62('0x31')],_0x41fb7d[_0xeb62('0x2e')]);_0x46a560[_0xeb62('0x33')]=_['intersection'](_0x41fb7d['model'],qs[_0xeb62('0x32')](_0x5dd0e3[_0xeb62('0x2e')][_0xeb62('0x32')]));_0x46a560[_0xeb62('0x33')]=_0x46a560[_0xeb62('0x33')]['length']?_0x46a560[_0xeb62('0x33')]:_0x41fb7d['model'];if(_0x5dd0e3[_0xeb62('0x2e')]['includeAll']){_0x46a560[_0xeb62('0x41')]=[{'all':!![]}];}_0x46a560=_['merge']({},_0x46a560,_0x5dd0e3[_0xeb62('0x3f')]);return db['JscriptyQuestionReport'][_0xeb62('0x46')](_0x46a560)[_0xeb62('0x26')](handleEntityNotFound(_0x4eda8b,null))[_0xeb62('0x26')](respondWithResult(_0x4eda8b,null))[_0xeb62('0x44')](handleError(_0x4eda8b,null));};exports[_0xeb62('0x47')]=function(_0x21bb97,_0x4e62eb){return db[_0xeb62('0x2b')][_0xeb62('0x47')](_0x21bb97['body'],{})['then'](respondWithResult(_0x4e62eb,0xc9))['catch'](handleError(_0x4e62eb,null));};exports['update']=function(_0x24dff5,_0x12562f){if(_0x24dff5['body']['id']){delete _0x24dff5[_0xeb62('0x48')]['id'];}return db[_0xeb62('0x2b')][_0xeb62('0x46')]({'where':{'id':_0x24dff5[_0xeb62('0x49')]['id']}})[_0xeb62('0x26')](handleEntityNotFound(_0x12562f,null))['then'](saveUpdates(_0x24dff5[_0xeb62('0x48')],null))['then'](respondWithResult(_0x12562f,null))[_0xeb62('0x44')](handleError(_0x12562f,null));};exports[_0xeb62('0x25')]=function(_0x7fb53f,_0x18c40d){return db[_0xeb62('0x2b')][_0xeb62('0x46')]({'where':{'id':_0x7fb53f[_0xeb62('0x49')]['id']}})[_0xeb62('0x26')](handleEntityNotFound(_0x18c40d,null))[_0xeb62('0x26')](removeEntity(_0x18c40d,null))[_0xeb62('0x44')](handleError(_0x18c40d,null));};exports[_0xeb62('0x4a')]=function(_0x13e102,_0x4c3b96){return db[_0xeb62('0x2b')]['describe']()['then'](respondWithResult(_0x4c3b96,null))[_0xeb62('0x44')](handleError(_0x4c3b96,null));};