00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef Affiliate_HPP
00012 #define Affiliate_HPP
00013
00014 #include "read_write_base.hpp"
00015
00016 class Affiliate_Obj: public read_write_base
00017 {
00018 public:
00019 identifier Id;
00020 string Organization_Name;
00021 string First;
00022 string Last;
00023 llong Promotion;
00024 string Phone;
00025 string Mobile;
00026 string Email;
00027 string Password;
00028 string Address_1;
00029 string Address_2;
00030 string City;
00031 string State;
00032 string Zip;
00033 string Country;
00034 Affiliate_Obj():read_write_base()
00035 ,Id(0LL)
00036 ,Organization_Name("")
00037 ,First("")
00038 ,Last("")
00039 ,Promotion(0LL)
00040 ,Phone("")
00041 ,Mobile("")
00042 ,Email("")
00043 ,Password("")
00044 ,Address_1("")
00045 ,Address_2("")
00046 ,City("")
00047 ,State("")
00048 ,Zip("")
00049 ,Country("")
00050 {
00051
00052 data_name("Affiliate");
00053
00054 addDXMap( new llongXfer("Id", &Id ));
00055 addDXMap( new stringXfer("Organization_Name", &Organization_Name ));
00056 addDXMap( new stringXfer("First", &First ));
00057 addDXMap( new stringXfer("Last", &Last ));
00058 addDXMap( new llongXfer("Promotion", &Promotion ));
00059 addDXMap( new stringXfer("Phone", &Phone ));
00060 addDXMap( new stringXfer("Mobile", &Mobile ));
00061 addDXMap( new stringXfer("Email", &Email ));
00062 addDXMap( new stringXfer("Password", &Password ));
00063 addDXMap( new stringXfer("Address_1", &Address_1 ));
00064 addDXMap( new stringXfer("Address_2", &Address_2 ));
00065 addDXMap( new stringXfer("City", &City ));
00066 addDXMap( new stringXfer("State", &State ));
00067 addDXMap( new stringXfer("Zip", &Zip ));
00068 addDXMap( new stringXfer("Country", &Country ));
00069 }
00070 bool enoughData( void )
00071 {
00072 bool result = true;
00073 if( First.length() == 0 )
00074 {
00075 result = false;
00076 m_result = "Please enter your first name.";
00077 }
00078 if( Last.length() == 0 )
00079 {
00080 result = false;
00081 m_result = "Please enter your last name.";
00082 }
00083 if( Email.length() == 0 )
00084 {
00085 result = false;
00086 m_result = "Please enter your email address.";
00087 }
00088 if( Phone.length() == 0 && Mobile.length() == 0 )
00089 {
00090 result = false;
00091 m_result = "Please enter your phone number.";
00092 }
00093 if( result )
00094 {
00095 if( Organization_Name.length() == 0 )
00096 {
00097
00098 Organization_Name = First + " " + Last;
00099 }
00100 }
00101 return result;
00102 }
00103 bool uniquePromotion( void )
00104 {
00105 bool result = true;
00106 if( Promotion > 0 )
00107 {
00108 ocString sql = "select Id, Organization_Name from Affiliate where Promotion = ";
00109 sql.append( Promotion );
00110 if( Id )
00111 {
00112 sql += " and Id != ";
00113 sql.append(Id);
00114 }
00115 if( rs.open(sql) )
00116 {
00117 result = false;
00118 m_result = "The requested Promotion is already in use by ";
00119 m_result += rs.getField(1).format();
00120 }
00121 }
00122 return result;
00123 }
00124
00125 bool ivalidate( void )
00126 {
00127 bool result = enoughData();
00128 if( result ) result = uniquePromotion();
00129 return result;
00130 }
00131
00132 bool uvalidate( changeMap & changes )
00133 {
00134 bool result = enoughData();
00135 if( result ) result = uniquePromotion();
00136 return result;
00137 }
00138
00139 bool isupplemental( void )
00140 {
00141 ocString sql = "insert into user_roles ( user_id , role_id , enabled ) values ( ";
00142 sql.append(key());
00143 sql += ", 2, 1 )";
00144 cmd.execute(sql);
00145 return true;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 };
00163 #endif
00164
00165
00166