On May 31, 2011, at 8:01 AM, Owen wrote:
Has any one in the group tried Ruport?
http://www.rubyreports.org/
Wow, that looks really nice, and timely, too. I wonder if it works
with Rails 3.x yet? (Example code in the Web site referred to "add the
gem require to your environment.rb", so I'm not sure.
Walter
On May 31, 5:52 am, Piotroslav <[email protected]> wrote:
Greetings,
I am trying to generate some reports that requires to join some
models.
My models are:
Lead
has_many :engineers, :through => :offers
has_many :offers, :accessible => true
has_many :projects, :accessible => true
has_many :bidforms, :accessible => true
belongs_to :contact
belongs_to :user, :class_name => "User", :creator => true
User
has_many :calls
has_many :companies
has_many :projects
has_many :leads
has_many :signoffs
has_many :todos
belongs_to :access_role
Contact
belongs_to :user, :class_name => "User", :creator => true
belongs_to :company
has_many :calls
has_many :leads, :accessible => :true
Calls
belongs_to :contact
belongs_to :user, :class_name => "User", :creator => true
Company
has_many :projects, :accessible => :true
has_many :contacts, :accessible => :true
belongs_to :user, :class_name => "User", :creator => true
has_many :calls, :through => :contacts
Some of reports to generate are:
*A report that show the number of calls, to the number of contacts,
with the number of leads in the last quarter (e.g. would say for
example Vodafone Group services, 27 calls to 12 contacts with 2
leads)
*A report which allows you to list all calls by a salesperson over a
user defined time period
So what I figured out is I need to create named_scope.
To generate report that shows all calls from users within last
quarter
I do:
named_scope :show_calls, :from => "(select *, (select count(*) from
calls where user_id=users.id and created_at >= '" +
(Date.commercial(Date.today.year, Date.today.cweek, 1) - 11 *
7).strftime("%Y-%m-%d") + "' and result != 'nocall') as total_calls
from users) users", :conditions => "total_calls > 0"
But I do not know how to generate report which (like in first
example)
joins multiple models (in this example Company with Call, Contact and
Lead model), nor how to vary report (like in second exaple by user
specified dates)
Thank you in advance!
Kind regards,
Piotr Stepniak
--
You received this message because you are subscribed to the Google
Groups "Hobo Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.