Implemented template cloning
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Oct 2006 02:35:38 +0000 (02:35 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Oct 2006 02:35:38 +0000 (02:35 +0000)
Added the ability to move templates/reports/outputs to different folders
Broke output display into completed vs. non-completed output tables
Forcing regular expressions (visually) on parameter entry when available
Rearranged the report editor to hopefully make a little more sense
Fixed some other small bugs

git-svn-id: svn://svn.open-ils.org/ILS/trunk@6533 dcc99617-32d9-48b4-a31d-7c20da2025e4

14 files changed:
Open-ILS/web/reports/oils_rpt.css
Open-ILS/web/reports/oils_rpt.js
Open-ILS/web/reports/oils_rpt.xhtml
Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_builder.xhtml
Open-ILS/web/reports/oils_rpt_editor.xhtml
Open-ILS/web/reports/oils_rpt_folder_window.js
Open-ILS/web/reports/oils_rpt_folder_window.xhtml
Open-ILS/web/reports/oils_rpt_param_editor.js
Open-ILS/web/reports/oils_rpt_param_editor.xhtml
Open-ILS/web/reports/oils_rpt_report_editor.js
Open-ILS/web/reports/oils_rpt_utils.js
Open-ILS/web/reports/oils_rpt_vars.js
Open-ILS/web/reports/oils_rpt_widget.js

index bf54b50..c470124 100644 (file)
@@ -114,11 +114,20 @@ button:active {
        position: absolute;     
        text-align: center;
        z-index: 1;
-       background: #E0F0F0; 
+       /*background: #E0F0F0; */
+       background: #FFCC7F;   /* see FF9900 as the primary color in the color picker for complimentaries */
        border: 3px groove #0033EE;
        padding: 10px;
+
+       /* testing static location */
+       width: 600px;
+       top: 60px;
+       left: 20px;
 }
 
+.oils_rpt_tab_picker_selected {
+       background: #96A1C6;
+}
 
 .oils_rpt_tab_table {
        width: 100%;
@@ -128,6 +137,7 @@ button:active {
        border: 1px solid #808080;
        border-collapse: collapse;
        text-align: center;
+       font-weight: bold;
 }
 
 .oils_rpt_tab_table td {
@@ -237,10 +247,12 @@ button:active {
 
 #oils_rpt_param_editor_table td {
        border: 1px solid #808080;
+       padding: 2px;
 }
 
 #oils_rpt_param_editor_table thead td {
        font-weight: bold;
+       text-align: center;
 }
 
 .oils_rpt_folder_tree {
@@ -285,6 +297,19 @@ button:active {
 .oils_rpt_generic_table { width: 100%; }
 .oils_rpt_generic_table td { border: 1px solid #808080; padding: 5px; }
 
+#oils_rpt_content_count_row_2 {
+       border-top: 2px solid #808080;
+       border-bottom: 1px solid #808080;
+       padding-top: 10px;
+       margin-top: 10px;
+}
+
 
+#oils_rpt_editor_table tr {
+       border-bottom: 1px solid #D0D0D0;
+}
 
+#oils_rpt_editor_table tr td {
+       border-left: 1px solid #808080;
+}
 
index 32325a3..7754cfb 100644 (file)
@@ -69,19 +69,22 @@ function oilsReport(templateObj, reportObj) {
 
        this.params     = {};
        this.name       = "";
-       this.templateObject = templateObj;
        this.reportObject = reportObj;
 
-       if( templateObj ) {
-               this.def = JSON2js(templateObj.data());
-               this.name = templateObj.name();
-       }
+       if(templateObj) this.setTemplate(templateObj);
 
        if( reportObj ) 
                this.params = JSON2js(reportObj.data());
        if(!this.params) this.params = {};
 }
 
+
+oilsReport.prototype.setTemplate = function(template) {
+       this.def                = JSON2js(template.data());
+       this.name       = template.name();
+       this.templateObject = template;
+}
+
 oilsReport.prototype.toString = function() {
        return formatJSON(js2JSON(this));
 }
index dbeb6c8..3b58958 100644 (file)
@@ -82,7 +82,7 @@
                                                </div>
                                        </td>
 
-                                       <td id='oils_rpt_folder_table_alt_td' class='hide_me'>
+                                       <td id='oils_rpt_folder_table_alt_td' class='hide_me' valign='top'>
                                                <div class='oils_rpt_folder_window'>
                                                        <!--#include virtual="oils_rpt_editor.xhtml"-->
                                                </div>
index 2debd1a..31790e1 100644 (file)
@@ -10,12 +10,60 @@ function oilsInitReportBuilder() {
                function() { 
                        hideMe(DOM.oils_rpt_tree_loading); 
                        unHideMe(DOM.oils_rpt_table); 
+                       oilsRptBuilderDrawClone(new CGI().param('ct'));
                }
        );
 
        DOM.oils_rpt_builder_save_template.onclick = oilsReportBuilderSave;
 }
 
+function oilsRptBuilderDrawClone(templateId) {
+       if(!templateId) return;
+       unHideMe(DOM.oils_rpt_builder_cloning);
+
+       oilsRptFetchTemplate(templateId,
+               function(template) { oilsRptBuilderDrawClone2(template);}
+       );
+}
+
+
+function oilsRptBuilderDrawClone2(template) {
+       //oilsRpt.
+       appendClear( DOM.oils_rpt_build_cloning_name, template.name() );
+       DOM.oils_rpt_builder_new_name.value = template.name();
+       DOM.oils_rpt_builder_new_desc.value = template.description();
+
+       _debug(formatJSON(template.data()));
+
+       /* manually shove data into the display selectors */
+       var def = JSON2js(template.data());
+
+       var table = def.from.table;
+       var node;
+       for( var i in oilsIDL ) {
+               node = oilsIDL[i];
+               if( node.table == table ) {
+                       setSelector(DOM.oils_rpt_builder_type_selector, node.name);
+                       DOM.oils_rpt_builder_type_selector.onchange();
+                       break;
+               }
+       }
+
+       iterate(def.select,
+               function(item) {
+                       oilsAddRptDisplayItem(item.path, item.alias, item.column.transform)});
+
+       iterate(def.where,
+               function(item) {
+                       oilsAddRptFilterItem(item.path, item.column.transform, oilsRptObjectKeys(item.condition)[0])});
+
+       iterate(def.having,
+               function(item) {
+                       oilsAddRptHavingItem(item.path, item.column.transform, oilsRptObjectKeys(item.condition)[0])});
+
+       oilsRpt.setTemplate(template);
+}
+
 function oilsReportBuilderReset() {
        var n = (oilsRpt) ? oilsRpt.name : "";
        oilsRpt = new oilsReport();
@@ -46,13 +94,18 @@ function oilsReportBuilderSave() {
        //return; /* XXX */
 
        var req = new Request(OILS_RPT_CREATE_TEMPLATE, SESSION, tmpl);
+       req.request.alertEvent = false;
        req.callback(
                function(r) {
                        var res = r.getResultObject();
-                       if( res && res != '0' ) {
-                               oilsRptAlertSuccess();
-                               _l('oils_rpt.xhtml');
-                       } 
+                       if(checkILSEvent(res)) {
+                               alertILSEvent(res);
+                       } else {
+                               if( res && res != '0' ) {
+                                       oilsRptAlertSuccess();
+                                       _l('oils_rpt.xhtml');
+                               } 
+                       }
                }
        );
        
@@ -573,6 +626,10 @@ function oilsRptHideEditorDivs() {
        hideMe(DOM.oils_rpt_filter_div);
        hideMe(DOM.oils_rpt_agg_filter_div);
        hideMe(DOM.oils_rpt_order_by_div);
+
+       removeCSSClass(DOM.oils_rpt_tform_tab.parentNode, 'oils_rpt_tab_picker_selected');
+       removeCSSClass(DOM.oils_rpt_filter_tab.parentNode, 'oils_rpt_tab_picker_selected');
+       removeCSSClass(DOM.oils_rpt_agg_filter_tab.parentNode, 'oils_rpt_tab_picker_selected');
 }
 
 
@@ -592,7 +649,10 @@ function oilsRptDrawDataWindow(path) {
 
        var div = DOM.oils_rpt_column_editor;
        /* set a preliminary top position so the page won't bounce around */
-       div.setAttribute('style','top:'+oilsMouseX+'px');
+
+
+       /* XXX */
+       //div.setAttribute('style','top:'+oilsMouseX+'px');
 
        /* unhide the div so we can determine the dimensions */
        unHideMe(div);
@@ -605,7 +665,10 @@ function oilsRptDrawDataWindow(path) {
        oilsRptDrawHavingWindow(path, col, cls, field);
        oilsRptDrawOrderByWindow(path, col, cls, field);
 
-       buildFloatingDiv(div, 600);
+       //buildFloatingDiv(div, 600);
+
+       //window.scrollTo(0,0);
+       window.scrollTo(0, 60);
 
        /* now let them see it */
        div.style.visibility='visible';
@@ -615,12 +678,27 @@ function oilsRptDrawDataWindow(path) {
 
 function oilsRptSetDataWindowActions(div) {
        /* give the tab links behavior */
+
+
        DOM.oils_rpt_tform_tab.onclick = 
-               function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_tform_div)};
+               function(){
+                       oilsRptHideEditorDivs();
+                       unHideMe(DOM.oils_rpt_tform_div)
+                       addCSSClass(DOM.oils_rpt_tform_tab.parentNode, 'oils_rpt_tab_picker_selected');
+               };
+
        DOM.oils_rpt_filter_tab.onclick = 
-               function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_filter_div)};
+               function(){
+                       oilsRptHideEditorDivs();
+                       unHideMe(DOM.oils_rpt_filter_div)
+                       addCSSClass(DOM.oils_rpt_filter_tab.parentNode, 'oils_rpt_tab_picker_selected');
+               };
        DOM.oils_rpt_agg_filter_tab.onclick = 
-               function(){oilsRptHideEditorDivs();unHideMe(DOM.oils_rpt_agg_filter_div)};
+               function(){
+                       oilsRptHideEditorDivs();
+                       unHideMe(DOM.oils_rpt_agg_filter_div)
+                       addCSSClass(DOM.oils_rpt_agg_filter_tab.parentNode, 'oils_rpt_tab_picker_selected');
+               };
 
        /*
        DOM.oils_rpt_order_by_tab.onclick = 
index 73f6060..d145589 100644 (file)
@@ -21,6 +21,9 @@
 
                <div>
                        <a class='oils_rpt_main_link' href='javascript:_l("oils_rpt.xhtml");'>Reports Home</a>
+                       <span id='oils_rpt_builder_cloning' class='hide_me' style='padding-left: 10px;'>
+                               (<b>Cloning template "<span id='oils_rpt_build_cloning_name'/>"</b>)
+                       </span>
                </div>
 
                <div id='oils_rpt_tree_loading'>
@@ -80,7 +83,7 @@
 
                        <table id='oils_rpt_editor_tab_table' class='oils_rpt_tab_table'><tbody>
                                <tr>
-                                       <td width='25%'><a id='oils_rpt_tform_tab' href='javascript:void(0);'>Display Items</a></td>
+                                       <td width='25%' class='oils_rpt_tab_picker_selected'><a id='oils_rpt_tform_tab' href='javascript:void(0);'>Display Items</a></td>
                                        <td width='25%'><a id='oils_rpt_filter_tab' href='javascript:void(0);'>Filters</a></td>
                                        <td width='25%'><a id='oils_rpt_agg_filter_tab' href='javascript:void(0);'>Aggregate Filters</a></td>
                                        <!--
index f5def67..71fba14 100644 (file)
@@ -1,32 +1,44 @@
 <div id='oils_rpt_editor_div'>
-       <table width='100%'>
+       <table width='100%' id='oils_rpt_editor_table'>
                <tbody>
                        <tr>
-                               <td>Template Name:</td>
-                               <td><b id='oils_rpt_report_editor_template_name'/></td>
+                               <th>Template Name:</th>
+                               <td><span id='oils_rpt_report_editor_template_name'/></td>
                        </tr>
                        <tr>
-                               <td>Template Creator:</td>
-                               <td><b id='oils_rpt_report_editor_template_creator'/></td>
+                               <th>Template Creator:</th>
+                               <td><span id='oils_rpt_report_editor_template_creator'/></td>
                        </tr>
                        <tr>
-                               <td>Template Description:</td>
-                               <td><b id='oils_rpt_report_editor_template_description'/></td>
+                               <th>Template Description:</th>
+                               <td><span id='oils_rpt_report_editor_template_description'/></td>
                        </tr>
 
                        <tr>
-                               <td>Report Name:</td>
-                               <td><input type='text' id='oils_rpt_report_editor_name'/></td>
+                               <th>Report Name:</th>
+                               <script>
+                                       var oils_rpt_report_editor_name_func = function(obj) {
+                                               if(obj.value) removeCSSClass(obj, OILS_RPT_INVALID_DATA);
+                                               else addCSSClass(obj, OILS_RPT_INVALID_DATA);
+                                       }
+                               </script>
+                               <td>
+                                       <input type='text' id='oils_rpt_report_editor_name' class='oils_rpt_invalid_input'
+                                               onkeyup='oils_rpt_report_editor_name_func(this);' 
+                                               onchange='oils_rpt_report_editor_name_func(this);'/>
+                               </td>
                        </tr>
                        <tr>
-                               <td>Report Description:</td>
+                               <th>Report Description:</th>
                                <td><textarea cols='45' rows='2' id='oils_rpt_report_editor_desc'/></td>
                        </tr>
                        <tr>
-                               <td>Report Columns:</td>
+                               <th>Report Columns:</th>
                                <td><b id='oils_rpt_report_editor_cols'/></td>
                        </tr>
+                       <!--
                        <tr><td colspan='2'><hr/></td></tr>
+                       -->
                        <tr>
                                <th>Choose a folder to store this report definition: </th>
                                <td>
                                        <span id='oils_rpt_report_editor_dest_folder'/>
                                </td>
                        </tr>
+                       <!--
                        <tr><td colspan='2'><hr/></td></tr>
+                       -->
                        <tr>
-                               <td colspan='2'>
+                               <td colspan='2' style='padding: 10px;'>
                                        <!--#include virtual="oils_rpt_param_editor.xhtml"-->
                                </td>
                        </tr>
+                       <!--
                        <tr><td colspan='2'><hr/></td></tr>
+                       -->
+                       <!--
                        <tr>
                                <th colspan='2'>Output Options</th>
                        </tr>
+                       -->
                        <tr>
                                <td colspan='2'>
+                                       <div><b>Output Options</b></div>
                                        <ul>
                                                <li><input type="checkbox" id="oils_rpt_format_excel" value="t" checked="checked"/><span>Excel Output</span></li>
                                                <li><input type="checkbox" id="oils_rpt_format_csv" value="t"/><span>CSV Output</span></li>
 
                                </td>
                        </tr>
+                       <!--
                        <tr><td colspan='2'><hr/></td></tr>
+                       -->
                        <tr>
-                               <td colspan='2'>
-                                       <table>
-                                               <tbody>
-                                                       <tr>
-                                                               <th>
-                                                                       <span>Run ASAP </span>
-                                                                               <input type='checkbox' id='oils_rpt_report_editor_run_now'/>
-                                                                       <span> or at :</span>
-                                                               </th>
-                                                               <td>
-                                                                       <input id="oils_rpt_param_editor_sched_start_date" type="text" size="10"/>
-                                                                               at
-                                                                       <select id='oils_rpt_param_editor_sched_start_hour'>
-                                                                               <option value="00:00">Midnight</option>
-                                                                               <option value="01:00">1 AM</option>
-                                                                               <option value="02:00">2 AM</option>
-                                                                               <option value="03:00">3 AM</option>
-                                                                               <option value="04:00">4 AM</option>
-                                                                               <option value="05:00">5 AM</option>
-                                                                               <option value="06:00">6 AM</option>
-                                                                               <option value="07:00">7 AM</option>
-                                                                               <option value="09:00">8 AM</option>
-                                                                               <option value="09:00">9 AM</option>
-                                                                               <option value="10:00">10 AM</option>
-                                                                               <option value="11:00">11 AM</option>
-                                                                               <option value="12:00">Noon</option>
-                                                                               <option value="13:00">1 PM</option>
-                                                                               <option value="14:00">2 PM</option>
-                                                                               <option value="15:00">3 PM</option>
-                                                                               <option value="16:00">4 PM</option>
-                                                                               <option value="17:00">5 PM</option>
-                                                                               <option value="18:00">6 PM</option>
-                                                                               <option value="19:00">7 PM</option>
-                                                                               <option value="20:00">8 PM</option>
-                                                                               <option value="21:00">9 PM</option>
-                                                                               <option value="22:00">10 PM</option>
-                                                                               <option value="23:00">11 PM</option>
-                                                                       </select>
-                                                               </td>
-                                                       </tr>
-                                                       <tr>
-                                                               <th>Send completion notification to this Email address:</th>
-                                                               <td><input id="oils_rpt_param_editor_sched_email" type="text" size="25"/></td>
-                                                       </tr>
-                                                       <tr>
-                                                               <th>Choose a folder to store this report's output: </th>
-                                                               <td>
-                                                                       <div style='margin-bottom: 7px;'>
-                                                                               <span>Selected Folder: </span>
-                                                                               <b id='oils_rpt_output_selected_folder'/>
-                                                                       </div>
-                                                                       <span id='oils_rpt_output_dest_folder'/>
-                                                               </td>
-                                                       </tr>
-                                               </tbody>
-                                       </table>
+                               <th>Recurring Report: </th>
+                               <td>
+                                       <input type="checkbox" id="oils_rpt_recur" value="t"
+                                               onclick='
+                                                       if(this.checked) {
+                                                               DOM.oils_rpt_recur_count.disabled = false;
+                                                               DOM.oils_rpt_recur_interval_type.disabled = false;
+                                                       } else {
+                                                               DOM.oils_rpt_recur_count.disabled = true;
+                                                               DOM.oils_rpt_recur_interval_type.disabled = true;
+                                                       }
+                                       '/>
+                               </td>
+                       </tr>
+                       <tr>
+                               <th>Recurrence Interval: </th>
+                               <td>
+                                       <select id="oils_rpt_recur_count" disabled='disabled'>
+                                               <option value='1'>1</option>
+                                               <option value='2'>2</option>
+                                               <option value='3'>3</option>
+                                               <option value='4'>4</option>
+                                               <option value='5'>5</option>
+                                               <option value='6'>6</option>
+                                               <option value='7'>7</option>
+                                               <option value='8'>8</option>
+                                               <option value='9'>9</option>
+                                               <option value='10'>10</option>
+                                               <option value='11'>11</option>
+                                               <option value='12'>12</option>
+                                               <option value='13'>13</option>
+                                               <option value='14'>14</option>
+                                               <option value='15'>15</option>
+                                               <option value='16'>16</option>
+                                               <option value='17'>17</option>
+                                               <option value='18'>18</option>
+                                               <option value='19'>19</option>
+                                               <option value='20'>20</option>
+                                               <option value='21'>21</option>
+                                               <option value='22'>22</option>
+                                               <option value='23'>23</option>
+                                               <option value='24'>24</option>
+                                       </select>
+                                       <select id="oils_rpt_recur_interval_type" disabled='disabled'>
+                                               <option value="days">Day(s)</option>
+                                               <option value="weeks">Week(s)</option>
+                                               <option value="months">Month(s)</option>
+                                       </select>
                                </td>
                        </tr>
                        <tr>
+                               <th>
+                                       <span>Run ASAP </span>
+                                               <input type='checkbox' id='oils_rpt_report_editor_run_now'
+                                                       onclick='
+                                                               if(this.checked) {
+                                                                       DOM.oils_rpt_param_editor_sched_start_date.disabled = true;
+                                                                       DOM.oils_rpt_param_editor_sched_start_hour.disabled = true;
+                                                               } else {
+                                                                       DOM.oils_rpt_param_editor_sched_start_date.disabled = false;
+                                                                       DOM.oils_rpt_param_editor_sched_start_hour.disabled = false;
+                                                               }
+                                                       '
+                                               />
+                                       <span> or at: </span>
+                               </th>
+                               <td>
+                                       <input id="oils_rpt_param_editor_sched_start_date" type="text" size="10"/>
+                                               at
+                                       <select id='oils_rpt_param_editor_sched_start_hour'>
+                                               <option value="00:00">Midnight</option>
+                                               <option value="01:00">1 AM</option>
+                                               <option value="02:00">2 AM</option>
+                                               <option value="03:00">3 AM</option>
+                                               <option value="04:00">4 AM</option>
+                                               <option value="05:00">5 AM</option>
+                                               <option value="06:00">6 AM</option>
+                                               <option value="07:00">7 AM</option>
+                                               <option value="09:00">8 AM</option>
+                                               <option value="09:00">9 AM</option>
+                                               <option value="10:00">10 AM</option>
+                                               <option value="11:00">11 AM</option>
+                                               <option value="12:00">Noon</option>
+                                               <option value="13:00">1 PM</option>
+                                               <option value="14:00">2 PM</option>
+                                               <option value="15:00">3 PM</option>
+                                               <option value="16:00">4 PM</option>
+                                               <option value="17:00">5 PM</option>
+                                               <option value="18:00">6 PM</option>
+                                               <option value="19:00">7 PM</option>
+                                               <option value="20:00">8 PM</option>
+                                               <option value="21:00">9 PM</option>
+                                               <option value="22:00">10 PM</option>
+                                               <option value="23:00">11 PM</option>
+                                       </select>
+                               </td>
+                       </tr>
+                       <tr>
+                               <th>Send completion notification to this Email address: </th>
+                               <td><input id="oils_rpt_param_editor_sched_email" type="text" size="25"/></td>
+                       </tr>
+                       <tr>
+                               <th>Choose a folder to store this report's output: </th>
+                               <td>
+                                       <div style='margin-bottom: 7px;'>
+                                               <span>Selected Folder: </span>
+                                               <b id='oils_rpt_output_selected_folder'/>
+                                       </div>
+                                       <span id='oils_rpt_output_dest_folder'/>
+                               </td>
+                       </tr>
+
+                       <tr>
                                <td colspan='2'>
                                        <input id='oils_rpt_report_editor_save' type='submit' value='Save Report'/>
                                </td>
index 5e902dd..3efef31 100644 (file)
@@ -19,14 +19,21 @@ oilsRptFolderWindow.prototype.draw = function() {
 
        var obj = this;
        setSelector(DOM.oils_rpt_output_limit_selector, oilsRptOutputLimit);
+       setSelector(DOM.oils_rpt_output_limit_selector_2, oilsRptOutputLimit2);
 
        DOM.oils_rpt_output_limit_selector.onchange = function() {
                oilsRptOutputLimit = getSelectorVal(DOM.oils_rpt_output_limit_selector);
                obj.draw();
        }
 
+       DOM.oils_rpt_output_limit_selector_2.onchange = function() {
+               oilsRptOutputLimit2 = getSelectorVal(DOM.oils_rpt_output_limit_selector_2);
+               obj.draw();
+       }
+
+       var mine = ( this.folderNode.folder.owner().id() == USER.id() );
 
-       if( this.folderNode.folder.owner().id() == USER.id() && this.type == 'template') 
+       if( mine  && this.type == 'template') 
                unHideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode);
        else hideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode);
 
@@ -59,6 +66,12 @@ oilsRptFolderWindow.prototype.draw = function() {
        var x = true;
        for( var i = 0; i < sel.options.length; i++ ) {
                var opt = sel.options[i];
+
+               if( !mine && opt.getAttribute('value').match(/move/) ) {
+                       hideMe(opt);
+                       continue;
+               }
+
                if( opt.getAttribute('type') == this.type ) {
                        if(x && !opt.disabled) {
                                opt.selected = true;
@@ -79,7 +92,8 @@ oilsRptFolderWindow.prototype.drawEditActions = function() {
 
        DOM.oils_rpt_folder_window_contents_new_template.onclick = function() {
                var s = location.search+'';
-               s = s.replace(/\&folder=\d+/,'');
+               s = s.replace(/\&folder=\d+/g,'');
+               s = s.replace(/\&ct=\d+/g,'');
                goTo( 'oils_rpt_builder.xhtml'+s+'&folder='+obj.folderNode.folder.id());
        }
 
@@ -186,7 +200,11 @@ oilsRptFolderWindow.prototype.hideFolderActions = function() {
 
 
 oilsRptFolderWindow.prototype.doFolderAction = function() {
-       var objs = this.fmTable.getSelected();
+       var objs = (this.fmTable) ? this.fmTable.getSelected() : [];
+
+       if( this.type == 'output' && this.fmTable2 ) 
+               objs = objs.concat( this.fmTable2.getSelected() );
+
        if( objs.length == 0 ) 
                return alert('Please select an item from the list');
        var action = getSelectorVal(DOM.oils_rpt_folder_contents_action_selector);
@@ -225,6 +243,93 @@ oilsRptFolderWindow.prototype.doFolderAction = function() {
                        this.deleteOutputs(objs,0, successCallback);
                        break;
 
+               case 'move_template':
+                       this.changeBatchFolder(objs, 'template', successCallback);
+                       break;
+
+               case 'move_report':
+                       this.changeBatchFolder(objs, 'report', successCallback);
+                       break;
+
+               case 'move_output':
+                       this.changeBatchFolder(objs, 'output', successCallback);
+                       break;
+
+               case 'clone_template':
+                       this.cloneTemplate(objs[0]);
+       }
+}
+
+oilsRptFolderWindow.prototype.changeBatchFolder = function(objs, type, callback) {
+       hideMe(DOM.oils_rpt_folder_window_contents_table);
+       unHideMe(DOM.oils_rpt_move_folder_div)
+       var obj = this;
+       this.drawFolderOptions(type,    
+               function(folderid) {
+                       obj.changeFolderList(objs, type, folderid, 0, callback);
+                       hideMe(DOM.oils_rpt_move_folder_div)
+                       unHideMe(DOM.oils_rpt_folder_window_contents_table);
+               }
+       );
+}
+
+oilsRptFolderWindow.prototype.cloneTemplate = function(template) {
+       hideMe(DOM.oils_rpt_folder_window_contents_table);
+       unHideMe(DOM.oils_rpt_move_folder_div)
+       var obj = this;
+       this.drawFolderOptions('template',
+               function(folderid) {
+                       var s = location.search+'';
+                       s = s.replace(/\&folder=\d+/g,'');
+                       s = s.replace(/\&ct=\d+/g,'');
+                       goTo('oils_rpt_builder.xhtml'+s+'&folder='+folderid+'&ct='+template.id());
+               }
+       );
+}
+
+
+oilsRptFolderWindow.prototype.changeFolderList = function(list, type, folderid, idx, callback, errid) {
+       if( idx >= list.length ) return callback(errid);
+       var item = list[idx];
+       var obj = this;
+       var rcback = function(){obj.changeFolderList(list,type,folderid,++idx,callback,errid)};
+
+       item.folder(folderid);
+
+       switch(type) {
+               case 'template':
+                       oilsRptUpdateTemplate(item,rcback);
+                       break;
+               case 'report':
+                       oilsRptUpdateReport(item,rcback);
+                       break;
+               case 'output':
+                       oilsRptUpdateSchedule(item,rcback);
+                       break;
+       }
+}
+
+oilsRptFolderWindow.prototype.drawFolderOptions = function(type, callback) {
+       //var oilsRptChangeFolderTree;
+       var selectedFolder;
+       oilsRptBuildFolder(
+               type,
+               DOM.oils_rpt_move_folder_picker,
+               'tree9807897',
+               'Change Folders',
+               function(node) { 
+                       appendClear(DOM.oils_rpt_move_folder_selected, node.folder.name());
+                       selectedFolder = node.folder.id();
+               } 
+       );
+
+       DOM.oils_rpt_change_folder_submit.onclick = function() {
+               if(selectedFolder) callback(selectedFolder);
+       }
+
+       DOM.oils_rpt_change_folder_cancel.onclick = function() {
+               hideMe(DOM.oils_rpt_move_folder_div)
+               unHideMe(DOM.oils_rpt_folder_window_contents_table);
        }
 }
 
@@ -247,10 +352,16 @@ oilsRptFolderWindow.prototype.deleteOutputs = function(list, idx, callback, erri
 }
 
 oilsRptFolderWindow.prototype.showOutput = function(sched) {
-       oilsRptFetchReport(sched.report(), 
+       oilsRptFetchReport(sched.report().id()
                function(r) {
                        var url = oilsRptBuildOutputLink(r.template(), r.id(), sched.id());
-                       goTo(url);
+                       _debug("launching report output view at URL: " + url);
+                       if(isXUL()) 
+                               xulG.new_tab(url,{"tab_name":"Report Output: " + r.name()},{})
+                       else {
+                               //goTo(url);
+                               var win = window.open(url,r.name(), 'resizable,width=800,height=600,scrollbars=1'); 
+                       }
                }
        );
 }
@@ -338,13 +449,21 @@ oilsRptFolderWindow.prototype.drawFolderDetails = function() {
 
 
 oilsRptFolderWindow.prototype.fetchFolderData = function(callback) {
+
+       hideMe(DOM.oils_rpt_content_count_row_2);
+       hideMe(DOM.oils_rpt_content_row_2);
+
        removeChildren(this.selector);
        var req = new Request(OILS_RPT_FETCH_FOLDER_DATA, 
                SESSION, this.type, this.folderNode.folder.id(), oilsRptOutputLimit);
 
+       hideMe(DOM.oils_rpt_pending_output);
+
        if(this.type == 'output') {
+               unHideMe(DOM.oils_rpt_pending_output);
+               /* first fetch the non-complete schedules */
                req = new Request(OILS_RPT_FETCH_OUTPUT, 
-                       SESSION, this.folderNode.folder.id(), oilsRptOutputLimit);
+                       SESSION, this.folderNode.folder.id(), oilsRptOutputLimit, 0);
        }
 
        var obj = this;
@@ -352,9 +471,22 @@ oilsRptFolderWindow.prototype.fetchFolderData = function(callback) {
        req.callback(
                function(r) {
                        var res = r.getResultObject();
+
+                       if( res.length == 0 ) {
+                               hideMe(DOM.oils_rpt_content_count_row);
+                               hideMe(DOM.oils_rpt_content_row);
+                               unHideMe(DOM.oils_rpt_content_row_empty);
+                       } else {
+                               unHideMe(DOM.oils_rpt_content_count_row);
+                               unHideMe(DOM.oils_rpt_content_row);
+                               hideMe(DOM.oils_rpt_content_row_empty);
+                       }
+
                        if( obj.type == 'output' ) {
-                               obj.fleshSchedules(res, 0);
+                               obj.fleshSchedules(res, 0, obj.selector);
                        } else {
+
+
                                obj.fmTable = drawFMObjectTable( 
                                        { 
                                                dest : obj.selector, 
@@ -369,10 +501,41 @@ oilsRptFolderWindow.prototype.fetchFolderData = function(callback) {
                }
        );
        req.send();
+
+       if( this.type != 'output' ) return;
+
+       /*
+       unHideMe(DOM.oils_rpt_content_count_row_2);
+       unHideMe(DOM.oils_rpt_content_row_2);
+       */
+
+       /* now fetch the completed schedules */
+       req = new Request(OILS_RPT_FETCH_OUTPUT, 
+               SESSION, this.folderNode.folder.id(), oilsRptOutputLimit2, 1);
+
+       _debug("TRYING: fleshing finished scheds with div: " + DOM.oils_rpt_folder_contents_selector_2);
+       removeChildren(DOM.oils_rpt_folder_contents_selector_2);
+       req.callback(
+               function(r) {
+                       var res = r.getResultObject();
+
+                       if( res.length == 0 ) {
+                               hideMe(DOM.oils_rpt_content_count_row_2);
+                               hideMe(DOM.oils_rpt_content_row_2);
+                       } else {
+                               unHideMe(DOM.oils_rpt_content_count_row_2);
+                               unHideMe(DOM.oils_rpt_content_row_2);
+                       }
+
+                       _debug("fleshing finished scheds with div: " + DOM.oils_rpt_folder_contents_selector_2);
+                       obj.fleshSchedules(res, 0, DOM.oils_rpt_folder_contents_selector_2, true);
+               }
+       );
+       req.send();
 }
 
 
-oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) {
+oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, selector, isSecond) {
 
        if( idx >= list.length ) return;
 
@@ -388,9 +551,10 @@ oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) {
                                function(template) {
                                        sched.report().template(template);
                                        if( idx == 0 ) {
-                                               obj.fmTable = drawFMObjectTable( 
+                                               _debug("drawing schedule with output: "+selector);
+                                               var t = drawFMObjectTable( 
                                                        { 
-                                                               dest : obj.selector, 
+                                                               dest : selector, 
                                                                obj : [sched],
                                                                selectCol : true,
                                                                selectColName : 'Select',
@@ -398,10 +562,17 @@ oilsRptFolderWindow.prototype.fleshSchedules = function(list, idx, table) {
                                                                selectNoneName : 'None'
                                                        }
                                                );
+
+                                               if( isSecond ) obj.fmTable2 = t;
+                                               else obj.fmTable = t;
+
                                        } else {
-                                               obj.fmTable.add(sched);
+                                               //obj.fmTable.add(sched);
+                                               if( isSecond ) obj.fmTable2.add(sched);
+                                               else obj.fmTable.add(sched);
                                        }
-                                       obj.fleshSchedules(list, ++idx);
+
+                                       obj.fleshSchedules(list, ++idx, selector, isSecond);
                                }
                        );
                }
index 629f12f..e04ce8c 100644 (file)
                                        <span>
                                                <select id='oils_rpt_folder_contents_action_selector' style='width: auto;'>
                                                        <option type='template' value='create_report'>Create a new report from selected template</option>
-                                                       <option type='template' value='clone_template' disabled='disabled'>Clone selected template</option>
+                                                       <option type='template' value='clone_template'>Clone selected template</option>
                                                        <option type='template' value='delete_template'>Delete selected template(s)</option>
                                                        <option type='report' value='change_params' disabled='disabled'>Clone report</option>
                                                        <option type='report' value='schedule_report' disabled='disabled'>Schedule report</option>
                                                        <option type='report' value='delete_report'>Delete selected report(s)</option>
                                                        <option type='output' value='show_output'>View report output</option>
                                                        <option type='output' value='delete_output'>Delete selected output(s)</option>
+
+                                                       <option type='template' value='move_template'>Move the selected template(s) to a different folder</option>
+                                                       <option type='report' value='move_report'>Move the select report(s) to a different folder</option>
+                                                       <option type='output' value='move_output'>Move the selected output(s) to a different folder</option>
                                                </select>
                                        </span>
                                        <input type='submit' value='Submit' id='oils_rpt_folder_content_action_go'/>
                                </td>
                        </tr>
 
-                       <tr>
+                       <tr id='oils_rpt_content_count_row'>
                                <td style='text-align:left;'>
                                        <div>
                                                Limit output to 
@@ -37,6 +41,7 @@
                                                        <option value='50'>50</option>
                                                        <option value=''>All</option>
                                                </select>
+                                               <span><b id='oils_rpt_pending_output' class='hide_me'>Pending Items</b></span>
                                        </div>
                                </td>
                                <td style='text-align:right;'>
                                </td>
                        </tr>
 
-                       <tr class='oils_rpt_folder_window_contents_row'>
+                       <tr class='oils_rpt_folder_window_contents_row' id='oils_rpt_content_row'>
                                <td colspan='2'>
                                        <div id='oils_rpt_folder_contents_selector'/>
                                </td>
                        </tr>
 
+                       <tr class='hide_me' id='oils_rpt_content_row_empty'>
+                               <td style='text-align:left;'><b>No items to display</b></td>
+                       </tr>
+
+
+                       <!-- =================================================================== -->
+                       <!--  Second set of folder data for schedule objects that have completed-->
+                       <!-- =================================================================== -->
+                       <tr id='oils_rpt_content_count_row_2' class='hide_me'>
+                               <td style='text-align:left;padding-top: 20px;'>
+                                       <div>
+                                               Limit output to 
+                                               <select id='oils_rpt_output_limit_selector_2'>
+                                                       <option value='5'>5</option>
+                                                       <option value='10'>10</option>
+                                                       <option value='25'>25</option>
+                                                       <option value='50'>50</option>
+                                                       <option value=''>All</option>
+                                               </select>
+                                               <span><b>Completed Items</b></span>
+                                       </div>
+                               </td>
+                       </tr>
+
+                       <tr class='oils_rpt_folder_window_contents_row hide_me' id='oils_rpt_content_row_2'>
+                               <td colspan='2'>
+                                       <div id='oils_rpt_folder_contents_selector_2'/>
+                               </td>
+                       </tr>
+                       <!-- =================================================================== -->
+
                </tbody>
        </table>
 
+       <div id='oils_rpt_move_folder_div' class='hide_me' style='width:100%; padding: 5px; margin-left: 10px;'>
+               <div>Selected Folder: <b id='oils_rpt_move_folder_selected'/></div>
+               <hr/>
+               <div id='oils_rpt_move_folder_picker'/>
+               <hr/>
+               <input type='submit' value='Select Folder' id='oils_rpt_change_folder_submit'/>
+               <input type='submit' value='Cancel' id='oils_rpt_change_folder_cancel'/>
+       </div>
+
        <span class='hide_me' id='oils_rpt_folder_contents_confirm_delete'>
                Are you sure you wish to delete the selected item(s)?
        </span>
                You may not delete another user's items
        </span>
 
+       <span class='hide_me' id='oils_rpt_change_folder_not_allowed'>
+               You may not move another user's items
+       </span>
+
+
 </div>
 
index b29457b..7f522d3 100644 (file)
@@ -6,13 +6,18 @@ function oilsRptParamEditor(report, tbody) {
 
 
 oilsRptParamEditor.prototype.recur = function() {
-       var cb = $n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur');
+       //var cb = $n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur');
+       var cb = DOM.oils_rpt_recur;
        return (cb.checked) ? 't' : 'f';
 }
 
 oilsRptParamEditor.prototype.recurInterval = function() {
+       /*
        var count = getSelectorVal($n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur_count'));
        var intvl = getSelectorVal($n(DOM.oils_rpt_recur_editor_table,'oils_rpt_recur_interval_type'));
+       */
+       var count = getSelectorVal(DOM.oils_rpt_recur_count);
+       var intvl = getSelectorVal(DOM.oils_rpt_recur_interval_type);
        return count+''+intvl;
 }
 
@@ -37,36 +42,9 @@ oilsRptParamEditor.prototype.draw = function() {
                $n(row, 'action').appendChild(text(OILS_RPT_FILTERS[par.op].label));
                par.widget = this.buildWidget(par, $n(row, 'widget'));
                par.widget.draw();
-               //this.buildRelWidget(par, row);
        }
 }
 
-
-/* display the time-relative options if necessary */
-/*
-oilsRptParamEditor.prototype.buildRelWidget = function(par, row) {
-
-       var field = oilsRptFindField(
-               oilsIDL[oilsRptPathClass(par.path)], oilsRptPathCol(par.path));
-
-       _debug('checking rel widget for datatype '+field.datatype);
-
-       if(field.datatype != 'timestamp') return;
-       if(par.op != '=') return;
-
-       var dom = $n(row,'reldate_div');
-       unHideMe(dom);
-       par.relWidget = new oilsRptRelDatePicker({node:$n(dom,'reldate'),relative:true});
-       par.relWidget.draw();
-       var cb = $n(row,'choose_rel');
-       cb.onclick = function() {
-               par.relWidgetChecked = false;
-               if( cb.checked ) par.relWidgetChecked = true;
-       }
-}
-*/
-
-
 oilsRptParamEditor.prototype.buildWidget = function(param, node) {
        var transform = param.column.transform;
        var cls = oilsRptPathClass(param.path);
@@ -80,6 +58,7 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node) {
        var widgetArgs  = {node:node};
        widgetArgs.calFormat = OILS_RPT_TRANSFORMS[transform].cal_format;
        widgetArgs.inputSize = OILS_RPT_TRANSFORMS[transform].input_size;
+       widgetArgs.regex = OILS_RPT_TRANSFORMS[transform].regex;
 
        switch(transform) {
                case 'date':
@@ -196,31 +175,8 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node) {
                default:
                        return new atomicWidget(widgetArgs);
        }
-
-       /*
-       switch(param.op) {
-               case 'in':
-               case 'not in':
-                       if( cls == 'aou' ) {
-                               return new oilsRptOrgMultiSelect({node:node});
-                       } else {
-                               return new oilsRptInputMultiWidget({node:node});
-                       }
-               case 'between':
-                       return new oilsRptMultiInputWidget({node:node});
-
-               default:
-                       switch(dtype) {
-                               case 'timestamp':
-                                       return new oilsRptWidget({node:node});
-                               default:
-                                       return new oilsRptWidget({node:node});
-                       }
-       }
-       */
 }
 
-//oilsRptParamEditor.prototype.get = function(param, node) {
 
 
 
index a6f54d0..0cc3831 100644 (file)
@@ -3,6 +3,7 @@
                <b id='oils_rpt_param_editor_report_name'> </b>
        </div>
 
+       <!--
        <table id='oils_rpt_recur_editor_table'>
                <tbody>
                        <tr>
@@ -39,9 +40,6 @@
                                                <option value='24'>24</option>
                                        </select>
                                        <select name="oils_rpt_recur_interval_type">
-                                               <!--
-                                               <option value="hours">Hour(s)</option>
-                                               -->
                                                <option value="days">Day(s)</option>
                                                <option value="weeks">Week(s)</option>
                                                <option value="months">Month(s)</option>
@@ -50,6 +48,7 @@
                        </tr>
                </tbody>
        </table>
+       -->
 
        <table id='oils_rpt_param_editor_table'>
                <thead>
index b038ceb..62bef6b 100644 (file)
@@ -84,8 +84,18 @@ oilsRptReportEditor.prototype.save = function() {
                var par = this.paramEditor.params[p];
                _debug("adding report param "+par.key+" to report data");
                var val = par.widget.getValue();
+
                if(!val || val.length == 0 )
                        return alertId('oils_rpt_empty_param');
+
+               if( typeof val == 'object') {
+                       for( var i = i; i < val.length; i++ ) {
+                               _debug("looking at widget value" + val[i]);
+                               if( val[i] == '' || val[i] == null ) 
+                                       return alertId('oils_rpt_empty_param');
+                       }
+               }
+
                data[par.key] = val;
        }
 
@@ -141,10 +151,14 @@ oilsRptReportEditor.prototype.save = function() {
        req.callback(
                function(r) {
                        var res = r.getResultObject();
-                       if( res && res != '0' ) {
-                               oilsRptAlertSuccess();
-                               oilsRptCurrentFolderManager.draw();
-                               obj.folderWindow.draw();
+                       if(checkILSEvent(res)) {
+                               alertILSEvent(res);
+                       } else {
+                               if( res && res != '0' ) {
+                                       oilsRptAlertSuccess();
+                                       oilsRptCurrentFolderManager.draw();
+                                       obj.folderWindow.draw();
+                               }
                        }
                }
        );
index 0e75523..6cf1aef 100644 (file)
@@ -127,14 +127,17 @@ function print_tabs(t) {
 
 
 function oilsRptDebug() {
+       if(!oilsRptDebugEnabled) return;
+
        _debug("\n-------------------------------------\n");
        _debug(oilsRpt.toString());
        _debug("\n-------------------------------------\n");
-       if(!oilsRptDebugEnabled) return;
+
+       /*
        if(!oilsRptDebugWindow)
                oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1'); 
-
        oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString();
+       */
 }
 
 
@@ -198,6 +201,8 @@ function buildFloatingDiv(div, width) {
                top = oilsMouseY - div.clientHeight - 10;
        }
        div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px');
+       //div.setAttribute('style', 'top:'+top+'px;');
+       //alert(DOM.oils_rpt_filter_selector.style.top);
 }
 
 
@@ -281,6 +286,31 @@ function oilsRptCreateFolder(folder, type, callback) {
        }
 }
 
+function oilsRptUpdateTemplate(template, callback) {
+       oilsRptDoGenericUpdate(OILS_RPT_UPDATE_TEMPLATE, template, callback);
+}
+
+function oilsRptUpdateReport(report, callback) {
+       oilsRptDoGenericUpdate(OILS_RPT_UPDATE_REPORT, report, callback);
+}
+
+function oilsRptUpdateSchedule(schedule, callback) {
+       oilsRptDoGenericUpdate(OILS_RPT_UPDATE_SCHEDULE, schedule, callback);
+}
+
+function oilsRptDoGenericUpdate( method, arg, callback ) {
+       _debug("generic update running: "+method);
+       var req = new Request(method, SESSION, arg);
+       req.callback(
+               function(r) {
+                       if( r.getResultObject() > 0 )
+                               callback(true);
+                       else callback(false);
+               }
+       );
+       req.send();
+}
+
 /*
 function oilsRptFetchReport(id, callback) {
        var req = new Request(OILS_RPT_FETCH_REPORT, SESSION, id);
index 2348829..3059786 100644 (file)
@@ -23,7 +23,9 @@ var oilsRptSharedReportFolderTree;
 var oilsRptSharedOutputFolderTree;
 
 var oilsRptOutputLimit = 10;
+var oilsRptOutputLimit2 = 10;
 
+var OILS_RPT_INVALID_DATA = 'oils_rpt_invalid_input';
 
 /* URL to retrieve the IDL from */
 var OILS_IDL_URL = "/reports/fm_IDL.xml";
@@ -84,6 +86,7 @@ var OILS_RPT_CREATE_TEMPLATE          = 'open-ils.reporter:open-ils.reporter.template.cr
 var OILS_RPT_CREATE_SCHEDULE           = 'open-ils.reporter:open-ils.reporter.schedule.create';
 var OILS_RPT_UPDATE_REPORT                     = 'open-ils.reporter:open-ils.reporter.report.update';
 var OILS_RPT_UPDATE_TEMPLATE           = 'open-ils.reporter:open-ils.reporter.template.update';
+var OILS_RPT_UPDATE_SCHEDULE           = 'open-ils.reporter:open-ils.reporter.schedule.update';
 var OILS_RPT_FETCH_OUTPUT                      = 'open-ils.reporter:open-ils.reporter.schedule.retrieve_by_folder';
 var OILS_RPT_FETCH_REPORT                      = 'open-ils.reporter:open-ils.reporter.report.retrieve';
 var OILS_RPT_FETCH_TEMPLATE            = 'open-ils.reporter:open-ils.reporter.template.retrieve';
index 8bc9428..74eb53b 100644 (file)
@@ -1,250 +1,5 @@
-/*
-oilsRptSetSubClass('oilsRptWidget', 'oilsRptObject');
-oilsRptWidget.OILS_RPT_TRANSFORM_WIDGET = 0;
-oilsRptWidget.OILS_RPT_OPERATION_WIDGET = 1;
-
-function oilsRptWidget(args) {
-       this.initWidget(args);
-       this.dest = elem('input',{type:'text'});
-}
-
-oilsRptWidget.prototype.initWidget = function(args) {
-       if(!args) return;
-       this.init();
-       this.node       = args.node;
-       this.type       = args.type;
-       this.action = args.action;
-       this.column     = args.column;
-}
-
-oilsRptWidget.prototype.getValue = function() {
-       return this.dest.value ;
-}
-
-oilsRptWidget.prototype.draw = function() {
-       appendClear(this.node, this.dest);
-}
-
-oilsRptSetSubClass('oilsRptMultiInputWidget', 'oilsRptWidget');
-function oilsRptMultiInputWidget(args) {
-       this.initInputWidget(args);
-}
-
-oilsRptMultiInputWidget.prototype.initInputWidget = function(args) {
-       if(!args) return;
-       this.initWidget(args);
-       this.count = (args.count) ? args.count : 2;
-       this.dest = [];
-       for( var i = 0; i < this.count; i++ )
-               this.dest.push(elem('input',{type:'text',size:10}));
-}
-
-oilsRptMultiInputWidget.prototype.getValue = function() {
-       var vals = [];
-       for( var i = 0; i < this.dest.length; i++ )
-               vals.push(this.dest[i].value);
-       return vals;
-}
-
-oilsRptMultiInputWidget.prototype.draw = function() {
-       removeChildren(this.node);
-       for( var i = 0; i < this.dest.length; i++ ) {
-               if( this.label )
-                       this.node.appendChild(this.label[i]);
-               this.node.appendChild(this.dest[i]);
-       }
-}
-
-oilsRptMultiInputWidget.prototype.setLabels = function(labels) {
-       this.labels = labels;   
-}
-
-
-
-
-oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget');
-function oilsRptMultiWidget(args) {
-       this.initMultiWidget(args);
-}
-
-oilsRptMultiWidget.prototype.initMultiWidget = function(args) {
-       if(!args) return;
-       this.initWidget(args);
-       this.dest = elem('select',
-               {multiple:'multiple','class':'oils_rpt_small_info_selector'});
-
-       var obj = this;
-
-       this.addButton = elem('input',{type:'submit',value:"Add"})
-       this.addButton.onclick = this.getSourceCollector();
-       this.delButton = elem('input',{type:'submit',value:"Del"})
-       this.delButton.onclick = function(){obj.removeSelected()};
-}
-
-oilsRptMultiWidget.prototype.getValue = function() {
-       var vals = [];
-       for( var i = 0; i < this.dest.options.length; i++ )
-               vals.push(this.dest.options[i].value);
-       return vals;
-}
-
-oilsRptMultiWidget.prototype.removeSelected = function() {
-       oilsDelSelectedItems(this.dest);
-}
-
-oilsRptMultiWidget.prototype.addItem = function(name, val) {
-       for( var i = 0; i < this.dest.options.length; i++ ) {
-               if( this.dest.options[i].value == val ) 
-                       return;
-       }
-       insertSelectorVal(this.dest, -1, name, val);
-}
-
-oilsRptMultiWidget.prototype.setSource = function(src) {
-       this.source = src;
-}
-
-oilsRptMultiWidget.prototype.drawMultiWidget = function() {
-       appendClear(this.node, this.source);
-       this.node.appendChild(elem('br'))
-       this.node.appendChild(this.addButton);
-       this.node.appendChild(this.delButton);
-       this.node.appendChild(elem('br'))
-       this.node.appendChild(this.dest);
-}
-
-oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget');
-function oilsRptInputMultiWidget(args) {
-       this.initInputMultiWidget(args);
-}
-oilsRptInputMultiWidget.prototype.initInputMultiWidget = function(args) {
-       if(!args) return;
-       this.initMultiWidget(args);
-       this.setSource(elem('input',{type:'text'}));
-}
-
-oilsRptInputMultiWidget.prototype.draw = function() {
-       this.drawMultiWidget();
-}
-
-oilsRptInputMultiWidget.prototype.getSourceCollector = function() {
-       var obj = this;
-       return function() {
-               obj.addItem(obj.source.value, obj.source.value);
-       }
-}
-
-
-
-oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget');
-function oilsRptSelectorMultiWidget(args) {
-       this.initSelectorMultiWidget(args);
-}
-oilsRptSelectorMultiWidget.prototype.initSelectorMultiWidget = function(args) {
-       if(!args) return;
-       this.initMultiWidget(args);
-       this.setSource(
-               elem('select',{multiple:'multiple', 'class':'oils_rpt_small_info_selector'}));
-}
-
-oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() {
-       var obj = this;
-       return function() {
-               for( var i = 0; i < obj.source.options.length; i++ ) {
-                       if( obj.source.options[i].selected )
-                               obj.addItem(obj.source.options[i].innerHTML, 
-                                       obj.source.options[i].value);
-               }
-       }
-}
-*/
-
-/* ----------------------------------------------------------- */
-
-/*
-oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget');
-function oilsRptRemoteWidget(args) {
-       this.initRemoteWidget(args);
-}
-oilsRptRemoteWidget.prototype.initRemoteWidget = function(args) {
-       if(!args) return;
-       this.initSelectorMultiWidget(args);
-       this.selector = args.selector;
-}
-
-oilsRptRemoteWidget.prototype.draw = function() {
-       this.fetch();
-       //this.draw();
-}
-
-oilsRptRemoteWidget.prototype.setFetch = function(func) {
-       this.fetch = func;
-}
-*/
-
-
-
-
-/* --------------------------------------------------------------------- */
-/*
-oilsRptSetSubClass('oilsRptOrgMultiSelect','oilsRptSelectorMultiWidget');
-function oilsRptOrgMultiSelect(args) {
-       this.initSelectorMultiWidget(args);
-}
-oilsRptOrgMultiSelect.prototype.draw = function(org) {
-       if(!org) org = globalOrgTree;
-       var opt = insertSelectorVal( this.source, -1, 
-               org.shortname(), org.id(), null, findOrgDepth(org) );
-       if( org.id() == oilsRptCurrentOrg )
-               opt.selected = true;
-       if( org.children() ) {
-               for( var c = 0; c < org.children().length; c++ )
-                       this.draw(org.children()[c]);
-       }
-       this.drawMultiWidget();
-}
-*/
-
-
-
-/* --------------------------------------------------------------------- */
-/*
-function oilsRptRelDatePicker(args) {
-       this.node = args.node;
-       this.relative = args.relative;
-       this.div = DOM.oils_rpt_relative_date_picker.cloneNode(true);
-}
-
-oilsRptRelDatePicker.prototype.draw = function() {
-       this.node.appendChild(this.div);
-       unHideMe(this.div);
-}
-
-oilsRptRelDatePicker.prototype.getValue = function() {
-       var str = 
-               getSelectorVal($n(this.div, 'count')) + 
-               getSelectorVal($n(this.div,'type'));
-       if( this.relative ) str = '-'+str;
-       return str;
-}
-*/
-/* --------------------------------------------------------------------- */
-
-
-
-
-
-
-
-
-/* --------------------------------------------------------------------- */
-/* --------------------------------------------------------------------- */
-
-
-
-
 /* --------------------------------------------------------------------- 
-       Represents a set of value, an inputWidget collects data and a 
+       Represents a set of values, an inputWidget collects data and a 
        multi-select displays the data and allows the user to remove items
        --------------------------------------------------------------------- */
 function oilsRptSetWidget(args) {
@@ -319,7 +74,7 @@ oilsRptSetWidget.prototype.strToObj = function(str) {
 
 /* --------------------------------------------------------------------- 
        represents a widget that has start and end values.  start and end
-       are gather from start/end widgets
+       are gathered from start/end widgets
        --------------------------------------------------------------------- */
 function oilsRptBetweenWidget(args) {
        this.node = args.node;
@@ -356,6 +111,7 @@ oilsRptBetweenWidget.prototype.getValue = function() {
 function oilsRptTextWidget(args) {
        this.node = args.node;
        this.dest = elem('input',{type:'text',size:12});
+       oilsRptMonitorWidget(this.dest);
 }
 oilsRptTextWidget.prototype.draw = function() {
        this.node.appendChild(this.dest);
@@ -401,6 +157,34 @@ oilsRptBoolWidget.prototype.getDisplayValue = function() {
 }
 
 
+/* If you monitor a text widget with this function, it 
+       will style the input differently to indicate the
+       field needs data.  If a regex is provided, it will
+       style the field differently until the data matches 
+       the regex.  The style comes from OILS_RPT_INVALID_DATA. */
+function oilsRptMonitorWidget(input, regex) {
+       addCSSClass(input, OILS_RPT_INVALID_DATA);
+       var func = function() {
+               var val = input.value;
+               if(!val) {
+                       addCSSClass(input, OILS_RPT_INVALID_DATA);
+               } else {
+                       if( regex ) {
+                               if( val && val.match(regex) ) 
+                                       removeCSSClass(input, OILS_RPT_INVALID_DATA);
+                               else
+                                       addCSSClass(input, OILS_RPT_INVALID_DATA);
+                       } else {
+                               removeCSSClass(input, OILS_RPT_INVALID_DATA);
+                       }
+               }
+       }
+
+       input.onkeyup = func;
+       input.onchange = func;
+}
+
+
 
 
 /* --------------------------------------------------------------------- 
@@ -411,6 +195,8 @@ function oilsRptCalWidget(args) {
        this.calFormat = args.calFormat;
        this.input = elem('input',{type:'text',size:12});
 
+       oilsRptMonitorWidget(this.input, args.regex);
+
        if( args.inputSize ) {
                this.input.setAttribute('size',args.inputSize);
                this.input.setAttribute('maxlength',args.inputSize);
@@ -470,7 +256,7 @@ oilsRptOrgSelector.prototype.draw = function(org) {
 
 oilsRptOrgSelector.prototype.getValue = function() {
        var vals = [];
-       iterate(this.selector,
+       iterate(this.selector, /* XXX this.selector.options?? */
                function(o){
                        if( o.selected )
                                vals.push(o.getAttribute('value'))
@@ -501,8 +287,12 @@ function oilsRptAgeWidget(args) {
 }
 
 oilsRptAgeWidget.prototype.draw = function() {
+
+       //insertSelectorVal(this.count, -1, ' -- Select One -- ', '');
        for( var i = 1; i < 25; i++ )
                insertSelectorVal(this.count, -1, i, i);
+
+       //insertSelectorVal(this.type, -1, ' -- Select One -- ', '');
        insertSelectorVal(this.type, -1, 'Day(s)', 'days');
        insertSelectorVal(this.type, -1, 'Month(s)', 'months');
        insertSelectorVal(this.type, -1, 'Year(s)', 'years');
@@ -537,29 +327,17 @@ function oilsRptNumberWidget(args) {
        this.node = args.node;
        this.size = args.size || 32;
        this.start = args.start;
-       /*
-       var len = new String(this.size).length;
-       _debug('length = ' + len);
-       this.input = elem('input',{type:'text',size: len});
-       */
        this.selector = elem('select');
 }
 oilsRptNumberWidget.prototype.draw = function() {
+       //insertSelectorVal(this.selector, -1, ' -- Select One -- ', '');
        for( var i = this.start; i < (this.size + this.start); i++ )
                insertSelectorVal(this.selector, -1, i, i);
        this.node.appendChild(this.selector);
-       //this.node.appendChild(this.input);
        var obj = this;
-       /*
-       this.selector.onchange = function() {
-               obj.input.value = getSelectorVal(obj.selector);
-       }
-       this.input.value = getSelectorVal(this.selector);
-       */
 }
 
 oilsRptNumberWidget.prototype.getValue = function() {
-       //return this.input.value;
        return getSelectorVal(this.selector);
 }