Merge branch 'master' of https://github.com/CPM-INDIA-SALES-AND-MARKETING-PVT-LTD/GSKORANGEV1 into Category_G
# Conflicts: # GSKMTOrange/src/main/AndroidManifest.xml # GSKMTOrange/src/main/java/cpm/com/gskmtorange/MainActivity.java
This commit is contained in:
@@ -8,6 +8,8 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
@@ -20,6 +22,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.MAPPINGT2PGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MappingStockGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SkuMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.Stock_FacingGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.SubCategoryMasterGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
|
||||
|
||||
@@ -58,6 +61,11 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
db.execSQL(TableBean.getDisplayMaster());
|
||||
db.execSQL(TableBean.getMappingStock());
|
||||
db.execSQL(TableBean.getMappingT2p());
|
||||
|
||||
db.execSQL(CommonString.CREATE_TABLE_INSERT_MSL_AVAILABILITY);
|
||||
|
||||
db.execSQL(CommonString.CREATE_TABLE_INSERT_STOCK_FACING_HEADER);
|
||||
db.execSQL(CommonString.CREATE_TABLE_INSERT_STOCK_FACING_CHILD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,6 +340,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
|
||||
//Category List
|
||||
public ArrayList<CategoryGetterSetter> getCategoryListData(String keyAccountId, String storeTypeId, String classId) {
|
||||
ArrayList<CategoryGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
@@ -373,6 +382,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return list;
|
||||
}
|
||||
|
||||
//MSL_Availability
|
||||
public ArrayList<MSL_AvailabilityGetterSetter> getMSL_AvailabilityHeaderData(String category_id) {
|
||||
ArrayList<MSL_AvailabilityGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
@@ -457,4 +467,165 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void InsertMSL_Availability(String storeId, String categoryId, List<MSL_AvailabilityGetterSetter> hashMapListHeaderData,
|
||||
HashMap<MSL_AvailabilityGetterSetter, List<MSL_AvailabilityGetterSetter>> hashMapListChildData) {
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
try {
|
||||
db.beginTransaction();
|
||||
for (int i = 0; i < hashMapListHeaderData.size(); i++) {
|
||||
|
||||
for (int j = 0; j < hashMapListChildData.get(hashMapListHeaderData.get(i)).size(); j++) {
|
||||
MSL_AvailabilityGetterSetter data = hashMapListChildData.get(hashMapListHeaderData.get(i)).get(j);
|
||||
|
||||
values.put("Store_Id", storeId);
|
||||
values.put("Category_Id", categoryId);
|
||||
values.put("SKU_ID", data.getSku_id());
|
||||
values.put("SKU", data.getSku());
|
||||
values.put("SKU_SEQUENCE", data.getSku_sequence());
|
||||
values.put("MBQ", data.getMbq());
|
||||
values.put("TOGGLE_VALUE", data.getToggleValue());
|
||||
|
||||
db.insert(CommonString.TABLE_INSERT_MSL_AVAILABILITY, null, values);
|
||||
}
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
} catch (Exception ex) {
|
||||
Log.d("Exception ", " in Insert MSL_Availability " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
//Stock_facing
|
||||
public ArrayList<Stock_FacingGetterSetter> getStockAndFacingHeaderData(String category_id) {
|
||||
ArrayList<Stock_FacingGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
|
||||
try {
|
||||
dbcursor = db.rawQuery("Select DISTINCT SB.SUB_CATEGORY_ID,SB.SUB_CATEGORY,BR.BRAND_ID,BR.BRAND " +
|
||||
"from MAPPING_STOCK M " +
|
||||
"inner join SKU_MASTER SK " +
|
||||
"on M.SKU_ID=SK.SKU_ID " +
|
||||
"inner join BRAND_MASTER BR " +
|
||||
"on SK.BRAND_ID=BR.BRAND_ID " +
|
||||
"inner join SUB_CATEGORY_MASTER SB " +
|
||||
"on BR.SUB_CATEGORY_ID=SB.SUB_CATEGORY_ID " +
|
||||
"inner join CATEGORY_MASTER CA " +
|
||||
"on SB.CATEGORY_ID=CA.CATEGORY_ID " +
|
||||
"where CA.CATEGORY_ID='" + category_id + "' " +
|
||||
"order by SB.SUB_CATEGORY,BR.BRAND", null);
|
||||
|
||||
if (dbcursor != null) {
|
||||
dbcursor.moveToFirst();
|
||||
while (!dbcursor.isAfterLast()) {
|
||||
Stock_FacingGetterSetter cd = new Stock_FacingGetterSetter();
|
||||
|
||||
cd.setSub_category_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY_ID")));
|
||||
cd.setSub_category(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY")));
|
||||
cd.setBrand_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("BRAND_ID")));
|
||||
cd.setBrand(dbcursor.getString(dbcursor.getColumnIndexOrThrow("BRAND")));
|
||||
cd.setImage1("");
|
||||
cd.setImage2("");
|
||||
|
||||
list.add(cd);
|
||||
dbcursor.moveToNext();
|
||||
}
|
||||
dbcursor.close();
|
||||
return list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("Exception ", "get MSL_AvailabilityHeader!" + e.toString());
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<Stock_FacingGetterSetter> getStockAndFacingSKUData(String category_id, String brand_id) {
|
||||
ArrayList<Stock_FacingGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
|
||||
try {
|
||||
dbcursor = db.rawQuery("Select DISTINCT SK.SKU_ID,SK.SKU,SK.MRP,SK.SKU_SEQUENCE,M.MBQ,BR.COMPANY_ID " +
|
||||
"from MAPPING_STOCK M " +
|
||||
"inner join SKU_MASTER SK " +
|
||||
"on M.SKU_ID=SK.SKU_ID " +
|
||||
"inner join BRAND_MASTER BR " +
|
||||
"on SK.BRAND_ID=BR.BRAND_ID " +
|
||||
"inner join SUB_CATEGORY_MASTER SB " +
|
||||
"on BR.SUB_CATEGORY_ID=SB.SUB_CATEGORY_ID " +
|
||||
"inner join CATEGORY_MASTER CA " +
|
||||
"on SB.CATEGORY_ID=CA.CATEGORY_ID " +
|
||||
"where CA.CATEGORY_ID='" + category_id + "' AND BR.BRAND_ID='" + brand_id + "'", null);
|
||||
|
||||
if (dbcursor != null) {
|
||||
|
||||
dbcursor.moveToFirst();
|
||||
while (!dbcursor.isAfterLast()) {
|
||||
Stock_FacingGetterSetter cd = new Stock_FacingGetterSetter();
|
||||
|
||||
cd.setSku_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU_ID")));
|
||||
cd.setSku(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU")));
|
||||
cd.setMrp(dbcursor.getString(dbcursor.getColumnIndexOrThrow("MRP")));
|
||||
cd.setSku_sequence(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SKU_SEQUENCE")));
|
||||
cd.setMbq(dbcursor.getString(dbcursor.getColumnIndexOrThrow("MBQ")));
|
||||
cd.setCompany_id(dbcursor.getString(dbcursor.getColumnIndexOrThrow("COMPANY_ID")));
|
||||
cd.setStock("");
|
||||
cd.setFacing("");
|
||||
|
||||
list.add(cd);
|
||||
dbcursor.moveToNext();
|
||||
}
|
||||
dbcursor.close();
|
||||
return list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("Exception ", "get MSL_AvailabilityHeader!" + e.toString());
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void InsertStock_Facing(String storeId, String categoryId, List<Stock_FacingGetterSetter> hashMapListHeaderData,
|
||||
HashMap<Stock_FacingGetterSetter, List<Stock_FacingGetterSetter>> hashMapListChildData) {
|
||||
ContentValues values = new ContentValues();
|
||||
ContentValues values1 = new ContentValues();
|
||||
|
||||
try {
|
||||
db.beginTransaction();
|
||||
for (int i = 0; i < hashMapListHeaderData.size(); i++) {
|
||||
Stock_FacingGetterSetter data1 = hashMapListHeaderData.get(i);
|
||||
|
||||
values1.put("Store_Id", storeId);
|
||||
values1.put("Category_Id", categoryId);
|
||||
values1.put("SUB_CATEGORY_ID", data1.getSub_category_id());
|
||||
values1.put("SUB_CATEGORY", data1.getSub_category());
|
||||
values1.put("BRAND_ID", data1.getBrand_id());
|
||||
values1.put("BRAND", data1.getBrand());
|
||||
values1.put("IMAGE1", data1.getImage1());
|
||||
values1.put("IMAGE2", data1.getImage2());
|
||||
|
||||
db.insert(CommonString.TABLE_INSERT_STOCK_FACING_HEADER, null, values1);
|
||||
|
||||
for (int j = 0; j < hashMapListChildData.get(hashMapListHeaderData.get(i)).size(); j++) {
|
||||
Stock_FacingGetterSetter data = hashMapListChildData.get(hashMapListHeaderData.get(i)).get(j);
|
||||
|
||||
values.put("Store_Id", storeId);
|
||||
values.put("Category_Id", categoryId);
|
||||
values.put("SKU_ID", data.getSku_id());
|
||||
values.put("SKU", data.getSku());
|
||||
values.put("SKU_SEQUENCE", data.getSku_sequence());
|
||||
values.put("MBQ", data.getMbq());
|
||||
values.put("COMPANY_ID", data.getCompany_id());
|
||||
values.put("STOCK_VALUE", data.getStock());
|
||||
values.put("FACEUP_VALUE", data.getFacing());
|
||||
|
||||
db.insert(CommonString.TABLE_INSERT_STOCK_FACING_CHILD, null, values);
|
||||
}
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
} catch (Exception ex) {
|
||||
Log.d("Exception ", " in Insert MSL_Availability " + ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -198,6 +199,7 @@ public class MainActivity extends AppCompatActivity
|
||||
File backupDB = new File(path, backupDBPath);
|
||||
|
||||
//Snackbar.make(rec_store_data, "Database Exported Successfully", Snackbar.LENGTH_SHORT).show();
|
||||
Toast.makeText(MainActivity.this, "Database Exported Successfully", Toast.LENGTH_SHORT).show();
|
||||
|
||||
if (currentDB.exists()) {
|
||||
@SuppressWarnings("resource")
|
||||
|
||||
@@ -60,13 +60,97 @@ public class CommonString {
|
||||
+ "KEY_ID"
|
||||
+ " INTEGER PRIMARY KEY AUTOINCREMENT ,"
|
||||
|
||||
+ "Common_ID"
|
||||
+ "Store_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "POST_WORK_IMAGE"
|
||||
+ "Category_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "POST_WORK_IMAGE1"
|
||||
+ "SKU_ID"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SKU"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SKU_SEQUENCE"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "MBQ"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "TOGGLE_VALUE"
|
||||
+ " VARCHAR"
|
||||
|
||||
+ ")";
|
||||
|
||||
|
||||
public static final String TABLE_INSERT_STOCK_FACING_HEADER = "Stock_Facing_Header_Data";
|
||||
|
||||
public static final String CREATE_TABLE_INSERT_STOCK_FACING_HEADER = "CREATE TABLE IF NOT EXISTS "
|
||||
+ TABLE_INSERT_STOCK_FACING_HEADER
|
||||
+ "("
|
||||
+ "KEY_ID"
|
||||
+ " INTEGER PRIMARY KEY AUTOINCREMENT ,"
|
||||
|
||||
+ "Store_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "Category_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SUB_CATEGORY_ID"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SUB_CATEGORY"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "BRAND_ID"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "BRAND"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "IMAGE1"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "IMAGE2"
|
||||
+ " VARCHAR"
|
||||
|
||||
+ ")";
|
||||
|
||||
public static final String TABLE_INSERT_STOCK_FACING_CHILD = "Stock_Facing_Child_Data";
|
||||
|
||||
public static final String CREATE_TABLE_INSERT_STOCK_FACING_CHILD = "CREATE TABLE IF NOT EXISTS "
|
||||
+ TABLE_INSERT_STOCK_FACING_CHILD
|
||||
+ "("
|
||||
+ "KEY_ID"
|
||||
+ " INTEGER PRIMARY KEY AUTOINCREMENT ,"
|
||||
|
||||
+ "Store_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "Category_Id"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SKU_ID"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SKU"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SKU_SEQUENCE"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "MBQ"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "COMPANY_ID"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "STOCK_VALUE"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "FACEUP_VALUE"
|
||||
+ " VARCHAR"
|
||||
|
||||
+ ")";
|
||||
|
||||
+57
-11
@@ -1,6 +1,8 @@
|
||||
package cpm.com.gskmtorange.gsk_dailyentry;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
@@ -23,6 +25,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -46,7 +49,7 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
|
||||
GSKOrangeDB db;
|
||||
|
||||
String categoryName, categoryId;
|
||||
String categoryName, categoryId, storeId;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -66,6 +69,7 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
storeId = "";
|
||||
|
||||
txt_mslAvailabilityName.setText(categoryName);
|
||||
|
||||
@@ -75,8 +79,43 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
|
||||
//if (validateData(listDataHeader, listDataChild)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
|
||||
builder.setMessage("Are you sure you want to save")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
db.open();
|
||||
|
||||
db.InsertMSL_Availability(storeId,categoryId, hashMapListHeaderData, hashMapListChildData);
|
||||
|
||||
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
/*} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
|
||||
builder.setMessage("Fill the value or fill 0 ")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}*/
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,7 +142,7 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
getCurrentFocus().clearFocus();
|
||||
}
|
||||
|
||||
expandableListView.invalidateViews();
|
||||
//expandableListView.invalidateViews();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -287,6 +326,10 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
holder.txt_skuName = (TextView) convertView.findViewById(R.id.txt_skuName);
|
||||
holder.txt_mbq = (TextView) convertView.findViewById(R.id.txt_mbq);
|
||||
holder.toggle_available = (ToggleButton) convertView.findViewById(R.id.toggle_available);
|
||||
|
||||
holder.toggle_available.setTextOff("No");
|
||||
holder.toggle_available.setTextOn("Yes");
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
@@ -295,14 +338,11 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
holder.txt_skuName.setText(childData.getSku());
|
||||
holder.txt_mbq.setText(childData.getMbq());
|
||||
|
||||
holder.toggle_available.setTextOff("No");
|
||||
holder.toggle_available.setTextOn("Yes");
|
||||
|
||||
if (childData.getToggleValue().equals("1")) {
|
||||
holder.toggle_available.setChecked(true);
|
||||
/*if (childData.getToggleValue().equals("1")) {
|
||||
holder.toggle_available.setText("Yes");
|
||||
} else {
|
||||
holder.toggle_available.setChecked(false);
|
||||
}
|
||||
holder.toggle_available.setText("No");
|
||||
}*/
|
||||
|
||||
holder.toggle_available.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@@ -317,6 +357,12 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
if (childData.getToggleValue().equals("1")) {
|
||||
holder.toggle_available.setChecked(true);
|
||||
} else {
|
||||
holder.toggle_available.setChecked(false);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
+154
-49
@@ -1,6 +1,8 @@
|
||||
package cpm.com.gskmtorange.gsk_dailyentry;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -28,6 +30,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import java.io.File;
|
||||
@@ -38,6 +41,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.Stock_FacingGetterSetter;
|
||||
@@ -52,11 +56,13 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
HashMap<Stock_FacingGetterSetter, List<Stock_FacingGetterSetter>> hashMapListChildData;
|
||||
|
||||
ExpandableListAdapter adapter;
|
||||
GSKOrangeDB db;
|
||||
|
||||
String title;
|
||||
String categoryName, categoryId, storeId;
|
||||
|
||||
String path = "", str = "", _pathforcheck = "", img1 = "";
|
||||
static int child_position = -1;
|
||||
boolean isDialogOpen = true;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -68,11 +74,17 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
db = new GSKOrangeDB(this);
|
||||
db.open();
|
||||
|
||||
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
|
||||
txt_stockFacingName = (TextView) findViewById(R.id.txt_stockFacingName);
|
||||
|
||||
title = getIntent().getStringExtra("categoryName");
|
||||
txt_stockFacingName.setText(title);
|
||||
categoryName = getIntent().getStringExtra("categoryName");
|
||||
categoryId = getIntent().getStringExtra("categoryId");
|
||||
storeId = "";
|
||||
|
||||
txt_stockFacingName.setText(categoryName);
|
||||
|
||||
prepareList();
|
||||
|
||||
@@ -82,8 +94,44 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
/*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();*/
|
||||
|
||||
//if (validateData(listDataHeader, listDataChild)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
|
||||
builder.setMessage("Are you sure you want to save")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
db.open();
|
||||
|
||||
db.InsertStock_Facing(storeId, categoryId, hashMapListHeaderData, hashMapListChildData);
|
||||
|
||||
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
/*} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MSL_AvailabilityActivity.this);
|
||||
builder.setMessage("Fill the value or fill 0 ")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}*/
|
||||
}
|
||||
});
|
||||
|
||||
@@ -150,58 +198,23 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void prepareList() {
|
||||
headerDataList = new ArrayList<>();
|
||||
|
||||
Stock_FacingGetterSetter msl = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax header 1");
|
||||
msl.setMbq("1");
|
||||
msl.setAvailable("No");
|
||||
headerDataList.add(msl);
|
||||
|
||||
msl = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax header 2");
|
||||
msl.setMbq("2");
|
||||
msl.setAvailable("Yes");
|
||||
headerDataList.add(msl);
|
||||
|
||||
msl = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax header 3");
|
||||
msl.setMbq("3");
|
||||
msl.setAvailable("Yes");
|
||||
headerDataList.add(msl);
|
||||
|
||||
msl = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax header 4");
|
||||
msl.setMbq("4");
|
||||
msl.setAvailable("No");
|
||||
headerDataList.add(msl);
|
||||
|
||||
|
||||
hashMapListHeaderData = new ArrayList<>();
|
||||
hashMapListChildData = new HashMap<>();
|
||||
|
||||
//Header
|
||||
headerDataList = db.getStockAndFacingHeaderData(categoryId);
|
||||
|
||||
if (headerDataList.size() > 0) {
|
||||
|
||||
for (int i = 0; i < headerDataList.size(); i++) {
|
||||
hashMapListHeaderData.add(headerDataList.get(i));
|
||||
|
||||
childDataList = new ArrayList<>();
|
||||
//childDataList = new ArrayList<>();
|
||||
childDataList = db.getStockAndFacingSKUData(categoryId, headerDataList.get(i).getBrand_id());
|
||||
|
||||
Stock_FacingGetterSetter msl1 = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax 1");
|
||||
msl.setMbq("1");
|
||||
msl.setAvailable("No");
|
||||
childDataList.add(msl1);
|
||||
|
||||
msl1 = new Stock_FacingGetterSetter();
|
||||
msl.setBrandName("Parodontax 2");
|
||||
msl.setMbq("2");
|
||||
msl.setAvailable("No");
|
||||
childDataList.add(msl1);
|
||||
|
||||
hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData);
|
||||
@@ -252,7 +265,7 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
ImageView img_edit = (ImageView) convertView.findViewById(R.id.img_edit);
|
||||
|
||||
txt_stockFaceupHeader.setTypeface(null, Typeface.BOLD);
|
||||
txt_stockFaceupHeader.setText(headerTitle.getBrandName());
|
||||
txt_stockFaceupHeader.setText(headerTitle.getSub_category() + "-" + headerTitle.getBrand());
|
||||
|
||||
img_camera1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -338,7 +351,7 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
|
||||
View convertView, ViewGroup parent) {
|
||||
Stock_FacingGetterSetter childData = (Stock_FacingGetterSetter) getChild(groupPosition, childPosition);
|
||||
final Stock_FacingGetterSetter childData = (Stock_FacingGetterSetter) getChild(groupPosition, childPosition);
|
||||
ViewHolder holder = null;
|
||||
|
||||
if (convertView == null) {
|
||||
@@ -357,8 +370,100 @@ public class Stock_FacingActivity extends AppCompatActivity {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.txt_skuName.setText(childData.getBrandName());
|
||||
holder.ed_stock.setText(childData.getMbq());
|
||||
holder.txt_skuName.setText(childData.getSku());
|
||||
|
||||
if (childData.getCompany_id().equals("1")) {
|
||||
holder.txt_skuName.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
} else {
|
||||
holder.txt_skuName.setTextColor(getResources().getColor(R.color.black));
|
||||
}
|
||||
|
||||
|
||||
if (childData.getStock().equals("0")) {
|
||||
holder.ed_facing.setEnabled(false);
|
||||
} else {
|
||||
holder.ed_facing.setEnabled(true);
|
||||
}
|
||||
|
||||
final ViewHolder finalHolder = holder;
|
||||
holder.ed_stock.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
|
||||
final EditText caption = (EditText) v;
|
||||
String edStock = caption.getText().toString();
|
||||
|
||||
if (!edStock.equals("")) {
|
||||
String stock = edStock.replaceFirst("^0+(?!$)", "");
|
||||
childData.setStock(stock);
|
||||
|
||||
if (edStock.equals("0")) {
|
||||
childData.setFacing("0");
|
||||
|
||||
finalHolder.ed_facing.setEnabled(false);
|
||||
} else {
|
||||
childData.setFacing(childData.getFacing());
|
||||
finalHolder.ed_facing.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
childData.setStock("");
|
||||
finalHolder.ed_facing.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.ed_stock.setText(childData.getStock());
|
||||
|
||||
holder.ed_facing.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
final EditText caption = (EditText) v;
|
||||
final String edFaceup = caption.getText().toString().replaceFirst("^0+(?!$)", "");
|
||||
|
||||
if (!childData.getStock().equals("")) {
|
||||
if (!edFaceup.equals("")) {
|
||||
if (Integer.parseInt(edFaceup) <= Integer.parseInt(childData.getStock())) {
|
||||
childData.setFacing(edFaceup);
|
||||
} else {
|
||||
if (isDialogOpen) {
|
||||
isDialogOpen = !isDialogOpen;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
|
||||
builder.setMessage("Faceup can not be greater than stock value")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
isDialogOpen = !isDialogOpen;
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
childData.setFacing("");
|
||||
}
|
||||
} else {
|
||||
if (isDialogOpen) {
|
||||
isDialogOpen = !isDialogOpen;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(Stock_FacingActivity.this);
|
||||
builder.setMessage("First fill the stock value")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
isDialogOpen = !isDialogOpen;
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.ed_facing.setText(childData.getFacing());
|
||||
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
+98
-9
@@ -5,14 +5,87 @@ package cpm.com.gskmtorange.xmlGetterSetter;
|
||||
*/
|
||||
|
||||
public class Stock_FacingGetterSetter {
|
||||
String brandName, mbq, available;
|
||||
String sub_category_id, sub_category, brand_id, brand,
|
||||
sku_id, sku, mrp, sku_sequence, stock, facing, mbq, company_id, image1, image2;
|
||||
|
||||
public String getBrandName() {
|
||||
return brandName;
|
||||
public String getSub_category_id() {
|
||||
return sub_category_id;
|
||||
}
|
||||
|
||||
public void setBrandName(String brandName) {
|
||||
this.brandName = brandName;
|
||||
public void setSub_category_id(String sub_category_id) {
|
||||
this.sub_category_id = sub_category_id;
|
||||
}
|
||||
|
||||
public String getSub_category() {
|
||||
return sub_category;
|
||||
}
|
||||
|
||||
public void setSub_category(String sub_category) {
|
||||
this.sub_category = sub_category;
|
||||
}
|
||||
|
||||
public String getBrand_id() {
|
||||
return brand_id;
|
||||
}
|
||||
|
||||
public void setBrand_id(String brand_id) {
|
||||
this.brand_id = brand_id;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
public String getSku_id() {
|
||||
return sku_id;
|
||||
}
|
||||
|
||||
public void setSku_id(String sku_id) {
|
||||
this.sku_id = sku_id;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
public String getMrp() {
|
||||
return mrp;
|
||||
}
|
||||
|
||||
public void setMrp(String mrp) {
|
||||
this.mrp = mrp;
|
||||
}
|
||||
|
||||
public String getSku_sequence() {
|
||||
return sku_sequence;
|
||||
}
|
||||
|
||||
public void setSku_sequence(String sku_sequence) {
|
||||
this.sku_sequence = sku_sequence;
|
||||
}
|
||||
|
||||
public String getStock() {
|
||||
return stock;
|
||||
}
|
||||
|
||||
public void setStock(String stock) {
|
||||
this.stock = stock;
|
||||
}
|
||||
|
||||
public String getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
public void setFacing(String facing) {
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
public String getMbq() {
|
||||
@@ -23,11 +96,27 @@ public class Stock_FacingGetterSetter {
|
||||
this.mbq = mbq;
|
||||
}
|
||||
|
||||
public String getAvailable() {
|
||||
return available;
|
||||
public String getCompany_id() {
|
||||
return company_id;
|
||||
}
|
||||
|
||||
public void setAvailable(String available) {
|
||||
this.available = available;
|
||||
public void setCompany_id(String company_id) {
|
||||
this.company_id = company_id;
|
||||
}
|
||||
|
||||
public String getImage1() {
|
||||
return image1;
|
||||
}
|
||||
|
||||
public void setImage1(String image1) {
|
||||
this.image1 = image1;
|
||||
}
|
||||
|
||||
public String getImage2() {
|
||||
return image2;
|
||||
}
|
||||
|
||||
public void setImage2(String image2) {
|
||||
this.image2 = image2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
|
||||
app:menu="@menu/activity_main_drawer" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:id="@+id/coordinate"
|
||||
tools:context="cpm.com.gskmtorange.MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
|
||||
Reference in New Issue
Block a user