diff --git a/dist/lets.min.js b/dist/lets.min.js index f448cff..1f75c5a 100644 --- a/dist/lets.min.js +++ b/dist/lets.min.js @@ -1,4 +1,4 @@ -!function(){"use strict";function e(){this.headers={};this.set=function(e,t){this.headers[e]=t},this.get=function(e){if(this.headers[e].findLabel=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a.label}},this.headers[e].get=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}},this.headers[e].tabs)for(var t in this.headers[e].tabs)this.headers[e].tabs[t].get=function(e){if(!this.fields||!this.fields.length)return null;for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}};return this.headers[e]},this.$get=function(){return this}}function t(e,t){}var a=angular.module("letsAngular",["ui.router","ngAnimate","ui.bootstrap","angular.viacep","ngCpfCnpj","ui.mask","ui.jq","ui.event","ngFileUpload","moment-filter","checklist-model","ui.toggle","ngSanitize","colorpicker-dr","ckeditor","thatisuday.dropzone","swangular","angularjs-dropdown-multiselect","daterangepicker"]);a.config(t),a.provider("headers",e),t.$inject=["$stateProvider","$httpProvider"]}(),function(){"use strict";function e(){var e=this;return e._placeholderList=["paciente"],e._placeholderAttr=["nome"],e.removeAccents=function(e){var t="ÀÁÂÃÄÅàáâãäåßÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž",a="AAAAAAaaaaaaBOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";e=e.split("");var i,n,o=e.length;for(i=0;o>i;i++)-1!=(n=t.indexOf(e[i]))&&(e[i]=a[n]);return e.join("")},e._removeSpecialChars=function(e){var t="!@#$%*()-_+=/.,:;?[{]}`~^|";e=e.split("");var a,i=e.length;for(a=0;i>a;a++)-1!=t.indexOf(e[a])&&(e[a]="");return e.join("")},e.lemmatize=function(t){return t=e.removeAccents(t),e._removeSpecialChars(t)},e.changePlaceholders=function(t,a){return e._placeholderList.forEach(function(i,n){if(a[i]){var o="["+i.toUpperCase()+"]";if(-1!==t.indexOf(o)){var l=t.split(o),r="",s=l.length;l.forEach(function(t,o){r+=t,s-1>o&&(r+=a[i][e._placeholderAttr[n]])}),t=r}}}),t},{removeAccents:e.removeAccents,lemmatize:e.lemmatize,changePlaceholders:e.changePlaceholders}}angular.module("letsAngular").service("utilsStringService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i){var n=this;return n._printHTML=function(e){var t=$("").appendTo("body")[0];t.contentWindow.printAndRemove=function(){t.contentWindow.print(),setTimeout(function(){$(t).remove()},3e3)};var a=''+e+"",i=t.contentWindow.document.open("text/html","replace");i.write(a),i.close()},n.print=function(o,l){moment.locale("pt-br");var r=angular.extend(t.$new(),l);e(o).then(function(e){var t=a($("
"+e+"
"))(r),o=function(){r.$$phase?i(o):(n._printHTML(t.html()),r.$destroy())};o()})},{print:n.print}}e.$inject=["$templateRequest","$rootScope","$compile","$timeout"],angular.module("letsAngular").service("utilsPrintService",e),e.inject=["$templateRequest","$rootScope","$compile","$timeout"]}(),function(){"use strict";function e(){var e=this;return e.convertObjSearch=function(e,t){var a={};return Object.keys(e).forEach(function(i){if(e[i])if("object"==typeof e[i]){var n={};Object.keys(e[i]).forEach(function(a){if("createdAt"!==a&&"updatedAt"!==a){var o=a;"id"!==a&&(o="label"),"label"===o&&t&&i===t.relation?n.label=e[i][t.label]:n[o]=e[i][a]}}),a[i+".label"]=n,a[i]=n.id}else-1===i.indexOf("id")&&"createdAt"!==i&&"updatedAt"!==i&&(a[i]=e[i])}),a},e.convertObjLabels=function(e){return e.forEach(function(e){Object.keys(e).forEach(function(t){if("object"==typeof e[t]){var a=t.split(".")[0];"label"===t.split(".")[1]&&(e[a]=angular.copy(e[t]),delete e[t])}})}),e},e.setInputsFromObject=function(e){Object.keys(e).forEach(function(t){if(e[t]&&-1===t.indexOf("hashKey")&&"id"!==t&&"createdAt"!==t&&"updatedAt"!==t){var a=angular.element("#"+t).scope();void 0===a&&-1!==t.indexOf("label")&&(a=angular.element("#"+t.split(".")[0]).scope()),a&&(a.field.autocomplete?"object"==typeof e[t]&&(e[t].label||(e[t].label=e[t].nome),a.$parent.data[t]=e[t].label,a.$parent.data[t+".label"]=e[t]):a.$parent.data[t]=e[t])}})},{convertObjSearch:e.convertObjSearch,convertObjLabels:e.convertObjLabels,setInputsFromObject:e.setInputsFromObject}}angular.module("letsAngular").service("utilsObjectService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e.getDiffDuration=function(e,t,a){moment.isMoment(e)||(e=moment(e)),moment.isMoment(t)||(t=moment(t));var i=moment.duration(e.diff(t));switch(a){case"day":return i.asDays();case"hour":return i.asHours();case"minute":return i.asMinutes();case"second":return i.asSeconds();case"week":return i.asWeeks();case"month":return i.asMonths();case"year":return i.asYears();default:return i.asMilliseconds()}},{getDiffDuration:e.getDiffDuration}}angular.module("letsAngular").service("utilsDateTimeService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e._getFilledFilterAttr=function(e,t){var a={radios:[],checkboxes:[]};return Object.keys(e).forEach(function(t){null!==e[t]&&a.radios.push(t)}),Object.keys(t).forEach(function(e){t[e].length>0&&a.checkboxes.push(e)}),a},e._findCheckAttr=function(e,t){var a=null;return Object.keys(t).forEach(function(i){i===e&&(a=t[i])}),a},e.filterList=function(t,a,i,n,o,l){var r=t.slice(0),s=Object.keys(l).length,d=e._getFilledFilterAttr(a,n),c="neutral";d.checkboxes.forEach(function(e){n[e].length>o[e].length?c="add":n[e].lengtha[t]?1:0}):e},e.getMinMaxValues=function(e,t,a,i,n,o,l){var r={x:l[0][t],y:l[0][n]},s={x:l[0][t],y:l[0][n]};return l.forEach(function(e){e[t]s.x&&(s.x=e[t]),e[n]s.y&&(s.y=e[n])}),"date"===e?(r.x=new Date(moment(r.x).subtract(a,"day").format("MM/DD/YYYY")),s.x=new Date(moment(s.x).add(a,"day").format("MM/DD/YYYY"))):(r.x-=a,s.x+=a),"date"===i?(r.y=new Date(moment(r.y).subtract(o,"day").format("MM/DD/YYYY")),s.y=new Date(moment(s.y).add(o,"day").format("MM/DD/YYYY"))):(r.y-=o,s.y+=o),{min:r,max:s}},{filterList:e.filterList,orderList:e.orderList,getMinMaxValues:e.getMinMaxValues}}angular.module("letsAngular").service("utilsComparatorService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a){var i=this;return i._createModal=function(t){return e.open(t).result},i.createCRUDModal=function(e,a,n,o){return i._createModal({animation:!0,templateUrl:o||"lets/views/crud/crud-modal.html",controller:n||"CRUDFormModalController",resolve:{headers:function(){return e},data:function(){try{var e=angular.copy(a)}catch(i){var e=t.extend({},a)}return e}},size:"lg",backdrop:"static",keyboard:!1})},i.hide=function(){a.$emit("cancel-modal")},{createModal:i._createModal,createCRUDModal:i.createCRUDModal,hide:i.hide}}e.$inject=["$modal","jQuery","$rootScope"],angular.module("letsAngular").service("fwModalService",e),e.inject=["$modal","jQuery","$rootScope"]}(),function(){"use strict";function e(e){var t=this;return t.emitFormErrors=function(t){var a=[],i=Object.keys(t.$error),n=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var o in i){var l=t.$error[i[o]];for(var r in l){var s=l[r].$options.fieldInfo.label;"required"==i[o]?a.push("O campo "+s+" é obrigatório"):"date"==i[o]&&0==n.test(l[r].$viewValue)&&a.push("O campo "+s+" está com uma data inválida")}}a.length>0&&e.warning(a.join("
"))},{emitFormErrors:t.emitFormErrors}}e.$inject=["ngToast"],angular.module("letsAngular").service("fwErrorService",e),e.inject=["ngToast"]}(),function(){"use strict";function e(){var e=this;return e.configD3chart=function(e,t,a){var i=null,n={left:40,bottom:28,right:28,top:28};return a||(a={x:[],y:[0,150]}),i="multibar"===e?nv.models.multiBarChart().margin(n).color(t).yDomain(a.y):nv.models.lineChart().margin(n).color(t).xDomain(a.x).yDomain(a.y),i.xAxis.showMaxMin(!1).tickFormat(function(e){return d3.time.format("%d/%m/%y")(new Date(e))}),i.xScale(d3.time.scale()),i.yAxis.showMaxMin(!1).tickFormat(d3.format(",f")),i.tooltip.enabled(!1),i},e.configD3chartData=function(e,t,a){var i=[];return a.forEach(function(e){var t={x:new Date(moment(e.data).format("MM/DD/YYYY")),y:e.valor};i.push(t)}),[{area:e,key:t,values:i}]},e.getMockD3chartsData=function(e){return e||(e=!1),{glicemiaCapilar:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:77},{x:new Date("06/17/2017").getTime(),y:70},{x:new Date("07/01/2017").getTime(),y:121},{x:new Date("07/08/2017").getTime(),y:84},{x:new Date("07/15/2017").getTime(),y:75},{x:new Date("07/22/2017").getTime(),y:80},{x:new Date("07/29/2017").getTime(),y:76},{x:new Date("08/05/2017").getTime(),y:120},{x:new Date("08/12/2017").getTime(),y:77},{x:new Date("08/19/2017").getTime(),y:85}]}],pressao:[{area:e,key:"Sistólica",values:[{x:new Date("06/10/2017").getTime(),y:125},{x:new Date("06/17/2017").getTime(),y:139},{x:new Date("07/01/2017").getTime(),y:129},{x:new Date("07/08/2017").getTime(),y:133},{x:new Date("07/15/2017").getTime(),y:134},{x:new Date("07/22/2017").getTime(),y:133},{x:new Date("07/29/2017").getTime(),y:143},{x:new Date("08/05/2017").getTime(),y:148},{x:new Date("08/12/2017").getTime(),y:139},{x:new Date("08/19/2017").getTime(),y:134}]},{area:e,key:"Diastólica",values:[{x:new Date("06/10/2017").getTime(),y:78},{x:new Date("06/17/2017").getTime(),y:75},{x:new Date("07/01/2017").getTime(),y:83},{x:new Date("07/08/2017").getTime(),y:80},{x:new Date("07/15/2017").getTime(),y:77},{x:new Date("07/22/2017").getTime(),y:79},{x:new Date("07/29/2017").getTime(),y:83},{x:new Date("08/05/2017").getTime(),y:81},{x:new Date("08/12/2017").getTime(),y:74},{x:new Date("08/19/2017").getTime(),y:81}]}],peso:[{area:e,key:"Quilos",values:[{x:new Date("06/10/2017").getTime(),y:89},{x:new Date("06/17/2017").getTime(),y:90},{x:new Date("07/01/2017").getTime(),y:89},{x:new Date("07/08/2017").getTime(),y:92},{x:new Date("07/15/2017").getTime(),y:93},{x:new Date("07/22/2017").getTime(),y:94},{x:new Date("07/29/2017").getTime(),y:93},{x:new Date("08/05/2017").getTime(),y:93},{x:new Date("08/12/2017").getTime(),y:93},{x:new Date("08/19/2017").getTime(),y:92}]}],altura:[{area:e,key:"Metros",values:[{x:new Date("06/10/2017").getTime(),y:1.76},{x:new Date("06/17/2017").getTime(),y:1.76},{x:new Date("07/01/2017").getTime(),y:1.76},{x:new Date("07/08/2017").getTime(),y:1.76},{x:new Date("07/15/2017").getTime(),y:1.76},{x:new Date("07/22/2017").getTime(),y:1.76},{x:new Date("07/29/2017").getTime(),y:1.76},{x:new Date("08/05/2017").getTime(),y:1.76},{x:new Date("08/12/2017").getTime(),y:1.76},{x:new Date("08/19/2017").getTime(),y:1.76}]}],imc:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:15.3},{x:new Date("06/17/2017").getTime(),y:15.5},{x:new Date("07/01/2017").getTime(),y:15.3},{x:new Date("07/08/2017").getTime(),y:15.8},{x:new Date("07/15/2017").getTime(),y:16},{x:new Date("07/22/2017").getTime(),y:16.2},{x:new Date("07/29/2017").getTime(),y:16},{x:new Date("08/05/2017").getTime(),y:16},{x:new Date("08/12/2017").getTime(),y:16},{x:new Date("08/19/2017").getTime(),y:15.8}]}],hdlLdl:[{area:e,key:"HDL",values:[{x:new Date("06/10/2017").getTime(),y:43},{x:new Date("06/17/2017").getTime(),y:41},{x:new Date("07/01/2017").getTime(),y:42},{x:new Date("07/08/2017").getTime(),y:45},{x:new Date("07/15/2017").getTime(),y:46},{x:new Date("07/22/2017").getTime(),y:48},{x:new Date("07/29/2017").getTime(),y:44},{x:new Date("08/05/2017").getTime(),y:41},{x:new Date("08/12/2017").getTime(),y:42},{x:new Date("08/19/2017").getTime(),y:40}]},{area:e,key:"LDL",values:[{x:new Date("06/10/2017").getTime(),y:121},{x:new Date("06/17/2017").getTime(),y:130},{x:new Date("07/01/2017").getTime(),y:137},{x:new Date("07/08/2017").getTime(),y:138},{x:new Date("07/15/2017").getTime(),y:120},{x:new Date("07/22/2017").getTime(),y:122},{x:new Date("07/29/2017").getTime(),y:123},{x:new Date("08/05/2017").getTime(),y:124},{x:new Date("08/12/2017").getTime(),y:122},{x:new Date("08/19/2017").getTime(),y:120}]}]}},e.getMockD3chartsConfig=function(){return{glicemiaCapilar:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,130]}),pressao:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,150]}),peso:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[80,100]}),altura:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[0,2]}),imc:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[12,20]}),hdlLdl:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[30,150]})}},{getMockD3chartsData:e.getMockD3chartsData,getMockD3chartsConfig:e.getMockD3chartsConfig,configD3chart:e.configD3chart,configD3chartData:e.configD3chartData}}angular.module("letsAngular").service("fwChartService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i,n,o,l,r){var s=o.API_URL,d=this;d.updateLocalStorage=function(e,t){var a=d.getUser();a[e]=t,d.setUserInfo(a)},d.setUserLb=function(e){t.setUser(e.id,e.userId,e.user),t.rememberMe=!0,t.save()},d.setUserInfo=function(e){window.localStorage.user=angular.toJson(e)},d.getUser=function(){return window.localStorage.user?JSON.parse(window.localStorage.user):!1},d.isAuthenticated=function(){return null!=t.currentUserId},d.authenticate=function(e){return n.authenticate(e).then(function(e){var t={accessToken:e.access_token};return l.post(s+"users/facebook/token",t)}).then(function(e){var t={id:e.data.id,userId:e.data.user.id,user:e.data.user};d.setUserLb(t),d.setUserInfo(e.data.user),d.removeSatellizer(),i.go("main.search")})["catch"](function(e){})},d.logout=function(n){a.userLogout({accessToken:n}).$promise.then(function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})["catch"](function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})},d.getCurrentUserId=function(){return t.currentUserId},d.getCurrentUserToken=function(){return t.accessTokenId},d.removeSatellizer=function(){e.localStorage.getItem("satellizer_token")&&e.localStorage.removeItem("satellizer_token")}}e.$inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http","$q"],angular.module("letsAngular").service("fwAuthService",e),e.inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http"]}(),function(){"use strict";function e(e){return{restrict:"A",scope:!0,link:function(t,a,i){t.defaultProgress=0,t.alreadySent=!1;var n=!0;t.$on("setProgressFile",function(){void 0!=t.data[t.field.name]&&null!=t.data[t.field.name]&&t.fileName&&"fileName"!=t.fileName&&(t.defaultProgress=100,t.alreadySent=!0)}),t.pushName=function(){e(function(){if(document.getElementsByClassName("dz-filename")[0]&&n){n=!1,document.getElementsByClassName("dropzone")[0].style.width="192px",document.getElementsByClassName("file-preview")[0]&&(document.getElementsByClassName("file-preview")[0].style.display="none"),document.getElementsByName("temp_filename")[0].value=document.getElementsByClassName("dz-filename")[0].firstElementChild.innerText;var e=i.find('input[type="hidden"]');e.controller("ngModel").$setViewValue(document.getElementsByName("temp_filename")[0].value)}})},t.remove=function(){t.alreadySent=!1;var e=i.find('input[type="hidden"]');document.getElementsByName("temp_filename")[0].value=null,e.controller("ngModel").$setViewValue(null)},t.upload=function(a,n){t.f=a,t.errFile=n&&n[0],a&&(a.upload=t._upload(t.field,a),a.upload.then(function(n,o){t.$emit("upload-complete",n),e(function(){if(a.result=n.data,i.$$element)var e=i.$$element.find('input[type="hidden"]');else var e=i.find('input[type="hidden"]');a.newName=n.data.result.files.file[0].name,e.controller("ngModel").$setViewValue(a.newName)})},function(e){e.status>0&&(t.errorMsg=e.status+": "+e.data),t.$emit("upload-error",e)},function(e){a.progress=Math.min(100,parseInt(100*e.loaded/e.total))}))}}}}angular.module("letsAngular").directive("fwUpload",e),e.$inject=["$timeout"]}(),function(){"use strict";function e(){return{restrict:"E",scope:{tags:"="},template:'
{{tag}} ×
',link:function(e,t){null==e.tags&&(e.tags=[]);var a=angular.element(t).find("input");e.autocomplete,e.add=function(){-1==e.tags.indexOf(e.newValue)&&e.tags.push(e.newValue),e.newValue=""},e.remove=function(t){e.tags.splice(t,1)},a.bind("keypress",function(t){13==t.keyCode&&(t.stopPropagation(),t.preventDefault(),e.$apply(e.add))})}}}angular.module("letsAngular").directive("fwTags",e),e.$inject=[]}(),function(){"use strict";angular.module("letsAngular").directive("numbersOnly",function(){return{require:"ngModel",link:function(e,t,a,i){function n(e){if(e){var t=e.replace(/[^0-9]/g,"");return t!==e&&(i.$setViewValue(t),i.$render()),t}return""}i.$parsers.push(n)}}})}(),function(){"use strict";function e(e,t,a){return{restrict:"A",priority:1,link:function(e,t){e.dataReference=$(t)},controller:["$scope","$state",function(e,i){e.initMultiSelect=!1,e.msmodel=[],e.filter={},e.msdata=[],e.setting={};var n="";e.$on("filter-init",function(t){var a=t.targetScope.data||void 0,i=$(e.dataReference).attr("data-reference")||void 0;n=i,i&&a&&(e.msmodel=angular.copy(a[i])||[])}),e.changedMultiSelect=function(t){e.msmodel.length?angular.element(".fw-multiselect-button").css("color","#555555"):angular.element(".fw-multiselect-button").css("color","#CCC")},e.onItemSelect=function(t,a){e.data[n]=e.msmodel;var i=e.msdata.find(function(e){return e.id==t.id});t.label=i.label},e.onItemDeselect=function(e){},e.removeDuplicates=function(e,t){return e.filter(function(e,a,i){return i.map(function(e){return e[t]}).indexOf(e[t])===a})},e.makeRequestAutocomplete=function(i,n,o,l){t(function(){n||(n="[blank]");var r=l?"general/":"";e.resource=a.all(e.route()),e.resource.customGET(r+"autocomplete/"+o+"/"+n+"?limit=10").then(function(a){i.options=e.removeDuplicates(a.concat(i.selectedModel),"id"),t(function(){},0)},function(){})})},e._debounce=function(e){var t=null;return function(a){t&&clearTimeout(t),t=setTimeout(function(){e(a)},200)}},e.openDropdownByButton=function(e){t(function(){$('[data-reference="'+e+'"] button').click()})},e.onInitMulti=function(t,a){var i=$(t.target);i.scope().input.searchFilter="";var n=a.customOptions.general?a.customOptions.general:a.name,o=a.customOptions.general?!0:!1;if(!i.initMultiSelect){var l=i.scope();i.initMultiSelect=!0,e.makeRequestAutocomplete(l,"[blank]",n,o),i.parent().find(".dropdown-header").append(''),l.$watch("input.searchFilter",e._debounce(function(t){e.makeRequestAutocomplete(l,t,n,o)})),l.texts.buttonDefaultText="Selecione "+a.label,l.texts.searchPlaceholder="Buscar "+a.label,l.texts.dynamicButtonTextSuffix="selecionado(s)",l.externalEvents.onItemSelect=e.onItemSelect,l.externalEvents.onSelectionChanged=e.changedMultiSelect,l.externalEvents.onItemDeselect=e.onItemDeselect}},e.mssettings={scrollableHeight:"200px",scrollable:!0,buttonDefaultText:"Tipos de imóveis",enableSearch:!0,styleActive:!0,showCheckAll:!1,showUncheckAll:!1,selectedToTop:!0,buttonClasses:"btn btn-default fw-multiselect-button"}}]}}angular.module("letsAngular").directive("fwMultiSelect",e),e.$inject=["$compile","$timeout","Restangular","$state"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input.html",replace:!0,link:{pre:function(t,o,l,r){var s=o.attr("fw-data");if(t.field&&t.field.customOptions&&"object"==typeof t.field.customOptions&&!t.field.customOptions.events&&(t.field.customOptions.events={}),t.fieldHtml=function(){return n.trustAsHtml(t.field.toString())},"data"!=s&&(t.data=t[s]),"detail_data"==s){var d=t.detail_key;t.field&&t.field.autocomplete!==!1&&(t.autocomplete=function(e,a){return t.autocompleteDetail(d,e,a)},t.autocompleteSelect=function(e,a,i){return t.autocompleteDetailSelect(d,e,a,i)}),t.field&&t.field.customOptions&&void 0!=t.field.customOptions.file&&(t.download=function(e,a){return t.downloadDetail(d,e,a,t.data)})}if(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.cep)o.find("input.main-input").blur(function(){var a=angular.element(this).scope();e.get(this.value).then(function(e){var i=a.field.customOptions.cep;a.data[i.address]=e.logradouro,a.data[i.district]=e.bairro,a.data[i.city]=e.localidade,a.data[i.state]=e.uf,t.$$phase||t.$apply()})});else if(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.multiple&&1==t.field.customOptions.multiple){a(o.contents())(t)}i(o).on("blur",":input[ng-model]",function(e){try{void 0!=angular.element(this).scope().field.customOptions.events.blur&&angular.element(this).scope().field.customOptions.events.blur.call(this,e)}catch(e){}}),t.openDate=function(e){$("input#"+e.name).click()},t.isEmpty=function(e){return Object.keys(e).length}}}}}angular.module("letsAngular").directive("fwInput",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t,a,i){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input-detail.html",replace:!0,link:{post:function(e,t,a,i){}}}}angular.module("letsAngular").directive("fwInputDetail",e),e.$inject=["viaCEP","$timeout","$compile","jQuery"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"A",link:{post:function(a,n,o,l){if(l||(l=n.controller("ngModel")),a.field&&"date"==a.field.type)n.mask("99/99/9999");else if(a.field&&void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cpf&&null!=a.field.customOptions.cpf)n.mask("999.999.999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cnpj)n.mask("99.999.999/9999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.customMask)n.mask(a.field.customOptions.customMask);else if(void 0!=a.field.customOptions&&"float"==a.field.type)void 0!=a.field.customOptions&&void 0!=a.field.customOptions.currency&&(n.mask("#.##0,00",{reverse:!0}),l.$parsers.unshift(function(e){return parseFloat(n.cleanVal(),10)/100}),l.$formatters.unshift(function(e){return n.masked(e?parseFloat(e).toFixed(2):null)}));else if(void 0!=a.field.customOptions&&void 0!==a.field.customOptions.documento){var r=function(e){return e.replace(/\D/g,"").length>=12?"00.000.000/0000-00":"000.000.000-009"},s={onKeyPress:function(e,t,a,i){a.mask(r.apply({},arguments),i)}};t(function(){n.mask(r,s)},10)}else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.telefone){var d=function(e){return 11===e.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(e,t,a,i){a.mask(d.apply({},arguments),i)}};t(function(){n.mask(d,c)},100)}else void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cep&&n.blur(function(){if(!this.value)return!1;var t=angular.element(this).scope();i(this).parent().attr("fw-data");e.get(this.value).then(function(e){var a=t.field.customOptions.cep;t.data[a.address]=e.logradouro,t.data[a.district]=e.bairro,t.data[a.city]=e.localidade,t.data[a.state]=e.uf,t.data[a.ibge]=e.ibge,t.data[a.gia]=e.gia,t.$emit("viacep complete",e)})})}}}}angular.module("letsAngular").directive("fwDynamic",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$filter"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,template:'',replace:!0,link:{pre:function(t,a,i,o){t.formatData=function(t,a){if(a.autocomplete!==!1)return t[a.name+".label"]?t[a.name+".label"].label||t[a.name+".label"]:null;if("date"==a.type)return a.customOptions.hour?moment(t[a.name]).format("DD/MM/YYYY HH:mm"):moment(t[a.name]).format("DD/MM/YYYY");if("time"==a.type)return moment(t[a.name]).format("HH:mm");if("boolean"!=a.type){if("string"==a.type&&a.customOptions.file){var i=e.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+t[a.name];return n.trustAsHtml('')}if("float"==a.type){if(a.customOptions&&a.customOptions.currency){var o=t[a.name],o=o.toFixed(2).split(".");return o[0]="R$ "+o[0].split(/(?=(?:...)*$)/).join("."),o.join(",")}return t[a.name]}if("custom"==a.type){var l=a.toString({attributes:t});return l&&l[0]&&l[0].outerHTML?n.trustAsHtml(l[0].outerHTML):""}return t[a.name]}return a.customOptions.statusFalseText&&a.customOptions.statusTrueText?t[a.name]?a.customOptions.statusTrueText:a.customOptions.statusFalseText:void 0}}}}}angular.module("letsAngular").directive("fwDetailData",e),e.$inject=["$rootScope","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,compile:function(t,i){function n(e,a){var i=t.attr(e);angular.isDefined(i)&&i!==!1||t.attr(e,a)}var o=angular.element('
');return n("type","text"),n("is-open",a+".popupOpen"),n("show-button-bar",!1),n("show-weeks",!1),n("datepicker-options","datepickerOptions"),t.addClass("form-control"),t.removeAttr("fw-date-picker"),t.after(o),o.prepend(t),function(t,a){var n={};void 0===t.data&&(t.data={}),t.field?null!=t.data[t.field.name]&&(n.initDate=new Date(t.data[t.field.name]),t.data[t.field.name]=angular.copy(n.initDate)):(t.field={customOptions:[]},i.fwDatePickerNgModelParent?(n.initDate=new Date(t.$parent[i.ngModel]),t.$parent[i.ngModel]=angular.copy(n.initDate)):(n.initDate=new Date(t[i.ngModel]),t[i.ngModel]=angular.copy(n.initDate)));var o="dd/MM/yyyy";void 0!==t.field.customOptions.monthpicker&&(n.datepickerMode="'month'",n.minMode="month",o="MM/yyyy"),a.find("input").attr("datepicker-popup",o),a.find("input").blur(function(){moment(this.value,o).isValid()||""===this.value?t.field.error=!1:t.field.error=!0}),t.datepickerOptions=n,e(a)(t)}},controller:["$scope",function(e){this.popupOpen=!1,this.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0}}],controllerAs:a}}angular.module("letsAngular").directive("fwDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,link:{post:function(t,a,i,n){$(a).find("input").controller();try{a.addClass("form-control");var o=JSON.parse(i.field),l=!0;"object"==typeof o.filter&&o.filter.range===!0&&o.filter._edit===!0&&(l=!1);var r=moment().startOf("month"),s=moment(),d=l?"{":"{date: {startDate: "+r+", endDate: "+s+" }, ",c=d+" minYear: 1901, maxYear: parseInt(moment().format('YYYY'), 10), applyButtonClasses: 'btn-primary', cancelButtonClasses: 'btn-default', showDropdowns: false, singleDatePicker:"+l+", locale: { format: 'DD/MM/YYYY', separator: ' - ', applyLabel: 'Aplicar', cancelLabel: 'Cancelar', daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'], }, }";l?a.attr("placeholder","DD/MM/YYYY"):a.attr("placeholder","DD/MM/YYYY - DD/MM/YYYY"),a.attr("options",c.toString()),a.removeAttr("new-date-picker")}catch(u){console.error(u)}a.on("show.daterangepicker",function(e,t){l||t.startDate||t.endDate||(t.setStartDate(r),t.setEndDate(s))}),e(a)(t)}},controller:["$scope",function(e){setTimeout(function(){console.log(e)},100)}],controllerAs:a}}angular.module("letsAngular").directive("newDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(e,t){"function"==typeof define&&define.amd?define(["angular"],t):t(angular)}(this,function(e){function t(e){return{restrict:"A",require:["ckeditor","ngModel"],controller:["$scope","$element","$attrs","$parse","$q",a],link:function(t,a,n,o){var l=o[0],r=o[1];l.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){l.onCKEvent(e,function(){r.$setViewValue(l.instance.getData()||"")})}),l.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){l.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){l.ready().then(function(){l.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){l.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,o){var l,r=n(a.ckeditor)(e)||{},s=t[0],d=o.defer();l=s.hasAttribute("contenteditable")&&"true"==s.getAttribute("contenteditable").toLowerCase()?this.instance=CKEDITOR.inline(s,r):this.instance=CKEDITOR.replace(s,r),this.onCKEvent=function(t,a){function n(){var e=arguments;i(function(){o.apply(null,e)})}function o(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return l.on(t,n),function(){l.removeListener(t,o)}},this.onCKEvent("instanceReady",function(){d.resolve(!0)}),this.ready=function(){return d.promise},e.$on("$destroy",function(){d.promise.then(function(){l.destroy(!1)})})}e.module("ckeditor",[]).directive("ckeditor",["$parse",t]);var i=window&&window.setImmediate?window.setImmediate:function(e){setTimeout(e,0)}}),function(){"use strict";function e(e,t,a){return{restrict:"E",replace:!1,scope:{crudChartSettings:"&",crudChartData:"&"},templateUrl:"lets/views/framework/chart.html",controller:["$scope",function(i){var n=i.crudChartSettings(),o=n.chart_settings,l=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(o.xType,o.xLabel,o.xOffset,o.yType,o.yLabel,o.yOffset,l),s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]};i.d3chartStartDate=r.min.x,i.d3chartEndDate=r.max.x,i.d3chartConfig=e.configD3chart("line",["#092e64"],s),i.d3chartData=e.configD3chartData(n.fillArea||!1,n.key,l),i.$watch("d3chartStartDate",function(t,n){r.min.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})}),i.$watch("d3chartEndDate",function(t,n){r.max.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})})}],link:function(e,t,a,i,n){e.$el=t}}}angular.module("letsAngular").directive("fwChart",e),e.$inject=["fwChartService","fwComparatorService","$rootScope"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",priority:1,link:function(e,a){var i=a.find("input"),n=function(){var e=i.val(),a=e+" ";i.controller("ngModel").$setViewValue(a),t(function(){i.controller("ngModel").$setViewValue(e)})};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)})},controller:function(){},controllerAs:a}}angular.module("letsAngular").directive("fwAutoComplete",e),e.$inject=["$compile","$timeout"]}(),function(){"use strict";function e(e,t,a,i){var n="vm";return{restrict:"A",priority:1,link:function(e,i){ -var n=e;n.tableSelected=function(e,t,a){n.tableVisibily=!1;var i=e.currentTarget.firstElementChild.firstChild.data.trim();n.data[t]=a.id,n.data[t+".labelCopy"]={id:a.id,label:i},n.data[t+".label"]=i},n.loadDataAutoCompleteTable=function(e,o){var l=i.find(":input").val().split(" "),r="/^("+l[0]+")";l.splice(0,1),l.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+o+'":{"regexp":"'+r+'"}}}',d=t.appSettings.API_URL+e+"?filter="+s,c=t.appSettings.API_URL+e+"/crudGET/";a.get(d).then(function(e){n.autoCompleteTableData2=[],e.data.forEach(function(e){a.get(c+e.id).then(function(e){n.autoCompleteTableData2.push(e.data)})})})}},controller:["$scope",function(e){e.autoCompleteTableFocus=function(t){e.tableVisibily=!0},e.autoCompleteTableLostFocus=function(){setTimeout(function(){e.$apply(function(){e.tableVisibily=!1})},100)},e.updateAutoCompleteTable=function(t,a){e.loadDataAutoCompleteTable(t,a)}}],controllerAs:n}}angular.module("letsAngular").directive("fwAutoCompleteTable",e),e.$inject=["$compile","$rootScope","$http","$timeout"]}(),function(){"use strict";var e={navy:"#001f3f",blue:"#0074D9",aqua:"#7FDBFF",teal:"#39CCCC",olive:"#3D9970",green:"#2ECC40",lime:"#01FF70",yellow:"#FFDC00",orange:"#FF851B",red:"#FF4136",maroon:"#85144b",fuchia:"#F012BE",purple:"#B10DC9",black:"#111111",gray:"#AAAAAA",white:"#FFFFFF"},t=function(t,a,i){return{restrict:"A",require:"ngModel",scope:{changeColor:"&",tinyTrigger:"@",colorMe:"@",ngModel:"=",setColors:"@"},link:function(n,o,l,r){var s=0,d="";if(n.setColors)n.setColors=JSON.parse(n.setColors),n.setColors.forEach(function(t){0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',s++)},this);else for(var c in e)0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',s++);var u,f,p,m,g,b='
',h='
',v='
';g=function(e){if(e.previousElementSibling)return e.previousElementSibling;for(;e=e.previousSibling;)if(1===e.nodeType)return e},m=function(e,t){for(var a=!1;void 0!==e.parent()&&a===!1;)e.parent().hasClass(t)&&(a=!0),e=e.parent();return e},void 0!==n.tinyTrigger&&"true"===n.tinyTrigger?(v=v.replace("picker-icon","picker-icon trigger"),f=t(v)(n),o.replaceWith(f),d=b+d,p=angular.element(d),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color"))}),angular.element(document.body).append(p),f.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=m(angular.element(e.target),"color-picker-wrapper"),a=t[0].getBoundingClientRect().top,n=t[0].getBoundingClientRect().height;a+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=a+n+"px",p[0].style.left=t[0].getBoundingClientRect().left+"px",e.stopPropagation()}})):"INPUT"===o[0].tagName?(d=b+d,p=angular.element(d),p.find("cp-color").on("click",function(e){var t=angular.element(e.target).attr("color");r.$setViewValue(t),void 0!==n.colorMe&&"true"===n.colorMe?o[0].style.backgroundColor=t:o.val(t)}),n.$watch("ngModel",function(e,t){var a=e;void 0!=a&&void 0!==n.colorMe&&"true"===n.colorMe&&(o[0].style.backgroundColor=a,o[0].value="")}),angular.element(document.body).append(p),o.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=e.target.getBoundingClientRect().top,a=e.target.getBoundingClientRect().height;t+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=t+a+"px",p[0].style.left=e.target.getBoundingClientRect().left+"px",e.stopPropagation()}}),f=t(v)(n),o.after(f),f.bind("click",function(e){var t=m(angular.element(e.target),"color-picker-wrapper"),a=g(t[0]),n=a.getBoundingClientRect().top,o=a.getBoundingClientRect().height;n+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=n+o+"px",p[0].style.left=a.getBoundingClientRect().left+"px",e.stopPropagation()}),t(u)(n)):(d=h+d,p=t(d)(n),o.replaceWith(p),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color")),e.stopPropagation()})),a.bind("click",function(e){var t,i=a.find("body").children();for(t=0;t';return this.$el.append(e),this.delegateEvents(),this}});else if("custom"==e.type){var o={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var l=i.Cell.extend({className:"custom-cell",formatter:o});l.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},l.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=o.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(l)}else if("address"==e.type){var r={fromRaw:function(e,t){try{return e.city+" - "+e.state}catch(a){return""}},toRaw:function(e,t){return"down"}},s=i.Cell.extend({className:"address-cell",formatter:r});n.cell=s}else if("float"==e.type)e.customOptions&&e.customOptions.currency?n.cell=i.Cell.extend({formatter:{fromRaw:function(e,t){if(e){var e=e.toFixed(2).split(".");return e[0]="R$ "+e[0].split(/(?=(?:...)*$)/).join("."),e.join(",")}}}}):n.cell=i.NumberCell.extend({decimalSeparator:",",orderSeparator:"."});else if("date"==e.type){var d="DD/MM/YYYY",c="YYYY/M/D",u=!0;void 0!==e.customOptions.monthpicker&&(d="MM/YYYY"),e.customOptions.timestamp&&(c="YYYY/M/D HH:mm:ss.SSS",u=!1),n.cell=i.Extension.MomentCell.extend({modelFormat:c,displayLang:"pt-br",displayFormat:d,displayInUTC:u})}else if(void 0!=e.customOptions["enum"]){var f=[];for(var p in e.customOptions["enum"]){var m=e.customOptions["enum"][p];f.push([m,p])}n.cell=i.SelectCell.extend({optionValues:f})}else 1==e.autocomplete&&(e.customOptions&&void 0!=e.customOptions.list?n.cell=i.Cell.extend({className:"custom-situation-cell-select",formatter:{fromRaw:function(t,a){var i="";return e.customOptions.list.forEach(function(e){e.id==t&&(i=e.label)}),i},toRaw:function(e,t){return"down"}}}):n.name=n.name+".label");a.push(n)}});var l=i.Cell.extend({className:"text-right btn-column"+(1==d.tab?" detail":""),template:function(){var e=[];if(d.tab)if(d.settings){if(d.settings.edit){var a=t('');a.attr("data-route",d.url),e.push(a)}if(d.settings["delete"]){var i=t('');i.attr("data-route",d.url),e.push(i)}}else{var i=t('');i.attr("data-route",d.url),e.push(i)}else d.settings.edit&&e.push(t('')),d.settings["delete"]&&e.push(t(''));var n=t('
');return n.append(e),n},events:{},editRow:function(e){e.preventDefault()},render:function(){var e=this.template(this.model.toJSON());return this.$el.html(e),this.$el.data("model",this.model),this.$el.find("button.btn-edit").click(function(e){e.stopPropagation();var t=angular.element(this).scope();d.tab?t.$parent.edit($(this).closest("td").data("model").attributes):t.edit($(this).closest("td").data("model").attributes)}),this.$el.find("button.btn-delete").click(function(e){e.stopPropagation();var t=window.confirm("Deseja realmente excluir esse registro?");if(t){var a=angular.element(this).scope();d.tab?a.$parent["delete"]($(this).closest("td").data("model").attributes):a["delete"]($(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-delete-detail").click(function(e){e.stopPropagation();var a=window.confirm("Deseja realmente excluir esse registro?");if(a){var i=angular.element(this).scope(),n=t(this).attr("data-route");d.tab?i.$parent.deleteDetail(n,$(this).closest("td").data("model").attributes):i.deleteDetail(n,$(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-edit-detail").click(function(e){e.stopPropagation();var t=angular.element(this).scope(),a=$.parseJSON($(this).closest(".table-container").attr("tab-config")),i=$(this).closest("td").data("model").attributes,n=$(this).attr("data-route");t.newDetail(a,t.data,i.id,n)}),this.delegateEvents(),this}});(d.settings.edit||d.settings["delete"])&&a.push({name:"actions",label:"Ações",sortable:!1,cell:l}),o.$parent.app.helpers.isScreen("xs")&&a.splice(3,1);var r=[];1==d.tab&&r.push("detail"),void 0==d.settings||d.settings.edit||r.push("cant-edit");var s=i.Row.extend({className:r.join(" ")}),c="table table-striped table-editable no-margin mb-sm";d.tableClass&&(c+=" "+d.tableClass);var u=new i.Grid({row:s,columns:a,collection:e,className:c}),f=new i.Extension.Paginator({slideScale:.25,goBackFirstOnSort:!1,collection:e,controls:{rewind:{label:'',title:"First"},back:{label:'',title:"Previous"},forward:{label:'',title:"Next"},fastForward:{label:'',title:"Last"}}});o.$el.find(".table-container").html("").append(u.render().$el).append(f.render().$el),setTimeout(function(){angular.element(f.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),o.$broadcast("refreshGRID",!0)}var d=o.crudListSettings();d.route=n.API_URL+d.url,o.route=d.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var c=a.Model.extend({}),u={model:c,url:d.route+(d.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return o.$el[0].parseRecords&&"function"==typeof o.$el[0].parseRecords?o.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return l(function(){var a=t("
    ");a.append(t("
  • ").html("Registros na página: "+e.total_entries+" / "+e.total_count)),o.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),o.$el.find(".table-container .backgrid-paginator").append(a)}),o.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};d.filterScope&&(u.queryParams={scope:d.filterScope}),d.sort&&(u.state.sortKey=d.sort.sortKey,d.sort.order&&"desc"==d.sort.order&&(u.state.order=1));var f=a.PageableCollection.extend(u),p=new f;o.pageableCRUDModel=p;var m=angular.copy(p.fetch);p.fetch=function(t,a,i){l(function(){i&&(p.state.currentPage=1);var n=o.$el.attr("grid"),l=$('div[crud-filter][grid="'+n+'"] input').scope();if(l||(l={}),a){if("main"==n&&e.location.search){var s={};if(decodeURIComponent(e.location.search).replace("?filter=","").split("&").forEach(function(e,t){var a=e.split("=");if(a[0].split("_ini").length>1){var i=a[0].replace(/_ini$/,"");s[i]||(s[i]={}),s[i].ini=decodeURIComponent(a[1])}else if(a[0].split("_fim").length>1){var i=a[0].replace(/_fim$/,"");s[i]||(s[i]={}),s[i].fim=decodeURIComponent(a[1])}else{try{a[1]=JSON.parse(a[1])}catch(n){a[1]=a[1]}"object"==typeof a[1]?s[a[0]]=a[1]:s[a[0]]=decodeURIComponent(a[1])}}),s.p&&(l.data.p=s.p,p.state.currentPage=parseInt(s.p)),s.q)l.data.q=s.q;else{l=l||{};var c=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)l.data[e.replace("_label","")+".label"]={id:s[e.replace("_label","")],label:s[e]};else{var t=d.fields.find(function(t){return t.name==e});if("object"==typeof s[e])for(var a in s[e])"ini"==a||"fim"==a?(l.data[e+"_"+a]=t&&"date"==t.type?moment(s[e][a],"DD/MM/YYYY").toDate():s[e][a],"ini"==a&&(l.data[e]=l.data[e]?l.data[e]:{},t&&"date"==t.type&&(l.data[e].startDate=moment(s[e][a],"DD/MM/YYYY").toDate())),"fim"==a&&(l.data[e]=l.data[e]?l.data[e]:{},t&&"date"==t.type&&(l.data[e].endDate=moment(s[e][a],"DD/MM/YYYY").toDate()))):s[e][a].id&&s[e][a].label?l.data[e]=s[e]:(l.data[e]=l.data[e]||{},l.data[e][a]=s[e][a]);else l.data[e]=s[e]}"p"!=e&&(c=!0)}),l.data.showBusca=c}l.filterData(!1)}}else if("main"==n){var u=[];if(l.objFilter&&l.objFilter.data.q&&u.push("q="+l.objFilter.data.q),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0)for(var f in l.objFilter.data.filter)if("object"==typeof l.objFilter.data.filter[f]){if(l.objFilter.data.filter[f].ini&&u.push(f+"_ini="+l.objFilter.data.filter[f].ini),l.objFilter.data.filter[f].fim&&u.push(f+"_fim="+l.objFilter.data.filter[f].fim),!l.objFilter.data.filter[f].ini&&!l.objFilter.data.filter[f].fim){var g=l.objFilter.data.filter[f];u.push(f+"="+JSON.stringify(g))}}else"p"!=f&&u.push(f+"="+l.objFilter.data.filter[f]);p.state&&p.state.currentPage&&1!=p.state.currentPage&&u.push("p="+p.state.currentPage);var b=u.join("&");r.transitionTo(r.$current.name,{filter:b},{location:!0,inherit:!0,relative:r.$current,notify:!1})}l&&l.objFilter&&l.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=l.objFilter.data.q,l.objFilter.data.p&&a&&(t.data.page=l.objFilter.data.p,p.state.currentPage=parseInt(l.objFilter.data.p))),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=l.objFilter.data.filter,l.objFilter.data.filter.p&&a&&(t.data.page=l.objFilter.data.filter.p,p.state.currentPage=parseInt(l.objFilter.data.filter.p))),m.call(p,t)})},s(p)}o.$el=s;var u=o.$parent.$watch("headers",function(e,t){if(null!=e){var a=o.crudListSettings();if(1==a.tab)var i=o.$parent.$watch("data",function(e,t){void 0!=e.id&&(c(),i(),u())});else c(),u()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a){return{replace:!1,link:function(i,n){for(var o in i.headers.fields){var l=i.headers.fields[o];l.customOptions&&l.customOptions.file&&(i.dzOptions={url:a.API_URL+"upload/"+l.customOptions.file.container+"/upload",acceptedFiles:l.customOptions.file.acceptedFiles,maxFilesize:"25",maxFiles:"1",uploadMultiple:!1,addRemoveLinks:!0})}i.dzMethods={},i.removeNewFile=function(){i.dzMethods.removeFile(i.newFile)},e(n).on("click",".button-new",function(){var t=e(this).attr("detail"),a=e(this).attr("origin"),n="true"==e(this).attr("form-modal");i.newDetailData(a,t,n)}),t(function(){n.find(".tab-group .nav-tabs li:first").find("a").click(),n.find(':input[type!="hidden"]:first').focus()},500),$(n).parsley({priorityEnabled:!1,errorsContainer:function(e){return e.$element.closest(".input-container")}})}}}angular.module("letsAngular").directive("crudForm",e),e.$inject=["jQuery","$timeout","appSettings"]}(),function(){"use strict";function e(e,t,a,i){return{templateUrl:"lets/views/crud/crud-filter.html",replace:!0,scope:{fields:"&",route:"&",search:"&",clearButton:"=clearButton"},controller:["$scope",function(e){}],link:function(n,o){n.data={},n.showBuscaAvancada=!1;var l;n.fieldsFilter=[],n.startFilters=function(){l=angular.copy(n.fields()),n.fieldsFilter=[],l=l.filter(function(e){return e.filter}),l.forEach(function(e,t){if(e.filter){if(e.disabled=!1,e.notnull=!1,e.name=e.name,void 0!=e.customOptions&&e.customOptions.file&&delete e.customOptions.file,e.customOptions.multiselect&&(e.type="multiselect",e.autocomplete=!1),"text"==e.type)e.type="string";else if("boolean"==e.type)e.type="number",e.autocomplete=!0,e.customOptions={list:[{id:"false",label:e.customOptions.statusFalseText},{id:"true",label:e.customOptions.statusTrueText}],select:!0};else if("olddate"==e.type){if("object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}}else if("date"==e.type){if(e.filter._edit=!0,"object"==typeof e.filter&&e.filter.range===!0)return void n.fieldsFilter.push(e)}else if(("number"==e.type||"integer"==e.type||"float"==e.type||"bigint"==e.type)&&"object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}n.fieldsFilter.push(e)}}),n.fieldsFilter=n.fieldsFilter.sort(function(e,t){var a=e.filter.sequence||0,i=t.filter.sequence||0;return a-i}),setTimeout(function(){n.$emit("filter-init",n),n.$broadcast("filter-init",n)},500)},n.autocomplete=function(a,i){n.$emit("before-filter-autocomplete",n),n.resource=t.all(n.route());var o=[],l=e.defer();if(a.autocomplete_dependencies.length>0){var r=a.autocomplete_dependencies;for(var s in r){var d=r[s];if(void 0==n.data[d.field]||null==n.data[d.field]||"null"==n.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),l.resolve(u),l.promise}o[d.field]=n.data[d.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)n.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){l.resolve(e)},function(){return l.reject()});else if(void 0==a.customOptions.list){var f="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,n.resource.customGET(f,o).then(function(e){e.unshift({id:"null",label:"[Em Branco]"}),e.unshift({id:null,label:"--- Selecione ---"}),l.resolve(e)},function(){return l.reject()})}else{var p=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||p.unshift({id:"null",label:"[Em Branco]"}),a.customOptions.required||p.unshift({id:null,label:"--- Selecione ---"})),l.resolve(p)}return l.promise},n.autocompleteSelect=function(e,t,i){n.$emit("after-filter-autocomplete",{scope:n,name:this.field.name,value:e});var o=this.data;if(void 0==o&&(o={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)o[this.field.name]=e.id;else{if(null!=e.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}this.data=o;var l=this.field;a(function(){jQuery("#"+l.name).trigger("keyup")})},n.filterData=function(e){n.objFilter=void 0;var t={};n.data.showBuscaAvancada&&(n.showBuscaAvancada=angular.copy(n.data.showBuscaAvancada),delete n.data.showBuscaAvancada),n.showBuscaAvancada||n.data.showBusca?(l.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};n.data[e.name]&&("date"==e.type?(i.ini=n.data[e.name].startDate,i.fim=n.data[e.name].endDate,i.ini=n.getDateFormated(i.ini),i.fim=n.getDateFormated(i.fim),Object.keys(i).length>0&&(delete t[e.name],t[e.name]=i)):"olddate"==e.type&&(n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i))),n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)}else n.data[e.name]&&(t[e.name]=n.data[e.name],e.customOptions&&e.customOptions.telefone?t[e.name]=n.data[e.name].replace(/\D/g,""):"olddate"==e.type?t[e.name]=n.getDateFormated(t[e.name]):"date"==e.type&&e.filter&&1!=e.filter.range?t[e.name]=n.getDateFormated(t[e.name]):e.autocomplete&&!e.customOptions.multiselect?t[e.name+"_label"]=n.data[e.name+".label"].label:e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=n.data[e.name]))}),n.data.q=null,n.objFilter={data:{filter:t}}):(t.q=n.data.q,t.p=n.data.p,n.objFilter={data:t}),e&&i.$broadcast("refreshGRID",!1,!0)},n.openBuscaAvancada=function(){n.showBuscaAvancada=!n.showBuscaAvancada},n.clearBusca=function(){Object.keys(n.data).forEach(function(e){n.data[e]=null}),n.filterData(!0)},n.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},n.startFilters(),n.$on("refresh-fields",function(e,t){n.startFilters()}),"fixed"==n.search()&&(n.showBuscaAvancada=!0,n.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope"]}(),function(){"use strict";function e(){return{restrict:"E",templateUrl:"lets/views/framework/breadcrumb.html",replace:!0,link:function(e,t){}}}angular.module("letsAngular").directive("crudBreadcrumb",e),e.$inject=[]}(),function(){"use strict";function e(e){this.$get=e.$get,this.state=e.state,this.setCRUDRoutes=function(e){var t={main:{enable:!0,templateUrl:"lets/views/crud/crud.html",controller:"CRUDController"},list:{enable:!0,templateUrl:"lets/views/crud/crud-list.html",controller:"CRUDController"},edit:{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"},"new":{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"}},a=angular.merge(t,e.options);a.main.enable&&this.state("app."+e.route,{"abstract":!0,url:"/"+e.route,templateUrl:a.main.templateUrl,controller:a.main.controller,resolve:{id:["$stateParams",function(e){return e.id}],module:function(){return e.modelName}}}),a.list.enable&&this.state("app."+e.route+".list",{url:"?filter",templateUrl:a.list.templateUrl,controller:a.list.controller}),a["new"].enable&&this.state("app."+e.route+".new",{url:"/new?filter",templateUrl:a["new"].templateUrl,controller:a["new"].controller}),a.edit.enable&&this.state("app."+e.route+".edit",{url:"/:id/edit?filter",templateUrl:a.edit.templateUrl,controller:a.edit.controller})}}e.$inject=["$stateProvider"],angular.module("letsAngular").provider("fwState",e)}(),function(){"use strict";function e(){this.$get=["$templateRequest",function(e){return new t(e)}]}function t(e){var t=this;return t.getCrudBaseTemplate=function(){return e("lets/views/crud/crud.html")},t.getCrudListTemplate=function(){return e("lets/views/crud/crud-list.html")},t.getCrudEditTemplate=function(){return e("lets/views/crud/crud-edit.html")},{getCrudBaseTemplate:t.getCrudBaseTemplate,getCrudListTemplate:t.getCrudListTemplate,getCrudEditTemplate:t.getCrudEditTemplate}}angular.module("letsAngular").provider("fwFileLoad",e)}(),function(){"use strict";function e(e){if(null!=e){"string"==typeof e&&(e=new Date(e));var t=" meses",a=moment(e),i=moment().diff(a,"months");return i?i>12&&(t=" anos",i=moment().diff(a,"years")):(t=" dias",i=moment().diff(a,"days")),i+t}}e.$inject=["birthday"],angular.module("letsAngular").filter("fwAgeMonth",e)}(),function(){"use strict";function e(e){return e.Backgrid}angular.module("letsAngular").factory("Backgrid",e),e.$inject=["$window"]}(),function(){"use strict";function e(e){return e.Backbone}angular.module("letsAngular").factory("Backbone",e),e.$inject=["$window"]}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDController",["$scope","Restangular","module","$state","$window","$stateParams","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,o,l,r,s,d){function c(){var t=angular.copy(r.get(a));e.headers=t}e.headersReady=!1,e.export_btn_is_disable=!1,c(),e.$on("refresh-headers",function(){c()}),e.resource=t.all(e.headers.route),e.$broadcast("headers-set"),e.headersReady=!0,e.getFilter=function(){return decodeURIComponent(n.location.search).replace("?filter=","")},e.goNew=function(){i.go(i.current.name.replace(".list",".new"),{filter:e.getFilter()})},e.goToList=function(){-1==i.current.name.indexOf(".list")&&i.go(i.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.edit=function(t){i.go(i.current.name.replace(/\.list$/,".edit"),{id:t.id,page:null,filter:e.getFilter()})},e["delete"]=function(t){return e.resource.customDELETE(t.id).then(function(){l.$broadcast("refreshGRID")})},e["export"]=function(){function t(e){return e["export"]}function a(e){var t={};return t[e.name]=e.label,e.customOptions&&e.customOptions.exportColumn&&(t.exportColumn=e.customOptions.exportColumn),t}function i(e,t){if(t.length<=0)return null;if(1==t.length){if(e[0]){var a=e.map(function(e){return e[t[0]]});return a}return e[t[0]]}if(e[0]){var n=[],o=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,o)}var n=e[t[0]],o=t.slice(1),o=t.slice(1);return i(n,o)}function n(e,t,a){e[0]&&e.forEach(function(e){if(a+=Object.keys(e)[0]+"#",e.exportColumn){var i=a+e.exportColumn[0].name;t.push({antes:i.split("#"),depois:e.exportColumn[0].label})}else{var o=Object.keys(e);if(Array.isArray(e[o[0]])){var l=e[o[0]];l.forEach(function(e){n([e],t,a)})}}a=""})}function o(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var l=o(e.tabs[n]);if(l){var r={};r[n]=l,r.real_name=e.tabs[n].label,e.tabs[n].customOptions&&e.tabs[n].customOptions.exportColumn&&(r.exportColumn=e.tabs[n].customOptions.exportColumn),i.push(angular.copy(r))}}if(e.tabs_session)for(var n in e.tabs_session){var s=o(e.tabs_session[n]);if(s){var r={};r[n]=s,r.real_name=e.tabs_session[n].label,e.tabs_session[n].customOptions&&e.tabs_session[n].customOptions.exportColumn&&(r.exportColumn=e.tabs_session[n].customOptions.exportColumn),i.push(angular.copy(r))}}return i.length?i:void 0}function l(e,t){return t.reduce(function(e,t){if(e&&e[0]){var a=[];return e.forEach(function(e){e&&a.push(e[t])}),a}return e&&"undefined"!==e[t]?e[t]:void 0},e)}function r(e){var t={};e=e.split("&");for(var a=0;a',o+='",o+="
",b.push("m_"+r+i),h.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),o+=c(n,t,a)}),o}var u=e.getFilter();e.export_btn_is_disable=!0;var f=void 0!==e.totalPager?e.totalPager:$("tr").find("td").last().data("model").collection.state.totalRecords;if(f&&f>2e3)throw d.warning("Não é possível exportar mais que 2000 registros."),e.export_btn_is_disable=!1,"Não é possível exportar mais que 2000 registros.";var p=e.resource,m=o(e.headers),g='
',b=[],h=[];for(var v in m){var y=Object.keys(m[v])[0],w=Object.values(m[v])[0];"string"==typeof w?(g+="
",g+='',g+='",g+="
",b.push("m_"+y),h.push(y)):g+=c(m[v],[],[])}g+="
",s.swal({title:"Selecione as Colunas Desejadas",html:g,preConfirm:function(){var e=b.map(function(e){return document.getElementById(""+e).checked});return e},showCancelButton:!0}).then(function(t){if(t.value&&e.totalPager&&void 0!=e.totalPager){s.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){s.showLoading()}});var a=h.filter(function(e,a){return t.value[a]}),o=r(u);o=Object.assign({},o,{per_page:f}),p.customGET("pager",o).then(function(t){function o(){var o=t.data.map(function(e){var t={};return a.forEach(function(a){var n=a.split("#");if(1==n.length)t[a]=e[a];else if(n.length>1){n.reduce(function(t,a,o){return o===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),r=[];n(m,r,""),o.map(function(e){var t=r;t.forEach(function(t){var a=l(e,t.antes);"object"==typeof a&&(a=a.join(", ")),e[t.depois]=a}),t.forEach(function(t){t.antes[0]!=t.depois&&delete e[t.antes[0]]})}),s.close();var d=XLSX.utils.json_to_sheet(o),c=XLSX.utils.book_new();XLSX.utils.book_append_sheet(c,d,"dadosexportados");var u=moment().unix();XLSX.writeFile(c,"Exportacao_"+u+".xlsx"),e.export_btn_is_disable=!1}e.$emit("before export",t,o),e.$$listeners["before export"]||o()})}else void 0==e.totalPager||t.dismiss||s.swal({type:"info",title:"Ocorreu um erro",text:"Não é possível criar exportar os dados, pois não há registros."}),e.export_btn_is_disable=!1})}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","ngToast","headers","Restangular","$stateParams","$timeout","$state","$rootScope","$q","$http","Upload","$modal","data","fwStringService","auth","fwObjectService","fwErrorService",function(t,a,i,n,o,l,r,s,d,c,u,f,p,m,g,b,h,v,y){t("CRUDEditController",{$scope:a,Restangular:l,$stateParams:r,$timeout:s,$modal:m,module:e,$state:d, -$rootScope:c,$q:u,ngToast:n,$http:f,Upload:p}),a.data=g||{},a.headers=o,a.resource=l.all(o.route);for(var w in a.headers.fields){var $=a.headers.fields[w];"boolean"==$.type&&void 0==a.data[$.name]&&($.customOptions["default"]?a.data[$.name]=!0:a.data[$.name]=!1)}o.modal_id&&c.$emit("open:"+o.modal_id,a),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){this.crudForm.$valid?i.close(a.data):y.emitFormErrors(this.crudForm)},c.$on("cancel-modal",function(e,t){i.dismiss("cancel")}),s(function(){a.$broadcast("setProgressFile")})}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","Restangular","$stateParams","$timeout","$modal","module","$state","$rootScope","$q","ngToast","$http","Upload","fwModalService","$window",function(e,t,a,i,n,o,l,r,s,d,c,u,f,p){e.data={},e.dataLoaded=!1,e.module=o,e.$http=c,e.$emit("refresh-headers"),e.datepickers={},e.loading_http_request=!1,e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]},e.fetchData=function(){if(a.id)e.$parent.resource.customGET("crudGET/"+a.id).then(function(t){for(var a in e.headers.fields){var n=e.headers.fields[a];if("date"==n.type&&void 0!=t[n.name]&&null!=t[n.name]){var o=new Date(t[n.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[n.name]=o}n.customOptions&&void 0!=n.customOptions.list&&n.customOptions.list.forEach(function(e){e.id==t[n.name]&&(t[n.name+".label"]=e.label)}),"password"==n.type&&(n.notnull=!1),n.customOptions&&void 0!=n.customOptions.file&&(e.fileName=t[n.name])}e.data=t,e.dataLoaded=!0,i(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded")});else{i(function(){e.$emit("data-new")},50);for(var t in e.headers.fields){var n=e.headers.fields[t];"boolean"==n.type&&(e.data[n.name]=n.customOptions["default"]?n.customOptions["default"]:!1)}e.dataLoaded=!0,e.$emit("data-loaded")}},e.headersReady&&e.fetchData(),e.$on("headers-set",function(){e.fetchData()}),e._upload=function(e,t){var a=r.appSettings.API_URL;return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),u.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=r.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(o){}},e.getFilter=function(){return decodeURIComponent(p.location.search).replace("?filter=","")},e.submit=function(){function t(t){if(t)i.loading_http_request=!1,t.message?d.warning(t.message):d.warning("Confira seu formulário");else{i.headers.tabs&&Object.keys(i.headers.tabs).forEach(function(e){i.data[e]&&delete i.data[e]});var n;if(a.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function a(){i.loading_http_request=!1,l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})}e.$emit("after save",a,t,o),e.$$listeners["after save"]||a()},function(t){function a(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var n=[];if(i.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(o,function(e,t){var i=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=l[e].replace("%s",i);n.push(a)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}}var i=this,n={},o=i.data;if(_.each(i.headers.fields,function(e,t){o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),_.each(i.data,function(e,t){-1!==t.indexOf(".label")&&void 0===o.id&&"object"!=typeof e&&""!==e&&(n[t]="Adicione o(a) "+t.split(".")[0]+" no sistema antes de escolher nesse formulário!"),"data_nascimento"===t&&(moment(e).isAfter(moment())||moment(e).isSame(moment(),"day"))&&(n[t]="Insira uma data de nascimento válida, anterior ao dia de hoje!")}),Object.keys(n).length>0){var r=new Array;_.each(n,function(e,t){r.push(e)}),d.warning(r.join("
"))}else if(this.crudForm.$valid)i.loading_http_request=!0,e.$emit("before save",t),e.$$listeners["before save"]||t();else{var s=[],c=Object.keys(this.crudForm.$error),u=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var f in c){var p=this.crudForm.$error[c[f]];for(var m in p){var g=p[m].$options.fieldInfo.label;"required"==c[f]?s.push("O campo "+g+" é obrigatório"):"date"==c[f]&&0==u.test(p[m].$viewValue)&&s.push("O campo "+g+" está com uma data inválida")}}if(s.length>0)d.warning(s.join("
"));else{if(a.id)var b=e.data.put(),h="edit";else var b=e.$parent.resource.post(e.data),h="new";b.then(function(){void 0!=e.doAfterSave&&"function"==typeof e.doAfterSave?e.doAfterSave(resp,h):l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},function(e){function t(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var a=[];if(422==e.status)if("CANT_SAVE_MODEL"==e.data.error.code)a.push(e.data.error.message);else if(e.data.error.details){var n=e.data.error.details.codes,o={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro"};_.each(n,function(e,i){var n=t(i),l=o[e].replace("%s",n);a.push(l)})}else a.push(e.data.error.message);d.warning(a.join("
"))})}}},e.cancel=function(){l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.autocompleteModels={},e.autocompleteAdd=function(e){},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0!==t.customOptions.general)e.resource.customGET("general/autocomplete/"+t.customOptions.general+"/"+a,n).then(function(e){t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()});else if(void 0==t.customOptions.list){if(i)var f="details/"+i+"/autocomplete/"+t.name+"/"+a;else var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.doafterAutoCompleteSelect={},e._autocompleteSelect=function(t,a,n,o){var l=o?this.detail_data:this.data;if(void 0==l&&(l={}),null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)l[this.field.name]=t.id;else{if(null!=t.id)return l[this.field.name+".label"]=null,!1;l[this.field.name]=l[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,l,t,a,n),o?this.detail_data=l:this.data=l;var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)},e.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0},e.buttonClick=function(t){e[t]()},e.newDetail=function(t,a,i,n){t.fixedRoute||(t.fixedRoute=t.route);e.headers.parent_route?e.headers.parent_route:e.headers.route.toLowerCase();t.route=i?n:e.headers.route+t.fixedRoute,t.id=i?i:null,f.createCRUDModal(t,null,"CRUDEditDetailController")},e.deleteDetail=function(e,a){var i=t.all(e);i.customDELETE(a.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){d.warning(e.data.error.message)})},e.newDetailData=function(t,a,i){if(e.data[a]=e.data[a]||[],i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,f.createCRUDModal(n).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var o={},l=e.headers[t][a].fields;for(var r in l)"boolean"!=l[r].type?o[l[r].name]=null:o[l[r].name]=!1;o["new"]=!0,e.data[a].push(o),e.$apply()}},e.editDetailData=function(t,a,i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,f.createCRUDModal(n,i).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm("Deseja realmente excluir esse item?")&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","Restangular","$http","$stateParams","$timeout","headers","$rootScope","$modalInstance","$q","ngToast","Upload",function(e,t,a,i,n,o,l,r,s,d,c){e.data={},e.headers=o,e.resource=t.all(o.route),e.autocompleteModels={},e.doafterAutoCompleteSelect={},e.$http=a,o.modal_id&&l.$emit("open:"+o.modal_id,e),e.datepickers={},e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]};for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=!1)}if(o.id)e.resource.customGET(o.id).then(function(t){for(var a in e.headers.fields){var i=e.headers.fields[a];if("date"==i.type&&void 0!=t[i.name]&&null!=t[i.name]){var o=new Date(t[i.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[i.name]=o}i.customOptions&&void 0!=i.customOptions.list&&i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e.label)}),"password"==i.type&&(i.notnull=!1)}e.data=t,n(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded-detail")});else{n(function(){e.$emit("data-new-detail")},50);for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=f.customOptions["default"]?f.customOptions["default"]:!1)}}n(function(){e.submit=function(){function t(){if(e.data.id)var t=e.resource.customPUT(e.data,e.data.id),n="edit";else var t=e.resource.customPOST(e.data,i.id),n="new";t.then(function(t){function a(){l.$broadcast("refreshGRID"),r.dismiss("success")}e.$emit("after save",a,t,n),e.$$listeners["after save"]||a()},function(t){function i(e){for(var t in a.headers.fields){var i=a.headers.fields[t];if(i.name==e)return i.label}}var n=[];if(422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(o,function(e,t){var a=i(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var i=l[e].replace("%s",a);n.push(i)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}var a=this,n={},o=a.data;if(_.each(a.headers.fields,function(e,t){"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),Object.keys(n).length>0){var s=new Array;_.each(n,function(e,t){s.push(e)}),d.warning(s.join("
"))}else this.crudForm.$valid&&(e.$emit("before save",t),e.$$listeners["before save"]||t())},e.cancel=function(){r.dismiss("success")},e._upload=function(e,t){var a=l.appSettings.API_URL;return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),c.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=l.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=l.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=l.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=l.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(o){}},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione o "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}e.data[d.field].id?n[d.field]=e.data[d.field].id:n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0==t.customOptions.list){var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:null,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e._autocompleteSelect=function(t,a,i,o){if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)this.data[this.field.name]=t.id;else{if(null!=t.id)return this.data[this.field.name+".label"]=null,!1;this.data[this.field.name]=this.data[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,this.data,t,a,i);var l=this.field;n(function(){jQuery("#"+l.name).trigger("keyup")})},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)}},500)}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/crud/crud-detail-list.html",'
{{field.label}}{{field.label}}Ações
Nenhum dado cadastrado.
'),e.put("lets/views/crud/crud-edit.html",'
'),e.put("lets/views/crud/crud-filter.html",'
'),e.put("lets/views/crud/crud-form-input.html",'
'),e.put("lets/views/crud/crud-form.html",'
Informações Principais
Informações Principais
'),e.put("lets/views/crud/crud-list.html",'
'),e.put("lets/views/crud/crud-modal.html",'
'),e.put("lets/views/crud/crud-tab-list.html",""),e.put("lets/views/crud/crud.html",'
'),e.put("lets/views/framework/breadcrumb.html",''),e.put("lets/views/framework/chart.html",'

