00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <string>
00015 #include "cgiClass.h"
00016
00017 #include "connectstring"
00018 using namespace std;
00019
00020
00021 string baseUrl;
00022 #include "../admin/Promotion.hpp"
00023 #include "page.hpp"
00024 #include "read_write_base.hpp"
00025 #include "forms_base.hpp"
00026 #include "Session.hpp"
00027 #include "page_control.hpp"
00028
00029
00030 Session_Obj * gSession = 0;
00031
00032 class Promotion_form: public Promotion_Obj, public forms_base
00033 {
00034 public:
00035 Promotion_form(cgiScript & script):Promotion_Obj(),forms_base(script){setKey(*this);}
00036 virtual ~Promotion_form(){;}
00037
00038 void form_id_transfer( void )
00039 {
00040 llongFXfer( "Id", Id );
00041 }
00042 void form_data_transfer( void )
00043 {
00044 stringFXfer( "CUUID", UUID);
00045 }
00046
00047 bool dbf_action( string mode, changeMap & changes )
00048 {
00049 string clause="UUID='"+UUID+"'";
00050 if( get_data(clause) && gSession )
00051 {
00052 Session_Obj & sess = *gSession;
00053 ocString promoId;
00054 promoId.append(Id);
00055 sess.SetData( "Promotion", promoId.c_str() );
00056 sess.Synch();
00057 return true;
00058 }
00059 return false;
00060 }
00061
00062
00063 bool form_display( void )
00064 {
00065 bool breturn = true;
00066 ocString sql;
00067
00068 script << makeTop("Promotions.meta", "Please Enter your Promotion Coupon string");
00069 script << makeHiddenBox( "Id", Id );
00070 script << makeTextBox("Coupon:", "CUUID", "","125","35");
00071
00072 script << "<input type='button' onclick='forms[0].submit()' value=' OK '></div></form>";
00073
00074 return breturn;
00075 }
00076 };
00077
00078 bool intraMain(page & pg ,cgiScript & script)
00079 {
00080 Promotion_form myFrm(script);
00081
00082
00083 myFrm.loadControlTemplates("Templates/divform.htmp");
00084 if( myFrm.form_action() == false )
00085 {
00086 myFrm.form_display();
00087 }
00088 else
00089 {
00090 script << "<h2>" << myFrm.Name << "</h2>" << endl
00091 << "<p>" << myFrm.Description << "</p>" << endl;
00092 }
00093 return true;
00094 }
00095 class free_form_functor: public base_functor
00096 {
00097 cgiScript & script;
00098
00099 public:
00100
00101 free_form_functor(page & ipg,cgiScript & script )
00102 :base_functor(ipg)
00103 ,script(script)
00104 {;}
00105 virtual ~free_form_functor(){;}
00106
00107 virtual bool operator()( xmlNode & node )
00108 {
00109 bool bRet = false;
00110 if( script.ClientArguments().count("CUUID") == 0 )
00111 {
00112
00113 ocString uuidCheck;
00114 page_paragraphs & paras = pg.get_page_paragraphs();
00115 paragraph_vector::iterator pos;
00116 for( pos=paras.begin(); pos!=paras.end(); ++pos )
00117 {
00118 uuidCheck = pos->name();
00119 if( uuidCheck.regExMatch("^CUUID") )
00120 {
00121 string uuid = uuidCheck.substr(6);
00122
00123 script.ClientArguments()["CUUID"] = uuid.c_str();
00124 break;
00125 }
00126 }
00127 }
00128
00129 bRet = intraMain( pg, script);
00130 return bRet;
00131 }
00132
00133 };
00134
00135
00136
00137
00138 int main(int argc, char ** argv)
00139 {
00140 baseUrl = "Promotions.meta";
00141
00142 cgiScript script("text/html",false);
00143 gSession = new Session_Obj();
00144 script.closeHeader();
00145
00146 page pg(script);
00147
00148
00149 if( pg.load() )
00150 {
00151 page_control ctrl(pg);
00152
00153 ctrl.addOp ( "detail", new free_form_functor(pg,script) );
00154 ctrl.emit();
00155 }
00156 else
00157 {
00158 script << "<html><head><title>Page Unavailable</title></head>" << endl
00159 << "<body><h1>Sorry</h1>" << endl
00160 << "<p>The page you requested is not available</p></body></html>";
00161 }
00162
00163 delete gSession;
00164
00165 return 0;
00166 }
00167
00168
00169 #include "read_write_base.cpp"
00170 #include "forms_base.cpp"
00171