00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <string>
00014
00015 #include "openLogger.h"
00016 using namespace std;
00017
00018
00019 string baseUrl;
00020 #include "connectstring"
00021 #include "w3intranet.h"
00022 #include "reform_base.hpp"
00023
00024 bool Report_Parameters_form::hasParamValues = false;
00025
00026 void paramForm(cgiScript & script, Report_Parameters_form & param_form, string reportName )
00027 {
00028
00029 cgiTemplates pgTemplate;
00030
00031 if( ! pgTemplate.load("Templates/reportPane.htmp") )
00032 {
00033 script << "<h2>could not load Templates/reportPane.htmp</h2>" << endl;
00034 }
00035
00036 script << ocString(pgTemplate.getParagraph("top"))
00037 .replaceAll("$heading$","Reports");
00038
00039 if( !param_form.loadControlTemplates("Templates/repform.htmp") )
00040 {
00041 {
00042 script << "<h2>could not load Templates/repform.htmp</h2>" << endl;
00043 }
00044 }
00045 param_form.reportName = reportName;
00046 param_form.form_display();
00047 ocString end = pgTemplate.getParagraph("bottom");
00048 script << end;
00049 }
00050
00051 bool redirectToHTMLDoc( cgiScript & script, string mimeType )
00052 {
00053 bool doRedirect = false;
00054 ocString qs = script.QueryString().c_str();
00055 doRedirect = ( mimeType == "application/pdf" && qs.regExMatch("isPDF") == false );
00056 if( doRedirect )
00057 {
00058 cgiInput & args = script.ClientArguments();
00059
00060 string redir = "/htmldoc.cgi";
00061 redir += script.ScriptName().c_str();
00062 redir += "?isPDF=1";
00063 if( args.TheMap().size() > 0 )
00064 {
00065
00066 for( queryStringMap::iterator pos = args.TheMap().begin();
00067 pos != args.TheMap().end();
00068 )
00069 {
00070 redir += "&";
00071 redir += pos->first;
00072 redir += "=";
00073 redir += pos->second.c_str();
00074 ++pos;
00075 if( pos != args.TheMap().end() )
00076 {
00077 ocString paramTest = pos->first;
00078 if( paramTest == "xmldirections" )
00079 {
00080 break;
00081 }
00082 }
00083 }
00084 }
00085 script.Redirect( redir.c_str() );
00086 script.closeHeader();
00087 }
00088 return doRedirect;
00089 }
00090 void showErr( cgiScript & script, string err )
00091 {
00092 script.closeHeader();
00093 script << err << endl;
00094 }
00095
00096 int main(int argc, char ** argv)
00097 {
00098 baseUrl = "Formation.meta";
00099
00100
00101 cgiScript script("text/html",false);
00102 bool isSignedOn = check(script);
00103
00104
00105 if( isSignedOn )
00106 {
00107
00108 if (script.ClientArguments().count("Id")==1)
00109 {
00110 string strId = script.ClientArguments()["Id"].c_str();
00111 if( strId.length() )
00112 {
00113 Report_Obj report;
00114 report.Id = atoll(strId.c_str());
00115 report.key(report.Id);
00116 if( report.get_data() )
00117 {
00118
00119 Report_Parameters_form param_form(script);
00120 param_form.Report_Id = report.Id;
00121 param_form.get();
00122 if( param_form.haveFormValues() == false )
00123 {
00124 script.closeHeader();
00125 paramForm(script,param_form,report.Name);
00126 }
00127 else if( ! redirectToHTMLDoc( script, report.getMediaType() ) )
00128 {
00129 string path = "reportTemplates/" + report.getTemplatePath();
00130 string sql = report.getCompositeQuery();
00131 sql = param_form.paramFilters( sql );
00132 reform_base basis(script);
00133 basis.loadTemplate(path);
00134 if( basis.getData(sql) )
00135 {
00136 script.closeHeader();
00137 basis.emitData();
00138 } else showErr( script, "could not get report data" );
00139 }
00140 } else showErr(script, "could not get report");
00141 } else showErr(script, "no report id val" );
00142 } else showErr(script, "no report id var" );
00143 } else showErr(script, "not signed in" );
00144 return 0;
00145 }
00146
00147
00148 #include "read_write_base.cpp"
00149 #include "forms_base.cpp"