23a44cb3c1c5e88b7d159b7290f33b09d6fc0626
[motion.git] / server / utils / report_extraction.js
1 var _0x1c09=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x74\x6F\x2D\x63\x73\x76","\x70\x64\x66\x6D\x61\x6B\x65","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x45\x78\x74\x72\x61\x63\x74\x65\x64\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4C\x69\x63\x65\x6E\x73\x65","\x53\x65\x74\x74\x69\x6E\x67","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x66\x73","\x6D\x6F\x6D\x65\x6E\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x65\x6E\x63\x6F\x64\x65","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x70\x61\x74\x68","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x2E\x2F\x72\x65\x70\x6F\x72\x74\x5F\x62\x75\x69\x6C\x64","\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x69\x63\x65\x6E\x73\x65\x2F\x6C\x69\x63\x65\x6E\x73\x65\x2E\x73\x65\x72\x76\x69\x63\x65","\x66\x6F\x6E\x74\x73","\x52\x6F\x62\x6F\x74\x6F\x2D\x52\x65\x67\x75\x6C\x61\x72\x2E\x74\x74\x66","\x6A\x6F\x69\x6E","\x52\x6F\x62\x6F\x74\x6F\x2D\x4D\x65\x64\x69\x75\x6D\x2E\x74\x74\x66","\x52\x6F\x62\x6F\x74\x6F\x2D\x49\x74\x61\x6C\x69\x63\x2E\x74\x74\x66","\x6D\x65\x73\x73\x61\x67\x65","\x73\x74\x69\x63\x6B\x79\x3A\x62\x61\x6C\x61\x6E\x63\x65","\x72\x65\x70\x6F\x72\x74","\x71\x75\x65\x72\x79","\x65\x78\x74\x72\x61\x63\x74\x65\x64\x49\x64","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x74\x79\x70\x65","\x75\x73\x65\x72","\x6F\x6E","\x6C\x6F\x67","\x71\x75\x65\x72\x79\x20\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x69\x73\x41\x72\x72\x61\x79","\x6C\x65\x6E\x67\x74\x68","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x66\x6F\x72\x4F\x77\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x6C\x69\x63\x65\x6E\x73\x65","\x64\x61\x74\x61\x31","\x64\x65\x63\x72\x79\x70\x74","\x70\x61\x72\x73\x65","\x64\x65\x66\x61\x75\x6C\x74\x4C\x6F\x67\x69\x6E\x4C\x6F\x67\x6F","\x6C\x6F\x67\x69\x6E\x4C\x6F\x67\x6F","\x63\x75\x73\x74\x6F\x6D","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x69\x6D\x61\x67\x65\x73","\x64\x65\x66\x61\x75\x6C\x74","\x6C\x6F\x67\x6F\x2D\x62\x69\x67\x2D\x70\x64\x66\x2E\x70\x6E\x67","\x70\x6F\x70","\x2E","\x73\x70\x6C\x69\x74","\x74\x68\x65\x6E","\x70\x64\x66","\x63\x73\x76","\x65\x6D\x70\x74\x79","\x71\x75\x65\x72\x79\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x65\x72\x72\x6F\x72","\x63\x68\x65\x63\x6B\x51\x75\x65\x72\x79","\x62\x75\x69\x6C\x64\x51\x75\x65\x72\x79","\x73\x70\x72\x65\x61\x64","\x62\x75\x69\x6C\x64\x46\x69\x6C\x74\x65\x72","\x74\x61\x62\x6C\x65","\x66\x69\x6E\x64\x42\x79\x49\x64","\x6A\x70\x65\x67","\x6A\x70\x67","\x72\x65\x70\x6F\x72\x74\x5F","\x6E\x61\x6D\x65","\x5F","\x2E\x70\x64\x66","\x61\x6C\x69\x61\x73","\x74\x61\x62\x6C\x65\x48\x65\x61\x64\x65\x72","\x70\x75\x73\x68","","\x68\x65\x61\x64\x65\x72","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x23\x38\x32\x38\x36\x38\x32","\x73\x74\x61\x72\x74\x44\x61\x74\x65","\x46\x72\x6F\x6D\x3A\x20","\x6C\x61\x62\x65\x6C","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D","\x64\x61\x79","\x73\x74\x61\x72\x74\x4F\x66","\x20\x20\x54\x6F\x3A\x20","\x65\x6E\x64\x4F\x66","\x65\x6E\x64\x44\x61\x74\x65","\x74\x61\x62\x6C\x65\x45\x78\x61\x6D\x70\x6C\x65","\x6C\x61\x6E\x64\x73\x63\x61\x70\x65","\x2A","\x64\x61\x74\x61\x3A\x69\x6D\x61\x67\x65\x2F","\x3B\x62\x61\x73\x65\x36\x34\x2C","\x6E\x6F\x42\x6F\x72\x64\x65\x72\x73","\x20\x6F\x66\x20","\x63\x65\x6E\x74\x65\x72","\x62\x6C\x61\x63\x6B","\x62\x72\x65\x61\x6B\x2D\x77\x6F\x72\x64","\x63\x72\x65\x61\x74\x65\x50\x64\x66\x4B\x69\x74\x44\x6F\x63\x75\x6D\x65\x6E\x74","\x72\x65\x70\x6F\x72\x74\x73","\x63\x72\x65\x61\x74\x65\x57\x72\x69\x74\x65\x53\x74\x72\x65\x61\x6D","\x65\x72\x72\x6F\x72","\x70\x64\x66\x20\x77\x72\x69\x74\x65\x20\x65\x72\x72\x6F\x72","\x66\x69\x6E\x69\x73\x68","\x63\x6F\x6D\x70\x6C\x65\x74\x65\x64","\x70\x69\x70\x65","\x65\x6E\x64","\x70\x64\x66\x20\x63\x72\x65\x61\x74\x69\x6F\x6E\x20\x65\x72\x72\x6F\x72","\x2E\x63\x73\x76","\x63\x73\x76\x20\x77\x72\x69\x74\x65\x20\x65\x72\x72\x6F\x72","\x77\x72\x69\x74\x65\x46\x69\x6C\x65","\x63\x73\x76\x20\x63\x72\x65\x61\x74\x69\x6F\x6E\x20\x65\x72\x72\x6F\x72","\x66\x69\x6E\x69\x73\x68\x65\x64","\x73\x65\x6E\x64","\x66\x69\x6E\x61\x6C\x6C\x79","\x2D\x2D\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6E\x67\x20\x72\x65\x70\x6F\x72\x74\x20\x77\x69\x74\x68\x20\x65\x72\x72\x6F\x72\x20\x3A\x20","\x2D\x2D\x46\x69\x6E\x69\x73\x68\x65\x64\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6E\x67\x20\x72\x65\x70\x6F\x72\x74","\x75\x70\x64\x61\x74\x65"];_0x1c09[0];var csv=require(_0x1c09[1]);var PdfMake=require(_0x1c09[2]);var _=require(_0x1c09[3]);var util=require(_0x1c09[4]);var ExtractedReport=require(_0x1c09[6])[_0x1c09[5]];var License=require(_0x1c09[6])[_0x1c09[7]];var Setting=require(_0x1c09[6])[_0x1c09[8]];var sequelize=require(_0x1c09[6])[_0x1c09[9]];var fs=require(_0x1c09[10]);var moment=require(_0x1c09[11]);var Promise=require(_0x1c09[12]);var base64=Promise[_0x1c09[15]](require(_0x1c09[14])[_0x1c09[13]]);var sr=require(_0x1c09[16]);var path=require(_0x1c09[17]);var config=require(_0x1c09[18]);var reportBuildUtils=require(_0x1c09[19]);var license=require(_0x1c09[20]);var fonts={Roboto:{normal:path[_0x1c09[23]](config[_0x1c09[21]],_0x1c09[22]),bold:path[_0x1c09[23]](config[_0x1c09[21]],_0x1c09[24]),italics:path[_0x1c09[23]](config[_0x1c09[21]],_0x1c09[25]),bolditalics:path[_0x1c09[23]](config[_0x1c09[21]],_0x1c09[25])}};process[_0x1c09[34]](_0x1c09[26],function(_0x9703x13){if(_0x9703x13!== _0x1c09[27]){general(_0x9703x13[_0x1c09[28]],_0x9703x13[_0x1c09[29]],_0x9703x13[_0x1c09[30]],_0x9703x13[_0x1c09[32]][_0x1c09[31]](),_0x9703x13[_0x1c09[33]])}});function general(_0x9703x15,_0x9703x16,_0x9703x17,_0x9703x18,_0x9703x19){extract(_0x9703x15,_0x9703x16,_0x9703x17,_0x9703x18,_0x9703x19)}function extract(_0x9703x15,_0x9703x1b,_0x9703x17,_0x9703x18,_0x9703x19){var _0x9703x1c,_0x9703x1d;return License[_0x1c09[70]](1)[_0x1c09[60]](function(_0x9703x23){_0x9703x1c= _0x9703x23;return Setting[_0x1c09[70]](1)})[_0x1c09[60]](function(_0x9703x28){_0x9703x1d= _0x9703x28;return _0x9703x15[_0x1c09[69]]})[_0x1c09[60]](reportBuildUtils[_0x1c09[68]](_0x9703x19))[_0x1c09[60]](function(_0x9703x27){return [_0x9703x27,_0x9703x15]})[_0x1c09[67]](reportBuildUtils[_0x1c09[66]](_0x9703x1b))[_0x1c09[60]](reportBuildUtils[_0x1c09[65]]())[_0x1c09[60]](function(_0x9703x1f){if(_0x9703x1f){if(_[_0x1c09[38]](_0x9703x1f)){if(_0x9703x1f[_0x1c09[39]]){_[_0x1c09[43]](_0x9703x1f,function(_0x9703x20){_[_0x1c09[42]](_0x9703x20,function(_0x9703x21,_0x9703x22){if(_0x9703x21 instanceof  Date){_0x9703x20[_0x9703x22]= moment(_0x9703x21)[_0x1c09[41]](_0x1c09[40]).toString()}})});switch(_0x9703x18){case _0x1c09[61]:var _0x9703x23=_0x9703x1c?JSON[_0x1c09[47]](license[_0x1c09[46]](_0x9703x1c[_0x1c09[44]],_0x9703x1c[_0x1c09[45]])):null;var _0x9703x24=(_0x9703x1d&&  !_0x9703x1d[_0x1c09[48]]&& _0x9703x1d[_0x1c09[49]]&& _0x9703x23&& _0x9703x23[_0x1c09[50]])?path[_0x1c09[23]](config[_0x1c09[51]],_0x1c09[52],_0x1c09[53],_0x1c09[54],_0x9703x1d[_0x1c09[49]]):path[_0x1c09[23]](config[_0x1c09[51]],_0x1c09[52],_0x1c09[53],_0x1c09[54],_0x1c09[55],_0x1c09[56]);return base64(_0x9703x24)[_0x1c09[60]](function(_0x9703x25){var _0x9703x26=_0x9703x24[_0x1c09[59]](_0x1c09[58])[_0x1c09[57]]();return createPdf(_0x9703x1f,_0x9703x15,_0x9703x1b,_0x9703x17,_0x9703x25,_0x9703x26)});case _0x1c09[62]:return createCsv(_0x9703x1f,_0x9703x15,_0x9703x1b,_0x9703x17);default:return createCsv(_0x9703x1f,_0x9703x15,_0x9703x1b,_0x9703x17)}}else {return updateExtracted(_0x9703x17,null,_0x1c09[63])}}else {return updateExtracted(_0x9703x17,null,_0x9703x1f)}}else {return updateExtracted(_0x9703x17,null,_0x1c09[64])}})[_0x1c09[37]](function(_0x9703x1e){console[_0x1c09[35]](_0x9703x1e);return updateExtracted(_0x9703x17,null,_0x1c09[36])})}function createPdf(_0x9703x1f,_0x9703x15,_0x9703x1b,_0x9703x2a,_0x9703x2b,_0x9703x26){switch(_0x9703x26){case _0x1c09[72]:_0x9703x26= _0x1c09[71];break;default:};var _0x9703x2c=sr({length:20,prefix:_0x1c09[73]+ _0x9703x15[_0x1c09[74]]+ _0x1c09[75],suffix:_0x1c09[76]});var _0x9703x2d=[];_[_0x1c09[43]](_0x9703x15.Fields,function(_0x9703x2e){_0x9703x2d[_0x1c09[79]]({text:String(_0x9703x2e[_0x1c09[77]]),style:_0x1c09[78]})});var _0x9703x2f=[_0x9703x2d];_[_0x1c09[43]](_0x9703x1f,function(_0x9703x2e){var _0x9703x20=[];_[_0x1c09[42]](_0x9703x2e,function(_0x9703x30,_0x9703x22){_0x9703x20[_0x1c09[79]](_0x9703x30?String(_0x9703x30):_0x1c09[80])});_0x9703x2f[_0x1c09[79]](_0x9703x20)});var _0x9703x31=[{text:_0x9703x15[_0x1c09[74]],style:_0x1c09[81]}];if(_0x9703x15[_0x1c09[82]]){_0x9703x31[_0x1c09[79]]({text:_0x9703x15[_0x1c09[82]]|| _0x1c09[80],color:_0x1c09[83],margin:[0,0,0,5]})};if(_0x9703x1b[_0x1c09[84]]){_0x9703x31[_0x1c09[79]]({text:[{text:_0x1c09[85],style:_0x1c09[86]},moment(_0x9703x1b[_0x1c09[84]])[_0x1c09[89]](_0x1c09[88])[_0x1c09[41]](_0x1c09[87]).toString(),{text:_0x1c09[90],style:_0x1c09[86]},moment(_0x9703x1b[_0x1c09[92]]|| _0x9703x1b[_0x1c09[84]])[_0x1c09[91]](_0x1c09[88])[_0x1c09[41]](_0x1c09[87]).toString()]})};var _0x9703x32=[];_0x9703x32[_0x1c09[79]]({style:_0x1c09[93],table:{headerRows:1,dontBreakRows:true,body:_0x9703x2f}});var _0x9703x33={pageOrientation:_0x1c09[94],pageMargins:[15,90,15,25],header:function(){return {margin:[15,15,0,0],columns:[{table:{widths:[100,_0x1c09[95]],body:[[{image:_0x1c09[96]+ _0x9703x26+ _0x1c09[97]+ _0x9703x2b,fit:[100,60]},_0x9703x31]]},layout:_0x1c09[98]}]}},content:_0x9703x32,footer:function(_0x9703x34,_0x9703x35){return {columns:[{text:_0x9703x34.toString()+ _0x1c09[99]+ _0x9703x35,alignment:_0x1c09[100]}]}},styles:{header:{fontSize:18,bold:true,margin:[0,0,0,5]},tableExample:{margin:[0,0,0,5],fontSize:8},tableHeader:{bold:true,fontSize:8,color:_0x1c09[101],wordWrap:_0x1c09[102]},label:{bold:true,color:_0x1c09[101]}}};var _0x9703x36= new PdfMake(fonts);var _0x9703x37=_0x9703x36[_0x1c09[103]](_0x9703x33);if(_0x9703x37){var _0x9703x38=fs[_0x1c09[105]](config[_0x1c09[104]]+ _0x9703x2c);_0x9703x38[_0x1c09[34]](_0x1c09[106],function(){return updateExtracted(_0x9703x2a,null,_0x1c09[107])});_0x9703x38[_0x1c09[34]](_0x1c09[108],function(){return updateExtracted(_0x9703x2a,_0x9703x2c,_0x1c09[109])});_0x9703x37[_0x1c09[110]](_0x9703x38);_0x9703x37[_0x1c09[111]]()}else {return updateExtracted(_0x9703x2a,null,_0x1c09[112])}}function createCsv(_0x9703x1f,_0x9703x15,_0x9703x1b,_0x9703x2a){var _0x9703x2c=sr({length:20,prefix:_0x1c09[73]+ _0x9703x15[_0x1c09[74]]+ _0x1c09[75],suffix:_0x1c09[113]});var _0x9703x3a=csv(_0x9703x1f);if(_0x9703x3a){fs[_0x1c09[115]](config[_0x1c09[104]]+ _0x9703x2c,_0x9703x3a,function(_0x9703x1e){if(_0x9703x1e){console[_0x1c09[35]](_0x9703x1e);return updateExtracted(_0x9703x2a,null,_0x1c09[114])}else {return updateExtracted(_0x9703x2a,_0x9703x2c,_0x1c09[109])}})}else {return updateExtracted(_0x9703x2a,null,_0x1c09[116])}}function updateExtracted(_0x9703x2a,_0x9703x2c,_0x9703x3c){return ExtractedReport[_0x1c09[122]]({status:_0x9703x3c,savename:_0x9703x2c},{where:{id:_0x9703x2a}})[_0x1c09[60]](function(){console[_0x1c09[35]](_0x1c09[121])})[_0x1c09[37]](function(_0x9703x1e){console[_0x1c09[35]](_0x1c09[120]+ _0x9703x1e)})[_0x1c09[119]](function(){process[_0x1c09[118]]({message:_0x1c09[117],status:_0x9703x3c})})}