Built motion from commit 5fc88b3.|0.0.60
[motion.git] / server / api / service / service.controller.js
1 var _0x6da1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x53\x65\x72\x76\x69\x63\x65","\x55\x73\x65\x72\x48\x61\x73\x53\x65\x72\x76\x69\x63\x65","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x67\x65\x74\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x6C\x6F\x67","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x70\x64\x61\x74\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x43\x55\x53\x54\x4F\x4D\x5F\x46\x49\x45\x4C\x44","\x62\x6F\x64\x79","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x6E\x61\x6D\x65","\x63\x72\x65\x61\x74\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x53\x65\x72\x76\x69\x63\x65\x49\x64","\x63\x72\x65\x61\x74\x65","\x73\x68\x6F\x77","\x73\x65\x72\x76\x69\x63\x65\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x53\x45\x52\x56\x49\x43\x45","\x75\x70\x64\x61\x74\x65","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x6D\x61\x70","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x55\x73\x65\x72\x73","\x6E\x6F\x20\x73\x65\x72\x76\x69\x63\x65\x20\x66\x6F\x75\x6E\x64","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x61\x6C\x6C","\x43\x6F\x6E\x74\x61\x63\x74\x73","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x64\x65\x61\x63\x74\x69\x76\x61\x74\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64"];_0x6da1[0];var _=require(_0x6da1[1]);var util=require(_0x6da1[2]);var User=require(_0x6da1[4])[_0x6da1[3]];var Service=require(_0x6da1[4])[_0x6da1[5]];var UserHasService=require(_0x6da1[4])[_0x6da1[6]];var CustomField=require(_0x6da1[4])[_0x6da1[7]];var Contact=require(_0x6da1[4])[_0x6da1[8]];var Util=require(_0x6da1[9]);exports[_0x6da1[10]]=function(_0x51dax9,_0x51daxa,_0x51daxb){return Service[_0x6da1[17]](Util[_0x6da1[16]](_0x51dax9[_0x6da1[15]]))[_0x6da1[14]](function(_0x51daxd){_0x51daxa[_0x6da1[13]](200)[_0x6da1[12]](_0x51daxd)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[18]]=function(_0x51dax9,_0x51daxa){CustomField[_0x6da1[22]]({where:{ServiceId:_0x51dax9[_0x6da1[21]][_0x6da1[20]],active:true}})[_0x6da1[14]](function(_0x51daxe){return _0x51daxa[_0x6da1[13]](200)[_0x6da1[12]](_0x51daxe)})[_0x6da1[11]](function(_0x51daxc){console[_0x6da1[19]](_0x51daxc);return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[23]]=function(_0x51dax9,_0x51daxa){CustomField[_0x6da1[25]](_0x51dax9[_0x6da1[21]][_0x6da1[20]])[_0x6da1[14]](function(_0x51daxf){if(!_0x51daxf){return _0x51daxa[_0x6da1[24]](404)};return _0x51daxa[_0x6da1[12]](_0x51daxf)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[26]]=function(_0x51dax9,_0x51daxa){CustomField[_0x6da1[22]]({where:{name:_0x51dax9[_0x6da1[29]][_0x6da1[32]],id:{$ne:_0x51dax9[_0x6da1[29]][_0x6da1[20]]}}})[_0x6da1[14]](function(_0x51daxe){if(!_0x51daxe){return _0x51daxa[_0x6da1[24]](404)};if(_0x51daxe[_0x6da1[27]]>0){return _0x51daxa[_0x6da1[13]](500)[_0x6da1[12]]({message:_0x6da1[28]})};if(_0x51dax9[_0x6da1[29]][_0x6da1[20]]){delete _0x51dax9[_0x6da1[29]][_0x6da1[20]]};CustomField[_0x6da1[25]](_0x51dax9[_0x6da1[21]][_0x6da1[20]])[_0x6da1[14]](function(_0x51daxf){if(!_0x51daxf){return _0x51daxa[_0x6da1[24]](404)};var _0x51dax10=_[_0x6da1[30]](_0x51daxf,_0x51dax9[_0x6da1[29]]);_0x51dax10[_0x6da1[31]]()[_0x6da1[14]](function(){return _0x51daxa[_0x6da1[13]](200)[_0x6da1[12]](_0x51daxf)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[33]]=function(_0x51dax9,_0x51daxa){_0x51dax9[_0x6da1[29]][_0x6da1[34]]=_0x51dax9[_0x6da1[21]][_0x6da1[20]];CustomField[_0x6da1[35]](_0x51dax9[_0x6da1[29]])[_0x6da1[14]](function(_0x51daxf){return _0x51daxa[_0x6da1[13]](201)[_0x6da1[12]](_0x51daxf)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[36]]=function(_0x51dax9,_0x51daxa){Service[_0x6da1[25]](_0x51dax9[_0x6da1[21]][_0x6da1[20]])[_0x6da1[14]](function(_0x51dax11){if(!_0x51dax11){return _0x51daxa[_0x6da1[24]](404)};return _0x51daxa[_0x6da1[12]](_0x51dax11)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[37]]=function(_0x51dax9,_0x51daxa){console[_0x6da1[19]](_0x51dax9[_0x6da1[29]]);Service[_0x6da1[22]]({where:{id:_0x51dax9[_0x6da1[29]][_0x6da1[20]]}})[_0x6da1[14]](function(_0x51dax11){if(!_0x51dax11){return _0x51daxa[_0x6da1[24]](404)};return _0x51daxa[_0x6da1[12]](_0x51dax11)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[35]]=function(_0x51dax9,_0x51daxa){Service[_0x6da1[22]]({where:{name:_0x51dax9[_0x6da1[29]][_0x6da1[32]]}})[_0x6da1[14]](function(_0x51dax12){console[_0x6da1[19]](_0x51dax12);console[_0x6da1[19]](_0x6da1[38]);if(!_0x51dax12){return _0x51daxa[_0x6da1[24]](404)};if(_0x51dax12[_0x6da1[27]]>0){return _0x51daxa[_0x6da1[13]](500)[_0x6da1[12]]({message:_0x6da1[39]})};Service[_0x6da1[35]](_0x51dax9[_0x6da1[29]])[_0x6da1[14]](function(_0x51dax11){return _0x51daxa[_0x6da1[13]](201)[_0x6da1[12]](_0x51dax11)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[40]]=function(_0x51dax9,_0x51daxa){Service[_0x6da1[22]]({where:{name:_0x51dax9[_0x6da1[29]][_0x6da1[32]]}})[_0x6da1[14]](function(_0x51dax12){console[_0x6da1[19]](_0x51dax12);console[_0x6da1[19]](_0x6da1[38]);if(!_0x51dax12){return _0x51daxa[_0x6da1[24]](404)};if(_0x51dax12[_0x6da1[27]]>0){return _0x51daxa[_0x6da1[13]](500)[_0x6da1[12]]({message:_0x6da1[39]})};return Service[_0x6da1[25]](_0x51dax9[_0x6da1[21]][_0x6da1[20]])})[_0x6da1[14]](function(_0x51dax11){if(!_0x51dax11){return _0x51daxa[_0x6da1[24]](404)};if(_0x51dax9[_0x6da1[29]][_0x6da1[20]]){delete _0x51dax9[_0x6da1[29]][_0x6da1[20]]};var _0x51dax10=_[_0x6da1[30]](_0x51dax11,_0x51dax9[_0x6da1[29]]);return _0x51dax10[_0x6da1[31]]()})[_0x6da1[14]](function(_0x51dax11){return _0x51daxa[_0x6da1[13]](200)[_0x6da1[12]](_0x51dax11)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};exports[_0x6da1[41]]=function(_0x51dax9,_0x51daxa,_0x51daxb){console[_0x6da1[19]](_0x6da1[41]);console[_0x6da1[19]](_0x51dax9[_0x6da1[21]]);console[_0x6da1[19]](_0x51dax9[_0x6da1[29]]);User[_0x6da1[22]]({where:{id:{$in:_0x51dax9[_0x6da1[29]][_0x6da1[44]]}}})[_0x6da1[14]](function(_0x51dax13){var _0x51dax14=_[_0x6da1[42]](_0x51dax13,function(_0x51dax15){return {service:_0x51dax9[_0x6da1[21]][_0x6da1[20]],membername:_0x51dax15[_0x6da1[32]],UserId:_0x51dax15[_0x6da1[20]]}});UserHasService[_0x6da1[43]](_0x51dax14,{individualHooks:true})[_0x6da1[14]](function(){return _0x51daxa[_0x6da1[24]](200)})[_0x6da1[11]](function(_0x51daxc){return _0x51daxb(_0x51daxc)})})[_0x6da1[11]](function(_0x51daxc){return _0x51daxb(_0x51daxc)})};exports[_0x6da1[45]]=function(_0x51dax9,_0x51daxa,_0x51daxb){Service[_0x6da1[48]]({where:{id:_0x51dax9[_0x6da1[21]][_0x6da1[20]]}})[_0x6da1[14]](function(_0x51dax11){if(_0x51dax11){_0x51dax11[_0x6da1[46]](_0x51dax9[_0x6da1[29]][_0x6da1[44]],{individualHooks:true})[_0x6da1[14]](function(){return _0x51daxa[_0x6da1[24]](200)})[_0x6da1[11]](function(_0x51daxc){return _0x51daxb(_0x51daxc)})}else {return _0x51daxb( new Error(_0x6da1[47]))}})[_0x6da1[11]](function(_0x51daxc){return _0x51daxb(_0x51daxc)})};exports[_0x6da1[49]]=function(_0x51dax9,_0x51daxa){destroyService(_0x51dax9[_0x6da1[21]][_0x6da1[20]],_0x51daxa)};exports[_0x6da1[50]]=function(_0x51dax9,_0x51daxa){destroyService(_0x51dax9[_0x6da1[15]][_0x6da1[20]],_0x51daxa)};function destroyService(_0x51dax17,_0x51daxa){return delOrUpdateCf(_0x51dax17)[_0x6da1[51]]()[_0x6da1[14]](function(){return Service[_0x6da1[49]]({where:{id:_0x51dax17},individualHooks:true})})[_0x6da1[14]](function(){return _0x51daxa[_0x6da1[24]](204)})[_0x6da1[11]](function(_0x51daxc){console[_0x6da1[19]](_0x51daxc);return handleError(_0x51daxa,_0x51daxc)})}function delOrUpdateCf(_0x51dax17){return CustomField[_0x6da1[22]]({where:{ServiceId:_0x51dax17},include:[{model:Contact}]})[_0x6da1[14]](function(_0x51daxe){console[_0x6da1[19]](_0x51daxe[_0x6da1[27]]);var _0x51dax19=[];_[_0x6da1[54]](_0x51daxe,function(_0x51dax1a){if(_0x51dax1a[_0x6da1[52]][_0x6da1[27]]){_0x51dax19[_0x6da1[53]](_0x51dax1a[_0x6da1[40]]({active:false}))}else {_0x51dax19[_0x6da1[53]](_0x51dax1a[_0x6da1[49]]())}});return _0x51dax19})}exports[_0x6da1[55]]=function(_0x51dax9,_0x51daxa){CustomField[_0x6da1[25]](_0x51dax9[_0x6da1[21]][_0x6da1[20]],{include:[{model:Contact}]})[_0x6da1[14]](function(_0x51daxf){if(!_0x51daxf){return _0x51daxa[_0x6da1[24]](404)};if(_0x51daxf[_0x6da1[52]][_0x6da1[27]]){return _0x51daxf[_0x6da1[40]]({active:false})}else {return _0x51daxf[_0x6da1[49]]()}})[_0x6da1[14]](function(){return _0x51daxa[_0x6da1[24]](204)})[_0x6da1[11]](function(_0x51daxc){return handleError(_0x51daxa,_0x51daxc)})};function handleError(_0x51daxa,_0x51daxc){return _0x51daxa[_0x6da1[13]](500)[_0x6da1[12]](_0x51daxc)}