[eluser]D_Williams[/eluser]
I'm new to both CI and MVC. I have a bunch of code going at work and I'm continually expanding on it. I've read a bunch about CI and I really like it. I want to start converting all my current code over to CI, starting with my report system.
My report system is fairly decent, but it has problems that I feel would be helped by CI (specifically form validation, authentication, and general formatting but there's not the point of this topic).
The basic synopsis of how my report system works is as follows: I have a viewreport.php file in my root directory that serves as the report engine. I have a "reports" directory with one PHP file for each report. Each file in "reports" implements a getReportHTML() function and a displayConfig() function as well as sets some report-specific config values. It's pretty obvious what these functions do, displayConfig() outputs a form asking for what input the form requires (dates, ranges, and so forth). getReportHTML() queries the database, does the processing, and returns (not echoes) HTML for the report's table and such. viewreport.php takes a report name from GET and includes "reports/<whatever report>" then runs the report when the config has been set, giving the user the option of displaying it in-page, downloading as PDF, emailing it, or saving it on the server.
I'm a bit caught up on how to implement this in CI. It seems like what I have now is a little bit similar to the MVC pattern, but not all the way there. I was hoping somebody could help me with a basic MVC structure for this project.
So far these are my thoughts:
Models: I'm not sure what to do here really. Most (but not all) reports deal with either my accounts table or my payments table, but they usually require vastly different column names from all the other reports. "accounts" has about 75 columns and payments has around 40 (yes I know that's crazy but this database isn't normalized very well, I'm not the one who designed it and re-designing it is a bigger project than I care to undertake), so I don't want to just have some "get account row" or "get payment row" model function that returns the whole row since it's very inefficient to pull down 75 columns when I just need 4 or 5. On the other hand, I don't want to have a thousand little functions retrieving a column here and a column there, and I don't want to have a model or model function specific to any reports.
Controllers: Again my goal for most of this is to leave report-specific code out of the "report engine" itself as much as possible and have pluggable reports. What I'm thinking about doing is sticking to having a "reports" folder and put it under application/reports. I would have a "reports" controller. The index function would quite literally be an index and output a list of all reports in the reports folder and display a link to another function under the reports controller, but I'm not sure where to go from here. I need to keep the ability to have my users be able to choose what to do with their reports (display in page, PDF, email, etc), so I can't just call a single controller function to display it in a page. Right about here is where my thought process starts getting muddy.
Views: I don't see any option here other than to have multiple views for each report representing the different report destinations like report1_email report1_pdf and report1_page.
Thanks in advance to anyone who can help me clear this up