Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .controller('capacitacion', ['$scope', '$http', '$location', '$routeParams', 'firmantesCombo','LEYENDAS',
- function($scope,$http,$location, $routeParams,firmantesCombo,LEYENDAS) {
- var self = this;
- self.leyendas= LEYENDAS;
- self.modelo = {};
- self.capacitacionId = null;
- if ($routeParams!=null && $routeParams.capacitacionId !=null){
- self.capacitacionId = $routeParams.capacitacionId;
- }
- self.inicio = null;
- self.fin = null;
- self.fechaEmision = null;
- self.firmantes = [];
- self.provincias = [];
- self.localidades = [];
- self.tiposcapacitacion = [];
- self.tipocapacitacion = {id:null};
- firmantesCombo.buscarTiposCapacitacionEnum().success(function(response){
- self.modelo = response;
- });
- firmantesCombo.buscar().success(function(response){
- self.firmantes = response._embedded.firmante;
- });
- firmantesCombo.buscarProvincias().success(function(response){
- self.provincias = response._embedded;
- });
- firmantesCombo.buscarTiposCapacpacitacion().success(function(response){
- self.tiposcapacitacion = response._embedded;
- });
- self.buscarLocalidadesPorProvincia = function(){
- firmantesCombo.buscarLocalidadesProvincia(self.capacitacion.provincia.id).success(function(response){
- self.localidades = response._embedded;
- }).error(function(error){
- self.localidades = [];
- });
- };
- self.usarTemplate = function(){
- if (self.tipocapacitacion.id!=null){
- self.capacitacion.modelo = self.tipocapacitacion.modelo;
- self.capacitacion.nombre = self.tipocapacitacion.nombre;
- self.capacitacion.provincia = self.tipocapacitacion.provincia;
- self.buscarLocalidadesPorProvincia();
- self.capacitacion.localidad = self.tipocapacitacion.localidad;
- self.capacitacion.firmante1 = self.tipocapacitacion.firmante1;
- self.capacitacion.firmante2 = self.tipocapacitacion.firmante2;
- self.capacitacion.firmante3 = self.tipocapacitacion.firmante3;
- self.capacitacion.logoProvinciaPath = self.tipocapacitacion.logoProvinciaPath;
- self.capacitacion.logoCentralPath = self.tipocapacitacion.logoCentralPath;
- }
- };
- self.fechaEmisionDefault = function(){
- if ((self.fechaEmision == null && self.fin != null) || (self.fechaEmision != null && self.fin != null && self.fechaEmision < self.fin)){
- self.fechaEmision = self.fin;
- }
- };
- $scope.currentPage = 1;
- $scope.viewby = 10;
- $scope.itemsPerPage = $scope.viewby;
- $scope.maxSize = 5; // Number of pager buttons to show
- self.enviarConsultaCapacitacion = function(){
- if ((self.capacitacionId!=null && self.capacitacionId!="" )||
- (self.curso!=null && self.curso!="" )){
- $scope.currentPage=1;
- }
- self.capacitacionId = null;
- navegar();
- };
- var navegar = function(){
- var curso="%";
- var capacitacionId=null;
- if (self.capacitacionId!=null && self.capacitacionId!=""){
- capacitacionId=self.capacitacionId;
- }
- if (self.curso!=null && self.curso!=""){
- curso=self.curso+"%";
- }
- if (self.capacitacionId==null || self.capacitacionId==""){
- firmantesCombo.buscarCapacitacionesNombreConsulta(curso,$scope.currentPage-1,$scope.itemsPerPage)
- .then(function(response) {
- $scope.capacitacion = response.data;
- $scope.totalItems = response.data.page.totalElements;
- $scope.numPages = response.data.page.totalPages;
- });
- }else{
- firmantesCombo.buscarCapacitacion(capacitacionId)
- .then(function(response) {
- $scope.capacitacion={_embedded: {
- capacitacion: []
- }
- };
- $scope.capacitacion._embedded.capacitacion.push(response.data);
- $scope.totalItems = 1;
- $scope.numPages = 1;
- });
- };
- };
- navegar();
- $scope.setPage = function (pageNo) {
- $scope.currentPage = pageNo;
- };
- $scope.pageChanged = function() {
- console.log('Page changed to: ' + $scope.currentPage);
- navegar();
- };
- $scope.setItemsPerPage = function(num) {
- $scope.itemsPerPage = num;
- $scope.currentPage = 1; // reset to first paghe
- navegar();
- }
- enviar = function(capacitacion){
- $http.post($location.protocol() +"://" + $location.host()+":"+$location.port() +
- '/diplomaapi/capacitacion',capacitacion).then(function(response) {
- navegar();
- });
- };
- enviarEdita = function(capacitacion){
- $http.put(capacitacion._links.self.href,capacitacion).then(function(response) {
- navegar();
- });
- };
- enviarEditaLogos = function(id,logoProvincia,logoCentral){
- var fd = new FormData();
- fd.append('file', logoProvincia);
- var fd2 = new FormData();
- fd2.append('file', logoCentral);
- $http.post($location.protocol() +"://" + $location.host()+":"+$location.port() +
- '/diplomaapi/capacitacion/logoProvincia/'+id,
- fd, {
- transformRequest: angular.identity,
- headers: {'Content-Type': undefined}
- }).then(function(response) {
- $http.post($location.protocol() +"://" + $location.host()+":"+$location.port() +
- '/diplomaapi/capacitacion/logoCentral/'+id,
- fd2, {
- transformRequest: angular.identity,
- headers: {'Content-Type': undefined}
- }).then(function(response) {
- navegar();
- });
- });
- };
- $scope.cargoFilter = function () {
- return function (item) {
- return item.posicion=="Directora Nacional" || item.posicion=="Subsecretario Subsecretaría de Gestión de Servicios Audiovisuales";
- };
- };
- self.verAcreditacion = function(link,indice){
- var valor=indice;
- $scope.capacitacion._embedded.capacitacion[valor].acreditaciones = [];
- $http.get(link).then(function(response) {
- angular.forEach(response.data._embedded.acreditacion, function(value, key) {
- $scope.capacitacion._embedded.capacitacion[valor].acreditaciones.push({participanteId:"#/participante/"+value.persona.id,apellido:value.persona.apellido});
- });
- });
- };
- self.sortMe = function() {
- return function(object) {
- return object.apellido;
- }
- };
- self.ocultarAcreditacion = function(indice){
- $scope.capacitacion._embedded.capacitacion[indice].acreditaciones = null;
- }
- self.setearCapacitacion = function(capacitacion){
- self.capacitacion = capacitacion;
- if (self.capacitacion.provincia!=null){
- self.buscarLocalidadesPorProvincia();
- }
- self.inicio = new Date();
- if (self.capacitacion.inicio!=null){
- self.inicio = new Date(self.capacitacion.inicio);
- }
- self.fin = new Date();
- if (self.capacitacion.fin!=null){
- self.fin = new Date(self.capacitacion.fin);
- }
- self.fechaEmision = new Date();
- if (self.capacitacion.fechaEmision!=null){
- self.fechaEmision = new Date(self.capacitacion.fechaEmision);
- }
- self.logos= 1;
- $scope.myFileLogoProvincia = capacitacion.logoProvincia;
- $scope.myFileLogologoCentral = capacitacion.logoCentral;
- };
- self.setTipoCapacitacionEnum = function(tipocapacitacionenum){
- self.capacitacion.modelo = tipocapacitacionenum;
- };
- self.setearCargarLogos = function(capacitacion){
- self.capacitacion = capacitacion;
- self.logos= 2;
- $scope.myFileLogoProvincia = capacitacion.logoProvincia;
- $scope.myFileLogologoCentral = capacitacion.logoCentral;
- };
- self.crearCapacitacion = function(){
- self.capacitacion = {};
- self.localidades = [];
- self.inicio = new Date();
- self.fin = new Date();
- self.fechaEmision = new Date();
- self.logos= 1;
- };
- self.cancelarCapacitacion = function(){
- self.localidades = null;
- self.inicio=null;
- self.fin=null;
- self.fechaEmision=null;
- if (self.capacitacionId!=null){
- self.curso = self.capacitacion.nombre;
- navegar();
- }
- self.capacitacion = null;
- self.logos= null;
- $scope.myFileLogoProvincia = null;
- $scope.myFileLogologoCentral = null;
- };
- self.cancelarLogos = function(){
- self.capacitacion = null;
- self.localidades = null;
- self.logos= null;
- $scope.myFileLogoProvincia = null;
- $scope.myFileLogologoCentral = null;
- };
- self.enviarCapacitacion = function(){
- self.capacitacion.inicio = self.inicio;
- self.capacitacion.fin = self.fin;
- self.capacitacion.fechaEmision = self.fechaEmision;
- if (self.capacitacion._links!=null && self.capacitacion._links.self.href!=null){
- enviar(self.capacitacion);
- }else{
- enviar(self.capacitacion);
- }
- self.capacitacion=null;
- self.localidades = null;
- self.inicio=null;
- self.fin=null;
- self.fechaEmision=null;
- self.logos= null;
- $location.path("/capacitacion");
- };
- self.enviarLogos = function(){
- enviarEditaLogos(self.capacitacion.id,$scope.myFileLogoProvincia,$scope.myFileLogoCentral);
- self.capacitacion=null;
- self.localidades = null;
- self.logos= null;
- $scope.myFileLogoProvincia = null;
- $scope.myFileLogologoCentral = null;
- };
- }])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement