00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
00012 #include <iomanip>
00013 #include "cgiTemplates.h"
00014 #include "connectstring"
00015 #include "forms.h"
00016 #include "ocTypes.h"
00017 #include "ocString.h"
00018 #include "cgiTemplates.h"
00019
00020 #include "Designer.hpp"
00021 #include "list_base.hpp"
00022 #include "forms_base.hpp"
00023
00024 #include "openLogin.h"
00025
00026 using namespace std;
00027 openLogin oLogin;
00028
00029 class Designer_List: public list_base
00030 {
00031 public:
00032 ocString Product_Id;
00033
00034 Designer_List(cgiScript&sc):list_base(sc){;}
00035 ~Designer_List(){;}
00036
00037 bool list_display( bool isThisProduct )
00038 {
00039 bool breturn = true;
00040
00041 hotCol=-2;
00042 editLink = listTemplate.getParagraph("hotcolumn");
00043 string url = "Designer_ui.cgi";
00044 if( !isThisProduct )
00045 {
00046 url += "?Product_Id=";
00047 url += Product_Id;
00048 url += "&";
00049 editLink = editLink.replace("$prog$?",url.c_str());
00050 }
00051 else
00052 {
00053 editLink = editLink.replace("$prog$",url.c_str());
00054 }
00055 string heading ="Id|Orientation|Y-Pixels|X-Pixels|Pattern|Design No";
00056 emitHeadings(heading);
00057 string q = "Select Id, Orientation, Pixel_Height, Pixel_Width, Pattern_Image, Design_No "
00058 " from Designer ";
00059
00060 if( isThisProduct )
00061 q += "where Product_Id = ";
00062 else
00063 q += "where Product_Id != ";
00064
00065 q += Product_Id;
00066 q += " order by Pattern_Image ";
00067
00068 webIO << "<!--" << q << "-->" << endl;
00069 getData( q );
00070 emitData();
00071 emitEnd();
00072 return breturn;
00073 }
00074 };
00075
00076 class Designer_form: public Designer_Obj, public forms_base
00077 {
00078 public:
00079 Designer_form(cgiScript & script):Designer_Obj(),forms_base(script){setKey(*this);}
00080 virtual ~Designer_form(){;}
00081
00082 void form_id_transfer( void )
00083 {
00084 llongFXfer( "Id", Id );
00085 }
00086 void form_data_transfer( void )
00087 {
00088 llongFXfer( "Product_Id", Product_Id);
00089 intFXfer( "Real_Height", Real_Height);
00090 intFXfer( "Real_Width", Real_Width);
00091 llongFXfer( "Size", Size);
00092 llongFXfer( "Style", Style);
00093 stringFXfer( "Orientation", Orientation);
00094 intFXfer( "Pixel_Height", Pixel_Height);
00095 intFXfer( "Pixel_Width", Pixel_Width);
00096 intFXfer( "Text_Top_Left_X", Text_Top_Left_X);
00097 intFXfer( "Text_Top_Left_Y", Text_Top_Left_Y);
00098 intFXfer( "Text_Bot_Right_X", Text_Bot_Right_X);
00099 intFXfer( "Text_Bot_Right_Y", Text_Bot_Right_Y);
00100 stringFXfer( "Pattern_Image", Pattern_Image);
00101 stringFXfer( "Design_No", Design_No);
00102 }
00103
00104 bool dbf_action( string mode, changeMap & changes )
00105 {
00106 changes["Size"]="Size";
00107 changes["Style"]="Style";
00108 changes["Orientation"]="Orientation";
00109 return db_action( mode, changes );
00110 }
00111
00112
00113 bool form_display( void )
00114 {
00115 bool breturn = true;
00116 ocString sql;
00117
00118
00119 ocString searchString = script.QueryString().c_str();
00120 if( searchString.find( "&Id" ) != string::npos )
00121 {
00122 key(Id=0);
00123 searchString.parse("=");
00124 string prodid = searchString.parse("&");
00125 Product_Id = atoll(prodid.c_str());
00126 }
00127 script << makeTop("Designer_ui.cgi", "Designer")
00128 << formTemplate.getParagraph("advanced_begin");
00129 script << makeStaticBox("Id", "Id", Id ,"8");
00130 script << "<br style='clear: left;'>" << endl;
00131 script << makeHiddenBox( "Product_Id", Product_Id );
00132 script << makeTextBox("Real Width", "Real_Width", Real_Width ,"8","8");
00133 script << makeTextBox("Height", "Real_Height", Real_Height ,"8","8");
00134 script << formTemplate.getParagraph("advanced_end");
00135 script << "<br style='clear: left;'>" << endl;
00136 if( Pattern_Image.length() )
00137 {
00138 script << "<img id='pattern' style='float: right;' src='../images/" << Pattern_Image <<
00139 "' alt=''>" << endl;
00140 }
00141 sql = "select s.Id, concat(s.X, 'x', s.Y, u.Abbreviation) from "
00142 "Size_Price s inner join Unit u on s.Units = u.Id "
00143 "inner join Product_Sizes ps on s.Id = ps.Size and ps.Product = ";
00144 sql.append(Product_Id);
00145 sql += " order by s.X, s.Y";
00146
00147 script << makeComboBox("Size", "Size", Size ,sql);
00148 script << "<br style='clear: left;'>" << endl;
00149
00150 sql = "select s.Id, s.Name from Style s where s.Product = ";
00151 sql.append(Product_Id);
00152 sql += " order by s.Name";
00153
00154 script << makeComboBox("Style", "Style", Style ,sql);
00155 script << "<br style='clear: left;'>" << endl;
00156
00157 script << makeManualComboBox( "Orientation", "Orientation", Orientation,
00158 "Horizontal=Horizontal,Vertical=Vertical", "", "");
00159
00160 script << "<br style='clear: left;'>" << endl;
00161
00162 script << makeTextBox("Pixel Width", "Pixel_Width", Pixel_Width ,"8","8");
00163 script << makeTextBox("Height", "Pixel_Height", Pixel_Height ,"8","8");
00164
00165 script << "<br style='clear: left;'>" << endl;
00166 script << "<h5>Text Area</h5>" << endl;
00167
00168 script << makeTextBox("Upper Left: X", "Text_Top_Left_X", Text_Top_Left_X ,"8","8");
00169 script << makeTextBox("Y", "Text_Top_Left_Y", Text_Top_Left_Y ,"8","8");
00170 script << "<br style='clear: left;'>" << endl;
00171 script << makeTextBox("Lower Right: X", "Text_Bot_Right_X", Text_Bot_Right_X ,"8","8");
00172 script << makeTextBox("Y", "Text_Bot_Right_Y", Text_Bot_Right_Y ,"8","8");
00173 script << "<br style='clear: left;'>" << endl;
00174 script << makeImageBox( "Pattern_Image", "Pattern_Image", Pattern_Image, "25" );
00175 script << "<br style='clear: left;'>" << endl;
00176 script << makeTextBox("Design No.", "Design_No", Design_No ,"125", "25");
00177 script << "<br style='clear: left;'>" << endl;
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 script << makeButtons( key() );
00200 script << makeBottom( m_result ) << endl;
00201 return breturn;
00202 }
00203 };
00204
00205
00206 int main( int argcount, char ** args )
00207 {
00208 cgiScript script( "text/html", false );
00209 Designer_form myFrm(script);
00210 Designer_List mylist(script);
00211 if( oLogin.testLoginStatus() )
00212 {
00213 script.closeHeader();
00214 cgiTemplates pgTemplate;
00215 pgTemplate.load("Templates/adminPane.htmp");
00216
00217 script << ocString(pgTemplate.getParagraph("top"))
00218 .replaceAll("$heading$","Designer");
00219
00220 myFrm.loadControlTemplates("Templates/divform.htmp");
00221 myFrm.form_action();
00222 myFrm.form_display();
00223 mylist.Product_Id.append(myFrm.Product_Id);
00224 mylist.loadListTemplates("Templates/list.htmp");
00225 mylist.list_display(true);
00226 script << "<h4>Import from other product:</h4>" << endl;
00227 mylist.list_display(false);
00228 ocString end = pgTemplate.getParagraph("bottom");
00229 script << end.replace( "/*_extra_js_*/",
00230 "var ptrnImage = myDom.getElementById('pattern');\n"
00231 "if( ptrnImage ) {\n"
00232 "document.forms['uiForm'].Pixel_Height.value = myDom.getElementById('pattern').height;\n"
00233 "ctrlChanged(document.forms['uiForm'].Pixel_Height)\n"
00234 "document.forms['uiForm'].Pixel_Width.value = myDom.getElementById('pattern').width;\n"
00235 "ctrlChanged(document.forms['uiForm'].Pixel_Width)\n"
00236 "myDom.addListener(ptrnImage,'mousedown', txtTop, true);"
00237 "myDom.addListener(ptrnImage,'mouseup', txtEnd, true);"
00238 "}\n"
00239 "}\n"
00240
00241 "function txtTop(evt) {"
00242 "document.forms['uiForm'].Text_Top_Left_X.value = evt.pageX - evt.target.x;"
00243 "document.forms['uiForm'].Text_Top_Left_Y.value = evt.pageY - evt.target.y;"
00244 "if (evt.preventDefault) { evt.preventDefault(); } return false;"
00245 "}\n"
00246 "function txtEnd(evt) {"
00247 "document.forms['uiForm'].Text_Bot_Right_X.value = evt.pageX - evt.target.x ;"
00248 "document.forms['uiForm'].Text_Bot_Right_Y.value = evt.pageY - evt.target.y ;"
00249
00250 );
00251 }
00252 else
00253 {
00254 script.Redirect("signIn.html");
00255 }
00256 }
00257
00258 #include "read_write_base.cpp"
00259 #include "forms_base.cpp"
00260
00261
00262
00263
00264
00265