You are on page 1of 95

SYNOPSIS

The online bookstore is


opened in the network, not
a physical store but a
virtual store. In order to
improve the efficiency
of the query, the site can
not only use a single
condition query, but also
can use multiple
conditions to achieve
accurate
query, the query will be
added after the shopping
cart function, the query
function, And then you
can purchase to submit
orders, generate orders and
payment to complete the
entire purchase process
function, the user can
submit orders before
the order to modify, when
the seller after the
shipment can also confirm
the receipt of the operation
to complete the
transaction , After the
completion of the
transaction the user can
comment on the
corresponding book, the
other
unregistered users can not
purchase books or add to
the shopping cart
operation, the user must
first register as a member
of the bookstore, log in
before the above
operations. In addition to
the foreground function,
the need for background
management,
administrators can log in
through the corresponding
Web site background, after
the classification of the
book catalog and book
information to add,
modify and delete, but
also the order information
management, Such as the
cancellation of unpaid or
unpaid orders, the
payment of orders for
delivery operations, etc.,
can also reply to the user's
comments, you can reply
to each comment, and the
client's book details page
is displayed
The online food ordering system has been developed to override the problem prevailing in the
practicing system. This software is supported to eliminated and in some cases reduce the
hardships faced by this existing system. Moreover this system is designed for the particular need
of the company to carryout operations in a smooth and effective manner. The application is
reduced as much as possible to avoid errors while entering the data. It also provides error
message while entering invalid data. No formal knowledge is needed for the user to use this
application. Thus by this all it proves it is user friendly. Online food ordering system, as
described above, can lead to error free, secure, reliable and fast management system. It can assist
the user to concentrate on their other activities rather to concentrate on the record keeping. Thus
it will help organization in better utilization of resources.

1. INTRODUCTION
The purpose of online food ordering system is to automate the existing manual system by the
help of computerized equipments and full-fledged computer software, fulfilling their
requirements, so that their valuable data/information can be stored for a longer period with easy
accessing and manipulation of the same. The required software and hardware are easily available
and easy to work with. Online food ordering system, as described above, can lead to error free
secure, reliable and fast management system. It can assist the user to concentrate on their other
activities rather to concentrate on the record keeping. The organization can maintain
computerized records without redundant entries. That means that one need not be distracted by
information’s that is not relevant, while being able to reach the information’s. The aim is to
automated its existing manual system by the help of computerized equipments and fully fledged
computer software, fulfilling their requirements, so that their valuable data/information’s can be
stored for a longer period with easy accessing and manipulation of the same. Basically the
project describes how to manage for good performance and better services for the clients.

2. SYSTEM STUDY

2.1 PROJECT DESCRIPTION

With the increasing popularity of food delivery in colleges and universities, the traditional
telephone order food has become inconvenient to the customers and the food delivery store. The
online food ordering system provides convenience for the customers. It overcomes the
disadvantage of the traditional queuing system. This android application increases the takeaway
of foods than visitors. Therefore, this system enhances the speed and standardization of taking
the order from the customer. It provides a better communication platform. The user details are
noted electronically. Using this application, the customers need not go to the restaurant by
themselves, but they can order the meals through Android mobiles anywhere. In this system
there are four namely, Admin, Delivery boy, Restaurant manager and User. Admin can login,
manage restaurants by adding, updating and deleting, manage delivery person by adding,
updating and deleting. Admin can also check registered users and the orders total count. Delivery
boy can login and see the allotted orders, they can upload the status of the order whether it is
picked, on the way or delivered. Restaurant manager can login and update their restaurants
details, they can even check for reviews and ratings given by users. They can manage menu by
adding new items and deleting unwanted. Manager can manage orders by allotting to the
delivery boy, can update status of delivery. Manager can see the payment done by electronic
mode. Users can register and login. Users have option to choose the cuisine, hotels nearby. User
will get details of restaurants like name, location and reviews. Users can select the food from the
menu list, can add to favorites and can get processed further. User can view the history of their
orders and the current orders status. User have online payment options. User will get notification
of the order status.

2.1.1 EXISTING SYSTEM

In an existing system for giving any orders, a user should visit Hotels or Restaurants to know
about food items and then give orders and pay in advance or you need to select menu and place
an order on call. In this method time and manual work is required. Maintaining critical
information in the files and manuals is full of risk and tedious process. Tracking of Delivery is
not available in previous applications and Booking of a particular table in advance is also not
available. Customization of Order, Current status of the order is not available. Some systems
contain an outdated database that is Restaurant is closed, yet it shows on the application.

2.1.2 PROPORSED SYSTEM

The application is an online food ordering system which consists of GPS option where the
application user can select the option to see the restaurants nearby his vicinity. It is mainly
implemented using Global Positioning System (GPS).Users with location-aware wireless devices
can query about their surroundings at any place, anytime[2]. This android application enables the
end users to register on the application, select the food from menu card and order food by an
android app. The User will receive a confirmation call, by selecting and ordering the food they
want to have. The results after selecting food from menu card will directly appear in web
application part on the system of a manager. By using this application the work of waiter is
reduced or we can say that work is nullified. The benefit is that if there is a rush in a restaurant
then there will be chances that the waiters will be unavailable and then the users can directly
order the food by using android application. The user is given Username and Password to Login.

2.2 REQUIREMENT SPECIFICATION

2.2.1 HARDWARE REQUIREMENTS

