package com.xbsaykat.easy24admin.Discount; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.squareup.picasso.Picasso; import com.xbsaykat.easy24admin.R; import de.hdodenhof.circleimageview.CircleImageView; public class DiscountViewShow extends RecyclerView.ViewHolder{ public DiscountViewShow(@NonNull View itemView) { super(itemView); } public void setDetails(final Context context, final String shopname, final String category, final String shopPercentage, final String mobile, final String divition, final String zila, final String upzila, final String email, final String joindate, final String key, final String confirm, final String ID,final String UserPercentage,final String shoplogo,final String shoploc) { TextView Shopname = itemView.findViewById(R.id.shop_name); TextView Per_centage = itemView.findViewById(R.id.per_centage); TextView UserPer_centage = itemView.findViewById(R.id.userper_centage); TextView Cate_gory = itemView.findViewById(R.id.cate_gory); TextView Email = itemView.findViewById(R.id.e_mail); TextView Location = itemView.findViewById(R.id.lo_cation); TextView Joindate = itemView.findViewById(R.id.join_date); TextView Call = itemView.findViewById(R.id.call); TextView Approve = itemView.findViewById(R.id.approve); TextView Reject = itemView.findViewById(R.id.reject); CircleImageView imageView=itemView.findViewById(R.id.logo_image); Picasso.get().load(shoplogo).into(imageView); Shopname.setText("Shop Name : "+shopname); Per_centage.setText("Easy24 Referral : "+shopPercentage+"%"); UserPer_centage.setText("User Discount : "+UserPercentage+"%"); Cate_gory.setText("Shop Type : "+category); Email.setText("Email : "+email); Location.setText("Location : "+divition +" , "+zila+" , "+upzila+" , " +shoploc); Joindate.setText("Joindate : "+joindate); final String Convertzila=zila.substring(0, zila.indexOf('(')); final String ConvertUpzila=upzila.substring(0, upzila.indexOf('(')); final String Convertcategory=category.substring(0, category.indexOf('(')); Call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+mobile)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }); Approve.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(!shopPercentage.equals("0")) { try { DatabaseReference Vendor = FirebaseDatabase.getInstance().getReference().child("Vendors").child(key); Vendor.child("confirm").setValue("1"); DatabaseReference VendorCategorySearch = FirebaseDatabase.getInstance().getReference().child("VendorsCategory").child(Convertcategory).child(key); VendorCategorySearch.child("shopname").setValue(shopname); VendorCategorySearch.child("mobile").setValue(mobile); VendorCategorySearch.child("email").setValue(email); VendorCategorySearch.child("divition").setValue(divition); VendorCategorySearch.child("zila").setValue(zila); VendorCategorySearch.child("upzila").setValue(upzila); VendorCategorySearch.child("shopPercentage").setValue(shopPercentage); VendorCategorySearch.child("key").setValue(key); VendorCategorySearch.child("ID").setValue(ID); VendorCategorySearch.child("userPercentage").setValue(UserPercentage); VendorCategorySearch.child("logo").setValue(shoplogo); VendorCategorySearch.child("subplace").setValue(shoploc); DatabaseReference VendorzilaSearch = FirebaseDatabase.getInstance().getReference().child("VendorzilaSearch").child(Convertzila).child(key); VendorzilaSearch.child("shopname").setValue(shopname); VendorzilaSearch.child("mobile").setValue(mobile); VendorzilaSearch.child("email").setValue(email); VendorzilaSearch.child("category").setValue(category); VendorzilaSearch.child("divition").setValue(divition); VendorzilaSearch.child("zila").setValue(zila); VendorzilaSearch.child("upzila").setValue(upzila); VendorzilaSearch.child("shopPercentage").setValue(shopPercentage); VendorzilaSearch.child("key").setValue(key); VendorzilaSearch.child("ID").setValue(ID); VendorzilaSearch.child("userPercentage").setValue(UserPercentage); VendorzilaSearch.child("logo").setValue(shoplogo); VendorzilaSearch.child("subplace").setValue(shoploc); DatabaseReference VendorPlaceSearch = FirebaseDatabase.getInstance().getReference().child("VendorPlaceSearch").child(Convertzila).child(ConvertUpzila).child(key); VendorPlaceSearch.child("shopname").setValue(shopname); VendorPlaceSearch.child("mobile").setValue(mobile); VendorPlaceSearch.child("email").setValue(email); VendorPlaceSearch.child("category").setValue(category); VendorPlaceSearch.child("divition").setValue(divition); VendorPlaceSearch.child("zila").setValue(zila); VendorPlaceSearch.child("upzila").setValue(upzila); VendorPlaceSearch.child("shopPercentage").setValue(shopPercentage); VendorPlaceSearch.child("key").setValue(key); VendorPlaceSearch.child("ID").setValue(ID); VendorPlaceSearch.child("userPercentage").setValue(UserPercentage); VendorPlaceSearch.child("logo").setValue(shoplogo); VendorPlaceSearch.child("subplace").setValue(shoploc); DatabaseReference VendorPlaceCategortSearch = FirebaseDatabase.getInstance().getReference().child("VendorPlaceCategortSearch").child(Convertzila).child(ConvertUpzila).child(Convertcategory).child(key); VendorPlaceCategortSearch.child("shopname").setValue(shopname); VendorPlaceCategortSearch.child("mobile").setValue(mobile); VendorPlaceCategortSearch.child("email").setValue(email); VendorPlaceCategortSearch.child("category").setValue(category); VendorPlaceCategortSearch.child("divition").setValue(divition); VendorPlaceCategortSearch.child("zila").setValue(zila); VendorPlaceCategortSearch.child("upzila").setValue(upzila); VendorPlaceCategortSearch.child("shopPercentage").setValue(shopPercentage); VendorPlaceCategortSearch.child("key").setValue(key); VendorPlaceCategortSearch.child("ID").setValue(ID); VendorPlaceCategortSearch.child("userPercentage").setValue(UserPercentage); VendorPlaceCategortSearch.child("logo").setValue(shoplogo); VendorPlaceCategortSearch.child("subplace").setValue(shoploc); DatabaseReference VendorApproveList = FirebaseDatabase.getInstance().getReference().child("VendorApproveList").child(key); VendorApproveList.child("shopname").setValue(shopname); VendorApproveList.child("mobile").setValue(mobile); VendorApproveList.child("email").setValue(email); VendorApproveList.child("category").setValue(category); VendorApproveList.child("divition").setValue(divition); VendorApproveList.child("zila").setValue(zila); VendorApproveList.child("upzila").setValue(upzila); VendorApproveList.child("shopPercentage").setValue(shopPercentage); VendorApproveList.child("key").setValue(key); VendorApproveList.child("ID").setValue(ID); VendorApproveList.child("userPercentage").setValue(UserPercentage); VendorApproveList.child("logo").setValue(shoplogo); VendorApproveList.child("subplace").setValue(shoploc); DatabaseReference VendorID = FirebaseDatabase.getInstance().getReference().child("VendorID").child(ID).child(key); VendorID.child("shopname").setValue(shopname); VendorID.child("mobile").setValue(mobile); VendorID.child("email").setValue(email); VendorID.child("category").setValue(category); VendorID.child("divition").setValue(divition); VendorID.child("zila").setValue(zila); VendorID.child("upzila").setValue(upzila); VendorID.child("shopPercentage").setValue(shopPercentage); VendorID.child("key").setValue(key); VendorID.child("ID").setValue(ID); VendorID.child("userPercentage").setValue(UserPercentage); VendorID.child("logo").setValue(shoplogo); VendorID.child("subplace").setValue(shoploc); DatabaseReference VendorIDList = FirebaseDatabase.getInstance().getReference().child("VendorIDList"); VendorIDList.child(ID).setValue(ID); DatabaseReference Remove = FirebaseDatabase.getInstance().getReference().child("VendorsRequest").child(key); Remove.removeValue(); } catch (Exception IO) { } } else{ DatabaseReference Vendor = FirebaseDatabase.getInstance().getReference().child("Vendors").child(key); Vendor.child("confirm").setValue("1"); DatabaseReference VendorApproveListWithZero = FirebaseDatabase.getInstance().getReference().child("VendorApproveListWithZero").child(key); VendorApproveListWithZero.child("shopname").setValue(shopname); VendorApproveListWithZero.child("mobile").setValue(mobile); VendorApproveListWithZero.child("email").setValue(email); VendorApproveListWithZero.child("category").setValue(category); VendorApproveListWithZero.child("divition").setValue(divition); VendorApproveListWithZero.child("zila").setValue(zila); VendorApproveListWithZero.child("upzila").setValue(upzila); VendorApproveListWithZero.child("shopPercentage").setValue(shopPercentage); VendorApproveListWithZero.child("key").setValue(key); VendorApproveListWithZero.child("ID").setValue(ID); VendorApproveListWithZero.child("userPercentage").setValue(UserPercentage); VendorApproveListWithZero.child("logo").setValue(shoplogo); VendorApproveListWithZero.child("subplace").setValue(shoploc); DatabaseReference VendorCategorySearch = FirebaseDatabase.getInstance().getReference().child("VendorsCategory").child(Convertcategory).child(key); VendorCategorySearch.child("shopname").setValue(shopname); VendorCategorySearch.child("mobile").setValue(mobile); VendorCategorySearch.child("email").setValue(email); VendorCategorySearch.child("divition").setValue(divition); VendorCategorySearch.child("zila").setValue(zila); VendorCategorySearch.child("upzila").setValue(upzila); VendorCategorySearch.child("shopPercentage").setValue(shopPercentage); VendorCategorySearch.child("key").setValue(key); VendorCategorySearch.child("ID").setValue(ID); VendorCategorySearch.child("userPercentage").setValue(UserPercentage); VendorCategorySearch.child("logo").setValue(shoplogo); VendorCategorySearch.child("subplace").setValue(shoploc); DatabaseReference VendorzilaSearch = FirebaseDatabase.getInstance().getReference().child("VendorzilaSearch").child(Convertzila).child(key); VendorzilaSearch.child("shopname").setValue(shopname); VendorzilaSearch.child("mobile").setValue(mobile); VendorzilaSearch.child("email").setValue(email); VendorzilaSearch.child("category").setValue(category); VendorzilaSearch.child("divition").setValue(divition); VendorzilaSearch.child("zila").setValue(zila); VendorzilaSearch.child("upzila").setValue(upzila); VendorzilaSearch.child("shopPercentage").setValue(shopPercentage); VendorzilaSearch.child("key").setValue(key); VendorzilaSearch.child("ID").setValue(ID); VendorzilaSearch.child("userPercentage").setValue(UserPercentage); VendorzilaSearch.child("logo").setValue(shoplogo); VendorzilaSearch.child("subplace").setValue(shoploc); DatabaseReference VendorPlaceSearch = FirebaseDatabase.getInstance().getReference().child("VendorPlaceSearch").child(Convertzila).child(ConvertUpzila).child(key); VendorPlaceSearch.child("shopname").setValue(shopname); VendorPlaceSearch.child("mobile").setValue(mobile); VendorPlaceSearch.child("email").setValue(email); VendorPlaceSearch.child("category").setValue(category); VendorPlaceSearch.child("divition").setValue(divition); VendorPlaceSearch.child("zila").setValue(zila); VendorPlaceSearch.child("upzila").setValue(upzila); VendorPlaceSearch.child("shopPercentage").setValue(shopPercentage); VendorPlaceSearch.child("key").setValue(key); VendorPlaceSearch.child("ID").setValue(ID); VendorPlaceSearch.child("userPercentage").setValue(UserPercentage); VendorPlaceSearch.child("logo").setValue(shoplogo); VendorPlaceSearch.child("subplace").setValue(shoploc); DatabaseReference VendorPlaceCategortSearch = FirebaseDatabase.getInstance().getReference().child("VendorPlaceCategortSearch").child(Convertzila).child(ConvertUpzila).child(Convertcategory).child(key); VendorPlaceCategortSearch.child("shopname").setValue(shopname); VendorPlaceCategortSearch.child("mobile").setValue(mobile); VendorPlaceCategortSearch.child("email").setValue(email); VendorPlaceCategortSearch.child("category").setValue(category); VendorPlaceCategortSearch.child("divition").setValue(divition); VendorPlaceCategortSearch.child("zila").setValue(zila); VendorPlaceCategortSearch.child("upzila").setValue(upzila); VendorPlaceCategortSearch.child("shopPercentage").setValue(shopPercentage); VendorPlaceCategortSearch.child("key").setValue(key); VendorPlaceCategortSearch.child("ID").setValue(ID); VendorPlaceCategortSearch.child("userPercentage").setValue(UserPercentage); VendorPlaceCategortSearch.child("logo").setValue(shoplogo); VendorPlaceCategortSearch.child("subplace").setValue(shoploc); DatabaseReference VendorApproveList = FirebaseDatabase.getInstance().getReference().child("VendorApproveList").child(key); VendorApproveList.child("shopname").setValue(shopname); VendorApproveList.child("mobile").setValue(mobile); VendorApproveList.child("email").setValue(email); VendorApproveList.child("category").setValue(category); VendorApproveList.child("divition").setValue(divition); VendorApproveList.child("zila").setValue(zila); VendorApproveList.child("upzila").setValue(upzila); VendorApproveList.child("shopPercentage").setValue(shopPercentage); VendorApproveList.child("key").setValue(key); VendorApproveList.child("ID").setValue(ID); VendorApproveList.child("userPercentage").setValue(UserPercentage); VendorApproveList.child("logo").setValue(shoplogo); VendorApproveList.child("subplace").setValue(shoploc); DatabaseReference VendorID = FirebaseDatabase.getInstance().getReference().child("VendorID").child(ID).child(key); VendorID.child("shopname").setValue(shopname); VendorID.child("mobile").setValue(mobile); VendorID.child("email").setValue(email); VendorID.child("category").setValue(category); VendorID.child("divition").setValue(divition); VendorID.child("zila").setValue(zila); VendorID.child("upzila").setValue(upzila); VendorID.child("shopPercentage").setValue(shopPercentage); VendorID.child("key").setValue(key); VendorID.child("ID").setValue(ID); VendorID.child("userPercentage").setValue(UserPercentage); VendorID.child("logo").setValue(shoplogo); VendorID.child("subplace").setValue(shoploc); DatabaseReference VendorIDList = FirebaseDatabase.getInstance().getReference().child("VendorIDList"); VendorIDList.child(ID).setValue(ID); DatabaseReference Remove = FirebaseDatabase.getInstance().getReference().child("VendorsRequest").child(key); Remove.removeValue(); } } }); Reject.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatabaseReference Vendor = FirebaseDatabase.getInstance().getReference().child("Vendors").child(key); Vendor.child("confirm").setValue("2"); DatabaseReference VendorRejectList = FirebaseDatabase.getInstance().getReference().child("VendorRejectList").child(key); VendorRejectList.child("shopname").setValue(shopname); VendorRejectList.child("mobile").setValue(mobile); VendorRejectList.child("email").setValue(email); VendorRejectList.child("category").setValue(category); VendorRejectList.child("divition").setValue(divition); VendorRejectList.child("zila").setValue(zila); VendorRejectList.child("upzila").setValue(upzila); VendorRejectList.child("shopPercentage").setValue(shopPercentage); VendorRejectList.child("key").setValue(key); VendorRejectList.child("ID").setValue(ID); VendorRejectList.child("userPercentage").setValue(UserPercentage); VendorRejectList.child("logo").setValue(shoplogo); VendorRejectList.child("subplace").setValue(shoploc); DatabaseReference Remove = FirebaseDatabase.getInstance().getReference().child("VendorsRequest").child(key); Remove.removeValue(); } }); } }