00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
00012 #include <iomanip>
00013 #include "cgiClass.h"
00014 #include "cgiTemplates.h"
00015 #include "connectstring"
00016 #include "forms.h"
00017 #include "ocTypes.h"
00018 #include "ocString.h"
00019 #include "cgiTemplates.h"
00020
00021 #include "read_write_base.hpp"
00022 #include "superlist_base.hpp"
00023 #include "forms_base.hpp"
00024 #include "Promotion.hpp"
00025 #include "openLogin.h"
00026
00027 using namespace std;
00028 openLogin oLogin;
00029
00030
00031 class Promotion_List: public list_base
00032 {
00033 public:
00034
00035 Promotion_List(cgiScript&sc,Session_Obj & session):list_base(sc,session){;}
00036 ~Promotion_List(){;}
00037
00038 bool list_display( void )
00039 {
00040 bool breturn = true;
00041
00042 hotCol=-2;
00043 editLink = listTemplate.getParagraph("hotcolumn");
00044 editLink = editLink.replace("$prog$","Promotion_ui.cgi");
00045 emitFilter( "Promotion_ui.cgi",
00046 "<h5>Promotions · Search by Name</h5>" );
00047 string heading =
00048 "<a class='sortcol' href='Promotion_ui.cgi?sort=Id'>Id</a>|"
00049 "<a class='sortcol' href='Promotion_ui.cgi?sort=Name'>Name</a>|"
00050 "<a class='sortcol' href='Promotion_ui.cgi?sort=Description'>Description</a>|"
00051 "<a class='sortcol' href='Promotion_ui.cgi?sort=UUID'>UUID</a>|"
00052 "<a class='sortcol' href='Promotion_ui.cgi?sort=Percent_Discount'>Percent Discount</a>|"
00053 "<a class='sortcol' href='Promotion_ui.cgi?sort=Free_Shipping'>Free Shipping?</a>|"
00054 "<a class='sortcol' href='Promotion_ui.cgi?sort=Percent_Commission'>Percent Commission</a>"
00055 ;
00056 emitHeadings(heading);
00057 getFilteredData(
00058 "Id, "
00059 "Name, "
00060 "Description, "
00061 "UUID, "
00062 "Percent_Discount, "
00063 "Free_Shipping, "
00064 "Percent_Commission "
00065 ,"Promotion",
00066 "Name like '$filter$%'" );
00067 emitData();
00068 emitNavigation("Promotion_ui.cgi");
00069 emitEnd();
00070 return breturn;
00071 }
00072 virtual void sendHotField( int iField, ocString & td )
00073 {
00074 ocString data = rs.getField(iField).format();
00075 if( iField == 5 ) data=data=="1"?"Yes":"No";
00076 webIO << td.replace( "$data$",
00077 editLink.replaceAll( "$key$",rs.getField(0).format().c_str())
00078 .replaceAll( "$col$",data.c_str()).c_str());
00079 }
00080 };
00081
00082 class Promotion_form: public Promotion_Obj, public forms_base
00083 {
00084 public:
00085 Promotion_form(cgiScript & script):Promotion_Obj(),forms_base(script){setKey(*this);}
00086 virtual ~Promotion_form(){;}
00087
00088 void form_id_transfer( void )
00089 {
00090 llongFXfer( "Id", Id );
00091 }
00092 void form_data_transfer( void )
00093 {
00094 stringFXfer( "Name", Name);
00095 stringFXfer( "Description", Description);
00096 stringFXfer( "UUID", UUID);
00097 doubleFXfer( "Percent_Discount", Percent_Discount);
00098 boolFXfer( "Free_Shipping", Free_Shipping);
00099 doubleFXfer( "Percent_Commission", Percent_Commission);
00100
00101 }
00102
00103 bool dbf_action( string mode, changeMap & changes )
00104 {
00105 return db_action( mode, changes );
00106 }
00107
00108
00109 bool form_display( void )
00110 {
00111 bool breturn = true;
00112 ocString sql;
00113
00114 script << makeTop("Promotion_ui.cgi", "Promotion")
00115 << formTemplate.getParagraph("advanced_begin");
00116 script << makeStaticBox("Id", "Id", Id ,"8");
00117 script << "<br class='clearall'>" << endl;
00118 script << formTemplate.getParagraph("advanced_end");
00119
00120 script << makeTextBox("Name", "Name", Name ,"125","35");
00121 script << "<br class='clearall'>" << endl;
00122 script << makeTextArea("Description", "Description", Description ,"5","80");
00123 script << "<br class='clearall'>" << endl;
00124 script << makeTextBox("UUID", "UUID", UUID ,"125","35");
00125 script << "<br class='clearall'>" << endl;
00126 script << makeTextBox("Percent Discount", "Percent_Discount", Percent_Discount ,"16","16");
00127 script << "<br class='clearall'>" << endl;
00128 script << makeBoolBox("Free Shipping?", "Free_Shipping", Free_Shipping );
00129 script << "<br class='clearall'>" << endl;
00130 script << makeTextBox("Percent Commission", "Percent_Commission", Percent_Commission ,"16","16");
00131 script << "<br class='clearall'>" << endl;
00132
00133 script << makeButtons( key() );
00134 script << makeBottom( m_result ) << endl;
00135 return breturn;
00136 }
00137 };
00138
00139 int main( int argcount, char ** args )
00140 {
00141 cgiScript script( "text/html", false );
00142 Promotion_form myFrm(script);
00143 Promotion_List mylist(script,oLogin.Session());
00144 if( oLogin.testLoginStatus() )
00145 {
00146 script.closeHeader();
00147 cgiTemplates pgTemplate;
00148 pgTemplate.load("Templates/adminPane.htmp");
00149
00150 script << ocString(pgTemplate.getParagraph("top"))
00151 .replaceAll("$heading$","Promotion");
00152
00153 myFrm.loadControlTemplates("Templates/divform.htmp");
00154 myFrm.form_action();
00155 myFrm.form_display();
00156
00157 mylist.loadListTemplates("Templates/list.htmp");
00158 mylist.list_display();
00159
00160 ocString end = pgTemplate.getParagraph("bottom");
00161 script << end;
00162 }
00163 else
00164 {
00165 script.Redirect("signIn.html");
00166 }
00167 }
00168
00169 #include "read_write_base.cpp"
00170 #include "forms_base.cpp"
00171
00172
00173