Commit c2d747bb authored by Nina Sanchez's avatar Nina Sanchez

Works now

parent dc40a971
......@@ -29,7 +29,8 @@ public final class R {
public static final int prelimlogo=0x7f020003;
}
public static final class id {
public static final int action_settings=0x7f080040;
public static final int aaa=0x7f08003e;
public static final int action_settings=0x7f080042;
public static final int btnAddMenu=0x7f08001c;
public static final int btnAddToCart=0x7f08003c;
public static final int btnAdmin=0x7f08002f;
......@@ -62,13 +63,14 @@ 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=0x7f08003d;
public static final int price=0x7f08003f;
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=0x7f08003f;
public static final int textView00=0x7f080040;
public static final int textView01=0x7f080041;
public static final int textView1=0x7f08001e;
public static final int textView2=0x7f080020;
public static final int textView3=0x7f08002e;
......@@ -110,9 +112,10 @@ public final class R {
public static final int activity_settings=0x7f03000b;
public static final int activity_table_chooser=0x7f03000c;
public static final int activity_view_profile=0x7f03000d;
public static final int group=0x7f03000e;
public static final int menu_item=0x7f03000f;
public static final int row=0x7f030010;
public static final int cart_item=0x7f03000e;
public static final int group=0x7f03000f;
public static final int menu_item=0x7f030010;
public static final int row=0x7f030011;
}
public static final class menu {
public static final int add_edit_profile=0x7f070000;
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/nameF"
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: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
......@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
......@@ -12,10 +12,38 @@
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tableName"
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: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.cart_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
......@@ -49,4 +87,25 @@ 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,20 +47,16 @@ public class Customer extends Activity {
Intent i = getIntent();
tableNum = i.getIntExtra("tableNumber", 0);
ParseUser pu = ParseUser.getCurrentUser();
if (pu == null) {
Log.i("help", "null pls");
}
table = Helper.findTable(pu, tableNum);
//ParseUser pu = ParseUser.getCurrentUser();
table = Helper.findTable(null, tableNum);
if(table==null) {
table = Helper.addTable(pu, tableNum);
table = Helper.addTable(null, 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));
......@@ -161,6 +157,10 @@ 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);
startActivity(i);
startActivityForResult(i, 1);
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("Order");
ParseObject order = new ParseObject("Item_Order");
order.put("item_id", obj);
order.put("quantity", 3);
order.put("table_id", table);
......@@ -404,10 +404,14 @@ public class Customer extends Activity {
System.out.println("RESULT :D");
}
if(requestCode==1) {
String key = data.getStringExtra("itemName");
int value = data.getIntExtra("qty", 0);
int value = data.getIntExtra("quantity", 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,13 +83,23 @@ public class Helper {
}
public static void addOrder(ParseObject table, ParseObject item, int qty) {
ParseObject order = new ParseObject("Order");
ParseObject order = new ParseObject("Item_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();
order.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
// myObjectSavedSuccessfully();
} else {
//myObjectSaveDidNotSucceed();
}
}
});
}
public static void setOrderAttribute(ParseObject order, String key, boolean value) {
......@@ -128,8 +138,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;
......@@ -137,8 +147,9 @@ 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);
//ParseObject rest = user.getParseObject("restaurant");
//query.whereEqualTo("rest_id", rest).whereEqualTo("table_id", num);
query.whereEqualTo("table_id", num);
List<ParseObject> list = null;
try {
......@@ -154,4 +165,15 @@ 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.*;
......@@ -93,14 +95,17 @@ public class Kitchen extends Activity {
public void setListData()
{
for (int i = 0; i < 11; i++) {
List<ParseObject> queue = Helper.getQueue();
final OrderModel sched = new OrderModel();
for (int i = 0; i < queue.size(); i++) {
final OrderModel sched = new OrderModel();
ParseObject obj = queue.get(i);
/******* Firstly take data in model object ******/
sched.setFoodName(""+i);
sched.setTableNumber("Table Number: "+i);
//ParseObject item = obj.getParseObject("item_id");
sched.setFoodName(obj.getString("item_name") + " " + obj.getInt("quantity"));
sched.setTableNumber("Table Number: "+ obj.getInt("table_no"));
/******** 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