00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ItemDetail_HPP
00016 #define ItemDetail_HPP
00017
00018 #include "../admin/Ordered_Item.hpp"
00019 #include "../admin/Product.hpp"
00020 #include "../admin/Size_Price.hpp"
00021 #include "../admin/Unit.hpp"
00022 #include "../admin/Style.hpp"
00023
00024 class ItemDetail
00025 {
00026 private:
00027
00028
00029
00030
00031 void extra()
00032 {
00033 if( m_Product )
00034 {
00035 Product_Obj product;
00036 product.key(m_Product);
00037 if( product.get_data() )
00038 {
00039 m_ProductName = product.Name;
00040 m_ProductDescription = product.Description;
00041 m_SKU = product.SKU;
00042 m_IsDesigner = product.Designer;
00043 m_LinesCustomText = product.Lines_Custom_Text;
00044 m_Manufacturer = product.Manufacturer;
00045 }
00046 else
00047 {
00048 m_ProductName = product.last_result();
00049 m_ProductName += " ! ";
00050 }
00051 }
00052 if( m_Size )
00053 {
00054 Size_Price_Obj szprc;
00055 szprc.key(m_Size);
00056 if( szprc.get_data() )
00057 {
00058 m_Price = szprc.Price;
00059 m_Shipping = szprc.Shipping;
00060 Unit_Obj unit;
00061 unit.key(szprc.Units);
00062 unit.get_data();
00063 m_Width = m_Height = "";
00064 if( m_Orientation == "Horizontal" )
00065 {
00066 m_Width.append( szprc.X );
00067 m_Height.append( szprc.Y );
00068 }
00069 else
00070 {
00071 m_Width.append( szprc.Y );
00072 m_Height.append( szprc.X );
00073 }
00074 m_Width += unit.Abbreviation;
00075 m_Height += unit.Abbreviation;
00076 }
00077 }
00078 if( m_Style )
00079 {
00080 Style_Obj style;
00081 style.key(m_Style);
00082 if( style.get_data() )
00083 {
00084 m_StyleName = style.Name;
00085 m_StyleImage = style.Image;
00086 m_Design_No = style.Manufacturer_Design_No;
00087 }
00088 }
00089 }
00090 protected:
00091
00092 llong m_Product;
00093 llong m_OrderedItem;
00094 llong m_Size;
00095 llong m_Style;
00096 llong m_Design;
00097 bool m_IsDesigner;
00098 string m_ProductName;
00099 string m_ProductDescription;
00100 string m_SKU;
00101 string m_Background;
00102 string m_Textcolor;
00103 string m_Design_No;
00104 string m_Font;
00105 string m_FontSize;
00106 string m_Design_Pattern_Image;
00107 string m_StyleName;
00108 string m_StyleImage;
00109 ocString m_Width;
00110 ocString m_Height;
00111 string m_Orientation;
00112 ocString m_CustomText;
00113 int m_LinesCustomText;
00114 int m_Count;
00115 money m_Price;
00116 money m_Shipping;
00117
00118
00119 llong m_Manufacturer;
00120
00121 public:
00122
00123 ItemDetail():
00124 m_Product(0LL),
00125 m_OrderedItem(0LL),
00126 m_Size(0LL),
00127 m_Style(0LL),
00128 m_Design(0LL),
00129 m_IsDesigner(false),
00130 m_ProductName(""),
00131 m_ProductDescription(""),
00132 m_SKU(""),
00133 m_Background(""),
00134 m_Textcolor(""),
00135 m_Design_No(""),
00136 m_Font(""),
00137 m_FontSize(""),
00138 m_Design_Pattern_Image(""),
00139 m_StyleName(""),
00140 m_StyleImage(""),
00141 m_Width(""),
00142 m_Height(""),
00143 m_Orientation(""),
00144 m_CustomText(""),
00145 m_LinesCustomText(0),
00146 m_Count(0),
00147 m_Price(0.0),
00148 m_Shipping(0.0),
00149 m_Manufacturer(0)
00150 {
00151 ;
00152 }
00153
00154
00155 virtual ~ItemDetail(){;}
00156
00157 ItemDetail( const ItemDetail & in):
00158 m_Product(in.m_Product),
00159 m_OrderedItem(in.m_OrderedItem),
00160 m_Size(in.m_Size),
00161 m_Style(in.m_Style),
00162 m_Design(in.m_Design),
00163 m_ProductName(in.m_ProductName),
00164 m_ProductDescription(in.m_ProductDescription),
00165 m_SKU(in.m_SKU),
00166 m_IsDesigner(in.m_IsDesigner),
00167 m_Background(in.m_Background),
00168 m_Textcolor(in.m_Textcolor),
00169 m_Design_No(in.m_Design_No),
00170 m_Font(in.m_Font),
00171 m_FontSize(in.m_FontSize),
00172 m_Design_Pattern_Image(in.m_Design_Pattern_Image),
00173 m_StyleName(in.m_StyleName),
00174 m_StyleImage(in.m_StyleImage),
00175 m_Width(in.m_Width),
00176 m_Height(in.m_Height),
00177 m_Orientation(in.m_Orientation),
00178 m_CustomText(in.m_CustomText),
00179 m_LinesCustomText(in.m_LinesCustomText),
00180 m_Count(in.m_Count),
00181 m_Price(in.m_Price),
00182 m_Shipping(in.m_Shipping),
00183 m_Manufacturer(in.m_Manufacturer)
00184 {
00185 ;
00186 }
00187
00188
00189 ItemDetail & operator = ( const ItemDetail & in )
00190 {
00191 m_Product = in.m_Product;
00192 m_OrderedItem = in.m_OrderedItem;
00193 m_Size = in.m_Size;
00194 m_Style = in.m_Style;
00195 m_Design = in.m_Design;
00196 m_IsDesigner = in.m_IsDesigner;
00197 m_ProductName = in.m_ProductName;
00198 m_ProductDescription = in.m_ProductDescription;
00199 m_SKU = in.m_SKU;
00200 m_Background = in.m_Background;
00201 m_Textcolor = in.m_Textcolor;
00202 m_Design_No = in.m_Design_No;
00203 m_Font = in.m_Font;
00204 m_FontSize = in.m_FontSize;
00205 m_Design_Pattern_Image = in.m_Design_Pattern_Image;
00206 m_StyleName = in.m_StyleName;
00207 m_StyleImage = in.m_StyleImage;
00208 m_Width = in.m_Width;
00209 m_Height = in.m_Height;
00210 m_Orientation = in.m_Orientation;
00211 m_CustomText = in.m_CustomText;
00212 m_LinesCustomText = in.m_LinesCustomText;
00213 m_Count = in.m_Count;
00214 m_Price = in.m_Price;
00215 m_Shipping = in.m_Shipping;
00216 m_Manufacturer = in.m_Manufacturer;
00217 return *this;
00218 }
00219
00220 ItemDetail & operator = ( Ordered_Item_Obj & oi )
00221 {
00222 m_Product = oi.Product_Id;
00223 m_CustomText = "";
00224 Ordered_Item_Option_Obj options;
00225
00226 ocString clause = " Ordered_Item_Id = ";
00227 clause.append(oi.Id);
00228 bool got = options.get_data(clause);
00229 m_Count = oi.Product_Count;
00230 while( got )
00231 {
00232 cerr << options.Name << endl;
00233 if( options.Name == "style" )
00234 {
00235 m_Style = atoll(options.Value.c_str());
00236 }
00237 else if( options.Name == "size" )
00238 {
00239 m_Size =atoll( options.Value.c_str());
00240 }
00241 else if( options.Name == "orientation" )
00242 {
00243 m_Orientation = options.Value;
00244 }
00245 else if( options.Name.substr(0,4) == "line" )
00246 {
00247 m_CustomText += options.Value;
00248 m_CustomText += "\n";
00249 }
00250 else if( options.Name == "design" )
00251 {
00252 m_Design = atoll(options.Value.c_str());
00253 }
00254 else if( options.Name == "font" )
00255 {
00256 m_Font = options.Value;
00257 }
00258 else if( options.Name == "fontsize" )
00259 {
00260 m_FontSize= options.Value;
00261 }
00262 else if( options.Name == "background" )
00263 {
00264 m_Background = options.Value;
00265 }
00266 else if( options.Name == "textcolor" )
00267 {
00268 m_Textcolor = options.Value;
00269 }
00270 got = options.next();
00271 }
00272
00273 size_t txtlen = m_CustomText.length();
00274 if( txtlen ) m_CustomText = m_CustomText.substr(0,txtlen-1);
00275
00276 extra();
00277
00278 return * this;
00279 }
00280
00281 ItemDetail & operator = ( xmlNode & node )
00282 {
00283
00284 if( node.attr["id"].length() ) m_Product = atoll(node.attr["id"].c_str());
00285 m_Count = 1;
00286 if(node.attr["count"].length() ) m_Count = atoll(node.attr["count"].c_str());
00287
00288 m_CustomText = node.data;
00289
00290 ocString options = node.attr["options"];
00291 for( ocString vpair=options.parse(";"); vpair.length(); vpair=options.parse(";") )
00292 {
00293 string name = vpair.parse("=");
00294 string value = vpair.parse("=");
00295 if( name == "style" )
00296 {
00297 m_Style = atoll(value.c_str());
00298 }
00299 else if( name == "size" )
00300 {
00301 m_Size = atoll(value.c_str());
00302 }
00303 else if( name == "orientation" )
00304 {
00305 m_Orientation = value;
00306 }
00307 }
00308 extra();
00309 return *this;
00310 }
00311
00312
00313
00314 llong Product( void ) { return m_Product; }
00315
00316 void Product( const llong in ) { m_Product = in; }
00317
00318
00319 llong OrderedItem( void ) { return m_OrderedItem; }
00320
00321 void OrderedItem( const llong in ) { m_OrderedItem = in; }
00322
00323
00324 llong Size( void ) { return m_Size; }
00325 string strSize( void ) { return m_Width + " x " + m_Height; }
00326
00327 void Size( const llong in ) { m_Size = in; }
00328
00329
00330 llong Style( void ) { return m_Style; }
00331
00332 void Style( const llong in ) { m_Style = in; }
00333
00334
00335 llong Design( void ) { return m_Design; }
00336
00337 void Design( const llong in ) { m_Design = in; }
00338
00339
00340 bool IsDesigner( void ) { return m_IsDesigner; }
00341
00342 void IsDesigner( const bool in ) { m_IsDesigner = in; }
00343
00344
00345 string & ProductName( void ) { return m_ProductName; }
00346
00347 void ProductName( const string & in ) { m_ProductName = in; }
00348
00349
00350 string & ProductDescription( void ) { return m_ProductDescription; }
00351
00352 void ProductDescription( const string & in ) { m_ProductDescription = in; }
00353
00354
00355 string & SKU( void ) { return m_SKU; }
00356
00357 void SKU( const string & in ) { m_SKU = in; }
00358
00359
00360 string & Background( void ) { return m_Background; }
00361
00362 void Background( const string & in ) { m_Background = in; }
00363
00364
00365 string & Textcolor( void ) { return m_Textcolor; }
00366
00367 void Textcolor( const string & in ) { m_Textcolor = in; }
00368
00369
00370 string & Design_No( void ) { return m_Design_No; }
00371
00372 void Design_No( const string & in ) { m_Design_No = in; }
00373
00374
00375 string & Font( void ) { return m_Font; }
00376
00377 void Font( const string & in ) { m_Font = in; }
00378
00379
00380 string & FontSize( void ) { return m_FontSize; }
00381
00382 void FontSize( const string & in ) { m_FontSize = in; }
00383
00384
00385 string & Design_Pattern_Image( void ) { return m_Design_Pattern_Image; }
00386
00387 void Design_Pattern_Image( const string & in ) { m_Design_Pattern_Image = in; }
00388
00389
00390 string & StyleName( void ) { return m_StyleName; }
00391
00392 void StyleName( const string & in ) { m_StyleName = in; }
00393
00394
00395 string & StyleImage( void ) { return m_StyleImage; }
00396
00397 void StyleImage( const string & in ) { m_StyleImage = in; }
00398
00399
00400 ocString & Width( void ) { return m_Width; }
00401
00402 void Width( const string & in ) { m_Width = in; }
00403
00404
00405 ocString & Height( void ) { return m_Height; }
00406
00407 void Height( const string & in ) { m_Height = in; }
00408
00409
00410 string & Orientation( void ) { return m_Orientation; }
00411
00412 void Orientation( const string & in ) { m_Orientation = in; }
00413
00414
00415 ocString & CustomText( void ) { return m_CustomText; }
00416
00417 void CustomText( const string & in ) { m_CustomText = in; }
00418
00419
00420 int LinesCustomText( void ) { return m_LinesCustomText; }
00421
00422 void LinesCustomText( const int in ) { m_LinesCustomText = in; }
00423
00424
00425 int Count( void ) { return m_Count; }
00426 string strCount( void ) { ocString strCount; return strCount.append(m_Count); }
00427
00428
00429 void Count( const int in ) { m_Count = in; }
00430
00431
00432 money & Price( void ) { return m_Price; }
00433
00434 void Price( const money & in ) { m_Price = in; }
00435
00436
00437 money & Shipping( void ) { return m_Shipping; }
00438
00439 void Shipping( const money & in ) { m_Shipping = in; }
00440
00441
00442 money Total( void )
00443 {
00444 money Total;
00445 Total.amount() = (m_Price.amount() + m_Shipping.amount())*m_Count;
00446 return Total;
00447 }
00448
00449 llong Manufacturer( void ) { return m_Manufacturer; }
00450
00451 void Manufacturer( const llong in ) { m_Manufacturer = in; }
00452
00453 };
00454
00455 #endif
00456