Hardware requirements. The most common set of requirements defined by any


operating system or software application is the physical computer resources, also known
as hardware, A hardware requirements list is often accompanied by a hardware compatibility list
(HCL), especially in case of operating systems.
 Operating System : Windows 7/8/8.1/10
 Front end : HTML,CSS
 Back end : PHP
 IDE : DREMVIEWER
 Data base : MYSQL

2.2.2 SOFTWARE REQUIREMENTS

The software requirements document is the specification of the system. It Should include both a
definition and requirements. It is useful in estimating cost, planning team activities and
performing tasks throughout the development activity.

 Processor : Dual core processor 2.6.0 GHz


 RAM : 1GB
 Hard disk : 160 GB
 Compact Disk : 650 MB
 Keyboard : Standard keyboard
 Monitor : 15 inch color monitor

4. SYSTEM DESIGN

System design represents the project diagrammatically using the logical shapes. Systems design
is the process of defining the architecture, components, modules, interfaces, and data for a
system to satisfy specified requirements. Systems design could be seen as the application of
systems theory to product development.

4.1 LOGICAL DESIGN


Logical design is an abstract concept in computer programming by whichprogrammers arranges
data in a series of logical relationships known as attributes or entities. An entity refers to a chunk
of information, whereas an attribute defines the unique properties of an entity.

4.2 MODULE DESCRIPTION

A module is a software component or part of a program that contains one or more routines.
One or more independently developed modules make up a program. An enterprise- level
software application may contain several different modules, and each module serves unique
and separate business operations. Modules make a programmer's job easy by allowing the
programmer to focus on only one area of the functionality of the software application.
Modules are typically incorporated into the program (software) through interfaces.

MODULES

 ADMIN
 USER

MODULE DESCRIPTION

ADMIN

Login

Admin is the head of our android application they having a unique user name and password for
login session.

Add food

Admin will add food categories and food details in these application all of the food related
information’s will be shared on to the customer.

View orders

In this module describe as admin can view all of the orders who can order the food and food
ordering details in to these application.
USERS

Register & Login

If the student first time enters into our application they will enters all the personal information’s
for the registration process after they will get an unique user name and password for a login
session.

View food

In these modules describe as if every users view the food and food details on this functions, the
food details will be describe as food name, food quantity, food price, food offer.

Order

User can view all the food and food details after they wish to get permission to ordering a food
via our android phone and check the order is confirmed or not confirmed.

5. SYSTEM DEVELOPMENT

System development is one of the main aspects in this project. This means program with the help
of that program of which the system works. System development is actually a coding which
would be accurately made from which we must complete accordingly and the program. Every
language has their own personal coding.
5.1 PROGRAM DEVELOPMENT

System development is the process of defining, designing, testing, and implementing a


new software application or program. It could include the internal development of customized
systems, the creation of database systems, or the acquisition of third party developed software.
written standards and procedures must glide all information systems processing functions. The
organization’s management must define and implement standards and adopt an appropriate
system development life cycle methodology govern8ingthe process of developing, acquiring,
implementing, and maintaining computerized information systems and related technology.

SOURCE CODE

ADMIN L;OGIN

package com.example.food_order;
import java.io.DataInputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Random;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class admin_login extends Activity {


ProgressDialog pDialog;

Button loginbtn;
EditText useremail;
EditText password;
TextView ttl;
public static String uemail="";
TextView register;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_login);
loginbtn = (Button) findViewById(R.id.button1);
register = (TextView)findViewById(R.id.textView2);
ttl = (TextView)findViewById(R.id.textView1);

useremail = (EditText)findViewById(R.id.u_name);
password = (EditText)findViewById(R.id.pass);
useremail.setHint("User Name");
//useremail.setText("admin");
//password.setText("admin");
ttl.setText("Admin Login");
register.setVisibility(View.INVISIBLE);
loginbtn.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View arg0) {
// new userlogin().execute();
String lname=useremail.getText().toString();
String lpass=password.getText().toString();
if(lname.equals("admin")&&(lpass.equals("admin"))){

Intent in = new Intent(getApplicationContext(), admin_home.class);


startActivity(in);
}
else
{
Toast.makeText(getApplicationContext(), "Invalid user",
Toast.LENGTH_LONG).show();
}
}
});

// register.setOnClickListener(new OnClickListener()
// {
//
// @Override
// public void onClick(View arg0) {
//
// Intent i = new
Intent(admin_login.this,user_reg.class);
//
//
// startActivity(i);
//
//
// }
// });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

package com.example.food_order;

import java.io.DataInputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Random;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class admin_home extends Activity {


TextView new_food,new_order,delivery,logout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_home);

new_food = (TextView) findViewById(R.id.textView2);


new_order = (TextView) findViewById(R.id.textView3);
delivery = (TextView) findViewById(R.id.textView4);
logout = (TextView) findViewById(R.id.textView5);

new_food.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
Intent in = new Intent(getApplicationContext(), admin_new_food.class);
startActivity(in);
}
});
new_order.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
Intent in = new Intent(getApplicationContext(),
admin_new_order.class);
startActivity(in);
}
});

delivery.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
Intent in = new Intent(getApplicationContext(), admin_delivery.class);
startActivity(in);
}
});

logout.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
finish();
}
});

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

ADMIN VIEW DELIVEDRY

