How to write custom reports in Drupal - drupal

What's the "right" way in Drupal to create reports? I was hoping to use a view but am not having much luck. My goal is to create a table of rows containing three fields: user name, location, SUM of volunteer hours. Once I have this part working, I plan to expose filters for Location and Date.
Views Calc only allows you to group by one field. I know Crystal Reports and MSSQL Reporting Services and I was hoping to find a similar kind of thing for Drupal. Is there a framework, examples, or a module to help with this, or do I need to write a custom module implementing the views_alter_SQL hook to get the desired data for each report?
EDIT: I ended up getting it to work with BIRT reports, which gave a lot more power than Views could allow. Code is on my blog: http://nicholaiburton.com/blog/2010/creating-custom-reports-for-drupal

You could implement a views_query_alter but you might be better off implementing a custom views field handler, because I assume that your user.uid joins to hours.uid. This will probably be your best long term solution.
All you'd need to do is just tell views how your tables join and define the handler for the total hours. You can find help/docs -> http://views-help.doc.logrus.com/help/views/api

in any way, for Sum of Volunteer hours you need to build custom module, so building custom query more simpler, than attaching custom field to Views via it's hooks...

Related

How to write Custom HTML code for a Rally/CA report

What would be the HTML code to "filter out" a handful of specific user stories?
Your question is highly unspecific. The only way to get stories is to programatically access the API via a language like Javascript, Java, C#, C++, etc., etc.
You can embed javascript into your html page and get the code to fetch stories with a filter passed in on the access. To see how to structure a query, you could turn on the developer tools in your browser and have a look at the network accesses that the browser does when fetching stories into a custom list app on a page. Using the custom list, you could refine your query to what you want first.
You could always build a custom app for a specific use case, but if you're looking for data and having trouble finding it, there are ways to do so with a combination of custom lists, Rally's own query language, and creative use of advanced filters. It's also possible to massage your data in way that makes Rally's native reporting a bit easier to use.
This is just an example but, if I'm looking to get information on the quarterly progress of my team who don't use start/end date or releases/milestones, there's not a lot available from an app/report standpoint that's already built. However, if I coach my team on keeping a few simple data elements neat and tidy, and utilize the custom report views to make that data useful, it can be pretty quick and easy to implement.
I have my teams keep a few basic fields up to date: Title, Owner, Project, Tags, Refined Estimate (all at a feature level), and most importantly - keeping a parent/child relationship between most work.
Now I can build a report that filters by a certain tag, that can also be filtered by team, and also has the ability to show additional valuable data that can be unearthed because your house is tidy. In this case, you can now display a column that will total all child objects under a certain feature, and display that next to 'Planned' estimate, which will give you the ability to also export and show a planned vs. actual to help your teams estimate more accurately.
It's a round-about way of saying there are a lot of possibilities with the tool if you can use your resources. Building custom apps means you also have to maintain them or pay someone with the knowledge to do so.

How to implement reservation system in week view in drupal?

I want to implement reservation system in my project which should display bookings available for a week (in week view)and users can select the slot which is not booked. I am completely new in drupal. Can anyone tell me how to do this and which module is suitable?
The trick in Drupal is to always search for modules that get you closer to what you want, since there are so many that can save you days of work. I would suggest starting by reviewing this comparison of Booking modules: https://groups.drupal.org/node/137544 before rolling your own.
If none of them suits you, the basic concept would be to have bookings created (a content type) and the some calendar that displays the available dates, then you could use Views for this last part.
The whole solution can be accomplish with a combination of Views and one of the Booking modules above.
Your question is rather general so review that comparison and you will find something you can use for sure.

How to do database queries with Drupal 7 without coding?

