Built motion from commit (unavailable).|2.0.83
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 5b0b9e8..513bbb7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f49=['stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject','save','destroy','stack','name','send','index','rawAttributes','keys','query','dateStart','dateEnd','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','add','merge','filter','options','includeAll','include','findAll','rows','params','VtigerConfiguration','find','create','body','update','getFields','findOne','VtigerField','order','map','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','querystring','papaparse','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','client','http','request','then','info','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s'];(function(_0x2b9294,_0x3a7140){var _0x2fa110=function(_0x44cf55){while(--_0x44cf55){_0x2b9294['push'](_0x2b9294['shift']());}};_0x2fa110(++_0x3a7140);}(_0x8f49,0x19f));var _0x98f4=function(_0x5e6337,_0x2700b3){_0x5e6337=_0x5e6337-0x0;var _0x270b4d=_0x8f49[_0x5e6337];return _0x270b4d;};'use strict';var pdf=require(_0x98f4('0x0'));var emlformat=require(_0x98f4('0x1'));var rimraf=require(_0x98f4('0x2'));var zipdir=require(_0x98f4('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x98f4('0x4'));var moment=require(_0x98f4('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x98f4('0x6'));var util=require(_0x98f4('0x7'));var path=require(_0x98f4('0x8'));var sox=require(_0x98f4('0x9'));var csv=require(_0x98f4('0xa'));var ejs=require(_0x98f4('0xb'));var fs=require('fs');var _=require(_0x98f4('0xc'));var squel=require(_0x98f4('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x98f4('0xe'));var Papa=require(_0x98f4('0xf'));var qs=require(_0x98f4('0x10'));var logger=require(_0x98f4('0x11'))(_0x98f4('0x12'));var utils=require(_0x98f4('0x13'));var config=require(_0x98f4('0x14'));var db=require('../../mysqldb')['db'];var jayson=require('jayson/promise');var client=jayson[_0x98f4('0x15')][_0x98f4('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x505672,_0x5f22b7,_0x20aeeb,_0x57edc5){return new BPromise(function(_0x260881,_0x578925){var _0x4358dd=_0x57edc5||client;return _0x4358dd[_0x98f4('0x17')](_0x505672,_0x20aeeb)[_0x98f4('0x18')](function(_0x2e4e88){logger[_0x98f4('0x19')](_0x98f4('0x1a'),_0x5f22b7,_0x98f4('0x1b'));logger[_0x98f4('0x1c')](_0x98f4('0x1d'),_0x5f22b7,_0x98f4('0x1b'),JSON[_0x98f4('0x1e')](_0x2e4e88));if(_0x2e4e88['error']){if(_0x2e4e88[_0x98f4('0x1f')][_0x98f4('0x20')]===0x1f4){logger[_0x98f4('0x1f')]('VtigerConfiguration,\x20%s,\x20%s',_0x5f22b7,_0x2e4e88[_0x98f4('0x1f')][_0x98f4('0x21')]);return _0x578925(_0x2e4e88['error'][_0x98f4('0x21')]);}logger['error'](_0x98f4('0x1a'),_0x5f22b7,_0x2e4e88['error'][_0x98f4('0x21')]);return _0x260881(_0x2e4e88[_0x98f4('0x1f')][_0x98f4('0x21')]);}else{logger[_0x98f4('0x19')](_0x98f4('0x1a'),_0x5f22b7,'request\x20sent');_0x260881(_0x2e4e88[_0x98f4('0x22')][_0x98f4('0x21')]);}})[_0x98f4('0x23')](function(_0x400071){logger[_0x98f4('0x1f')](_0x98f4('0x1a'),_0x5f22b7,_0x400071);_0x578925(_0x400071);});});}function respondWithStatusCode(_0x26fa56,_0x3d15e5){_0x3d15e5=_0x3d15e5||0xcc;return function(_0x4594fb){if(_0x4594fb){return _0x26fa56[_0x98f4('0x24')](_0x3d15e5);}return _0x26fa56[_0x98f4('0x25')](_0x3d15e5)[_0x98f4('0x26')]();};}function respondWithResult(_0xbe6ef4,_0x5cfdfa){_0x5cfdfa=_0x5cfdfa||0xc8;return function(_0x4913f2){if(_0x4913f2){return _0xbe6ef4[_0x98f4('0x25')](_0x5cfdfa)[_0x98f4('0x27')](_0x4913f2);}};}function respondWithFilteredResult(_0xdcd050,_0x936341){return function(_0x1aad9b){if(_0x1aad9b){var _0x1eccbd=_0x1aad9b[_0x98f4('0x28')],_0x40ce79=_0x936341['offset'],_0x412d73=_0x936341[_0x98f4('0x29')]+_0x936341[_0x98f4('0x2a')],_0x1b0362;if(_0x412d73>=_0x1eccbd){_0x412d73=_0x1eccbd;_0x1b0362=0xc8;}else{_0x1b0362=0xce;}_0xdcd050[_0x98f4('0x25')](_0x1b0362);return _0xdcd050['set'](_0x98f4('0x2b'),_0x40ce79+'-'+_0x412d73+'/'+_0x1eccbd)[_0x98f4('0x27')](_0x1aad9b);}return null;};}function patchUpdates(_0x4ee2d1){return function(_0x2da7bf){try{jsonpatch[_0x98f4('0x2c')](_0x2da7bf,_0x4ee2d1,!![]);}catch(_0x474fd8){return BPromise[_0x98f4('0x2d')](_0x474fd8);}return _0x2da7bf[_0x98f4('0x2e')]();};}function saveUpdates(_0x3240bc,_0xea5ac8){return function(_0x4cac83){if(_0x4cac83){return _0x4cac83['update'](_0x3240bc)[_0x98f4('0x18')](function(_0x1128a6){return _0x1128a6;});}return null;};}function removeEntity(_0x321d70,_0x3c29f4){return function(_0x21eac9){if(_0x21eac9){return _0x21eac9[_0x98f4('0x2f')]()['then'](function(){_0x321d70[_0x98f4('0x25')](0xcc)[_0x98f4('0x26')]();});}};}function handleEntityNotFound(_0x35af60,_0xfb8180){return function(_0x20abc2){if(!_0x20abc2){_0x35af60[_0x98f4('0x24')](0x194);}return _0x20abc2;};}function handleError(_0x2ce662,_0x4bccf6){_0x4bccf6=_0x4bccf6||0x1f4;return function(_0x530ebf){logger[_0x98f4('0x1f')](_0x530ebf[_0x98f4('0x30')]);if(_0x530ebf[_0x98f4('0x31')]){delete _0x530ebf[_0x98f4('0x31')];}_0x2ce662[_0x98f4('0x25')](_0x4bccf6)[_0x98f4('0x32')](_0x530ebf);};}exports[_0x98f4('0x33')]=function(_0x3075e5,_0x4e6b51){var _0x541804={},_0x4d1550={},_0x3dc89e={'count':0x0,'rows':[]};var _0x5fd731=db['VtigerConfiguration'][_0x98f4('0x34')];_0x4d1550['model']=_[_0x98f4('0x35')](_0x5fd731);var _0x5a6875={'dateStart':_0x3075e5[_0x98f4('0x36')][_0x98f4('0x37')],'dateEnd':_0x3075e5[_0x98f4('0x36')][_0x98f4('0x38')]};delete _0x3075e5[_0x98f4('0x36')][_0x98f4('0x37')];delete _0x3075e5[_0x98f4('0x36')][_0x98f4('0x38')];_0x4d1550[_0x98f4('0x36')]=_[_0x98f4('0x35')](_0x3075e5[_0x98f4('0x36')]);_0x4d1550[_0x98f4('0x39')]=_['intersection'](_0x4d1550[_0x98f4('0x3a')],_0x4d1550[_0x98f4('0x36')]);_0x541804[_0x98f4('0x3b')]=_[_0x98f4('0x3c')](_0x4d1550['model'],qs[_0x98f4('0x3d')](_0x3075e5[_0x98f4('0x36')][_0x98f4('0x3d')]));_0x541804['attributes']=_0x541804['attributes'][_0x98f4('0x3e')]?_0x541804[_0x98f4('0x3b')]:_0x4d1550[_0x98f4('0x3a')];if(!_0x3075e5[_0x98f4('0x36')][_0x98f4('0x3f')](_0x98f4('0x40'))){_0x541804[_0x98f4('0x2a')]=qs[_0x98f4('0x2a')](_0x3075e5[_0x98f4('0x36')]['limit']);_0x541804['offset']=qs['offset'](_0x3075e5[_0x98f4('0x36')][_0x98f4('0x29')]);}_0x541804['order']=qs[_0x98f4('0x41')](_0x3075e5[_0x98f4('0x36')][_0x98f4('0x41')]);_0x541804[_0x98f4('0x42')]=qs[_0x98f4('0x39')](_[_0x98f4('0x43')](_0x3075e5['query'],_0x4d1550['filters']));if(_0x5a6875[_0x98f4('0x37')]){if(_0x5a6875[_0x98f4('0x38')]){_0x5a6875[_0x98f4('0x38')]=moment(_0x5a6875[_0x98f4('0x38')])[_0x98f4('0x44')](0x1,'day');}else{_0x5a6875[_0x98f4('0x38')]=moment(_0x5a6875[_0x98f4('0x37')])[_0x98f4('0x44')](0x1,'day');}_[_0x98f4('0x45')](_0x541804['where'],{'createdAt':{'$gte':_0x5a6875['dateStart'],'$lte':_0x5a6875[_0x98f4('0x38')]}});}if(_0x3075e5[_0x98f4('0x36')][_0x98f4('0x46')]){_0x541804[_0x98f4('0x42')]=_[_0x98f4('0x45')](_0x541804['where'],{'$or':_['map'](_0x541804[_0x98f4('0x3b')],function(_0x37e858){var _0x32aa5b={};_0x32aa5b[_0x37e858]={'$like':'%'+_0x3075e5[_0x98f4('0x36')]['filter']+'%'};return _0x32aa5b;})});}_0x541804=_['merge']({},_0x541804,_0x3075e5[_0x98f4('0x47')]);var _0x386feb={'where':_0x541804[_0x98f4('0x42')]};return db['VtigerConfiguration'][_0x98f4('0x28')](_0x386feb)[_0x98f4('0x18')](function(_0x18c691){_0x3dc89e[_0x98f4('0x28')]=_0x18c691;if(_0x3075e5['query'][_0x98f4('0x48')]){_0x541804[_0x98f4('0x49')]=[{'all':!![]}];}return db['VtigerConfiguration'][_0x98f4('0x4a')](_0x541804);})[_0x98f4('0x18')](function(_0x4edb0d){_0x3dc89e[_0x98f4('0x4b')]=_0x4edb0d;return _0x3dc89e;})[_0x98f4('0x18')](respondWithFilteredResult(_0x4e6b51,_0x541804))[_0x98f4('0x23')](handleError(_0x4e6b51,null));};exports['show']=function(_0x406924,_0x27216e){var _0x4e0c28={'raw':![],'where':{'id':_0x406924[_0x98f4('0x4c')]['id']}},_0x43bcba={};_0x43bcba[_0x98f4('0x3a')]=_[_0x98f4('0x35')](db[_0x98f4('0x4d')][_0x98f4('0x34')]);_0x43bcba[_0x98f4('0x36')]=_[_0x98f4('0x35')](_0x406924[_0x98f4('0x36')]);_0x43bcba['filters']=_[_0x98f4('0x3c')](_0x43bcba[_0x98f4('0x3a')],_0x43bcba[_0x98f4('0x36')]);_0x4e0c28[_0x98f4('0x3b')]=_[_0x98f4('0x3c')](_0x43bcba[_0x98f4('0x3a')],qs[_0x98f4('0x3d')](_0x406924[_0x98f4('0x36')][_0x98f4('0x3d')]));_0x4e0c28[_0x98f4('0x3b')]=_0x4e0c28['attributes'][_0x98f4('0x3e')]?_0x4e0c28[_0x98f4('0x3b')]:_0x43bcba[_0x98f4('0x3a')];if(_0x406924[_0x98f4('0x36')]['includeAll']){_0x4e0c28[_0x98f4('0x49')]=[{'all':!![]}];}_0x4e0c28=_[_0x98f4('0x45')]({},_0x4e0c28,_0x406924[_0x98f4('0x47')]);return db[_0x98f4('0x4d')][_0x98f4('0x4e')](_0x4e0c28)[_0x98f4('0x18')](handleEntityNotFound(_0x27216e,null))[_0x98f4('0x18')](respondWithResult(_0x27216e,null))[_0x98f4('0x23')](handleError(_0x27216e,null));};exports[_0x98f4('0x4f')]=function(_0x2c73de,_0x85ad08){return db['VtigerConfiguration'][_0x98f4('0x4f')](_0x2c73de[_0x98f4('0x50')],{})[_0x98f4('0x18')](respondWithResult(_0x85ad08,0xc9))['catch'](handleError(_0x85ad08,null));};exports[_0x98f4('0x51')]=function(_0x17b41e,_0x356fbf){if(_0x17b41e['body']['id']){delete _0x17b41e['body']['id'];}return db['VtigerConfiguration'][_0x98f4('0x4e')]({'where':{'id':_0x17b41e[_0x98f4('0x4c')]['id']}})[_0x98f4('0x18')](handleEntityNotFound(_0x356fbf,null))[_0x98f4('0x18')](saveUpdates(_0x17b41e[_0x98f4('0x50')],null))['then'](respondWithResult(_0x356fbf,null))[_0x98f4('0x23')](handleError(_0x356fbf,null));};exports[_0x98f4('0x2f')]=function(_0x14912d,_0x434740){return db['VtigerConfiguration'][_0x98f4('0x4e')]({'where':{'id':_0x14912d['params']['id']}})[_0x98f4('0x18')](handleEntityNotFound(_0x434740,null))[_0x98f4('0x18')](removeEntity(_0x434740,null))['catch'](handleError(_0x434740,null));};exports[_0x98f4('0x52')]=function(_0x1309a6,_0x2ff202,_0x816587){var _0x43d849={};var _0x1537a8={};var _0x5b83fa;var _0xff5b46;return db[_0x98f4('0x4d')][_0x98f4('0x53')]({'where':{'id':_0x1309a6[_0x98f4('0x4c')]['id']}})[_0x98f4('0x18')](handleEntityNotFound(_0x2ff202,null))[_0x98f4('0x18')](function(_0x2c6d66){if(_0x2c6d66){_0x5b83fa=_0x2c6d66;_0x1537a8[_0x98f4('0x3a')]=_[_0x98f4('0x35')](db[_0x98f4('0x54')]['rawAttributes']);_0x1537a8['query']=_[_0x98f4('0x35')](_0x1309a6[_0x98f4('0x36')]);_0x1537a8[_0x98f4('0x39')]=_[_0x98f4('0x3c')](_0x1537a8['model'],_0x1537a8[_0x98f4('0x36')]);_0x43d849[_0x98f4('0x3b')]=_[_0x98f4('0x3c')](_0x1537a8[_0x98f4('0x3a')],qs[_0x98f4('0x3d')](_0x1309a6[_0x98f4('0x36')][_0x98f4('0x3d')]));_0x43d849[_0x98f4('0x3b')]=_0x43d849[_0x98f4('0x3b')][_0x98f4('0x3e')]?_0x43d849[_0x98f4('0x3b')]:_0x1537a8[_0x98f4('0x3a')];_0x43d849[_0x98f4('0x55')]=qs[_0x98f4('0x41')](_0x1309a6[_0x98f4('0x36')]['sort']);_0x43d849[_0x98f4('0x42')]=qs[_0x98f4('0x39')](_[_0x98f4('0x43')](_0x1309a6[_0x98f4('0x36')],_0x1537a8['filters']));if(_0x1309a6[_0x98f4('0x36')][_0x98f4('0x46')]){_0x43d849[_0x98f4('0x42')]=_[_0x98f4('0x45')](_0x43d849[_0x98f4('0x42')],{'$or':_[_0x98f4('0x56')](_0x43d849[_0x98f4('0x3b')],function(_0x5367e6){var _0x23459a={};_0x23459a[_0x5367e6]={'$like':'%'+_0x1309a6['query']['filter']+'%'};return _0x23459a;})});}_0x43d849=_[_0x98f4('0x45')]({},_0x43d849,_0x1309a6[_0x98f4('0x47')]);return _0x5b83fa[_0x98f4('0x52')](_0x43d849);}})[_0x98f4('0x18')](function(_0x217602){if(_0x217602){_0xff5b46=_0x217602[_0x98f4('0x3e')];if(!_0x1309a6[_0x98f4('0x36')][_0x98f4('0x3f')](_0x98f4('0x40'))){_0x43d849[_0x98f4('0x2a')]=qs[_0x98f4('0x2a')](_0x1309a6[_0x98f4('0x36')][_0x98f4('0x2a')]);_0x43d849[_0x98f4('0x29')]=qs[_0x98f4('0x29')](_0x1309a6[_0x98f4('0x36')]['offset']);}return _0x5b83fa[_0x98f4('0x52')](_0x43d849);}})['then'](function(_0x3c0e22){if(_0x3c0e22){return _0x3c0e22?{'count':_0xff5b46,'rows':_0x3c0e22}:null;}})[_0x98f4('0x18')](respondWithResult(_0x2ff202,null))[_0x98f4('0x23')](handleError(_0x2ff202,null));};exports['getSubjects']=function(_0xb908e0,_0x19f770,_0x2011e0){var _0x106ee7={};var _0x9750d8={};var _0x4e457b;var _0x488746;return db['VtigerConfiguration'][_0x98f4('0x53')]({'where':{'id':_0xb908e0[_0x98f4('0x4c')]['id']}})['then'](handleEntityNotFound(_0x19f770,null))['then'](function(_0x150eaf){if(_0x150eaf){_0x4e457b=_0x150eaf;_0x9750d8[_0x98f4('0x3a')]=_[_0x98f4('0x35')](db[_0x98f4('0x54')][_0x98f4('0x34')]);_0x9750d8[_0x98f4('0x36')]=_[_0x98f4('0x35')](_0xb908e0['query']);_0x9750d8[_0x98f4('0x39')]=_[_0x98f4('0x3c')](_0x9750d8[_0x98f4('0x3a')],_0x9750d8['query']);_0x106ee7[_0x98f4('0x3b')]=_[_0x98f4('0x3c')](_0x9750d8['model'],qs[_0x98f4('0x3d')](_0xb908e0[_0x98f4('0x36')][_0x98f4('0x3d')]));_0x106ee7[_0x98f4('0x3b')]=_0x106ee7[_0x98f4('0x3b')]['length']?_0x106ee7['attributes']:_0x9750d8[_0x98f4('0x3a')];_0x106ee7[_0x98f4('0x55')]=qs[_0x98f4('0x41')](_0xb908e0[_0x98f4('0x36')]['sort']);_0x106ee7[_0x98f4('0x42')]=qs[_0x98f4('0x39')](_[_0x98f4('0x43')](_0xb908e0['query'],_0x9750d8[_0x98f4('0x39')]));if(_0xb908e0['query'][_0x98f4('0x46')]){_0x106ee7[_0x98f4('0x42')]=_[_0x98f4('0x45')](_0x106ee7[_0x98f4('0x42')],{'$or':_[_0x98f4('0x56')](_0x106ee7[_0x98f4('0x3b')],function(_0x30372f){var _0x4d91bd={};_0x4d91bd[_0x30372f]={'$like':'%'+_0xb908e0[_0x98f4('0x36')][_0x98f4('0x46')]+'%'};return _0x4d91bd;})});}_0x106ee7=_[_0x98f4('0x45')]({},_0x106ee7,_0xb908e0[_0x98f4('0x47')]);return _0x4e457b[_0x98f4('0x57')](_0x106ee7);}})[_0x98f4('0x18')](function(_0xf16cbe){if(_0xf16cbe){_0x488746=_0xf16cbe['length'];if(!_0xb908e0[_0x98f4('0x36')][_0x98f4('0x3f')]('nolimit')){_0x106ee7[_0x98f4('0x2a')]=qs[_0x98f4('0x2a')](_0xb908e0['query'][_0x98f4('0x2a')]);_0x106ee7[_0x98f4('0x29')]=qs[_0x98f4('0x29')](_0xb908e0[_0x98f4('0x36')][_0x98f4('0x29')]);}return _0x4e457b[_0x98f4('0x57')](_0x106ee7);}})[_0x98f4('0x18')](function(_0x5e0550){if(_0x5e0550){return _0x5e0550?{'count':_0x488746,'rows':_0x5e0550}:null;}})[_0x98f4('0x18')](respondWithResult(_0x19f770,null))['catch'](handleError(_0x19f770,null));};exports[_0x98f4('0x58')]=function(_0x443c60,_0x35b1b8,_0x23f50f){var _0x18cf11={};var _0x541949={};var _0x127f0b;var _0x422b71;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x443c60[_0x98f4('0x4c')]['id']}})[_0x98f4('0x18')](handleEntityNotFound(_0x35b1b8,null))[_0x98f4('0x18')](function(_0x1b4971){if(_0x1b4971){_0x127f0b=_0x1b4971;_0x541949[_0x98f4('0x3a')]=_[_0x98f4('0x35')](db[_0x98f4('0x54')][_0x98f4('0x34')]);_0x541949['query']=_[_0x98f4('0x35')](_0x443c60[_0x98f4('0x36')]);_0x541949['filters']=_[_0x98f4('0x3c')](_0x541949[_0x98f4('0x3a')],_0x541949['query']);_0x18cf11[_0x98f4('0x3b')]=_[_0x98f4('0x3c')](_0x541949[_0x98f4('0x3a')],qs['fields'](_0x443c60['query'][_0x98f4('0x3d')]));_0x18cf11[_0x98f4('0x3b')]=_0x18cf11[_0x98f4('0x3b')][_0x98f4('0x3e')]?_0x18cf11[_0x98f4('0x3b')]:_0x541949['model'];_0x18cf11[_0x98f4('0x55')]=qs[_0x98f4('0x41')](_0x443c60[_0x98f4('0x36')]['sort']);_0x18cf11[_0x98f4('0x42')]=qs[_0x98f4('0x39')](_['pick'](_0x443c60['query'],_0x541949[_0x98f4('0x39')]));if(_0x443c60['query'][_0x98f4('0x46')]){_0x18cf11[_0x98f4('0x42')]=_['merge'](_0x18cf11[_0x98f4('0x42')],{'$or':_[_0x98f4('0x56')](_0x18cf11[_0x98f4('0x3b')],function(_0x3b13aa){var _0x201e2a={};_0x201e2a[_0x3b13aa]={'$like':'%'+_0x443c60[_0x98f4('0x36')][_0x98f4('0x46')]+'%'};return _0x201e2a;})});}_0x18cf11=_[_0x98f4('0x45')]({},_0x18cf11,_0x443c60['options']);return _0x127f0b[_0x98f4('0x58')](_0x18cf11);}})[_0x98f4('0x18')](function(_0x19deba){if(_0x19deba){_0x422b71=_0x19deba[_0x98f4('0x3e')];if(!_0x443c60[_0x98f4('0x36')][_0x98f4('0x3f')](_0x98f4('0x40'))){_0x18cf11['limit']=qs[_0x98f4('0x2a')](_0x443c60[_0x98f4('0x36')][_0x98f4('0x2a')]);_0x18cf11[_0x98f4('0x29')]=qs[_0x98f4('0x29')](_0x443c60[_0x98f4('0x36')][_0x98f4('0x29')]);}return _0x127f0b['getDescriptions'](_0x18cf11);}})[_0x98f4('0x18')](function(_0x83f9c9){if(_0x83f9c9){return _0x83f9c9?{'count':_0x422b71,'rows':_0x83f9c9}:null;}})[_0x98f4('0x18')](respondWithResult(_0x35b1b8,null))[_0x98f4('0x23')](handleError(_0x35b1b8,null));};
\ No newline at end of file
+var _0x2bc6=['mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','client','http','request','info','VtigerConfiguration,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','result','catch','status','offset','limit','set','Content-Range','apply','reject','save','update','then','end','stack','name','send','index','VtigerConfiguration','rawAttributes','model','keys','query','dateStart','dateEnd','intersection','attributes','fields','hasOwnProperty','sort','filters','pick','add','day','merge','where','filter','map','options','count','includeAll','findAll','show','params','length','find','create','body','destroy','getFields','findOne','order','nolimit','VtigerField','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment'];(function(_0x32ce61,_0x2ba733){var _0x28eded=function(_0x34db11){while(--_0x34db11){_0x32ce61['push'](_0x32ce61['shift']());}};_0x28eded(++_0x2ba733);}(_0x2bc6,0xac));var _0x62bc=function(_0x49431e,_0x17699a){_0x49431e=_0x49431e-0x0;var _0x759cc0=_0x2bc6[_0x49431e];return _0x759cc0;};'use strict';var pdf=require(_0x62bc('0x0'));var emlformat=require(_0x62bc('0x1'));var rimraf=require(_0x62bc('0x2'));var zipdir=require(_0x62bc('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x62bc('0x4'));var moment=require(_0x62bc('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x62bc('0x6'));var util=require(_0x62bc('0x7'));var path=require(_0x62bc('0x8'));var sox=require(_0x62bc('0x9'));var csv=require(_0x62bc('0xa'));var ejs=require(_0x62bc('0xb'));var fs=require('fs');var _=require(_0x62bc('0xc'));var squel=require(_0x62bc('0xd'));var crypto=require(_0x62bc('0xe'));var jsforce=require(_0x62bc('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x62bc('0xa'));var querystring=require(_0x62bc('0x10'));var Papa=require(_0x62bc('0x11'));var qs=require(_0x62bc('0x12'));var logger=require(_0x62bc('0x13'))(_0x62bc('0x14'));var utils=require(_0x62bc('0x15'));var config=require(_0x62bc('0x16'));var db=require(_0x62bc('0x17'))['db'];var jayson=require(_0x62bc('0x18'));var client=jayson[_0x62bc('0x19')][_0x62bc('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x5aa745,_0x3ae804,_0x308390,_0x4f0039){return new BPromise(function(_0x57e490,_0x3e5d12){var _0x46b7b9=_0x4f0039||client;return _0x46b7b9[_0x62bc('0x1b')](_0x5aa745,_0x308390)['then'](function(_0x293288){logger[_0x62bc('0x1c')](_0x62bc('0x1d'),_0x3ae804,'request\x20sent');logger[_0x62bc('0x1e')]('VtigerConfiguration,\x20%s,\x20%s,\x20%s',_0x3ae804,_0x62bc('0x1f'),JSON[_0x62bc('0x20')](_0x293288));if(_0x293288[_0x62bc('0x21')]){if(_0x293288[_0x62bc('0x21')]['code']===0x1f4){logger['error'](_0x62bc('0x1d'),_0x3ae804,_0x293288[_0x62bc('0x21')][_0x62bc('0x22')]);return _0x3e5d12(_0x293288[_0x62bc('0x21')][_0x62bc('0x22')]);}logger[_0x62bc('0x21')](_0x62bc('0x1d'),_0x3ae804,_0x293288[_0x62bc('0x21')]['message']);return _0x57e490(_0x293288[_0x62bc('0x21')][_0x62bc('0x22')]);}else{logger['info'](_0x62bc('0x1d'),_0x3ae804,_0x62bc('0x1f'));_0x57e490(_0x293288[_0x62bc('0x23')][_0x62bc('0x22')]);}})[_0x62bc('0x24')](function(_0x3e44e9){logger['error'](_0x62bc('0x1d'),_0x3ae804,_0x3e44e9);_0x3e5d12(_0x3e44e9);});});}function respondWithStatusCode(_0x1ed7d3,_0x467e6d){_0x467e6d=_0x467e6d||0xcc;return function(_0x4b80be){if(_0x4b80be){return _0x1ed7d3['sendStatus'](_0x467e6d);}return _0x1ed7d3[_0x62bc('0x25')](_0x467e6d)['end']();};}function respondWithResult(_0x147267,_0x3f8917){_0x3f8917=_0x3f8917||0xc8;return function(_0x3a0b95){if(_0x3a0b95){return _0x147267[_0x62bc('0x25')](_0x3f8917)['json'](_0x3a0b95);}};}function respondWithFilteredResult(_0x130087,_0x233877){return function(_0x58b9cf){if(_0x58b9cf){var _0x2f3534=_0x58b9cf['count'],_0x53d8d9=_0x233877['offset'],_0x4dfb2b=_0x233877[_0x62bc('0x26')]+_0x233877[_0x62bc('0x27')],_0x44ca3d;if(_0x4dfb2b>=_0x2f3534){_0x4dfb2b=_0x2f3534;_0x44ca3d=0xc8;}else{_0x44ca3d=0xce;}_0x130087[_0x62bc('0x25')](_0x44ca3d);return _0x130087[_0x62bc('0x28')](_0x62bc('0x29'),_0x53d8d9+'-'+_0x4dfb2b+'/'+_0x2f3534)['json'](_0x58b9cf);}return null;};}function patchUpdates(_0x1c4537){return function(_0x2c7189){try{jsonpatch[_0x62bc('0x2a')](_0x2c7189,_0x1c4537,!![]);}catch(_0x27aa40){return BPromise[_0x62bc('0x2b')](_0x27aa40);}return _0x2c7189[_0x62bc('0x2c')]();};}function saveUpdates(_0x3856d3,_0xb01d97){return function(_0x50bd8f){if(_0x50bd8f){return _0x50bd8f[_0x62bc('0x2d')](_0x3856d3)['then'](function(_0x5cb650){return _0x5cb650;});}return null;};}function removeEntity(_0x578768,_0x3e053f){return function(_0x401070){if(_0x401070){return _0x401070['destroy']()[_0x62bc('0x2e')](function(){_0x578768['status'](0xcc)[_0x62bc('0x2f')]();});}};}function handleEntityNotFound(_0x295ba9,_0x4c5dcc){return function(_0x203218){if(!_0x203218){_0x295ba9['sendStatus'](0x194);}return _0x203218;};}function handleError(_0x463b56,_0x3b036c){_0x3b036c=_0x3b036c||0x1f4;return function(_0x82e147){logger['error'](_0x82e147[_0x62bc('0x30')]);if(_0x82e147[_0x62bc('0x31')]){delete _0x82e147[_0x62bc('0x31')];}_0x463b56[_0x62bc('0x25')](_0x3b036c)[_0x62bc('0x32')](_0x82e147);};}exports[_0x62bc('0x33')]=function(_0x1bfe02,_0x14bd47){var _0x3a94e8={},_0x19545b={},_0xe7d484={'count':0x0,'rows':[]};var _0x44a83d=db[_0x62bc('0x34')][_0x62bc('0x35')];_0x19545b[_0x62bc('0x36')]=_[_0x62bc('0x37')](_0x44a83d);var _0x2ec3d6={'dateStart':_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x39')],'dateEnd':_0x1bfe02[_0x62bc('0x38')]['dateEnd']};delete _0x1bfe02[_0x62bc('0x38')][_0x62bc('0x39')];delete _0x1bfe02[_0x62bc('0x38')][_0x62bc('0x3a')];_0x19545b[_0x62bc('0x38')]=_[_0x62bc('0x37')](_0x1bfe02[_0x62bc('0x38')]);_0x19545b['filters']=_[_0x62bc('0x3b')](_0x19545b[_0x62bc('0x36')],_0x19545b[_0x62bc('0x38')]);_0x3a94e8[_0x62bc('0x3c')]=_[_0x62bc('0x3b')](_0x19545b[_0x62bc('0x36')],qs['fields'](_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x3d')]));_0x3a94e8['attributes']=_0x3a94e8[_0x62bc('0x3c')]['length']?_0x3a94e8[_0x62bc('0x3c')]:_0x19545b[_0x62bc('0x36')];if(!_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x3e')]('nolimit')){_0x3a94e8[_0x62bc('0x27')]=qs['limit'](_0x1bfe02['query'][_0x62bc('0x27')]);_0x3a94e8[_0x62bc('0x26')]=qs[_0x62bc('0x26')](_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x26')]);}_0x3a94e8['order']=qs[_0x62bc('0x3f')](_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x3f')]);_0x3a94e8['where']=qs[_0x62bc('0x40')](_[_0x62bc('0x41')](_0x1bfe02['query'],_0x19545b[_0x62bc('0x40')]));if(_0x2ec3d6[_0x62bc('0x39')]){if(_0x2ec3d6[_0x62bc('0x3a')]){_0x2ec3d6[_0x62bc('0x3a')]=moment(_0x2ec3d6[_0x62bc('0x3a')])[_0x62bc('0x42')](0x1,_0x62bc('0x43'));}else{_0x2ec3d6[_0x62bc('0x3a')]=moment(_0x2ec3d6[_0x62bc('0x39')])[_0x62bc('0x42')](0x1,_0x62bc('0x43'));}_[_0x62bc('0x44')](_0x3a94e8[_0x62bc('0x45')],{'createdAt':{'$gte':_0x2ec3d6[_0x62bc('0x39')],'$lte':_0x2ec3d6[_0x62bc('0x3a')]}});}if(_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x46')]){_0x3a94e8[_0x62bc('0x45')]=_[_0x62bc('0x44')](_0x3a94e8['where'],{'$or':_[_0x62bc('0x47')](_0x3a94e8['attributes'],function(_0x104be7){var _0x2db719={};_0x2db719[_0x104be7]={'$like':'%'+_0x1bfe02['query'][_0x62bc('0x46')]+'%'};return _0x2db719;})});}_0x3a94e8=_['merge']({},_0x3a94e8,_0x1bfe02[_0x62bc('0x48')]);var _0x214ea4={'where':_0x3a94e8['where']};return db['VtigerConfiguration']['count'](_0x214ea4)[_0x62bc('0x2e')](function(_0x1bf22e){_0xe7d484[_0x62bc('0x49')]=_0x1bf22e;if(_0x1bfe02[_0x62bc('0x38')][_0x62bc('0x4a')]){_0x3a94e8['include']=[{'all':!![]}];}return db['VtigerConfiguration'][_0x62bc('0x4b')](_0x3a94e8);})['then'](function(_0x2077a5){_0xe7d484['rows']=_0x2077a5;return _0xe7d484;})[_0x62bc('0x2e')](respondWithFilteredResult(_0x14bd47,_0x3a94e8))[_0x62bc('0x24')](handleError(_0x14bd47,null));};exports[_0x62bc('0x4c')]=function(_0x5b028f,_0x3d6d19){var _0x3c9aa0={'raw':![],'where':{'id':_0x5b028f[_0x62bc('0x4d')]['id']}},_0x38e686={};_0x38e686[_0x62bc('0x36')]=_[_0x62bc('0x37')](db[_0x62bc('0x34')]['rawAttributes']);_0x38e686['query']=_[_0x62bc('0x37')](_0x5b028f['query']);_0x38e686['filters']=_[_0x62bc('0x3b')](_0x38e686[_0x62bc('0x36')],_0x38e686[_0x62bc('0x38')]);_0x3c9aa0[_0x62bc('0x3c')]=_[_0x62bc('0x3b')](_0x38e686[_0x62bc('0x36')],qs[_0x62bc('0x3d')](_0x5b028f[_0x62bc('0x38')]['fields']));_0x3c9aa0[_0x62bc('0x3c')]=_0x3c9aa0[_0x62bc('0x3c')][_0x62bc('0x4e')]?_0x3c9aa0[_0x62bc('0x3c')]:_0x38e686[_0x62bc('0x36')];if(_0x5b028f[_0x62bc('0x38')]['includeAll']){_0x3c9aa0['include']=[{'all':!![]}];}_0x3c9aa0=_['merge']({},_0x3c9aa0,_0x5b028f['options']);return db[_0x62bc('0x34')][_0x62bc('0x4f')](_0x3c9aa0)[_0x62bc('0x2e')](handleEntityNotFound(_0x3d6d19,null))[_0x62bc('0x2e')](respondWithResult(_0x3d6d19,null))[_0x62bc('0x24')](handleError(_0x3d6d19,null));};exports['create']=function(_0x36f616,_0x56a2b8){return db['VtigerConfiguration'][_0x62bc('0x50')](_0x36f616[_0x62bc('0x51')],{})[_0x62bc('0x2e')](respondWithResult(_0x56a2b8,0xc9))['catch'](handleError(_0x56a2b8,null));};exports[_0x62bc('0x2d')]=function(_0x43ba11,_0x2ec720){if(_0x43ba11[_0x62bc('0x51')]['id']){delete _0x43ba11[_0x62bc('0x51')]['id'];}return db[_0x62bc('0x34')][_0x62bc('0x4f')]({'where':{'id':_0x43ba11[_0x62bc('0x4d')]['id']}})[_0x62bc('0x2e')](handleEntityNotFound(_0x2ec720,null))['then'](saveUpdates(_0x43ba11[_0x62bc('0x51')],null))[_0x62bc('0x2e')](respondWithResult(_0x2ec720,null))[_0x62bc('0x24')](handleError(_0x2ec720,null));};exports[_0x62bc('0x52')]=function(_0x328a56,_0x4c2cec){return db[_0x62bc('0x34')]['find']({'where':{'id':_0x328a56['params']['id']}})[_0x62bc('0x2e')](handleEntityNotFound(_0x4c2cec,null))[_0x62bc('0x2e')](removeEntity(_0x4c2cec,null))[_0x62bc('0x24')](handleError(_0x4c2cec,null));};exports[_0x62bc('0x53')]=function(_0x556013,_0xd72c99,_0x58695d){var _0x107deb={};var _0x2fe69f={};var _0x8c47b7;var _0x46c360;return db[_0x62bc('0x34')][_0x62bc('0x54')]({'where':{'id':_0x556013[_0x62bc('0x4d')]['id']}})['then'](handleEntityNotFound(_0xd72c99,null))['then'](function(_0x27de0a){if(_0x27de0a){_0x8c47b7=_0x27de0a;_0x2fe69f[_0x62bc('0x36')]=_[_0x62bc('0x37')](db['VtigerField'][_0x62bc('0x35')]);_0x2fe69f[_0x62bc('0x38')]=_[_0x62bc('0x37')](_0x556013[_0x62bc('0x38')]);_0x2fe69f['filters']=_[_0x62bc('0x3b')](_0x2fe69f[_0x62bc('0x36')],_0x2fe69f['query']);_0x107deb[_0x62bc('0x3c')]=_[_0x62bc('0x3b')](_0x2fe69f['model'],qs['fields'](_0x556013['query']['fields']));_0x107deb[_0x62bc('0x3c')]=_0x107deb[_0x62bc('0x3c')][_0x62bc('0x4e')]?_0x107deb[_0x62bc('0x3c')]:_0x2fe69f[_0x62bc('0x36')];_0x107deb[_0x62bc('0x55')]=qs['sort'](_0x556013[_0x62bc('0x38')][_0x62bc('0x3f')]);_0x107deb['where']=qs['filters'](_['pick'](_0x556013[_0x62bc('0x38')],_0x2fe69f['filters']));if(_0x556013[_0x62bc('0x38')]['filter']){_0x107deb[_0x62bc('0x45')]=_[_0x62bc('0x44')](_0x107deb[_0x62bc('0x45')],{'$or':_[_0x62bc('0x47')](_0x107deb[_0x62bc('0x3c')],function(_0x1aaca3){var _0x2c9b00={};_0x2c9b00[_0x1aaca3]={'$like':'%'+_0x556013[_0x62bc('0x38')][_0x62bc('0x46')]+'%'};return _0x2c9b00;})});}_0x107deb=_['merge']({},_0x107deb,_0x556013[_0x62bc('0x48')]);return _0x8c47b7['getFields'](_0x107deb);}})[_0x62bc('0x2e')](function(_0x969c9c){if(_0x969c9c){_0x46c360=_0x969c9c[_0x62bc('0x4e')];if(!_0x556013['query'][_0x62bc('0x3e')](_0x62bc('0x56'))){_0x107deb['limit']=qs[_0x62bc('0x27')](_0x556013['query'][_0x62bc('0x27')]);_0x107deb[_0x62bc('0x26')]=qs[_0x62bc('0x26')](_0x556013[_0x62bc('0x38')][_0x62bc('0x26')]);}return _0x8c47b7[_0x62bc('0x53')](_0x107deb);}})[_0x62bc('0x2e')](function(_0x150e18){if(_0x150e18){return _0x150e18?{'count':_0x46c360,'rows':_0x150e18}:null;}})[_0x62bc('0x2e')](respondWithResult(_0xd72c99,null))['catch'](handleError(_0xd72c99,null));};exports['getSubjects']=function(_0x30d0fe,_0xe1b77c,_0x9aa01f){var _0x13201c={};var _0x556489={};var _0x44a6ed;var _0x74a2eb;return db[_0x62bc('0x34')][_0x62bc('0x54')]({'where':{'id':_0x30d0fe[_0x62bc('0x4d')]['id']}})[_0x62bc('0x2e')](handleEntityNotFound(_0xe1b77c,null))[_0x62bc('0x2e')](function(_0x1f1305){if(_0x1f1305){_0x44a6ed=_0x1f1305;_0x556489[_0x62bc('0x36')]=_[_0x62bc('0x37')](db[_0x62bc('0x57')][_0x62bc('0x35')]);_0x556489[_0x62bc('0x38')]=_[_0x62bc('0x37')](_0x30d0fe[_0x62bc('0x38')]);_0x556489[_0x62bc('0x40')]=_['intersection'](_0x556489['model'],_0x556489[_0x62bc('0x38')]);_0x13201c[_0x62bc('0x3c')]=_[_0x62bc('0x3b')](_0x556489[_0x62bc('0x36')],qs['fields'](_0x30d0fe['query']['fields']));_0x13201c[_0x62bc('0x3c')]=_0x13201c[_0x62bc('0x3c')][_0x62bc('0x4e')]?_0x13201c[_0x62bc('0x3c')]:_0x556489['model'];_0x13201c[_0x62bc('0x55')]=qs['sort'](_0x30d0fe[_0x62bc('0x38')][_0x62bc('0x3f')]);_0x13201c[_0x62bc('0x45')]=qs[_0x62bc('0x40')](_[_0x62bc('0x41')](_0x30d0fe['query'],_0x556489[_0x62bc('0x40')]));if(_0x30d0fe[_0x62bc('0x38')]['filter']){_0x13201c[_0x62bc('0x45')]=_[_0x62bc('0x44')](_0x13201c[_0x62bc('0x45')],{'$or':_[_0x62bc('0x47')](_0x13201c[_0x62bc('0x3c')],function(_0xa8ff96){var _0x4e0bc7={};_0x4e0bc7[_0xa8ff96]={'$like':'%'+_0x30d0fe[_0x62bc('0x38')]['filter']+'%'};return _0x4e0bc7;})});}_0x13201c=_[_0x62bc('0x44')]({},_0x13201c,_0x30d0fe[_0x62bc('0x48')]);return _0x44a6ed['getSubjects'](_0x13201c);}})[_0x62bc('0x2e')](function(_0x4b82b0){if(_0x4b82b0){_0x74a2eb=_0x4b82b0['length'];if(!_0x30d0fe[_0x62bc('0x38')][_0x62bc('0x3e')](_0x62bc('0x56'))){_0x13201c['limit']=qs[_0x62bc('0x27')](_0x30d0fe[_0x62bc('0x38')][_0x62bc('0x27')]);_0x13201c['offset']=qs[_0x62bc('0x26')](_0x30d0fe[_0x62bc('0x38')][_0x62bc('0x26')]);}return _0x44a6ed['getSubjects'](_0x13201c);}})[_0x62bc('0x2e')](function(_0x55bed3){if(_0x55bed3){return _0x55bed3?{'count':_0x74a2eb,'rows':_0x55bed3}:null;}})['then'](respondWithResult(_0xe1b77c,null))[_0x62bc('0x24')](handleError(_0xe1b77c,null));};exports['getDescriptions']=function(_0x25bf61,_0x4c003a,_0x14dee2){var _0x5dc964={};var _0x43dc36={};var _0x37a9f2;var _0x135bb7;return db[_0x62bc('0x34')]['findOne']({'where':{'id':_0x25bf61['params']['id']}})['then'](handleEntityNotFound(_0x4c003a,null))[_0x62bc('0x2e')](function(_0x876ab1){if(_0x876ab1){_0x37a9f2=_0x876ab1;_0x43dc36['model']=_[_0x62bc('0x37')](db['VtigerField'][_0x62bc('0x35')]);_0x43dc36[_0x62bc('0x38')]=_[_0x62bc('0x37')](_0x25bf61['query']);_0x43dc36[_0x62bc('0x40')]=_[_0x62bc('0x3b')](_0x43dc36[_0x62bc('0x36')],_0x43dc36[_0x62bc('0x38')]);_0x5dc964[_0x62bc('0x3c')]=_[_0x62bc('0x3b')](_0x43dc36['model'],qs[_0x62bc('0x3d')](_0x25bf61['query'][_0x62bc('0x3d')]));_0x5dc964[_0x62bc('0x3c')]=_0x5dc964['attributes'][_0x62bc('0x4e')]?_0x5dc964[_0x62bc('0x3c')]:_0x43dc36[_0x62bc('0x36')];_0x5dc964[_0x62bc('0x55')]=qs['sort'](_0x25bf61[_0x62bc('0x38')][_0x62bc('0x3f')]);_0x5dc964[_0x62bc('0x45')]=qs[_0x62bc('0x40')](_[_0x62bc('0x41')](_0x25bf61['query'],_0x43dc36['filters']));if(_0x25bf61[_0x62bc('0x38')][_0x62bc('0x46')]){_0x5dc964['where']=_['merge'](_0x5dc964[_0x62bc('0x45')],{'$or':_[_0x62bc('0x47')](_0x5dc964[_0x62bc('0x3c')],function(_0xee7af5){var _0x58e0fc={};_0x58e0fc[_0xee7af5]={'$like':'%'+_0x25bf61['query'][_0x62bc('0x46')]+'%'};return _0x58e0fc;})});}_0x5dc964=_[_0x62bc('0x44')]({},_0x5dc964,_0x25bf61[_0x62bc('0x48')]);return _0x37a9f2[_0x62bc('0x58')](_0x5dc964);}})[_0x62bc('0x2e')](function(_0x4c7684){if(_0x4c7684){_0x135bb7=_0x4c7684[_0x62bc('0x4e')];if(!_0x25bf61[_0x62bc('0x38')][_0x62bc('0x3e')]('nolimit')){_0x5dc964[_0x62bc('0x27')]=qs[_0x62bc('0x27')](_0x25bf61[_0x62bc('0x38')][_0x62bc('0x27')]);_0x5dc964[_0x62bc('0x26')]=qs['offset'](_0x25bf61[_0x62bc('0x38')][_0x62bc('0x26')]);}return _0x37a9f2[_0x62bc('0x58')](_0x5dc964);}})[_0x62bc('0x2e')](function(_0x5c9fb6){if(_0x5c9fb6){return _0x5c9fb6?{'count':_0x135bb7,'rows':_0x5c9fb6}:null;}})[_0x62bc('0x2e')](respondWithResult(_0x4c003a,null))[_0x62bc('0x24')](handleError(_0x4c003a,null));};
\ No newline at end of file