Commit f42a7428 authored by Nina Sanchez's avatar Nina Sanchez

Thing

parent 20f16f70
......@@ -31,5 +31,7 @@
<activity android:name=".KitchenAdapter"/>
<!--created by ADT ext plugin at 2015-12-02 23:42:23-->
<activity android:name=".OrderModel"/>
<!--created by ADT ext plugin at 2015-12-04 10:20:30-->
<activity android:name=".TableChooser"/>
</application>
</manifest>
......@@ -31,5 +31,7 @@
<activity android:name=".KitchenAdapter"/>
<!--created by ADT ext plugin at 2015-12-02 23:42:23-->
<activity android:name=".OrderModel"/>
<!--created by ADT ext plugin at 2015-12-04 10:20:30-->
<activity android:name=".TableChooser"/>
</application>
</manifest>
......@@ -29,68 +29,71 @@ public final class R {
public static final int prelimlogo=0x7f020003;
}
public static final class id {
public static final int action_settings=0x7f08003d;
public static final int btnAddMenu=0x7f08001b;
public static final int btnAddToCart=0x7f080039;
public static final int btnAdmin=0x7f08002e;
public static final int btnBack=0x7f080037;
public static final int btnCancel=0x7f08002b;
public static final int btnCart=0x7f080017;
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;
public static final int btnBack=0x7f08003a;
public static final int btnCancel=0x7f08002c;
public static final int btnCart=0x7f080018;
public static final int btnConfigure=0x7f08000b;
public static final int btnConfirm=0x7f08002c;
public static final int btnCustomer=0x7f080030;
public static final int btnDelete=0x7f080019;
public static final int btnDeleteMenu=0x7f08001a;
public static final int btnConfirm=0x7f08002d;
public static final int btnCustomer=0x7f080031;
public static final int btnDelete=0x7f08001a;
public static final int btnDeleteMenu=0x7f08001b;
public static final int btnDone=0x7f080005;
public static final int btnEditBill=0x7f08000a;
public static final int btnEditMenu=0x7f080009;
public static final int btnFinalize=0x7f08000e;
public static final int btnKitchen=0x7f08002f;
public static final int btnLogin=0x7f080022;
public static final int btnKitchen=0x7f080030;
public static final int btnLogin=0x7f080023;
public static final int btnLogout=0x7f08000c;
public static final int btnOff=0x7f080011;
public static final int btnOn=0x7f080012;
public static final int btnRegister=0x7f080023;
public static final int btnRevert=0x7f080018;
public static final int btnRegister=0x7f080024;
public static final int btnRevert=0x7f080019;
public static final int btnSave=0x7f080006;
public static final int btnSearch=0x7f080015;
public static final int checkRem=0x7f080021;
public static final int list=0x7f080016;
public static final int checkRem=0x7f080022;
public static final int enter=0x7f080034;
public static final int list=0x7f080017;
public static final int listCart=0x7f08000d;
public static final int listKitchen=0x7f08001c;
public static final int listKitchen=0x7f08001d;
public static final int listview1=0x7f080013;
public static final int logo=0x7f080007;
public static final int logout=0x7f080031;
public static final int priceName=0x7f080033;
public static final int quantity=0x7f080038;
public static final int tableName=0x7f08003b;
public static final int textView00=0x7f08003a;
public static final int textView01=0x7f08003c;
public static final int textView1=0x7f08001d;
public static final int textView2=0x7f08001f;
public static final int textView3=0x7f08002d;
public static final int textView4=0x7f080024;
public static final int textView5=0x7f080025;
public static final int textView6=0x7f080027;
public static final int textView7=0x7f080029;
public static final int logout=0x7f080032;
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 textView1=0x7f08001e;
public static final int textView2=0x7f080020;
public static final int textView3=0x7f08002e;
public static final int textView4=0x7f080025;
public static final int textView5=0x7f080026;
public static final int textView6=0x7f080028;
public static final int textView7=0x7f08002a;
public static final int textView8=0x7f080008;
public static final int textView9=0x7f080010;
public static final int totesPrice=0x7f08000f;
public static final int tvDesc=0x7f080035;
public static final int tvName=0x7f080032;
public static final int tvPrice=0x7f080034;
public static final int tvTags=0x7f080036;
public static final int tvDesc=0x7f080038;
public static final int tvName=0x7f080035;
public static final int tvPrice=0x7f080037;
public static final int tvTags=0x7f080039;
public static final int txtCategory=0x7f080002;
public static final int txtDescription=0x7f080003;
public static final int txtIngredients=0x7f080004;
public static final int txtItemName=0x7f080000;
public static final int txtPass=0x7f080020;
public static final int txtPass2=0x7f08002a;
public static final int txtPass=0x7f080021;
public static final int txtPass2=0x7f08002b;
public static final int txtPrice=0x7f080001;
public static final int txtResto=0x7f080026;
public static final int txtResto=0x7f080027;
public static final int txtSearch=0x7f080014;
public static final int txtUser=0x7f08001e;
public static final int txtUser2=0x7f080028;
public static final int txtUser=0x7f08001f;
public static final int txtUser2=0x7f080029;
}
public static final class layout {
public static final int activity_add_edit_profile=0x7f030000;
......@@ -105,10 +108,11 @@ public final class R {
public static final int activity_register=0x7f030009;
public static final int activity_select_account=0x7f03000a;
public static final int activity_settings=0x7f03000b;
public static final int activity_view_profile=0x7f03000c;
public static final int group=0x7f03000d;
public static final int menu_item=0x7f03000e;
public static final int row=0x7f03000f;
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 class menu {
public static final int add_edit_profile=0x7f070000;
......
......@@ -65,14 +65,17 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal" >
android:gravity="center_horizontal|left"
android:orientation="horizontal" >
<EditText
android:id="@+id/txtSearch"
android:layout_width="wrap_content"
android:layout_width="257dp"
android:layout_height="wrap_content"
android:ems="25" />
android:ems="25" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btnSearch"
......@@ -81,6 +84,13 @@
android:text="Search"
android:onClick="search" />
<Button
android:id="@+id/returnData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Return"
android:onClick="returnData" />
</LinearLayout>
<LinearLayout
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.cs123grpE.restaurantorderingsystem.TableChooser" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Table number"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/tableNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" >
<requestFocus />
</EditText>
</LinearLayout>
<Button
android:id="@+id/enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter"
android:onClick="toCustomer"/>
</LinearLayout>
......@@ -68,7 +68,7 @@ public class AddEditProfile extends Activity {
EditText des = (EditText) findViewById (R.id.txtDescription);
des.setText((String) obj.get("item_desc"));
EditText tag = (EditText) findViewById (R.id.txtIngredients);
tag.setText((String) obj.get("tag"));
EditText cat = (EditText) findViewById (R.id.txtCategory);
cat.setText( (String) ( (ParseObject) obj.get("category") ).get("category_name") );
}
......
package com.cs123grpE.restaurantorderingsystem;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
......@@ -36,7 +37,16 @@ public class Cart extends Activity {
public void finalize (View v) {
// Send cart contents to kitchen and clear
setResult(Activity.RESULT_OK,
new Intent().putExtra("finalize", true));
finish();
Toast.makeText(this, "Orders finalized.", Toast.LENGTH_SHORT).show();
}
public void onBackPressed() {
setResult(Activity.RESULT_CANCELED, null);
finish();
}
}
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
......@@ -33,13 +35,29 @@ public class Customer extends Activity {
List<String> listDataHeaderId;
HashMap<String, List<String>> listDataChild;
HashMap<String, List<ParseObject>> listDataChildObject;
int tableNum;
ParseObject table;
HashMap<String, Integer> cart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer);
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);
if(table==null) {
table = Helper.addTable(pu, tableNum);
}
prepareLists();
cart = new HashMap<String, Integer>();
//generateMenu("", true);
......@@ -82,45 +100,6 @@ public class Customer extends Activity {
}
});
// Listview on child click listener
exp.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
String name = listDataChild.get(listDataHeader.get(groupPosition))
.get(childPosition);
ParseObject x = null;
ParseObject order = null;
double price = 0;
try {
x = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst();
price = x.getDouble("item_price");
order = new ParseObject("Order");
order.put("item_id", x.getObjectId());
order.put("quantity", 1);
order.saveInBackground();
Intent i = new Intent(getApplicationContext(), ViewProfile.class);
i.putExtra("menu_name", name);
startActivity(i);
}catch(Exception e) {}
Toast.makeText(
getApplicationContext(),
listDataHeader.get(groupPosition) + " : " +
listDataChild.get(listDataHeader.get(groupPosition))
.get(childPosition) + " price: " + price, Toast.LENGTH_SHORT
).show();
return false;
}
});
//expList.setOnChildClickListener(this);
}
......@@ -170,12 +149,19 @@ public class Customer extends Activity {
EditText searchString = (EditText) findViewById (R.id.txtSearch);
String criteria = searchString.getText().toString().trim();
prepareLists(criteria);
}
public void returnData(View v) {
EditText searchString = (EditText) findViewById (R.id.txtSearch);
searchString.setText("");
prepareLists();
}
public void viewCart (View v) {
// go to cart screen
Intent i = new Intent (this, Cart.class);
startActivity (i);
startActivityForResult (i, 2);
}
private void prepareLists() {
......@@ -297,12 +283,141 @@ public class Customer extends Activity {
}
}
private void prepareLists(String searchQuery) {
prepareListData(searchQuery);
ListView lv = (ListView)findViewById(R.id.listview1);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
exp = (ExpandableListView)findViewById(R.id.list);
epa = new ExpandableAdapter(this, listDataHeader, listDataChild);
exp.setAdapter(epa);
exp.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// Toast.makeText(getApplicationContext(),
// "Group Clicked " + listDataHeader.get(groupPosition),
// Toast.LENGTH_SHORT).show();
return false;
}
});
// Listview Group expanded listener
exp.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Expanded",
Toast.LENGTH_SHORT).show();
}
});
// Listview Group collasped listener
exp.setOnGroupCollapseListener(new OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Collapsed",
Toast.LENGTH_SHORT).show();
}
});
// Listview on child click listener
exp.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
//editMenu(listDataHeader.get(groupPosition), childPosition);
String cat = listDataHeader.get(groupPosition);
String name = ((String) ( (ParseObject) listDataChildObject.get(cat).get(childPosition)).get("item_name"));
ParseObject obj = Helper.findObject("Menu_Item", "item_name", "Sinigang");
Log.i("ParseObject", obj.getString("item_name"));
ParseObject order = new ParseObject("Order");
order.put("item_id", obj);
order.put("quantity", 3);
order.put("table_id", table);
order.put("paid", false);
order.put("completed", false);
order.saveInBackground();
Intent i = new Intent(getApplicationContext(), ViewProfile.class);
i.putExtra("menu_name", name);
startActivityForResult(i, 1);
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition)
+ " : "
+ listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition), Toast.LENGTH_SHORT)
.show();
return false;
}
});
}
private void prepareListData(String searchQuery) {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
listDataChildObject = new HashMap<String, List<ParseObject>>();
String header = "Items containing the query: \'" + searchQuery + "\'";
listDataHeader.add(header);
ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Menu_Item").whereContains("item_name", searchQuery);
List<ParseObject> listChildren = null;
try {
listChildren = query1.find();
} catch(Exception e) {}
int n = listChildren.size();
List<String> list = new ArrayList<String>();
List<ParseObject> listObject = new ArrayList<ParseObject>();
for(int i = 0; i < n; i++) {
ParseObject obj = listChildren.get(i);
String name = (String) obj.get("item_name");
list.add(name);
listObject.add(obj);
}
listDataChild.put(header, list);
listDataChildObject.put(header, listObject);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, getIntent());
if(resultCode==RESULT_OK && requestCode==1){
System.out.println("RESULT :D");
}
if(requestCode==1) {
String key = data.getStringExtra("itemName");
int value = data.getIntExtra("qty", 0);
cart.put(key, value);
}
else if(requestCode==2 && data.getBooleanExtra("finalize", false)) {
for(Map.Entry<String, Integer> me: cart.entrySet()) {
String key = me.getKey();
int value = me.getValue();
ParseObject obj = Helper.findObject("Menu_Item", "item_name", key);
Helper.addOrder(table, obj, value);
}
cart.clear();
}
prepareLists();
}
}
......@@ -74,6 +74,7 @@ public class EditMenu extends Activity {
public void deleteMenu (View v) {
// show dialog for confirmation
Toast.makeText(this, "You will delete a Menu Item.", Toast.LENGTH_SHORT).show();
}
......@@ -197,35 +198,4 @@ public class EditMenu extends Activity {
prepareLists();
}
/*private void prepareListData() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
// Adding child data
listDataHeader.add("MEAT");
listDataHeader.add("SOUP");
listDataHeader.add("FISH");
// Adding child data
List<String> top250 = new ArrayList<String>();
top250.add("CRISPY PATA");
top250.add("ADUBA");
top250.add("PATAATIM");
top250.add("SINIGANG");
List<String> nowShowing = new ArrayList<String>();
nowShowing.add("CHICKEN NOODLE SOUP");
nowShowing.add("SINIGANG SA MISO");
nowShowing.add("SPINACH");
nowShowing.add("BIRD'S NEST");
List<String> comingSoon = new ArrayList<String>();
comingSoon.add("TALAKITOK");
comingSoon.add("PAKSIW");
comingSoon.add("ESCABECHE");
listDataChild.put(listDataHeader.get(0), top250); // Header, Child data
listDataChild.put(listDataHeader.get(1), nowShowing);
listDataChild.put(listDataHeader.get(2), comingSoon);
}*/
}
......@@ -3,6 +3,7 @@ package com.cs123grpE.restaurantorderingsystem;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
......@@ -37,7 +38,7 @@ public class Helper {
for(ParseObject a: list) {
if(className.equals("Menu_Item") && isActive(a)) return a;
if(className.equals("Category")) return a;
if(!className.equals("Menu_Item")) return a;
}
return null;
......@@ -49,6 +50,8 @@ public class Helper {
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
parseIngredients(item, tag);
item.put("tag", tag);
ParseObject obj = findObject("Category", "category_name", cat);
if(obj==null) obj = addCategory(cat);
......@@ -62,6 +65,8 @@ public class Helper {
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
parseIngredients(item, tag);
item.put("tag", tag);
ParseObject obj = findObject("Category", "category_name", cat);
if(obj==null) obj = addCategory(cat);
......@@ -77,12 +82,76 @@ public class Helper {
return p;
}
public static void addOrder(ParseObject item, int table_num, int qty) {
public static void addOrder(ParseObject table, ParseObject item, int qty) {
ParseObject order = new ParseObject("Order");
order.put("item_id", item);
//order.put("table_id", table_num); // get pointer
order.put("quantity", qty);
order.put("table_id", table);
order.put("paid", false);
order.put("completed", false);
order.saveInBackground();
}
public static void setOrderAttribute(ParseObject order, String key, boolean value) {
order.put(key, value);
order.saveInBackground();
}
public static void parseIngredients(ParseObject item, String ingredients) {
String[] ingr = ingredients.split(", ");
ArrayList<ParseObject> al = new ArrayList<ParseObject>();
for(String x: ingr) {
ParseObject p = findObject("Ingredient", "ingredient_name", x);
if(p==null)
p = addIngredient(x);
al.add(p);
}
item.put("item_ingredients", al);
}
public static ParseObject addIngredient(String ingr) {
ParseObject p = new ParseObject("Ingredient");
p.put("ingredient_name", ingr);
p.saveInBackground();
return p;
}
public static ParseObject addRestaurant(String rest) {
ParseObject p = new ParseObject("Restaurant");
p.put("rest_name", rest);
p.saveInBackground();
return p;
}
public static ParseObject addTable(ParseUser user, int num) {
ParseObject p = new ParseObject("Table");
ParseObject rest = user.getParseObject("restaurant");
p.put("rest_id", rest);
p.put("table_id", num);
p.saveInBackground();
return p;
}
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);
List<ParseObject> list = null;
try {
list = query.find();
} catch(Exception e) {
return null;
}
for(ParseObject a: list) {
return a;
}
return null;
}
}
package com.cs123grpE.restaurantorderingsystem ;
import java.util.ArrayList;
import com.parse.*;
import android.app.Activity;
import android.content.Intent;
......@@ -90,10 +92,12 @@ public class Kitchen extends Activity {
public void setListData()
{
for (int i = 0; i < 11; i++) {
final OrderModel sched = new OrderModel();
/******* Firstly take data in model object ******/
sched.setFoodName(""+i);
sched.setTableNumber("Table Number: "+i);
......@@ -102,4 +106,9 @@ public class Kitchen extends Activity {
CustomListViewValuesArr.add( sched );
}
}
//public void prepareListData() {
// ParseQuery<ParseObject> query = ParseQuery.getQuery("Order").whereMatches(key, itemName);
//}
}
......@@ -122,7 +122,7 @@ public class KitchenAdapter extends BaseAdapter implements OnClickListener{
/**** Call onItemClick Method inside CustomListViewAndroidExample Class ( See Below )****/
sct.onItemClick(mPosition);
//sct.onItemClick(mPosition);
}
......
......@@ -21,44 +21,6 @@ public class Login extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
/*
ParseObject crispyPata = new ParseObject("Menu_Item");
crispyPata.put("item_name", "Crispy Pata");
crispyPata.put("item_price", 100.00);
crispyPata.saveInBackground();
ParseObject aduba = new ParseObject("Menu_Item");
aduba.put("item_name", "Aduba");
aduba.put("item_price", 103.00);
aduba.saveInBackground();
ParseObject pataatim = new ParseObject("Menu_Item");
pataatim.put("item_name", "Pataatim");
pataatim.put("item_price", 102.00);
pataatim.saveInBackground();
ParseObject sinigang = new ParseObject("Menu_Item");
sinigang.put("item_name", "Sinigang");
sinigang.put("item_price", 101.00);
sinigang.saveInBackground();
ParseObject cns = new ParseObject("Menu_Item");
cns.put("item_name", "Chicken Noodle Soup");
cns.put("item_price", 40.00);
cns.saveInBackground();
ParseObject birdsnest = new ParseObject("Menu_Item");
birdsnest.put("item_name", "Bird's Nest Soup");
birdsnest.put("item_price", 40.00);
birdsnest.saveInBackground();
ParseObject paksiw = new ParseObject("Menu_Item");
paksiw.put("item_name", "Paksiw");
paksiw.put("item_price", 80.00);
paksiw.saveInBackground();
*/
// check for saved preferences, populate the fields
list = getSharedPreferences("Users", Context.MODE_PRIVATE);
if (!list.contains("nutzlich")) {
......
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -81,16 +82,38 @@ public class Register extends Activity {
Toast.makeText(this, "Please fill in all fields.", Toast.LENGTH_SHORT).show();
}
else {
// save in an arraylist (JSON in SharedPreferences)
/*User newUser = new User(name.getText().toString(),
user.getText().toString(), pass.getText().toString());
array.add(newUser);
ObjectMapper map = new ObjectMapper();
String json = map.writeValueAsString(array);*/
currUser.setUsername(username);
currUser.setPassword(password);
currUser.signUpInBackground();
ParseUser currentUser = new ParseUser();
currentUser.setUsername(username);
currentUser.setPassword(password);
currentUser.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});
List<ParseUser> al = null;
ParseObject resto = Helper.findObject("Restaurant", "rest_name", restaurant);
if(resto==null) {
resto = Helper.addRestaurant(restaurant);
al = new ArrayList<ParseUser>();
resto.put("rest_name", restaurant);
}
else
al = resto.getList("users");
resto.saveInBackground();
currentUser.put("restaurant", resto);
currentUser.saveInBackground();
//al.add(currentUser);
//resto.put("users", al);
/*SharedPreferences.Editor editor = list.edit();
editor.putString("nutzlich", json);
......
......@@ -55,7 +55,7 @@ public class SelectAccount extends Activity {
public void toCustomer (View v) {
// go to the Customer account main screen
Intent i = new Intent (this, Customer.class);
Intent i = new Intent (this, TableChooser.class);
startActivity(i);
finish();
}
......
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ExpandableListView.OnGroupCollapseListener;
import android.widget.ExpandableListView.OnGroupExpandListener;
import android.widget.Toast;
import com.parse.*;
public class TableChooser extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_table_chooser);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return false;
}
public void onBackPressed() {
// do nothing
}
public void toCustomer(View v) {
Intent i = new Intent (this, Customer.class);
EditText nm = (EditText) findViewById (R.id.tableNum);
i.putExtra("tableNumber", Integer.parseInt(nm.getText().toString().trim()));
startActivity(i);
finish();
}
}
......@@ -20,6 +20,8 @@ public class ViewProfile extends Activity {
String tags = "";
double price = 0;
ParseObject obj;
ParseObject table;
int tableNum;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -34,12 +36,15 @@ public class ViewProfile extends Activity {
Intent i = getIntent();
String name = i.getStringExtra("menu_name");
tableNum = i.getIntExtra("tableNum", 0);
table = Helper.findTable(ParseUser.getCurrentUser(), tableNum);
obj = null;
try{
obj = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst();
itemname = obj.getString("item_name");
description = obj.getString("item_desc");
tags = obj.getString("ingredient_name");
tags = obj.getString("tag");
price = obj.getDouble("item_price");
}catch(Exception e) {}
......@@ -83,7 +88,11 @@ public class ViewProfile extends Activity {
NumberPicker np = (NumberPicker) findViewById(R.id.quantity);
int qty = np.getValue();
Helper.addOrder(obj, 0, qty); // change table num
//Helper.addOrder(table, obj, qty);
setResult(Activity.RESULT_OK,
new Intent().putExtra("itemName", itemname).putExtra("quantity", qty).putExtra("tableNumber", tableNum));
finish();
Toast.makeText(getApplicationContext(),
"Ordered " + qty + " " + itemname,
......@@ -94,6 +103,7 @@ public class ViewProfile extends Activity {
public void onBackPressed() {
// go back to the Customer screen
setResult(Activity.RESULT_CANCELED, new Intent().putExtra("tableNumber", tableNum));
finish();
}
}
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