mainAppModule.controller('modificareAdresaCtrl', function($scope,ajaxService) { var defaultTipActDeIdentitate = "Selectati tip act identitate"; $scope.hint = null; $scope.jsonRequestUrl = ""; $scope.nomenclatorJudete = []; $scope.nomenclatorLocalitati = []; $scope.nomenclatorTipActDeIdentitate = [{ label : defaultTipActDeIdentitate } ]; $scope.judet = {id : -1, nume : "",errorCssFlag : false}; $scope.localitate = {id : -1, nume : "", errorCssFlag : false}; $scope.tipActDeIdentitate = {value : defaultTipActDeIdentitate,errorCssFlag : false}; $scope.showJudLoc = true; $scope.captchaPath = ""; $scope.searchLocalitate = ""; $scope.retreiveNomJudete = function(){ var judetId = $("input[id='judet.id']").val(); var localitateId = $("input[id='localitate.id']").val(); if(judetId != undefined && judetId != "") $scope.judet = {id : parseInt(judetId), nume : $("input[id='judet.nume']").val(), errorCssFlag : false}; if(localitateId != undefined && localitateId != "") $scope.localitate = {id : parseInt(localitateId), nume : $("input[id='localitate.nume']").val(), errorCssFlag : false}; $("input[id='judet.id']").remove(); $("input[id='judet.nume']").remove(); $("input[id='localitate.id']").remove(); $("input[id='localitate.nume']").remove(); $("input[name='judet_id']").attr("name","judet.id"); $("input[name='judet_nume']").attr("name","judet.nume"); $("input[name='localitate_id']").attr("name","localitate.id"); $("input[name='localitate_nume']").attr("name","localitate.nume"); if($scope.judet.id != -1) $scope.retreiveNomLocalitati($scope.judet.id,false); else if($scope.judet.id == -1 && $("#th_save_action").val() != undefined){ $scope.judet.errorCssFlag = true; $scope.localitate.errorCssFlag = true; } var params = $.param({type : "nomenclaturaJudete"}); var d=new Date(); ajaxService.sendXTR($scope.jsonRequestUrl+"&t="+d.getTime(),params) .then(function(result){ $scope.onResolveNomJud(result); }, function(status){ $scope.onRejectNomJud(status); }); }; $scope.retreiveTipActDeIdentitateList = function(){ var params = $.param({type : "nomenclaturaTipActDeIdentitate"}); var d=new Date(); ajaxService.sendXTR($scope.jsonRequestUrl+"&t="+d.getTime(),params) .then(function(result){ $scope.nomenclatorTipActDeIdentitate = $scope.nomenclatorTipActDeIdentitate.concat(result); var tipActDeIdentitateValue = $("input[id='tipActDeIdentitate']").val(); if(tipActDeIdentitateValue != null && tipActDeIdentitateValue.length > 0 && tipActDeIdentitateValue != defaultTipActDeIdentitate){ $scope.tipActDeIdentitate.value = tipActDeIdentitateValue; } else if($("#th_save_action").val() != undefined){ $scope.tipActDeIdentitate.errorCssFlag = true; } $("input[id='tipActDeIdentitate']").remove(); $("input[name='tipActDeIdentitate_']").attr("name","tipActDeIdentitate"); $scope.onChangeTipActDeIdentitate(); }, function(status){ }); }; $scope.onInitHint = function(){ $scope.hint = { show : false, map : new Array(), currentHint : "" }; $scope.hint.map = new Array(); $scope.hint.map['nume'] = "Introduceti numele dumneavostra asa cum apare in actul de identitate"; $scope.hint.map['prenume'] = "Introduceti prenumele dumneavostra asa cum apare in actul de identitate"; $scope.hint.map['cnp'] = "Introduceti Codul Numeric Personal format din 13 cifre"; $scope.hint.map['email'] = "Intorduceti adresa de email ce va fi folosita ca si nume de utilizator"; $scope.hint.map['tipAct'] = "Selectati tipul actului de identitate"; $scope.hint.map['serieBuletin'] = "Introduceti seria actului de identitate"; $scope.hint.map['numarBuletion'] = "Introdduceti numarulactului de identitate"; $scope.hint.map['eliberatDe'] = "Introduceti numele autoritatii ce a eliberat actul de identitate"; $scope.hint.map['laData'] = "Introduceti data de inceput a valabilitatii actului de identitate"; $scope.hint.map['validPana'] = "Introduceti data de sfarsit a valabilitatii actului de identitate"; $scope.hint.map['judet'] = "Selectati judetul de resedinta conform actului de identitate"; $scope.hint.map['localitate'] = "Selectati localitatea de resedinta conform actului de identitate"; $scope.hint.map['strada'] = "Introduceti numele strazii de resedinta conform actului de identitate"; $scope.hint.map['numar'] = "Introduceti numarul strazii"; $scope.hint.map['bloc'] = "Introduceti blocul"; $scope.hint.map['scara'] = "Introduceti scara"; $scope.hint.map['etaj'] = "Introduceti etajul"; $scope.hint.map['apartament'] = "Introduceti apartamentul"; $scope.hint.map['tipPersoanaS'] = "Selectati tipul reprezentarii"; $scope.hint.map['numeS'] = "introduceti numele/denumirea persoanei fizice/juridice reprezentate"; $scope.hint.map['codFiscalS'] = "Introduceti CNP/CUI al persoanei fizice/juridice reprezentate"; $scope.hint.map['documentS'] = "Introduceti identificatorul unic al documentului de reprezentare"; $scope.hint.map['dataExpirareS'] = "Introduceti data de expirare a documentului de reprezentare"; $scope.hint.map['codCertificatStagiu'] = "Introduceti codul de pe certificatul de stagiu primit prin posta";//CNPPEGUVM-18916 }; $scope.onClickHint = function(key){ $scope.hint.show = true; $scope.hint.currentHint = $scope.hint.map[key]; }; $scope.onCloseHint = function(){ $scope.hint.show = false; }; $scope.retreiveNomLocalitati = function(idJudet,onChangeJudet){ var params = $.param({type : "nomenclaturaLocalitati",idJudet : idJudet}); var d=new Date(); ajaxService.sendXTR($scope.jsonRequestUrl+"&t="+d.getTime(),params) .then(function(result){ $scope.onResolveNomLoc(result,onChangeJudet); }, function(status){ $scope.onRejectNomLoc(status); }); }; $scope.onResolveNomLoc = function(result,onChangeJudet){ $scope.nomenclatorLocalitati = result; $scope.nomenclatorLocalitati.splice(0,1); if(onChangeJudet == true){ $scope.localitate.id = -1; $scope.localitate.nume = ""; } else if($scope.localitate.id == -1 && $("#th_save_action").val() != undefined){ $scope.localitate.errorCssFlag = true; } //if($scope.localitate.id == -1){ // $selecteaza = angular.copy($scope.nomenclatorLocalitati[0]); // $selecteaza.id = -1; // $selecteaza.nume = ""; // $scope.localitate = $selecteaza; // $scope.nomenclatorLocalitati.unshift($selecteaza); //} }; $scope.onResolveNomJud = function(result){ $scope.nomenclatorJudete = result; $scope.nomenclatorJudete.splice(0,1); if($scope.judet.id == -1){ $selecteaza = angular.copy($scope.nomenclatorJudete[0]); $selecteaza.id = -1; $selecteaza.nume = "Selectati judetul"; $scope.nomenclatorJudete.unshift($selecteaza); } }; $scope.onChangeTipActDeIdentitate = function(){ if($scope.tipActDeIdentitate.value != defaultTipActDeIdentitate && $scope.nomenclatorTipActDeIdentitate[0].label == defaultTipActDeIdentitate) $scope.nomenclatorTipActDeIdentitate.splice(0,1); var hideJudLocValues = { "Pasaport" : 1 }; $scope.showJudLoc = hideJudLocValues[$scope.tipActDeIdentitate.value] == undefined; }; $scope.onChangeJudet = function(){ if($scope.nomenclatorJudete[0].id == -1 && $scope.nomenclatorJudete[0].nume == "Selectati judetul") $scope.nomenclatorJudete.splice(0,1); $scope.retreiveNomLocalitati($scope.judet.id,true); $scope.localitate = {id : -1, nume : "", errorCssFlag : false}; }; //$scope.onChangeLocalitate = function(){ // if($scope.nomenclatorLocalitati[0].id == -1 && // $scope.nomenclatorLocalitati[0].nume == "") // $scope.nomenclatorLocalitati.splice(0,1); //}; $scope.refreshCaptcha = function(){ var dataCurenta=(new Date()).getTime(); $scope.captchaImageTag = ""; $("#captcha_img_container").children().remove(); $("#captcha_img_container").append($scope.captchaImageTag); }; $scope.onRejectNomLoc = function(status){ console.log(status); }; $scope.onRejectNomJud = function(status){ console.log(status); }; });