package com.example.food_order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class admin_delivery extends Activity {


ProgressDialog pDialog;
ProgressDialog pd;
List<String> categories = new ArrayList<String>();
ListView listView;
public static String id="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_my_book);
pd = new ProgressDialog(this);
pd.setMessage("Loading please wait");
pd.setCancelable(false);
listView = (ListView) findViewById(R.id.listView1);
commonRequestThread();

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void commonRequestThread() {
status = "Please try again later";

pd.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Runnable runnable = new Runnable() {
public void run() {
pd.dismiss();
if(user_id.size()<1){
if(isError) {
toast("No result found");
//finish();
}else{
toast("No data found");
}
//finish();
}else{
adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1,
android.R.id.text1, values);
listView.setAdapter(adapter);

}
}
};
try {
runOnUiThread(runnable);
} catch (Exception e) {
// TODO: handle exception
}
}
};
Thread checkUpdate = new Thread() {
public void run() {
try {
commonRequest();
} catch (Exception e) {
System.out.println("Error in fetching json : "
+ e.toString());
}
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
}

Boolean isError = true;


public void commonRequest()
{
isError = true;
System.out.println("Common request sent : ");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://"+server_ipaddress.sip+"/admin_view_booking1.php");
InputStream is = null;
String result = "";
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
//nameValuePairs.add(new
BasicNameValuePair("email",user_login.uemail));
//nameValuePairs.add(new
BasicNameValuePair("user1",police_chat.selected_user));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
is = httpEntity.getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
System.out.println("Error 1 : "+e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error 2 : "+e.toString());
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
System.out.println("Error 2 : "+e.toString());
}
System.out.println("result : "+result);
res = result;
JSONObject food_object;

// TextView txtFirstName = (TextView)


rootView.findViewById(R.id.txtFirstName);
// txtFirstName.setText(""+res);

try {
//food_object = new JSONObject(result);
if(result.contains("result")){
isError = false;
}
food_object = new JSONObject(result.substring(result.indexOf("{"),
result.lastIndexOf("}") + 1));
JSONArray foo_array = food_object.getJSONArray("result");

values = new String[foo_array.length()];


for (int i = 0; i < foo_array.length(); i++) {
JSONObject js = foo_array.getJSONObject(i);

user_id.add(js.getString("id"));

String user=js.getString("user");
String food=js.getString("food");
String d2=js.getString("total");
//String sts=js.getString("quantity");

String status=js.getString("quantity");

String d=user+"\n"+food+"(Rs."+d2+")"+" No : "+status;

values[i] = d;
categories.add(d);
// categories1.add(js.getString("tname"));

// System.out.println("value q : "+values[i]);

} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Error 3 : "+e.toString());
e.printStackTrace();
}
}

String res = "", status = "";

ArrayAdapter<String> adapter;
String values[];

List<String> user_id = new ArrayList<String>();


List<String> ownername = new ArrayList<String>();

Context context = this;

Toast toast;
public void toast(String str) {
try {
toast.cancel();
} catch (Exception e) {
// TODO: handle exception
}
toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}

ADD FOOD

package com.example.food_order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class admin_delivery extends Activity {


ProgressDialog pDialog;
ProgressDialog pd;
List<String> categories = new ArrayList<String>();
ListView listView;
public static String id="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_my_book);
pd = new ProgressDialog(this);
pd.setMessage("Loading please wait");
pd.setCancelable(false);
listView = (ListView) findViewById(R.id.listView1);
commonRequestThread();

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void commonRequestThread() {
status = "Please try again later";

pd.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Runnable runnable = new Runnable() {
public void run() {
pd.dismiss();
if(user_id.size()<1){
if(isError) {
toast("No result found");
//finish();
}else{
toast("No data found");
}
//finish();
}else{
adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1,
android.R.id.text1, values);
listView.setAdapter(adapter);

}
}
};
try {
runOnUiThread(runnable);
} catch (Exception e) {
// TODO: handle exception
}
}
};
Thread checkUpdate = new Thread() {
public void run() {
try {
commonRequest();
} catch (Exception e) {
System.out.println("Error in fetching json : "
+ e.toString());
}
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
}

Boolean isError = true;


public void commonRequest()
{
isError = true;
System.out.println("Common request sent : ");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://"+server_ipaddress.sip+"/admin_view_booking1.php");
InputStream is = null;
String result = "";
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
//nameValuePairs.add(new
BasicNameValuePair("email",user_login.uemail));
//nameValuePairs.add(new
BasicNameValuePair("user1",police_chat.selected_user));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
is = httpEntity.getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
System.out.println("Error 1 : "+e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error 2 : "+e.toString());
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
System.out.println("Error 2 : "+e.toString());
}
System.out.println("result : "+result);
res = result;
JSONObject food_object;

// TextView txtFirstName = (TextView)


rootView.findViewById(R.id.txtFirstName);
// txtFirstName.setText(""+res);

try {
//food_object = new JSONObject(result);
if(result.contains("result")){
isError = false;
}
food_object = new JSONObject(result.substring(result.indexOf("{"),
result.lastIndexOf("}") + 1));
JSONArray foo_array = food_object.getJSONArray("result");
values = new String[foo_array.length()];
for (int i = 0; i < foo_array.length(); i++) {
JSONObject js = foo_array.getJSONObject(i);

user_id.add(js.getString("id"));

String user=js.getString("user");
String food=js.getString("food");
String d2=js.getString("total");
//String sts=js.getString("quantity");

String status=js.getString("quantity");

String d=user+"\n"+food+"(Rs."+d2+")"+" No : "+status;

values[i] = d;
categories.add(d);
// categories1.add(js.getString("tname"));

// System.out.println("value q : "+values[i]);

} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Error 3 : "+e.toString());
e.printStackTrace();
}
}

