00001
00002
00003
00004
00005
00006
00007 #include "xml_forms.hpp"
00008 #include "ocXML.h"
00009
00010 xml_form::xml_form(cgiScript & in):script(in)
00011 {
00012 m_warn = "<br>";
00013 getInstructions();
00014 }
00015
00016 xml_form::~xml_form()
00017 {
00018 ;
00019 }
00020
00021 bool xml_form::getInstructions( void )
00022 {
00023 bool breturn = false;
00024 if( script.ClientArguments().count("w3sysMode") )
00025 {
00026 mode = script.ClientArguments()["w3sysMode"].c_str();
00027 breturn=true;
00028 }
00029
00030
00031
00032
00033
00034 if( script.ClientArguments().count("w3sysChanges") )
00035 {
00036 ocString chgList = script.ClientArguments()["w3sysChanges"].c_str();
00037 string change = chgList.parse(",");
00038 while( change.length() )
00039 {
00040 changes[change]=change;
00041 change = chgList.parse(",");
00042 }
00043 breturn=true;
00044 }
00045 return breturn;
00046 }
00047
00048
00049 bool xml_form::form_action( void )
00050 {
00051
00052 if( mode != "r" && mode != "n" )
00053 {
00054 form_id_transfer();
00055 }
00056
00057 if( mode != "r" )
00058 {
00059 form_data_transfer();
00060 }
00061 return dbf_action( mode, changes );
00062 }
00063
00064
00065
00066 void xml_form::stringFXfer( string in, string & out )
00067 {
00068 if( script.ClientArguments().count(in.c_str()) )
00069 {
00070 changes[in]=in;
00071 out=script.ClientArguments()[in.c_str()].c_str();
00072 }
00073 }
00074 void xml_form::llongFXfer( string in, long long & out )
00075 {
00076 if( script.ClientArguments().count(in.c_str()) )
00077 {
00078 changes[in]=in;
00079 out=atoll(script.ClientArguments()[in.c_str()].c_str());
00080 }
00081 }
00082 void xml_form::longFXfer( string in, long & out )
00083 {
00084 if( script.ClientArguments().count(in.c_str()) )
00085 {
00086 changes[in]=in;
00087 out=atol(script.ClientArguments()[in.c_str()].c_str());
00088 }
00089 }
00090 void xml_form::unfmtLongFXfer( string in, long & out )
00091 {
00092 if( script.ClientArguments().count(in.c_str()) )
00093 {
00094 changes[in]=in;
00095 ocString fixUp = script.ClientArguments()[in.c_str()].c_str();
00096 out=atol(fixUp.replaceAll(",","").c_str());
00097 }
00098 }
00099 void xml_form::intFXfer( string in, int & out )
00100 {
00101 if( script.ClientArguments().count(in.c_str()) )
00102 {
00103 changes[in]=in;
00104 out=atoi(script.ClientArguments()[in.c_str()].c_str());
00105 }
00106 }
00107 void xml_form::shortFXfer( string in, short & out )
00108 {
00109 if( script.ClientArguments().count(in.c_str()) )
00110 {
00111 changes[in]=in;
00112 out=atoi(script.ClientArguments()[in.c_str()].c_str());
00113 }
00114 }
00115 void xml_form::doubleFXfer( string in, double & out )
00116 {
00117 if( script.ClientArguments().count(in.c_str()) )
00118 {
00119 changes[in]=in;
00120 out=atof( script.ClientArguments()[in.c_str()].c_str());
00121 }
00122 }
00123 void xml_form::moneyFXfer( string in, money & out )
00124 {
00125 if( script.ClientArguments().count(in.c_str()) )
00126 {
00127 changes[in]=in;
00128 ocString tmpVal = script.ClientArguments()[in.c_str()].c_str();
00129 double val = atof( tmpVal.replaceAll("$","").replaceAll(",","").c_str() );
00130 out=val;
00131 }
00132 }
00133 void xml_form::boolFXfer( string in, bool & out )
00134 {
00135 out = false;
00136 if( script.ClientArguments().count(in.c_str()) )
00137 {
00138 changes[in]=in;
00139 out=true;
00140 }
00141 }
00142
00143 void xml_form::dateFXfer( string in, oc_date & out )
00144 {
00145
00146 if( script.ClientArguments().count(in.c_str()) )
00147 {
00148 changes[in]=in;
00149 out.parse( script.ClientArguments()[in.c_str()].c_str() );
00150 }
00151 }
00152 void xml_form::dateFXfer( string in, time_date & out )
00153 {
00154
00155 if( script.ClientArguments().count(in.c_str()) )
00156 {
00157 changes[in]=in;
00158 out.parse( script.ClientArguments()[in.c_str()].c_str() ,"%m/%d/%Y %I:%M:%S %p" );
00159 }
00160 }
00161 void xml_form::timeFXfer( string in, oc_time & out )
00162 {
00163
00164 if( script.ClientArguments().count(in.c_str()) && script.ClientArguments()[in.c_str()].length() )
00165 {
00166 changes[in]=in;
00167 out.setFormat("%I:%M %p");
00168 out.parse( script.ClientArguments()[in.c_str()].c_str() );
00169 }
00170 }