Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / api / squareReportDetail / squareReportDetail.controller.js
index a51f997..84fe0aa 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf00b=['end','status','offset','limit','json','apply','save','update','then','destroy','stack','name','send','index','map','SquareDetailsReport','rawAttributes','type','key','model','query','keys','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','options','count','include','rows','params','merge','find','create','body','catch','describe','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','util','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf00b,0x17f));var _0xbf00=function(_0x5efd0c,_0xaafc8f){_0x5efd0c=_0x5efd0c-0x0;var _0x2ecdbe=_0xf00b[_0x5efd0c];return _0x2ecdbe;};'use strict';var pdf=require(_0xbf00('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xbf00('0x1'));var zipdir=require(_0xbf00('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbf00('0x3'));var moment=require(_0xbf00('0x4'));var BPromise=require(_0xbf00('0x5'));var Mustache=require('mustache');var util=require(_0xbf00('0x6'));var path=require(_0xbf00('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xbf00('0x8'));var fs=require('fs');var _=require(_0xbf00('0x9'));var squel=require(_0xbf00('0xa'));var crypto=require(_0xbf00('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xbf00('0xc'));var toCsv=require(_0xbf00('0xd'));var querystring=require(_0xbf00('0xe'));var Papa=require(_0xbf00('0xf'));var Redis=require(_0xbf00('0x10'));var authService=require(_0xbf00('0x11'));var qs=require(_0xbf00('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbf00('0x13'));var logger=require(_0xbf00('0x14'))(_0xbf00('0x15'));var utils=require(_0xbf00('0x16'));var config=require('../../config/environment');var db=require(_0xbf00('0x17'))['db'];function respondWithStatusCode(_0x889f14,_0x754120){_0x754120=_0x754120||0xcc;return function(_0x4011f5){if(_0x4011f5){return _0x889f14[_0xbf00('0x18')](_0x754120);}return _0x889f14['status'](_0x754120)[_0xbf00('0x19')]();};}function respondWithResult(_0x56d283,_0x230134){_0x230134=_0x230134||0xc8;return function(_0x1e70f7){if(_0x1e70f7){return _0x56d283[_0xbf00('0x1a')](_0x230134)['json'](_0x1e70f7);}};}function respondWithFilteredResult(_0xcc7889,_0x5e3b44){return function(_0x57a05b){if(_0x57a05b){var _0x3569db=_0x57a05b['count'],_0x132850=_0x5e3b44['offset'],_0x41a2ba=_0x5e3b44[_0xbf00('0x1b')]+_0x5e3b44[_0xbf00('0x1c')],_0x31c923;if(_0x41a2ba>=_0x3569db){_0x41a2ba=_0x3569db;_0x31c923=0xc8;}else{_0x31c923=0xce;}_0xcc7889[_0xbf00('0x1a')](_0x31c923);return _0xcc7889['set']('Content-Range',_0x132850+'-'+_0x41a2ba+'/'+_0x3569db)[_0xbf00('0x1d')](_0x57a05b);}return null;};}function patchUpdates(_0xec5a7e){return function(_0x5a9d2b){try{jsonpatch[_0xbf00('0x1e')](_0x5a9d2b,_0xec5a7e,!![]);}catch(_0x217091){return BPromise['reject'](_0x217091);}return _0x5a9d2b[_0xbf00('0x1f')]();};}function saveUpdates(_0xd44c15,_0x5ba3f){return function(_0x3ca8cb){if(_0x3ca8cb){return _0x3ca8cb[_0xbf00('0x20')](_0xd44c15)[_0xbf00('0x21')](function(_0x42a52d){return _0x42a52d;});}return null;};}function removeEntity(_0x2d8207,_0x23a4ea){return function(_0x26b5a6){if(_0x26b5a6){return _0x26b5a6[_0xbf00('0x22')]()[_0xbf00('0x21')](function(){_0x2d8207['status'](0xcc)[_0xbf00('0x19')]();});}};}function handleEntityNotFound(_0x3e08c4,_0x546b03){return function(_0x344d16){if(!_0x344d16){_0x3e08c4[_0xbf00('0x18')](0x194);}return _0x344d16;};}function handleError(_0x564086,_0x56e3ac){_0x56e3ac=_0x56e3ac||0x1f4;return function(_0x43142c){logger['error'](_0x43142c[_0xbf00('0x23')]);if(_0x43142c[_0xbf00('0x24')]){delete _0x43142c[_0xbf00('0x24')];}_0x564086[_0xbf00('0x1a')](_0x56e3ac)[_0xbf00('0x25')](_0x43142c);};}exports[_0xbf00('0x26')]=function(_0x13c436,_0x3083c8){var _0x45797f={},_0x3f04d8={},_0x3a8934={'count':0x0,'rows':[]};var _0x174402=_[_0xbf00('0x27')](db[_0xbf00('0x28')][_0xbf00('0x29')],function(_0x3c5a56){return{'name':_0x3c5a56['fieldName'],'type':_0x3c5a56[_0xbf00('0x2a')][_0xbf00('0x2b')]};});_0x3f04d8[_0xbf00('0x2c')]=_[_0xbf00('0x27')](_0x174402,'name');_0x3f04d8[_0xbf00('0x2d')]=_[_0xbf00('0x2e')](_0x13c436[_0xbf00('0x2d')]);_0x3f04d8[_0xbf00('0x2f')]=_['intersection'](_0x3f04d8[_0xbf00('0x2c')],_0x3f04d8['query']);_0x45797f[_0xbf00('0x30')]=_['intersection'](_0x3f04d8[_0xbf00('0x2c')],qs[_0xbf00('0x31')](_0x13c436['query'][_0xbf00('0x31')]));_0x45797f[_0xbf00('0x30')]=_0x45797f[_0xbf00('0x30')][_0xbf00('0x32')]?_0x45797f[_0xbf00('0x30')]:_0x3f04d8[_0xbf00('0x2c')];if(!_0x13c436[_0xbf00('0x2d')][_0xbf00('0x33')](_0xbf00('0x34'))){_0x45797f[_0xbf00('0x1c')]=qs['limit'](_0x13c436[_0xbf00('0x2d')][_0xbf00('0x1c')]);_0x45797f[_0xbf00('0x1b')]=qs[_0xbf00('0x1b')](_0x13c436[_0xbf00('0x2d')][_0xbf00('0x1b')]);}_0x45797f[_0xbf00('0x35')]=qs['sort'](_0x13c436['query'][_0xbf00('0x36')]);_0x45797f[_0xbf00('0x37')]=qs['filters'](_['pick'](_0x13c436[_0xbf00('0x2d')],_0x3f04d8[_0xbf00('0x2f')]),_0x174402);if(_0x13c436[_0xbf00('0x2d')][_0xbf00('0x38')]){_0x45797f[_0xbf00('0x37')]=_['merge'](_0x45797f[_0xbf00('0x37')],{'$or':_[_0xbf00('0x27')](_0x174402,function(_0x20cd64){if(_0x20cd64['type']!=='VIRTUAL'){var _0x593ab5={};_0x593ab5[_0x20cd64[_0xbf00('0x24')]]={'$like':'%'+_0x13c436[_0xbf00('0x2d')][_0xbf00('0x38')]+'%'};return _0x593ab5;}})});}_0x45797f=_['merge']({},_0x45797f,_0x13c436[_0xbf00('0x39')]);var _0x2cfd3b={'where':_0x45797f[_0xbf00('0x37')]};return db[_0xbf00('0x28')]['count'](_0x2cfd3b)[_0xbf00('0x21')](function(_0x5743ea){_0x3a8934[_0xbf00('0x3a')]=_0x5743ea;if(_0x13c436[_0xbf00('0x2d')]['includeAll']){_0x45797f[_0xbf00('0x3b')]=[{'all':!![]}];}return db[_0xbf00('0x28')]['findAll'](_0x45797f);})['then'](function(_0x4a220f){_0x3a8934[_0xbf00('0x3c')]=_0x4a220f;return _0x3a8934;})[_0xbf00('0x21')](respondWithFilteredResult(_0x3083c8,_0x45797f))['catch'](handleError(_0x3083c8,null));};exports['show']=function(_0x321948,_0x279932){var _0x1d006d={'raw':!![],'where':{'id':_0x321948[_0xbf00('0x3d')]['id']}},_0x4a56bd={};_0x4a56bd[_0xbf00('0x2c')]=_[_0xbf00('0x2e')](db['SquareDetailsReport'][_0xbf00('0x29')]);_0x4a56bd['query']=_[_0xbf00('0x2e')](_0x321948[_0xbf00('0x2d')]);_0x4a56bd[_0xbf00('0x2f')]=_['intersection'](_0x4a56bd[_0xbf00('0x2c')],_0x4a56bd[_0xbf00('0x2d')]);_0x1d006d[_0xbf00('0x30')]=_['intersection'](_0x4a56bd[_0xbf00('0x2c')],qs[_0xbf00('0x31')](_0x321948[_0xbf00('0x2d')]['fields']));_0x1d006d[_0xbf00('0x30')]=_0x1d006d[_0xbf00('0x30')][_0xbf00('0x32')]?_0x1d006d['attributes']:_0x4a56bd[_0xbf00('0x2c')];if(_0x321948[_0xbf00('0x2d')]['includeAll']){_0x1d006d['include']=[{'all':!![]}];}_0x1d006d=_[_0xbf00('0x3e')]({},_0x1d006d,_0x321948[_0xbf00('0x39')]);return db[_0xbf00('0x28')][_0xbf00('0x3f')](_0x1d006d)[_0xbf00('0x21')](handleEntityNotFound(_0x279932,null))['then'](respondWithResult(_0x279932,null))['catch'](handleError(_0x279932,null));};exports[_0xbf00('0x40')]=function(_0x583164,_0x5249cf){return db[_0xbf00('0x28')]['create'](_0x583164[_0xbf00('0x41')],{})[_0xbf00('0x21')](respondWithResult(_0x5249cf,0xc9))[_0xbf00('0x42')](handleError(_0x5249cf,null));};exports[_0xbf00('0x20')]=function(_0x11edf0,_0x37ed31){if(_0x11edf0[_0xbf00('0x41')]['id']){delete _0x11edf0[_0xbf00('0x41')]['id'];}return db[_0xbf00('0x28')][_0xbf00('0x3f')]({'where':{'id':_0x11edf0[_0xbf00('0x3d')]['id']}})[_0xbf00('0x21')](handleEntityNotFound(_0x37ed31,null))[_0xbf00('0x21')](saveUpdates(_0x11edf0[_0xbf00('0x41')],null))['then'](respondWithResult(_0x37ed31,null))[_0xbf00('0x42')](handleError(_0x37ed31,null));};exports[_0xbf00('0x22')]=function(_0x3ecc4a,_0x1b7330){return db['SquareDetailsReport'][_0xbf00('0x3f')]({'where':{'id':_0x3ecc4a[_0xbf00('0x3d')]['id']}})[_0xbf00('0x21')](handleEntityNotFound(_0x1b7330,null))[_0xbf00('0x21')](removeEntity(_0x1b7330,null))[_0xbf00('0x42')](handleError(_0x1b7330,null));};exports[_0xbf00('0x43')]=function(_0x4b2c5c,_0x496b05){return db[_0xbf00('0x28')]['describe']()[_0xbf00('0x21')](respondWithResult(_0x496b05,null))[_0xbf00('0x42')](handleError(_0x496b05,null));};
\ No newline at end of file
+var _0x9627=['bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','offset','undefined','limit','count','Content-Range','json','reject','save','update','then','sendStatus','error','name','send','map','SquareDetailsReport','rawAttributes','fieldName','type','query','keys','model','attributes','fields','length','hasOwnProperty','order','sort','where','filters','filter','merge','includeAll','include','catch','show','params','intersection','options','find','create','body','destroy','describe','zip-dir','fast-json-patch','request-promise'];(function(_0xb89a23,_0x6a4601){var _0x17435e=function(_0x121c3c){while(--_0x121c3c){_0xb89a23['push'](_0xb89a23['shift']());}};_0x17435e(++_0x6a4601);}(_0x9627,0x160));var _0x7962=function(_0x4a9fb1,_0x273043){_0x4a9fb1=_0x4a9fb1-0x0;var _0x348672=_0x9627[_0x4a9fb1];return _0x348672;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x7962('0x0'));var jsonpatch=require(_0x7962('0x1'));var rp=require(_0x7962('0x2'));var moment=require('moment');var BPromise=require(_0x7962('0x3'));var Mustache=require(_0x7962('0x4'));var util=require(_0x7962('0x5'));var path=require(_0x7962('0x6'));var sox=require(_0x7962('0x7'));var csv=require(_0x7962('0x8'));var ejs=require(_0x7962('0x9'));var fs=require('fs');var fs_extra=require(_0x7962('0xa'));var _=require(_0x7962('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7962('0xc'));var deskjs=require(_0x7962('0xd'));var toCsv=require('to-csv');var querystring=require(_0x7962('0xe'));var Papa=require(_0x7962('0xf'));var Redis=require(_0x7962('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x7962('0x11'));var hardwareService=require(_0x7962('0x12'));var logger=require(_0x7962('0x13'))(_0x7962('0x14'));var utils=require(_0x7962('0x15'));var config=require(_0x7962('0x16'));var licenseUtil=require(_0x7962('0x17'));var db=require(_0x7962('0x18'))['db'];function respondWithStatusCode(_0x329351,_0x59bd0d){_0x59bd0d=_0x59bd0d||0xcc;return function(_0x4c626e){if(_0x4c626e){return _0x329351['sendStatus'](_0x59bd0d);}return _0x329351[_0x7962('0x19')](_0x59bd0d)[_0x7962('0x1a')]();};}function respondWithResult(_0x2f0227,_0x203708){_0x203708=_0x203708||0xc8;return function(_0x2bc70e){if(_0x2bc70e){return _0x2f0227[_0x7962('0x19')](_0x203708)['json'](_0x2bc70e);}};}function respondWithFilteredResult(_0x4c15f4,_0x209b1b){return function(_0x86a20f){if(_0x86a20f){var _0x5cb321=typeof _0x209b1b[_0x7962('0x1b')]===_0x7962('0x1c')&&typeof _0x209b1b[_0x7962('0x1d')]===_0x7962('0x1c');var _0x595bdb=_0x86a20f[_0x7962('0x1e')];var _0x436379=_0x5cb321?0x0:_0x209b1b[_0x7962('0x1b')];var _0x3ae7c6=_0x5cb321?_0x86a20f['count']:_0x209b1b[_0x7962('0x1b')]+_0x209b1b[_0x7962('0x1d')];var _0x8af135;if(_0x3ae7c6>=_0x595bdb){_0x3ae7c6=_0x595bdb;_0x8af135=0xc8;}else{_0x8af135=0xce;}_0x4c15f4[_0x7962('0x19')](_0x8af135);return _0x4c15f4['set'](_0x7962('0x1f'),_0x436379+'-'+_0x3ae7c6+'/'+_0x595bdb)[_0x7962('0x20')](_0x86a20f);}return null;};}function patchUpdates(_0xed158){return function(_0x456bf0){try{jsonpatch['apply'](_0x456bf0,_0xed158,!![]);}catch(_0x5848bf){return BPromise[_0x7962('0x21')](_0x5848bf);}return _0x456bf0[_0x7962('0x22')]();};}function saveUpdates(_0x2f087b,_0x1eeb07){return function(_0x3a4312){if(_0x3a4312){return _0x3a4312[_0x7962('0x23')](_0x2f087b)['then'](function(_0xc5f715){return _0xc5f715;});}return null;};}function removeEntity(_0x5ba42e,_0xa83fda){return function(_0x5a9c92){if(_0x5a9c92){return _0x5a9c92['destroy']()[_0x7962('0x24')](function(){_0x5ba42e['status'](0xcc)[_0x7962('0x1a')]();});}};}function handleEntityNotFound(_0x83ca47,_0x30f828){return function(_0x13203e){if(!_0x13203e){_0x83ca47[_0x7962('0x25')](0x194);}return _0x13203e;};}function handleError(_0x615309,_0x3852e0){_0x3852e0=_0x3852e0||0x1f4;return function(_0x2413bf){logger[_0x7962('0x26')](_0x2413bf['stack']);if(_0x2413bf[_0x7962('0x27')]){delete _0x2413bf['name'];}_0x615309[_0x7962('0x19')](_0x3852e0)[_0x7962('0x28')](_0x2413bf);};}exports['index']=function(_0x21c2e1,_0x19319b){var _0x44eba0={},_0x4e9559={},_0x94c17e={'count':0x0,'rows':[]};var _0x57f23a=_[_0x7962('0x29')](db[_0x7962('0x2a')][_0x7962('0x2b')],function(_0x3f9bf8){return{'name':_0x3f9bf8[_0x7962('0x2c')],'type':_0x3f9bf8[_0x7962('0x2d')]['key']};});_0x4e9559['model']=_[_0x7962('0x29')](_0x57f23a,'name');_0x4e9559[_0x7962('0x2e')]=_[_0x7962('0x2f')](_0x21c2e1[_0x7962('0x2e')]);_0x4e9559['filters']=_['intersection'](_0x4e9559[_0x7962('0x30')],_0x4e9559[_0x7962('0x2e')]);_0x44eba0[_0x7962('0x31')]=_['intersection'](_0x4e9559['model'],qs['fields'](_0x21c2e1[_0x7962('0x2e')][_0x7962('0x32')]));_0x44eba0[_0x7962('0x31')]=_0x44eba0[_0x7962('0x31')][_0x7962('0x33')]?_0x44eba0[_0x7962('0x31')]:_0x4e9559[_0x7962('0x30')];if(!_0x21c2e1[_0x7962('0x2e')][_0x7962('0x34')]('nolimit')){_0x44eba0['limit']=qs[_0x7962('0x1d')](_0x21c2e1[_0x7962('0x2e')][_0x7962('0x1d')]);_0x44eba0[_0x7962('0x1b')]=qs[_0x7962('0x1b')](_0x21c2e1['query']['offset']);}_0x44eba0[_0x7962('0x35')]=qs[_0x7962('0x36')](_0x21c2e1[_0x7962('0x2e')][_0x7962('0x36')]);_0x44eba0[_0x7962('0x37')]=qs[_0x7962('0x38')](_['pick'](_0x21c2e1[_0x7962('0x2e')],_0x4e9559[_0x7962('0x38')]),_0x57f23a);if(_0x21c2e1[_0x7962('0x2e')][_0x7962('0x39')]){_0x44eba0['where']=_[_0x7962('0x3a')](_0x44eba0[_0x7962('0x37')],{'$or':_['map'](_0x57f23a,function(_0xf4ea3f){if(_0xf4ea3f[_0x7962('0x2d')]!=='VIRTUAL'){var _0x5ba0e7={};_0x5ba0e7[_0xf4ea3f[_0x7962('0x27')]]={'$like':'%'+_0x21c2e1[_0x7962('0x2e')][_0x7962('0x39')]+'%'};return _0x5ba0e7;}})});}_0x44eba0=_[_0x7962('0x3a')]({},_0x44eba0,_0x21c2e1['options']);var _0x1120e1={'where':_0x44eba0[_0x7962('0x37')]};return db['SquareDetailsReport'][_0x7962('0x1e')](_0x1120e1)['then'](function(_0xbb0008){_0x94c17e['count']=_0xbb0008;if(_0x21c2e1[_0x7962('0x2e')][_0x7962('0x3b')]){_0x44eba0[_0x7962('0x3c')]=[{'all':!![]}];}return db[_0x7962('0x2a')]['findAll'](_0x44eba0);})[_0x7962('0x24')](function(_0x56737d){_0x94c17e['rows']=_0x56737d;return _0x94c17e;})['then'](respondWithFilteredResult(_0x19319b,_0x44eba0))[_0x7962('0x3d')](handleError(_0x19319b,null));};exports[_0x7962('0x3e')]=function(_0x392409,_0x190042){var _0x3d9465={'raw':!![],'where':{'id':_0x392409[_0x7962('0x3f')]['id']}},_0x8eccd3={};_0x8eccd3[_0x7962('0x30')]=_[_0x7962('0x2f')](db[_0x7962('0x2a')][_0x7962('0x2b')]);_0x8eccd3['query']=_[_0x7962('0x2f')](_0x392409[_0x7962('0x2e')]);_0x8eccd3[_0x7962('0x38')]=_[_0x7962('0x40')](_0x8eccd3[_0x7962('0x30')],_0x8eccd3[_0x7962('0x2e')]);_0x3d9465[_0x7962('0x31')]=_[_0x7962('0x40')](_0x8eccd3[_0x7962('0x30')],qs[_0x7962('0x32')](_0x392409[_0x7962('0x2e')][_0x7962('0x32')]));_0x3d9465[_0x7962('0x31')]=_0x3d9465[_0x7962('0x31')]['length']?_0x3d9465[_0x7962('0x31')]:_0x8eccd3['model'];if(_0x392409['query'][_0x7962('0x3b')]){_0x3d9465[_0x7962('0x3c')]=[{'all':!![]}];}_0x3d9465=_[_0x7962('0x3a')]({},_0x3d9465,_0x392409[_0x7962('0x41')]);return db[_0x7962('0x2a')][_0x7962('0x42')](_0x3d9465)['then'](handleEntityNotFound(_0x190042,null))['then'](respondWithResult(_0x190042,null))[_0x7962('0x3d')](handleError(_0x190042,null));};exports[_0x7962('0x43')]=function(_0xb309f7,_0x1ead6c){return db[_0x7962('0x2a')]['create'](_0xb309f7[_0x7962('0x44')],{})[_0x7962('0x24')](respondWithResult(_0x1ead6c,0xc9))[_0x7962('0x3d')](handleError(_0x1ead6c,null));};exports['update']=function(_0x30723a,_0x2e5a80){if(_0x30723a[_0x7962('0x44')]['id']){delete _0x30723a[_0x7962('0x44')]['id'];}return db['SquareDetailsReport']['find']({'where':{'id':_0x30723a[_0x7962('0x3f')]['id']}})['then'](handleEntityNotFound(_0x2e5a80,null))['then'](saveUpdates(_0x30723a[_0x7962('0x44')],null))[_0x7962('0x24')](respondWithResult(_0x2e5a80,null))['catch'](handleError(_0x2e5a80,null));};exports[_0x7962('0x45')]=function(_0x15553a,_0x54cef7){return db[_0x7962('0x2a')][_0x7962('0x42')]({'where':{'id':_0x15553a['params']['id']}})[_0x7962('0x24')](handleEntityNotFound(_0x54cef7,null))['then'](removeEntity(_0x54cef7,null))[_0x7962('0x3d')](handleError(_0x54cef7,null));};exports[_0x7962('0x46')]=function(_0xe82c94,_0x19771b){return db['SquareDetailsReport'][_0x7962('0x46')]()[_0x7962('0x24')](respondWithResult(_0x19771b,null))[_0x7962('0x3d')](handleError(_0x19771b,null));};
\ No newline at end of file