tag:blogger.com,1999:blog-5542840264156477606.post-87290816449486457262008-01-30T12:15:00.000-05:002008-02-01T17:20:05.156-05:00Upcoming Andromeda FeatureAbout three weeks ago I was working on a project for work, that is using <a href="http://www.andromeda-project.org/">Andromeda</a> and for some reason got to thinking about reports. And I thought to myself why couldn't we use <a href="http://www.yaml.org/">YAML</a> to define reports. So I sent an email to <a href="http://database-programmer.blogspot.com/">Ken Downs</a> and suggested that we should get together and hash this idea out. So we got together about two weekends ago, and I presented this idea to him, and then showed him <a href="http://www.smarty.net/">Smarty</a> and showed him a couple of things that could be done with it.<br /><br />Basically the whole "concept" comes down to the following<br /><ul><li>We already have our tables defined in the application YAML file</li><li>A report is just how to display the data</li><li>Smarty Gives us a way to have some logic (Looping, Alternating Row Color)</li><li>WE just need a filter for the data to display (WHERE CLAUSE)<br /></li></ul>So over the course of the rest of the weekend Ken coded up the concept of an AndroPage, which literally passes off the data to a another class that handles either turning the data into a Report(PDF) or a page(Smarty). After he was done with that I put into place the code that loops through the sections, and assigned the row(s) to the appropriate Smarty Variables named after the section they are in.<br /><br />The definition of page looks like this:<br /><blockquote><pre>options:<br /> title: Reviews<br /><br />section review:<br /> onerow: "Y"<br /> table reviews:<br /> column name_book:<br /> compare: = @book<br /> column review:<br /> column ts_ins:<br /> column ts_upd:<br /> column uid_ins:<br /> column uid_upd:<br /><br />uifilter book:<br /> description: Book Title<br /> type_id: vchar<br /> colprec: 50<br /><br />template: p_review.tpl<br /></pre></blockquote><br /><span style="font-weight: bold;">options:</span> Allows us to set things such as page title.<br /><br /><span style="font-weight: bold;">section:</span> Allows us to litterally pull as much data as we want and place it in different sections around the page, such as maybe client information in one area and then ads pertaining to this clients industry in another area.<br /><br /><span style="font-weight: bold;">onerow:</span> Specified that we only expect one row back for this page(This is done so that we do not need a foreach loop in the smarty template)<br /><br /><span style="font-weight: bold;">table:</span> Refer to tables that are specified in the application YAML file. Multiple tables can be specified and Andromeda will attempt to join the tables based on primary_keys<br /><br /><span style="font-weight: bold;">column:</span> The columns to be used for display from the tables.<br /><br /><span style="font-weight: bold;">uifilter: </span>Tells Andromeda that we need to filter on something, and if its not specified display a page so the user can enter it.<br /><br /><span style="font-weight: bold;">template: </span>Tells Andromeda that this is a Smarty Page and to use the specified template.<br /><br />Each section get assigned to a Smarty variable with the same name, then you just have to create the Smarty template.<br /><br />An example of a Smarty template is this:<br /><blockquote><br /><pre>{* Smarty *}<br />&lt;table border="0" cellpadding="0" cellspacing="0"&gt;<br />&lt;tbody&gt;<br /> &lt;tr&gt;<br /> &lt;td&gt;&lt;h3&gt;{$review.name_book}&lt;/h3&gt;&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;tr&gt;<br /> &lt;td&gt;Review:&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;tr&gt;<br /> &lt;td&gt;{$review.review}&lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;tr&gt;<br /> &lt;td&gt;Reviewed by: {$review.uid_ins} on {$review.ts_ins}&lt;/td&gt;<br /> &lt;/tr&gt;<br />&lt;/tbody&gt;<br />&lt;/table&gt;<br /></pre></blockquote>There as still a couple of minor bugs which should be fixed shortly and then there will be a release.Donald J Organ IVhttp://www.blogger.com/profile/14412453157119493777noreply@blogger.com