String res = "", status = "";

ArrayAdapter<String> adapter;
String values[];

List<String> user_id = new ArrayList<String>();


List<String> ownername = new ArrayList<String>();

Context context = this;

Toast toast;
public void toast(String str) {
try {
toast.cancel();
} catch (Exception e) {
// TODO: handle exception
}
toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}

VIEW ORDERS

package com.example.food_order;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.example.food_order.user_login.userlogin;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class admin_new_order extends Activity {


ProgressDialog pDialog;
ProgressDialog pd;
List<String> categories = new ArrayList<String>();
ListView listView;
public static String id="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_my_book);
pd = new ProgressDialog(this);
pd.setMessage("Loading please wait");
pd.setCancelable(false);
listView = (ListView) findViewById(R.id.listView1);
commonRequestThread();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Log.i("Selected Item in list", arg1.toString());
String test = (String) listView.getAdapter().getItem(arg2);
Log.i("Selected Item in list", test);

String[] arrSplit = test.split("-");


Log.i("id", arrSplit[0]);
id=arrSplit[0];
new userlogin().execute();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void commonRequestThread() {
status = "Please try again later";

pd.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Runnable runnable = new Runnable() {
public void run() {
pd.dismiss();
if(user_id.size()<1){
if(isError) {
toast("No result found");
//finish();
}else{
toast("No data found");
}
//finish();
}else{
adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1,
android.R.id.text1, values);
listView.setAdapter(adapter);

}
}
};
try {
runOnUiThread(runnable);
} catch (Exception e) {
// TODO: handle exception
}
}
};
Thread checkUpdate = new Thread() {
public void run() {
try {
commonRequest();
} catch (Exception e) {
System.out.println("Error in fetching json : "
+ e.toString());
}
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
}

Boolean isError = true;


public void commonRequest()
{
isError = true;
System.out.println("Common request sent : ");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://"+server_ipaddress.sip+"/admin_view_booking.php");
InputStream is = null;
String result = "";
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
//nameValuePairs.add(new
BasicNameValuePair("email",user_login.uemail));
//nameValuePairs.add(new
BasicNameValuePair("user1",police_chat.selected_user));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
is = httpEntity.getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
System.out.println("Error 1 : "+e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error 2 : "+e.toString());
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
System.out.println("Error 2 : "+e.toString());
}
System.out.println("result : "+result);
res = result;
JSONObject food_object;
// TextView txtFirstName = (TextView)
rootView.findViewById(R.id.txtFirstName);
// txtFirstName.setText(""+res);

try {
//food_object = new JSONObject(result);
if(result.contains("result")){
isError = false;
}
food_object = new JSONObject(result.substring(result.indexOf("{"),
result.lastIndexOf("}") + 1));
JSONArray foo_array = food_object.getJSONArray("result");

values = new String[foo_array.length()];


for (int i = 0; i < foo_array.length(); i++) {
JSONObject js = foo_array.getJSONObject(i);

user_id.add(js.getString("id"));

String user=js.getString("user");
String food=js.getString("food");
String d2=js.getString("total");
//String sts=js.getString("quantity");

String status=js.getString("quantity");

String d=js.getString("id")+"-"+user+"\n"+food+"(Rs."+d2+")"+" No :
"+status;

values[i] = d;
categories.add(d);
// categories1.add(js.getString("tname"));
// System.out.println("value q : "+values[i]);

} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Error 3 : "+e.toString());
e.printStackTrace();
}
}

String res = "", status = "";

ArrayAdapter<String> adapter;
String values[];

List<String> user_id = new ArrayList<String>();


List<String> ownername = new ArrayList<String>();

Context context = this;

Toast toast;
public void toast(String str) {
try {
toast.cancel();
} catch (Exception e) {
// TODO: handle exception
}
toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}
public class userlogin extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(admin_new_order.this);
pDialog.setMessage("Requesting...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

protected String doInBackground(String... args) {

String txt = "";

try {

String ur = "http://"+server_ipaddress.sip+"/admin_update.php?"+ "id="


+ id;

URL url = new URL(ur);


Log.i("URL", ""+url);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
DataInputStream dis = new DataInputStream(uc.getInputStream());
String t = "";

while ((t = dis.readLine()) != null) {


txt += t;
}
Log.i("Read", txt);
// m=txt;
dis.close();

} catch (Exception e) {
Log.i("Login Ex", e.getMessage());
}
return txt;
}
protected void onPostExecute(String file_url) {
Log.i("file_url", file_url);
if (file_url.trim().equals("success")) {

Toast.makeText(getApplicationContext(), "Success",
Toast.LENGTH_LONG).show();
finish();

}
else if(file_url.trim().equals("failed")) {
Toast.makeText(getApplicationContext(), "Failed",
Toast.LENGTH_LONG).show();
}
else
{ Toast.makeText(getApplicationContext(), "Please Check Login...!",
Toast.LENGTH_LONG).show();}

pDialog.dismiss();
}

}
}

USER REGISTER

package com.example.food_order;

