ab2ce79ed1c7bd4b17c40bf5563dbbef9021a079
[motion.git] / server / utils / report_extraction.js
1 var _0x961c=["\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","\x53\x65\x74\x74\x69\x6E\x67\x73","\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","\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","\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\x56\x61\x6C\x75\x65\x73","\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\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","\x53\x45\x4C\x45\x43\x54","\x51\x75\x65\x72\x79\x54\x79\x70\x65\x73","\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"];var csv=require(_0x961c[0]);var PdfMake=require(_0x961c[1]);var _=require(_0x961c[2]);var util=require(_0x961c[3]);var ExtractedReport=require(_0x961c[5])[_0x961c[4]];var Settings=require(_0x961c[5])[_0x961c[6]];var sequelize=require(_0x961c[5])[_0x961c[7]];var fs=require(_0x961c[8]);var moment=require(_0x961c[9]);var Promise=require(_0x961c[10]);var base64=Promise[_0x961c[13]](require(_0x961c[12])[_0x961c[11]]);var sr=require(_0x961c[14]);var path=require(_0x961c[15]);var config=require(_0x961c[16]);var reportBuildUtils=require(_0x961c[17]);var license=require(_0x961c[18]);var fonts={Roboto:{normal:path[_0x961c[21]](config[_0x961c[19]],_0x961c[20]),bold:path[_0x961c[21]](config[_0x961c[19]],_0x961c[22]),italics:path[_0x961c[21]](config[_0x961c[19]],_0x961c[23]),bolditalics:path[_0x961c[21]](config[_0x961c[19]],_0x961c[23])}};process[_0x961c[31]](_0x961c[24],function(_0x4200x12){general(_0x4200x12[_0x961c[25]],_0x4200x12[_0x961c[26]],_0x4200x12[_0x961c[27]],_0x4200x12[_0x961c[29]][_0x961c[28]](),_0x4200x12[_0x961c[30]])});function general(_0x4200x14,_0x4200x15,_0x4200x16,_0x4200x17,_0x4200x18){extract(_0x4200x14,_0x4200x15,_0x4200x16,_0x4200x17,_0x4200x18)}function extract(_0x4200x14,_0x4200x1a,_0x4200x16,_0x4200x17,_0x4200x18){var _0x4200x1b;return Settings[_0x961c[67]](1)[_0x961c[56]](function(_0x4200x26){_0x4200x1b= _0x4200x26;return _0x4200x14[_0x961c[66]]})[_0x961c[56]](reportBuildUtils[_0x961c[65]](_0x4200x18))[_0x961c[56]](function(_0x4200x25){return [_0x4200x25,_0x4200x14]})[_0x961c[64]](reportBuildUtils[_0x961c[63]](_0x4200x1a))[_0x961c[56]](function(_0x4200x15){return _0x4200x15?sequelize[_0x961c[26]](_0x4200x15,{type:sequelize[_0x961c[62]][_0x961c[61]]}):[]})[_0x961c[56]](function(_0x4200x1d){if(_0x4200x1d){if(_0x4200x1d[_0x961c[35]]){_[_0x961c[39]](_0x4200x1d,function(_0x4200x1e){_[_0x961c[38]](_0x4200x1e,function(_0x4200x1f,_0x4200x20){if(_0x4200x1f instanceof  Date){_0x4200x1e[_0x4200x20]= moment(_0x4200x1f)[_0x961c[37]](_0x961c[36]).toString()}})});switch(_0x4200x17){case _0x961c[57]:var _0x4200x21=_0x4200x1b?JSON[_0x961c[43]](license[_0x961c[42]](_0x4200x1b[_0x961c[41]][_0x961c[40]])):null;var _0x4200x22=(_0x4200x1b&& !_0x4200x1b[_0x961c[44]]&& _0x4200x1b[_0x961c[45]]&& _0x4200x21&& _0x4200x21[_0x961c[46]])?path[_0x961c[21]](config[_0x961c[47]],_0x961c[48],_0x961c[49],_0x961c[50],_0x4200x1b[_0x961c[45]]):path[_0x961c[21]](config[_0x961c[47]],_0x961c[48],_0x961c[49],_0x961c[50],_0x961c[51],_0x961c[52]);console[_0x961c[32]](_0x4200x22);return base64(_0x4200x22)[_0x961c[56]](function(_0x4200x23){var _0x4200x24=_0x4200x22[_0x961c[55]](_0x961c[54])[_0x961c[53]]();return createPdf(_0x4200x1d,_0x4200x14,_0x4200x1a,_0x4200x16,_0x4200x23,_0x4200x24)});case _0x961c[58]:return createCsv(_0x4200x1d,_0x4200x14,_0x4200x1a,_0x4200x16);default:return createCsv(_0x4200x1d,_0x4200x14,_0x4200x1a,_0x4200x16)}}else {return updateExtracted(_0x4200x16,null,_0x961c[59])}}else {return updateExtracted(_0x4200x16,null,_0x961c[60])}})[_0x961c[34]](function(_0x4200x1c){console[_0x961c[32]](_0x4200x1c);return updateExtracted(_0x4200x16,null,_0x961c[33])})}function createPdf(_0x4200x1d,_0x4200x14,_0x4200x1a,_0x4200x28,_0x4200x29,_0x4200x24){switch(_0x4200x24){case _0x961c[69]:_0x4200x24= _0x961c[68];break;default:};var _0x4200x2a=sr({length:20,prefix:_0x961c[70]+ _0x4200x14[_0x961c[71]]+ _0x961c[72],suffix:_0x961c[73]});var _0x4200x2b=[];_[_0x961c[39]](_0x4200x14.Fields,function(_0x4200x2c){_0x4200x2b[_0x961c[76]]({text:String(_0x4200x2c[_0x961c[74]]),style:_0x961c[75]})});var _0x4200x2d=[_0x4200x2b];_[_0x961c[39]](_0x4200x1d,function(_0x4200x2c){var _0x4200x1e=[];_[_0x961c[38]](_0x4200x2c,function(_0x4200x2e,_0x4200x20){_0x4200x1e[_0x961c[76]](_0x4200x2e?String(_0x4200x2e):_0x961c[77])});_0x4200x2d[_0x961c[76]](_0x4200x1e)});var _0x4200x2f=[{text:_0x4200x14[_0x961c[71]],style:_0x961c[78]}];if(_0x4200x14[_0x961c[79]]){_0x4200x2f[_0x961c[76]]({text:_0x4200x14[_0x961c[79]]|| _0x961c[77],color:_0x961c[80],margin:[0,0,0,5]})};if(_0x4200x1a[_0x961c[81]]){_0x4200x2f[_0x961c[76]]({text:[{text:_0x961c[82],style:_0x961c[83]},moment(_0x4200x1a[_0x961c[81]])[_0x961c[86]](_0x961c[85])[_0x961c[37]](_0x961c[84]).toString(),{text:_0x961c[87],style:_0x961c[83]},moment(_0x4200x1a[_0x961c[89]]|| _0x4200x1a[_0x961c[81]])[_0x961c[88]](_0x961c[85])[_0x961c[37]](_0x961c[84]).toString()]})};var _0x4200x30=[];_0x4200x30[_0x961c[76]]({style:_0x961c[90],table:{headerRows:1,dontBreakRows:true,body:_0x4200x2d}});var _0x4200x31={pageOrientation:_0x961c[91],pageMargins:[15,90,15,25],header:function(){return {margin:[15,15,0,0],columns:[{table:{widths:[100,_0x961c[92]],body:[[{image:_0x961c[93]+ _0x4200x24+ _0x961c[94]+ _0x4200x29,fit:[100,60]},_0x4200x2f]]},layout:_0x961c[95]}]}},content:_0x4200x30,footer:function(_0x4200x32,_0x4200x33){return {columns:[{text:_0x4200x32.toString()+ _0x961c[96]+ _0x4200x33,alignment:_0x961c[97]}]}},styles:{header:{fontSize:18,bold:true,margin:[0,0,0,5]},tableExample:{margin:[0,0,0,5]},tableHeader:{bold:true,fontSize:13,color:_0x961c[98],wordWrap:_0x961c[99]},label:{bold:true,color:_0x961c[98]}}};var _0x4200x34= new PdfMake(fonts);var _0x4200x35=_0x4200x34[_0x961c[100]](_0x4200x31);if(_0x4200x35){var _0x4200x36=fs[_0x961c[102]](config[_0x961c[101]]+ _0x4200x2a);_0x4200x36[_0x961c[31]](_0x961c[103],function(){return updateExtracted(_0x4200x28,null,_0x961c[104])});_0x4200x36[_0x961c[31]](_0x961c[105],function(){return updateExtracted(_0x4200x28,_0x4200x2a,_0x961c[106])});_0x4200x35[_0x961c[107]](_0x4200x36);_0x4200x35[_0x961c[108]]()}else {return updateExtracted(_0x4200x28,null,_0x961c[109])}}function createCsv(_0x4200x1d,_0x4200x14,_0x4200x1a,_0x4200x28){var _0x4200x2a=sr({length:20,prefix:_0x961c[70]+ _0x4200x14[_0x961c[71]]+ _0x961c[72],suffix:_0x961c[110]});var _0x4200x38=csv(_0x4200x1d);if(_0x4200x38){fs[_0x961c[112]](config[_0x961c[101]]+ _0x4200x2a,_0x4200x38,function(_0x4200x1c){if(_0x4200x1c){console[_0x961c[32]](_0x4200x1c);return updateExtracted(_0x4200x28,null,_0x961c[111])}else {return updateExtracted(_0x4200x28,_0x4200x2a,_0x961c[106])}})}else {return updateExtracted(_0x4200x28,null,_0x961c[113])}}function updateExtracted(_0x4200x28,_0x4200x2a,_0x4200x3a){return ExtractedReport[_0x961c[119]]({status:_0x4200x3a,savename:_0x4200x2a},{where:{id:_0x4200x28}})[_0x961c[56]](function(){console[_0x961c[32]](_0x961c[118])})[_0x961c[34]](function(_0x4200x1c){console[_0x961c[32]](_0x961c[117]+ _0x4200x1c)})[_0x961c[116]](function(){process[_0x961c[115]]({message:_0x961c[114],status:_0x4200x3a})})}