Esempio n. 1
0
					'success': function(reportsCollection) {
						reportsListView.collection = reportsCollection;
						AgronetEstadisticas.mainRegion.currentView.reportsRegion.show(reportsListView);

						var reportModel = reportsCollection.find(function(r) {
							return r.get('idCategoria') === parseInt(idCategory,0) && r.get('idReporte') === parseInt(idReport, 0);
						});

						document.title = reportModel.get("titulo");
						ga('send', 'pageview', {
							'title': reportModel.get("idReporte") + " " + reportModel.get("titulo"),
							'page': Backbone.history.location.hash
						});

						if (typeof params !== 'undefined') {
							charts.params = params;
							filters.params = params;
							AgronetEstadisticas.params = params;
						}
						switch (reportModel.get("tipo")) {
							case 'reporte':
								charts.tipo = 'reportView';
								charts.fetch({
									'success': function(chartsCollection) {
										chartsListView.collection = chartsCollection;
										chartsListView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(chartsListView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 716;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(errorView);
									}
								});
								filters.fetch({
									'success': function(filtersCollection) {
										filterListView.collection = filtersCollection;
										filterListView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filterListView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 132;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							case 'descargable':
								files.fetch({
									'success': function(filesCollection) {
										filesListView.report = reportModel;
										filesListView.collection = filesCollection;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(filesListView);

										filesHeaderView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filesHeaderView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 777;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							case 'boletin':
								newsletters.fetch({
									'success': function(newslettersCollection) {
										filesListView.report = reportModel;
										filesListView.collection = newslettersCollection;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(filesListView);

										filesHeaderView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filesHeaderView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 777;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							default:
								break;
						}

					}
Esempio n. 2
0
			report: function(idCategory, idReport, params) {
				$.map(AgronetEstadisticas.xhrPool, function(xhr) {
					xhr.abort();
				});
				AgronetEstadisticas.xhrPool = [];
				AgronetEstadisticas.params = [];

				var categories = new Category.Collection();
				var reports = new Report.Collection();
				var report = new Report.Model();
				var charts = new Chart.Collection();
				var filters = new Filter.Collection();
				var files = new File.Collection();
				var newsletters = new Newsletter.Collection();

				var reportsView = new ReportsView();
				var categoriesView = new CategoriesView();
				var reportsListView = new ReportsListView();
				var chartsListView = new ChartsListView();
				var filterListView = new FilterListView();
				var filesListView = new FilesListView();
				var filesHeaderView = new FilesHeaderView();

				AgronetEstadisticas.mainRegion.show(reportsView);

				if (typeof idCategory !== 'undefined') {
					reports.idCategory = idCategory;
					report.idCategory = idCategory;
					charts.idCategory = idCategory;
					filters.idCategory = idCategory;
					files.idCategory = idCategory;
					AgronetEstadisticas.idCategory = idCategory;
				}
				categories.fetch({
					'success': function(categoriesCollection) {
						categoriesView.collection = categoriesCollection;
						AgronetEstadisticas.mainRegion.currentView.categoriesRegion.show(categoriesView);

						categoriesCollection.each(function(c) {
							if (c.get('idCategoria') == idCategory) {
								var titleView = Backbone.View.extend({
									tagName: 'span',
									className: 'navbar-brand title',
									render: function() {
										this.$el.html(c.get('tituloPrincipal'));
									}
								});
								AgronetEstadisticas.mainRegion.currentView.titleRegion.show(new titleView());
							}
						});
					}
				});

				if (typeof idReport !== 'undefined') {
					report.idReport = idReport;
					charts.idReport = idReport;
					filters.idReport = idReport;
					files.idReport = idReport;
					newsletters.idReport = idReport;
					AgronetEstadisticas.idReport = idReport;
				}
				reports.fetch({
					'success': function(reportsCollection) {
						reportsListView.collection = reportsCollection;
						AgronetEstadisticas.mainRegion.currentView.reportsRegion.show(reportsListView);

						var reportModel = reportsCollection.find(function(r) {
							return r.get('idCategoria') === parseInt(idCategory,0) && r.get('idReporte') === parseInt(idReport, 0);
						});

						document.title = reportModel.get("titulo");
						ga('send', 'pageview', {
							'title': reportModel.get("idReporte") + " " + reportModel.get("titulo"),
							'page': Backbone.history.location.hash
						});

						if (typeof params !== 'undefined') {
							charts.params = params;
							filters.params = params;
							AgronetEstadisticas.params = params;
						}
						switch (reportModel.get("tipo")) {
							case 'reporte':
								charts.tipo = 'reportView';
								charts.fetch({
									'success': function(chartsCollection) {
										chartsListView.collection = chartsCollection;
										chartsListView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(chartsListView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 716;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(errorView);
									}
								});
								filters.fetch({
									'success': function(filtersCollection) {
										filterListView.collection = filtersCollection;
										filterListView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filterListView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 132;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							case 'descargable':
								files.fetch({
									'success': function(filesCollection) {
										filesListView.report = reportModel;
										filesListView.collection = filesCollection;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(filesListView);

										filesHeaderView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filesHeaderView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 777;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							case 'boletin':
								newsletters.fetch({
									'success': function(newslettersCollection) {
										filesListView.report = reportModel;
										filesListView.collection = newslettersCollection;
										AgronetEstadisticas.mainRegion.currentView.chartsRegion.show(filesListView);

										filesHeaderView.report = reportModel;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(filesHeaderView);
									},
									'error': function(model, error) {
										var errorView = new ErrorView();
										errorView.message = error;
										errorView.height = 777;
										AgronetEstadisticas.mainRegion.currentView.filtersRegion.show(errorView);
									}
								});
								break;
							default:
								break;
						}

					}
				});

				// report.fetch({
				// 	'success': function(reportModel) {
				//
				//
				// 	}
				// });

			}