00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <iostream>
00015 #include <iomanip>
00016 #include "cgiTemplates.h"
00017 #include "connectstring"
00018 #include "forms.h"
00019 #include "ocTypes.h"
00020 #include "ocString.h"
00021 #include "cgiTemplates.h"
00022
00023 #include "read_write_base.hpp"
00024 #include "list_base.hpp"
00025 #include "forms_base.hpp"
00026 #include "Customer.hpp"
00027 #include "openLogin.h"
00028
00029 using namespace std;
00030 openLogin oLogin;
00031
00032 class Customer_List: public list_base
00033 {
00034 public:
00035
00036 Customer_List(cgiScript&sc):list_base(sc){;}
00037 ~Customer_List(){;}
00038
00039 bool list_display( void )
00040 {
00041 bool breturn = true;
00042
00043 hotCol=-2;
00044 editLink = listTemplate.getParagraph("hotcolumn");
00045 editLink = editLink.replace("$prog$","Customer_ui.cgi");
00046 emitFilter( "Customer_ui.cgi",
00047 " <B>FILTER (by Last Name)</B>" );
00048 string heading =
00049 "<a class='sortcol' href='Customer_ui.cgi?sort=Id'>Id</a>|"
00050 "<a class='sortcol' href='Customer_ui.cgi?sort=First_Name'>First_Name</a>|"
00051 "<a class='sortcol' href='Customer_ui.cgi?sort=Last_Name'>Last_Name</a>|"
00052 "<a class='sortcol' href='Customer_ui.cgi?sort=EMail'>EMail</a>|"
00053 "<a class='sortcol' href='Customer_ui.cgi?sort=Password'>Password</a>|"
00054 "<a class='sortcol' href='Customer_ui.cgi?sort=Address'>Address</a>|"
00055 "<a class='sortcol' href='Customer_ui.cgi?sort=City'>City</a>|"
00056 "<a class='sortcol' href='Customer_ui.cgi?sort=State'>State</a>|"
00057 "<a class='sortcol' href='Customer_ui.cgi?sort=Zip'>Zip</a>|"
00058 "<a class='sortcol' href='Customer_ui.cgi?sort=Phone'>Phone</a>|"
00059
00060 ;
00061 emitHeadings(heading);
00062 getFilteredData(
00063 "Id, "
00064 "First_Name, "
00065 "Last_Name, "
00066 "EMail, "
00067 "Password, "
00068 "Address, "
00069 "City, "
00070 "State, "
00071 "Zip, "
00072 "Phone, "
00073 "Payment_Service_Id "
00074 ,"Customer",
00075 "Last_Name like '$filter$%'" );
00076 emitData();
00077 emitNavigation("Customer_ui.cgi");
00078 emitEnd();
00079 return breturn;
00080 }
00081 };
00082
00083 class Customer_form: public Customer_Obj, public forms_base
00084 {
00085 public:
00086 Customer_form(cgiScript & script):Customer_Obj(),forms_base(script){setKey(*this);}
00087 virtual ~Customer_form(){;}
00088
00089 void form_id_transfer( void )
00090 {
00091 llongFXfer( "Id", Id );
00092 }
00093 void form_data_transfer( void )
00094 {
00095 stringFXfer( "First_Name", First_Name);
00096 stringFXfer( "Last_Name", Last_Name);
00097 stringFXfer( "EMail", EMail);
00098 stringFXfer( "Password", Password);
00099 stringFXfer( "Address", Address);
00100 stringFXfer( "City", City);
00101 stringFXfer( "State", State);
00102 stringFXfer( "Zip", Zip);
00103 stringFXfer( "Phone", Phone);
00104 llongFXfer( "Payment_Service_Id", Payment_Service_Id);
00105
00106 }
00107
00108 bool dbf_action( string mode, changeMap & changes )
00109 {
00110 return db_action( mode, changes );
00111 }
00112
00113
00114 bool form_display( void )
00115 {
00116 bool breturn = true;
00117 ocString sql;
00118
00119 script << makeTop("Customer_ui.cgi", "Customer")
00120 << formTemplate.getParagraph("advanced_begin");
00121 script << makeStaticBox("Id", "Id", Id ,"8");
00122 script << "<br class='clearall'>" << endl;
00123 script << formTemplate.getParagraph("advanced_end");
00124
00125 script << makeTextBox("First_Name", "First_Name", First_Name ,"25");
00126 script << "<br class='clearall'>" << endl;
00127 script << makeTextBox("Last_Name", "Last_Name", Last_Name ,"25");
00128 script << "<br class='clearall'>" << endl;
00129 script << makeTextBox("EMail", "EMail", EMail ,"25");
00130 script << "<br class='clearall'>" << endl;
00131 script << makeTextBox("Password", "Password", Password ,"25");
00132 script << "<br class='clearall'>" << endl;
00133 script << makeTextBox("Address", "Address", Address ,"25");
00134 script << "<br class='clearall'>" << endl;
00135 script << makeTextBox("City", "City", City ,"25");
00136 script << "<br class='clearall'>" << endl;
00137 script << makeTextBox("State", "State", State ,"25");
00138 script << "<br class='clearall'>" << endl;
00139 script << makeTextBox("Zip", "Zip", Zip ,"25");
00140 script << "<br class='clearall'>" << endl;
00141 script << makeTextBox("Phone", "Phone", Phone ,"25");
00142 script << "<br class='clearall'>" << endl;
00143 sql="select Id,Name from Payment_Service";
00144 script << makeComboBox("Payment_Service_Id", "Payment_Service_Id", Payment_Service_Id ,sql);
00145 script << "<br class='clearall'>" << endl;
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 script << makeButtons( key() );
00168 script << makeBottom( m_result ) << endl;
00169 return breturn;
00170 }
00171 };
00172
00173
00174 int main( int argcount, char ** args )
00175 {
00176 cgiScript script( "text/html", false );
00177 Customer_form myFrm(script);
00178 Customer_List mylist(script);
00179 if( oLogin.testLoginStatus() )
00180 {
00181 script.closeHeader();
00182 cgiTemplates pgTemplate;
00183 pgTemplate.load("Templates/adminPane.htmp");
00184
00185 script << ocString(pgTemplate.getParagraph("top"))
00186 .replaceAll("$heading$","Customer");
00187
00188 myFrm.loadControlTemplates("Templates/divform.htmp");
00189 myFrm.form_action();
00190 myFrm.form_display();
00191
00192 mylist.loadListTemplates("Templates/list.htmp");
00193 mylist.list_display();
00194
00195 ocString end = pgTemplate.getParagraph("bottom");
00196 script << end;
00197 }
00198 else
00199 {
00200 script.Redirect("signIn.html");
00201 }
00202 }
00203
00204 #include "read_write_base.cpp"
00205 #include "forms_base.cpp"
00206
00207