00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef Ordered_Item_HPP
00012 #define Ordered_Item_HPP
00013
00014 #include "read_write_base.hpp"
00015 #include "Ordered_Item_Option.hpp"
00016 #include "ocXML.h"
00017 class Ordered_Item
00018 {
00019 protected:
00020 ocString options;
00021 ocString data;
00022
00023 public:
00024 identifier Id;
00025 llong Product_Id;
00026 llong Order_Id;
00027 int Product_Count;
00028 money Total_Price;
00029 money Shipping;
00030 string Internal_Id;
00031 string External_Id;
00032
00033 Ordered_Item():
00034 Id(0LL),
00035 Product_Id(0LL),
00036 Order_Id(0LL),
00037 Product_Count(0),
00038 Total_Price(0.0),
00039 Shipping(0.0),
00040 Internal_Id(""),
00041 External_Id("")
00042 {
00043 ;
00044 }
00045
00046
00047 Ordered_Item( const Ordered_Item & in )
00048 {
00049 Id=in.Id;
00050 Product_Id=in.Product_Id;
00051 Order_Id=in.Order_Id;
00052 Product_Count=in.Product_Count;
00053 Total_Price=in.Total_Price;
00054 Shipping=in.Shipping;
00055 Internal_Id=in.Internal_Id;
00056 External_Id=in.External_Id;
00057 options=in.options;
00058 data=in.data;
00059 }
00060
00061
00062 virtual ~Ordered_Item()
00063 {
00064 ;
00065 }
00066
00067
00068 Ordered_Item & operator = ( const Ordered_Item & in )
00069 {
00070 Id=in.Id;
00071 Product_Id=in.Product_Id;
00072 Order_Id=in.Order_Id;
00073 Product_Count=in.Product_Count;
00074 Total_Price=in.Total_Price;
00075 Shipping=in.Shipping;
00076 Internal_Id=in.Internal_Id;
00077 External_Id=in.External_Id;
00078 options=in.options;
00079 data=in.data;
00080 return *this;
00081 }
00082 void addOrderItemOptions( xmlNode & node)
00083 {
00084 options = node.attr["options"];
00085 data = xmlUnescape(node.data);
00086 }
00087 };
00088
00089 typedef vector<Ordered_Item> items_ordered;
00090
00091 class Ordered_Item_Obj: public Ordered_Item, public read_write_base
00092 {
00093 public:
00094 Ordered_Item_Obj():Ordered_Item(),read_write_base()
00095 {
00096
00097 data_name("Ordered_Item");
00098
00099 addDXMap( new llongXfer("Id", &Id ));
00100 addDXMap( new llongXfer("Product_Id", &Product_Id ));
00101 addDXMap( new llongXfer("Order_Id", &Order_Id ));
00102 addDXMap( new intXfer("Product_Count", &Product_Count ));
00103 addDXMap( new moneyXfer("Total_Price", &Total_Price ));
00104 addDXMap( new moneyXfer("Shipping", &Shipping ));
00105 addDXMap( new stringXfer("Internal_Id", &Internal_Id ));
00106 addDXMap( new stringXfer("External_Id", &External_Id ));
00107 }
00108
00109 virtual ~Ordered_Item_Obj(){;}
00110
00111 Ordered_Item & operator = ( const Ordered_Item & in )
00112 {
00113 Ordered_Item::operator=(in);
00114 return *this;
00115 }
00116
00117 bool saveOptions( void )
00118 {
00119
00120 if(Id==0&&key()!=0) Id=key();
00121 if( options.length() )
00122 {
00123 ocString pair = options.parse(";");
00124 while( pair.length() )
00125 {
00126 pair.parseInit();
00127 Ordered_Item_Option_Obj opt;
00128 opt.Ordered_Item_Id = Id;
00129 opt.Name = pair.parse("=");
00130 opt.Value = pair.parse("=");
00131 opt.db_insert();
00132 pair = options.parse(";");
00133 }
00134 }
00135
00136 if( data.length() )
00137 {
00138 ocString lineName;
00139 int lnNo = 1;
00140 ocString line=data.parse("\n");
00141 while( line.length() )
00142 {
00143 lineName="line";
00144 lineName.append(lnNo);
00145 Ordered_Item_Option_Obj opt;
00146 opt.Ordered_Item_Id = Id;
00147 opt.Name = lineName;
00148 opt.Value = line;
00149 opt.db_insert();
00150 line=data.parse("\n");
00151 lnNo++;
00152 }
00153 }
00154 return true;
00155 }
00156
00157 };
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 #endif
00197