Professional Documents
Culture Documents
PROJECT REPORT
ON
“Automated Canteen Ordering System”
:: Submitted by ::
Mr. Abhijeet Baliram Pawale
Miss. Shradha Devanand
Jogdand Miss. Anjali Jaywantrao
Pawale Miss. Samiksha
Chakkawar
::Department of ::
COMPUTER ENGINEERING
GRAMIN POLYTECHNIC,
VISHNUPURI NANDED: - 431606
ACADEMIC YEAR
2020-21
A
PROJECT REPORT
ON
“Automated Canteen Ordering System”
:: Submitted by ::
Mr. Abhijeet Baliram Pawale
Miss. Shradha Devanand
Jogdand Miss. Anjali Jaywantrao
Pawale Miss. Samiksha
Chakkawar
:: Guided by ::
Ms. Dudhmal M.N.
In partial fulfillment for the award of the diploma in
COMPUTER ENGINEERING
GRAMIN POLYTECHNIC,
VISHNUPURI NANDED: - 431606
ACADEMIC YEAR
2020-21
CERTIFICATE
( ) ( )
Mr.Wahi G.S Ms. Dudhmal M.N.
( )
Dr. Pawar V.S.
Principal
PROJECT APPROVAL SHEET
Following team has done the appropriate work related to the “Automated
Canteen Ordering System” in partial fulfillment for the award of diploma in
Computer Engineering of “MSBTE” and is being submitted to Gramin Polytechnic
Vishnupuri, Nanded.
Team:
Mr. Abhijeet Baliram Pawale
Miss. Shradha Devanand
Jogdand Miss. Anjali Jaywantrao
Pawale Miss. Samiksha
Chakkawar Guide:
Ms. Dudhmal M.N.
Date:
Place: Nanded.
( ) ( )
Internal Examiner External Examiner
ACKNOWLEDGEMENT
We would like to thank our scheme, faculties and mentors for giving us the opportunity to
work under their guidance and help us in our final project. I would like to thank our beloved
principal Dr. Pawar V.S. who is the force behind this project. My sincere thanks to Ms.
Dudhmal
M.N. as our internal project guide for giving us valuable inputs and ideas right from the selection
of topic for project till its successful completion.
I thank Mr. Wahi G.S (HOD of Computer Department) for his ongoing support and
encouragement in every aspect Last but not the least entire staff of Department of Computer
Engineering for guiding their thoughts and vision.
The successful completion of our final project report would not have been possible
without the dedicated support from all our mentors, family and friends. Finally, yet importantly I
would like to express my heartfelt thanks to my beloved parents for their blessings, my friends,
and all those who supported me directly or indirectly for their help and wishes for successful
completion of this project.
The main aim of this project Canteen management system is to provide fast services to
their college students, Staffs etc. Usually People have to go to canteen and order the foods and
they have to wait in queue for a long time to get the orders. But with the help of this you just
have to follow a very simple process to order your stuffs. And you need not to wait in the long
queue.
This android application will provide the list of different menu list with different
categories. User can select any item from canteen and can order for it by using UPI payment or
wallet Payment. Wallet Recharging available with UPI details or admin can add amount in user’s
wallet.
Users have to register with valid details and OTP which will get sent to their mobile
number to login with canteen. Users also get recommendation for food items, Trending food
items.
Canteen Management system manages the all details of food items which contains name,
description, image, price etc. Admin can view the confirm order and update the status of the
order accordingly. Customer can check their balance, order history and able to delete the order
according to order status.
Advantages
Completely automated online ordering of food in a canteen.
Order can be placed using personal android phones.
Food ordering pages that look and feel exactly the same as the existing restaurant
Android Application.
Food ordering pages hosted on secure and special server so no risk of customers
getting.
Disadvantages
Requires an active internet connection.
Requires Android phone if user is ordering.
INDEX
No. No.
1 Introduction 1
2 Literature Survey 4
2.1 Introduction 4
2.2 Technologies Used 4
3 System Requirements Specifications 6
3.1. Hardware Requirement 6
3.2. Software Requirement 6
4 System Design 7
4.1 Design Document 7
4.2. E-R Diagram 7
4.3 Data Flow Diagram 7
4.4. Undefined Modeling Diagram 8
4.5 Use Case Diagram 8
4.6 Flow Chart Diagram 11
4.7 Activity Diagram 21
5 System Implementation 22
5.1. User Application Coding 22
6 Testing 85
6.1 Testing 85
6.2 Testing Objectives 85
6.3 Levels of Testing 85
6.4 Types of Testing 86
6.5 White box testing 88
6.6 Black box testing 88
6.7 Test Case 88
7 Advantages 91
8 Conclusion 92
9 References 93
Canteen Ordering System 2020-2021
CHAPTER 1
INTRODUCTION
The main aim of this project Canteen management system is to provide fast services to
their college students, Staffs etc. Usually People have to go to canteen and order the foods and
they have to wait in queue for a long time to get the orders. But with the help of this you just
have to follow a very simple process to order your stuffs. And you need not to wait in the long
queue.
This android application will provide the list of different menu list with different
categories. User can select any item from canteen and can order for it by using UPI payment or
wallet Payment. Wallet Recharging available with UPI details or admin can add amount in user’s
wallet.
Another significant contributor to the growth of eCommerce in India in the future is the
e- tailing industry which largely deals in providing jewelry, apparel and kitchen appliances
online. Day to day e-commerce business is increase. Know every one comes on Internet and
Online business. Some of local business man developed own mobile application.
If any Collage Canteen use automated canteen order system application then increase this
collage popularity and image. Every think about this collage positive i.e. If Canteen provide
online services like zomato and swiggy. The scope of eCommerce business is turning out to be
more famous day-after-day according to the market demand. And this requirement is generating
innovations worldwide focused on delivery time, ease of transactions and several features served
by eCommerce businesses, for example, drone delivery or artificial intelligence. Websites like
eCommerce in India. Due to these firms, India is one of the fastest growing eCommerce markets
in Asia/Pacific with China investing as much. Many analysts believe that the advent of 3G/4G
speed in net connectivity has been a major cog in the wheel for such a growth in this market.
1.4 OBJECTIVES
Avoid traveling charges.
Less time conssumes.
Easy to order from any location.
You can see and watch maximum product.
Currently Covid problem incease then you can use this application.
You can save your time.
Using this application promot degitalition.
Reduce management costs.
Providing a unique customer experience.
1.5 FEATURES
It is easy to set up.
There are no geographical boundaries.
Much cheaper than traditional business.
Easy to manage customer information.
All data store online.
Admin know all report.
There is no personal touch.
You can track easily your orders.
Admin knows all shop details from any location.
1.6 MODULE
🠶 User
🠶 Admin
CHAPTER 2
LITERATURE
2.1 INTRODUCTION
SURVEY
In this project we are explain and importance of digit world. The main aim of this project
Canteen management system is to provide fast services to their college students, Staffs etc.
Usually People have to go to canteen and order the foods and they have to wait in queue for a
long time to get the orders. But with the help of this you just have to follow a very simple
process to order your stuffs. And you need not to wait in the long queue.
This android application will provide the list of different menu list with different
categories. User can select any item from canteen and can order for it by using UPI payment or
wallet Payment. Wallet Recharging available with UPI details or admin can add amount in user’s
wallet.
Users have to register with valid details and OTP which will get sent to their mobile
number to login with canteen. Users also get recommendation for food items, Trending food
items.
Consortium's XML 1.0 Specification of 1998 and several other related specifications—all of
them free open standards—define XML.
2.2.2 TOOLS
2.2.3 DATABASE
Firebase(Server)
Firebase is a platform developed by Google for creating mobile and web applications. It
was originally an independent company founded in 2011. In 2014, Google acquired the platform
and it is now their flagship offering for app development.
Firebase's first product was the Firebase Realtime Database, an API that synchronizes
application data across iOS, Android, and Web devices, and stores it on Firebase's cloud. The
product assists software developers in building real-time, collaborative applications.
CHAPTER 3
SYSTEM REQUIREMENT SPECIFICATIONS
A System requirement specification (abbreviated SRS when needed to be distinct from a
SRS) is structured collection of information that embodies the requirements of the system.
CHAPTER 4
SYSTEM DESIGN
4.1 DESIGN DOCUMENT
The entire system is projected with a physical diagram which specifics the actual storage
parameters that are physically necessary for any database to be stored on to the disk. The overall
systems existential idea is derived from this diagram.
The relation upon the system is structure through a conceptual ER-Diagram, which not
only specifics the existential entities but also the standard relations through which the system
exists and the cardinalities that are necessary for the system state to continue.
4.2 ER-DIAGRAM
The entity Relationship Diagram (ERD) depicts the relationship between the data
objects. The ERD is the notation that is used to conduct the date modeling activity
the attributes of each data object noted is the ERD can be described resign a data
object descriptions.
The set of primary components that are identified by the ERD are
Data object
Relationships
Attributes
The primary purpose of the ERD is to represent data objects and their relationships.
used by the process, an external entity that interacts with the system and the
information flows in the system.
DFD shows how the information moves through the system and how it is modified
by a series of transformations. It is a graphical technique that depicts information
flow and the transformations that are applied as data moves from input to output
DFD is also known as bubble chart. A DFD may be used to represent a system at any
level of abstraction. DFD may be partitioned into levels that represent increasing
information flow and functional detail.
The unified modeling language allows the software engineer to express an analysis model
using the modeling notation that is governed by a set of syntactic semantic and pragmatic
rules.
A UML system is represented using five different views that describe the system from
distinctly different perspective. Each view is defined by a set of diagram, which is as
follows.
A use case diagram shows a set of use cases and actors and their relationships. Use
case diagrams address the static use case view of a system. These diagrams are especially
important in organizing and modeling the behaviors of a system.
A use case diagram is a just a special kind of diagram and shares the same common
properties as do all other diagrams. A use case diagram differs from all other kinds of
diagrams in its particular content.
4.5.1 Contents
Use case:
Use case is a description of set of sequence of actions that a system performs that
yields an observable result of value to a particular actor. A use case is used to structure the
behavioral things in a model. A use case is realized by collaboration. Graphically a use case
is rendered as an ellipse with solid lines, usually including only its name, as shown below.
Place order
Relationships:
Dependency
Fig.4.5(b) Dependency
0….1 *
Association
Fig.4.5(c) Association
Generalization
Fig.4.5(d) Generalization
4.6.3 Flow Chart Diagram of Canteen Ordering System User App Register
Activity
4.6.4 Flow Chart Diagram of Canteen Ordering System User App Home
Activity
CHAPTER 5
SYSTEM IMPLEMENTION
5.1 USER APPLICATION CODING/IMPLEMENTATION
if (Common.isConnectedToInternet(getBaseContext())) {
final ProgressDialog mDialog = new
ProgressDialog(MainActivity.this); mDialog.setMessage("Please
Waiting....................................................");
mDialog.show();
table_user.addValueEventListener(new ValueEventListener() {
@Override
Gramin Polytechnic Vishnupuri, Nanded. Page 24
Canteen Ordering System 2020-2021
TextView txtForgotPwd;
FirebaseDatabase database ;
DatabaseReference
table_user; ImageView
imageicon; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
edtPhone=(EditText) findViewById(R.id.edtPhone);
edtPassword=(EditText)
findViewById(R.id.edtPassword);
btnSignIn=(Button)findViewById(R.id.btnSignIn);
ckbRemember=(CheckBox)findViewById(R.id.ckbRemember);
txtForgotPwd=(TextView) findViewById(R.id.txtForgotPwd);
btnSignUp=(Button)findViewById(R.id.signup);
Paper.init(this);
imageicon=findViewById(R.id.imgicon);
imageicon.setImageDrawable(getResources().getDrawable(R.drawable.logo));
database = FirebaseDatabase.getInstance();
table_user=database.getReference("User");
txtForgotPwd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showForgotPwdDialog();
} });
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent loginIntent=new Intent(signin.this,signup.class);
startActivity(loginIntent);
} });
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Common.isConnectedToInternet(getBaseContext()))
{ if (ckbRemember.isChecked()) {
Paper.book().write(Common.USER_KEY,edtPhone.getText().toString());
Paper.book().write(Common.PWD_KEY,edtPassword.getText().toString());
}
final ProgressDialog mDialog = new
ProgressDialog(signin.this); mDialog.setMessage("Please
Waiting....................................................");
mDialog.show();
table_user.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ if (dataSnapshot.child(edtPhone.getText().toString()).exists()) {
Gramin Polytechnic Vishnupuri, Nanded. Page 27
Canteen Ordering System 2020-2021
mDialog.dismiss();
Toast.makeText(signin.this,"Your Password
:"+user.getPassword(),Toast.LENGTH_SHORT).show();
else
Toast.makeText(signin.this,"Wrong
Secure Code",Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
} }); } });
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
} });
builder.show();
}}
Login Form
table_user.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ if (!dataSnapshot.child(edtPhone.getText().toString()).exists()) {
mDialog.dismiss();
String name = edtName.getText().toString();
String pass = password.getText().toString();
String secureCode = edtrepassword.getText().toString();
User user = new User(name, pass, secureCode);
table_user.child(edtPhone.getText().toString()).setValue(user);
Toast.makeText(signup.this, "Sign Up Successfully", Toast.LENGTH_SHORT).show();
Intent login_intent=new Intent(signup.this, signin.class);
startActivity(login_intent);
else { }
if(dataSnapshot.child(edtPhone.getText().toString()).exists())
{ mDialog.dismiss();
Toast.makeText(signup.this, "You have Sign Up Successfully,Please
Login for continue your shopping", Toast.LENGTH_SHORT).show();
Intent login_intent=new Intent(signup.this, signin.class);
startActivity(login_intent);
} } }
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
} });
} else {
Toast.makeText(signup.this, "please check your connection !!",
Toast.LENGTH_SHORT).show();
return;
}}
} });
}
}
Registration Form
5.1.4 Bottom Activity (Home)
public class BottomActivity extends AppCompatActivity implements
NavigationView.OnNavigationItemSelectedListener {
FirebaseDatabase database;
DatabaseReference
category;
TextView txtFullName;
RecyclerView
recycler_menu;
RecyclerView.LayoutManager layoutManager;
SwipeRefreshLayout swipeRefreshLayout;
CounterFab fab;
View view;
HashMap<String,String>
image_list; SliderLayout mSlider;
Toolbar toolbar;
TabLayout
tabLayout;
static FrameLayout viewPager;
TabItem tabHome, tabCart, tabCategory, tabCustomer;
private int[] tabIcons = {
R.drawable.house, R.drawable.list, R.drawable.cart, R.drawable.cussupport
};
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottom);
toolbar=(Toolbar)findViewById(R.id.toolbar);
toolbar.setTitle("Menu");
setSupportActionBar(toolbar);
MultiDex.install(this);
DrawerLayout
drawer=(DrawerLayout)findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle=new ActionBarDrawerToggle(this,
drawer,toolbar,0,0);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView
navigationView=(NavigationView)findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View headerView =navigationView.getHeaderView(0);
txtFullName=(TextView)headerView.findViewById(R.id.txtFullName);
txtFullName.setText(Common.currentUser.getName());
tabLayout = findViewById(R.id.tablayout);
tabHome = findViewById(R.id.tabHome);
tabCategory = findViewById(R.id.tabCategory);
tabCart = findViewById(R.id.tabCart);
tabCustomer = findViewById(R.id.tabContact);
viewPager = findViewById(R.id.viewPager);
Fragment fragment = new Home();
getSupportFragmentManager().beginTransaction()
.replace(R.id.viewPager, fragment,
fragment.getClass().getSimpleName()).addToBackStack(null).commit();
Gramin Polytechnic Vishnupuri, Nanded. Page 36
Canteen Ordering System 2020-2021
tabClick();
setupTabIcons();
}
passwordUpdate.put("password", edtNewPassword.getText().toString());
DatabaseReference user = FirebaseDatabase.getInstance().getReference("User");
user.child(Common.currentUser.getPhone()).updateChildren(passwordUpdate)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
waitingDialog.dismiss();
Toast.makeText(com.spam.maddy.automatedcanteenordersystem.BottomActivity.this,
"Password was update", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(com.spam.maddy.automatedcanteenordersystem.BottomActivity.this,
e.getMessage(), Toast.LENGTH_SHORT).show();
} }); } else {
waitingDialog.dismiss();
Toast.makeText(com.spam.maddy.automatedcanteenordersystem.BottomActivity.this, "New
Password doesn't match", Toast.LENGTH_SHORT).show();
} }
else {
Toast.makeText(com.spam.maddy.automatedcanteenordersystem.BottomActivity.this, "Wrong
old password", Toast.LENGTH_SHORT).show();
} } });
alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
} });
alertDialog.show();
}
public void onBackPressed(){
DrawerLayout drawer=(DrawerLayout)findViewById(R.id.drawer_layout);
if(drawer.isDrawerOpen(GravityCompat.START)){
drawer.closeDrawer(GravityCompat.START);
}else{
super.onBackPressed();
} }
@Override
public void onPointerCaptureChanged(boolean hasCapture) {
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view=inflater.inflate(R.layout.activity_buy, container, false);
database= FirebaseDatabase.getInstance();
requests=database.getReference("Restaurants").child("02").child("detail").child("Requests");
locale = new Locale("en","IN");
fmt=NumberFormat.getCurrencyInstance(locale);
totalBill1=(TextView)view.findViewById(R.id.totalBill1);
userName=(TextView)view.findViewById(R.id.userName);
userNo=(TextView)view.findViewById(R.id.userNo);
deliveryCharge=(TextView)view.findViewById(R.id.deliveryCharge);
netAmount=(TextView)view.findViewById(R.id.netAmount);
btnBuy=(Button)view.findViewById(R.id.btnBuy1);
userName.setText(Common.currentUser.getName());
userNo.setText(Common.currentUser.getPhone());
cart1=new Database(getContext()).getCarts(Common.currentUser.getPhone());
adapter=new CartAdapter(cart1,this);
adapter.notifyDataSetChanged();
for(Order order:cart1)
total+=(Integer.parseInt(order.getDiscount()))*(Integer.parseInt(order.getQuantity()));
totalBill1.setText(fmt.format(total));
deliveryDatabase=database.getReference("Delivery");
deliveryDatabase.child("deliveryCharge").addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println(snapshot.getValue());
deliveryCharge.setText(String.valueOf(snapshot.getValue()));
int dc= Integer.parseInt(String.valueOf(snapshot.getValue()));
na= String.valueOf(dc+total);
netAmount.setText(na);
}
@Override
public void onCancelled(DatabaseError databaseError) {
} });
edtAddress=(MaterialEditText)view.findViewById(R.id.editAddress1);
edtComment=(MaterialEditText)view.findViewById(R.id.editComment1);
RadioButton
Address1=(RadioButton)view.findViewById(R.id.rdiHomeAddress1);
rdiHomeAddress1.setOnCheckedChangeListener(new
CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b){
if (Common.currentUser.getHomeAddress()!=null||!
TextUtils.isEmpty(Common.currentUser.getH omeAddress())) {
address = Common.currentUser.getHomeAddress();
edtAddress.setText(Common.currentUser.getHomeAddress());
}else {
Toast.makeText(getContext(), "Please Address", Toast.LENGTH_SHORT).show();
} } } });
btnBuy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (total >= 10) {
address = edtAddress.getText().toString();
comment =
edtComment.getText().toString(); if
(TextUtils.isEmpty(address)) {
edtAddress.setError("Enter Your Address");
Toast.makeText(getContext(), "Please enter address ", Toast.LENGTH_SHORT).show();
return;
}
Request rqst = new Request(Common.currentUser.getPhone(),
Common.currentUser.getName(), address,na,"0", comment,cart1,
Common.restaurantSelected );
String order_number = String.valueOf(System.currentTimeMillis());
requests.child(order_number).setValue(request);
new
Database(getContext()).cleanCart(Common.currentUser.getPhone());
Toast.makeText(getContext(), "Thank You, Order Place",
Toast.LENGTH_SHORT).show();
Fragment fragment = new Home();
getFragmentManager().beginTransaction()
.replace(R.id.viewPager, fragment,
fragment.getClass().getSimpleName()).addToBackStack(null).commit();
}
else {
Toast.makeText(getContext(),"Please Buy Minimum 100 Rs, Thank
You!"+total,Toast.LENGTH_SHORT).show();
} } });
return view;
}}
Buy Activity
5.1.6 Cart Activity
DatabaseReference requests;
Button btnPlace;
ImageButton btnDelete;
List<Order> cart=new ArrayList<>();
CartAdapter adapter;
TextView totalBill;
NumberFormat
fmt; Locale locale;
String
address,comment;
double total=0;
View
view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view=inflater.inflate(R.layout.activity_cart, container, false);
locale = new Locale("en","IN");
fmt=NumberFormat.getCurrencyInstance(locale);
database= FirebaseDatabase.getInstance();
requests=database.getReference("Restaurants").child(Common.restaurantSelected).child("detail"
).child("Requests");
recyclerView=(RecyclerView)view.findViewById(R.id.listCart);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
cart=new
Database(getContext()).getCarts(Common.currentUser.getPhone());
adapter=new CartAdapter(cart,this);
recyclerView.setAdapter(adapter);
btnPlace=(Button)view.findViewById(R.id.btnPlaceOrder);
btnPlace.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cart.size() > 0) {
Fragment fragment = new BuyActivity();
getFragmentManager().beginTransaction()
.replace(R.id.viewPager, fragment,
fragment.getClass().getSimpleName()).addToBackStack(null).commit();
}else {
Toast.makeText(getContext(), "Your cart is empty !!!",
Toast.LENGTH_SHORT).show();
} } });
loadListFood();
return view;
}
Gramin Polytechnic Vishnupuri, Nanded. Page 46
Canteen Ordering System 2020-2021
public void loadListFood() {
adapter.notifyDataSetChanged();
for(Order order:cart)
total+=(Integer.parseInt(order.getDiscount()))*(Integer.parseInt(order.getQuantity()));
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getTitle().equals(Common.DELETE))
deleteCart(item.getOrder());
return true;
}
private void deleteCart(int position) {
cart.remove(position);
new Database(getContext()).cleanCart(Common.currentUser.getPhone());
for(Order item:cart)
new Database(getContext()).addToCart(item);
loadListFood();
}}
Product List
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedAppbar);
String value = getArguments().getString("FoodId");
if(com.spam.maddy.automatedcanteenordersystem.FoodDetail.this!=null) if(!
foodId.isEmpty()){
if (Common.isConnectedToInternet(getContext())) {
getDetailFood(foodId);
}else {
Toast.makeText(getContext(),"check your connection !!",Toast.LENGTH_SHORT).show();
} }
return view;
}
private void getDetailFood(final String foodId)
{ foods.child(foodId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
currentFood=dataSnapshot.getValue(Food.class);
Picasso.with(getContext()).load(currentFood.getImage()).into(food_image);
collapsingToolbarLayout.setTitle(currentFood.getName());
food_price.setText(String.format("MRP ₹ %s",current
ood.getPrice()));
food_detail_disscount_price.setText(String.format("₹ ",cu
rrentFood.getDiscount()));
food_name.setText(currentFood.getName());
food_description.setText(currentFood.getDescription());
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}}
loadListFood(categoryId);
else{
Toast.makeText(getContext(),"connection !!",Toast.LENGTH_SHORT).show();
return;
} } } });
recyclerView=(RecyclerView)view.findViewById(R.id.recycler_food);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
txtCount=(TextView)view.findViewById(R.id.txtCount);
foodList.orderByChild("menuId").equalTo(value).addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println(snapshot.getChildrenCount()); //prints "Do you have data? You'll
love Firebase." }
@Override
public void onCancelled(atabaseError databaseError) {
} });
mBundleRecyclerViewState = new Bundle();
mListState = recyclerView.getLayoutManager().onSaveInstanceState();
mBundleRecyclerViewState.putParcelable(KEY_RECYCLER_STATE, mListState);
return view;
}
private void loadSuggest() {
foodList.orderByChild("menuId").equalTo(categoryId).addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ for(DataSnapshot postSnapshot:dataSnapshot.getChildren()){
Food
item=postSnapshot.getValue(Food.class);
suggestList.add(item.getName());
}
materialSearchBar.setLastSuggestions(suggestList);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
} }); }
private void loadListFood(String categoryId) {
Query
searchByName=foodList.orderByChild("menuId").equalTo(categoryId);
FirebaseRecyclerOptions<Food> foodOptions=new
FirebaseRecyclerOptions.Builder<Food>()
.setQuery(searchByName,Food.class)
.build();
Gramin Polytechnic Vishnupuri, Nanded. Page 57
Canteen Ordering System 2020-2021
adapter=new FirebaseRecyclerAdapter<Food, FoodViewHolder>(foodOptions) {
@Override
protected void onBindViewHolder(@NonNull FoodViewHolder viewHolder, int
position, @NonNull Food model) {
viewHolder.food_price.setText(String.format("MRP ₹ %s",model.getPrice().toString()));
String emptyStr=model.getPrice();
if(!emptyStr.equals("000"))
{ viewHolder.food_name.setText(model.getName());
viewHolder.quick_cart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{ boolean isExists=new
Database(getContext()).chechFoodExists(adapter.getRef(position).getKey(),Common.currentUse
r.getPhone());
if (!isExists) {
new Database(getContext()).addToCart(new
Order( Common.currentUser.getPhone(),adapter.getRef(position).getKe
y(), model.getName(),viewHolder.numberButton.getNumber(),
model.getPrice(),model.getDiscount(),model.getImage() ));
}else {
new
Database(getContext()).increaseCart(Common.currentUser.getPhone(),adapter.getRef(position).
getKey());
}
Toast.makeText(getContext(), "Added to Cart",
Toast.LENGTH_SHORT).show();
} });
viewHolder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick)
{ mBundleRecyclerViewState = new Bundle();
mListState = recyclerView.getLayoutManager().onSaveInstanceState();
mBundleRecyclerViewState.putParcelable(KEY_RECYCLER_STATE, mListState);
Fragment fragment = new FoodDetail();
Bundle args = new Bundle();
args.putString("FoodId",adapter.getRef(position).getKey());
fragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.viewPager, fragment,
fragment.getClass().getSimpleName()).addToBackStack(null).commit();
} }); }
else{
viewHolder.food_name.setText("Product Not Available");
viewHolder.quick_cart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getContext(), "Product Not Available", Toast.LENGTH_SHORT).show();
} });
viewHolder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick)
Toast.makeText(getContext(), "Product Not Available", Toast.LENGTH_SHORT).show();
} }); }
viewHolder.food_price.setPaintFlags(viewHolder.food_price.getPaintFlags() )
viewHolder.disscountPrice.setText(String.format("₹ %s",model.getDiscount().toString()));
Picasso.with(getContext()).load(model.getImage()).into(viewHolder.food_image);
if
(localDB.isFavorites(adapter.getRef(position).getKey(),Common.currentUser.getPhone()))
viewHolder.fav_image.setImageResource(R.drawable.ic_favorite_black_24dp);
viewHolder.fav_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!localDB.isFavorites(adapter.getRef(position).getKey(),Common.currentUser.getPhone()))
{
calDB.addToFavorites(adapter.getRef(position).getKey(),Common.currentUser.getPhone());
viewHolder.fav_image.setImageResource(R.drawable.ic_favorite_black_24dp);
Toast.makeText(getContext(),""+model.getName()+" was added to
Favorites",Toast.LENGTH_SHORT).show();
}else{ localDB.removeToFavorites(adapter.getRef(position).getKey(),Common.cu
rrentUser.getPhone()
);
viewHolder.fav_image.setImageResource(R.drawable.ic_favorite_border_black_24dp);
Toast.makeText(getContext(),""+model.getName()+" was remove from
Favorites",Toast.LENGTH_SHORT).show();
} } });
final Food local=model;
}
@NonNull
@Override
public FoodViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
viewType) {
View itemView= LayoutInflater.from(parent.getContext())
.inflate(R.layout.food_item,parent,false);
return new FoodViewHolder(itemView);
} };
adapter.startListening();
recyclerView.setAdapter(adapter);
swipeRefreshLayout.setRefreshing(false);
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
Gramin Polytechnic Vishnupuri, Nanded. Page 60
Canteen Ordering System 2020-2021
@Override
public void onResume() {
super.onResume();
if (mBundleRecyclerViewState != null) {
mListState = mBundleRecyclerViewState.getParcelable(KEY_RECYCLER_STATE);
recyclerView.getLayoutManager().onRestoreInstanceState(mListState);
}
recyclerView.setLayoutManager(layoutManager);
}
@Override
public void onPause() {
super.onPause();
mBundleRecyclerViewState = new Bundle();
mListState = recyclerView.getLayoutManager().onSaveInstanceState();
mBundleRecyclerViewState.putParcelable(KEY_RECYCLER_STATE,
mListState);
}}
} }); }
@NonNull
@Override
public OrderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
viewType) {
View itemView= LayoutInflater.from(parent.getContext())
.inflate(R.layout.order_layout,parent,false);
return new OrderViewHolder(itemView);
} };
adapter.startListening();
recyclerView.setAdapter(adapter);
}
@Override
public void onStop() {
super.onStop();
}}
TextView
order_id,order_phone,order_address,order_total,order_comment; String
order_id_value="";
RecyclerView lstFoods;
RecyclerView.LayoutManager layoutManager;
View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view=inflater.inflate(R.layout.activity_order_detail, container, false);
order_id=(TextView)view.findViewById(R.id.order_id1);
order_phone=(TextView)view.findViewById(R.id.order_phone1);
order_address=(TextView)view.findViewById(R.id.order_address1);
order_total=(TextView)view.findViewById(R.id.order_total1);
order_comment=(TextView)view.findViewById(R.id.order_comment1);
lstFoods=(RecyclerView)view.findViewById(R.id.lstFoods1);
lstFoods.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext());
lstFoods.setLayoutManager(layoutManager);
lstFoods.setItemAnimator(new DefaultItemAnimator());
if (getActivity()!=null) {
String value = getArguments().getString("Order Id");
order_id_value = value;
}
order_id.setText(order_id_value);
order_phone.setText(Common.currentRequest.getPhone());
order_total.setText(Common.currentRequest.getTotal());
order_address.setText(Common.currentRequest.getAddress());
order_comment.setText(Common.currentRequest.getComment());
OrderDetailAdapter adapter=new
OrderDetailAdapter(Common.currentRequest.getFoods(),this);
adapter.notifyDataSetChanged();
lstFoods.setAdapter(adapter);
return view;
}}
}
public String getProductId()
{ return ProductId;
}
public void setProductId(String productId)
{ ProductId = productId;
}
public String getProductName()
{ return ProductName;
}
public void setProductName(String productName)
{ ProductName = productName;
}
public String getQuantity()
{ return Quantity;
}
public void setQuantity(String quantity)
{ Quantity = quantity;
}
public String getPrice()
{ return Price;
}
public void setPrice(String price)
{ Price = price;
}
public String getDiscount()
{ return Discount;
}
public void setDiscount(String discount)
{ Discount = discount;
}
public String getImage()
{ return Image;
}
public void setImage(String image)
{ Image = image;
}
}
.child("detail").child("Category");
storage=FirebaseStorage.getInstance();
storageReference=storage.getReference();
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDialog();
} });
drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle=new ActionBarDrawerToggle(this,drawer,toolbar,0,0);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View headerView =navigationView.getHeaderView(0);
txtFullName=(TextView)headerView.findViewById(R.id.txtFullName);
txtFullName.setText("Admin");
recycler_menu=(RecyclerView)findViewById(R.id.recycler_menu);
recycler_menu.setHasFixedSize(true);
layoutManager=new LinearLayoutManager(this);
recycler_menu.setLayoutManager(layoutManager);
loadMenu();
updateToken(FirebaseInstanceId.getInstance().getToken());
}
private void updateToken(String token)
{ FirebaseDatabase
db=FirebaseDatabase.getInstance(); DatabaseReference
tokens=db.getReference("Tokens"); Token data=new
Token(token,true);
tokens.child("1234567891").setValue(data);
}
private void showDialog()
AlertDialog.Builder alertDialog=new AlertDialog.Builder(Home.this);
alertDialog.setTitle("Add new Category");
alertDialog.setMessage("Please fill full information");
LayoutInflater inflater=this.getLayoutInflater();
View
add_menu_layout=inflater.inflate(R.layout.add_new_menu_layout,null);
edtName=add_menu_layout.findViewById(R.id.edtName);
btnSelect=add_menu_layout.findViewById(R.id.btnSelect);
btnUpload=add_menu_layout.findViewById(R.id.btnUpload);
btnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chooseImage();
Gramin Polytechnic Vishnupuri, Nanded. Page 77
Canteen Ordering System 2020-2021
} });
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
uploadImage();
} });
alertDialog.setView(add_menu_layout);
alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
if (newCategory!=null){
categories.push().setValue(newCategory);
Snackbar.make(drawer,"New Category"+newCategory.getName()+" was
added",Snackbar.LENGTH_SHORT).show();
} } });
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
} });
alertDialog.show();
}
private void uploadImage()
{ if (saveUri!=null){
final ProgressDialog mDialog=new ProgressDialog(this);
mDialog.setMessage("Uploading...");
mDialog.show();
String imageName= UUID.randomUUID().toString();
final StorageReference imageFolder=storageReference.child("images/"+imageName);
imageFolder.putFile(saveUri).addOnSuccessListener(new
OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
mDialog.dismiss();
Toast.makeText(Home.this,"Uploaded !!!",Toast.LENGTH_SHORT).show();
imageFolder.getDownloadUrl().addOnSuccessListener(new
OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
newCategory=new Category(edtName.getText().toString(),uri.toString());
} }); }
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mDialog.dismiss();
Toast.makeText(Home.this,""+e.getMessage(),Toast.LENGTH_SHORT).show();
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
double progress=(100.0 *
taskSnapshot.getBytesTransferred()/taskSnapshot.getTotalByteCount());
mDialog.setMessage("Uploaded "+progress+"%");
} }); } }
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{ super.onActivityResult(requestCode, resultCode, data);
if (requestCode==Common.PICK_IMAGE_REQUEST &&
resultCode==RESULT_OK && data!=null && data.getData()!=null){
saveUri=data.getData();
btnSelect.setText("Image
Selected!");
} }
private void chooseImage()
{ Intent intent=new
Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select
Picture"),Common.PICK_IMAGE_REQUEST);
}
private void loadMenu()
{ FirebaseRecyclerOptions<Category> options = new
FirebaseRecyclerOptions.Builder<Category>()
.setQuery(categories,Category.class)
.build();
adapter= new FirebaseRecyclerAdapter<Category, MenuViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull MenuViewHolder viewHolder, int
position, @NonNull Category model) {
viewHolder.txtMenuName.setText(model.getName());
Picasso.get().load(model.getImage()).into(viewHolder.imageView);
viewHolder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick)
{ Intent foodList=new Intent(Home.this,FoodList.class);
foodList.putExtra("CategoryId",adapter.getRef(position).getKey());
startActivity(foodList);
} }); }
@NonNull
@Override
Gramin Polytechnic Vishnupuri, Nanded. Page 80
Canteen Ordering System 2020-2021
}else{
super.onBackPressed();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu)
{ getMenuInflater().inflate(R.menu.home,
menu);
return true;
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item)
{ int id = item.getItemId();
if(id==R.id.nav_menu){
Intent orderIntent=new Intent(Home.this, Home.class);
startActivity(orderIntent);
}else if(id==R.id.nav_user_list){
Intent shipper=new Intent(Home.this, UserDetails.class);
startActivity(shipper);
Gramin Polytechnic Vishnupuri, Nanded. Page 81
Canteen Ordering System 2020-2021
}else if(id==R.id.nav_orders){
edtName=add_menu_layout.findViewById(R.id.edtName);
btnSelect=add_menu_layout.findViewById(R.id.btnSelect);
btnUpload=add_menu_layout.findViewById(R.id.btnUpload);
edtName.setText(item.getName());
btnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chooseImage();
} });
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeImage(item);
} });
alertDialog.setView(add_menu_layout);
alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
item.setName(edtName.getText().toString());
categories.child(key).setValue(item);
} });
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
} });
alertDialog.show();
}
private void changeImage(final Category item)
{ if (saveUri!=null){
final ProgressDialog mDialog=new ProgressDialog(this);
mDialog.setMessage("Uploading...");
mDialog.show();
String imageName= UUID.randomUUID().toString();
final StorageReference imageFolder=storageReference.child("images/"+imageName);
imageFolder.putFile(saveUri).addOnSuccessListener(new
OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
mDialog.dismiss();
Toast.makeText(Home.this,"Uploaded !!!",Toast.LENGTH_SHORT).show();
imageFolder.getDownloadUrl().addOnSuccessListener(new
OnSuccessListener<Uri>() {
@Override
}
private void showAddFoodDailog() {
AlertDialog.Builder alertDialog=new AlertDialog.Builder(FoodList.this);
alertDialog.setTitle("Add new Food");
alertDialog.setMessage("Please fill full information");
LayoutInflater inflater=this.getLayoutInflater();
View add_menu_layout=inflater.inflate(R.layout.add_new_food_layout,null);
edtName=add_menu_layout.findViewById(R.id.edtName);
edtDescription=add_menu_layout.findViewById(R.id.edtDescription);
edtPrice=add_menu_layout.findViewById(R.id.edtPrice);
edtDiscount=add_menu_layout.findViewById(R.id.edtDiscount);
btnSelect=add_menu_layout.findViewById(R.id.btnSelect);
btnUpload=add_menu_layout.findViewById(R.id.btnUpload);
btnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chooseImage();
} });
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
uploadImage();
} });
alertDialog.setView(add_menu_layout);
alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
if (newFood!=null){
foodList.push().setValue(newFood);
Snackbar.make(rootLayout,"New Category"+newFood.getName()+" was
added",Snackbar.LENGTH_SHORT).show();
} } });
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
} });
alertDialog.show()
}
private void uploadImage()
{ if (saveUri!=null){
final ProgressDialog mDialog=new ProgressDialog(this);
mDialog.setMessage("Uploading...");
mDialog.show();
@Override
protected void onBindViewHolder(@NonNull FoodViewHolder viewHolder, int
position, @NonNull Food model) {
viewHolder.food_name.setText(model.getName());
Picasso.get().load(model.getImage()).into(viewHolder.food_image);
viewHolder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick) {
} }); }
@NonNull
@Override
public FoodViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.food_item,parent,false);
return new FoodViewHolder(itemView);
} };
adapter.startListening();
adapter.notifyDataSetChanged();
recyclerView.setAdapter(adapter);
}
@Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{ super.onActivityResult(requestCode, resultCode, data);
if (requestCode==Common.PICK_IMAGE_REQUEST && resultCode==RESULT_OK
&& data!=null && data.getData()!=null){
saveUri=data.getData();
btnSelect.setText("Image
Selected!");
} }
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle().equals(Common.UPDATE)){
howUpdateoodDialog(adapter.getRef(item.getOrder()).getKey(),adapter.getItem(item.getOrder()
));
}else if(item.getTitle().equals(Common.DELETE)){
deleteFood(adapter.getRef(item.getOrder()).getKey());
}
return super.onContextItemSelected(item);
}
private void deleteFood(String key) {
foodList.child(key).removeValue();
Gramin Polytechnic Vishnupuri, Nanded. Page 89
Canteen Ordering System 2020-2021
btnSelect=add_menu_layout.findViewById(R.id.btnSelect);
btnUpload=add_menu_layout.findViewById(R.id.btnUpload);
btnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chooseImage();
} });
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeImage(item);
} });
alertDialog.setView(add_menu_layout);
alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
item.setName(edtName.getText().toString());
item.setPrice(edtPrice.getText().toString());
item.setDiscount(edtDiscount.getText().toString());
item.setDescription(edtDescription.getText().toString());
foodList.child(key).setValue(item);
Snackbar.make(rootLayout," Food "+item.getName()+" was
Edited",Snackbar.LENGTH_SHORT).show();
} });
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Gramin Polytechnic Vishnupuri, Nanded. Page 90
Canteen Ordering System 2020-2021
dialogInterface.dismiss();
} });
alertDialog.show();
}
private void changeImage(final Food item)
{ if (saveUri!=null){
final ProgressDialog mDialog=new ProgressDialog(this);
mDialog.setMessage("Uploading...");
mDialog.show();
String imageName= UUID.randomUUID().toString();
final StorageReference imageFolder=storageReference.child("images/"+imageName);
imageFolder.putFile(saveUri).addOnSuccessListener(new
OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
mDialog.dismiss();
Toast.makeText(FoodList.this,"Uploaded !!!",Toast.LENGTH_SHORT).show()
; imageFolder.getDownloadUrl().addOnSuccessListener(new
OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
item.setImage(uri.toString());
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mDialog.dismiss();
Toast.makeText(FoodList.this,""+e.getMessage(),Toast.LENGTH_SHORT).show();
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot)
{ double progress=(100.0 *
taskSnapshot.getBytesTransferred()/taskSnapshot.getTotalByteCount());
mDialog.setMessage("Uploaded "+progress+"%");
}
});
} }
}
@Override
protected void onResume() {
super.onResume();
adapter.startListening();
}
@Override
public boolean onContextItemSelected(MenuItem item)
{ if (item.getTitle().equals(Common.UPDATE))
wUpdateDialog(adapter.getRef(item.getOrder()).getKey(),adapter.getItem(item.getOrder()));
else if (item.getTitle().equals(Common.DELETE))
deleteOrder(adapter.getRef(item.getOrder()).getKey());
return super.onContextItemSelected(item);
}
private void deleteOrder(String key)
{ requests.child(key).removeValue(
); adapter.notifyDataSetChanged();
}
private void showUpdateDialog(String key, final Request item) {
final AlertDialog.Builder alertDialog=new AlertDialog.Builder(OrderStatus.this);
alertDialog.setTitle("Update Order");
alertDialog.setMessage("Please choose status");
LayoutInflater inflater=this.getLayoutInflater();
final View view=inflater.inflate(R.layout.update_order_layout,null);
spinner=(MaterialSpinner)view.findViewById(R.id.statusSpinner);
spinner.setItems("Placed","On my way","Delivered");
shipperSpiner=(MaterialSpinner)view.findViewById(R.id.shipperSpinner);
List<String> shipperList= new ArrayList<>();
FirebaseDatabase.getInstance().getReference(Common.SHIPPERS_TABLE).addListenerForSin
gleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ for (DataSnapshot shipperSnapShot:dataSnapshot.getChildren())
shipperList.add(shipperSnapShot.getKey());
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
alertDialog.setView(view);
final String localKey=key;
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
item.setStatus(String.valueOf(spinner.getSelectedIndex()))
if (item.getStatus().equals("2"))
{
FirebaseDatabase.getInstance().getReference(Common.ORDER_NEED_SHIP_TABLE)
.child(shipperSpiner.getItems().get(shipperSpiner.getSelectedIndex()).toString())
.child(localKey)
.setValue(item);
requests.child(localKey).setValue(item);
adapter.notifyDataSetChanged()
sendOrderShipRequestToShipper(localKey,item);
}else{
requests.child(localKey).setValue(item);
adapter.notifyDataSetChanged();
}
requests.child(localKey).setValue(item);
adapter.notifyDataSetChanged();
sendOrderStatusToUser(localKey,item);
}
});
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alertDialog.show();
}
private void sendOrderStatusToUser(final String key,Request item)
{ DatabaseReference tokens=db.getReference("Tokens");
tokens.orderByKey().equalTo(item.getPhone())
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ for (DataSnapshot postSnapShot:dataSnapshot.getChildren()){
Token serverToken=postSnapShot.getValue(Token.class);
Map<String,String> dataSend=new HashMap<>();
dataSend.put("title","EasySale");
dataSend.put("message","Your Order : "+key+" was
updated"); DataMessage dataMessage=new
DataMessage(serverToken.getToken(),dataSend);
String test=new Gson().toJson(dataMessage);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void sendOrderShipRequestToShipper(String shipperPhone, Request item) {
DatabaseReference tokens=db.getReference("Tokens");
tokens.child(shipperPhone)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ for (DataSnapshot postSnapShot:dataSnapshot.getChildren()){
Token
serverToken=postSnapShot.getValue(Token.class);
Map<String,String> dataSend=new HashMap<>();
dataSend.put("title","EasySale");
dataSend.put("message","Your have new order");
DataMessage dataMessage=new
DataMessage(serverToken.getToken(),dataSend);
String test=new Gson().toJson(dataMessage);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
EditText
edtDeliverCharge; Button
btnUpdate; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update);
database=FirebaseDatabase.getInstance();
delivery=database.getReference("Delivery");
edtDeliverCharge=findViewById(R.id.edtDeliverCharge);
btnUpdate=findViewById(R.id.btnUpdate);
btnUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (edtDeliverCharge.getText().toString().trim().length() == 0)
{ edtDeliverCharge.setError("Enter Delivery Charge");
}else{
if (Common.isConnectedToInternet(getBaseContext())) {
final ProgressDialog mDialog = new
ProgressDialog(UpdateActivity.this); mDialog.setMessage("Please
Waiting....................................................");
mDialog.show();
delivery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{ Delivery user = new
Delivery(edtDeliverCharge.getText().toString());
delivery.setValue(user);
Toast.makeText(UpdateActivity.this, "Update Successfully",
Toast.LENGTH_SHORT).show();
mDialog.dismiss();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
} });
} else {
Toast.makeText(UpdateActivity.this, "please check your connection !!",
Toast.LENGTH_SHORT).show();
return;
} } }
});
}}
Gramin Polytechnic Vishnupuri, Nanded. Page
100
Canteen Ordering System 2020-2021
CHAPTER 6
TESTING & DEBUGGING STRATEGIES & TEST CASES
6.1 TESTING
Testing is the process of detecting errors. Testing performs a very critical role for quality
assurance and for ensuring the reliability of software. The results of testing are used later on during
maintenance also.
The aim of testing is often to demonstrate that a program works by showing that it has no
errors. The basic purpose of testing phase is to detect the errors that may be present in the
program. Hence one should not start testing with the intent of showing that a program works, but
the intent should be to show that a program doesn’t work. Testing is the process of executing a
program with the intent of finding errors.
The main objective of testing is to uncover a host of errors, systematically and with
minimum effort and time. Stating formally, we can say:
6.3LEVELS OF TESTING
In order to uncover the errors present in different phases we have the concept of levels testing.
The basic levels of testing are as shown below…
System Testing
The philosophy behind testing is to find errors. Test cases are devised with this in mind.
A strategy employed for system testing is code testing.
Code Testing:
This strategy examines the logic of the program. To follow this method we developed
some test data that resulted in executing every instruction in the program and module i.e. every
path is tested. Systems are not designed as entire nor are they tested as single systems. To ensure
that the coding is perfect two types of testing is performed or for that matter is performed or that
matter is performed or for that matter is performed on all systems.
Unit Testing
Link Testing
Unit testing focuses verification effort on the smallest unit of software i.e. the module.
Using the detailed design and the process specifications testing is done to uncover errors within
the boundary of the module. All modules must be successful in the unit test before the start of the
integration testing begins.
In this project each service can be thought of a module. There are so many modules like
Login, HWAdmin, MasterAdmin, Normal User, and PManager. Giving different sets of inputs
has tested each module. When developing the module as well as finishing the development so
that each module works without any error. The inputs are validated when accepting from the
user.
In this application developer tests the programs up as system. Software units in a system
are the modules and routines that are assembled and integrated to form a specific function. Unit
testing is first done on modules, independent of one another to locate errors. This enables to
detect errors. Through this errors resulting from interaction between modules initially avoided.
In this project integrating all the modules forms the main system. When integrating all
the modules I have checked whether the integration effects working of any of the services by
giving different combinations of inputs with which the two services run perfectly before
Integration.
Here the entire software system is tested. The reference document for this process is the
requirements document, and the goal os to see if software meets its requirements.
Here entire ‘ATM’ has been tested against requirements of project and it is checked
whether all requirements of project have been satisfied or not.
In this project ‘Network Management Of Database System’ I have collected some data
and tested whether project is working correctly or not.
Test cases should be selected so that the largest number of attributes of an equivalence
class is exercised at once. The testing phase is an important part of software development. It is
the process of finding errors and missing operations and also a complete verification to
determine whether the objectives are met and the user requirements are satisfied.
This is a unit testing method where a unit will be taken at a time and tested thoroughly at
a statement level to find the maximum possible errors. I tested step wise every piece of code,
taking care that every statement in the code is executed at least once. The white box testing is
also called Glass Box Testing.
I have generated a list of test cases, sample data. which is used to check all possible
combinations of execution paths through the code at every module level.
This testing method considers a module as a single unit and checks the unit at interface
and communication with other modules rather getting into details at statement level. Here the
module will be treated as a block box that will take some input and generate output. Output for a
given set of input combinations are forwarded to other modules.
2. Click on
Check box.
3. Reopen
Application.
04. TC_4 Check Forget 1.Click on Show Forget Show Forget Pass
Password Forget Password Password
Button work or Password Popup Popup
not. Button. Layout. Layout.
05. TC_5 Check already 1.Enter this Show Toast Show Toast Pass
register User number massege User massege User
Detect or not. which is Already Already
already Register. Register.
register.
06. TC_6 Check Contact 1.Click on Show Contect Show Contect Pass
Information Contact Us Type Image Type Image
work properly Tab item. and Button. and Button.
or not.
07. TC_7 Check call 1.Click on Call to Call to Pass
button work call button. Customer Customer
properly or not. Support. Support.
08. TC_8 Check 1.Click on Show Show Pass
Whatsapp whatsapp tab. whatsapp of whatsapp of
button work customer care. customer care.
properly or not.
09. TC_9 Check SMS 1.Click on Show SMS of Show SMS of Pass
button work SMS tab. customer care. customer care.
properly or not.
10. TC_10 Check Gmail 1.Click on Show Gmail Show Gmail Pass
button work Gmail tab. of customer of customer
properly or not. care. care.
11. TC_11 Check logout 1.Click on Go to login Go to login Pass
tab work Logout tab. activiy activiy
properly or not.
12. TC_12 Check 1.Click on Directly exit Directly exit Pass
backpressed backpressed from from
work properly button. application. application.
or not.
13. TC_13 Check 1.Click on Show Show Pass
Dashboard navigation Dashboard. Dashboard.
Work Properly mark.
or not..
14. TC_14 Check Change 1.Enter all Show toast Show toast Pass
password work password and msg chage msg chage
or not. fill this form. password password
successfully. successfully.
2. Click On
Cart tab.
19. TC_19 Check Place 1. Clear Cart Show toast Show toast Pass
Order Empty list. “Your Cart is “Your Cart is
Condition work empty”. empty”.
or not. 2. Click on
place order.
20. TC_20 Check Buy 1. Goto Calculate Calculate Pass
Activity Work buy Amount Amount
or not. activity. Properly and Properly and
place order place order
2. Check Successfully. Successfully.
Calculation of
price.
3. Click on
buy Button.
21. TC_21 Check Admin 1. Enter id & Open Home Open Home Pass
Login work or Password Activity. Activity.
not properly. then Login.
22. TC_22 Check Add 1. Click on Show toast Show toast Pass
Product. add button.. add product add product
successfully. successfully.
23 TC_23 Check Update 1. Enter Show Toast Show Toast Pass
Delivery charge of message message
Charge work or delivery. update update
not. successfully. successfully.
CHAPTER 7
ADVANTAGES
CHAPTER 8
9.1 CONCLUSION
The internet has opened so many opportunities for doing business online, and e-
commerce is one of the most popular ones. Not only does it require low investment, it actually is
a type of business that does not require a full-time commitment, especially if you are selling a
limited number of products.
Online ordering will boost your productivity by eliminating the inefficient process of
taking orders. It will help you to plan and implement an adaptive marketing campaign. Utilising
the latest online ordering technology for your restaurant will also help you to tap into a massive
customer base which is tech-savvy and believes in ‘online way’.
CHAPTER 9
REFERENCE
1. Websites:-
1. www.androidtutorials.com
2. www.javatpoint.com
3. www.progchamp.com
4. https://www.emarketinginstitute.org/
5. https://www.restolabs.com/
2. Books:-