MasterDB.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import android.util.Log;
import com.dfoe.frimaster.OrderDeatlsClass;
import com.dfoe.frimaster.modals.MenuInventaryItemDetails;
import com.dfoe.frimaster.modals.MenuPriceDetails;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.json.JSONArray;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import static android.webkit.WebSettings.PluginState.ON;
public class MasterDB {
private String DB_NAME = "frimaster.db";
// for Live release please make it as 4 private int DB_VERSION = 6;
public DataBaseHelper dbHelper;
private static MasterDB masterDB;
private String currentDateandTime = "";
private static Context mContext;
private String foregroundTaskPackageName;
private String TAG = "MasterDB";
private static final int COVERPAGE_CACHE_SIZE = 512 * 1024;
private static final String TABLE_NAME_DICT = "dict_";
private static SQLiteDatabase db_dict;
private MasterDB(Context context) {
dbHelper = new DataBaseHelper(context, DB_NAME, null, DB_VERSION);
dbHelper.getWritableDatabase(); // without this on create will not get dbHelper.close();
}
public static synchronized MasterDB getInstance(Context context) {
if (masterDB != null)
return masterDB;
else masterDB = new MasterDB(context.getApplicationContext());
return masterDB;
}
public long insertUserDeatils(String tableName, JSONObject object) {
if (dbHelper != null) {
try {
return dbHelper.insertUserDeatils(tableName, object);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestaurantDeatils(JSONObject object) {
if (dbHelper != null) {
try {
return dbHelper.insertRestaurantDeatils(object);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuCategoryDetails(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuCategoryDetails(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuDetails(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuDetails(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuPrice(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuPrice(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuFoodType(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuFoodType(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertFoodType(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertFoodType(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuImage(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuImage(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertMenuTag(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMenuTag(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertResTableDetails(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertResTableDetails(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertResTableSeatDetails(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertResTableSeatDetails(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertResTableCurrencyDetails(JSONObject object) {
if (dbHelper != null) {
try {
return dbHelper.insertResTableCurrencyDetails(object);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertResTableTaxDetails(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertResTableTaxDetails(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestorentMessages(JSONObject obj) {
if (dbHelper != null) {
try {
return dbHelper.insertMessages(obj);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestorentMessagesOff(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertMessagesTemp(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long deleteResDEltedOrders(int menu_id, int order_no, int menu_price_id, int table_id, int seat_id) {
if (dbHelper != null) {
try {
return dbHelper.deleteResDEltedOrders(menu_id, order_no, menu_price_id, table_id, seat_id);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long deleteTakewaydOrders(int id) {
if (dbHelper != null) {
try {
return dbHelper.deleteTakewayOrder(id);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertResTableDeletedOrderDeatils(int menu_id, int order_no, int menu_price_id, int table_id, int seat_id, int order_id) {
if (dbHelper != null) {
try {
return dbHelper.insertResTableDeletedOrderDeatils(menu_id, order_no, menu_price_id, table_id, seat_id, order_id);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public boolean IsMasterLoggedIn() {
if (dbHelper != null) {
try {
return dbHelper.IsMasterLoggedIn();
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else {
return false;
}
}
public ArrayList<Integer> statusOrderExists(int menu_id, int menu_price_id, int table_id, int seat_id, int order_no) {
if (dbHelper != null) {
try {
return dbHelper.statusOrderExists(menu_id, menu_price_id, table_id, seat_id, order_no);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public ArrayList<Integer> RestaurantTableDeatils() {
if (dbHelper != null) {
try {
return dbHelper.RestaurantTableDeatils();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getFeletedOrderDeatils(int table_id, int seat_id, int orderno) {
if (dbHelper != null) {
try {
return dbHelper.getFeletedOrderDeatils(table_id, seat_id, orderno);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONObject RestaurantTableDeatils(int table_id) {
if (dbHelper != null) {
try {
return dbHelper.RestaurantTableDeatils(table_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public ArrayList<Integer> RestaurantCaterogryDeatils() {
if (dbHelper != null) {
try {
return dbHelper.RestaurantCaterogryDeatils();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray RestaurantMenuDeatilsBasedOnCaterogryID(int caterogryID) {
if (dbHelper != null) {
try {
return dbHelper.RestaurantMenuDeatilsBasedOnCaterogryID(caterogryID);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray RestaurantMenuDeatilsBasedOnFoodType(String menu_ids) {
if (dbHelper != null) {
try {
return dbHelper.RestaurantMenuDeatilsBasedOnFoodType(menu_ids);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public ArrayList<Integer> getMenuIdBasedOnFoodTypeId(String foodType_ids, int caterogery_id) {
if (dbHelper != null) {
try {
return dbHelper.getMenuIdBasedOnFoodTypeId(foodType_ids, caterogery_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getOrderDeatilsForOrderNo(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.getOrderDeatilsForOrderNo(orderno);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getMessagesDeatilsForOrderNo(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.getMessagesmentdeatils(orderno);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getTaxdeatils() {
if (dbHelper != null) {
try {
return dbHelper.getTaxdeatils();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getPaymentdeatils(int orderNo) {
if (dbHelper != null) {
try {
return dbHelper.getPaymentdeatils(orderNo);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray RestaurantMenuDeatilsBasedOnCaterogryIDAndMenuName(String MenuName) {
if (dbHelper != null) {
try {
return dbHelper.RestaurantMenuDeatilsBasedOnCaterogryIDAndMenuName(MenuName);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONObject RestaurantCaterogryDetailsBasedOnCaterogery(int caterogeryID) {
if (dbHelper != null) {
try {
return dbHelper.RestaurantCaterogryDetailsBasedOnCaterogery(caterogeryID);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public int RestaurantID() {
if (dbHelper != null) {
try {
return dbHelper.RestaurantID();
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public int MasterUserID() {
if (dbHelper != null) {
try {
return dbHelper.MasterUserID();
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public JSONObject getSeatsStatus(int table_id) {
if (dbHelper != null) {
try {
return dbHelper.getSeatsStatus(table_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONObject getOrderDeatilsBasedOnId(int id) {
if (dbHelper != null) {
try {
return dbHelper.getOrderDeatilsBasedOnId(id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public String getSeatStstusBasedOnSeatId(int seat_id) {
if (dbHelper != null) {
try {
return dbHelper.getSeatStstusBasedOnSeatId(seat_id);
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public String getCurrencyDeatils() {
if (dbHelper != null) {
try {
return dbHelper.getCurrencyDeatils();
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public String getRestaurantDeatils() {
if (dbHelper != null) {
try {
return dbHelper.getRestaurantDeatils();
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public String getRestaurantImage() {
if (dbHelper != null) {
try {
return dbHelper.getRestaurantImage();
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public long insertRestaurantPaymentFromLogin(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertRestaurantPaymentFromLogin(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestaurantPayment(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertRestaurantPayment(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public Boolean OrderNoexists(int OrderNo) {
if (dbHelper != null) {
try {
return dbHelper.OrderNoexists(OrderNo);
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else {
return false;
}
}
public long deletedOrderFromDatabase(JSONArray array, int orderNo) {
if (dbHelper != null) {
try {
return dbHelper.deletedOrderFromDatabase(array, orderNo);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestaurantOrder(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertRestaurantOrder(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long insertRestaurantOrderForLogin(JSONArray array) {
if (dbHelper != null) {
try {
return dbHelper.insertRestaurantOrderForLogin(array);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateOrderServerStatus(int order_id, int orderStatus) {
if (dbHelper != null) {
try {
return dbHelper.updateOrderServerStatus(order_id, orderStatus);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateOrderConfrmStatus(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.updateOrderConfirmStatus(orderno);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateCancelOrder(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.updateCancelConfirmStatus(orderno);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateCancelConfirmStatusTo3(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.updateCancelConfirmStatusTo3(orderno);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateseatCancelOrder(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.updateSeatCancelConfirmStatus(orderno);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public long updateCancelOrderTakeway(int orderno) {
if (dbHelper != null) {
try {
return dbHelper.updateCancelConfirmStatusTakewy(orderno);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
} else {
return -1;
}
}
public ArrayList<Integer> getOrderNoBasedOnseat_id(int seat_id, int table_id) {
if (dbHelper != null) {
try {
return dbHelper.getOrderNoBasedOnseat_id(seat_id, table_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public ArrayList<Integer> getOrderIDBasedOnseat_id(int seat_id, int table_id) {
if (dbHelper != null) {
try {
return dbHelper.getOrderIDBasedOnseat_id(seat_id, table_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public Integer getOrderCount() {
if (dbHelper != null) {
try {
return dbHelper.getOrderCount();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}
public Integer getRevCount() {
if (dbHelper != null) {
try {
return dbHelper.getRevenueCount();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}
public Integer getRevCountToday(String date) {
if (dbHelper != null) {
try {
return dbHelper.getRevCountTodayFromPayment(date);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}
public ArrayList<String> getOrderHistorydates() {
if (dbHelper != null) {
try {
return dbHelper.getOrderHistorydates();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public OrderDeatlsClass getOrderDeatilsBasedOnIdForMenuScreen(int id) {
if (dbHelper != null) {
try {
return dbHelper.getOrderDeatilsBasedOnIdForMenuScreen(id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getItemReports(boolean menu_idexists, ArrayList<Integer> arrayList) {
if (dbHelper != null) {
try {
return dbHelper.getItemReports(menu_idexists, arrayList);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getItemReportsBasedOnDate(String from, String to, ArrayList<Integer> caterogry_id) {
if (dbHelper != null) {
try {
return dbHelper.getItemReportsBasedOnDate(from, to, caterogry_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getItemReportsBasedOnMenuName(String menu_name) {
if (dbHelper != null) {
try {
return dbHelper.getItemReportsBasedOnMenuName(menu_name);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public ArrayList<Integer> getMenuIDsDependOnCaterogryID(int caterogry_id) {
if (dbHelper != null) {
try {
return dbHelper.getMenuIDsDependOnCaterogryID(caterogry_id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public void deleteAllTable() {
if (dbHelper != null) {
try {
dbHelper.deleteAllTable();
} catch (Exception e) {
e.printStackTrace();
}
} else {
}
}
public JSONArray getOrderDetailsFromPayment(String date) {
if (dbHelper != null) {
try {
return dbHelper.getOrderDetailsFromPayment(date);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getOrderDetailsFromPayments() {
if (dbHelper != null) {
try {
return dbHelper.getTakewayOrder();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public JSONArray getFoodType() {
if (dbHelper != null) {
try {
return dbHelper.getFoodType();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public String getMenuNameByOnMenu_idandMenu_price_id(int menu_id, int menu_price_id) {
if (dbHelper != null) {
try {
return dbHelper.getMenuNameByOnMenu_idandMenu_price_id(menu_id, menu_price_id);
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public String getCaterogryNameByOnMenu_id(int menu_id) {
if (dbHelper != null) {
try {
return dbHelper.getCaterogryNameByOnMenu_id(menu_id);
} catch (Exception e) {
e.printStackTrace();
return "";
}
} else {
return "";
}
}
public Double getTotalAmount(int order_no) {
if (dbHelper != null) {
try {
return dbHelper.getTotalAmount(order_no);
} catch (Exception e) {
e.printStackTrace();
return 0.0;
}
} else {
return 0.0;
}
}
//TODO by basudev, All methods returing dataClass object should be below this
public ArrayList<MenuInventaryItemDetails> getMenuDetails(int restaurantID) {
if (dbHelper != null) {
try {
return dbHelper.getMenuDetails(restaurantID);
} catch (Exception e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
public void updateMenuAvailability(int menuPriceID, int availability) {
if (dbHelper != null) {
try {
dbHelper.updateMenuAvailability(menuPriceID, availability);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public SQLiteDatabase getReadableDatabase() {
return null;
}
private class DataBaseHelper extends SQLiteOpenHelper {
public DataBaseHelper(Context context, String name,
SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.UserTable.TABLE_NAME + " (" + MasterMetaData.UserTable.USER_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.UserTable.USER_TYPE_ID + " INTEGER, " + MasterMetaData.UserTable.NAME + " TEXT, " + MasterMetaData.UserTable.USERNAME + " TEXT, " + MasterMetaData.UserTable.USERPASSWORD + " TEXT, " + MasterMetaData.UserTable.RESTAURANT_ID + " INTEGER, " + MasterMetaData.UserTable.CREATEDAT + " TEXT, " + MasterMetaData.UserTable.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.Restaurant.TABLE_NAME + " (" + MasterMetaData.Restaurant.RESTAURANT_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.Restaurant.NAME + " TEXT, " + MasterMetaData.Restaurant.COMPANY_ID + " INTEGER, " + MasterMetaData.Restaurant.MERCAHNT_ID + " INTEGER, " + MasterMetaData.Restaurant.ADDRESS + " TEXT, " + MasterMetaData.Restaurant.CONTACTEMAIL + " TEXT, " + MasterMetaData.Restaurant.CONTACTNAME + " TEXT, " + MasterMetaData.Restaurant.PASSWORD + " TEXT, " + MasterMetaData.Restaurant.PHONE + " TEXT, " + MasterMetaData.Restaurant.LOGO + " TEXT, " + MasterMetaData.Restaurant.URL + " TEXT, " + MasterMetaData.Restaurant.LATITUDE + " TEXT, " + MasterMetaData.Restaurant.LONGITUDE + " TEXT, " + MasterMetaData.Restaurant.CURRENCY_ID + " TEXT, " + MasterMetaData.Restaurant.STATUS + " TEXT, " + MasterMetaData.Restaurant.MODIFIEDBY + " TEXT, " + MasterMetaData.Restaurant.TIN + " TEXT, " + MasterMetaData.Restaurant.AUTH_TOKEN + " TEXT, " + MasterMetaData.Restaurant.CREATEDAT + " TEXT, " + MasterMetaData.Restaurant.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantTable.TABLE_NAME + " (" + MasterMetaData.ResturantTable.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantTable.TABLENAME + " TEXT, " + MasterMetaData.ResturantTable.COMPANY_ID + " INTEGER, " + MasterMetaData.ResturantTable.MERCAHNT_ID + " INTEGER, " + MasterMetaData.ResturantTable.RESTAURANT_ID + " INTEGER, " + MasterMetaData.ResturantTable.DEVICEID + " TEXT, " + MasterMetaData.ResturantTable.IPADDRESS + " TEXT, " + MasterMetaData.ResturantTable.NUMBEROFSEATS + " TEXT, " + MasterMetaData.ResturantTable.TABLENO + " TEXT, " + MasterMetaData.ResturantTable.STATUS + " TEXT, " + MasterMetaData.ResturantTable.MODIFIEDBY + " TEXT, " + MasterMetaData.ResturantTable.CREATEDAT + " TEXT, " + MasterMetaData.ResturantTable.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantSeat.TABLE_NAME + " (" + MasterMetaData.ResturantSeat.SEAT_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantSeat.RES_TABLE_ID + " INTEGER, " + MasterMetaData.ResturantSeat.SEATNAME + " TEXT, " + MasterMetaData.ResturantSeat.SEATSTATUS + " TEXT, " + MasterMetaData.ResturantSeat.CREATEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuCategories.TABLE_NAME + " (" + MasterMetaData.MenuCategories.CATEGORY_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuCategories.NAME + " TEXT, " + MasterMetaData.MenuCategories.DISPLAYNAME + " TEXT, " + MasterMetaData.MenuCategories.DESCRIPTION + " TEXT, " + MasterMetaData.MenuCategories.RESTAURANT_ID + " INTEGER, " + MasterMetaData.MenuCategories.IMAGE + " TEXT, " + MasterMetaData.MenuCategories.CATEGORYTYPE + " INTEGER, " + MasterMetaData.MenuCategories.ORDERNO + " TEXT, " + MasterMetaData.MenuCategories.MODIFIEDBY + " TEXT, " + MasterMetaData.MenuCategories.CREATEDAT + " TEXT, " + MasterMetaData.MenuCategories.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantMenu.TABLE_NAME + " (" + MasterMetaData.ResturantMenu.MENU_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantMenu.NAME + " TEXT, " + MasterMetaData.ResturantMenu.COMPANY_ID + " INTEGER, " + MasterMetaData.ResturantMenu.MERCAHNT_ID + " INTEGER, " + MasterMetaData.ResturantMenu.RESTAURANT_ID + " INTEGER, " + MasterMetaData.ResturantMenu.IMAGE + " TEXT, " + MasterMetaData.ResturantMenu.DESCRIPTION + " TEXT, " + MasterMetaData.ResturantMenu.INGREDIENTS + " TEXT, " + MasterMetaData.ResturantMenu.PREPTIME + " TEXT, " + MasterMetaData.ResturantMenu.PRICE + " TEXT, " + MasterMetaData.ResturantMenu.CURRENCY_ID + " TEXT, " + MasterMetaData.ResturantMenu.VIDEOLINK + " TEXT, " + MasterMetaData.ResturantMenu.RATING + " TEXT, " + MasterMetaData.ResturantMenu.ORDERNO + " TEXT, " + MasterMetaData.ResturantMenu.LASTCHANED + " TEXT, " + MasterMetaData.ResturantMenu.KITCHEN_ID + " INTEGER, " + MasterMetaData.ResturantMenu.CATEGORY_ID + " INTEGER, " + MasterMetaData.ResturantMenu.MENUTYPE + " TEXT, " + MasterMetaData.ResturantMenu.STATUS + " TEXT, " + MasterMetaData.ResturantMenu.MODIFIEDBY + " TEXT, " + MasterMetaData.ResturantMenu.CREATEDAT + " TEXT, " + MasterMetaData.ResturantMenu.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuPrice.TABLE_NAME + " (" + MasterMetaData.MenuPrice.MENU_PRICE_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuPrice.MENU_ID + " INTEGER, " + MasterMetaData.MenuPrice.QUANTITYNAME + " TEXT, " + MasterMetaData.MenuPrice.AVAILABILITY + " TEXT, " + MasterMetaData.MenuPrice.MENU_PRICE + " REAL " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuImage.TABLE_NAME + " (" + MasterMetaData.MenuImage.MENU_IMAGE_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuImage.MENU_ID + " INTEGER, " + MasterMetaData.MenuImage.MENU_IMAGE_NAME + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuTag.TABLE_NAME + " (" + MasterMetaData.MenuTag.MENU_TAG_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuTag.MENU_ID + " INTEGER, " + MasterMetaData.MenuTag.MENU_TAG_NAME + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantOrders.TABLE_NAME + " (" + MasterMetaData.ResturantOrders.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantOrders.ORDER_ID + " TEXT, " + MasterMetaData.ResturantOrders.COMPANY_ID + " INTEGER, " + MasterMetaData.ResturantOrders.MERCAHNT_ID + " INTEGER, " + MasterMetaData.ResturantOrders.RESTAURANT_ID + " INTEGER, " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " INTEGER, " + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " TEXT, " + MasterMetaData.ResturantOrders.TABLENUMBER + " TEXT, " + MasterMetaData.ResturantOrders.BATCHNUMBER + " TEXT, " + MasterMetaData.ResturantOrders.BATCHSTATUS + " TEXT, " + MasterMetaData.ResturantOrders.ORDER_DATE + " TEXT, " + MasterMetaData.ResturantOrders.PRICE + " TEXT, " + MasterMetaData.ResturantOrders.ITEM_QUANTITY + " INTEGER, " + MasterMetaData.ResturantOrders.SERVERDSTATUS + " INTEGER, " + MasterMetaData.ResturantOrders.PENDINGSTATUS + " INTEGER, " + MasterMetaData.ResturantOrders.DEFCURRENCYID + " TEXT, " + MasterMetaData.ResturantOrders.USERID + " INTEGER, " + MasterMetaData.ResturantOrders.BILLNUMBER + " TEXT, " + MasterMetaData.ResturantOrders.ORDERNO + " INTEGER, " + MasterMetaData.ResturantOrders.SEATID + " INTEGER, " + MasterMetaData.ResturantOrders.MENUPRICEID + " INTEGER, " + MasterMetaData.ResturantOrders.ORDERITEMNO + " TEXT, " + MasterMetaData.ResturantOrders.MODIFIEDBY + " TEXT, " + MasterMetaData.ResturantOrders.CREATEDAT + " TEXT, " + MasterMetaData.ResturantOrders.TAKEAWAY + " TEXT, " + MasterMetaData.ResturantOrders.NAME + " TEXT, " + MasterMetaData.ResturantOrders.COUNTRYCODE + " TEXT, " + MasterMetaData.ResturantOrders.USERPHONE + " TEXT, " + MasterMetaData.ResturantOrders.USEREMAIL + " TEXT, " + MasterMetaData.ResturantOrders.CONFIRMDELIVERY + " TEXT, " + MasterMetaData.ResturantOrders.ORDERSTATUS + " TEXT, " + MasterMetaData.ResturantOrders.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantCurrency.TABLE_NAME + " (" + MasterMetaData.ResturantCurrency.CURRENCY_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantCurrency.NAME + " TEXT, " + MasterMetaData.ResturantCurrency.DISPLAYNAME + " TEXT, " + MasterMetaData.ResturantCurrency.DESCRIPTION + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantTax.TABLE_NAME + " (" + MasterMetaData.ResturantTax.TAX_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantTax.NAME + " TEXT, " + MasterMetaData.ResturantTax.DISPLAYNAME + " TEXT, " + MasterMetaData.ResturantTax.DESCRIPTION + " TEXT, " + MasterMetaData.ResturantTax.TAX + " INTEGER " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantPayment.TABLE_NAME + " (" + MasterMetaData.ResturantPayment.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantPayment.COMPANY_ID + " INTEGER, " + MasterMetaData.ResturantPayment.MERCAHNT_ID + " INTEGER, " + MasterMetaData.ResturantPayment.RESTAURANT_ID + " INTEGER, " + MasterMetaData.ResturantPayment.TABLENUMBER + " TEXT, " + MasterMetaData.ResturantPayment.BATCHNUMBER + " TEXT, " + MasterMetaData.ResturantPayment.BATCHSTATUS + " TEXT, " + MasterMetaData.ResturantPayment.PAYMENYDATE + " DATE, " + MasterMetaData.ResturantPayment.AMOUNT + " REAL, " + MasterMetaData.ResturantPayment.DISCOUNTAMOUNT + " REAL, " + MasterMetaData.ResturantPayment.TOTALAMOUNT + " REAL, " + MasterMetaData.ResturantPayment.DISCOUNTREASON + " TEXT, " + MasterMetaData.ResturantPayment.COUPONCODE + " TEXT, " + MasterMetaData.ResturantPayment.TRANSACTIONID + " TEXT, " + MasterMetaData.ResturantPayment.APPROVALCODE + " TEXT, " + MasterMetaData.ResturantPayment.APPROVALMESSAGE + " TEXT, " + MasterMetaData.ResturantPayment.PAYMENTSTATUS + " INTEGER, " + MasterMetaData.ResturantPayment.PAYMENTTYPE + " INTEGER, " + MasterMetaData.ResturantPayment.def_currency_id + " INTEGER, " + MasterMetaData.ResturantPayment.additional_info1 + " TEXT, " + MasterMetaData.ResturantPayment.additional_info2 + " TEXT, " + MasterMetaData.ResturantPayment.bill_number + " TEXT, " + MasterMetaData.ResturantPayment.tax_details + " TEXT, " + MasterMetaData.ResturantPayment.tips + " REAL, " + MasterMetaData.ResturantPayment.tx_status + " TEXT, " + MasterMetaData.ResturantPayment.tx_id + " TEXT, " + MasterMetaData.ResturantPayment.pg_resp_code + " TEXT, " + MasterMetaData.ResturantPayment.tx_msg + " TEXT, " + MasterMetaData.ResturantPayment.paid_amount + " REAL, " + MasterMetaData.ResturantPayment.auth_id_code + " TEXT, " + MasterMetaData.ResturantPayment.payment_mode + " TEXT, " + MasterMetaData.ResturantPayment.pg_mobile_no + " TEXT, " + MasterMetaData.ResturantPayment.txn_date_time + " TEXT, " + MasterMetaData.ResturantPayment.transaction_reference + " TEXT, " + MasterMetaData.ResturantPayment.pgCurrency + " TEXT, " + MasterMetaData.ResturantPayment.user_id + " TEXT, " + MasterMetaData.ResturantPayment.number_of_people + " TEXT, " + MasterMetaData.ResturantPayment.order_no + " INTEGER, " + MasterMetaData.ResturantPayment.CREATEDAT + " TEXT, " + MasterMetaData.ResturantPayment.MODIFIEDBY + " TEXT, " + MasterMetaData.ResturantPayment.payment_time + " TEXT, " + MasterMetaData.ResturantPayment.NAME + " TEXT, " + MasterMetaData.ResturantPayment.COUNTRYCODE + " TEXT, " + MasterMetaData.ResturantPayment.USERPHONE + " TEXT, " + MasterMetaData.ResturantPayment.USEREMAIL + " TEXT, " + MasterMetaData.ResturantPayment.REFUND + " TEXT, " + MasterMetaData.ResturantPayment.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.DeletedOrders.TABLE_NAME + " (" + MasterMetaData.DeletedOrders.ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + MasterMetaData.DeletedOrders.TABLEID + " TEXT, " + MasterMetaData.DeletedOrders.SEATID + " INTEGER, " + MasterMetaData.DeletedOrders.MENUITEMID + " INTEGER, " + MasterMetaData.DeletedOrders.MENUPRICEID + " INTEGER, " + MasterMetaData.DeletedOrders.OrderID + " INTEGER, " + MasterMetaData.DeletedOrders.ORDERNO + " INTEGER " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.FoodType.TABLE_NAME + " (" + MasterMetaData.FoodType.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.FoodType.RESTAURANT_ID + " INTEGER, " + MasterMetaData.FoodType.NAME + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuFoodTypes.TABLE_NAME + " (" + MasterMetaData.MenuFoodTypes.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuFoodTypes.food_type_id + " INTEGER, " + MasterMetaData.MenuFoodTypes.menu_item_id + " INTEGER, " + MasterMetaData.MenuFoodTypes.category_id + " INTEGER " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.messages.TABLE_NAME + " (" + MasterMetaData.messages.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.messages.restaurant_id + " INTEGER, " + MasterMetaData.messages.order_no + " INTEGER, " + MasterMetaData.messages.type + " INTEGER, " + MasterMetaData.messages.message + " TEXT " + ");");
}
@Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
if (i == 5 & i1 == 6) {
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.messages.TABLE_NAME + " (" + MasterMetaData.messages.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.messages.restaurant_id + " INTEGER, " + MasterMetaData.messages.order_no + " INTEGER, " + MasterMetaData.messages.type + " INTEGER, " + MasterMetaData.messages.message + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.ResturantPayment.TABLE_NAME + " (" + MasterMetaData.ResturantPayment.ID + " INTEGER PRIMARY KEY, " + MasterMetaData.ResturantPayment.COMPANY_ID + " INTEGER, " + MasterMetaData.ResturantPayment.MERCAHNT_ID + " INTEGER, " + MasterMetaData.ResturantPayment.RESTAURANT_ID + " INTEGER, " + MasterMetaData.ResturantPayment.TABLENUMBER + " TEXT, " + MasterMetaData.ResturantPayment.BATCHNUMBER + " TEXT, " + MasterMetaData.ResturantPayment.BATCHSTATUS + " TEXT, " + MasterMetaData.ResturantPayment.PAYMENYDATE + " DATE, " + MasterMetaData.ResturantPayment.AMOUNT + " REAL, " + MasterMetaData.ResturantPayment.DISCOUNTAMOUNT + " REAL, " + MasterMetaData.ResturantPayment.TOTALAMOUNT + " REAL, " + MasterMetaData.ResturantPayment.DISCOUNTREASON + " TEXT, " + MasterMetaData.ResturantPayment.COUPONCODE + " TEXT, " + MasterMetaData.ResturantPayment.TRANSACTIONID + " TEXT, " + MasterMetaData.ResturantPayment.APPROVALCODE + " TEXT, " + MasterMetaData.ResturantPayment.APPROVALMESSAGE + " TEXT, " + MasterMetaData.ResturantPayment.PAYMENTSTATUS + " INTEGER, " + MasterMetaData.ResturantPayment.PAYMENTTYPE + " INTEGER, " + MasterMetaData.ResturantPayment.def_currency_id + " INTEGER, " + MasterMetaData.ResturantPayment.additional_info1 + " TEXT, " + MasterMetaData.ResturantPayment.additional_info2 + " TEXT, " + MasterMetaData.ResturantPayment.bill_number + " TEXT, " + MasterMetaData.ResturantPayment.tax_details + " TEXT, " + MasterMetaData.ResturantPayment.tips + " REAL, " + MasterMetaData.ResturantPayment.tx_status + " TEXT, " + MasterMetaData.ResturantPayment.tx_id + " TEXT, " + MasterMetaData.ResturantPayment.pg_resp_code + " TEXT, " + MasterMetaData.ResturantPayment.tx_msg + " TEXT, " + MasterMetaData.ResturantPayment.paid_amount + " REAL, " + MasterMetaData.ResturantPayment.auth_id_code + " TEXT, " + MasterMetaData.ResturantPayment.payment_mode + " TEXT, " + MasterMetaData.ResturantPayment.pg_mobile_no + " TEXT, " + MasterMetaData.ResturantPayment.txn_date_time + " TEXT, " + MasterMetaData.ResturantPayment.transaction_reference + " TEXT, " + MasterMetaData.ResturantPayment.pgCurrency + " TEXT, " + MasterMetaData.ResturantPayment.user_id + " TEXT, " + MasterMetaData.ResturantPayment.number_of_people + " TEXT, " + MasterMetaData.ResturantPayment.order_no + " INTEGER, " + MasterMetaData.ResturantPayment.CREATEDAT + " TEXT, " + MasterMetaData.ResturantPayment.MODIFIEDBY + " TEXT, " + MasterMetaData.ResturantPayment.payment_time + " TEXT, " + MasterMetaData.ResturantPayment.NAME + " TEXT, " + MasterMetaData.ResturantPayment.COUNTRYCODE + " TEXT, " + MasterMetaData.ResturantPayment.USERPHONE + " TEXT, " + MasterMetaData.ResturantPayment.USEREMAIL + " TEXT, " + MasterMetaData.ResturantPayment.REFUND + " TEXT, " + MasterMetaData.ResturantPayment.MODIFIEDAT + " TEXT " + ");");
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + MasterMetaData.MenuPrice.TABLE_NAME + " (" + MasterMetaData.MenuPrice.MENU_PRICE_ID + " INTEGER PRIMARY KEY, " + MasterMetaData.MenuPrice.MENU_ID + " INTEGER, " + MasterMetaData.MenuPrice.QUANTITYNAME + " TEXT, " + MasterMetaData.MenuPrice.AVAILABILITY + " TEXT, " + MasterMetaData.MenuPrice.MENU_PRICE + " REAL " + ");");
}
}
private int activeDatabaseCount = 0;
public synchronized SQLiteDatabase openDatabase() {
SQLiteDatabase connection = getWritableDatabase(); // always returns // the same // connection // instance activeDatabaseCount++;
return connection;
}
public synchronized void closeDatabase(SQLiteDatabase connection) {
activeDatabaseCount--;
if (activeDatabaseCount == 0) {
if (connection != null) {
if (connection.isOpen()) {
// connection.close();
Log.i("OneMasterT",
"In MasterDB : closeDatabase : DB closed");
}
}
}
}
public long insertUserDeatils(String tableName,
JSONObject object) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.UserTable.USER_ID,
object.getInt("user_id"));
cv.put(MasterMetaData.UserTable.USER_TYPE_ID, object.getInt("user_type_id"));
cv.put(MasterMetaData.UserTable.NAME, object.getString("name"));
cv.put(MasterMetaData.UserTable.USERNAME, object.getString("user_name"));
cv.put(MasterMetaData.UserTable.USERPASSWORD,
object.getString("user_password"));
cv.put(MasterMetaData.UserTable.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.UserTable.CREATEDAT,
object.getString(MasterMetaData.UserTable.CREATEDAT));
cv.put(MasterMetaData.UserTable.MODIFIEDAT,
object.getString(MasterMetaData.UserTable.MODIFIEDAT));
row = db.insert(tableName, null, cv);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertRestaurantDeatils(JSONObject object) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.Restaurant.RESTAURANT_ID,
object.getInt("id"));
// cv.put(MasterMetaData.Restaurant.COMPANY_ID, object.getInt("company_id"));// cv.put(MasterMetaData.Restaurant.MERCAHNT_ID, object.getInt("merchant_id")); cv.put(MasterMetaData.Restaurant.NAME,
object.getString(MasterMetaData.Restaurant.NAME));
cv.put(MasterMetaData.Restaurant.ADDRESS, object.getString(MasterMetaData.Restaurant.ADDRESS));
cv.put(MasterMetaData.Restaurant.CONTACTNAME, object.getString(MasterMetaData.Restaurant.CONTACTNAME));
cv.put(MasterMetaData.Restaurant.CONTACTEMAIL,
object.getString(MasterMetaData.Restaurant.CONTACTEMAIL));
cv.put(MasterMetaData.Restaurant.PASSWORD, object.getString(MasterMetaData.Restaurant.PASSWORD));
// cv.put(MasterMetaData.Restaurant.PHONE, object.getString(MasterMetaData.Restaurant.PHONE));
cv.put(MasterMetaData.Restaurant.LOGO,
object.getString(MasterMetaData.Restaurant.LOGO));
cv.put(MasterMetaData.Restaurant.URL, object.getString(MasterMetaData.Restaurant.URL));
cv.put(MasterMetaData.Restaurant.LATITUDE, object.getString(MasterMetaData.Restaurant.LATITUDE));
cv.put(MasterMetaData.Restaurant.LONGITUDE,
object.getString(MasterMetaData.Restaurant.LONGITUDE));
cv.put(MasterMetaData.Restaurant.CURRENCY_ID, object.getString(MasterMetaData.Restaurant.CURRENCY_ID));
cv.put(MasterMetaData.Restaurant.STATUS, object.getString(MasterMetaData.Restaurant.STATUS));
cv.put(MasterMetaData.Restaurant.TIN,
object.getString("tin"));
cv.put(MasterMetaData.Restaurant.MODIFIEDBY,
object.getString(MasterMetaData.Restaurant.MODIFIEDBY));
cv.put(MasterMetaData.Restaurant.AUTH_TOKEN,
object.getString(MasterMetaData.Restaurant.AUTH_TOKEN));
cv.put(MasterMetaData.Restaurant.CREATEDAT,
object.getString(MasterMetaData.Restaurant.CREATEDAT));
cv.put(MasterMetaData.Restaurant.MODIFIEDAT,
object.getString(MasterMetaData.Restaurant.CREATEDAT));
row = db.insert(MasterMetaData.Restaurant.TABLE_NAME, null, cv);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuCategoryDetails(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.MenuCategories.CATEGORY_ID,
object.getInt("id"));
cv.put(MasterMetaData.MenuCategories.DISPLAYNAME, object.getString("display_name"));
cv.put(MasterMetaData.MenuCategories.NAME, object.getString("name"));
cv.put(MasterMetaData.MenuCategories.DESCRIPTION, object.getString("description"));
cv.put(MasterMetaData.MenuCategories.IMAGE,
object.getString("image"));
cv.put(MasterMetaData.MenuCategories.CATEGORYTYPE,
object.getString("category_type"));
cv.put(MasterMetaData.MenuCategories.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.MenuCategories.MODIFIEDBY,
object.getString("modified_by"));
cv.put(MasterMetaData.MenuCategories.ORDERNO,
object.getString("order_number"));
cv.put(MasterMetaData.MenuCategories.CREATEDAT,
object.getString(MasterMetaData.MenuCategories.CREATEDAT));
cv.put(MasterMetaData.MenuCategories.MODIFIEDAT,
object.getString(MasterMetaData.MenuCategories.MODIFIEDAT));
row = db.insert(MasterMetaData.MenuCategories.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuDetails(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantMenu.MENU_ID,
object.getInt("id"));
// cv.put(MasterMetaData.Restaurant.COMPANY_ID, object.getInt("company_id"));// cv.put(MasterMetaData.Restaurant.MERCAHNT_ID, object.getInt("merchant_id")); cv.put(MasterMetaData.ResturantMenu.INGREDIENTS, object.getString("ingredients"));
cv.put(MasterMetaData.ResturantMenu.NAME, object.getString("name"));
cv.put(MasterMetaData.ResturantMenu.DESCRIPTION, object.getString("description"));
cv.put(MasterMetaData.ResturantMenu.IMAGE,
object.getString("image"));
cv.put(MasterMetaData.ResturantMenu.PREPTIME,
object.getString("prep_time"));
cv.put(MasterMetaData.ResturantMenu.PRICE,
object.getString("price"));
cv.put(MasterMetaData.ResturantMenu.CURRENCY_ID,
object.getString("def_currency_id"));
cv.put(MasterMetaData.ResturantMenu.VIDEOLINK,
object.getString("video_link"));
cv.put(MasterMetaData.ResturantMenu.RATING,
object.getString("rating"));
cv.put(MasterMetaData.ResturantMenu.ORDERNO,
object.getString("order_number"));
cv.put(MasterMetaData.ResturantMenu.LASTCHANED,
object.getString("last_changed"));
cv.put(MasterMetaData.ResturantMenu.STATUS,
object.getString("status"));
cv.put(MasterMetaData.ResturantMenu.KITCHEN_ID,
object.getInt("kitchen_id"));
cv.put(MasterMetaData.ResturantMenu.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.ResturantMenu.MODIFIEDBY,
object.getString("modified_by"));
cv.put(MasterMetaData.ResturantMenu.CREATEDAT,
object.getString(MasterMetaData.ResturantMenu.CREATEDAT));
cv.put(MasterMetaData.ResturantMenu.MODIFIEDAT,
object.getString(MasterMetaData.ResturantMenu.MODIFIEDAT));
cv.put(MasterMetaData.ResturantMenu.CATEGORY_ID,
object.getInt("category_id"));
cv.put(MasterMetaData.ResturantMenu.MENUTYPE,
object.getString("menu_type"));
row = db.insert(MasterMetaData.ResturantMenu.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertFoodType(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.FoodType.ID,
object.getInt("id"));
cv.put(MasterMetaData.FoodType.NAME, object.getString("name"));
cv.put(MasterMetaData.FoodType.RESTAURANT_ID, object.getInt("restaurant_id"));
row = db.insert(MasterMetaData.FoodType.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuFoodType(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.MenuFoodTypes.ID,
object.getInt("id"));
cv.put(MasterMetaData.MenuFoodTypes.food_type_id, object.getInt("food_type_id"));
cv.put(MasterMetaData.MenuFoodTypes.menu_item_id, object.getInt("menu_item_id"));
cv.put(MasterMetaData.MenuFoodTypes.category_id, object.getInt("category_id"));
row = db.insert(MasterMetaData.MenuFoodTypes.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuPrice(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.MenuPrice.MENU_PRICE_ID,
object.getInt("menu_price_id"));
cv.put(MasterMetaData.MenuPrice.MENU_ID, object.getInt("menu_id"));
cv.put(MasterMetaData.MenuPrice.QUANTITYNAME, object.getString("quantity_name"));
cv.put(MasterMetaData.MenuPrice.MENU_PRICE, object.getDouble("menu_price"));
cv.put(MasterMetaData.MenuPrice.AVAILABILITY, object.getString("availability"));
row = db.insert(MasterMetaData.MenuPrice.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuImage(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.MenuImage.MENU_IMAGE_ID,
object.getInt("menu_image_id"));
cv.put(MasterMetaData.MenuImage.MENU_ID, object.getInt("menu_id"));
cv.put(MasterMetaData.MenuImage.MENU_IMAGE_NAME, object.getString("menu_image_name"));
row = db.insert(MasterMetaData.MenuImage.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMenuTag(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.MenuTag.MENU_TAG_ID,
object.getInt("tag_id"));
cv.put(MasterMetaData.MenuTag.MENU_ID, object.getInt("menu_id"));
cv.put(MasterMetaData.MenuTag.MENU_TAG_NAME, object.getString("tag_name"));
row = db.insert(MasterMetaData.MenuTag.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertResTableDetails(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantTable.ID,
object.getInt("id"));
// cv.put(MasterMetaData.ResturantTable.COMPANY_ID, object.getInt("company_id"));// cv.put(MasterMetaData.ResturantTable.MERCAHNT_ID, object.getInt("merchant_id")); cv.put(MasterMetaData.ResturantTable.RESTAURANT_ID,
object.getInt("restaurant_id"));
// cv.put(MasterMetaData.ResturantTable.TABLENO, object.getInt("table_number")); cv.put(MasterMetaData.ResturantTable.TABLENAME, object.getString("table_name"));
cv.put(MasterMetaData.ResturantTable.IPADDRESS, object.getString("ip_address"));
cv.put(MasterMetaData.ResturantTable.DEVICEID,
object.getString("device_id"));
cv.put(MasterMetaData.ResturantTable.NUMBEROFSEATS,
object.getString("number_of_seats"));
cv.put(MasterMetaData.ResturantTable.STATUS,
object.getString("status"));
cv.put(MasterMetaData.ResturantTable.MODIFIEDBY,
object.getString("modified_by"));
cv.put(MasterMetaData.ResturantTable.CREATEDAT,
object.getString(MasterMetaData.ResturantTable.CREATEDAT));
cv.put(MasterMetaData.ResturantTable.MODIFIEDAT,
object.getString(MasterMetaData.ResturantTable.MODIFIEDAT));
row = db.insert(MasterMetaData.ResturantTable.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertResTableCurrencyDetails(JSONObject object) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantCurrency.CURRENCY_ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantCurrency.NAME,
object.getString("name"));
cv.put(MasterMetaData.ResturantCurrency.DESCRIPTION, object.getString("description"));
cv.put(MasterMetaData.ResturantCurrency.DISPLAYNAME, object.getString("display_name"));
row = db.insert(MasterMetaData.ResturantCurrency.TABLE_NAME, null, cv);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMessages(JSONObject object) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
/* cv.put(MasterMetaData.messages.ID, object.getInt("id"));*/ try {
cv.put(MasterMetaData.messages.restaurant_id, object.getInt("restaurant_id"));
} catch (Exception e) {
}
cv.put(MasterMetaData.messages.order_no, object.getInt("order_no"));
cv.put(MasterMetaData.messages.type, object.getInt("type"));
cv.put(MasterMetaData.messages.message, object.getString("message"));
row = db.insert(MasterMetaData.messages.TABLE_NAME, null, cv);
closeDatabase(db);
} catch (Exception e) {
Log.e("Message", e.toString());
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertMessagesTemp(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
/* cv.put(MasterMetaData.messages.ID, object.getInt("id"));*/ try {
cv.put(MasterMetaData.messages.restaurant_id, object.getInt("restaurant_id"));
} catch (Exception e) {
}
cv.put(MasterMetaData.messages.order_no, object.getInt("order_no"));
cv.put(MasterMetaData.messages.type, object.getInt("type"));
cv.put(MasterMetaData.messages.message, object.getString("message"));
row = db.insert(MasterMetaData.messages.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
Log.e("Message", e.toString());
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long deleteResDEltedOrders(int menu_id, int order_no, int menu_price_id, int table_id, int seat_id) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
db.delete(MasterMetaData.DeletedOrders.TABLE_NAME, MasterMetaData.DeletedOrders.MENUITEMID + " = " + menu_id + " and " + MasterMetaData.DeletedOrders.MENUPRICEID + " = " + menu_price_id + " and " + MasterMetaData.DeletedOrders.ORDERNO + " = " + order_no + " and " + MasterMetaData.DeletedOrders.SEATID + " = " + seat_id + " and " + MasterMetaData.DeletedOrders.TABLEID + " = '" + table_id + "'", null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long deleteTakewayOrder(int id) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
db.delete(MasterMetaData.DeletedTakewayOrders.TABLE_NAME, MasterMetaData.DeletedTakewayOrders.ORDERNO + " and " + MasterMetaData.DeletedTakewayOrders.TAKEAWAY + " and " + MasterMetaData.DeletedTakewayOrders.ID, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertResTableDeletedOrderDeatils(int menu_id, int order_no, int menu_price_id, int table_id, int seat_id, int order_id) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
db.delete(MasterMetaData.DeletedOrders.TABLE_NAME, MasterMetaData.DeletedOrders.MENUITEMID + " = " + menu_id + " and " + MasterMetaData.DeletedOrders.MENUPRICEID + " = " + menu_price_id + " and " + MasterMetaData.DeletedOrders.ORDERNO + " = " + order_no + " and " + MasterMetaData.DeletedOrders.SEATID + " = " + seat_id + " and " + MasterMetaData.DeletedOrders.TABLEID + " = '" + table_id + "'" + " and " + MasterMetaData.DeletedOrders.OrderID + " = " + order_id, null);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.DeletedOrders.MENUITEMID,
menu_id);
cv.put(MasterMetaData.DeletedOrders.TABLEID, String.valueOf(table_id));
cv.put(MasterMetaData.DeletedOrders.ORDERNO, order_no);
cv.put(MasterMetaData.DeletedOrders.MENUPRICEID,
menu_price_id);
cv.put(MasterMetaData.DeletedOrders.SEATID,
seat_id);
cv.put(MasterMetaData.DeletedOrders.OrderID,
order_id);
row = db.insert(MasterMetaData.DeletedOrders.TABLE_NAME, null, cv);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertResTableTaxDetails(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantTax.TAX_ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantTax.NAME, object.getString("name"));
cv.put(MasterMetaData.ResturantTax.DISPLAYNAME, object.getString("display_name"));
cv.put(MasterMetaData.ResturantTax.DESCRIPTION,
object.getString("description"));
cv.put(MasterMetaData.ResturantTax.TAX,
object.getInt("tax"));
row = db.insert(MasterMetaData.ResturantTax.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertResTableSeatDetails(JSONArray array) {
long row = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantSeat.SEAT_ID,
object.getInt("seat_id"));
cv.put(MasterMetaData.ResturantSeat.RES_TABLE_ID, object.getInt("table_id"));
cv.put(MasterMetaData.ResturantSeat.SEATNAME, object.getString("seat_name"));
cv.put(MasterMetaData.ResturantSeat.SEATSTATUS,
object.getString("seat_status"));
cv.put(MasterMetaData.ResturantSeat.CREATEDAT,
object.getString(MasterMetaData.ResturantSeat.CREATEDAT));
row = db.insert(MasterMetaData.ResturantSeat.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public boolean IsMasterLoggedIn() {
boolean status = false;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.UserTable.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
status = true;
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public ArrayList<Integer> statusOrderExists(int menu_id, int menu_price_id, int table_id, int seat_id, int order_no) {
ArrayList<Integer> arrayList = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.DeletedOrders.MENUPRICEID + " = " + menu_price_id + " and " + MasterMetaData.ResturantOrders.SEATID + " = " + seat_id
+ " and " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " = " + menu_id + " and " + MasterMetaData.ResturantOrders.TABLENUMBER + " = '" + table_id + "'" + " and " + MasterMetaData.ResturantOrders.ORDERNO + " = '" + order_no + "'";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
arrayList = new ArrayList<>();
arrayList.add(c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.ID)));
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return arrayList;
}
public ArrayList<Integer> RestaurantTableDeatils() {
ArrayList<Integer> table_details = new ArrayList<>();
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantTable.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
table_details = new ArrayList<>();
do {
table_details.add(c.getInt(c.getColumnIndex(MasterMetaData.ResturantTable.ID)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return table_details;
}
public JSONArray SeatsDeatils(int table_id) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantSeat.TABLE_NAME + " Where " + MasterMetaData.ResturantSeat.RES_TABLE_ID + " = " + table_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("seat_id", c.getInt(c.getColumnIndex(MasterMetaData.ResturantSeat.SEAT_ID)));
object.put("seat_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantSeat.SEATNAME)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getFeletedOrderDeatils(int table_id, int seat_id, int orderno) {
JSONArray jsonArray = new JSONArray();
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.DeletedOrders.TABLE_NAME + " Where " + MasterMetaData.DeletedOrders.SEATID + " = " + seat_id + " and " + MasterMetaData.DeletedOrders.TABLEID + " = '" + table_id + "' and " + MasterMetaData.DeletedOrders.ORDERNO + " = " + orderno;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("seat_id", c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.SEATID)));
object.put("table_number", c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.TABLEID)));
object.put("menu_id", c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.MENUITEMID)));
object.put("menu_price_id", c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.MENUPRICEID)));
object.put("order_id", c.getInt(c.getColumnIndex(MasterMetaData.DeletedOrders.OrderID)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONObject RestaurantTableDeatils(int table_id) {
JSONObject object = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantTable.TABLE_NAME + " Where " + MasterMetaData.ResturantTable.ID + " = " + table_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
object = new JSONObject();
do {
object.put("table_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantTable.TABLENAME)));
object.put("numberOfSeats", c.getInt(c.getColumnIndex(MasterMetaData.ResturantTable.NUMBEROFSEATS)));
} while (c.moveToNext());
closeDatabase(db);
}
if (object != null) {
if (object.has("table_name")) {
JSONArray jsonarray = SeatsDeatils(table_id);
object.put("seat_details", jsonarray);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return object;
}
public ArrayList<Integer> RestaurantCaterogryDeatils() {
ArrayList<Integer> table_details = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.MenuCategories.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
table_details = new ArrayList<>();
table_details.add(0);
if (c.moveToFirst()) {
do {
table_details.add(c.getInt(c.getColumnIndex(MasterMetaData.MenuCategories.CATEGORY_ID)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return table_details;
}
public JSONArray RestaurantMenuDeatilsBasedOnCaterogryID(int caterogryID) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantMenu.TABLE_NAME + " Where " + MasterMetaData.ResturantMenu.CATEGORY_ID + " = " + caterogryID;
if (caterogryID == 0)
selectteacherdata = " SELECT * from " + MasterMetaData.ResturantMenu.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
int menu_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.MENU_ID));
object.put("menu_id", menu_id);
object.put("menu_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.NAME)));
object.put("menu_type", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.MENUTYPE)));
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + menu_id + " and " + MasterMetaData.MenuPrice.AVAILABILITY + " = " + 1;
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_price_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE_ID)));
object1.put("quantity_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)));
object1.put("menu_price", c1.getDouble(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_price_deatils", array);
}
data = " SELECT * from " + MasterMetaData.MenuImage.TABLE_NAME + " Where " + MasterMetaData.MenuImage.MENU_ID + " = " + menu_id ;
c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_image_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_ID)));
object1.put("menu_image_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_NAME)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_image_deatils", array);
}
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public ArrayList<Integer> getMenuIdBasedOnFoodTypeId(String foodType_ids, int caterogery_id) {
ArrayList<Integer> jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.MenuFoodTypes.TABLE_NAME + " Where " + MasterMetaData.MenuFoodTypes.category_id + " = " + caterogery_id + " and " + MasterMetaData.MenuFoodTypes.food_type_id + " IN (" + foodType_ids + ")";
if (caterogery_id == 0)
selectteacherdata = " SELECT * from " + MasterMetaData.MenuFoodTypes.TABLE_NAME + " Where " + MasterMetaData.MenuFoodTypes.food_type_id + " IN (" + foodType_ids + ")";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new ArrayList<>();
do {
jsonArray.add(c.getInt(c.getColumnIndex(MasterMetaData.MenuFoodTypes.menu_item_id)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray RestaurantMenuDeatilsBasedOnFoodType(String menu_ids) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantMenu.TABLE_NAME + " Where " + MasterMetaData.ResturantMenu.MENU_ID + " IN (" + menu_ids + ")";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
int menu_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.MENU_ID));
object.put("menu_id", menu_id);
object.put("menu_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.NAME)));
object.put("menu_type", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.MENUTYPE)));
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + menu_id;
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_price_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE_ID)));
object1.put("quantity_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)));
object1.put("menu_price", c1.getDouble(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_price_deatils", array);
}
data = " SELECT * from " + MasterMetaData.MenuImage.TABLE_NAME + " Where " + MasterMetaData.MenuImage.MENU_ID + " = " + menu_id;
c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_image_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_ID)));
object1.put("menu_image_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_NAME)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_image_deatils", array);
}
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray RestaurantMenuDeatilsBasedOnCaterogryIDAndMenuName(String MenuName) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = selectteacherdata = " SELECT * from " + MasterMetaData.ResturantMenu.TABLE_NAME + " Where " + MasterMetaData.ResturantMenu.NAME + " LIKE '%" + MenuName + "%'";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
int menu_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.MENU_ID));
object.put("menu_id", menu_id);
object.put("menu_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.NAME)));
object.put("menu_type", c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.MENUTYPE)));
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + menu_id;
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_price_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE_ID)));
object1.put("quantity_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)));
object1.put("menu_price", c1.getDouble(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_price_deatils", array);
}
data = " SELECT * from " + MasterMetaData.MenuImage.TABLE_NAME + " Where " + MasterMetaData.MenuImage.MENU_ID + " = " + menu_id;
c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
JSONArray array = new JSONArray();
do {
JSONObject object1 = new JSONObject();
object1.put("menu_image_id", c1.getInt(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_ID)));
object1.put("menu_image_name", c1.getString(c1.getColumnIndex(MasterMetaData.MenuImage.MENU_IMAGE_NAME)));
array.put(object1);
} while (c1.moveToNext());
object.put("menu_image_deatils", array);
}
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getPaymentdeatils(int orderNo) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantPayment.TABLE_NAME + " Where " + MasterMetaData.ResturantPayment.order_no + " = " + orderNo;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("time", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.payment_time)));
object.put("date", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENYDATE)));
object.put("total_amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.TOTALAMOUNT)));
object.put("discount_amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.DISCOUNTAMOUNT)));
object.put("tax_details", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.tax_details)));
object.put("amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.AMOUNT)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getTaxdeatils() {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantTax.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("tax_id", c.getInt(c.getColumnIndex(MasterMetaData.ResturantTax.TAX_ID)));
object.put("tex_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantTax.DISPLAYNAME)));
object.put("tax_amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantTax.TAX)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getOrderDeatilsForOrderNo(int orderno) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
String menu_name = c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_NAME));
int menu_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_ID));
int menu_price_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENUPRICEID));
object.put("menu_id", menu_id);
object.put("table_id", Integer.parseInt(c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.TABLENUMBER))));
object.put("seat_id", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SEATID)));
object.put("menu_price_id", menu_price_id);
object.put("item_quantity", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ITEM_QUANTITY)));
object.put("menu_price", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantOrders.PRICE)));
object.put("take_away", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.TAKEAWAY)));
object.put("name", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.NAME)));
object.put("user_phone", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.USERPHONE)));
object.put("served_status", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SERVERDSTATUS)));
object.put("order_status", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERSTATUS)));
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + menu_id + " and " + MasterMetaData.MenuPrice.MENU_PRICE_ID + " = " + menu_price_id;
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
do {
menu_name += " (" + c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)) + ")";
} while (c1.moveToNext());
}
object.put("menu_name", menu_name);
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public int RestaurantID() {
int restaurantID = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.Restaurant.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
restaurantID = c.getInt(c.getColumnIndex(MasterMetaData.Restaurant.RESTAURANT_ID));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return restaurantID;
}
public int MasterUserID() {
int userID = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.UserTable.TABLE_NAME + " Where " + MasterMetaData.UserTable.USER_TYPE_ID + " = 2";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
userID = c.getInt(c.getColumnIndex(MasterMetaData.UserTable.USER_ID));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return userID;
}
public JSONObject RestaurantCaterogryDetailsBasedOnCaterogery(int caterogeryID) {
JSONObject object = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.MenuCategories.TABLE_NAME + " Where " + MasterMetaData.MenuCategories.CATEGORY_ID + " = " + caterogeryID;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
object = new JSONObject();
do {
object.put("caterogery_name", c.getString(c.getColumnIndex(MasterMetaData.MenuCategories.NAME)));
object.put("caterogery_image", c.getString(c.getColumnIndex(MasterMetaData.MenuCategories.IMAGE)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return object;
}
public JSONObject getSeatsStatus(int table_id) {
JSONObject object = new JSONObject();
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = "Select COUNT (*) from " + MasterMetaData.ResturantSeat.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c != null) {
if (c.getCount() > 0) {
if (c.moveToFirst()) {
object = new JSONObject();
do {
object.put("total_seats", c.getInt(0));
} while (c.moveToNext());
}
} else {
object.put("total_seats", 0);
}
}
selectteacherdata = "Select COUNT (*) from " + MasterMetaData.ResturantSeat.TABLE_NAME + " Where " + MasterMetaData.ResturantSeat.SEATSTATUS + " = 'null'";
Cursor c1 = db.rawQuery(selectteacherdata, null);
if (c1 != null) {
if (c1.getCount() > 0) {
if (c1.moveToFirst()) {
do {
object.put("total_vacant_seat", c1.getInt(0));
} while (c1.moveToNext());
}
} else {
object.put("total_vacant_seat", 0);
}
}
selectteacherdata = "Select COUNT (*) from " + MasterMetaData.ResturantSeat.TABLE_NAME + " Where " + MasterMetaData.ResturantSeat.SEATSTATUS + " != 'null'";
Cursor c2 = db.rawQuery(selectteacherdata, null);
if (c2 != null) {
if (c2.getCount() > 0) {
if (c2.moveToFirst()) {
do {
object.put("total_occupied_seat", c2.getInt(0));
} while (c2.moveToNext());
}
} else {
object.put("total_occupied_seat", 0);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return object;
}
public long deletedOrderFromDatabase(JSONArray array, int orderNo) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
row = db.delete(MasterMetaData.DeletedOrders.TABLE_NAME, MasterMetaData.DeletedOrders.MENUITEMID + " = " + object.getInt("menu_id") + " and " + MasterMetaData.DeletedOrders.MENUPRICEID + " = " + object.getInt("menu_price_id") + " and " + MasterMetaData.DeletedOrders.ORDERNO + " = " + orderNo + " and " + MasterMetaData.DeletedOrders.SEATID + " = " + object.getInt("seat_id") + " and " + MasterMetaData.DeletedOrders.TABLEID + " = '" + object.getInt("table_number") + "'", null);
if (row != -1) {
row = db.delete(MasterMetaData.ResturantOrders.TABLE_NAME, MasterMetaData.ResturantOrders.ID + " = " + object.getInt("order_id") + " and " + MasterMetaData.ResturantOrders.MENUPRICEID + " = " + object.getInt("menu_price_id") + " and " + MasterMetaData.ResturantOrders.ORDERNO + " = " + orderNo + " and " + MasterMetaData.ResturantOrders.SEATID + " = " + object.getInt("seat_id") + " and " + MasterMetaData.ResturantOrders.TABLENUMBER + " = '" + object.getInt("table_number") + "'", null);
}
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertRestaurantOrder(JSONArray array) {
long row = -1;
SQLiteDatabase db = null;
try {
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
Boolean status = OrderNoexists(object.getInt("id"));
db = openDatabase();
if (status) {
// ContentValues cv = new ContentValues();// cv.put(MasterMetaData.ResturantOrders.PRICE,// object.getDouble("price"));// cv.put(MasterMetaData.ResturantOrders.ITEM_QUANTITY,// object.getInt("item_quantity"));// cv.put(MasterMetaData.ResturantOrders.MODIFIEDAT,// object.getString(MasterMetaData.ResturantOrders.MODIFIEDAT));// row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ID + " = "+object.getInt("id"),null); } else {
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantOrders.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.ResturantOrders.MENU_ITEM_ID, object.getInt("menu_item_id"));
cv.put(MasterMetaData.ResturantOrders.MENU_ITEM_NAME, object.getString("menu_item_name"));
cv.put(MasterMetaData.ResturantOrders.TABLENUMBER,
object.getString("table_number"));
/* String strDate = object.getString("order_date"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = dateFormat.parse(strDate); System.out.println(date); SimpleDateFormat dateFormat1 = new SimpleDateFormat("MM-DD-YYYY HH:MM"); String strDate1 = dateFormat1.format(date); cv.put(MasterMetaData.ResturantOrders.ORDER_DATE, strDate1);*/
cv.put(MasterMetaData.ResturantOrders.ORDER_DATE,
object.getString("order_date"));
cv.put(MasterMetaData.ResturantOrders.PRICE,
object.getDouble("price"));
cv.put(MasterMetaData.ResturantOrders.ITEM_QUANTITY,
object.getInt("item_quantity"));
cv.put(MasterMetaData.ResturantOrders.SERVERDSTATUS,
object.getInt("served_status"));
cv.put(MasterMetaData.ResturantOrders.PENDINGSTATUS,
object.getInt("pending_status"));
cv.put(MasterMetaData.ResturantOrders.CREATEDAT,
object.getString(MasterMetaData.ResturantOrders.CREATEDAT));
cv.put(MasterMetaData.ResturantOrders.MODIFIEDAT,
object.getString(MasterMetaData.ResturantOrders.MODIFIEDAT));
cv.put(MasterMetaData.ResturantOrders.MODIFIEDBY,
object.getString(MasterMetaData.ResturantOrders.MODIFIEDBY));
cv.put(MasterMetaData.ResturantOrders.USERID,
object.getInt(MasterMetaData.ResturantOrders.USERID));
cv.put(MasterMetaData.ResturantOrders.ORDERNO,
object.getInt("order_no"));
cv.put(MasterMetaData.ResturantOrders.SEATID,
object.getInt("seat_id"));
cv.put(MasterMetaData.ResturantOrders.MENUPRICEID,
object.getInt("menu_price_id"));
if (object.getInt("seat_id") == 0)
cv.put(MasterMetaData.ResturantOrders.TAKEAWAY,
object.getInt("take_away"));
cv.put(MasterMetaData.ResturantOrders.NAME,
object.getString("name"));
cv.put(MasterMetaData.ResturantOrders.COUNTRYCODE,
object.getString("country_code"));
cv.put(MasterMetaData.ResturantOrders.USERPHONE,
object.getString("user_phone"));
cv.put(MasterMetaData.ResturantOrders.USEREMAIL,
object.getString("user_email"));
cv.put(MasterMetaData.ResturantOrders.CONFIRMDELIVERY,
object.getString("confirm_delivery"));
cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
object.getString("order_status"));
Cursor test=db.rawQuery("select * from "+MasterMetaData.ResturantOrders.TABLE_NAME+" where "+
MasterMetaData.ResturantOrders.ID+"="+object.getInt("id"),null);
if(!test.moveToFirst()){
row = db.insert(MasterMetaData.ResturantOrders.TABLE_NAME, null, cv);
}
}
if (row > -1) {
if (object.getInt("seat_id") != 0) {
int sucess = -1;
try {
ContentValues cv1 = new ContentValues();
cv1.put(MasterMetaData.ResturantSeat.SEATSTATUS,
"1");
sucess = db.update(MasterMetaData.ResturantSeat.TABLE_NAME, cv1, MasterMetaData.ResturantSeat.SEAT_ID + " = " + object.getInt("seat_id"), null);
} catch (Exception e) {
e.printStackTrace();
}
if (sucess == -1)
row = -1;
}
}
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertRestaurantOrderForLogin(JSONArray array) {
long row = -1;
SQLiteDatabase db = null;
try {
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
Boolean status = OrderNoexists(object.getInt("id"));
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantOrders.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.ResturantOrders.MENU_ITEM_ID, object.getInt("menu_item_id"));
cv.put(MasterMetaData.ResturantOrders.MENU_ITEM_NAME, object.getString("menu_item_name"));
cv.put(MasterMetaData.ResturantOrders.TABLENUMBER,
object.getString("table_number"));
/* String strDate = object.getString("order_date"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = dateFormat.parse(strDate); System.out.println(date); SimpleDateFormat dateFormat1 = new SimpleDateFormat("MM-DD-YYYY HH:MM"); String strDate1 = dateFormat1.format(date); cv.put(MasterMetaData.ResturantOrders.ORDER_DATE, strDate1);*/
cv.put(MasterMetaData.ResturantOrders.ORDER_DATE,
object.getString("order_date"));
cv.put(MasterMetaData.ResturantOrders.PRICE,
object.getDouble("price"));
cv.put(MasterMetaData.ResturantOrders.ITEM_QUANTITY,
object.getInt("item_quantity"));
cv.put(MasterMetaData.ResturantOrders.SERVERDSTATUS,
object.getInt("served_status"));
cv.put(MasterMetaData.ResturantOrders.PENDINGSTATUS,
object.getInt("pending_status"));
cv.put(MasterMetaData.ResturantOrders.CREATEDAT,
object.getString(MasterMetaData.ResturantOrders.CREATEDAT));
cv.put(MasterMetaData.ResturantOrders.MODIFIEDAT,
object.getString(MasterMetaData.ResturantOrders.MODIFIEDAT));
cv.put(MasterMetaData.ResturantOrders.MODIFIEDBY,
object.getString(MasterMetaData.ResturantOrders.MODIFIEDBY));
cv.put(MasterMetaData.ResturantOrders.USERID,
object.getInt(MasterMetaData.ResturantOrders.USERID));
cv.put(MasterMetaData.ResturantOrders.ORDERNO,
object.getInt("order_no"));
cv.put(MasterMetaData.ResturantOrders.SEATID,
object.getInt("seat_id"));
if (object.getInt("seat_id") == 0)
cv.put(MasterMetaData.ResturantOrders.TAKEAWAY,
object.getInt("take_away"));
cv.put(MasterMetaData.ResturantOrders.MENUPRICEID,
object.getInt("menu_price_id"));
cv.put(MasterMetaData.ResturantOrders.NAME,
object.getString("name"));
cv.put(MasterMetaData.ResturantOrders.COUNTRYCODE,
object.getString("country_code"));
cv.put(MasterMetaData.ResturantOrders.USERPHONE,
object.getString("user_phone"));
cv.put(MasterMetaData.ResturantOrders.USEREMAIL,
object.getString("user_email"));
cv.put(MasterMetaData.ResturantOrders.CONFIRMDELIVERY,
object.getString("confirm_delivery"));
cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
object.getString("order_status"));
row = db.insert(MasterMetaData.ResturantOrders.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long insertRestaurantPaymentFromLogin(JSONArray array) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantPayment.ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantPayment.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.ResturantPayment.TABLENUMBER,
object.getString("table_number"));
String strDate = object.getString("payment_date");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(strDate);
System.out.println(date);
SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
String strDate1 = dateFormat1.format(date);
cv.put(MasterMetaData.ResturantPayment.PAYMENYDATE, strDate1);
cv.put(MasterMetaData.ResturantPayment.AMOUNT, object.getDouble("amount"));
cv.put(MasterMetaData.ResturantPayment.DISCOUNTAMOUNT,
object.getDouble("discount_amount"));
cv.put(MasterMetaData.ResturantPayment.TOTALAMOUNT,
object.getDouble("total_amount"));
cv.put(MasterMetaData.ResturantPayment.PAYMENTSTATUS,
object.getInt("payment_status"));
cv.put(MasterMetaData.ResturantPayment.PAYMENTTYPE,
object.getInt("payment_type"));
cv.put(MasterMetaData.ResturantPayment.def_currency_id,
object.getInt("def_currency_id"));
cv.put(MasterMetaData.ResturantPayment.tax_details,
object.getString("tax_details"));
cv.put(MasterMetaData.ResturantPayment.payment_time,
object.getString("payment_time"));
cv.put(MasterMetaData.ResturantPayment.paid_amount,
object.getDouble("paid_amount"));
cv.put(MasterMetaData.ResturantPayment.CREATEDAT,
object.getString(MasterMetaData.ResturantPayment.CREATEDAT));
cv.put(MasterMetaData.ResturantPayment.MODIFIEDAT,
object.getString(MasterMetaData.ResturantPayment.MODIFIEDAT));
cv.put(MasterMetaData.ResturantPayment.MODIFIEDBY,
object.getString(MasterMetaData.ResturantPayment.MODIFIEDBY));
cv.put(MasterMetaData.ResturantPayment.user_id,
object.getInt(MasterMetaData.ResturantPayment.user_id));
cv.put(MasterMetaData.ResturantPayment.order_no,
object.getInt("order_no"));
cv.put(MasterMetaData.ResturantPayment.NAME,
object.getString("name"));
cv.put(MasterMetaData.ResturantPayment.COUNTRYCODE,
object.getString("country_code"));
cv.put(MasterMetaData.ResturantPayment.USERPHONE,
object.getString("user_phone"));
cv.put(MasterMetaData.ResturantPayment.USEREMAIL,
object.getString("user_email"));
row = db.insert(MasterMetaData.ResturantPayment.TABLE_NAME, null, cv);
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
//insertRestaurantPayment public long insertRestaurantPayment(JSONArray array) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
for (int count = 0; count < array.length(); count++) {
JSONObject object = array.getJSONObject(count);
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantPayment.ID,
object.getInt("id"));
cv.put(MasterMetaData.ResturantPayment.RESTAURANT_ID,
object.getInt("restaurant_id"));
cv.put(MasterMetaData.ResturantPayment.TABLENUMBER,
object.getString("table_number"));
String strDate = object.getString("payment_date");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(strDate);
System.out.println(date);
SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
String strDate1 = dateFormat1.format(date);
cv.put(MasterMetaData.ResturantPayment.PAYMENYDATE, strDate1);
cv.put(MasterMetaData.ResturantPayment.AMOUNT, object.getDouble("amount"));
cv.put(MasterMetaData.ResturantPayment.DISCOUNTAMOUNT,
object.getDouble("discount_amount"));
cv.put(MasterMetaData.ResturantPayment.TOTALAMOUNT,
object.getDouble("total_amount"));
cv.put(MasterMetaData.ResturantPayment.PAYMENTSTATUS,
object.getInt("payment_status"));
cv.put(MasterMetaData.ResturantPayment.PAYMENTTYPE,
object.getInt("payment_type"));
cv.put(MasterMetaData.ResturantPayment.def_currency_id,
object.getInt("def_currency_id"));
cv.put(MasterMetaData.ResturantPayment.tax_details,
object.getString("tax_details"));
cv.put(MasterMetaData.ResturantPayment.payment_time,
object.getString("payment_time"));
cv.put(MasterMetaData.ResturantPayment.paid_amount,
object.getDouble("paid_amount"));
cv.put(MasterMetaData.ResturantPayment.CREATEDAT,
object.getString(MasterMetaData.ResturantPayment.CREATEDAT));
cv.put(MasterMetaData.ResturantPayment.MODIFIEDAT,
object.getString(MasterMetaData.ResturantPayment.MODIFIEDAT));
cv.put(MasterMetaData.ResturantPayment.MODIFIEDBY,
object.getString(MasterMetaData.ResturantPayment.MODIFIEDBY));
cv.put(MasterMetaData.ResturantPayment.user_id,
object.getInt(MasterMetaData.ResturantPayment.user_id));
cv.put(MasterMetaData.ResturantPayment.order_no,
object.getInt("order_no"));
cv.put(MasterMetaData.ResturantPayment.REFUND,
object.getString("refund"));
/* cv.put(MasterMetaData.ResturantPayment.NAME, object.getString("name")); cv.put(MasterMetaData.ResturantPayment.COUNTRYCODE, object.getString("country_code"));
cv.put(MasterMetaData.ResturantPayment.USERPHONE, object.getString("user_phone")); cv.put(MasterMetaData.ResturantPayment.USEREMAIL, object.getString("user_email"));*/ Cursor test=db.rawQuery("select * from "+MasterMetaData.ResturantPayment.TABLE_NAME+" where "+
MasterMetaData.ResturantPayment.ID+"="+object.getInt("id"),null);
if(!test.moveToFirst()){
row = db.insert(MasterMetaData.ResturantPayment.TABLE_NAME, null, cv);
}
if (row > -1) {
int sucess = -1;
try {
ContentValues cv1 = new ContentValues();
cv1.put(MasterMetaData.ResturantOrders.PENDINGSTATUS, 1);
if (object.getInt("table_number") != 0)
cv1.put(MasterMetaData.ResturantOrders.CONFIRMDELIVERY, 1);
cv1.put(MasterMetaData.ResturantOrders.ORDERSTATUS, 9);
//object.getString("pending_status"));
sucess = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv1, MasterMetaData.ResturantOrders.ORDERNO + " = " + object.getInt("order_no"), null);
} catch (Exception e) {
e.printStackTrace();
}
if (sucess == -1)
row = -1;
else {
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ORDERNO + " = " + object.getInt("order_no");
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
int seat_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SEATID));
if (seat_id > 0) {
int sucess1 = -1;
try {
ContentValues cv1 = new ContentValues();
cv1.put(MasterMetaData.ResturantSeat.SEATSTATUS,
"null");
sucess1 = db.update(MasterMetaData.ResturantSeat.TABLE_NAME, cv1, MasterMetaData.ResturantSeat.SEAT_ID + " = " + seat_id, null);
} catch (Exception e) {
e.printStackTrace();
}
if (sucess1 == -1)
row = -1;
}
} while (c.moveToNext());
}
}
}
}
closeDatabase(db);
} catch (Exception e) {
Log.d("MasterDB", e.toString());
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public Boolean OrderNoexists(int OrderID) {
Boolean status = false;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ID + " = " + OrderID + " and " + MasterMetaData.ResturantOrders.PENDINGSTATUS + " = 0";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
status = true;
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public long updateOrderServerStatus(int order_id, int orderStatus) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.SERVERDSTATUS,
orderStatus);
row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ID + " = " + order_id, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long updateOrderConfirmStatus(int orderno) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.CONFIRMDELIVERY,
1);
cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
9);
row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long updateCancelConfirmStatus(int orderno) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
2);
row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long updateCancelConfirmStatusTo3(int orderno) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
//CANCEL ORDER cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
3);
// cv.put(MasterMetaData.ResturantOrders.PENDINGSTATUS,1 );
row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long updateSeatCancelConfirmStatus(int orderno) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
if (row == -1)
row = -1;
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
int seat_id = c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SEATID));
if (seat_id > 0) {
int sucess1 = -1;
try {
ContentValues cv1 = new ContentValues();
cv1.put(MasterMetaData.ResturantSeat.SEATSTATUS,
"null");
sucess1 = db.update(MasterMetaData.ResturantSeat.TABLE_NAME, cv1, MasterMetaData.ResturantSeat.SEAT_ID + " = " + seat_id, null);
} catch (Exception e) {
e.printStackTrace();
}
if (sucess1 == -1)
row = -1;
}
} while (c.moveToNext());
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public long updateCancelConfirmStatusTakewy(int orderno) {
long row = -1;
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues cv = new ContentValues();
cv.put(MasterMetaData.ResturantOrders.ORDERSTATUS,
1);
row = db.update(MasterMetaData.ResturantOrders.TABLE_NAME, cv, MasterMetaData.ResturantOrders.ORDERNO + " = " + orderno, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return row;
}
public ArrayList<Integer> getOrderNoBasedOnseat_id(int seat_id, int table_id) {
ArrayList<Integer> order_details = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
//withourt Cancel order /* String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where "+ MasterMetaData.ResturantOrders.TABLENUMBER + " = "+table_id+ " and "+ MasterMetaData.ResturantOrders.SEATID + " = "+seat_id + " and " + MasterMetaData.ResturantOrders.PENDINGSTATUS + " = 0";
*/ // Query Used in Cancel Order String selectteacherdata = " Select * from restaurant_orders ro where " + MasterMetaData.ResturantOrders.TABLENUMBER + " = '" + table_id + "'" + " AND " + MasterMetaData.ResturantOrders.SEATID + " = '" + seat_id + "'" + " And (ro.order_status = 1 OR ro.order_status = 0)";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
order_details = new ArrayList<>();
do {
order_details.add(c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERNO)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return order_details;
}
public ArrayList<Integer> getOrderIDBasedOnseat_id(int seat_id, int table_id) {
ArrayList<Integer> order_details = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
// With out Cancel /* String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where "+ MasterMetaData.ResturantOrders.TABLENUMBER + " = "+table_id+ " and "+ MasterMetaData.ResturantOrders.SEATID + " = "+seat_id + " and " + MasterMetaData.ResturantOrders.PENDINGSTATUS + " = 0";
*/ // Query Used In Cancel order String selectteacherdata = " Select * from restaurant_orders ro where " + MasterMetaData.ResturantOrders.TABLENUMBER + " = '" + table_id + "'" + " AND " + MasterMetaData.ResturantOrders.SEATID + " = '" + seat_id + "'" + " And (ro.order_status = 1 OR ro.order_status = 0)";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
order_details = new ArrayList<>();
do {
order_details.add(c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ID)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return order_details;
}
public OrderDeatlsClass getOrderDeatilsBasedOnIdForMenuScreen(int id) {
OrderDeatlsClass object = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ID + " = " + id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
object = new OrderDeatlsClass();
do {
object.setQuantity(Integer.parseInt(c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.ITEM_QUANTITY))));
object.setMenu_price_id(c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENUPRICEID)));
object.setMenu_id(c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_ID)));
object.setMenu_name(c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_NAME)));
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_PRICE_ID + " = " + c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENUPRICEID));
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
do {
object.setMenu_price(c1.getDouble(c1.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE)));
object.setQuantity_name(c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)));
} while (c1.moveToNext());
}
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return object;
}
public Double getTotalAmount(int order_no) {
Double totalAmount = 0.00;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ORDERNO + " = " + order_no;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
totalAmount += c.getDouble(c.getColumnIndex(MasterMetaData.ResturantOrders.PRICE));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return totalAmount;
}
public JSONObject getOrderDeatilsBasedOnId(int id) {
JSONObject object = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantOrders.TABLE_NAME + " Where " + MasterMetaData.ResturantOrders.ID + " = " + id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
object = new JSONObject();
do {
String menu_name = "";
object.put("order_no", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERNO)));
menu_name = c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_NAME));
object.put("price", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.PRICE)));
object.put("item_quantity", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.ITEM_QUANTITY)));
object.put("served_status", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SERVERDSTATUS)));
// String data1 = " SELECT * from "// + MasterMetaData.MenuPrice.TABLE_NAME + " Where "+MasterMetaData.MenuPrice.MENU_ID + " = "+c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_ID));// Cursor c2 = db.rawQuery(data1, null);// int value = 0;// if (c2.moveToFirst()) {// if(c2.getCount() > 0)// {// value = c2.getCount();// }// }// if(value > 1) {// String data = " SELECT * from "// + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_ID)) + " and " + MasterMetaData.MenuPrice.MENU_PRICE_ID + " = " + c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENUPRICEID));// Cursor c1 = db.rawQuery(data, null);// if (c1.moveToFirst()) {// do {// menu_name += " (" + c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)) + ")";// } while (c1.moveToNext());// }// }
String data = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_ID)) + " and " + MasterMetaData.MenuPrice.MENU_PRICE_ID + " = " + c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.MENUPRICEID));
Cursor c1 = db.rawQuery(data, null);
if (c1.moveToFirst()) {
do {
menu_name += " (" + c1.getString(c1.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)) + ")";
} while (c1.moveToNext());
}
object.put("menu_name", menu_name);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return object;
}
public String getRestaurantImage() {
String status = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.Restaurant.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
status = c.getString(c.getColumnIndex(MasterMetaData.Restaurant.LOGO));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public String getRestaurantDeatils() {
String status = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.Restaurant.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
status = c.getString(c.getColumnIndex(MasterMetaData.Restaurant.NAME));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public String getCurrencyDeatils() {
String status = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantCurrency.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
status = c.getString(c.getColumnIndex(MasterMetaData.ResturantCurrency.DISPLAYNAME));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public String getSeatStstusBasedOnSeatId(int seat_id) {
String status = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantSeat.TABLE_NAME + " Where " + MasterMetaData.ResturantSeat.SEAT_ID + " = " + seat_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
status = c.getString(c.getColumnIndex(MasterMetaData.ResturantSeat.SEATSTATUS));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return status;
}
public Integer getOrderCount() {
int count = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = "Select COUNT (*) from " + MasterMetaData.ResturantPayment.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c != null) {
if (c.getCount() > 0) {
if (c.moveToFirst()) {
do {
count = c.getInt(0);
} while (c.moveToNext());
}
}
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return count;
}
public Integer getRevenueCount() {
int count = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = "Select SUM (total_amount) from " + MasterMetaData.ResturantPayment.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c != null) {
if (c.getCount() > 0) {
if (c.moveToFirst()) {
do {
count = c.getInt(0);
} while (c.moveToNext());
}
}
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return count;
}
public Integer getRevCountTodayFromPayment(String date) {
int count = 0;
SQLiteDatabase db = null;
try {
db = openDatabase();
//String selectteacherdata = "Select SUM (total_amount) from " + MasterMetaData.ResturantPayment.TABLE_NAME; String selectteacherdata = " Select SUM (total_amount) " + "From payments where date(" + MasterMetaData.ResturantPayment.PAYMENYDATE + ") = '" + date + "'" + "";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c != null) {
if (c.getCount() > 0) {
if (c.moveToFirst()) {
do {
count = c.getInt(0);
} while (c.moveToNext());
}
}
}
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return count;
}
public ArrayList<String> getOrderHistorydates() {
ArrayList<String> dates = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT " + MasterMetaData.ResturantPayment.PAYMENYDATE + " from " + MasterMetaData.ResturantPayment.TABLE_NAME + " Where " + MasterMetaData.ResturantPayment.PAYMENTSTATUS + " = " + 1 + " group by " + MasterMetaData.ResturantPayment.PAYMENYDATE + " order by " + MasterMetaData.ResturantPayment.ID + " desc";
// String selectteacherdata = "Select p.payment_date From payments p join restaurant_orders ro ON p.order_no = ro.order_no where p.payment_status = 1 AND ro.confirm_delivery = 1 group by p.payment_date order by p.payment_date DESC";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
dates = new ArrayList<>();
do {
if (!dates.contains(c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENYDATE)))) {
dates.add(c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENYDATE)));
}
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return dates;
}
public JSONArray getFoodType() {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.FoodType.TABLE_NAME;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("foodtype_id", c.getInt(c.getColumnIndex(MasterMetaData.FoodType.ID)));
object.put("name", c.getString(c.getColumnIndex(MasterMetaData.FoodType.NAME)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
/* public JSONArray getOrderDetailsFromPayment(String date) { JSONArray jsonArray = null; SQLiteDatabase db = null; try { db = openDatabase();*//* String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantPayment.TABLE_NAME + " Where "+MasterMetaData.ResturantPayment.PAYMENYDATE + " = '"+date+"'"+ " order by "+ MasterMetaData.ResturantPayment.ID+ " desc" ;*//*
//TODO by added or condition for showing that in order history //String selectteacherdata = " Select * From payments p join restaurant_orders ro ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND (ro.confirm_delivery = 1 OR ro.order_status=2 OR ro.order_status=3) group by p.order_no order by p.id desc";
// String selectteacherdata = " Select * From payments p join restaurant_orders ro ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND (ro.order_status=2 OR ro.order_status=3 OR ro.order_status=9) group by p.order_no order by p.id desc"; *//********************************************************************//* String selectteacherdata = " Select * from restaurant_orders ro left join payments p ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND (ro.order_status=2 OR ro.order_status=3 OR ro.order_status=9) group by ro.order_no order by ro.id desc";
*/
/******************************************************************//*
// String selectteacherdata = " Select * From payments p join restaurant_orders ro ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND ro.order_status = 1 group by p.order_no order by p.id desc";
// String selectteacherdata = " Select * from restaurant_orders ro left join payments p ON p.order_no = ro.order_no where date(ro.order_date) = '2020-04-30' AND (ro.order_status=2 OR ro.order_status=3 OR ro.order_status=9) group by ro.order_no order by ro.id desc";
Cursor c = db.rawQuery(selectteacherdata, null); if (c.moveToFirst()) { jsonArray = new JSONArray(); do { JSONObject object = new JSONObject(); object.put("order_no",c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.order_no))); object.put("table_number",c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.TABLENUMBER))); object.put("time",c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.payment_time))); // object.put("customedeatils","9985536424, Subhankar..."); object.put("name",c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.NAME))); object.put( "user_phone",c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.USERPHONE))); object.put("amount",c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.TOTALAMOUNT))); object.put("order_status",c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERSTATUS))); jsonArray.put(object); } while (c.moveToNext()); closeDatabase(db); } } catch (Exception e) { e.printStackTrace(); } finally { if (db != null && db.isOpen()) closeDatabase(db); } return jsonArray; }
*/ public JSONArray getOrderDetailsFromPayment(String date) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
/* String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantPayment.TABLE_NAME + " Where "+MasterMetaData.ResturantPayment.PAYMENYDATE + " = '"+date+"'"+ " order by "+ MasterMetaData.ResturantPayment.ID+ " desc" ;*/
//TODO by basudev added or condition for showing that in order history String selectteacherdata = " Select ro.order_no,ro.table_number,p.payment_time,ro.name,ro.user_phone,p.total_amount,ro.order_status " +
"From restaurant_orders ro left join payments p ON p.order_no = ro.order_no where date(ro." + MasterMetaData.ResturantOrders.ORDER_DATE + ") = '" + date + "'" + " AND (ro.order_status=2 OR ro.order_status=3 OR ro.order_status=9) group by ro.order_no order by ro.id desc";
// String selectteacherdata = " Select * From payments p join restaurant_orders ro ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND (ro.confirm_delivery = 1 OR ro.order_status=2 OR ro.order_status=3) group by p.order_no order by p.id desc";
// String selectteacherdata = " Select * From payments p join restaurant_orders ro ON p.order_no = ro.order_no where "+MasterMetaData.ResturantPayment.PAYMENYDATE +" = '"+date+"'"+" AND ro.order_status = 1 group by p.order_no order by p.id desc";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("order_no", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERNO)));
object.put("table_number", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.TABLENUMBER)));
object.put("time", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.payment_time)));
// object.put("customedeatils","9985536424, Subhankar..."); object.put("name", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.NAME)));
object.put("user_phone", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.USERPHONE)));
object.put("amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.TOTALAMOUNT)));
object.put("order_status", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERSTATUS)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
/* public Integer getRevCountTodayFromPayment(String date) { JSONArray jsonArray = null; SQLiteDatabase db = null; try { db = openDatabase();
String selectteacherdata = " Select SUM (total_amount) " + "From payments where date(" + MasterMetaData.ResturantPayment.PAYMENYDATE + ") = '" + date + "'" + "";
Cursor c = db.rawQuery(selectteacherdata, null); if (c.moveToFirst()) { jsonArray = new JSONArray(); do { JSONObject object = new JSONObject(); object.put("payment_date", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENYDATE))); jsonArray.put(object); } while (c.moveToNext()); closeDatabase(db); } } catch (Exception e) { e.printStackTrace(); } finally { if (db != null && db.isOpen()) closeDatabase(db); } return co; }*/
public JSONArray getTakewayOrder() {
JSONArray jsonArray = new JSONArray();
SQLiteDatabase db = null;
try {
db = openDatabase();
// String selectdata = "Select "+MasterMetaData.ResturantPayment.order_no +MasterMetaData.ResturantPayment.TOTALAMOUNT+" From "+MasterMetaData.ResturantPayment.TABLE_NAME+"ro JOIN" +MasterMetaData.ResturantOrders.TABLE_NAME + ON +MasterMetaData.ResturantPayment.order_no+" where "+MasterMetaData.ResturantOrders.TABLENUMBER+" = '0' AND "+MasterMetaData.ResturantOrders.SEATID+" = 0 AND "+MasterMetaData.ResturantOrders.TAKEAWAY+" = 1 order by "+MasterMetaData.ResturantPayment.RESTAURANT_ID; // String selectdata = "Select p.order_no,p.total_amount,p.restaurant_id,p.user_id,ro.menu_item_name,ro.item_quantity,ro.take_away,ro.order_date,p.payment_date,p.payment_time From payments p join restaurant_orders ro ON p.order_no = ro.order_no where ro.table_number = '0' AND ro.seat_id = 0 AND ro.take_away = 1 order by p.id";
//String selectdata = "Select p.order_no,p.total_amount,p.restaurant_id,p.user_id,ro.menu_item_name,ro.item_quantity,ro.take_away,ro.order_date,p.payment_date,p.payment_time,ro.name,ro.user_phone From payments p join restaurant_orders ro ON p.order_no = ro.order_no where ro.table_number = '0' AND ro.seat_id = 0 AND ro.take_away = 1 AND ro.confirm_delivery = 0 AND ro.order_status != 2 order by p.id";
String selectdata = "Select p.order_no,p.total_amount,p.restaurant_id,p.user_id,ro.menu_item_name,ro.item_quantity,ro.take_away,ro.order_date,p.payment_date,p.payment_time,ro.name,ro.user_phone,ro.served_status,ro.order_status,p.payment_type " +
"From payments p join restaurant_orders ro ON p.order_no = ro.order_no where ro.table_number = '0' AND ro.seat_id = 0 AND ro.take_away = 1 AND ro.confirm_delivery = 0 AND ro.order_status != 2 AND ro.order_status != 3 group by p.order_no order by p.id";
Cursor c = db.rawQuery(selectdata, null);
if (c.moveToLast()) {
// jsonArray = new JSONArray(); do {
JSONObject object = new JSONObject();
object.put("order_no", c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.order_no)));
object.put("total_amount", c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.TOTALAMOUNT)));
object.put("user_id", c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.user_id)));
object.put("restaurant_id", c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.RESTAURANT_ID)));
//Todo by basudev... get item ordered JSONArray orderItems = getOrderDeatilsForOrderNo(object.getInt("order_no"));
object.put("orderItems", orderItems);
object.put("menu_item_name", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.MENU_ITEM_NAME)));
object.put("item_quantity", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ITEM_QUANTITY)));
object.put("take_away", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.TAKEAWAY)));
object.put("order_date", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDER_DATE)));
object.put("payment_date", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENYDATE)));
object.put("payment_time", c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.payment_time)));
// object.put("name", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.NAME)));
object.put("user_phone", c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.USERPHONE)));
object.put("served_status", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SERVERDSTATUS)));
//todo by basudev to identify the order status object.put("order_status", c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.ORDERSTATUS)));
object.put("payment_type", c.getInt(c.getColumnIndex(MasterMetaData.ResturantPayment.PAYMENTTYPE)));
// object.put("message",c.getString(c.getColumnIndex(MasterMetaData.ResturantOrders.MESSAGE)));
// // object.put("pending_status",c.getInt(c.getColumnIndex(MasterMetaData.ResturantOrders.SERVERDSTATUS)));
// object.put("order_type","Dine-in"); //object.put("time",c.getString(c.getColumnIndex(MasterMetaData.ResturantPayment.payment_time))); // object.put("customedeatils","9985536424, Subhankar..."); // object.put("amount",c.getDouble(c.getColumnIndex(MasterMetaData.ResturantPayment.TOTALAMOUNT))); jsonArray.put(object);
} while (c.moveToPrevious());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public String getCaterogryNameByOnMenu_id(int menu_id) {
String caterogry_name = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT m.name From " + MasterMetaData.MenuCategories.TABLE_NAME + " m JOIN restaurant_menu rm ON m.category_id = rm.category_id" + " Where " + MasterMetaData.ResturantMenu.MENU_ID + " = " + menu_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
caterogry_name = c.getString(c.getColumnIndex("name"));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return caterogry_name;
}
public String getMenuNameByOnMenu_idandMenu_price_id(int menu_id, int menu_price_id) {
String caterogry_name = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * From " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_PRICE_ID + " = " + menu_price_id + " and " + MasterMetaData.MenuPrice.MENU_ID + " = " + menu_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
caterogry_name = c.getString(c.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return caterogry_name;
}
public JSONArray getItemReportsBasedOnDate(String from, String to, ArrayList<Integer> caterogry_id) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " as menu_id ," + MasterMetaData.ResturantOrders.MENUPRICEID + " as menu_price_id ," + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " as menu_name , SUM(ro." + MasterMetaData.ResturantOrders.PRICE + ") as price , " + " count(ro." + MasterMetaData.ResturantOrders.ITEM_QUANTITY + ") as item_quantity " + " from " + MasterMetaData.ResturantOrders.TABLE_NAME + " ro JOIN " + MasterMetaData.ResturantPayment.TABLE_NAME + " p ON ro." + MasterMetaData.ResturantOrders.ORDERNO + " = p." + MasterMetaData.ResturantPayment.order_no + " Where " + MasterMetaData.ResturantPayment.PAYMENYDATE + " >= '" + from + "' and " + MasterMetaData.ResturantPayment.PAYMENYDATE + " <= '" + to + "' group by " + MasterMetaData.ResturantOrders.MENUPRICEID + " order by " + MasterMetaData.ResturantOrders.ITEM_QUANTITY + " desc";
if (caterogry_id != null) {
if (caterogry_id.size() > 0) {
String menu_ids = "";
for (int count = 0; count < caterogry_id.size(); count++) {
if (count == 0)
menu_ids = "" + caterogry_id.get(count);
else menu_ids += "," + caterogry_id.get(count);
}
selectteacherdata = " SELECT " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " as menu_id ," + MasterMetaData.ResturantOrders.MENUPRICEID + " as menu_price_id ," + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " as menu_name , SUM(ro." + MasterMetaData.ResturantOrders.PRICE + ") as price , " + " SUM(ro." + MasterMetaData.ResturantOrders.ITEM_QUANTITY + ") as item_quantity " + " from " + MasterMetaData.ResturantOrders.TABLE_NAME + " ro JOIN " + MasterMetaData.ResturantPayment.TABLE_NAME + " p ON ro." + MasterMetaData.ResturantOrders.ORDERNO + " = p." + MasterMetaData.ResturantPayment.order_no + " Where " + MasterMetaData.ResturantPayment.PAYMENYDATE + " >= '" + from + "' and " + MasterMetaData.ResturantPayment.PAYMENYDATE + " <= '" + to + "' and " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " IN ( " + menu_ids + " )" + " group by " + MasterMetaData.ResturantOrders.MENUPRICEID + " order by item_quantity desc";
}
}
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("menu_id", c.getInt(c.getColumnIndex("menu_id")));
object.put("menu_price_id", c.getInt(c.getColumnIndex("menu_price_id")));
object.put("menu_name", c.getString(c.getColumnIndex("menu_name")));
object.put("price", c.getDouble(c.getColumnIndex("price")));
object.put("Quantities", c.getInt(c.getColumnIndex("item_quantity")));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getItemReportsBasedOnMenuName(String menu_name) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " as menu_id ," + MasterMetaData.ResturantOrders.MENUPRICEID + " as menu_price_id ," + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " as menu_name , SUM(ro." + MasterMetaData.ResturantOrders.PRICE + ") as price , " + " SUM(ro." + MasterMetaData.ResturantOrders.ITEM_QUANTITY + ") as item_quantity " + " from " + MasterMetaData.ResturantOrders.TABLE_NAME + " ro JOIN " + MasterMetaData.ResturantPayment.TABLE_NAME + " p ON ro." + MasterMetaData.ResturantOrders.ORDERNO + " = p." + MasterMetaData.ResturantPayment.order_no + " Where " + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " LIKE '%" + menu_name + "%'" + " group by " + MasterMetaData.ResturantOrders.MENUPRICEID + " order by " + MasterMetaData.ResturantOrders.ITEM_QUANTITY + " desc";
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("menu_id", c.getInt(c.getColumnIndex("menu_id")));
object.put("menu_price_id", c.getInt(c.getColumnIndex("menu_price_id")));
object.put("menu_name", c.getString(c.getColumnIndex("menu_name")));
object.put("price", c.getDouble(c.getColumnIndex("price")));
object.put("Quantities", c.getInt(c.getColumnIndex("item_quantity")));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getItemReports(boolean menu_idexists, ArrayList<Integer> arrayList) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " as menu_id ," + MasterMetaData.ResturantOrders.MENUPRICEID + " as menu_price_id ," + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " as menu_name , SUM(ro." + MasterMetaData.ResturantOrders.PRICE + ") as price , " + " SUM(ro." + MasterMetaData.ResturantOrders.ITEM_QUANTITY + ") as item_quantity " + " from " + MasterMetaData.ResturantOrders.TABLE_NAME + " ro JOIN " + MasterMetaData.ResturantPayment.TABLE_NAME + " p ON ro." + MasterMetaData.ResturantOrders.ORDERNO + " = p." + MasterMetaData.ResturantPayment.order_no + " group by " + MasterMetaData.ResturantOrders.MENUPRICEID + " order by " + MasterMetaData.ResturantOrders.ITEM_QUANTITY + " desc";
if (menu_idexists) {
if (arrayList != null) {
if (arrayList.size() > 0) {
String menu_ids = "";
for (int count = 0; count < arrayList.size(); count++) {
if (count == 0)
menu_ids = "" + arrayList.get(count);
else menu_ids += "," + arrayList.get(count);
}
selectteacherdata = " SELECT " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " as menu_id ," + MasterMetaData.ResturantOrders.MENUPRICEID + " as menu_price_id ," + MasterMetaData.ResturantOrders.MENU_ITEM_NAME + " as menu_name , SUM(ro." + MasterMetaData.ResturantOrders.PRICE + ") as price , " + " SUM(ro." + MasterMetaData.ResturantOrders.ITEM_QUANTITY + ") as item_quantity " + " from " + MasterMetaData.ResturantOrders.TABLE_NAME + " ro JOIN " + MasterMetaData.ResturantPayment.TABLE_NAME + " p ON ro." + MasterMetaData.ResturantOrders.ORDERNO + " = p." + MasterMetaData.ResturantPayment.order_no + " Where " + MasterMetaData.ResturantOrders.MENU_ITEM_ID + " IN ( " + menu_ids + " )" + " group by " + MasterMetaData.ResturantOrders.MENUPRICEID + " order by item_quantity desc";
}
}
}
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("menu_id", c.getInt(c.getColumnIndex("menu_id")));
object.put("menu_price_id", c.getInt(c.getColumnIndex("menu_price_id")));
object.put("menu_name", c.getString(c.getColumnIndex("menu_name")));
object.put("price", c.getDouble(c.getColumnIndex("price")));
object.put("Quantities", c.getInt(c.getColumnIndex("item_quantity")));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public ArrayList<Integer> getMenuIDsDependOnCaterogryID(int caterogry_id) {
ArrayList<Integer> jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * From " + MasterMetaData.ResturantMenu.TABLE_NAME + " Where " + MasterMetaData.ResturantMenu.CATEGORY_ID + " = " + caterogry_id;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new ArrayList<Integer>();
do {
jsonArray.add(c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.MENU_ID)));
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public JSONArray getMessagesmentdeatils(int orderNo) {
JSONArray jsonArray = null;
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.messages.TABLE_NAME + " Where " + MasterMetaData.messages.order_no + " = " + orderNo;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
jsonArray = new JSONArray();
do {
JSONObject object = new JSONObject();
object.put("type", c.getInt(c.getColumnIndex(MasterMetaData.messages.type)));
object.put("message", c.getString(c.getColumnIndex(MasterMetaData.messages.message)));
jsonArray.put(object);
} while (c.moveToNext());
closeDatabase(db);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return jsonArray;
}
public void deleteAllTable() {
SQLiteDatabase db = null;
try {
db = openDatabase();
db.delete(MasterMetaData.UserTable.TABLE_NAME, null, null);
db.delete(MasterMetaData.Restaurant.TABLE_NAME, null, null);
db.delete(MasterMetaData.MenuCategories.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantMenu.TABLE_NAME, null, null);
db.delete(MasterMetaData.MenuPrice.TABLE_NAME, null, null);
db.delete(MasterMetaData.MenuImage.TABLE_NAME, null, null);
db.delete(MasterMetaData.MenuTag.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantTable.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantSeat.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantOrders.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantCurrency.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantTax.TABLE_NAME, null, null);
db.delete(MasterMetaData.ResturantPayment.TABLE_NAME, null, null);
db.delete(MasterMetaData.DeletedOrders.TABLE_NAME, null, null);
db.delete(MasterMetaData.MenuFoodTypes.TABLE_NAME, null, null);
db.delete(MasterMetaData.FoodType.TABLE_NAME, null, null);
db.delete(MasterMetaData.messages.TABLE_NAME, null, null);
closeDatabase(db);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
}
//TODO please write all DB methods returning data classs below this only
public ArrayList<MenuInventaryItemDetails> getMenuDetails(int restaurantID) {
ArrayList<MenuInventaryItemDetails> menuDetails = new ArrayList<>();
SQLiteDatabase db = null;
int lastCategoryId = -1;
String lastCategoryName = "";
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.ResturantMenu.TABLE_NAME + " Where " + MasterMetaData.ResturantMenu.RESTAURANT_ID + " = " + restaurantID
+ " Order by " + MasterMetaData.ResturantMenu.CATEGORY_ID;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
boolean isCategoryChanging = false;
MenuInventaryItemDetails mItemDetails = new MenuInventaryItemDetails();
mItemDetails.setCategoryId(c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.CATEGORY_ID)));
mItemDetails.setKitchenId(c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.KITCHEN_ID)));
mItemDetails.setMenuId(c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.MENU_ID)));
mItemDetails.setMenuName(c.getString(c.getColumnIndex(MasterMetaData.ResturantMenu.NAME)));
mItemDetails.setMenuTRating(c.getInt(c.getColumnIndex(MasterMetaData.ResturantMenu.RATING)));
if (lastCategoryId == -1 || mItemDetails.getCategoryId() != lastCategoryId) {
lastCategoryId = mItemDetails.getCategoryId();
lastCategoryName = getCategoryNameByID(mItemDetails.getCategoryId());
isCategoryChanging = true;
}
if (isCategoryChanging) {
//Comment this if we dont want category as one of list item //Add a item with menu id -1 for new category MenuInventaryItemDetails mItemCategory = new MenuInventaryItemDetails();
mItemCategory.setMenuId(-1);
mItemCategory.setMenuCategoryName(lastCategoryName);
menuDetails.add(mItemCategory);
}
mItemDetails.setMenuCategoryName(lastCategoryName);
mItemDetails.setMenuPriceDetails(getMenuPriceDetails(mItemDetails.getMenuId()));
menuDetails.add(mItemDetails);
} while (c.moveToNext());
// closeDatabase(db); }
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return menuDetails;
}
public ArrayList<MenuPriceDetails> getMenuPriceDetails(int menuId) {
ArrayList<MenuPriceDetails> menuDetails = new ArrayList<>();
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.MenuPrice.TABLE_NAME + " Where " + MasterMetaData.MenuPrice.MENU_ID + " = " + menuId;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
MenuPriceDetails mItemDetails = new MenuPriceDetails();
mItemDetails.setMenuId(c.getInt(c.getColumnIndex(MasterMetaData.MenuPrice.MENU_ID)));
mItemDetails.setMenuPrice(c.getInt(c.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE)));
mItemDetails.setMenuPriceId(c.getInt(c.getColumnIndex(MasterMetaData.MenuPrice.MENU_PRICE_ID)));
mItemDetails.setQuantityName(c.getString(c.getColumnIndex(MasterMetaData.MenuPrice.QUANTITYNAME)));
boolean isAvailable = true;
if (c.getInt(c.getColumnIndex(MasterMetaData.MenuPrice.AVAILABILITY)) == 0) {
isAvailable = false;
}
mItemDetails.setAvailable(isAvailable);
menuDetails.add(mItemDetails);
} while (c.moveToNext());
// closeDatabase(db); }
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return menuDetails;
}
public String getCategoryNameByID(int categoryID) {
String categoryName = "";
SQLiteDatabase db = null;
try {
db = openDatabase();
String selectteacherdata = " SELECT * from " + MasterMetaData.MenuCategories.TABLE_NAME + " Where " + MasterMetaData.MenuCategories.CATEGORY_ID + " = " + categoryID;
Cursor c = db.rawQuery(selectteacherdata, null);
if (c.moveToFirst()) {
do {
categoryName = c.getString(c.getColumnIndex(MasterMetaData.MenuCategories.NAME));
} while (c.moveToNext());
// closeDatabase(db); }
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
return categoryName;
}
public void updateMenuAvailability(int menuPriceID, int availability) {
SQLiteDatabase db = null;
try {
db = openDatabase();
ContentValues args = new ContentValues();
args.put(MasterMetaData.MenuPrice.AVAILABILITY, availability);
int c = db.update(MasterMetaData.MenuPrice.TABLE_NAME, args, MasterMetaData.MenuPrice.MENU_PRICE_ID + "=" + menuPriceID, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (db != null && db.isOpen())
closeDatabase(db);
}
}
}
}
MasterMetaData.java
package com.dfoe.frimaster.DataBaseServices;
import android.provider.BaseColumns;
public class MasterMetaData {
private MasterMetaData() {
}
public class UserTable implements BaseColumns {
private UserTable() {
}
public static final int TABLE_ID = 1;
public static final String TABLE_NAME = "user";
public static final String USER_ID = "user_id";
public static final String USER_TYPE_ID = "user_type_id";
public static final String NAME = "name";
public static final String USERNAME = "user_name";
public static final String USERPASSWORD = "user_password";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String CREATEDAT = "created_at";
public static final String MODIFIEDAT = "modified_at";
}
public class Restaurant implements BaseColumns {
private Restaurant() {
}
public static final int TABLE_ID = 2;
public static final String TABLE_NAME = "restaurant";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String COMPANY_ID = "company_id";
public static final String MERCAHNT_ID = "merchant_id";
public static final String NAME = "name";
public static final String ADDRESS = "address";
public static final String CONTACTNAME = "contact_name";
public static final String CONTACTEMAIL = "contact_email";
public static final String PASSWORD = "admin_password";
public static final String PHONE = "phone";
public static final String LOGO = "logo";
public static final String URL = "url";
public static final String LATITUDE = "latitude";
public static final String LONGITUDE = "longitude";
public static final String CURRENCY_ID = "currency_id";
public static final String STATUS = "status";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String TIN = "tin";
public static final String AUTH_TOKEN = "auth_token";
public static final String MODIFIEDBY = "modified_by";
}
public class MenuCategories implements BaseColumns {
private MenuCategories() {
}
public static final int TABLE_ID = 3;
public static final String TABLE_NAME = "menu_categories";
public static final String CATEGORY_ID = "category_id";
public static final String NAME = "name";
public static final String DISPLAYNAME = "display_name";
public static final String DESCRIPTION = "description";
public static final String IMAGE = "image";
public static final String CATEGORYTYPE = "category_type";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String ORDERNO = "order_number";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String MODIFIEDBY = "modified_by";
}
public class ResturantMenu implements BaseColumns {
private ResturantMenu() {
}
public static final int TABLE_ID = 4;
public static final String TABLE_NAME = "restaurant_menu";
public static final String MENU_ID = "menu_id";
public static final String NAME = "name";
public static final String DESCRIPTION = "description";
public static final String IMAGE = "image";
public static final String INGREDIENTS = "ingredients";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String COMPANY_ID = "company_id";
public static final String MERCAHNT_ID = "merchant_id";
public static final String ORDERNO = "order_number";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String MODIFIEDBY = "modified_by";
public static final String PREPTIME = "prep_time";
public static final String PRICE = "price";
public static final String CURRENCY_ID = "def_currency_id";
public static final String VIDEOLINK = "video_link";
public static final String RATING = "rating";
public static final String LASTCHANED = "last_changed";
public static final String STATUS = "status";
public static final String KITCHEN_ID = "kitchen_id";
public static final String CATEGORY_ID = "category_id";
public static final String MENUTYPE = "menu_type";
}
public class MenuPrice implements BaseColumns {
private MenuPrice() {
}
public static final int TABLE_ID = 5;
public static final String TABLE_NAME = "menu_price";
public static final String MENU_PRICE_ID = "menu_price_id";
public static final String MENU_ID = "menu_id";
public static final String QUANTITYNAME = "quantity_name";
public static final String MENU_PRICE = "menu_price";
public static final String AVAILABILITY = "availability";
}
public class MenuImage implements BaseColumns {
private MenuImage() {
}
public static final int TABLE_ID = 6;
public static final String TABLE_NAME = "menu_image";
public static final String MENU_IMAGE_ID = "menu_image_id";
public static final String MENU_IMAGE_NAME = "menu_image_name";
public static final String MENU_ID = "menu_id";
}
public class MenuTag implements BaseColumns {
private MenuTag() {
}
public static final int TABLE_ID = 7;
public static final String TABLE_NAME = "menu_tags";
public static final String MENU_TAG_ID = "tag_id";
public static final String MENU_TAG_NAME = "tag_name";
public static final String MENU_ID = "menu_id";
}
public class ResturantTable implements BaseColumns {
private ResturantTable() {
}
public static final int TABLE_ID = 8;
public static final String TABLE_NAME = "restaurant_table";
public static final String ID = "table_id";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String COMPANY_ID = "company_id";
public static final String MERCAHNT_ID = "merchant_id";
public static final String TABLENAME = "table_name";
public static final String TABLENO = "table_number";
public static final String IPADDRESS = "ip_address";
public static final String DEVICEID = "device_id";
public static final String NUMBEROFSEATS = "number_of_seats";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String MODIFIEDBY = "modified_by";
public static final String STATUS = "status";
}
public class ResturantSeat implements BaseColumns {
private ResturantSeat() {
}
public static final int TABLE_ID = 9;
public static final String TABLE_NAME = "seat_details";
public static final String SEAT_ID = "seat_id";
public static final String RES_TABLE_ID = "table_id";
public static final String SEATNAME = "seat_name";
public static final String CREATEDAT = "created_at";
public static final String SEATSTATUS = "seat_status";
}
public class ResturantOrders implements BaseColumns {
private ResturantOrders() {
}
public static final int TABLE_ID = 10;
public static final String TABLE_NAME = "restaurant_orders";
public static final String ID= "id";
public static final String ORDER_ID = "order_id";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String COMPANY_ID = "company_id";
public static final String MERCAHNT_ID = "merchant_id";
public static final String MENU_ITEM_ID = "menu_item_id";
public static final String MENU_ITEM_NAME = "menu_item_name";
public static final String TABLENUMBER = "table_number";
public static final String BATCHNUMBER = "batch_number";
public static final String BATCHSTATUS = "batch_status";
public static final String ORDER_DATE = "order_date";
public static final String PRICE = "price";
public static final String ITEM_QUANTITY = "item_quantity";
public static final String SERVERDSTATUS = "served_status";
public static final String PENDINGSTATUS = "pending_status";
public static final String DEFCURRENCYID = "def_currency_id";
public static final String USERID = "user_id";
public static final String BILLNUMBER = "bill_number";
public static final String ORDERNO = "order_no";
public static final String ORDERITEMNO = "order_item_no";
public static final String SEATID = "seat_id";
public static final String MENUPRICEID = "menu_price_id";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String TAKEAWAY = "take_away";
public static final String MODIFIEDBY = "modified_by";
public static final String NAME = "name";
public static final String COUNTRYCODE = "country_code";
public static final String USERPHONE = "user_phone";
public static final String USEREMAIL = "user_email";
public static final String CONFIRMDELIVERY = "confirm_delivery";
public static final String ORDERSTATUS = "order_status";
}
public class ResturantCurrency implements BaseColumns {
private ResturantCurrency() {
}
public static final int TABLE_ID = 11;
public static final String TABLE_NAME = "currency_detail";
public static final String CURRENCY_ID = "currency_id";
public static final String NAME = "name";
public static final String DISPLAYNAME = "display_name";
public static final String DESCRIPTION = "description";
}
public class ResturantTax implements BaseColumns {
private ResturantTax() {
}
public static final int TABLE_ID = 12;
public static final String TABLE_NAME = "tax_detail";
public static final String TAX_ID = "tax_id";
public static final String NAME = "name";
public static final String DISPLAYNAME = "display_name";
public static final String DESCRIPTION = "description";
public static final String TAX = "tax";
}
public class ResturantPayment implements BaseColumns {
private ResturantPayment() {
}
public static final int TABLE_ID = 13;
public static final String TABLE_NAME = "payments";
public static final String ID = "id";
public static final String RESTAURANT_ID = "restaurant_id";
public static final String COMPANY_ID = "company_id";
public static final String MERCAHNT_ID = "merchant_id";
public static final String TABLENUMBER = "table_number";
public static final String BATCHNUMBER = "batch_number";
public static final String BATCHSTATUS = "batch_status";
public static final String PAYMENYDATE = "payment_date";
public static final String AMOUNT = "amount";
public static final String DISCOUNTAMOUNT = "discount_amount";
public static final String TOTALAMOUNT = "total_amount";
public static final String DISCOUNTREASON = "discount_reason";
public static final String COUPONCODE = "coupon_code";
public static final String TRANSACTIONID = "transaction_id";
public static final String APPROVALCODE = "approval_code";
public static final String APPROVALMESSAGE = "approval_message";
public static final String PAYMENTSTATUS = "payment_status";
public static final String PAYMENTTYPE = "payment_type";
public static final String def_currency_id = "def_currency_id";
public static final String additional_info1 = "additional_info1";
public static final String additional_info2 = "additional_info2";
public static final String CREATEDAT = "created_date";
public static final String MODIFIEDAT = "modified_date";
public static final String MODIFIEDBY = "modified_by";
public static final String bill_number = "bill_number";
public static final String tax_details = "tax_details";
public static final String tips = "tips";
public static final String tx_status = "tx_status";
public static final String tx_id = "tx_id";
public static final String pg_resp_code = "pg_resp_code";
public static final String tx_msg = "tx_msg";
public static final String paid_amount = "paid_amount";
public static final String auth_id_code = "auth_id_code";
public static final String payment_mode = "payment_mode";
public static final String pg_mobile_no = "pg_mobile_no";
public static final String txn_date_time = "txn_date_time";
public static final String transaction_reference = "transaction_reference";
public static final String pgCurrency = "pgCurrency";
public static final String user_id = "user_id";
public static final String number_of_people = "number_of_people";
public static final String order_no = "order_no";
public static final String TAKEAWAY = "take_away";
public static final String payment_time = "payment_time";
public static final String NAME = "name";
public static final String COUNTRYCODE = "country_code";
public static final String USERPHONE = "user_phone";
public static final String USEREMAIL = "user_email";
public static final String REFUND = "refund";
}
public class DeletedOrders implements BaseColumns {
private DeletedOrders() {
}
public static final int TABLE_ID = 14;
public static final String TABLE_NAME = "deleted_order_detail";
public static final String ID = "id";
public static final String MENUITEMID = "menu_item_id";
public static final String TABLEID = "table_id";
public static final String ORDERNO = "order_no";
public static final String SEATID = "seat_id";
public static final String MENUPRICEID = "menu_price_id";
public static final String OrderID = "order_id";
}
public class DeletedTakewayOrders implements BaseColumns {
private DeletedTakewayOrders() {
}
public static final int TABLE_ID = 10;
public static final String TABLE_NAME = "restaurant_orders";
public static final String ORDERNO = "order_no";
public static final String TAKEAWAY = "take_away";
public static final String ID = "id";
}
public class FoodType implements BaseColumns {
private FoodType() {
}
public static final int TABLE_ID = 15;
public static final String TABLE_NAME = "food_type";
public static final String ID = "id";
public static final String NAME = "name";
public static final String RESTAURANT_ID = "restaurant_id";
}
public class MenuFoodTypes implements BaseColumns {
private MenuFoodTypes() {
}
public static final int TABLE_ID = 16;
public static final String TABLE_NAME = "menu_food_types";
public static final String ID = "id";
public static final String food_type_id = "food_type_id";
public static final String menu_item_id = "menu_item_id";
public static final String category_id = "category_id";
}
public class messages implements BaseColumns {
private messages() {
}
public static final int TABLE_ID = 17;
public static final String TABLE_NAME = "messages";
public static final String ID = "id";
public static final String restaurant_id = "restaurant_id";
public static final String order_no = "order_no";
public static final String type = "type";
public static final String message = "message";
}
}
No comments:
Post a Comment