Project 2

Due May 24 (start of class and on blackboard start of class)

Points 200

PHP-to-NodeJS + NodeJS + Database

....YOU ARE GOING TO WORK In your group teams on this project (up to 3 people max) that you were assigned to


You are going to extend your work from Project 1. In particular, you are going to modify your previous Project 1 to use NodeJS, Express and MongoDB to store the order information in a MongoDB collection.

finalOrder.php programs to call a serverside NodeJS program that stores the data to a MongoDB collection and returns a ejs file with the successfully stored oreder information which the finalOrder.php to handle the data entered into your HTML ordering form page in Project 1.

 

TIP ON HOW TO SET IDS for Collections when inserting new document --- why? you need for the BILLING entry to know the corresponding CUSTOMER document _id and similarrly iwht SHIPPING and ORDERS entries

****** the 2 exercises will greatly help you with this project both the PHP to Node as well as the M1 exercise --- refer to your work and the partial code examples that I gave for this to help you with the project *******************

ITEM 1) You will modify finalOrder.php programs to call a serverside NodeJS program /storeData

ITEM 2) your NodeJS+Express project will contain a mapping of the URL /storeData to the invokation of the function storeData that will take a POST request to it. See your first exercise for tips but, your routes/index.js will contain code that looks like:

router.post("/storeData", ControllerDatabase.storeData); //note sometimes the router object in our sample code and in the book is called app

//note you will have had to define the ControllerDatabase before this to point to the Controller code located in controllers/database

 

 

ITEM 3) a controller file called database.js inside a controllers directory and this code will have a module.export.storeData function that will do the following: (TIP: both of the previous exercises will help you do this)


 

ITEM 4) the finalOrder.php program recieves the results of calling the NodeJS program (/storeData) and returns this to its client (the webbrowser)....minimally you should report "Order Successful" or "Order NOT Successful" and you can let the php code simply as it did in Project 2 print out ALL the Order information from the PHP Session data --alternatively the data returned from /storeData can have both the message "Order Successfull" or "Order NOT Successful" WITH the original order data. The choice of getting all the order information from either the session data or having it return it with the message from the NodeJS program is up to you.

 

ITEM 5) Create a mLab MongoDB with the following Collections and requirements

Database Requirements - you will use mLab's MongoDB server and create the following

 

Name of Collections:

CUSTOMERS = (_id, FIRSTNAME, LASTNAME, STREET, CITY, STATE, ZIP, EMAIL)

 

BILLING = (_id, CUSTOMER_ID, CREDITCARDTYPE, CREDITCARDNUM, CREDITCARDEXP, CREDITCARDSECURITYNUM)

 

SHIPPING = (_id, CUSTOMER_ID, SHIPPING_STREET, SHIPPING_CITY, SHIPPING_STATE, SHIPPING_ZIP)

ORDERS = (_id, CUSTOMER_ID, BILLING_ID, SHIPPING_ID, DATE, PRODUCT_VECTOR, ORDER_TOTAL)

 

ORDER of insertion
1) you will insert a new document in the CUSTOMERS collection and get the _id of the CUSTOMER that will be used in #2

2) you will insert a new document in the BILLING collection using the _id of the customer from #1 into the CUSTOMER_ID field

3) you will then enter in a new document in the SHIPPING collection again storing the cursotmer _id in CUSTOMER_ID field

4) you will then create a new document in the ORDERS collection storing the customer _id from #1, the billing _id from #2 adn the shipping _id from #3 in the corresponding fields of this new entry in the ORDERS table.

What is PRODUCT_VECTOR?

PRODUCT_VECTOR = list of products ordered in following format where I show an example of 3 products ordered*** (note your products were not required to have color and size --but, IF they DO you must include the delivery of this information.

"{ProductID_1, Quantity1, Price1, Color1, Size 1} , {ProductID_2, Quantity2, Price2, Color2, Size2}, {ProductID_3, Quantity3, Price3, Color3, Size 3}"

 

The output of this PHP and EJS program(s) as well must keep the same style of the web site

 

Order Validity

Your PHP program must only check that some kind of data has been entered into the forms, if it is blank your program for the time being can use some default values for the missing fields.

 

 


Evaluation Guidelines


Deliverables

  1. Update your web-site with the PHP Code and update HTML appropriately. Fully test out program. Post on the server.
  2. Deploy all NodeJS on Heorku and through Heoku and mLab use MongoDB database.
  3. CodeDescription.doc:

    SECTION 1) DESCRIPTION SECTION: Word document containing one-page (not 1 sentence!!!) description of how code is structured and how it works. You must list the name of EACH PHP file and NoeJS (e.g. A.pl) and give a description. GIVE URL TO your website!!!AND LIST ALL THE PEOPLE IN YOUR GROUP --- every person in the group must turn in ALL the deliverables and everyone recieves the same score unless a student did not participate at all and then it is at the instructors discretion.

    SECTION 2) CHECKOUT PROCESS: containing series of screen shots from web-browsers showing the processing of the series of forms used in the check out process.

    SECTION 3) DATABASE RESULTS FROM ORDERING:Printout of database BOTH before and after the order from item 2 was made. (you can do screen shots showing before an after of ORDERS collection in your GUI admin tool on mLab..in this case you will need to turn in a word document). Label the Before and After data (or screen shots) --- I MUST see the new entries in ALL of the collections. LABEL each picture BEFORE or AFTER.

    • for collection CUSTOMERS
    • for collection BILLING
    • for collection SHIPPING
    • for collection ORDERS

     

    SECTION 4) STATUS: here you must state what pages and requirements you have implmemented and ESPECIALLY TELL ME what you have not finished or is not workin

  4. Code.zip containing all PHP code (*.php). NodeJSProject.zip - contains NodeJS+Express code.
  5. upload the files to blackboard project: PHPCode.zip, NodeJSProject.zip, CodeDescription.doc and URL YOU SHOULD KEEP THE FILENAMES I HAVE DESIGNATED. Upload to Blackboard->Projects->Project 2

 

 

 

© Lynne Grewe