import java.io.DataInputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Random;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class user_reg extends Activity {


Button regbtn ;
ProgressDialog pDialog;
EditText name,contact,email,pass1,pass2,address;
public static String nam="",fpass="",spass="",cont="",eml="",ran="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.user_register);
regbtn = (Button) findViewById(R.id.reg);
name = (EditText)findViewById(R.id.name);
contact = (EditText)findViewById(R.id.con);
email = (EditText)findViewById(R.id.email);
pass1 = (EditText)findViewById(R.id.pass);
pass2 = (EditText)findViewById(R.id.cpass);
address = (EditText)findViewById(R.id.addr);

regbtn.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View arg0) {
nam=name.getText().toString();
fpass=pass1.getText().toString();
spass=pass2.getText().toString();
cont=contact.getText().toString();
eml=email.getText().toString();
if(nam=="")
{
Toast.makeText(getApplicationContext(), "Enter all fileds",
Toast.LENGTH_LONG).show();
}
else if(fpass=="")
{
Toast.makeText(getApplicationContext(), "Enter all fileds",
Toast.LENGTH_LONG).show();
}
else if(spass=="")
{
Toast.makeText(getApplicationContext(), "Enter all fileds",
Toast.LENGTH_LONG).show();
}
else if(cont=="")
{
Toast.makeText(getApplicationContext(), "Enter all fileds",
Toast.LENGTH_LONG).show();
}
else if(eml=="")
{
Toast.makeText(getApplicationContext(), "Enter all fileds",
Toast.LENGTH_LONG).show();
}

else if(fpass.equals(spass))
{
// Toast.makeText(getApplicationContext(), "click",
Toast.LENGTH_LONG).show();
Log.i("Pass", "same");
new reg().execute();
}
else
{
Toast.makeText(getApplicationContext(), "failed",
Toast.LENGTH_LONG).show();
Intent i = new Intent(user_reg.this,user_reg.class);
startActivity(i);
}

//Toast.makeText(getApplicationContext(), "Success",
Toast.LENGTH_LONG).show();

//Intent i = new Intent(Registration.this,MainActivity.class);


//startActivity(i);
// Toast.makeText(getApplicationContext(), "start",
Toast.LENGTH_LONG).show();
//mEdit.setText(""+m);

}
});
}
public class reg extends AsyncTask<String, String, String> {

//capture values from EditText

// String accno,name1,address,gen,pass,dob;

// String userid=u.getText().toString();
// String password=p.getText().toString();
String rnam=name.getText().toString();
String rfpass=pass1.getText().toString();
String rspass=pass2.getText().toString();
String rcont=contact.getText().toString();
String reml=email.getText().toString();
String address1=address.getText().toString();
@Override
protected void onPreExecute() {
// Toast.makeText(getApplicationContext(), "process",
Toast.LENGTH_LONG).show();
super.onPreExecute();
pDialog = new ProgressDialog(user_reg.this);
pDialog.setMessage("Requesting " + rnam + ")...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {

String txt = "";

try {
String ur = "http://"+server_ipaddress.sip+"/user_register.php?"
+ "name=" +URLEncoder.encode(rnam, "UTF-8")
+ "&pass=" +URLEncoder.encode(rfpass, "UTF-8")
+ "&cont=" +URLEncoder.encode(rcont, "UTF-8")
+ "&email=" +URLEncoder.encode(reml, "UTF-8")
+"&address="+URLEncoder.encode(address1, "UTF-8") ;
Log.i("URL", ur);
URL url = new URL(ur);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
DataInputStream dis = new DataInputStream(uc.getInputStream());
String t = "";
while ((t = dis.readLine()) != null) {
txt += t;
}
//Log.i("Read", txt);
// m=txt;
dis.close();

} catch (Exception e) {
Log.i("Login Ex", e.getMessage());
}
return txt;
}
protected void onPostExecute(String file_url) {

Log.i("file_url", file_url);
String tmp=file_url;
if (file_url.trim().equals("success")) {

Toast.makeText(getApplicationContext(), "Success",
Toast.LENGTH_LONG).show();
finish();
// Intent in = new Intent(getApplicationContext(), login.class);
// startActivity(in);

}
// muser =uid.getText().toString();

else if(file_url.trim().equals("Invalid user")) {


Toast.makeText(getApplicationContext(), "Invalid user",
Toast.LENGTH_LONG).show();
}
else
{ Toast.makeText(getApplicationContext(), file_url,
Toast.LENGTH_LONG).show();

// Toast.makeText(getApplicationContext(), "Please Check Login...!",


Toast.LENGTH_LONG).show();

pDialog.dismiss();
}

USER LOGIN
package com.example.food_order;

import java.io.DataInputStream;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Random;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class user_login extends Activity {


ProgressDialog pDialog;

Button loginbtn;
EditText useremail;
EditText password;
TextView register;
public static String uemail="";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_login);
loginbtn = (Button) findViewById(R.id.button1);
register = (TextView)findViewById(R.id.textView2);

useremail = (EditText)findViewById(R.id.u_name);
password = (EditText)findViewById(R.id.pass);
//useremail.setText("arun@gmail.com");
//password.setText("123");
loginbtn.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View arg0) {
new userlogin().execute();

}
});

