Permalink
Browse files

Cambios en combo fecha en cargar contactos

  • Loading branch information...
1 parent 414f165 commit 0d677475f288b1f75c70ad55064c2f1d1be9dff7 @martinvega committed Mar 28, 2012
View
13 app/controllers/contacts_controller.rb
@@ -2,15 +2,13 @@ class ContactsController < ApplicationController
before_filter :auth
before_filter :admin, :only => [:new, :create, :import_csv, :import_csv_contacts]
- @state
require 'csv'
require 'iconv'
# GET /contacts
# GET /contacts.json
def index
if @auth_user.admin?
if params[:state_id].present?
- @state = Contact.where(:contact_state_id => params[:state_id])
@contacts = Contact.paginate(
:page => params[:page],
:per_page => 10
@@ -111,10 +109,13 @@ def update
def load_contacts
- unless params[:campaign].nil?
- @campaign = Campaign.find(params[:campaign])
- @selected = @campaign.id
- date = @campaign.date
+ unless params[:campaign_month].nil? || params[:campaign_year].nil?
+ puts "MES: #{params[:campaign_month]} - ANIO: #{params[:campaign_year]}"
+ #@campaign = Campaign.find(params[:campaign])
+ @selected_year = params[:campaign_year].to_i
+ @selected_month = params[:campaign_month].to_i
+ date = DateTime.new(@selected_year, @selected_month)
+ puts "DATE: #{date}"
contact = Contact.where('contact_state_id IS NULL AND date BETWEEN :start AND :end',
:start => date.beginning_of_month,
:end => date.end_of_month).first!
View
12 app/views/contacts/load_contacts.html.erb
@@ -1,3 +1,11 @@
+<% months = [] %>
+<% years = [] %>
+<% MONTHS.each_with_index do |month, i| %>
+ <% months << [month, i+1] %>
+<% end %>
+<% YEARS.each do |year| %>
+ <% years << year %>
+<% end %>
<div id="select_campaign">
<% unless @contact.nil? %>
<%= render :partial => 'contact' %>
@@ -7,8 +15,8 @@
<div class="field">
<%= label_tag 'Seleccione la campaña' %><br />
- <%= select_tag :campaign,
- options_from_collection_for_select(Campaign.all, "id", "date", @selected) %>
+ <%= select_tag :campaign_month, options_for_select(months, @selected_month) %>
+ <%= select_tag :campaign_year, options_for_select(years, @selected_year) %>
</div>
<div id="search_contact">
<%= submit_tag 'Buscar Contacto' %>
View
23 config/initializers/constants.rb
@@ -1,5 +1,28 @@
require 'prawn/measurement_extensions'
+# Meses
+MONTHS = [
+ 'Enero',
+ 'Febrero',
+ 'Marzo',
+ 'Abril',
+ 'Mayo',
+ 'Junio',
+ 'Julio',
+ 'Agosto',
+ 'Setiembre',
+ 'Octubre',
+ 'Noviembre',
+ 'Diciembre'
+]
+
+# Años
+YEARS = [
+ 2010,
+ 2011,
+ 2012
+]
+
# Ruta a la carpeta pública
PUBLIC_PATH = File.join(Rails.root, 'public')

0 comments on commit 0d67747

Please sign in to comment.