Built motion from commit 945d615.|1.0.13
[motion.git] / server / config / scheduler / reports.js
1 var _0xf224=["\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x6D\x6F\x6D\x65\x6E\x74","\x6D\x6F\x6D\x65\x6E\x74\x2D\x72\x61\x6E\x67\x65","\x2E\x2E\x2F\x75\x74\x69\x6C","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x44\x65\x66\x61\x75\x6C\x74\x52\x65\x70\x6F\x72\x74","\x45\x78\x74\x72\x61\x63\x74\x65\x64\x52\x65\x70\x6F\x72\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x66\x73\x2D\x65\x78\x74\x72\x61","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x52\x65\x70\x6F\x72\x74\x73\x20\x73\x63\x68\x65\x64\x75\x6C\x65\x73\x20\x6C\x61\x75\x6E\x63\x68\x65\x72\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x65\x78\x74\x72\x61\x63\x74\x52\x65\x70\x6F\x72\x74","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x45\x78\x74\x72\x61\x63\x74\x69\x6E\x67\x20\x72\x65\x70\x6F\x72\x74\x2E\x2E\x2E","\x63\x75\x72\x72\x65\x6E\x74\x44\x61\x79","\x63\x72\x6F\x6E\x54\x79\x70\x65","\x43\x68\x65\x63\x6B\x69\x6E\x67\x20\x74\x6F\x64\x61\x79\x20\x73\x63\x68\x65\x64\x75\x6C\x65\x20\x72\x61\x6E\x67\x65\x20\x76\x61\x6C\x69\x64\x69\x74\x79\x2E\x2E\x2E","\x76\x61\x6C\x69\x64\x69\x74\x79\x53\x74\x61\x72\x74","\x76\x61\x6C\x69\x64\x69\x74\x79\x45\x6E\x64","\x54\x68\x65\x20\x68\x6F\x75\x72\x73\x20\x72\x61\x6E\x67\x65\x20\x69\x73\x20\x76\x61\x6C\x69\x64\x2C\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6E\x67\x20\x74\x6F\x64\x61\x79\x20\x72\x65\x70\x6F\x72\x74\x2E\x2E\x2E","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44","\x66\x6F\x72\x6D\x61\x74","\x30\x30\x3A\x30\x30","\x32\x33\x3A\x35\x39","\x4F\x75\x74\x20\x6F\x66\x20\x68\x6F\x75\x72\x73\x20\x72\x61\x6E\x67\x65\x2C\x20\x73\x6B\x69\x70\x70\x69\x6E\x67\x20\x72\x65\x63\x6F\x72\x64\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x21","\x64\x61\x79\x73","\x73\x75\x62\x74\x72\x61\x63\x74","\x79\x65\x73\x74\x65\x72\x64\x61\x79","\x6C\x61\x73\x74\x37","\x6C\x61\x73\x74\x33\x30","\x6D\x6F\x6E\x74\x68","\x73\x74\x61\x72\x74\x4F\x66","\x6D\x6F\x6E\x74\x68\x73","\x65\x6E\x64\x4F\x66","\x6C\x61\x73\x74\x4D\x6F\x6E\x74\x68","\x72\x65\x70\x6F\x72\x74\x52\x61\x6E\x67\x65","\x63\x6F\x6E\x74\x61\x69\x6E\x73","\x68","\x72\x61\x6E\x67\x65","\x74\x65\x78\x74","\x2F\x20","\x70\x61\x72\x65\x6E\x74","\x23","\x66\x69\x6E\x64","\x72\x65\x70\x6F\x72\x74\x54\x79\x70\x65","\x64\x65\x66\x61\x75\x6C\x74","\x53\x63\x68\x65\x64\x75\x6C\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x65\x72\x72\x6F\x72\x3A\x20","\x63\x61\x74\x63\x68","\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C\x73\x2F\x72\x65\x70\x6F\x72\x74\x5F\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x2E\x6A\x73","\x66\x6F\x72\x6B","\x65\x72\x72\x6F\x72","\x63\x68\x69\x6C\x64\x20\x65\x72\x72\x6F\x72","\x6F\x6E","\x63\x6C\x6F\x73\x65","\x63\x68\x69\x6C\x64\x20\x63\x6C\x6F\x73\x65","\x6D\x65\x73\x73\x61\x67\x65","\x63\x68\x69\x6C\x64\x20\x6D\x65\x73\x73\x61\x67\x65","\x73\x65\x6E\x64\x4D\x61\x69\x6C","\x73\x74\x61\x74\x75\x73","\x63\x6F\x6D\x70\x6C\x65\x74\x65\x64","\x69\x64","\x6B\x69\x6C\x6C","\x61\x64\x6D\x69\x6E","\x72\x65\x70\x6F\x72\x74\x4F\x75\x74\x70\x75\x74","\x73\x65\x6E\x64","\x73\x70\x72\x65\x61\x64","\x74\x72\x65\x65","\x70\x61\x72\x73\x65","\x6E\x61\x6D\x65","\x74\x61\x62\x6C\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x5F\x68\x69\x73\x74\x6F\x72\x79","","\x72\x65\x70\x6C\x61\x63\x65","\x6D\x61\x6E\x75\x61\x6C","\x73\x63\x68\x65\x64\x75\x6C\x65\x64","\x63\x72\x65\x61\x74\x65","\x74\x68\x65\x6E","\x52\x65\x70\x6F\x72\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x21","\x66\x69\x6E\x64\x42\x79\x49\x64","\x72\x65\x70\x6F\x72\x74\x49\x64","\x66\x69\x65\x6C\x64\x73","\x73\x63\x6F\x70\x65","\x66\x69\x6E\x61\x6C\x6C\x79","\x45\x72\x72\x6F\x72\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x65\x78\x74\x72\x61\x63\x74\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x20\x62\x79\x20\x6D\x61\x69\x6C\x21","\x53\x63\x68\x65\x64\x75\x6C\x65\x64\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x73\x65\x6E\x74\x21","\x73\x65\x74\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x53\x63\x68\x65\x64\x75\x6C\x65\x64\x20\x52\x65\x70\x6F\x72\x74","\x61\x64\x64\x72\x65\x73\x73","\x65\x6D\x61\x69\x6C","\x41\x20\x6E\x65\x77\x20\x72\x65\x70\x6F\x72\x74\x20\x68\x61\x73\x20\x62\x65\x65\x6E\x20\x63\x72\x65\x61\x74\x65\x64\x2C\x20\x79\x6F\x75\x20\x63\x61\x6E\x20\x63\x68\x65\x63\x6B\x20\x74\x68\x65\x20\x61\x74\x74\x61\x63\x68\x65\x64\x20\x66\x69\x6C\x65\x2E","\x53\x45\x4E\x44\x49\x4E\x47","\x45\x78\x74\x72\x61\x63\x74\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x21","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x4E\x6F\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x6F\x72\x20\x53\x4D\x54\x50\x20\x61\x64\x64\x72\x65\x73\x73\x20\x63\x6F\x6E\x66\x69\x67\x75\x72\x65\x64","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x72\x65\x70\x6F\x72\x74\x73","\x73\x61\x76\x65\x6E\x61\x6D\x65","\x6A\x6F\x69\x6E","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x2E","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x6F\x75\x74\x70\x75\x74","\x62\x61\x73\x65\x6E\x61\x6D\x65","\x63\x6F\x70\x79\x53\x79\x6E\x63","\x73\x75\x63\x63\x65\x73\x73\x21","\x45\x72\x72\x6F\x72\x20\x67\x65\x74\x74\x69\x6E\x67\x20\x74\x68\x65\x20\x65\x78\x74\x72\x61\x63\x74\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x20\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x21","\x67\x65\x74\x46\x69\x6C\x65\x53\x69\x7A\x65","\x5F","\x44\x44\x2D\x4D\x4D\x2D\x59\x59\x59\x59","\x73\x74\x61\x72\x74\x44\x61\x74\x65","\x65\x6E\x64\x44\x61\x74\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F","\x65\x78\x70\x6F\x72\x74\x73"];var cp=require(_0xf224[0]);var moment=require(_0xf224[1]);require(_0xf224[2]);var Util=require(_0xf224[3]);var CustomReport=require(_0xf224[5])[_0xf224[4]];var DefaultReport=require(_0xf224[5])[_0xf224[6]];var ExtractedReport=require(_0xf224[5])[_0xf224[7]];var MailAttachment=require(_0xf224[5])[_0xf224[8]];var MailServerOut=require(_0xf224[5])[_0xf224[9]];var MailAccount=require(_0xf224[5])[_0xf224[10]];var MailMessage=require(_0xf224[5])[_0xf224[11]];var path=require(_0xf224[12]);var config=require(_0xf224[13]);var fs=require(_0xf224[14]);var _=require(_0xf224[15]);var ReportTree=require(_0xf224[5])[_0xf224[16]];function Reports(){console[_0xf224[18]](_0xf224[17])}Reports[_0xf224[20]][_0xf224[19]]= function(_0xcdccx11,_0xcdccx12){console[_0xf224[18]](_0xf224[21]);extract(_0xcdccx11,_0xcdccx12)};function extract(_0xcdccx11,_0xcdccx12){switch(_0xcdccx11[_0xf224[23]]){case _0xf224[22]:extractTodayReport(_0xcdccx11,_0xcdccx12);break;default:extractRangeReport(_0xcdccx11,_0xcdccx12);break}}function extractTodayReport(_0xcdccx11,_0xcdccx12){console[_0xf224[18]](_0xf224[24]);if(_0xcdccx12|| checkValidity(_0xcdccx11[_0xf224[25]],_0xcdccx11[_0xf224[26]])){console[_0xf224[18]](_0xf224[27]);docExtract(_0xcdccx11,moment()[_0xf224[29]](_0xf224[28]),moment()[_0xf224[29]](_0xf224[28]),_0xcdccx12,_0xf224[30],_0xf224[31])}else {console[_0xf224[18]](_0xf224[32])}}function extractRangeReport(_0xcdccx11,_0xcdccx12){switch(_0xcdccx11[_0xf224[43]]){case _0xf224[35]:docExtract(_0xcdccx11,moment()[_0xf224[34]](1,_0xf224[33])[_0xf224[29]](_0xf224[28]),moment()[_0xf224[34]](1,_0xf224[33])[_0xf224[29]](_0xf224[28]),_0xcdccx12);break;case _0xf224[36]:docExtract(_0xcdccx11,moment()[_0xf224[34]](7,_0xf224[33])[_0xf224[29]](_0xf224[28]),moment()[_0xf224[34]](1,_0xf224[33])[_0xf224[29]](_0xf224[28]),_0xcdccx12);break;case _0xf224[37]:docExtract(_0xcdccx11,moment()[_0xf224[34]](30,_0xf224[33])[_0xf224[29]](_0xf224[28]),moment()[_0xf224[34]](1,_0xf224[33])[_0xf224[29]](_0xf224[28]),_0xcdccx12);break;case _0xf224[42]:docExtract(_0xcdccx11,moment()[_0xf224[34]](1,_0xf224[40])[_0xf224[39]](_0xf224[38])[_0xf224[29]](_0xf224[28]),moment()[_0xf224[34]](1,_0xf224[40])[_0xf224[41]](_0xf224[38])[_0xf224[29]](_0xf224[28]),_0xcdccx12);break}}function checkValidity(_0xcdccx17,_0xcdccx18){return moment()[_0xf224[46]](moment(_0xcdccx17,_0xf224[45]),moment(_0xcdccx18,_0xf224[45]))[_0xf224[44]](moment())}function getReportPath(_0xcdccx1a,_0xcdccx1b,path){path= _0xcdccx1a[_0xf224[47]]+ _0xf224[48]+ path;if(_0xcdccx1a[_0xf224[49]]=== _0xf224[50]){return path}else {return getReportPath(_[_0xf224[51]](_0xcdccx1b,{id:_0xcdccx1a[_0xf224[49]]}),_0xcdccx1b,path)}}function docExtract(_0xcdccx11,_0xcdccx1d,_0xcdccx1e,_0xcdccx12,_0xcdccx1f,_0xcdccx20){var _0xcdccx21=_0xcdccx11[_0xf224[52]]=== _0xf224[53]?DefaultReport:CustomReport;var _0xcdccx22;_0xcdccx21[_0xf224[90]](_0xf224[89])[_0xf224[87]](_0xcdccx11[_0xf224[88]])[_0xf224[85]](function(_0xcdccx27){if(!_0xcdccx27){console[_0xf224[18]](_0xf224[86]);return};_0xcdccx22= _0xcdccx27;return ReportTree[_0xf224[87]](_0xcdccx11[_0xf224[52]]=== _0xf224[53]?1:2)})[_0xf224[85]](function(_0xcdccx1b){_0xcdccx1b= JSON[_0xf224[75]](_0xcdccx1b[_0xf224[74]]);var _0xcdccx1a=_[_0xf224[51]](_0xcdccx1b,{id:_0xcdccx22[_0xf224[49]]});var path=getReportPath(_0xcdccx1a,_0xcdccx1b,_0xcdccx22[_0xf224[76]]);if(_0xcdccx11[_0xf224[23]]=== _0xf224[22]){_0xcdccx22[_0xf224[78]][_0xf224[77]]= _0xcdccx22[_0xf224[78]][_0xf224[77]][_0xf224[81]](_0xf224[79],_0xf224[80])};return [_0xcdccx22,ExtractedReport[_0xf224[84]]({name:_0xcdccx22[_0xf224[76]],startDate:_0xcdccx1d,endDate:_0xcdccx1e,output:_0xcdccx11[_0xf224[71]],type:_0xcdccx12?_0xf224[82]:_0xf224[83],UserId:_0xcdccx12?_0xcdccx12[_0xf224[68]]:null})]})[_0xf224[73]](function(_0xcdccx22,_0xcdccx24){var _0xcdccx25=cp[_0xf224[57]](__dirname+ _0xf224[56]);_0xcdccx25[_0xf224[60]](_0xf224[63],function(_0xcdccx26){console[_0xf224[18]](_0xf224[64],_0xcdccx26);if(_0xcdccx11[_0xf224[65]]&& _0xcdccx26[_0xf224[66]]=== _0xf224[67]){sendReportByMail(_0xcdccx11,_0xcdccx24[_0xf224[68]],_0xcdccx12,_0xcdccx25)}else {_0xcdccx25[_0xf224[69]]()}})[_0xf224[60]](_0xf224[61],function(){console[_0xf224[18]](_0xf224[62])})[_0xf224[60]](_0xf224[58],function(_0xcdccx23){console[_0xf224[18]](_0xf224[59],_0xcdccx23)});_0xcdccx25[_0xf224[72]]({report:_0xcdccx22,query:{startDate:_0xcdccx1d,endDate:_0xcdccx1e,startTime:_0xcdccx1f|| null,endTime:_0xcdccx20|| null},extractedId:_0xcdccx24[_0xf224[68]],user:_0xcdccx12?_0xcdccx12:{role:_0xf224[70]},type:_0xcdccx11[_0xf224[71]]})})[_0xf224[55]](function(_0xcdccx23){console[_0xf224[18]](_0xf224[54],_0xcdccx23)})}function sendReportByMail(_0xcdccx11,_0xcdccx29,_0xcdccx12,_0xcdccx25){var _0xcdccx2a;return ExtractedReport[_0xf224[87]](_0xcdccx29)[_0xf224[85]](function(extract){if(!extract){throw  new Error(_0xf224[100])};_0xcdccx2a= extract;if(_0xcdccx11[_0xf224[9]]&& _0xcdccx11[_0xf224[9]][_0xf224[68]]){return MailAccount[_0xf224[51]]({attributes:[_0xf224[68],_0xf224[96]],include:[{model:MailServerOut,attributes:[_0xf224[68],_0xf224[101]],where:{id:_0xcdccx11[_0xf224[9]][_0xf224[68]]}}]})}else {throw  new Error(_0xf224[102])}})[_0xf224[85]](function(_0xcdccx2c){var _0xcdccx2d=getAttachment(_0xcdccx2a);var _0xcdccx2e={subject:_0xf224[95],from:[_0xcdccx2c[_0xf224[96]]],to:[_0xcdccx11[_0xf224[97]]],cc:[],html:_0xf224[98],text:null,inReplyTo:null,status:_0xf224[99],attachment:true,UserId:_0xcdccx12?_0xcdccx12[_0xf224[68]]:null,MailAttachments:[_0xcdccx2d]};return MailMessage[_0xf224[84]](_0xcdccx2e,{include:[{model:MailAttachment}]})})[_0xf224[85]](function(_0xcdccx2b){return _0xcdccx2a[_0xf224[94]](_0xcdccx2b)})[_0xf224[85]](function(){console[_0xf224[18]](_0xf224[93])})[_0xf224[55]](function(_0xcdccx23){console[_0xf224[18]](_0xf224[92],_0xcdccx23)})[_0xf224[91]](function(){_0xcdccx25[_0xf224[69]]()})}function getAttachment(extract){var _0xcdccx30=path[_0xf224[108]](config[_0xf224[103]],_0xf224[104],_0xf224[105],_0xf224[106],extract[_0xf224[107]]);var _0xcdccx31=path[_0xf224[108]](config[_0xf224[103]],_0xf224[104],_0xf224[105],_0xf224[109]);var _0xcdccx32=path[_0xf224[113]](extract[_0xf224[107]],_0xf224[110]+ extract[_0xf224[112]][_0xf224[111]]());try{fs[_0xf224[114]](_0xcdccx30,path[_0xf224[108]](_0xcdccx31,_0xcdccx32));console[_0xf224[18]](_0xf224[115])}catch(err){console[_0xf224[58]](_0xf224[116]);return null};return {size:Util[_0xf224[117]](_0xcdccx30),path:path[_0xf224[108]](_0xcdccx31,_0xcdccx32),name:extract[_0xf224[76]]+ _0xf224[118]+ moment(extract[_0xf224[120]])[_0xf224[29]](_0xf224[119])+ _0xf224[118]+ moment(extract[_0xf224[121]])[_0xf224[29]](_0xf224[119])+ _0xf224[110]+ extract[_0xf224[112]][_0xf224[111]](),type:_0xf224[122]+ extract[_0xf224[112]][_0xf224[111]](),basename:_0xcdccx32}}module[_0xf224[123]]= Reports