Relatório de {{key}}

'),e.put("lets/views/framework/input-detail.html",'
'),e.put("lets/views/framework/input.html",'
R$
  • A data informada é inválida.
  • A data informada é inválida.
  • O horário informado é inválido.
{{ f.progress + \'%\' }} {{ f.name }} {{ f.newName }}
{{ column.label }}
{{ data[column.name] }}
'); +!function(){"use strict";function e(){this.headers={};this.set=function(e,t){this.headers[e]=t},this.get=function(e){if(this.headers[e].findLabel=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a.label}},this.headers[e].get=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}},this.headers[e].tabs)for(var t in this.headers[e].tabs)this.headers[e].tabs[t].get=function(e){if(!this.fields||!this.fields.length)return null;for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}};return this.headers[e]},this.$get=function(){return this}}function t(e,t){}var a=angular.module("letsAngular",["ui.router","ngAnimate","ui.bootstrap","angular.viacep","ngCpfCnpj","ui.mask","ui.jq","ui.event","ngFileUpload","moment-filter","checklist-model","ui.toggle","ngSanitize","colorpicker-dr","ckeditor","thatisuday.dropzone","swangular","angularjs-dropdown-multiselect","daterangepicker"]);a.config(t),a.provider("headers",e),t.$inject=["$stateProvider","$httpProvider"]}(),function(){"use strict";function e(){var e=this;return e._placeholderList=["paciente"],e._placeholderAttr=["nome"],e.removeAccents=function(e){var t="ÀÁÂÃÄÅàáâãäåßÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž",a="AAAAAAaaaaaaBOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";e=e.split("");var i,n,o=e.length;for(i=0;o>i;i++)-1!=(n=t.indexOf(e[i]))&&(e[i]=a[n]);return e.join("")},e._removeSpecialChars=function(e){var t="!@#$%*()-_+=/.,:;?[{]}`~^|";e=e.split("");var a,i=e.length;for(a=0;i>a;a++)-1!=t.indexOf(e[a])&&(e[a]="");return e.join("")},e.lemmatize=function(t){return t=e.removeAccents(t),e._removeSpecialChars(t)},e.changePlaceholders=function(t,a){return e._placeholderList.forEach(function(i,n){if(a[i]){var o="["+i.toUpperCase()+"]";if(-1!==t.indexOf(o)){var l=t.split(o),r="",s=l.length;l.forEach(function(t,o){r+=t,s-1>o&&(r+=a[i][e._placeholderAttr[n]])}),t=r}}}),t},{removeAccents:e.removeAccents,lemmatize:e.lemmatize,changePlaceholders:e.changePlaceholders}}angular.module("letsAngular").service("utilsStringService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i){var n=this;return n._printHTML=function(e){var t=$("").appendTo("body")[0];t.contentWindow.printAndRemove=function(){t.contentWindow.print(),setTimeout(function(){$(t).remove()},3e3)};var a=''+e+"",i=t.contentWindow.document.open("text/html","replace");i.write(a),i.close()},n.print=function(o,l){moment.locale("pt-br");var r=angular.extend(t.$new(),l);e(o).then(function(e){var t=a($("
"+e+"
"))(r),o=function(){r.$$phase?i(o):(n._printHTML(t.html()),r.$destroy())};o()})},{print:n.print}}e.$inject=["$templateRequest","$rootScope","$compile","$timeout"],angular.module("letsAngular").service("utilsPrintService",e),e.inject=["$templateRequest","$rootScope","$compile","$timeout"]}(),function(){"use strict";function e(){var e=this;return e.convertObjSearch=function(e,t){var a={};return Object.keys(e).forEach(function(i){if(e[i])if("object"==typeof e[i]){var n={};Object.keys(e[i]).forEach(function(a){if("createdAt"!==a&&"updatedAt"!==a){var o=a;"id"!==a&&(o="label"),"label"===o&&t&&i===t.relation?n.label=e[i][t.label]:n[o]=e[i][a]}}),a[i+".label"]=n,a[i]=n.id}else-1===i.indexOf("id")&&"createdAt"!==i&&"updatedAt"!==i&&(a[i]=e[i])}),a},e.convertObjLabels=function(e){return e.forEach(function(e){Object.keys(e).forEach(function(t){if("object"==typeof e[t]){var a=t.split(".")[0];"label"===t.split(".")[1]&&(e[a]=angular.copy(e[t]),delete e[t])}})}),e},e.setInputsFromObject=function(e){Object.keys(e).forEach(function(t){if(e[t]&&-1===t.indexOf("hashKey")&&"id"!==t&&"createdAt"!==t&&"updatedAt"!==t){var a=angular.element("#"+t).scope();void 0===a&&-1!==t.indexOf("label")&&(a=angular.element("#"+t.split(".")[0]).scope()),a&&(a.field.autocomplete?"object"==typeof e[t]&&(e[t].label||(e[t].label=e[t].nome),a.$parent.data[t]=e[t].label,a.$parent.data[t+".label"]=e[t]):a.$parent.data[t]=e[t])}})},{convertObjSearch:e.convertObjSearch,convertObjLabels:e.convertObjLabels,setInputsFromObject:e.setInputsFromObject}}angular.module("letsAngular").service("utilsObjectService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e.getDiffDuration=function(e,t,a){moment.isMoment(e)||(e=moment(e)),moment.isMoment(t)||(t=moment(t));var i=moment.duration(e.diff(t));switch(a){case"day":return i.asDays();case"hour":return i.asHours();case"minute":return i.asMinutes();case"second":return i.asSeconds();case"week":return i.asWeeks();case"month":return i.asMonths();case"year":return i.asYears();default:return i.asMilliseconds()}},{getDiffDuration:e.getDiffDuration}}angular.module("letsAngular").service("utilsDateTimeService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e._getFilledFilterAttr=function(e,t){var a={radios:[],checkboxes:[]};return Object.keys(e).forEach(function(t){null!==e[t]&&a.radios.push(t)}),Object.keys(t).forEach(function(e){t[e].length>0&&a.checkboxes.push(e)}),a},e._findCheckAttr=function(e,t){var a=null;return Object.keys(t).forEach(function(i){i===e&&(a=t[i])}),a},e.filterList=function(t,a,i,n,o,l){var r=t.slice(0),s=Object.keys(l).length,d=e._getFilledFilterAttr(a,n),c="neutral";d.checkboxes.forEach(function(e){n[e].length>o[e].length?c="add":n[e].lengtha[t]?1:0}):e},e.getMinMaxValues=function(e,t,a,i,n,o,l){var r={x:l[0][t],y:l[0][n]},s={x:l[0][t],y:l[0][n]};return l.forEach(function(e){e[t]s.x&&(s.x=e[t]),e[n]s.y&&(s.y=e[n])}),"date"===e?(r.x=new Date(moment(r.x).subtract(a,"day").format("MM/DD/YYYY")),s.x=new Date(moment(s.x).add(a,"day").format("MM/DD/YYYY"))):(r.x-=a,s.x+=a),"date"===i?(r.y=new Date(moment(r.y).subtract(o,"day").format("MM/DD/YYYY")),s.y=new Date(moment(s.y).add(o,"day").format("MM/DD/YYYY"))):(r.y-=o,s.y+=o),{min:r,max:s}},{filterList:e.filterList,orderList:e.orderList,getMinMaxValues:e.getMinMaxValues}}angular.module("letsAngular").service("utilsComparatorService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a){var i=this;return i._createModal=function(t){return e.open(t).result},i.createCRUDModal=function(e,a,n,o){return i._createModal({animation:!0,templateUrl:o||"lets/views/crud/crud-modal.html",controller:n||"CRUDFormModalController",resolve:{headers:function(){return e},data:function(){try{var e=angular.copy(a)}catch(i){var e=t.extend({},a)}return e}},size:"lg",backdrop:"static",keyboard:!1})},i.hide=function(){a.$emit("cancel-modal")},{createModal:i._createModal,createCRUDModal:i.createCRUDModal,hide:i.hide}}e.$inject=["$modal","jQuery","$rootScope"],angular.module("letsAngular").service("fwModalService",e),e.inject=["$modal","jQuery","$rootScope"]}(),function(){"use strict";function e(e){var t=this;return t.emitFormErrors=function(t){var a=[],i=Object.keys(t.$error),n=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var o in i){var l=t.$error[i[o]];for(var r in l){var s=l[r].$options.fieldInfo.label;"required"==i[o]?a.push("O campo "+s+" é obrigatório"):"date"==i[o]&&0==n.test(l[r].$viewValue)&&a.push("O campo "+s+" está com uma data inválida")}}a.length>0&&e.warning(a.join("
"))},{emitFormErrors:t.emitFormErrors}}e.$inject=["ngToast"],angular.module("letsAngular").service("fwErrorService",e),e.inject=["ngToast"]}(),function(){"use strict";function e(){var e=this;return e.configD3chart=function(e,t,a){var i=null,n={left:40,bottom:28,right:28,top:28};return a||(a={x:[],y:[0,150]}),i="multibar"===e?nv.models.multiBarChart().margin(n).color(t).yDomain(a.y):nv.models.lineChart().margin(n).color(t).xDomain(a.x).yDomain(a.y),i.xAxis.showMaxMin(!1).tickFormat(function(e){return d3.time.format("%d/%m/%y")(new Date(e))}),i.xScale(d3.time.scale()),i.yAxis.showMaxMin(!1).tickFormat(d3.format(",f")),i.tooltip.enabled(!1),i},e.configD3chartData=function(e,t,a){var i=[];return a.forEach(function(e){var t={x:new Date(moment(e.data).format("MM/DD/YYYY")),y:e.valor};i.push(t)}),[{area:e,key:t,values:i}]},e.getMockD3chartsData=function(e){return e||(e=!1),{glicemiaCapilar:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:77},{x:new Date("06/17/2017").getTime(),y:70},{x:new Date("07/01/2017").getTime(),y:121},{x:new Date("07/08/2017").getTime(),y:84},{x:new Date("07/15/2017").getTime(),y:75},{x:new Date("07/22/2017").getTime(),y:80},{x:new Date("07/29/2017").getTime(),y:76},{x:new Date("08/05/2017").getTime(),y:120},{x:new Date("08/12/2017").getTime(),y:77},{x:new Date("08/19/2017").getTime(),y:85}]}],pressao:[{area:e,key:"Sistólica",values:[{x:new Date("06/10/2017").getTime(),y:125},{x:new Date("06/17/2017").getTime(),y:139},{x:new Date("07/01/2017").getTime(),y:129},{x:new Date("07/08/2017").getTime(),y:133},{x:new Date("07/15/2017").getTime(),y:134},{x:new Date("07/22/2017").getTime(),y:133},{x:new Date("07/29/2017").getTime(),y:143},{x:new Date("08/05/2017").getTime(),y:148},{x:new Date("08/12/2017").getTime(),y:139},{x:new Date("08/19/2017").getTime(),y:134}]},{area:e,key:"Diastólica",values:[{x:new Date("06/10/2017").getTime(),y:78},{x:new Date("06/17/2017").getTime(),y:75},{x:new Date("07/01/2017").getTime(),y:83},{x:new Date("07/08/2017").getTime(),y:80},{x:new Date("07/15/2017").getTime(),y:77},{x:new Date("07/22/2017").getTime(),y:79},{x:new Date("07/29/2017").getTime(),y:83},{x:new Date("08/05/2017").getTime(),y:81},{x:new Date("08/12/2017").getTime(),y:74},{x:new Date("08/19/2017").getTime(),y:81}]}],peso:[{area:e,key:"Quilos",values:[{x:new Date("06/10/2017").getTime(),y:89},{x:new Date("06/17/2017").getTime(),y:90},{x:new Date("07/01/2017").getTime(),y:89},{x:new Date("07/08/2017").getTime(),y:92},{x:new Date("07/15/2017").getTime(),y:93},{x:new Date("07/22/2017").getTime(),y:94},{x:new Date("07/29/2017").getTime(),y:93},{x:new Date("08/05/2017").getTime(),y:93},{x:new Date("08/12/2017").getTime(),y:93},{x:new Date("08/19/2017").getTime(),y:92}]}],altura:[{area:e,key:"Metros",values:[{x:new Date("06/10/2017").getTime(),y:1.76},{x:new Date("06/17/2017").getTime(),y:1.76},{x:new Date("07/01/2017").getTime(),y:1.76},{x:new Date("07/08/2017").getTime(),y:1.76},{x:new Date("07/15/2017").getTime(),y:1.76},{x:new Date("07/22/2017").getTime(),y:1.76},{x:new Date("07/29/2017").getTime(),y:1.76},{x:new Date("08/05/2017").getTime(),y:1.76},{x:new Date("08/12/2017").getTime(),y:1.76},{x:new Date("08/19/2017").getTime(),y:1.76}]}],imc:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:15.3},{x:new Date("06/17/2017").getTime(),y:15.5},{x:new Date("07/01/2017").getTime(),y:15.3},{x:new Date("07/08/2017").getTime(),y:15.8},{x:new Date("07/15/2017").getTime(),y:16},{x:new Date("07/22/2017").getTime(),y:16.2},{x:new Date("07/29/2017").getTime(),y:16},{x:new Date("08/05/2017").getTime(),y:16},{x:new Date("08/12/2017").getTime(),y:16},{x:new Date("08/19/2017").getTime(),y:15.8}]}],hdlLdl:[{area:e,key:"HDL",values:[{x:new Date("06/10/2017").getTime(),y:43},{x:new Date("06/17/2017").getTime(),y:41},{x:new Date("07/01/2017").getTime(),y:42},{x:new Date("07/08/2017").getTime(),y:45},{x:new Date("07/15/2017").getTime(),y:46},{x:new Date("07/22/2017").getTime(),y:48},{x:new Date("07/29/2017").getTime(),y:44},{x:new Date("08/05/2017").getTime(),y:41},{x:new Date("08/12/2017").getTime(),y:42},{x:new Date("08/19/2017").getTime(),y:40}]},{area:e,key:"LDL",values:[{x:new Date("06/10/2017").getTime(),y:121},{x:new Date("06/17/2017").getTime(),y:130},{x:new Date("07/01/2017").getTime(),y:137},{x:new Date("07/08/2017").getTime(),y:138},{x:new Date("07/15/2017").getTime(),y:120},{x:new Date("07/22/2017").getTime(),y:122},{x:new Date("07/29/2017").getTime(),y:123},{x:new Date("08/05/2017").getTime(),y:124},{x:new Date("08/12/2017").getTime(),y:122},{x:new Date("08/19/2017").getTime(),y:120}]}]}},e.getMockD3chartsConfig=function(){return{glicemiaCapilar:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,130]}),pressao:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,150]}),peso:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[80,100]}),altura:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[0,2]}),imc:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[12,20]}),hdlLdl:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[30,150]})}},{getMockD3chartsData:e.getMockD3chartsData,getMockD3chartsConfig:e.getMockD3chartsConfig,configD3chart:e.configD3chart,configD3chartData:e.configD3chartData}}angular.module("letsAngular").service("fwChartService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i,n,o,l,r){var s=o.API_URL,d=this;d.updateLocalStorage=function(e,t){var a=d.getUser();a[e]=t,d.setUserInfo(a)},d.setUserLb=function(e){t.setUser(e.id,e.userId,e.user),t.rememberMe=!0,t.save()},d.setUserInfo=function(e){window.localStorage.user=angular.toJson(e)},d.getUser=function(){return window.localStorage.user?JSON.parse(window.localStorage.user):!1},d.isAuthenticated=function(){return null!=t.currentUserId},d.authenticate=function(e){return n.authenticate(e).then(function(e){var t={accessToken:e.access_token};return l.post(s+"users/facebook/token",t)}).then(function(e){var t={id:e.data.id,userId:e.data.user.id,user:e.data.user};d.setUserLb(t),d.setUserInfo(e.data.user),d.removeSatellizer(),i.go("main.search")})["catch"](function(e){})},d.logout=function(n){a.userLogout({accessToken:n}).$promise.then(function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})["catch"](function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})},d.getCurrentUserId=function(){return t.currentUserId},d.getCurrentUserToken=function(){return t.accessTokenId},d.removeSatellizer=function(){e.localStorage.getItem("satellizer_token")&&e.localStorage.removeItem("satellizer_token")}}e.$inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http","$q"],angular.module("letsAngular").service("fwAuthService",e),e.inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http"]}(),function(){"use strict";var e={navy:"#001f3f",blue:"#0074D9",aqua:"#7FDBFF",teal:"#39CCCC",olive:"#3D9970",green:"#2ECC40",lime:"#01FF70",yellow:"#FFDC00",orange:"#FF851B",red:"#FF4136",maroon:"#85144b",fuchia:"#F012BE",purple:"#B10DC9",black:"#111111",gray:"#AAAAAA",white:"#FFFFFF"},t=function(t,a,i){return{restrict:"A",require:"ngModel",scope:{changeColor:"&",tinyTrigger:"@",colorMe:"@",ngModel:"=",setColors:"@"},link:function(n,o,l,r){var s=0,d="";if(n.setColors)n.setColors=JSON.parse(n.setColors),n.setColors.forEach(function(t){0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',s++)},this);else for(var c in e)0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',s++);var u,f,p,m,g,b='
',h='
',v='
';g=function(e){if(e.previousElementSibling)return e.previousElementSibling;for(;e=e.previousSibling;)if(1===e.nodeType)return e},m=function(e,t){for(var a=!1;void 0!==e.parent()&&a===!1;)e.parent().hasClass(t)&&(a=!0),e=e.parent();return e},void 0!==n.tinyTrigger&&"true"===n.tinyTrigger?(v=v.replace("picker-icon","picker-icon trigger"),f=t(v)(n),o.replaceWith(f),d=b+d,p=angular.element(d),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color"))}),angular.element(document.body).append(p),f.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=m(angular.element(e.target),"color-picker-wrapper"),a=t[0].getBoundingClientRect().top,n=t[0].getBoundingClientRect().height;a+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=a+n+"px",p[0].style.left=t[0].getBoundingClientRect().left+"px",e.stopPropagation()}})):"INPUT"===o[0].tagName?(d=b+d,p=angular.element(d),p.find("cp-color").on("click",function(e){var t=angular.element(e.target).attr("color");r.$setViewValue(t),void 0!==n.colorMe&&"true"===n.colorMe?o[0].style.backgroundColor=t:o.val(t)}),n.$watch("ngModel",function(e,t){var a=e;void 0!=a&&void 0!==n.colorMe&&"true"===n.colorMe&&(o[0].style.backgroundColor=a,o[0].value="")}),angular.element(document.body).append(p),o.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=e.target.getBoundingClientRect().top,a=e.target.getBoundingClientRect().height;t+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=t+a+"px",p[0].style.left=e.target.getBoundingClientRect().left+"px",e.stopPropagation()}}),f=t(v)(n),o.after(f),f.bind("click",function(e){var t=m(angular.element(e.target),"color-picker-wrapper"),a=g(t[0]),n=a.getBoundingClientRect().top,o=a.getBoundingClientRect().height;n+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=n+o+"px",p[0].style.left=a.getBoundingClientRect().left+"px",e.stopPropagation()}),t(u)(n)):(d=h+d,p=t(d)(n),o.replaceWith(p),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color")),e.stopPropagation()})),a.bind("click",function(e){var t,i=a.find("body").children();for(t=0;t0&&(t.errorMsg=e.status+": "+e.data),t.$emit("upload-error",e)},function(e){a.progress=Math.min(100,parseInt(100*e.loaded/e.total))}))}}}}angular.module("letsAngular").directive("fwUpload",e),e.$inject=["$timeout"]}(),function(){"use strict";function e(){return{restrict:"E",scope:{tags:"="},template:'
{{tag}} ×
',link:function(e,t){null==e.tags&&(e.tags=[]);var a=angular.element(t).find("input");e.autocomplete,e.add=function(){-1==e.tags.indexOf(e.newValue)&&e.tags.push(e.newValue),e.newValue=""},e.remove=function(t){e.tags.splice(t,1)},a.bind("keypress",function(t){13==t.keyCode&&(t.stopPropagation(),t.preventDefault(),e.$apply(e.add))})}}}angular.module("letsAngular").directive("fwTags",e),e.$inject=[]}(),function(){"use strict";angular.module("letsAngular").directive("numbersOnly",function(){return{require:"ngModel",link:function(e,t,a,i){function n(e){if(e){var t=e.replace(/[^0-9]/g,"");return t!==e&&(i.$setViewValue(t),i.$render()),t}return""}i.$parsers.push(n)}}})}(),function(){"use strict";function e(e,t,a){return{restrict:"A",priority:1,link:function(e,t){e.dataReference=$(t)},controller:["$scope","$state",function(e,i){e.initMultiSelect=!1,e.msmodel=[],e.filter={},e.msdata=[],e.setting={};var n="";e.$on("filter-init",function(t){var a=t.targetScope.data||void 0,i=$(e.dataReference).attr("data-reference")||void 0;n=i,i&&a&&(e.msmodel=angular.copy(a[i])||[])}),e.changedMultiSelect=function(t){e.msmodel.length?angular.element(".fw-multiselect-button").css("color","#555555"):angular.element(".fw-multiselect-button").css("color","#CCC")},e.onItemSelect=function(t,a){e.data[n]=e.msmodel;var i=e.msdata.find(function(e){return e.id==t.id});t.label=i.label},e.onItemDeselect=function(e){},e.removeDuplicates=function(e,t){return e.filter(function(e,a,i){return i.map(function(e){return e[t]}).indexOf(e[t])===a})},e.makeRequestAutocomplete=function(i,n,o,l){t(function(){n||(n="[blank]");var r=l?"general/":"";e.resource=a.all(e.route()),e.resource.customGET(r+"autocomplete/"+o+"/"+n+"?limit=10").then(function(a){i.options=e.removeDuplicates(a.concat(i.selectedModel),"id"),t(function(){},0)},function(){})})},e._debounce=function(e){var t=null;return function(a){t&&clearTimeout(t),t=setTimeout(function(){e(a)},200)}},e.openDropdownByButton=function(e){t(function(){$('[data-reference="'+e+'"] button').click()})},e.onInitMulti=function(t,a){var i=$(t.target);i.scope().input.searchFilter="";var n=a.customOptions.general?a.customOptions.general:a.name,o=a.customOptions.general?!0:!1;if(!i.initMultiSelect){var l=i.scope();i.initMultiSelect=!0,e.makeRequestAutocomplete(l,"[blank]",n,o),i.parent().find(".dropdown-header").append(''),l.$watch("input.searchFilter",e._debounce(function(t){e.makeRequestAutocomplete(l,t,n,o)})),l.texts.buttonDefaultText="Selecione "+a.label,l.texts.searchPlaceholder="Buscar "+a.label,l.texts.dynamicButtonTextSuffix="selecionado(s)",l.externalEvents.onItemSelect=e.onItemSelect,l.externalEvents.onSelectionChanged=e.changedMultiSelect,l.externalEvents.onItemDeselect=e.onItemDeselect}},e.mssettings={scrollableHeight:"200px",scrollable:!0,buttonDefaultText:"Tipos de imóveis",enableSearch:!0,styleActive:!0,showCheckAll:!1,showUncheckAll:!1,selectedToTop:!0,buttonClasses:"btn btn-default fw-multiselect-button"}}]}}angular.module("letsAngular").directive("fwMultiSelect",e),e.$inject=["$compile","$timeout","Restangular","$state"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input.html",replace:!0,link:{pre:function(t,o,l,r){var s=o.attr("fw-data");if(t.field&&t.field.customOptions&&"object"==typeof t.field.customOptions&&!t.field.customOptions.events&&(t.field.customOptions.events={}),t.fieldHtml=function(){return n.trustAsHtml(t.field.toString())},"data"!=s&&(t.data=t[s]),"detail_data"==s){var d=t.detail_key;t.field&&t.field.autocomplete!==!1&&(t.autocomplete=function(e,a){return t.autocompleteDetail(d,e,a)},t.autocompleteSelect=function(e,a,i){return t.autocompleteDetailSelect(d,e,a,i)}),t.field&&t.field.customOptions&&void 0!=t.field.customOptions.file&&(t.download=function(e,a){return t.downloadDetail(d,e,a,t.data)})}if(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.cep)o.find("input.main-input").blur(function(){var a=angular.element(this).scope();e.get(this.value).then(function(e){var i=a.field.customOptions.cep;a.data[i.address]=e.logradouro,a.data[i.district]=e.bairro,a.data[i.city]=e.localidade,a.data[i.state]=e.uf,t.$$phase||t.$apply()})});else if(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.multiple&&1==t.field.customOptions.multiple){a(o.contents())(t)}i(o).on("blur",":input[ng-model]",function(e){try{void 0!=angular.element(this).scope().field.customOptions.events.blur&&angular.element(this).scope().field.customOptions.events.blur.call(this,e)}catch(e){}}),t.openDate=function(e){$("input#"+e.name).click()},t.isEmpty=function(e){return Object.keys(e).length}}}}}angular.module("letsAngular").directive("fwInput",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t,a,i){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input-detail.html",replace:!0,link:{post:function(e,t,a,i){}}}}angular.module("letsAngular").directive("fwInputDetail",e),e.$inject=["viaCEP","$timeout","$compile","jQuery"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"A",link:{post:function(a,n,o,l){if(l||(l=n.controller("ngModel")),a.field&&"date"==a.field.type)n.mask("99/99/9999");else if(a.field&&void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cpf&&null!=a.field.customOptions.cpf)n.mask("999.999.999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cnpj)n.mask("99.999.999/9999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.customMask)n.mask(a.field.customOptions.customMask);else if(void 0!=a.field.customOptions&&"float"==a.field.type)void 0!=a.field.customOptions&&void 0!=a.field.customOptions.currency&&(n.mask("#.##0,00",{reverse:!0}),l.$parsers.unshift(function(e){return parseFloat(n.cleanVal(),10)/100}),l.$formatters.unshift(function(e){return n.masked(e?parseFloat(e).toFixed(2):null)}));else if(void 0!=a.field.customOptions&&void 0!==a.field.customOptions.documento){var r=function(e){return e.replace(/\D/g,"").length>=12?"00.000.000/0000-00":"000.000.000-009"},s={onKeyPress:function(e,t,a,i){a.mask(r.apply({},arguments),i)}};t(function(){n.mask(r,s)},10)}else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.telefone){var d=function(e){return 11===e.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(e,t,a,i){a.mask(d.apply({},arguments),i)}};t(function(){n.mask(d,c)},100)}else void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cep&&n.blur(function(){if(!this.value)return!1;var t=angular.element(this).scope();i(this).parent().attr("fw-data");e.get(this.value).then(function(e){var a=t.field.customOptions.cep;t.data[a.address]=e.logradouro,t.data[a.district]=e.bairro,t.data[a.city]=e.localidade,t.data[a.state]=e.uf,t.data[a.ibge]=e.ibge,t.data[a.gia]=e.gia,t.$emit("viacep complete",e)})})}}}}angular.module("letsAngular").directive("fwDynamic",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$filter"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,template:'',replace:!0,link:{pre:function(t,a,i,o){t.formatData=function(t,a){if(a.autocomplete!==!1)return t[a.name+".label"]?t[a.name+".label"].label||t[a.name+".label"]:null;if("date"==a.type)return a.customOptions.hour?moment(t[a.name]).format("DD/MM/YYYY HH:mm"):moment(t[a.name]).format("DD/MM/YYYY");if("time"==a.type)return moment(t[a.name]).format("HH:mm");if("boolean"!=a.type){if("string"==a.type&&a.customOptions.file){var i=e.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+t[a.name];return n.trustAsHtml('')}if("float"==a.type){if(a.customOptions&&a.customOptions.currency){var o=t[a.name],o=o.toFixed(2).split(".");return o[0]="R$ "+o[0].split(/(?=(?:...)*$)/).join("."),o.join(",")}return t[a.name]}if("custom"==a.type){var l=a.toString({attributes:t});return l&&l[0]&&l[0].outerHTML?n.trustAsHtml(l[0].outerHTML):""}return t[a.name]}return a.customOptions.statusFalseText&&a.customOptions.statusTrueText?t[a.name]?a.customOptions.statusTrueText:a.customOptions.statusFalseText:void 0}}}}}angular.module("letsAngular").directive("fwDetailData",e),e.$inject=["$rootScope","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,compile:function(t,i){function n(e,a){var i=t.attr(e);angular.isDefined(i)&&i!==!1||t.attr(e,a)}var o=angular.element('
');return n("type","text"),n("is-open",a+".popupOpen"),n("show-button-bar",!1),n("show-weeks",!1),n("datepicker-options","datepickerOptions"),t.addClass("form-control"),t.removeAttr("fw-date-picker"),t.after(o),o.prepend(t),function(t,a){var n={};void 0===t.data&&(t.data={}),t.field?null!=t.data[t.field.name]&&(n.initDate=new Date(t.data[t.field.name]),t.data[t.field.name]=angular.copy(n.initDate)):(t.field={customOptions:[]},i.fwDatePickerNgModelParent?(n.initDate=new Date(t.$parent[i.ngModel]),t.$parent[i.ngModel]=angular.copy(n.initDate)):(n.initDate=new Date(t[i.ngModel]),t[i.ngModel]=angular.copy(n.initDate)));var o="dd/MM/yyyy";void 0!==t.field.customOptions.monthpicker&&(n.datepickerMode="'month'",n.minMode="month",o="MM/yyyy"),a.find("input").attr("datepicker-popup",o),a.find("input").blur(function(){moment(this.value,o).isValid()||""===this.value?t.field.error=!1:t.field.error=!0}),t.datepickerOptions=n,e(a)(t)}},controller:["$scope",function(e){ +this.popupOpen=!1,this.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0}}],controllerAs:a}}angular.module("letsAngular").directive("fwDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,link:{post:function(t,a,i,n){$(a).find("input").controller();try{a.addClass("form-control");var o=JSON.parse(i.field),l=!0;"object"==typeof o.filter&&o.filter.range===!0&&o.filter._edit===!0&&(l=!1);var r=moment().startOf("month"),s=moment(),d=l?"{":"{date: {startDate: "+r+", endDate: "+s+" }, ",c=d+" minYear: 1901, maxYear: parseInt(moment().format('YYYY'), 10), applyButtonClasses: 'btn-primary', cancelButtonClasses: 'btn-default', showDropdowns: false, singleDatePicker:"+l+", locale: { format: 'DD/MM/YYYY', separator: ' - ', applyLabel: 'Aplicar', cancelLabel: 'Cancelar', daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'], }, }";l?a.attr("placeholder","DD/MM/YYYY"):a.attr("placeholder","DD/MM/YYYY - DD/MM/YYYY"),a.attr("options",c.toString()),a.removeAttr("new-date-picker")}catch(u){console.error(u)}a.on("show.daterangepicker",function(e,t){l||t.startDate||t.endDate||(t.setStartDate(r),t.setEndDate(s))}),e(a)(t)}},controller:["$scope",function(e){setTimeout(function(){console.log(e)},100)}],controllerAs:a}}angular.module("letsAngular").directive("newDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(e,t){"function"==typeof define&&define.amd?define(["angular"],t):t(angular)}(this,function(e){function t(e){return{restrict:"A",require:["ckeditor","ngModel"],controller:["$scope","$element","$attrs","$parse","$q",a],link:function(t,a,n,o){var l=o[0],r=o[1];l.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){l.onCKEvent(e,function(){r.$setViewValue(l.instance.getData()||"")})}),l.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){l.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){l.ready().then(function(){l.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){l.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,o){var l,r=n(a.ckeditor)(e)||{},s=t[0],d=o.defer();l=s.hasAttribute("contenteditable")&&"true"==s.getAttribute("contenteditable").toLowerCase()?this.instance=CKEDITOR.inline(s,r):this.instance=CKEDITOR.replace(s,r),this.onCKEvent=function(t,a){function n(){var e=arguments;i(function(){o.apply(null,e)})}function o(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return l.on(t,n),function(){l.removeListener(t,o)}},this.onCKEvent("instanceReady",function(){d.resolve(!0)}),this.ready=function(){return d.promise},e.$on("$destroy",function(){d.promise.then(function(){l.destroy(!1)})})}e.module("ckeditor",[]).directive("ckeditor",["$parse",t]);var i=window&&window.setImmediate?window.setImmediate:function(e){setTimeout(e,0)}}),function(){"use strict";function e(e,t,a){return{restrict:"E",replace:!1,scope:{crudChartSettings:"&",crudChartData:"&"},templateUrl:"lets/views/framework/chart.html",controller:["$scope",function(i){var n=i.crudChartSettings(),o=n.chart_settings,l=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(o.xType,o.xLabel,o.xOffset,o.yType,o.yLabel,o.yOffset,l),s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]};i.d3chartStartDate=r.min.x,i.d3chartEndDate=r.max.x,i.d3chartConfig=e.configD3chart("line",["#092e64"],s),i.d3chartData=e.configD3chartData(n.fillArea||!1,n.key,l),i.$watch("d3chartStartDate",function(t,n){r.min.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})}),i.$watch("d3chartEndDate",function(t,n){r.max.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})})}],link:function(e,t,a,i,n){e.$el=t}}}angular.module("letsAngular").directive("fwChart",e),e.$inject=["fwChartService","fwComparatorService","$rootScope"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",priority:1,link:function(e,a){var i=a.find("input"),n=function(){var e=i.val(),a=e+" ";i.controller("ngModel").$setViewValue(a),t(function(){i.controller("ngModel").$setViewValue(e)})};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)})},controller:function(){},controllerAs:a}}angular.module("letsAngular").directive("fwAutoComplete",e),e.$inject=["$compile","$timeout"]}(),function(){"use strict";function e(e,t,a,i){var n="vm";return{restrict:"A",priority:1,link:function(e,i){var n=e;n.tableSelected=function(e,t,a){n.tableVisibily=!1;var i=e.currentTarget.firstElementChild.firstChild.data.trim();n.data[t]=a.id,n.data[t+".labelCopy"]={id:a.id,label:i},n.data[t+".label"]=i},n.loadDataAutoCompleteTable=function(e,o){var l=i.find(":input").val().split(" "),r="/^("+l[0]+")";l.splice(0,1),l.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+o+'":{"regexp":"'+r+'"}}}',d=t.appSettings.API_URL+e+"?filter="+s,c=t.appSettings.API_URL+e+"/crudGET/";a.get(d).then(function(e){n.autoCompleteTableData2=[],e.data.forEach(function(e){a.get(c+e.id).then(function(e){n.autoCompleteTableData2.push(e.data)})})})}},controller:["$scope",function(e){e.autoCompleteTableFocus=function(t){e.tableVisibily=!0},e.autoCompleteTableLostFocus=function(){setTimeout(function(){e.$apply(function(){e.tableVisibily=!1})},100)},e.updateAutoCompleteTable=function(t,a){e.loadDataAutoCompleteTable(t,a)}}],controllerAs:n}}angular.module("letsAngular").directive("fwAutoCompleteTable",e),e.$inject=["$compile","$rootScope","$http","$timeout"]}(),function(){"use strict";function e(e){return{scope:{crudTabListData:"=",crudTabListSettings:"&",parentData:"="},templateUrl:"lets/views/crud/crud-tab-list.html",link:function(e,t){setTimeout(function(){var t=e.crudTabListSettings();e.data=e.parentData,e.type=t.type,e.headers=t.headers,e.app=e.$parent.app,e.crudTabListData&&(e.extraData=e.crudTabListData)},1e3)}}}angular.module("letsAngular").directive("crudTabList",e),e.$inject=["jQuery"]}(),function(){"use strict";function e(e,t,a,i,n,o,l,r){return{scope:{crudListSettings:"&",crudListDependenciesData:"&",app:"="},controller:["$scope",function(e){e.route=null,e.$on("refreshGRID",function(t,a,i){e.pageableCRUDModel.fetch(null,a,i)})}],link:function(o,s,d){function c(){function s(e){var a=[],n=function(){};n.prototype=new i.StringFormatter,_.extend(n.prototype,{fromRaw:function(e,t,a,i,n){return e}}),_.each(d.fields,function(e,t){if(e.viewable){var n={name:e.name,label:e.label,cell:"string",editable:!1,headers:e};if("boolean"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",formatter:{fromRaw:function(t,a){return t?e.customOptions.statusTrueText:e.customOptions.statusFalseText},toRaw:function(e,t){return"down"}}});else if("simplecolor"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",initialize:function(){i.Cell.prototype.initialize.apply(this,arguments)},render:function(){this.$el.empty();var e='';return this.$el.append(e),this.delegateEvents(),this}});else if("custom"==e.type){var o={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var l=i.Cell.extend({className:"custom-cell",formatter:o});l.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},l.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=o.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(l)}else if("address"==e.type){var r={fromRaw:function(e,t){try{return e.city+" - "+e.state}catch(a){return""}},toRaw:function(e,t){return"down"}},s=i.Cell.extend({className:"address-cell",formatter:r});n.cell=s}else if("float"==e.type)e.customOptions&&e.customOptions.currency?n.cell=i.Cell.extend({formatter:{fromRaw:function(e,t){if(e){var e=e.toFixed(2).split(".");return e[0]="R$ "+e[0].split(/(?=(?:...)*$)/).join("."),e.join(",")}}}}):n.cell=i.NumberCell.extend({decimalSeparator:",",orderSeparator:"."});else if("date"==e.type){var d="DD/MM/YYYY",c="YYYY/M/D",u=!0;void 0!==e.customOptions.monthpicker&&(d="MM/YYYY"),e.customOptions.timestamp&&(c="YYYY/M/D HH:mm:ss.SSS",u=!1),n.cell=i.Extension.MomentCell.extend({modelFormat:c,displayLang:"pt-br",displayFormat:d,displayInUTC:u})}else if(void 0!=e.customOptions["enum"]){var f=[];for(var p in e.customOptions["enum"]){var m=e.customOptions["enum"][p];f.push([m,p])}n.cell=i.SelectCell.extend({optionValues:f})}else 1==e.autocomplete&&(e.customOptions&&void 0!=e.customOptions.list?n.cell=i.Cell.extend({className:"custom-situation-cell-select",formatter:{fromRaw:function(t,a){var i="";return e.customOptions.list.forEach(function(e){e.id==t&&(i=e.label)}),i},toRaw:function(e,t){return"down"}}}):n.name=n.name+".label");a.push(n)}});var l=i.Cell.extend({className:"text-right btn-column"+(1==d.tab?" detail":""),template:function(){var e=[];if(d.tab)if(d.settings){if(d.settings.edit){var a=t('');a.attr("data-route",d.url),e.push(a)}if(d.settings["delete"]){var i=t('');i.attr("data-route",d.url),e.push(i)}}else{var i=t('');i.attr("data-route",d.url),e.push(i)}else d.settings.edit&&e.push(t('')),d.settings["delete"]&&e.push(t(''));var n=t('
');return n.append(e),n},events:{},editRow:function(e){e.preventDefault()},render:function(){var e=this.template(this.model.toJSON());return this.$el.html(e),this.$el.data("model",this.model),this.$el.find("button.btn-edit").click(function(e){e.stopPropagation();var t=angular.element(this).scope();d.tab?t.$parent.edit($(this).closest("td").data("model").attributes):t.edit($(this).closest("td").data("model").attributes)}),this.$el.find("button.btn-delete").click(function(e){e.stopPropagation();var t=window.confirm("Deseja realmente excluir esse registro?");if(t){var a=angular.element(this).scope();d.tab?a.$parent["delete"]($(this).closest("td").data("model").attributes):a["delete"]($(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-delete-detail").click(function(e){e.stopPropagation();var a=window.confirm("Deseja realmente excluir esse registro?");if(a){var i=angular.element(this).scope(),n=t(this).attr("data-route");d.tab?i.$parent.deleteDetail(n,$(this).closest("td").data("model").attributes):i.deleteDetail(n,$(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-edit-detail").click(function(e){e.stopPropagation();var t=angular.element(this).scope(),a=$.parseJSON($(this).closest(".table-container").attr("tab-config")),i=$(this).closest("td").data("model").attributes,n=$(this).attr("data-route");t.newDetail(a,t.data,i.id,n)}),this.delegateEvents(),this}});(d.settings.edit||d.settings["delete"])&&a.push({name:"actions",label:"Ações",sortable:!1,cell:l}),o.$parent.app.helpers.isScreen("xs")&&a.splice(3,1);var r=[];1==d.tab&&r.push("detail"),void 0==d.settings||d.settings.edit||r.push("cant-edit");var s=i.Row.extend({className:r.join(" ")}),c="table table-striped table-editable no-margin mb-sm";d.tableClass&&(c+=" "+d.tableClass);var u=new i.Grid({row:s,columns:a,collection:e,className:c}),f=new i.Extension.Paginator({slideScale:.25,goBackFirstOnSort:!1,collection:e,controls:{rewind:{label:'',title:"First"},back:{label:'',title:"Previous"},forward:{label:'',title:"Next"},fastForward:{label:'',title:"Last"}}});o.$el.find(".table-container").html("").append(u.render().$el).append(f.render().$el),setTimeout(function(){angular.element(f.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),o.$broadcast("refreshGRID",!0)}var d=o.crudListSettings();d.route=n.API_URL+d.url,o.route=d.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var c=a.Model.extend({}),u={model:c,url:d.route+(d.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return o.$el[0].parseRecords&&"function"==typeof o.$el[0].parseRecords?o.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return l(function(){var a=t("
    ");a.append(t("
  • ").html("Registros na página: "+e.total_entries+" / "+e.total_count)),o.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),o.$el.find(".table-container .backgrid-paginator").append(a)}),o.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};d.filterScope&&(u.queryParams={scope:d.filterScope}),d.sort&&(u.state.sortKey=d.sort.sortKey,d.sort.order&&"desc"==d.sort.order&&(u.state.order=1));var f=a.PageableCollection.extend(u),p=new f;o.pageableCRUDModel=p;var m=angular.copy(p.fetch);p.fetch=function(t,a,i){l(function(){i&&(p.state.currentPage=1);var n=o.$el.attr("grid"),l=$('div[crud-filter][grid="'+n+'"] input').scope();if(l||(l={}),a){if("main"==n&&e.location.search){var s={};if(decodeURIComponent(e.location.search).replace("?filter=","").split("&").forEach(function(e,t){var a=e.split("=");if(a[0].split("_ini").length>1){var i=a[0].replace(/_ini$/,"");s[i]||(s[i]={}),s[i].ini=decodeURIComponent(a[1])}else if(a[0].split("_fim").length>1){var i=a[0].replace(/_fim$/,"");s[i]||(s[i]={}),s[i].fim=decodeURIComponent(a[1])}else{try{a[1]=JSON.parse(a[1])}catch(n){a[1]=a[1]}"object"==typeof a[1]?s[a[0]]=a[1]:s[a[0]]=decodeURIComponent(a[1])}}),s.p&&(l.data.p=s.p,p.state.currentPage=parseInt(s.p)),s.q)l.data.q=s.q;else{l=l||{};var c=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)l.data[e.replace("_label","")+".label"]={id:s[e.replace("_label","")],label:s[e]};else{var t=d.fields.find(function(t){return t.name==e});if("object"==typeof s[e])for(var a in s[e])"ini"==a||"fim"==a?(l.data[e+"_"+a]=t&&"date"==t.type?moment(s[e][a],"DD/MM/YYYY").toDate():s[e][a],"ini"==a&&(l.data[e]=l.data[e]?l.data[e]:{},t&&"date"==t.type&&(l.data[e].startDate=moment(s[e][a],"DD/MM/YYYY").toDate())),"fim"==a&&(l.data[e]=l.data[e]?l.data[e]:{},t&&"date"==t.type&&(l.data[e].endDate=moment(s[e][a],"DD/MM/YYYY").toDate()))):s[e][a].id&&s[e][a].label?l.data[e]=s[e]:(l.data[e]=l.data[e]||{},l.data[e][a]=s[e][a]);else l.data[e]=s[e]}"p"!=e&&(c=!0)}),l.data.showBusca=c}l.filterData(!1)}}else if("main"==n){var u=[];if(l.objFilter&&l.objFilter.data.q&&u.push("q="+l.objFilter.data.q),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0)for(var f in l.objFilter.data.filter)if("object"==typeof l.objFilter.data.filter[f]){if(l.objFilter.data.filter[f].ini&&u.push(f+"_ini="+l.objFilter.data.filter[f].ini),l.objFilter.data.filter[f].fim&&u.push(f+"_fim="+l.objFilter.data.filter[f].fim),!l.objFilter.data.filter[f].ini&&!l.objFilter.data.filter[f].fim){var g=l.objFilter.data.filter[f];u.push(f+"="+JSON.stringify(g))}}else"p"!=f&&u.push(f+"="+l.objFilter.data.filter[f]);p.state&&p.state.currentPage&&1!=p.state.currentPage&&u.push("p="+p.state.currentPage);var b=u.join("&");r.transitionTo(r.$current.name,{filter:b},{location:!0,inherit:!0,relative:r.$current,notify:!1})}l&&l.objFilter&&l.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=l.objFilter.data.q,l.objFilter.data.p&&a&&(t.data.page=l.objFilter.data.p,p.state.currentPage=parseInt(l.objFilter.data.p))),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=l.objFilter.data.filter,l.objFilter.data.filter.p&&a&&(t.data.page=l.objFilter.data.filter.p,p.state.currentPage=parseInt(l.objFilter.data.filter.p))),m.call(p,t)})},s(p)}o.$el=s;var u=o.$parent.$watch("headers",function(e,t){if(null!=e){var a=o.crudListSettings();if(1==a.tab)var i=o.$parent.$watch("data",function(e,t){void 0!=e.id&&(c(),i(),u())});else c(),u()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a){return{replace:!1,link:function(i,n){for(var o in i.headers.fields){var l=i.headers.fields[o];l.customOptions&&l.customOptions.file&&(i.dzOptions={url:a.API_URL+"upload/"+l.customOptions.file.container+"/upload",acceptedFiles:l.customOptions.file.acceptedFiles,maxFilesize:"25",maxFiles:"1",uploadMultiple:!1,addRemoveLinks:!0})}i.dzMethods={},i.removeNewFile=function(){i.dzMethods.removeFile(i.newFile)},e(n).on("click",".button-new",function(){var t=e(this).attr("detail"),a=e(this).attr("origin"),n="true"==e(this).attr("form-modal");i.newDetailData(a,t,n)}),t(function(){n.find(".tab-group .nav-tabs li:first").find("a").click(),n.find(':input[type!="hidden"]:first').focus()},500),$(n).parsley({priorityEnabled:!1,errorsContainer:function(e){return e.$element.closest(".input-container")}})}}}angular.module("letsAngular").directive("crudForm",e),e.$inject=["jQuery","$timeout","appSettings"]}(),function(){"use strict";function e(e,t,a,i){return{templateUrl:"lets/views/crud/crud-filter.html",replace:!0,scope:{fields:"&",route:"&",search:"&",clearButton:"=clearButton"},controller:["$scope",function(e){}],link:function(n,o){n.data={},n.showBuscaAvancada=!1;var l;n.fieldsFilter=[],n.startFilters=function(){l=angular.copy(n.fields()),n.fieldsFilter=[],l=l.filter(function(e){return e.filter}),l.forEach(function(e,t){if(e.filter){if(e.disabled=!1,e.notnull=!1,e.name=e.name,void 0!=e.customOptions&&e.customOptions.file&&delete e.customOptions.file,e.customOptions.multiselect&&(e.type="multiselect",e.autocomplete=!1),"text"==e.type)e.type="string";else if("boolean"==e.type)e.type="number",e.autocomplete=!0,e.customOptions={list:[{id:"false",label:e.customOptions.statusFalseText},{id:"true",label:e.customOptions.statusTrueText}],select:!0};else if("olddate"==e.type){if("object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}}else if("date"==e.type){if(e.filter._edit=!0,"object"==typeof e.filter&&e.filter.range===!0)return void n.fieldsFilter.push(e)}else if(("number"==e.type||"integer"==e.type||"float"==e.type||"bigint"==e.type)&&"object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}n.fieldsFilter.push(e)}}),n.fieldsFilter=n.fieldsFilter.sort(function(e,t){var a=e.filter.sequence||0,i=t.filter.sequence||0;return a-i}),setTimeout(function(){n.$emit("filter-init",n),n.$broadcast("filter-init",n)},500)},n.autocomplete=function(a,i){n.$emit("before-filter-autocomplete",n),n.resource=t.all(n.route());var o=[],l=e.defer();if(a.autocomplete_dependencies.length>0){var r=a.autocomplete_dependencies;for(var s in r){var d=r[s];if(void 0==n.data[d.field]||null==n.data[d.field]||"null"==n.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),l.resolve(u),l.promise}o[d.field]=n.data[d.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)n.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){l.resolve(e)},function(){return l.reject()});else if(void 0==a.customOptions.list){var f="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,n.resource.customGET(f,o).then(function(e){e.unshift({id:"null",label:"[Em Branco]"}),e.unshift({id:null,label:"--- Selecione ---"}),l.resolve(e)},function(){return l.reject()})}else{var p=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||p.unshift({id:"null",label:"[Em Branco]"}),a.customOptions.required||p.unshift({id:null,label:"--- Selecione ---"})),l.resolve(p)}return l.promise},n.autocompleteSelect=function(e,t,i){n.$emit("after-filter-autocomplete",{scope:n,name:this.field.name,value:e});var o=this.data;if(void 0==o&&(o={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)o[this.field.name]=e.id;else{if(null!=e.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}this.data=o;var l=this.field;a(function(){jQuery("#"+l.name).trigger("keyup")})},n.filterData=function(e){n.objFilter=void 0;var t={};n.data.showBuscaAvancada&&(n.showBuscaAvancada=angular.copy(n.data.showBuscaAvancada),delete n.data.showBuscaAvancada),n.showBuscaAvancada||n.data.showBusca?(l.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};n.data[e.name]&&("date"==e.type?(i.ini=n.data[e.name].startDate,i.fim=n.data[e.name].endDate,i.ini=n.getDateFormated(i.ini),i.fim=n.getDateFormated(i.fim),Object.keys(i).length>0&&(delete t[e.name],t[e.name]=i)):"olddate"==e.type&&(n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i))),n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)}else n.data[e.name]&&(t[e.name]=n.data[e.name],e.customOptions&&e.customOptions.telefone?t[e.name]=n.data[e.name].replace(/\D/g,""):"olddate"==e.type?t[e.name]=n.getDateFormated(t[e.name]):"date"==e.type&&e.filter&&1!=e.filter.range?t[e.name]=n.getDateFormated(t[e.name]):e.autocomplete&&!e.customOptions.multiselect?t[e.name+"_label"]=n.data[e.name+".label"].label:e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=n.data[e.name]))}),n.data.q=null,n.objFilter={data:{filter:t}}):(t.q=n.data.q,t.p=n.data.p,n.objFilter={data:t}),e&&i.$broadcast("refreshGRID",!1,!0)},n.openBuscaAvancada=function(){n.showBuscaAvancada=!n.showBuscaAvancada},n.clearBusca=function(){Object.keys(n.data).forEach(function(e){n.data[e]=null}),n.filterData(!0)},n.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},n.startFilters(),n.$on("refresh-fields",function(e,t){n.startFilters()}),"fixed"==n.search()&&(n.showBuscaAvancada=!0,n.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope"]}(),function(){"use strict";function e(){return{restrict:"E",templateUrl:"lets/views/framework/breadcrumb.html",replace:!0,link:function(e,t){}}}angular.module("letsAngular").directive("crudBreadcrumb",e),e.$inject=[]}(),function(){"use strict";function e(e){this.$get=e.$get,this.state=e.state,this.setCRUDRoutes=function(e){var t={main:{enable:!0,templateUrl:"lets/views/crud/crud.html",controller:"CRUDController"},list:{enable:!0,templateUrl:"lets/views/crud/crud-list.html",controller:"CRUDController"},edit:{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"},"new":{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"}},a=angular.merge(t,e.options);a.main.enable&&this.state("app."+e.route,{"abstract":!0,url:"/"+e.route,templateUrl:a.main.templateUrl,controller:a.main.controller,resolve:{id:["$stateParams",function(e){return e.id}],module:function(){return e.modelName}}}),a.list.enable&&this.state("app."+e.route+".list",{url:"?filter",templateUrl:a.list.templateUrl,controller:a.list.controller}),a["new"].enable&&this.state("app."+e.route+".new",{url:"/new?filter",templateUrl:a["new"].templateUrl,controller:a["new"].controller}),a.edit.enable&&this.state("app."+e.route+".edit",{url:"/:id/edit?filter",templateUrl:a.edit.templateUrl,controller:a.edit.controller})}}e.$inject=["$stateProvider"],angular.module("letsAngular").provider("fwState",e)}(),function(){"use strict";function e(){this.$get=["$templateRequest",function(e){return new t(e)}]}function t(e){var t=this;return t.getCrudBaseTemplate=function(){return e("lets/views/crud/crud.html")},t.getCrudListTemplate=function(){return e("lets/views/crud/crud-list.html")},t.getCrudEditTemplate=function(){return e("lets/views/crud/crud-edit.html")},{getCrudBaseTemplate:t.getCrudBaseTemplate,getCrudListTemplate:t.getCrudListTemplate,getCrudEditTemplate:t.getCrudEditTemplate}}angular.module("letsAngular").provider("fwFileLoad",e)}(),function(){"use strict";function e(e){if(null!=e){"string"==typeof e&&(e=new Date(e));var t=" meses",a=moment(e),i=moment().diff(a,"months");return i?i>12&&(t=" anos",i=moment().diff(a,"years")):(t=" dias",i=moment().diff(a,"days")),i+t}}e.$inject=["birthday"],angular.module("letsAngular").filter("fwAgeMonth",e)}(),function(){"use strict";function e(e){return e.Backgrid}angular.module("letsAngular").factory("Backgrid",e),e.$inject=["$window"]}(),function(){"use strict";function e(e){return e.Backbone}angular.module("letsAngular").factory("Backbone",e),e.$inject=["$window"]}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDController",["$scope","Restangular","module","$state","$window","$stateParams","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,o,l,r,s,d){function c(){var t=angular.copy(r.get(a));e.headers=t}e.headersReady=!1,e.export_btn_is_disable=!1,c(),e.$on("refresh-headers",function(){c()}),e.resource=t.all(e.headers.route),e.$broadcast("headers-set"),e.headersReady=!0,e.getFilter=function(){return decodeURIComponent(n.location.search).replace("?filter=","")},e.goNew=function(){i.go(i.current.name.replace(".list",".new"),{filter:e.getFilter()})},e.goToList=function(){-1==i.current.name.indexOf(".list")&&i.go(i.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.edit=function(t){i.go(i.current.name.replace(/\.list$/,".edit"),{id:t.id,page:null,filter:e.getFilter()})},e["delete"]=function(t){return e.resource.customDELETE(t.id).then(function(){l.$broadcast("refreshGRID")})},e["export"]=function(){function t(e){return e["export"]}function a(e){var t={};return t[e.name]=e.label,e.customOptions&&e.customOptions.exportColumn&&(t.exportColumn=e.customOptions.exportColumn),t}function i(e,t){if(t.length<=0)return null;if(1==t.length){if(e[0]){var a=e.map(function(e){return e[t[0]]});return a}return e[t[0]]}if(e[0]){var n=[],o=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,o)}var n=e[t[0]],o=t.slice(1),o=t.slice(1);return i(n,o)}function n(e,t,a){e[0]&&e.forEach(function(e){if(a+=Object.keys(e)[0]+"#",e.exportColumn){var i=a+e.exportColumn[0].name;t.push({antes:i.split("#"),depois:e.exportColumn[0].label})}else{var o=Object.keys(e);if(Array.isArray(e[o[0]])){var l=e[o[0]];l.forEach(function(e){n([e],t,a)})}else{var r=a.split("#").length;r>2&&t.push({antes:[a.split("#")[0],a.split("#")[1]],depois:o[0]})}}a=""})}function o(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var l=o(e.tabs[n]);if(l){var r={};r[n]=l,r.real_name=e.tabs[n].label,e.tabs[n].customOptions&&e.tabs[n].customOptions.exportColumn&&(r.exportColumn=e.tabs[n].customOptions.exportColumn),i.push(angular.copy(r))}}if(e.tabs_session)for(var n in e.tabs_session){var s=o(e.tabs_session[n]);if(s){var r={};r[n]=s,r.real_name=e.tabs_session[n].label,e.tabs_session[n].customOptions&&e.tabs_session[n].customOptions.exportColumn&&(r.exportColumn=e.tabs_session[n].customOptions.exportColumn),i.push(angular.copy(r))}}return i.length?i:void 0}function l(e,t){return t.reduce(function(e,t){if(e&&e[0]){var a=[];return e.forEach(function(e){e&&a.push(e[t])}),a}return e&&"undefined"!==e[t]?e[t]:void 0},e)}function r(e){var t={};e=e.split("&");for(var a=0;a',o+='",o+="
",b.push("m_"+r+i),h.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),o+=c(n,t,a)}),o}var u=e.getFilter();e.export_btn_is_disable=!0;var f=void 0!==e.totalPager?e.totalPager:$("tr").find("td").last().data("model").collection.state.totalRecords;if(f&&f>2e3)throw d.warning("Não é possível exportar mais que 2000 registros."),e.export_btn_is_disable=!1,"Não é possível exportar mais que 2000 registros.";var p=e.resource,m=o(e.headers),g='
',b=[],h=[];for(var v in m){var y=Object.keys(m[v])[0],w=Object.values(m[v])[0];"string"==typeof w?(g+="
",g+='',g+='",g+="
",b.push("m_"+y),h.push(y)):g+=c(m[v],[],[])}g+="
",s.swal({title:"Selecione as Colunas Desejadas",html:g,preConfirm:function(){var e=b.map(function(e){return document.getElementById(""+e).checked});return e},showCancelButton:!0}).then(function(t){if(t.value&&e.totalPager&&void 0!=e.totalPager){s.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){s.showLoading()}});var a=h.filter(function(e,a){return t.value[a]}),o=r(u);o=Object.assign({},o,{per_page:f}),p.customGET("pager",o).then(function(t){function o(){var o=t.data.map(function(e){var t={};return a.forEach(function(a){var n=a.split("#");if(1==n.length)t[a]=e[a];else if(n.length>1){n.reduce(function(t,a,o){return o===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),r=[];n(m,r,""),o.map(function(e){var t=r;t.forEach(function(t){var a=l(e,t.antes);"object"==typeof a&&(a=a.join(", ")),e[t.depois]=a}),t.forEach(function(t){t.antes[0]!=t.depois&&delete e[t.antes[0]]})}),console.log(o),s.close();var d=XLSX.utils.json_to_sheet(o),c=XLSX.utils.book_new();XLSX.utils.book_append_sheet(c,d,"dadosexportados");var u=moment().unix();XLSX.writeFile(c,"Exportacao_"+u+".xlsx"),e.export_btn_is_disable=!1}e.$emit("before export",t,o),e.$$listeners["before export"]||o()})}else void 0==e.totalPager||t.dismiss||s.swal({type:"info",title:"Ocorreu um erro",text:"Não é possível criar exportar os dados, pois não há registros."}),e.export_btn_is_disable=!1})}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","ngToast","headers","Restangular","$stateParams","$timeout","$state","$rootScope","$q","$http","Upload","$modal","data","fwStringService","auth","fwObjectService","fwErrorService",function(t,a,i,n,o,l,r,s,d,c,u,f,p,m,g,b,h,v,y){ +t("CRUDEditController",{$scope:a,Restangular:l,$stateParams:r,$timeout:s,$modal:m,module:e,$state:d,$rootScope:c,$q:u,ngToast:n,$http:f,Upload:p}),a.data=g||{},a.headers=o,a.resource=l.all(o.route);for(var w in a.headers.fields){var $=a.headers.fields[w];"boolean"==$.type&&void 0==a.data[$.name]&&($.customOptions["default"]?a.data[$.name]=!0:a.data[$.name]=!1)}o.modal_id&&c.$emit("open:"+o.modal_id,a),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){this.crudForm.$valid?i.close(a.data):y.emitFormErrors(this.crudForm)},c.$on("cancel-modal",function(e,t){i.dismiss("cancel")}),s(function(){a.$broadcast("setProgressFile")})}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","Restangular","$stateParams","$timeout","$modal","module","$state","$rootScope","$q","ngToast","$http","Upload","fwModalService","$window",function(e,t,a,i,n,o,l,r,s,d,c,u,f,p){e.data={},e.dataLoaded=!1,e.module=o,e.$http=c,e.$emit("refresh-headers"),e.datepickers={},e.loading_http_request=!1,e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]},e.fetchData=function(){if(a.id)e.$parent.resource.customGET("crudGET/"+a.id).then(function(t){for(var a in e.headers.fields){var n=e.headers.fields[a];if("date"==n.type&&void 0!=t[n.name]&&null!=t[n.name]){var o=new Date(t[n.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[n.name]=o}n.customOptions&&void 0!=n.customOptions.list&&n.customOptions.list.forEach(function(e){e.id==t[n.name]&&(t[n.name+".label"]=e.label)}),"password"==n.type&&(n.notnull=!1),n.customOptions&&void 0!=n.customOptions.file&&(e.fileName=t[n.name])}e.data=t,e.dataLoaded=!0,i(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded")});else{i(function(){e.$emit("data-new")},50);for(var t in e.headers.fields){var n=e.headers.fields[t];"boolean"==n.type&&(e.data[n.name]=n.customOptions["default"]?n.customOptions["default"]:!1)}e.dataLoaded=!0,e.$emit("data-loaded")}},e.headersReady&&e.fetchData(),e.$on("headers-set",function(){e.fetchData()}),e._upload=function(e,t){var a=r.appSettings.API_URL;return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),u.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=r.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(o){}},e.getFilter=function(){return decodeURIComponent(p.location.search).replace("?filter=","")},e.submit=function(){function t(t){if(t)i.loading_http_request=!1,t.message?d.warning(t.message):d.warning("Confira seu formulário");else{i.headers.tabs&&Object.keys(i.headers.tabs).forEach(function(e){i.data[e]&&delete i.data[e]});var n;if(a.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function a(){i.loading_http_request=!1,l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})}e.$emit("after save",a,t,o),e.$$listeners["after save"]||a()},function(t){function a(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var n=[];if(i.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(o,function(e,t){var i=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=l[e].replace("%s",i);n.push(a)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}}var i=this,n={},o=i.data;if(_.each(i.headers.fields,function(e,t){o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),_.each(i.data,function(e,t){-1!==t.indexOf(".label")&&void 0===o.id&&"object"!=typeof e&&""!==e&&(n[t]="Adicione o(a) "+t.split(".")[0]+" no sistema antes de escolher nesse formulário!"),"data_nascimento"===t&&(moment(e).isAfter(moment())||moment(e).isSame(moment(),"day"))&&(n[t]="Insira uma data de nascimento válida, anterior ao dia de hoje!")}),Object.keys(n).length>0){var r=new Array;_.each(n,function(e,t){r.push(e)}),d.warning(r.join("
"))}else if(this.crudForm.$valid)i.loading_http_request=!0,e.$emit("before save",t),e.$$listeners["before save"]||t();else{var s=[],c=Object.keys(this.crudForm.$error),u=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var f in c){var p=this.crudForm.$error[c[f]];for(var m in p){var g=p[m].$options.fieldInfo.label;"required"==c[f]?s.push("O campo "+g+" é obrigatório"):"date"==c[f]&&0==u.test(p[m].$viewValue)&&s.push("O campo "+g+" está com uma data inválida")}}if(s.length>0)d.warning(s.join("
"));else{if(a.id)var b=e.data.put(),h="edit";else var b=e.$parent.resource.post(e.data),h="new";b.then(function(){void 0!=e.doAfterSave&&"function"==typeof e.doAfterSave?e.doAfterSave(resp,h):l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},function(e){function t(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var a=[];if(422==e.status)if("CANT_SAVE_MODEL"==e.data.error.code)a.push(e.data.error.message);else if(e.data.error.details){var n=e.data.error.details.codes,o={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro"};_.each(n,function(e,i){var n=t(i),l=o[e].replace("%s",n);a.push(l)})}else a.push(e.data.error.message);d.warning(a.join("
"))})}}},e.cancel=function(){l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.autocompleteModels={},e.autocompleteAdd=function(e){},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0!==t.customOptions.general)e.resource.customGET("general/autocomplete/"+t.customOptions.general+"/"+a,n).then(function(e){t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()});else if(void 0==t.customOptions.list){if(i)var f="details/"+i+"/autocomplete/"+t.name+"/"+a;else var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.doafterAutoCompleteSelect={},e._autocompleteSelect=function(t,a,n,o){var l=o?this.detail_data:this.data;if(void 0==l&&(l={}),null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)l[this.field.name]=t.id;else{if(null!=t.id)return l[this.field.name+".label"]=null,!1;l[this.field.name]=l[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,l,t,a,n),o?this.detail_data=l:this.data=l;var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)},e.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0},e.buttonClick=function(t){e[t]()},e.newDetail=function(t,a,i,n){t.fixedRoute||(t.fixedRoute=t.route);e.headers.parent_route?e.headers.parent_route:e.headers.route.toLowerCase();t.route=i?n:e.headers.route+t.fixedRoute,t.id=i?i:null,f.createCRUDModal(t,null,"CRUDEditDetailController")},e.deleteDetail=function(e,a){var i=t.all(e);i.customDELETE(a.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){d.warning(e.data.error.message)})},e.newDetailData=function(t,a,i){if(e.data[a]=e.data[a]||[],i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,f.createCRUDModal(n).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var o={},l=e.headers[t][a].fields;for(var r in l)"boolean"!=l[r].type?o[l[r].name]=null:o[l[r].name]=!1;o["new"]=!0,e.data[a].push(o),e.$apply()}},e.editDetailData=function(t,a,i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,f.createCRUDModal(n,i).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm("Deseja realmente excluir esse item?")&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","Restangular","$http","$stateParams","$timeout","headers","$rootScope","$modalInstance","$q","ngToast","Upload",function(e,t,a,i,n,o,l,r,s,d,c){e.data={},e.headers=o,e.resource=t.all(o.route),e.autocompleteModels={},e.doafterAutoCompleteSelect={},e.$http=a,o.modal_id&&l.$emit("open:"+o.modal_id,e),e.datepickers={},e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]};for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=!1)}if(o.id)e.resource.customGET(o.id).then(function(t){for(var a in e.headers.fields){var i=e.headers.fields[a];if("date"==i.type&&void 0!=t[i.name]&&null!=t[i.name]){var o=new Date(t[i.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[i.name]=o}i.customOptions&&void 0!=i.customOptions.list&&i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e.label)}),"password"==i.type&&(i.notnull=!1)}e.data=t,n(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded-detail")});else{n(function(){e.$emit("data-new-detail")},50);for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=f.customOptions["default"]?f.customOptions["default"]:!1)}}n(function(){e.submit=function(){function t(){if(e.data.id)var t=e.resource.customPUT(e.data,e.data.id),n="edit";else var t=e.resource.customPOST(e.data,i.id),n="new";t.then(function(t){function a(){l.$broadcast("refreshGRID"),r.dismiss("success")}e.$emit("after save",a,t,n),e.$$listeners["after save"]||a()},function(t){function i(e){for(var t in a.headers.fields){var i=a.headers.fields[t];if(i.name==e)return i.label}}var n=[];if(422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(o,function(e,t){var a=i(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var i=l[e].replace("%s",a);n.push(i)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}var a=this,n={},o=a.data;if(_.each(a.headers.fields,function(e,t){"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),Object.keys(n).length>0){var s=new Array;_.each(n,function(e,t){s.push(e)}),d.warning(s.join("
"))}else this.crudForm.$valid&&(e.$emit("before save",t),e.$$listeners["before save"]||t())},e.cancel=function(){r.dismiss("success")},e._upload=function(e,t){var a=l.appSettings.API_URL;return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),c.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=l.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=l.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=l.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=l.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(o){}},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione o "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}e.data[d.field].id?n[d.field]=e.data[d.field].id:n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0==t.customOptions.list){var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:null,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e._autocompleteSelect=function(t,a,i,o){if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)this.data[this.field.name]=t.id;else{if(null!=t.id)return this.data[this.field.name+".label"]=null,!1;this.data[this.field.name]=this.data[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,this.data,t,a,i);var l=this.field;n(function(){jQuery("#"+l.name).trigger("keyup")})},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)}},500)}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/crud/crud-detail-list.html",'
{{field.label}}{{field.label}}Ações
Nenhum dado cadastrado.
'),e.put("lets/views/crud/crud-edit.html",'
'),e.put("lets/views/crud/crud-filter.html",'
'),e.put("lets/views/crud/crud-form-input.html",'
'),e.put("lets/views/crud/crud-form.html",'
Informações Principais
Informações Principais
'),e.put("lets/views/crud/crud-list.html",'
'),e.put("lets/views/crud/crud-modal.html",'
'),e.put("lets/views/crud/crud-tab-list.html",""),e.put("lets/views/crud/crud.html",'
'),e.put("lets/views/framework/breadcrumb.html",''),e.put("lets/views/framework/chart.html",'