register.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View arg0) {

Intent i = new Intent(user_login.this,user_reg.class);

startActivity(i);

}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class userlogin extends AsyncTask<String, String, String> {

String lname=useremail.getText().toString();
String lpass=password.getText().toString();

@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(user_login.this);
pDialog.setMessage("Requesting " + lname + ")...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

protected String doInBackground(String... args) {

String txt = "";

try {
String ur = "http://"+server_ipaddress.sip+"/user_login.php?"+ "mail="
+ lname + "&pass=" +lpass;

URL url = new URL(ur);


Log.i("URL", ""+url);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
DataInputStream dis = new DataInputStream(uc.getInputStream());
String t = "";

while ((t = dis.readLine()) != null) {


txt += t;
}
Log.i("Read", txt);
// m=txt;
dis.close();

} catch (Exception e) {
Log.i("Login Ex", e.getMessage());
}
return txt;
}
protected void onPostExecute(String file_url) {
Log.i("file_url", file_url);
if (file_url.trim().equals("success")) {

uemail=lname;

Toast.makeText(getApplicationContext(), "Login Success",


Toast.LENGTH_LONG).show();
finish();

Intent in = new Intent(getApplicationContext(), user_home.class);


startActivity(in);
}
else if(file_url.trim().equals("Invalid user")) {
Toast.makeText(getApplicationContext(), "Invalid user",
Toast.LENGTH_LONG).show();
}
else
{ Toast.makeText(getApplicationContext(), "Please Check Login...!",
Toast.LENGTH_LONG).show();}

pDialog.dismiss();
}

USER SEARCH FOOD

package com.example.food_order;

import java.io.DataInputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class user_search_food_2 extends Activity {


TextView amount;
EditText card,holder,cvv,ex_date;
ProgressDialog pDialog;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_search_food_2);

amount = (TextView) findViewById(R.id.textView7);

card = (EditText) findViewById(R.id.editText1);


holder = (EditText) findViewById(R.id.editText2);
cvv = (EditText) findViewById(R.id.editText3);
ex_date = (EditText) findViewById(R.id.editText4);

btn = (Button) findViewById(R.id.button1);


int price2=Integer.parseInt(user_search_food_1.food_price);
int docount_2=Integer.parseInt(user_search_food_1.food_discount);
int gst_2=Integer.parseInt(user_search_food_1.food_gst);
int final_price=price2-docount_2+gst_2;
int
final_price_1=final_price*(Integer.parseInt(user_search_food_1.quantit
y));
amount.setText(""+final_price_1);

btn.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
String card1=card.getText().toString().trim();
String holder1=holder.getText().toString().trim();
String cvv1=cvv.getText().toString().trim();
String ex_date1=ex_date.getText().toString().trim();

if(card1.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter Card Number",
Toast.LENGTH_LONG).show();
}
else if(holder1.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter Holder Name",
Toast.LENGTH_LONG).show();
}
else if(cvv1.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter cvv",
Toast.LENGTH_LONG).show();
}
else if(ex_date1.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter ex_date",
Toast.LENGTH_LONG).show();
}
else
{

new userlogin().execute();
}
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class userlogin extends AsyncTask<String, String, String> {
String user=user_login.uemail;
String food_id=user_search_food.id;
String price=amount.getText().toString().trim();
String quntity=user_search_food_1.quantity;
String amoun2=amount.getText().toString().trim();

String card1=card.getText().toString().trim();
String holder1=holder.getText().toString().trim();
String cvv1=cvv.getText().toString().trim();
String ex_date1=ex_date.getText().toString().trim();
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(user_search_food_2.this);
pDialog.setMessage("Requesting...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
String txt = "";
try {
String ur = "http://"+server_ipaddress.sip+"/user_payment.php?"
+ "user=" + URLEncoder.encode(user, "UTF-8")
+ "&food=" +URLEncoder.encode(user_search_food_1.food_name, "UTF-8")
+ "&quantity=" +URLEncoder.encode(quntity, "UTF-8")
+ "&price=" +URLEncoder.encode(price, "UTF-8")

+ "&total=" +URLEncoder.encode(amoun2, "UTF-8")

+ "&card=" +URLEncoder.encode(card1, "UTF-8")


+ "&holder=" +URLEncoder.encode(holder1, "UTF-8")
+ "&cvv=" +URLEncoder.encode(cvv1, "UTF-8")
+ "&ex_date=" +URLEncoder.encode(ex_date1, "UTF-8");

URL url = new URL(ur);


Log.i("URL", ""+url);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
DataInputStream dis = new DataInputStream(uc.getInputStream());
String t = "";

while ((t = dis.readLine()) != null) {


txt += t;
}
Log.i("Read", txt);
// m=txt;
dis.close();

} catch (Exception e) {
Log.i("Login Ex", e.getMessage());
}
return txt;
}
protected void onPostExecute(String file_url) {
Log.i("file_url", file_url);
if (file_url.trim().equals("success")) {
Toast.makeText(getApplicationContext(), "Success",
Toast.LENGTH_LONG).show();
finish();

}
else if(file_url.trim().equals("failed")) {
Toast.makeText(getApplicationContext(), "Failed",
Toast.LENGTH_LONG).show();
}
else
{ Toast.makeText(getApplicationContext(), "Please Check Login...!",
Toast.LENGTH_LONG).show();}

pDialog.dismiss();
}

package com.example.food_order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class user_search_food_1 extends Activity {


TextView food,category,price,gst,discount;
EditText qty;
Button btn;
ProgressDialog pd;
ListView listView;
public static String quantity="";
public static String food_price="";
public static String food_discount="";
public static String food_gst="";
public static String food_name="";
ImageView img;
int loader = R.drawable.loader;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_search_food_1);

food = (TextView) findViewById(R.id.textView3);


category = (TextView) findViewById(R.id.textView5);
price = (TextView) findViewById(R.id.textView7);
gst = (TextView) findViewById(R.id.textView9);
discount = (TextView) findViewById(R.id.textView10);
img = (ImageView) findViewById(R.id.imageView1);
qty = (EditText) findViewById(R.id.editText1);
btn = (Button) findViewById(R.id.button1);
pd = new ProgressDialog(this);
pd.setMessage("Loading please wait");
pd.setCancelable(false);
commonRequestThread();

btn.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View arg0) {
quantity=qty.getText().toString().trim();
if(quantity.isEmpty())
{
Toast.makeText(getApplicationContext(), "Enter quantity",
Toast.LENGTH_LONG).show();
}
else
{
food_price=price.getText().toString().trim();
food_discount=discount.getText().toString().trim();
food_gst=gst.getText().toString().trim();
food_name=food.getText().toString().trim();
Intent i = new
Intent(user_search_food_1.this,user_search_food_2.class);
startActivity(i);
finish();
}

}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void commonRequestThread() {
status = "Please try again later";
pd.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Runnable runnable = new Runnable() {
public void run() {
pd.dismiss();
if(user_id.size()<1){
if(isError) {
toast("No result found");
// finish();
}else{
toast("No data found");
}
// finish();
}else{
adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1,
android.R.id.text1, values);
listView.setAdapter(adapter);

}
}
};
try {
runOnUiThread(runnable);
} catch (Exception e) {
// TODO: handle exception
}
}
};
Thread checkUpdate = new Thread() {
public void run() {
try {
commonRequest();
} catch (Exception e) {
System.out.println("Error in fetching json : "
+ e.toString());
}
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
}

Boolean isError = true;


public void commonRequest()
{
isError = true;
System.out.println("Common request sent : ");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://"+server_ipaddress.sip+"/view_food_list1.php");
InputStream is = null;
String result = "";
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id",user_search_food.id));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
is = httpEntity.getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
System.out.println("Error 1 : "+e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error 2 : "+e.toString());
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
System.out.println("Error 2 : "+e.toString());
}
System.out.println("result : "+result);
res = result;
JSONObject food_object;

// TextView txtFirstName = (TextView)


rootView.findViewById(R.id.txtFirstName);
// txtFirstName.setText(""+res);

try {
//food_object = new JSONObject(result);
if(result.contains("result")){
isError = false;
}
food_object = new JSONObject(result.substring(result.indexOf("{"),
result.lastIndexOf("}") + 1));
JSONArray foo_array = food_object.getJSONArray("result");

values = new String[foo_array.length()];


for (int i = 0; i < foo_array.length(); i++) {
JSONObject js = foo_array.getJSONObject(i);

user_id.add(js.getString("id"));
food.setText(js.getString("food_name"));
category.setText(js.getString("category"));
price.setText(js.getString("price"));
gst.setText(js.getString("gst"));
discount.setText(js.getString("discount"));

String uprof=js.getString("file_name");
String image_url = "http://"+server_ipaddress.sip+"/uploads/"+uprof;

// ImageLoader class instance


ImageLoader imgLoader = new ImageLoader(getApplicationContext());

// whenever you want to load an image from url


// call DisplayImage function
// url - image url to load
// loader - loader image, will be displayed before getting image
// image - ImageView
imgLoader.DisplayImage(image_url, loader, img);

// String d=js.getString("id")+"-"+js.getString("food");

// categories1.add(js.getString("id"));

// System.out.println("value q : "+values[i]);

} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Error 3 : "+e.toString());
e.printStackTrace();
}
}

String res = "", status = "";

ArrayAdapter<String> adapter;
String values[];

List<String> user_id = new ArrayList<String>();


List<String> ownername = new ArrayList<String>();

Context context = this;

Toast toast;
public void toast(String str) {
try {
toast.cancel();
} catch (Exception e) {
// TODO: handle exception
}
toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}
}

