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