This commit is contained in:
yadavendras
2017-01-24 17:28:21 +05:30
5 changed files with 100 additions and 30 deletions
@@ -1749,6 +1749,9 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
sb.setENTRY_ALLOW(dbcursor.getString(dbcursor.getColumnIndexOrThrow("ENTRY_ALLOW"))); sb.setENTRY_ALLOW(dbcursor.getString(dbcursor.getColumnIndexOrThrow("ENTRY_ALLOW")));
sb.setIMAGE_ALLOW(dbcursor.getString(dbcursor.getColumnIndexOrThrow("IMAGE_ALLOW")));
list.add(sb); list.add(sb);
dbcursor.moveToNext(); dbcursor.moveToNext();
} }
@@ -3334,12 +3337,25 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
return filled; return filled;
} }
public boolean isMappingStockData() { public boolean isMappingStockDataMSL_Availability(String category_id, String keyAccount_id, String storeType_id, String class_id) {
boolean filled = false; boolean filled = false;
Cursor dbcursor = null; Cursor dbcursor = null;
try { try {
dbcursor = db.rawQuery("SELECT * FROM MAPPING_STOCK ", null); //dbcursor = db.rawQuery("SELECT * FROM MAPPING_STOCK ", null);
dbcursor = db.rawQuery("Select M.* 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 M.MUST_HAVE=1 AND CA.CATEGORY_ID='" + category_id + "' " +
"AND M.KEYACCOUNT_ID = '" + keyAccount_id + "' AND M.STORETYPE_ID = '" + storeType_id + "' " +
"AND M.CLASS_ID = '" + class_id + "' " +
"order by SB.SUB_CATEGORY,BR.BRAND", null);
if (dbcursor != null) { if (dbcursor != null) {
dbcursor.moveToFirst(); dbcursor.moveToFirst();
@@ -3358,6 +3374,43 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
return filled; return filled;
} }
public boolean isMappingStockDataStockFacing(String category_id, String keyAccount_id, String storeType_id, String class_id) {
boolean filled = false;
Cursor dbcursor = null;
try {
//dbcursor = db.rawQuery("SELECT * FROM MAPPING_STOCK ", null);
dbcursor = db.rawQuery("Select M.* 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 M.KEYACCOUNT_ID = '" + keyAccount_id + "' " +
"AND M.STORETYPE_ID = '" + storeType_id + "' AND M.CLASS_ID = '" + class_id + "' " +
"order by SB.SUB_CATEGORY,BR.BRAND ", null);
if (dbcursor != null) {
dbcursor.moveToFirst();
int icount = dbcursor.getInt(0);
dbcursor.close();
if (icount > 0) {
filled = true;
} else {
filled = false;
}
}
} catch (Exception e) {
Log.d("Exception ", " when fetching Records!!!!!!!!!!!!!!!!!!!!! " + e.toString());
return filled;
}
return filled;
}
public boolean isMappingT2PData(String store_id, String category_id) { public boolean isMappingT2PData(String store_id, String category_id) {
boolean filled = false; boolean filled = false;
Cursor dbcursor = null; Cursor dbcursor = null;
@@ -226,9 +226,6 @@ public class MainActivity extends AppCompatActivity
if (coverageList.size() == 0) { if (coverageList.size() == 0) {
Snackbar.make(webView, R.string.no_data_for_upload, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); Snackbar.make(webView, R.string.no_data_for_upload, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
Intent i = new Intent(getBaseContext(), UploadActivity.class);
startActivity(i);
} else { } else {
if (isStoreCheckedIn() && isValid()) { if (isStoreCheckedIn() && isValid()) {
@@ -53,7 +53,7 @@ public class NonWorkingReason extends AppCompatActivity implements
ArrayList<NonWorkingReasonGetterSetter> reasondata = new ArrayList<NonWorkingReasonGetterSetter>(); ArrayList<NonWorkingReasonGetterSetter> reasondata = new ArrayList<NonWorkingReasonGetterSetter>();
private Spinner reasonspinner; private Spinner reasonspinner;
private GSKOrangeDB database; private GSKOrangeDB database;
String reasonname, reasonid, entry_allow, image, entry, reason_reamrk, intime; String reasonname, reasonid, entry_allow, image, entry, reason_reamrk, intime,image_allow;
Button save; Button save;
private ArrayAdapter<CharSequence> reason_adapter; private ArrayAdapter<CharSequence> reason_adapter;
protected String _path, str; protected String _path, str;
@@ -152,7 +152,9 @@ public class NonWorkingReason extends AppCompatActivity implements
reasonid = reasondata.get(position - 1).getREASON_ID().get(0); reasonid = reasondata.get(position - 1).getREASON_ID().get(0);
entry_allow = reasondata.get(position - 1).getENTRY_ALLOW().get(0); entry_allow = reasondata.get(position - 1).getENTRY_ALLOW().get(0);
if (reasonname.equalsIgnoreCase("Store closed")) { image_allow = reasondata.get(position - 1).getIMAGE_ALLOW().get(0);
if (image_allow.equalsIgnoreCase("1")) {
rel_cam.setVisibility(View.VISIBLE); rel_cam.setVisibility(View.VISIBLE);
image = "true"; image = "true";
} else { } else {
@@ -102,16 +102,27 @@ public class CategoryListActivity extends AppCompatActivity {
boolean flag_filled = false; boolean flag_filled = false;
String category_id = categoryList.get(i).getCategory_id(); String category_id = categoryList.get(i).getCategory_id();
//Additional_Visibility
if (db.additionalVisibilitydata(store_id, category_id)) { if (db.additionalVisibilitydata(store_id, category_id)) {
boolean flag = true; boolean flag = true;
if (db.isMappingStockData()) { //MSL_Availability
if (!db.checkMsl_AvailabilityData(store_id, category_id) if (db.isMappingStockDataMSL_Availability(category_id, keyAccount_id, storeType_id, class_id)) {
&& !db.checkStockAndFacingData(store_id, category_id)) { if (!db.checkMsl_AvailabilityData(store_id, category_id)) {
flag = false; flag = false;
} }
} }
//Stock_Facing
if (flag) {
if (db.isMappingStockDataStockFacing(category_id, keyAccount_id, storeType_id, class_id)) {
if (!db.checkStockAndFacingData(store_id, category_id)) {
flag = false;
}
}
}
//Promo Compliance
if (flag) { if (flag) {
if (db.isMappingPromotionData(store_id, category_id)) { if (db.isMappingPromotionData(store_id, category_id)) {
if (!db.checkPromoComplianceData(store_id, category_id)) { if (!db.checkPromoComplianceData(store_id, category_id)) {
@@ -120,6 +131,7 @@ public class CategoryListActivity extends AppCompatActivity {
} }
} }
//T2P
if (flag) { if (flag) {
if (db.isMappingT2PData(store_id, category_id)) { if (db.isMappingT2PData(store_id, category_id)) {
if (!db.isFilledT2P(store_id, category_id)) { if (!db.isFilledT2P(store_id, category_id)) {
@@ -289,25 +301,31 @@ public class CategoryListActivity extends AppCompatActivity {
if (db.additionalVisibilitydata(store_id, category_id)) { if (db.additionalVisibilitydata(store_id, category_id)) {
//boolean flag = true; //boolean flag = true;
if (db.isMappingStockData()) { if (db.isMappingStockDataMSL_Availability(category_id, keyAccount_id, storeType_id, class_id)) {
if (!db.checkMsl_AvailabilityData(store_id, category_id) if (!db.checkMsl_AvailabilityData(store_id, category_id)) {
&& !db.checkStockAndFacingData(store_id, category_id)) { flag_filled = false;
break;
}
}
//Stock_Facing
if (db.isMappingStockDataStockFacing(category_id, keyAccount_id, storeType_id, class_id)) {
if (!db.checkStockAndFacingData(store_id, category_id)) {
flag_filled = false;
break;
}
}
if (db.isMappingPromotionData(store_id, category_id)) {
if (!db.checkPromoComplianceData(store_id, category_id)) {
flag_filled = false; flag_filled = false;
break; break;
} }
} }
if (!db.isMappingPromotionData(store_id,category_id)) { if (db.isMappingT2PData(store_id, category_id)) {
if (db.checkPromoComplianceData(store_id, category_id)) { if (!db.isFilledT2P(store_id, category_id)) {
flag_filled = false;
break;
}
}
if (!db.isMappingT2PData(store_id, category_id)) {
if (db.isFilledT2P(store_id, category_id)) {
flag_filled = false; flag_filled = false;
break; break;
} }
@@ -106,7 +106,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter(); DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter();
//data.setCategory_name("MSL Availability"); //data.setCategory_name("MSL Availability");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability)); data.setCategory_name(getResources().getString(R.string.daily_data_menu_msl_availability));
if (db.isMappingStockData()) { if (db.isMappingStockDataMSL_Availability(categoryId, keyAccount_id, storeType_id, class_id)) {
if (db.checkMsl_AvailabilityData(store_id, categoryId)) { if (db.checkMsl_AvailabilityData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.msl_availability_done); data.setCategory_img(R.mipmap.msl_availability_done);
} else { } else {
@@ -120,7 +120,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
data = new DailyDataMenuGetterSetter(); data = new DailyDataMenuGetterSetter();
//data.setCategory_name("Stock & Facing"); //data.setCategory_name("Stock & Facing");
data.setCategory_name(getResources().getString(R.string.daily_data_menu_stock_facing)); data.setCategory_name(getResources().getString(R.string.daily_data_menu_stock_facing));
if (db.isMappingStockData()) { if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
if (db.checkStockAndFacingData(store_id, categoryId)) { if (db.checkStockAndFacingData(store_id, categoryId)) {
data.setCategory_img(R.mipmap.stock_facing_done); data.setCategory_img(R.mipmap.stock_facing_done);
} else { } else {
@@ -248,13 +248,13 @@ public class DailyDataMenuActivity extends AppCompatActivity {
holder.categoryIcon.setImageResource(dailyData.getCategory_img()); holder.categoryIcon.setImageResource(dailyData.getCategory_img());
if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_msl_availability))) { if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_msl_availability))) {
if (db.isMappingStockData()) { if (db.isMappingStockDataMSL_Availability(categoryId, keyAccount_id, storeType_id, class_id)) {
holder.categoryName.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); holder.categoryName.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
} else { } else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background)); holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
} }
} else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) { } else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) {
if (db.isMappingStockData()) { if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
holder.categoryName.setTextColor(getResources().getColor(R.color.colorPrimaryDark)); holder.categoryName.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
} else { } else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background)); holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
@@ -277,14 +277,14 @@ public class DailyDataMenuActivity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_msl_availability))) { if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_msl_availability))) {
if (db.isMappingStockData()) { if (db.isMappingStockDataMSL_Availability(categoryId, keyAccount_id, storeType_id, class_id)) {
Intent intent = new Intent(DailyDataMenuActivity.this, MSL_AvailabilityActivity.class); Intent intent = new Intent(DailyDataMenuActivity.this, MSL_AvailabilityActivity.class);
intent.putExtra("categoryName", dailyData.getCategory_name()); intent.putExtra("categoryName", dailyData.getCategory_name());
intent.putExtra("categoryId", categoryId); intent.putExtra("categoryId", categoryId);
startActivity(intent); startActivity(intent);
} }
} else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) { } else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.daily_data_menu_stock_facing))) {
if (db.isMappingStockData()) { if (db.isMappingStockDataStockFacing(categoryId, keyAccount_id, storeType_id, class_id)) {
Intent intent = new Intent(DailyDataMenuActivity.this, Stock_FacingActivity.class); Intent intent = new Intent(DailyDataMenuActivity.this, Stock_FacingActivity.class);
intent.putExtra("categoryName", dailyData.getCategory_name()); intent.putExtra("categoryName", dailyData.getCategory_name());
intent.putExtra("categoryId", categoryId); intent.putExtra("categoryId", categoryId);