package com.example.food_order;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class user_search_food extends Activity {


Button serc ;
EditText intxt;
ProgressDialog pd;
List<String> categories = new ArrayList<String>();
ListView listView;
public static String text="";
String qry_list[]=new String[100];
public static String id="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_search_food);
serc = (Button) findViewById(R.id.button1);
listView = (ListView) findViewById(R.id.listView1);
intxt = (EditText) findViewById(R.id.editText1);
pd = new ProgressDialog(this);
pd.setMessage("Loading please wait");
pd.setCancelable(false);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Log.i("Selected Item in list", arg1.toString());
String test = (String) listView.getAdapter().getItem(arg2);
Log.i("Selected Item in list", test);

String[] arrSplit = test.split("-");


Log.i("id", arrSplit[0]);
id=arrSplit[0];
//Toast.makeText(user_my_list.this,id ,Toast.LENGTH_LONG);
Intent in = new Intent(user_search_food.this,
user_search_food_1.class);
startActivity(in);
}
});
serc.setOnClickListener(new OnClickListener()
{

public void onClick(View arg0) {


String t=intxt.getText().toString().trim();

if(t.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter Values",
Toast.LENGTH_LONG).show();

}
else
{
text=t;
commonRequestThread();
}

}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void commonRequestThread() {
status = "Please try again later";

pd.show();
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Runnable runnable = new Runnable() {
public void run() {
pd.dismiss();
if(user_id.size()<1){
if(isError) {
toast("No result found");
// finish();
}else{
toast("No data found");
}
// finish();
}else{
adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1,
android.R.id.text1, values);
listView.setAdapter(adapter);

}
}
};
try {
runOnUiThread(runnable);
} catch (Exception e) {
// TODO: handle exception
}
}
};
Thread checkUpdate = new Thread() {
public void run() {
try {
commonRequest();
} catch (Exception e) {
System.out.println("Error in fetching json : "
+ e.toString());
}
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
}

Boolean isError = true;


public void commonRequest()
{
isError = true;
System.out.println("Common request sent : ");
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://"+server_ipaddress.sip+"/view_food_list.php");
InputStream is = null;
String result = "";
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("food",text));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
is = httpEntity.getContent();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
System.out.println("Error 1 : "+e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error 2 : "+e.toString());
}

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
System.out.println("Error 2 : "+e.toString());
}
System.out.println("result : "+result);
res = result;
JSONObject food_object;