My professor recently gave my class an assignment and I need help finding the tools to do so.
We have a database of tables (Customer, Payment, Order, etc.) and I need to use Drupal 7 to allow users to see customer's info, view customer data (i.e. payment history), or edit customer information. This would involve select statements, aggregate clauses, joins, etc. It would also involve forms to input customer name/information.
Here is the catch: I am not allowed to write any code. That means no API, no SQL queries, and no PHP. I am only allowed to use ready-built modules.
So my questions is: What module(s) should I use, and how do I use them?
I know the view is a good place to start, but the default options of view are for content. I have tables on a database, not content. Also from what I understand, custom queries of view require coding.
I believe this is what you are looking for:
http://drupal.org/project/data
If it integrates with the Views module properly, then you won't be required to do any hand-coding to make a View which queries your tables.
(Disclaimer: I haven't actually used it)

Drupal Query builder

I quite often use Drupal's Views Module to build SQL that I paste into my code. It understands the Drupal database schema quite well.
Is there a module that would give me this functionality or can I factor this out of Views?
Would be cool of the Views module was extended to better support programmatic usage, but until then you might perhaps want to take a look at one of my colleagues attempt at creating something similar to such a thing: http://github.com/hugowetterberg/query_builder
Related to this might be the Services project attempt at providing Views data as a service, an effort that we right now are separating out into it's own module: http://drupal.org/node/709100 Might be worth follow since it's going to need some level of programmatic access to Views.
Another example of a module that's accessing Views programmatically is Development Seeds Litenode: http://developmentseed.org/blog/2009/feb/4/litenode
Update 15/12-2010: The EntityFieldQuery in Drupal 7 is almost like using Views programmatically to build queries - the difference being that EntityQueryBuilder works on only entities and fields and by that also with the bonus that it actually can build queries against any type of field storage in use - eg. a NoSQL database like MongoDB. Example can be found here: http://drupal4hu.com/node/267
Although this isn't the ideal way to do things, you can get the results of a view as follows:
$view = views_get_view('search');
$view->set_display('main');
$view->set_items_per_page(0);
$view->execute();
$items = array();
foreach ($view->result as $row) {
$items[] = $row;
}
This way, whenever you modify your views query, you don't have to re-copy the code. I do agree that Views needs to be split up into a query building api and a UI.
Yes, i assume views is the best to know what tables are used for current field, because many modules (and more in views) have hook functions, that provide some information about this field, table, and connection type with other tables.
Also you can read scheme of tables and fields via: http://drupal.org/project/schema
I'm curious- why would you use Views to build SQL, and then not use Views?
When it comes to more difficult things like many to many relationships, GROUP BY, COUNT, SUM, subquerying etc whatever the function calls for, it's best to write it yourself (especially if contrib modules have no views support and you need more than the node table).
For me, when Views can't get it done, I write a simple module that invokes hook_menu (to register the paths) with a callback that does the querying I need.

Drupal 6 - Views2 - How to build a view of non-nodes

I have a need to build views in drupal of non-nodes, actually objects external to drupal. The api that I am calling against passes me back a stdClass object.
Anyone have ideas on how to get Views2 to display non-node objects?
My understanding of Views 2 is that it is meant to work with information stored in a database.
If you don't have access to the database against which the API was written, then consider writing the objects the API returns into a table. The easiest thing would probably be to create nodes from the objects. Then you could access them with Views 2.
This is similar to the approach taken by the Acitivty Stream module (http://drupal.org/project/activitystream). It creates nodes from the data returned by various APIs. Check out the module's code for examples of how to create the nodes:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/activitystream/activitystream.module?view=markup
On the other hand, if you have access to the source database, you might consider exposing the tables of that database to Views directly. This is the approach taken in the latest Views 2 integration code included with CiviCRM v2.2.3, which you can review here:
http://svn.civicrm.org/civicrm/trunk/drupal/modules/views/
CiviCRM is a Drupal module that writes data to tables outside of the Drupal database -- not into nodes. The views integration code exposes most of those tables to Drupal.
Hope this helps.
-- Andrew B.
According to the Views 3 roadmap, Views will eventually work with non-SQL data sources. In the meantime, some very preliminary work has been done in this area, using the Flikr API as a proof-of-concept.
Fixed in latest 6.x-1.x-dev branch. VBO now supports users and comments in addition to nodes. A special hook_object_info can be used to support any other type of object. Please try it and let me know!
you have to expose custom data to views like described here:
http://www.darrenmothersele.com/drupal-blog/drupal-views2-handlers
http://views-help.doc.logrus.com/help/views/api-tables
Views is built for working with nodes + CCK exclusively. If you want to create views for custom pages, you'll need to code some additional module + theme pages.

Resources