Commit dc40a971 authored by Nina Sanchez's avatar Nina Sanchez

Revert "why not working anymore"

This reverts commit 28cdda65.
parent 28cdda65
......@@ -29,8 +29,7 @@ public final class R {
public static final int prelimlogo=0x7f020003;
}
public static final class id {
public static final int aaa=0x7f08003f;
public static final int action_settings=0x7f080042;
public static final int action_settings=0x7f080040;
public static final int btnAddMenu=0x7f08001c;
public static final int btnAddToCart=0x7f08003c;
public static final int btnAdmin=0x7f08002f;
......@@ -63,14 +62,13 @@ public final class R {
public static final int listview1=0x7f080013;
public static final int logo=0x7f080007;
public static final int logout=0x7f080032;
public static final int nameF=0x7f08003e;
public static final int price=0x7f080040;
public static final int priceName=0x7f080036;
public static final int quantity=0x7f08003b;
public static final int returnData=0x7f080016;
public static final int tableName=0x7f08003e;
public static final int tableNum=0x7f080033;
public static final int textView00=0x7f08003d;
public static final int textView01=0x7f080041;
public static final int textView01=0x7f08003f;
public static final int textView1=0x7f08001e;
public static final int textView2=0x7f080020;
public static final int textView3=0x7f08002e;
......
......@@ -2,48 +2,20 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:orientation="vertical" >
<TextView
android:id="@+id/nameF"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="1" />
<TextView
android:id="@+id/aaa"
android:id="@+id/tableName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
\ No newline at end of file
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import java.util.List;
import com.parse.ParseObject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class Cart extends Activity {
ListView lv;
TextView rn;
public double total = 0;
public ArrayList<CartItem> cartitems = new ArrayList<CartItem>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
getData();
lv = (ListView)findViewById(R.id.listCart);
rn = (TextView)findViewById(R.id.totesPrice);
rn.setText(Double.toString(total));
@SuppressWarnings("unchecked")
final ArrayAdapter<OrderModel> adapter = new ArrayAdapter(getBaseContext(), R.layout.menu_item, android.R.id.text1, cartitems) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text1 = (TextView) view.findViewById(R.id.nameF);
TextView text2 = (TextView) view.findViewById(R.id.quantity);
TextView text3 = (TextView) view.findViewById(R.id.price);
text1.setText(cartitems.get(position).getFoodname());
text2.setText(cartitems.get(position).getQuantity());
text3.setText(Double.toString(cartitems.get(position).getPrice()));
return view;
}
};
//lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
}
@Override
......@@ -87,25 +49,4 @@ public class Cart extends Activity {
finish();
}
public void getData(){
for (int i = 0; i < 10; i++) {
final CartItem sched = new CartItem();
//ParseObject obj = queue.get(i);
/******* Firstly take data in model object ******/
//ParseObject item = obj.getParseObject("item_id");
sched.setFoodname("SINIGANG");
int qty = 2;
sched.setQuantity(qty);
double orgprice = 100;
sched.setPrice(orgprice);
total += (qty * orgprice);
/******** Take Model Object in ArrayList **********/
cartitems.add( sched );
}
}
}
package com.cs123grpE.restaurantorderingsystem;
public class CartItem {
private String foodname = "";
private int quantity;
private double price;
public String getFoodname() {
return foodname;
}
public void setFoodname(String foodname) {
this.foodname = foodname;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
......@@ -47,16 +47,20 @@ public class Customer extends Activity {
Intent i = getIntent();
tableNum = i.getIntExtra("tableNumber", 0);
//ParseUser pu = ParseUser.getCurrentUser();
table = Helper.findTable(null, tableNum);
ParseUser pu = ParseUser.getCurrentUser();
if (pu == null) {
Log.i("help", "null pls");
}
table = Helper.findTable(pu, tableNum);
if(table==null) {
table = Helper.addTable(null, tableNum);
table = Helper.addTable(pu, tableNum);
}
prepareLists();
cart = new HashMap<String, Integer>();
//generateMenu("", true);
ListView lv = (ListView)findViewById(R.id.listview1);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
......@@ -157,10 +161,6 @@ public class Customer extends Activity {
public void viewCart (View v) {
// go to cart screen
Intent i = new Intent (this, Cart.class);
ArrayList<String> items = new ArrayList<String>();
startActivityForResult (i, 2);
}
......@@ -226,7 +226,7 @@ public class Customer extends Activity {
Intent i = new Intent(getApplicationContext(), ViewProfile.class);
i.putExtra("menu_name", name);
startActivityForResult(i, 1);
startActivity(i);
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition)
......@@ -345,7 +345,7 @@ public class Customer extends Activity {
ParseObject obj = Helper.findObject("Menu_Item", "item_name", "Sinigang");
Log.i("ParseObject", obj.getString("item_name"));
ParseObject order = new ParseObject("Item_Order");
ParseObject order = new ParseObject("Order");
order.put("item_id", obj);
order.put("quantity", 3);
order.put("table_id", table);
......@@ -403,15 +403,11 @@ public class Customer extends Activity {
if(resultCode==RESULT_OK && requestCode==1){
System.out.println("RESULT :D");
}
if(requestCode==1) {
String key = data.getStringExtra("itemName");
int value = data.getIntExtra("quantity", 0);
int value = data.getIntExtra("qty", 0);
cart.put(key, value);
ParseObject obj = Helper.findObject("Menu_Item", "item_name", key);
Helper.addOrder(table, obj, value);
}
else if(requestCode==2 && data.getBooleanExtra("finalize", false)) {
for(Map.Entry<String, Integer> me: cart.entrySet()) {
......
......@@ -83,23 +83,13 @@ public class Helper {
}
public static void addOrder(ParseObject table, ParseObject item, int qty) {
ParseObject order = new ParseObject("Item_Order");
ParseObject order = new ParseObject("Order");
order.put("item_id", item);
order.put("item_name", item.getString("item_name"));
order.put("quantity", qty);
order.put("table_id", table);
order.put("table_no", table.getInt("table_id"));
order.put("paid", false);
order.put("completed", false);
order.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
// myObjectSavedSuccessfully();
} else {
//myObjectSaveDidNotSucceed();
}
}
});
order.saveInBackground();
}
public static void setOrderAttribute(ParseObject order, String key, boolean value) {
......@@ -138,8 +128,8 @@ public class Helper {
public static ParseObject addTable(ParseUser user, int num) {
ParseObject p = new ParseObject("Table");
//ParseObject rest = user.getParseObject("restaurant");
//p.put("rest_id", rest);
ParseObject rest = user.getParseObject("restaurant");
p.put("rest_id", rest);
p.put("table_id", num);
p.saveInBackground();
return p;
......@@ -147,9 +137,8 @@ public class Helper {
public static ParseObject findTable(ParseUser user, int num) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Table");
//ParseObject rest = user.getParseObject("restaurant");
//query.whereEqualTo("rest_id", rest).whereEqualTo("table_id", num);
query.whereEqualTo("table_id", num);
ParseObject rest = user.getParseObject("restaurant");
query.whereEqualTo("rest_id", rest).whereEqualTo("table_id", num);
List<ParseObject> list = null;
try {
......@@ -165,15 +154,4 @@ public class Helper {
return null;
}
public static List<ParseObject> getQueue() {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Item_Order").whereEqualTo("completed", false);
List<ParseObject> list = null;
try {
list = query.find();
} catch(Exception e) {
return null;
}
return list;
}
}
package com.cs123grpE.restaurantorderingsystem ;
import java.util.ArrayList;
import java.util.List;
import com.parse.*;
......@@ -95,17 +93,14 @@ public class Kitchen extends Activity {
public void setListData()
{
List<ParseObject> queue = Helper.getQueue();
for (int i = 0; i < queue.size(); i++) {
for (int i = 0; i < 11; i++) {
final OrderModel sched = new OrderModel();
ParseObject obj = queue.get(i);
/******* Firstly take data in model object ******/
//ParseObject item = obj.getParseObject("item_id");
sched.setFoodName(obj.getString("item_name") + " " + obj.getInt("quantity"));
sched.setTableNumber("Table Number: "+ obj.getInt("table_no"));
sched.setFoodName(""+i);
sched.setTableNumber("Table Number: "+i);
/******** Take Model Object in ArrayList **********/
CustomListViewValuesArr.add( sched );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment