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 "read_write_base.hpp"
00021 #include "list_base.hpp"
00022 #include "forms_base.hpp"
00023 #include "Ordered.hpp"
00024 #include "openLogin.h"
00025
00026
00027 #include "../source/proofs.hpp"
00028 #include "Customer.hpp"
00029
00030 using namespace std;
00031 openLogin oLogin;
00032
00033 class Ordered_List: public list_base
00034 {
00035 public:
00036
00037 Ordered_List(cgiScript&sc):list_base(sc){;}
00038 ~Ordered_List(){;}
00039
00040 bool list_display( void )
00041 {
00042 bool breturn = true;
00043
00044 hotCol=-2;
00045 editLink = listTemplate.getParagraph("hotcolumn");
00046 editLink = editLink.replace("$prog$","Ordered_ui.cgi");
00047 emitFilter( "Ordered_ui.cgi",
00048 " <B>Find (by Order Id)</B>" );
00049 string heading =
00050 "<a class='sortcol' href='Ordered_ui.cgi?sort=Id'>Id</a>|"
00051 "<a class='sortcol' href='Ordered_ui.cgi?sort=s.Name'>Order Status</a>|"
00052 "<a class='sortcol' href='Ordered_ui.cgi?sort=Product_Total'>Product Total</a>|"
00053 "<a class='sortcol' href='Ordered_ui.cgi?sort=Shipping_Total'>Shipping Total</a>|"
00054 "<a class='sortcol' href='Ordered_ui.cgi?sort=Tax_Total'>Tax Total</a>|"
00055 "<a class='sortcol' href='Ordered_ui.cgi?sort=Order_Total'>Order Total</a>|"
00056 "<a class='sortcol' href='Ordered_ui.cgi?sort=Order_Date'>Order Date</a>|"
00057 "<a class='sortcol' href='Ordered_ui.cgi?sort=Transaction_Id'>Transaction Id</a>";
00058 emitHeadings(heading);
00059 getFilteredData(
00060 "o.Id, "
00061 "s.Name, "
00062 "o.Product_Total, "
00063 "o.Shipping_Total, "
00064 "o.Tax_Total, "
00065 "o.Order_Total, "
00066 "o.Order_Date, "
00067 "o.Transaction_Id "
00068 ,"Ordered o inner join Order_Status s on o.Order_Status_Id = s.Id",
00069 "o.Id = $filter$",
00070 "o.Order_Date desc" );
00071 emitData();
00072 emitNavigation("Ordered_ui.cgi");
00073 emitEnd();
00074 return breturn;
00075 }
00076 };
00077
00078 class Ordered_form: public Ordered_Obj, public forms_base
00079 {
00080 public:
00081 Ordered_form(cgiScript & script):Ordered_Obj(),forms_base(script){setKey(*this);}
00082 virtual ~Ordered_form(){;}
00083
00084 void form_id_transfer( void )
00085 {
00086 llongFXfer( "Id", Id );
00087 }
00088 void form_data_transfer( void )
00089 {
00090 llongFXfer( "Customer_Id", Customer_Id);
00091 llongFXfer( "Order_Status_Id", Order_Status_Id);
00092 moneyFXfer( "Product_Total", Product_Total);
00093 moneyFXfer( "Shipping_Total", Shipping_Total);
00094 moneyFXfer( "Tax_Total", Tax_Total);
00095 moneyFXfer( "Order_Total", Order_Total);
00096 dateFXfer( "Order_Date", Order_Date);
00097 stringFXfer( "Transaction_Id", Transaction_Id);
00098 stringFXfer( "Notes", Notes);
00099 llongFXfer( "Customer_Pmt_Svc_Id", Customer_Pmt_Svc_Id);
00100 }
00101
00102 bool dbf_action( string mode, changeMap & changes )
00103 {
00104 return db_action( mode, changes );
00105 }
00106
00107
00108 bool form_display( void )
00109 {
00110 bool breturn = true;
00111 ocString sql;
00112
00113 script << makeTop("Ordered_ui.cgi", "Ordered")
00114 << formTemplate.getParagraph("advanced_begin");
00115 script << makeStaticBox("Id", "Id", Id ,"8");
00116 script << "<br class='clearall'>" << endl;
00117 script << makeTextArea("Notes", "Notes", Notes ,"2","40");
00118 script << "<br class='clearall'>" << endl;
00119 script << formTemplate.getParagraph("advanced_end");
00120 sql = "select Id, concat( First_Name, ' ', Last_Name ) as Name from Customer";
00121 script << makeComboBox("Customer", "Customer_Id", Customer_Id ,sql);
00122 script << "<br class='clearall'>" << endl;
00123 sql = "select Id, Name from Order_Status";
00124 script << makeComboBox("Order Status", "Order_Status_Id", Order_Status_Id ,sql);
00125 script << "<br class='clearall'>" << endl;
00126 script << makeTextBox("Product Total", "Product_Total", Product_Total ,"16","16");
00127 script << "<br class='clearall'>" << endl;
00128 script << makeTextBox("Shipping Total", "Shipping_Total", Shipping_Total ,"16","16");
00129 script << "<br class='clearall'>" << endl;
00130 script << makeTextBox("Tax Total", "Tax_Total", Tax_Total ,"16","16");
00131 script << "<br class='clearall'>" << endl;
00132 script << makeTextBox("Order Total", "Order_Total", Order_Total ,"16","16");
00133 script << "<br class='clearall'>" << endl;
00134 script << makeTextBox("Order Date", "Order_Date", Order_Date ,"24","24");
00135 script << "<br class='clearall'>" << endl;
00136 script << makeTextBox("Transaction Id", "Transaction_Id", Transaction_Id ,"25");
00137 script << "<br class='clearall'>" << endl;
00138 sql = "select Id, Name from Promotion order by Name";
00139 script << makeComboBox("Promotion", "Promotion", Promotion ,sql,"None");
00140
00141 sql = "select cps.Id, ps.Name from Customer_Payment_Service cps "
00142 "inner join Payment_Service ps on cps.Payment_Service_Id = ps.Id "
00143 "where cps.Customer_Id =";
00144 sql.append(Customer_Id);
00145
00146 script << makeComboBox("Payment Svc", "Customer_Pmt_Svc_Id", Customer_Pmt_Svc_Id ,sql);
00147 script << "<br class='clearall'>" << endl;
00148
00149 script << makeButtons( key() );
00150 if( Id )
00151 {
00152 showCustomer();
00153 showProof();
00154 }
00155 script << makeBottom( m_result ) << endl;
00156 return breturn;
00157 }
00158
00159 void showProof(void)
00160 {
00161 proofs proof;
00162 proof.m="1";
00163 proof.o="";
00164 proof.o.append(Id);
00165 proof.showOrderedItems( script );
00166 }
00167
00168 void showCustomer()
00169 {
00170 Customer_Obj cstmr;
00171 cstmr.key(Customer_Id);
00172 if( cstmr.get_data() )
00173 {
00174 ocString grp = formTemplate.getParagraph("control_group");
00175 script << "<h3>Customer Information:</h3>" << endl;
00176 script << grp.replace("$label$","Customer")
00177 .replace("$control$", (cstmr.First_Name+" "+cstmr.Last_Name).c_str());
00178 script << "<br class='clearall'>" << endl;
00179 script << grp.replace("$label$","Phone")
00180 .replace("$control$",cstmr.Phone.c_str());
00181
00182 script << "<br class='clearall'>" << endl;
00183 script << grp.replace("$label$","E-Mail")
00184 .replace("$control$",cstmr.EMail.c_str());
00185 script << "<br class='clearall'>" << endl;
00186 script << grp.replace("$label$","Address")
00187 .replace("$control$",cstmr.Address.c_str());
00188
00189 script << "<br class='clearall'>" << endl;
00190 script << grp.replace("$label$","City")
00191 .replace("$control$",cstmr.City.c_str());
00192 script << "<br class='clearall'>" << endl;
00193 script << grp.replace("$label$","State")
00194 .replace("$control$",cstmr.State.c_str());
00195 script << "<br class='clearall'>" << endl;
00196 script << grp.replace("$label$","Zip")
00197 .replace("$control$",cstmr.Zip.c_str());
00198 script << "<br class='clearall'>" << endl;
00199 }
00200 }
00201 };
00202
00203
00204 int main( int argcount, char ** args )
00205 {
00206 cgiScript script( "text/html", false );
00207 Ordered_form myFrm(script);
00208 Ordered_List mylist(script);
00209 if( oLogin.testLoginStatus() )
00210 {
00211 script.closeHeader();
00212 cgiTemplates pgTemplate;
00213 pgTemplate.load("Templates/adminPane.htmp");
00214
00215 script << ocString(pgTemplate.getParagraph("top"))
00216 .replaceAll("$heading$","Ordered");
00217
00218 myFrm.loadControlTemplates("Templates/divform.htmp");
00219 myFrm.form_action();
00220 myFrm.form_display();
00221
00222 mylist.loadListTemplates("Templates/list.htmp");
00223 mylist.list_display();
00224
00225 ocString end = pgTemplate.getParagraph("bottom");
00226 script << end;
00227 }
00228 else
00229 {
00230 script.Redirect("signIn.html");
00231 }
00232 }
00233
00234
00235 #include "read_write_base.cpp"
00236 #include "forms_base.cpp"
00237