Relatório de {{key}}

'),e.put("lets/views/framework/input-detail.html",'
'),e.put("lets/views/framework/input.html",'
R$
  • A data informada é inválida.
  • A data informada é inválida.
  • O horário informado é inválido.
{{ f.progress + \'%\' }} {{ f.name }} {{ f.newName }}
{{ column.label }}
{{ data[column.name] }}
'); }]); \ No newline at end of file diff --git a/package.json b/package.json index 3d29e14..3bd391e 100644 --- a/package.json +++ b/package.json @@ -1,77 +1,77 @@ { - "name": "lets-angular-framework-core", - "version": "0.0.9", - "description": "Core Module for Lets Angular Framework", - "dependencies": {}, - "scripts": { - "start": "gulp watch", - "build": "gulp build", - "test": "gulp test" + "name": "lets-angular-framework-core", + "version": "0.0.9", + "description": "Core Module for Lets Angular Framework", + "dependencies": {}, + "scripts": { + "start": "gulp watch", + "build": "gulp build", + "test": "gulp test" + }, + "devDependencies": { + "del": "~2.0.2", + "gulp": "^3.9.1", + "gulp-angular-filesort": "~1.1.1", + "gulp-angular-templatecache": "~1.8.0", + "gulp-autoprefixer": "~3.0.2", + "gulp-csso": "~1.0.0", + "gulp-filter": "^3.0.1", + "gulp-flatten": "~0.0.4", + "gulp-gh-pages": "^0.5.1", + "gulp-inject": "~3.0.0", + "gulp-jshint": "~1.9.0", + "gulp-load-plugins": "~0.10.0", + "gulp-minify-html": "~1.0.4", + "gulp-ng-annotate": "~1.1.0", + "gulp-protractor": "~1.0.0", + "gulp-rename": "~1.2.2", + "gulp-replace": "~0.5.4", + "gulp-rev": "~6.0.1", + "gulp-rev-replace": "~0.4.2", + "gulp-sass": "^3.0.0", + "gulp-size": "~2.0.0", + "gulp-sourcemaps": "~1.6.0", + "gulp-uglify": "~1.4.1", + "gulp-useref": "~1.3.0", + "gulp-util": "^3.0.8", + "wrench": "~1.5.8" + }, + "engines": { + "node": ">=0.10.0" + }, + "eslintConfig": { + "extends": [ + "plugin:angular/johnpapa" + ], + "plugins": [ + "angular" + ], + "rules": { + "angular/no-service-method": 0, + "angular/file-name": 0, + "angular/controller-as-vm": 0, + "angular/document-service": 0, + "angular/controller-name": 0, + "angular/controller-as": 0, + "angular/timeout-service": 0, + "angular/window-service": 0 }, - "devDependencies": { - "del": "~2.0.2", - "gulp": "^3.9.1", - "gulp-angular-filesort": "~1.1.1", - "gulp-angular-templatecache": "~1.8.0", - "gulp-autoprefixer": "~3.0.2", - "gulp-csso": "~1.0.0", - "gulp-filter": "^3.0.1", - "gulp-flatten": "~0.0.4", - "gulp-gh-pages": "^0.5.1", - "gulp-inject": "~3.0.0", - "gulp-jshint": "~1.9.0", - "gulp-load-plugins": "~0.10.0", - "gulp-minify-html": "~1.0.4", - "gulp-ng-annotate": "~1.1.0", - "gulp-protractor": "~1.0.0", - "gulp-rename": "~1.2.2", - "gulp-replace": "~0.5.4", - "gulp-rev": "~6.0.1", - "gulp-rev-replace": "~0.4.2", - "gulp-sass": "^3.0.0", - "gulp-size": "~2.0.0", - "gulp-sourcemaps": "~1.6.0", - "gulp-uglify": "~1.4.1", - "gulp-useref": "~1.3.0", - "gulp-util": "^3.0.8", - "wrench": "~1.5.8" + "env": { + "es6": true, + "browser": true, + "jasmine": true }, - "engines": { - "node": ">=0.10.0" + "ecmaFeatures": { + "modules": true }, - "eslintConfig": { - "extends": [ - "plugin:angular/johnpapa" - ], - "plugins": [ - "angular" - ], - "rules": { - "angular/no-service-method": 0, - "angular/file-name": 0, - "angular/controller-as-vm": 0, - "angular/document-service": 0, - "angular/controller-name": 0, - "angular/controller-as": 0, - "angular/timeout-service": 0, - "angular/window-service": 0 - }, - "env": { - "es6": true, - "browser": true, - "jasmine": true - }, - "ecmaFeatures": { - "modules": true - }, - "globals": { - "angular": true, - "module": true, - "inject": true, - "jQuery": true, - "$": true, - "swal": true, - "ngDescribe": true - } + "globals": { + "angular": true, + "module": true, + "inject": true, + "jQuery": true, + "$": true, + "swal": true, + "ngDescribe": true } + } } diff --git a/src/controllers/lets-crud.controller.js b/src/controllers/lets-crud.controller.js index e0390f5..66a6806 100644 --- a/src/controllers/lets-crud.controller.js +++ b/src/controllers/lets-crud.controller.js @@ -1,414 +1,420 @@ (function () { - 'use strict'; + 'use strict'; - var module = angular.module('letsAngular'); + var module = angular.module('letsAngular'); - module.controller('CRUDController', function ($scope, Restangular, module, $state, $window, $stateParams, $rootScope, headers, swangular,ngToast) { - $scope.headersReady = false; - $scope.export_btn_is_disable = false; + module.controller('CRUDController', function ($scope, Restangular, module, $state, $window, $stateParams, $rootScope, headers, swangular, ngToast) { + $scope.headersReady = false; + $scope.export_btn_is_disable = false; - function getHeaders() { - var data = angular.copy(headers.get(module)); - $scope.headers = data; - } + function getHeaders() { + var data = angular.copy(headers.get(module)); + $scope.headers = data; + } - getHeaders(); + getHeaders(); - $scope.$on('refresh-headers', function () { - getHeaders(); - }) + $scope.$on('refresh-headers', function () { + getHeaders(); + }) - $scope.resource = Restangular.all($scope.headers.route); + $scope.resource = Restangular.all($scope.headers.route); - $scope.$broadcast('headers-set'); - $scope.headersReady = true; + $scope.$broadcast('headers-set'); + $scope.headersReady = true; - $scope.getFilter = function(){ - return decodeURIComponent($window.location.search).replace("?filter=",""); - } + $scope.getFilter = function () { + return decodeURIComponent($window.location.search).replace("?filter=", ""); + } - $scope.goNew = function () { - $state.go($state.current.name.replace('.list', '.new'), {filter:$scope.getFilter()}); - }; + $scope.goNew = function () { + $state.go($state.current.name.replace('.list', '.new'), { filter: $scope.getFilter() }); + }; - $scope.goToList = function () { - if ($state.current.name.indexOf('.list') == -1) { - $state.go($state.current.name.replace('.edit', '.list').replace('.new', '.list'), {filter:$scope.getFilter()}); - } - }; + $scope.goToList = function () { + if ($state.current.name.indexOf('.list') == -1) { + $state.go($state.current.name.replace('.edit', '.list').replace('.new', '.list'), { filter: $scope.getFilter() }); + } + }; - $scope.edit = function (row) { - $state.go($state.current.name.replace(/\.list$/, '.edit'), { id: row.id, page: null, filter:$scope.getFilter()}); - }; + $scope.edit = function (row) { + $state.go($state.current.name.replace(/\.list$/, '.edit'), { id: row.id, page: null, filter: $scope.getFilter() }); + }; - $scope.delete = function (row) { - return $scope.resource.customDELETE(row.id).then(function () { - $rootScope.$broadcast('refreshGRID'); - }); - }; + $scope.delete = function (row) { + return $scope.resource.customDELETE(row.id).then(function () { + $rootScope.$broadcast('refreshGRID'); + }); + }; - $scope.export = function(){ + $scope.export = function () { + var bigFiltro = $scope.getFilter(); + $scope.export_btn_is_disable = true; + var totalRecords = $scope.totalPager !== undefined ? $scope.totalPager : $('tr').find('td').last().data('model').collection.state.totalRecords; + if (totalRecords && totalRecords > 2000) { + ngToast.warning('Não é possível exportar mais que 2000 registros.'); + $scope.export_btn_is_disable = false; + throw 'Não é possível exportar mais que 2000 registros.'; + } + var resource = $scope.resource; + function filtraExport(item) { + return item.export; + } - var bigFiltro = $scope.getFilter(); - $scope.export_btn_is_disable = true; - var totalRecords = $scope.totalPager !== undefined ? $scope.totalPager : $('tr').find('td').last().data('model').collection.state.totalRecords; - if(totalRecords && totalRecords > 2000) - { - ngToast.warning('Não é possível exportar mais que 2000 registros.') - $scope.export_btn_is_disable = false; - throw 'Não é possível exportar mais que 2000 registros.' - } - var resource = $scope.resource; - function filtraExport (item){ - return item.export; + function mapExportName(item) { + var obj = {}; + obj[item.name] = item.label; + if (!!item.customOptions && !!item.customOptions.exportColumn) { + obj['exportColumn'] = item.customOptions.exportColumn; + } + return obj; + } + + function caminhaObj(obj, vetor) { + if (vetor.length <= 0) { + return null; + } else if (vetor.length == 1) { + if (obj[0]) { + var res = obj.map(function (objt) { + return objt[vetor[0]]; + }); + return res; + } else { + return obj[vetor[0]]; } - - function mapExportName(item){ - var obj = {}; - obj[item.name] = item.label; - if(!!item.customOptions && !!item.customOptions.exportColumn){ - obj["exportColumn"] = item.customOptions.exportColumn; - } - return obj; + } else { + if (obj[0]) { + var novoObj = []; + var novoVetor = vetor.slice(1); + obj.forEach(function (objt) { + novoObj.append(objt[vetor[0]]); + }); + return caminhaObj(novoObj, novoVetor); + } else { + var novoObj = obj[vetor[0]]; + var novoVetor = vetor.slice(1); } - - function caminhaObj(obj, vetor){ - if(vetor.length <= 0){ - return null; - }else if(vetor.length == 1){ - if(obj[0]){ - var res = obj.map(function(objt){ - return objt[vetor[0]]; + var novoVetor = vetor.slice(1); + return caminhaObj(novoObj, novoVetor); + } + } + + function montaColunasComNomes(fields, trocas, caminho) { + if (fields[0]) { + fields.forEach(function (campo) { + caminho += Object.keys(campo)[0] + '#'; + if (campo.exportColumn) { + var antestxt = caminho + campo.exportColumn[0].name; + trocas.push({ + antes: antestxt.split('#'), + depois: campo.exportColumn[0].label, + }); + } else { + var nextfield = Object.keys(campo); + if (Array.isArray(campo[nextfield[0]])) { + var filhos = campo[nextfield[0]]; + filhos.forEach(function (filho) { + montaColunasComNomes([filho], trocas, caminho); }); - return res; - }else{ - return obj[vetor[0]]; - } - }else{ - if(obj[0]){ - var novoObj = []; - var novoVetor = vetor.slice(1); - obj.forEach(function(objt){ - novoObj.append(objt[vetor[0]]); - }) - return caminhaObj(novoObj, novoVetor); - } else{ - var novoObj = obj[vetor[0]]; - var novoVetor = vetor.slice(1); - } - var novoVetor = vetor.slice(1); - return caminhaObj(novoObj, novoVetor); - } - } - - function montaColunasComNomes(fields, trocas, caminho) { - if(fields[0]){ - fields.forEach(function(campo){ - caminho += Object.keys(campo)[0] + '#'; - if(campo.exportColumn){ - var antestxt = caminho + campo.exportColumn[0].name + } else { + var tmp = caminho.split('#').length; + if (tmp > 2) { trocas.push({ - antes: antestxt.split('#'), - depois: campo.exportColumn[0].label - }) - }else{ - var nextfield = Object.keys(campo); - if(Array.isArray(campo[nextfield[0]])){ - var filhos = campo[nextfield[0]]; - filhos.forEach(function(filho){ - montaColunasComNomes([filho], trocas, caminho); - }) - } + antes: [caminho.split('#')[0], caminho.split('#')[1]], + depois: nextfield[0], + }); } - caminho = ''; - }); - } - } - - // debugger; - function extraiColunas(headers){ - var headers_field = headers.fields - .filter(filtraExport) - .map(mapExportName); - if(headers.tabs){ - for(var k in headers.tabs){ - var tab = extraiColunas(headers.tabs[k]) - if(tab) { - var obj = {}; - obj[k] = tab; - obj.real_name = headers.tabs[k].label; - if(!!headers.tabs[k].customOptions && !!headers.tabs[k].customOptions.exportColumn){ - obj["exportColumn"] = headers.tabs[k].customOptions.exportColumn; - } - headers_field.push(angular.copy(obj)); - }; - // if(tab) headers_field.push({[k]: tab}); } } - if(headers.tabs_session){ - for(var k in headers.tabs_session){ - var tabsession = extraiColunas(headers.tabs_session[k]); - if(tabsession) { - var obj = {}; - obj[k] = tabsession; - obj.real_name = headers.tabs_session[k].label; - if(!!headers.tabs_session[k].customOptions && !!headers.tabs_session[k].customOptions.exportColumn){ - obj["exportColumn"] = headers.tabs_session[k].customOptions.exportColumn; - } - headers_field.push(angular.copy(obj)); - } - // if(tabsession) headers_field.push({[k]: tabsession}); + caminho = ''; + }); + } + } + + function extraiColunas(headers) { + var headers_field = headers.fields.filter(filtraExport).map(mapExportName); + if (headers.tabs) { + for (var k in headers.tabs) { + var tab = extraiColunas(headers.tabs[k]); + if (tab) { + var obj = {}; + obj[k] = tab; + obj.real_name = headers.tabs[k].label; + if (!!headers.tabs[k].customOptions && !!headers.tabs[k].customOptions.exportColumn) { + obj['exportColumn'] = headers.tabs[k].customOptions.exportColumn; } + headers_field.push(angular.copy(obj)); } - return (headers_field.length)? headers_field : undefined; + // if(tab) headers_field.push({[k]: tab}); } - - function percorreObjeto(objeto, caminho){ - return caminho.reduce(function(obj, key){ - // debugger; - if(obj && obj[0]){ - var saida = []; - obj.forEach(function(it){ - if(it){ - saida.push(it[key]); - } - }); - return saida; - }else{ - return (obj && obj[key] !== 'undefined' ? obj[key] : undefined) - } - }, objeto); - }; - - function filtrarGrid(filtro) { - var _f = {}; - // //debugger; - - filtro = filtro.split('&'); - for (var i = 0; i < filtro.length; i++) { - var q = filtro[i].split('=', 2); - if (q[0] == 'q') { - // Query geral - _f[q[0]] = q[1]; - } else if (q[0] == 'p') { - // Pagination - _f['page'] = q[1]; - } else if ((/_ini$/g).test(q[0])) { - // Range Inicio - _f['filter[' + q[0].replace(/_ini$/g, '') + '][ini]'] = decodeURIComponent(q[1]); - } else if ((/_fim$/g).test(q[0])) { - // Range Fim - _f['filter[' + q[0].replace(/_fim$/g, '') + '][fim]'] = decodeURIComponent(q[1]); - } else { - // Query especificas - _f['filter[' + q[0] + ']'] = decodeURIComponent(q[1]); + } + if (headers.tabs_session) { + for (var k in headers.tabs_session) { + var tabsession = extraiColunas(headers.tabs_session[k]); + if (tabsession) { + var obj = {}; + obj[k] = tabsession; + obj.real_name = headers.tabs_session[k].label; + if (!!headers.tabs_session[k].customOptions && !!headers.tabs_session[k].customOptions.exportColumn) { + obj['exportColumn'] = headers.tabs_session[k].customOptions.exportColumn; } + headers_field.push(angular.copy(obj)); } - - return _f + // if(tabsession) headers_field.push({[k]: tabsession}); } - - var fields = extraiColunas($scope.headers); - // console.log(fields); - - var htmlmodal = '
'; - var htmlIds = []; - var columnXlsx = []; - - function escreveAninhado(fields, array, a_var){ - var pai = Object.keys(fields)[0]; - var filhos = Object.values(fields); - var html = ''; - // debugger; - filhos.forEach(function(filho, i){ - if(Object.keys(fields)[i] !== "exportColumn"){ - if(typeof(filho) === "string"){ - if(fields.real_name !== filho){ - var idx= array.join('').replace(' ', '_'); - html += '
'; - html += ''; - html += ''; - html += '
'; - htmlIds.push('m_'+ idx + pai); - columnXlsx.push(a_var.join('#')+'#'+pai); - } - }else{ - if(!(pai + 1 > 0)){ - array.push(fields.real_name); - a_var.push(pai); - } - html += escreveAninhado(filho, array, a_var); - } + } + return headers_field.length ? headers_field : undefined; + } + + function percorreObjeto(objeto, caminho) { + // console.log(objeto) + return caminho.reduce(function (obj, key) { + // if (key == 'card_params') debugger; + // if (key == 'cards') debugger; + + if (obj && obj[0]) { + var saida = []; + obj.forEach(function (it) { + if (it) { + saida.push(it[key]); } }); - - return html; + return saida; + } else { + return obj && obj[key] !== 'undefined' ? obj[key] : undefined; + } + }, objeto); + } + + function filtrarGrid(filtro) { + var _f = {}; + // //debugger; + + filtro = filtro.split('&'); + for (var i = 0; i < filtro.length; i++) { + var q = filtro[i].split('=', 2); + if (q[0] == 'q') { + // Query geral + _f[q[0]] = q[1]; + } else if (q[0] == 'p') { + // Pagination + _f['page'] = q[1]; + } else if (/_ini$/g.test(q[0])) { + // Range Inicio + _f['filter[' + q[0].replace(/_ini$/g, '') + '][ini]'] = decodeURIComponent(q[1]); + } else if (/_fim$/g.test(q[0])) { + // Range Fim + _f['filter[' + q[0].replace(/_fim$/g, '') + '][fim]'] = decodeURIComponent(q[1]); + } else { + // Query especificas + _f['filter[' + q[0] + ']'] = decodeURIComponent(q[1]); } - - for(var key in fields){ - var k = Object.keys(fields[key])[0]; - var ob = Object.values(fields[key])[0]; - if(typeof(ob) === "string"){ - htmlmodal += '
'; - htmlmodal += ''; - htmlmodal += ''; - htmlmodal += '
'; - htmlIds.push('m_'+k); - columnXlsx.push(k); - }else{ - // debugger; - htmlmodal += escreveAninhado(fields[key], [], []); + } + + return _f; + } + + var fields = extraiColunas($scope.headers); + // console.log(fields); + + var htmlmodal = '
'; + var htmlIds = []; + var columnXlsx = []; + + function escreveAninhado(fields, array, a_var) { + var pai = Object.keys(fields)[0]; + var filhos = Object.values(fields); + var html = ''; + // debugger; + filhos.forEach(function (filho, i) { + if (Object.keys(fields)[i] !== 'exportColumn') { + if (typeof filho === 'string') { + if (fields.real_name !== filho) { + var idx = array.join('').replace(' ', '_'); + html += '
'; + html += ''; + html += ''; + html += '
'; + htmlIds.push('m_' + idx + pai); + columnXlsx.push(a_var.join('#') + '#' + pai); + } + } else { + if (!(pai + 1 > 0)) { + array.push(fields.real_name); + a_var.push(pai); + } + html += escreveAninhado(filho, array, a_var); } } - + }); + + return html; + } + + for (var key in fields) { + var k = Object.keys(fields[key])[0]; + var ob = Object.values(fields[key])[0]; + if (typeof ob === 'string') { + htmlmodal += '
'; + htmlmodal += ''; + htmlmodal += ''; htmlmodal += '
'; - - // console.log(htmlIds); - // console.log(columnXlsx); - - swangular.swal({ - title: 'Selecione as Colunas Desejadas', - html: htmlmodal, - preConfirm: function(){ - var elementos = htmlIds.map(function(item){ - return document.getElementById(''+item).checked - }); - return elementos - }, - showCancelButton: true, - }).then(function(result){ - // debugger; - if(!!result.value && !!($scope.totalPager) && ($scope.totalPager != undefined)){ - - swangular.swal({ - html: 'Por favor aguarde, estamos buscando os dados.', - allowOutsideClick: false, - allowEscapeKey: false, - onOpen:function(){ - swangular.showLoading(); - } - }); - - var clmnxlsx = columnXlsx.filter(function(column, index){ - return result.value[index] - }); - - - var all_filter = filtrarGrid(bigFiltro); - all_filter = Object.assign({}, all_filter,{per_page: totalRecords}); - - - resource.customGET('pager', all_filter).then(function (response) { - - function nextBeforeExport() { - // debugger; - var res = response.data.map(function(lead){ - var leadFiltrado = {} - clmnxlsx.forEach(function(column){ - var atrbts = column.split('#'); - if(atrbts.length == 1){ - leadFiltrado[column] = lead[column]; - }else if(atrbts.length>1){ - var aux = atrbts.reduce(function(obj, atb, i){ - if(i === atrbts.length - 1){ - obj? obj[atb] = caminhaObj(lead, atrbts): ''; - return obj; - } - return (obj? (obj[atb] = obj[atb]? obj[atb]: {}): ''); - }, leadFiltrado); - } - }); - return leadFiltrado; + htmlIds.push('m_' + k); + columnXlsx.push(k); + } else { + // debugger; + htmlmodal += escreveAninhado(fields[key], [], []); + } + } + + htmlmodal += '
'; + + // console.log(htmlIds); + // console.log(columnXlsx); + + swangular + .swal({ + title: 'Selecione as Colunas Desejadas', + html: htmlmodal, + preConfirm: function () { + var elementos = htmlIds.map(function (item) { + return document.getElementById('' + item).checked; + }); + return elementos; + }, + showCancelButton: true, + }) + .then(function (result) { + // debugger; + // console.log({ result: result }) + if (!!result.value && !!$scope.totalPager && $scope.totalPager != undefined) { + swangular.swal({ + html: 'Por favor aguarde, estamos buscando os dados.', + allowOutsideClick: false, + allowEscapeKey: false, + onOpen: function () { + swangular.showLoading(); + }, + }); + + var clmnxlsx = columnXlsx.filter(function (column, index) { + return result.value[index]; + }); + + var all_filter = filtrarGrid(bigFiltro); + all_filter = Object.assign({}, all_filter, { per_page: totalRecords }); + + resource.customGET('pager', all_filter).then(function (response) { + // console.log(response.data, clmnxlsx) + function nextBeforeExport() { + // debugger; + var res = response.data.map(function (lead) { + var leadFiltrado = {}; + clmnxlsx.forEach(function (column) { + var atrbts = column.split('#'); + if (atrbts.length == 1) { + leadFiltrado[column] = lead[column]; + } else if (atrbts.length > 1) { + var aux = atrbts.reduce(function (obj, atb, i) { + if (i === atrbts.length - 1) { + obj ? (obj[atb] = caminhaObj(lead, atrbts)) : ''; + return obj; + } + return obj ? (obj[atb] = obj[atb] ? obj[atb] : {}) : ''; + }, leadFiltrado); + } }); - - var trocas = []; - montaColunasComNomes(fields, trocas, ''); - // console.log(trocas); - - res.map(function(row){ - var trc = trocas; - trc.forEach(function(troca){ - // row[troca.depois] = percorreObjeto(row, troca.antes); - - var aux = percorreObjeto(row, troca.antes); - if(typeof(aux) === 'object')aux = aux.join(', '); - - row[troca.depois] = aux; - - }); - // SÓ PODE DELETAR DEPOIS DE ATRIBIR TODOS POIS PODE ACONTECER DE UM ATRIBUTO TER ALGUM ATRIBUTO PAI EM COMUM - // debugger; - trc.forEach(function(troca){ - if(troca.antes[0] != troca.depois){ - delete row[troca.antes[0]]; - } - }); - // FAZ DATA - // for(var key in row){ - // debugger; - - // if(!row[key].match(/[A-Z]{2,}[0-9]{4,}(_[A-Z0-9]{1,6})?/g) && moment(row[key], 'YYYY-MM-DD', true).isValid()){ - // var aux = moment(row[key], 'YYYY-MM-DD'); - // row[key] = aux.format('DD/MM/YY h:mm'); - // } - - // if(moment(row[key], 'YYYY-MM-DD').isValid()){ - // var aux = moment(row[key], 'YYYY-MM-DD'); - // row[key] = aux.format('DD/MM/YY h:mm'); - // } - // } - + return leadFiltrado; + }); + + var trocas = []; + montaColunasComNomes(fields, trocas, ''); + // console.log(trocas); + + res.map(function (row) { + var trc = trocas; + trc.forEach(function (troca) { + // row[troca.depois] = percorreObjeto(row, troca.antes); + + var aux = percorreObjeto(row, troca.antes); + // if (!aux) debugger; + // console.log({ a: aux, b: row, c: troca, d: trocas, e: fields }); + if (typeof aux === 'object') aux = aux.join(', '); + // else if (typeof (aux) === 'string') aux = aux.join(', '); + // debugger + row[troca.depois] = aux; }); - - // var oldLabels = fOldLabels(fields); - // var titles = fTitles(res) - // var oldIndex = fOldIndex(oldLabels, titles); - + // SÓ PODE DELETAR DEPOIS DE ATRIBIR TODOS POIS PODE ACONTECER DE UM ATRIBUTO TER ALGUM ATRIBUTO PAI EM COMUM // debugger; - - // fields - /* generate a worksheet */ - swangular.close(); - var ws = XLSX.utils.json_to_sheet(res); - // oldIndex.forEach(function(oi, i){ - // if(oi != -1){ - // var celula = 'A'+ (oi+1); - // var cell = ws[celula]; - // delete ws[celula].w; - - // ws[celula].v = labelcelula(fields, oldLabels[i]); - // } - // }); - /* add to workbook */ - var wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, "dadosexportados"); - /* write workbook and force a download */ - var date = moment().unix(); - XLSX.writeFile(wb, "Exportacao_" + date + ".xlsx"); - - $scope.export_btn_is_disable = false; - } - - $scope.$emit("before export", response, nextBeforeExport); - if (!$scope.$$listeners["before export"]){ - nextBeforeExport(); - } - }); - - }else{ - - if($scope.totalPager != undefined && !result.dismiss){ - swangular.swal({ - type: 'info', - title: 'Ocorreu um erro', - text: 'Não é possível criar exportar os dados, pois não há registros.' - }) + trc.forEach(function (troca) { + if (troca.antes[0] != troca.depois) { + delete row[troca.antes[0]]; + } + }); + // FAZ DATA + // for(var key in row){ + // debugger; + + // if(!row[key].match(/[A-Z]{2,}[0-9]{4,}(_[A-Z0-9]{1,6})?/g) && moment(row[key], 'YYYY-MM-DD', true).isValid()){ + // var aux = moment(row[key], 'YYYY-MM-DD'); + // row[key] = aux.format('DD/MM/YY h:mm'); + // } + + // if(moment(row[key], 'YYYY-MM-DD').isValid()){ + // var aux = moment(row[key], 'YYYY-MM-DD'); + // row[key] = aux.format('DD/MM/YY h:mm'); + // } + // } + // console.log({ trc: trc }) + }); + + // var oldLabels = fOldLabels(fields); + // var titles = fTitles(res) + // var oldIndex = fOldIndex(oldLabels, titles); + + // debugger; + console.log(res); + // fields + /* generate a worksheet */ + swangular.close(); + var ws = XLSX.utils.json_to_sheet(res); + // oldIndex.forEach(function(oi, i){ + // if(oi != -1){ + // var celula = 'A'+ (oi+1); + // var cell = ws[celula]; + // delete ws[celula].w; + + // ws[celula].v = labelcelula(fields, oldLabels[i]); + // } + // }); + /* add to workbook */ + var wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, 'dadosexportados'); + /* write workbook and force a download */ + var date = moment().unix(); + XLSX.writeFile(wb, 'Exportacao_' + date + '.xlsx'); + + $scope.export_btn_is_disable = false; + } + + $scope.$emit('before export', response, nextBeforeExport); + if (!$scope.$$listeners['before export']) { + nextBeforeExport(); } - - $scope.export_btn_is_disable = false; + }); + } else { + if ($scope.totalPager != undefined && !result.dismiss) { + swangular.swal({ + type: 'info', + title: 'Ocorreu um erro', + text: 'Não é possível criar exportar os dados, pois não há registros.', + }); } - }); - } - }); + + $scope.export_btn_is_disable = false; + } + }); + }; + }); })(); \ No newline at end of file