// TextView txtFirstName = (TextView)


rootView.findViewById(R.id.txtFirstName);
// txtFirstName.setText(""+res);

try {
//food_object = new JSONObject(result);
if(result.contains("result")){
isError = false;
}
food_object = new JSONObject(result.substring(result.indexOf("{"),
result.lastIndexOf("}") + 1));
JSONArray foo_array = food_object.getJSONArray("result");

values = new String[foo_array.length()];


for (int i = 0; i < foo_array.length(); i++) {
JSONObject js = foo_array.getJSONObject(i);

user_id.add(js.getString("id"));

String d=js.getString("id")+"-"+js.getString("food_name");
qry_list[i]=js.getString("id");
values[i] = d;
categories.add(d);
// categories1.add(js.getString("tname"));

// System.out.println("value q : "+values[i]);

} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Error 3 : "+e.toString());
e.printStackTrace();
}
}

String res = "", status = "";


ArrayAdapter<String> adapter;
String values[];

List<String> user_id = new ArrayList<String>();


List<String> ownername = new ArrayList<String>();

Context context = this;

Toast toast;
public void toast(String str) {
try {
toast.cancel();
} catch (Exception e) {
// TODO: handle exception
}
toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}
}

<?php

include("dbconnect.php");
extract($_POST);

$email=$_REQUEST['email'];

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
else
{

$qry="select * from user_booking where user='$email'";


$resvalues = array();

$result = mysqli_query($conn, $qry);


$result = $conn->query($qry);

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($resvalues,array("id"=>$row['id'],"food"=>$row['food'],"qua
ntity"=>$row['quantity'],"price"=>$row['price'],"total"=>$row['total']
,"status"=>$row['status']));
}
}

echo json_encode(array("result"=>$resvalues));

$conn->close();
?>
5. SYSTEM TESTING

5.1 PROJECT TESTING

A Project system must be thoroughly tested to reveal its errors and misconceived before it is
finally delivered to the user who bought it. Planning the testing of a programming system
involves formulating a set of sets of test cases, problems and important points. Which are similar
to the real data that the system is intended to manipulate?

5.2 UNIT TESTING


Unit testing focuses verification effort on the smallest unit of software design the module. Using
the procedural design description as a guide important control paths are tested to uncover the
errors within the boundary of the module. The relative complexity of the tests and uncovered
errors is limited by the constrained scope for unit testing.

5.1.2 VALIDATION TESTING

Validation testing begins with the help of spiral and concentrates on each unit of the limitation of
the software as implemented in the source code. Initially test focus on each individually, assuring
it the functions properly as a unit. Hence the name is Validation testing. Validation testing makes
heavy usage of limiting techniques, exercising the specific path of the required desire of
choosing and in a module’s control structure to ensure complete coverage the maximum data
detection.
6. SYSTEM IMPLEMENTATION
7. CONCLUSION

Our project is only a humble venture to satisfy the needs to manage their project work. Several
user friendly coding have also adopted. This package shall prove to be a powerful package in
satisfying all the requirements of the school. The objective of software planning is to provide a
frame work that enables the manager to make reasonable estimates made within a limited time
frame at the beginning of the software project and should be updated regularly as the project
progresses

FUTURE WORK

 We can give more advanced software for online food ordering system including more
facilities.
 We will host the platform on online services to make it accessible worldwide.
 Create a master and slave database structure to reduces the overload of the database on
regular basis on different servers.
BIBLIOGRAPHY

BOOK REFERENCES

[1] Programming Android Java Programming for the New Generation of Mobile Devices” by
Zigurd Mennieks

[2] “Hello, Android Introducing Google’s Mobile Development Platform” by Ed Burnette

[3] “Learning Android Building Applications for the Android Market” by Marko Gargenta

[4] “Android Programming: The Big Nerd Ranch Guide” by Bill Phillips and Chris Stewart

[5] “Head First Android Development: A Brain-Friendly Guide” by Dawn Griffiths and David
Griffiths

WEB REFERENCES

[1] https://www.researchgate.net/publication/263027693_Mobile_Food_Ordering_Application_/

[2] https://sites.google.com/site/ignoubcafinalyearprojects/project-report/food-ordering-project-
report

[3] https://www.filemakr.com/btech-final-year-project-report-online-food-ordering

You might also like