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.setIMAGE_ALLOW(dbcursor.getString(dbcursor.getColumnIndexOrThrow("IMAGE_ALLOW")));
list.add(sb);
dbcursor.moveToNext();
}
@@ -3334,12 +3337,25 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
return filled;
}
public boolean isMappingStockData() {
public boolean isMappingStockDataMSL_Availability(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 * 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) {
dbcursor.moveToFirst();
@@ -3358,6 +3374,43 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
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) {
boolean filled = false;
Cursor dbcursor = null;
@@ -3366,7 +3419,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
dbcursor = db.rawQuery("SELECT * FROM MAPPING_T2P M INNER JOIN BRAND_MASTER BR ON M.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.STORE_ID = '"+ store_id +"' AND CA.CATEGORY_ID= '" + category_id + "'", null);
"WHERE M.STORE_ID = '" + store_id + "' AND CA.CATEGORY_ID= '" + category_id + "'", null);
if (dbcursor != null) {
dbcursor.moveToFirst();
@@ -226,9 +226,6 @@ public class MainActivity extends AppCompatActivity
if (coverageList.size() == 0) {
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 {
if (isStoreCheckedIn() && isValid()) {
@@ -53,7 +53,7 @@ public class NonWorkingReason extends AppCompatActivity implements
ArrayList<NonWorkingReasonGetterSetter> reasondata = new ArrayList<NonWorkingReasonGetterSetter>();
private Spinner reasonspinner;
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;
private ArrayAdapter<CharSequence> reason_adapter;
protected String _path, str;
@@ -152,7 +152,9 @@ public class NonWorkingReason extends AppCompatActivity implements
reasonid = reasondata.get(position - 1).getREASON_ID().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);
image = "true";
} else {
@@ -102,16 +102,27 @@ public class CategoryListActivity extends AppCompatActivity {
boolean flag_filled = false;
String category_id = categoryList.get(i).getCategory_id();
//Additional_Visibility
if (db.additionalVisibilitydata(store_id, category_id)) {
boolean flag = true;
if (db.isMappingStockData()) {
if (!db.checkMsl_AvailabilityData(store_id, category_id)
&& !db.checkStockAndFacingData(store_id, category_id)) {
//MSL_Availability
if (db.isMappingStockDataMSL_Availability(category_id, keyAccount_id, storeType_id, class_id)) {
if (!db.checkMsl_AvailabilityData(store_id, category_id)) {
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 (db.isMappingPromotionData(store_id, category_id)) {
if (!db.checkPromoComplianceData(store_id, category_id)) {
@@ -120,6 +131,7 @@ public class CategoryListActivity extends AppCompatActivity {
}
}
//T2P
if (flag) {
if (db.isMappingT2PData(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)) {
//boolean flag = true;
if (db.isMappingStockData()) {
if (!db.checkMsl_AvailabilityData(store_id, category_id)
&& !db.checkStockAndFacingData(store_id, category_id)) {
if (db.isMappingStockDataMSL_Availability(category_id, keyAccount_id, storeType_id, class_id)) {
if (!db.checkMsl_AvailabilityData(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;
break;
}
}
if (!db.isMappingPromotionData(store_id,category_id)) {
if (db.checkPromoComplianceData(store_id, category_id)) {
flag_filled = false;
break;
}
}
if (!db.isMappingT2PData(store_id, category_id)) {
if (db.isFilledT2P(store_id, category_id)) {
if (db.isMappingT2PData(store_id, category_id)) {
if (!db.isFilledT2P(store_id, category_id)) {
flag_filled = false;
break;
}
@@ -106,7 +106,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter();
//data.setCategory_name("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)) {
data.setCategory_img(R.mipmap.msl_availability_done);
} else {
@@ -120,7 +120,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
data = new DailyDataMenuGetterSetter();
//data.setCategory_name("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)) {
data.setCategory_img(R.mipmap.stock_facing_done);
} else {
@@ -248,13 +248,13 @@ public class DailyDataMenuActivity extends AppCompatActivity {
holder.categoryIcon.setImageResource(dailyData.getCategory_img());
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));
} else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
}
} 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));
} else {
holder.categoryName.setTextColor(getResources().getColor(R.color.grey_background));
@@ -277,14 +277,14 @@ public class DailyDataMenuActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
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.putExtra("categoryName", dailyData.getCategory_name());
intent.putExtra("categoryId", categoryId);
startActivity(intent);
}
} 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.putExtra("categoryName", dailyData.getCategory_name());
intent.putExtra("categoryId", categoryId);