2020-02-01 15:48:06
package com.xbsaykat.easy24vendorapp;
 
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
 
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
 
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.xbsaykat.easy24vendorapp.DailyReport.ModelClass;
import com.xbsaykat.easy24vendorapp.DailyReport.ReportDaily;
import com.xbsaykat.easy24vendorapp.DailyReport.ViewClass;
import com.xbsaykat.easy24vendorapp.MonthlyReport.ReportMonthly;
 
import java.util.ArrayList;
 
public class ReportActivaty extends AppCompatActivity {
    TextView textViewTeg,Report_daily,Report_monthly,Report_year;
    ImageView Img1;
    String date, month,year;
    ArrayList<String> arrayList = new ArrayList<>();
    ArrayList<String> arrayListMonth = new ArrayList<>();
    ArrayList<String> arrayListYear = new ArrayList<>();
    int totalallpricevalue=0;
    int totalallpricevalueonthly=0;
    int totalallpricevalueyear=0;
    private FirebaseDatabase mFirebaseDatabase;
    private DatabaseReference mRefAmountDaily,mRefAmountMonthly,mRefAmountYearly;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.approve);
 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimary, this.getTheme()));
        } else {
            View decorView = getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(uiOptions);
        }
        date= String.valueOf(android.text.format.DateFormat.format("dd-MM-yyyy", new java.util.Date()));
        month = String.valueOf(android.text.format.DateFormat.format("MM-yyyy", new java.util.Date()));
        year = String.valueOf(android.text.format.DateFormat.format("yyyy", new java.util.Date()));
 
        textViewTeg=findViewById(R.id.teg);
        Report_daily=findViewById(R.id.dailyreport);
        Report_monthly=findViewById(R.id.monthlyreport);
        Report_year=findViewById(R.id.yearlyreport);
 
        Report_daily.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(ReportActivaty.this, ReportDaily.class);
                for(String price:arrayList){
                    int convert= Integer.parseInt(price);
                    totalallpricevalue+=convert;
                }
                mRefAmountDaily= FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportDailyAmount").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(date);
                mRefAmountDaily.child("TotalCalculation").setValue(String.valueOf(totalallpricevalue));
 
                startActivity(intent);
                finish();
            }
        });
        Report_monthly.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(ReportActivaty.this, ReportMonthly.class);
                for(String price:arrayListMonth){
                    int convert= Integer.parseInt(price);
                    totalallpricevalueonthly+=convert;
                }
                mRefAmountMonthly= FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportMonthlyAmount").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(month);
                mRefAmountMonthly.child("TotalCalculation").setValue(String.valueOf(totalallpricevalueonthly));
 
                startActivity(intent);
                finish();
            }
        });
        Report_year.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(ReportActivaty.this, ReportYearly.class);
                for(String price:arrayListYear){
                    int convert= Integer.parseInt(price);
                    totalallpricevalueyear+=convert;
                }
                mRefAmountYearly= FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportYearlyAmount").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(year);
                mRefAmountYearly.child("TotalCalculation").setValue(String.valueOf(totalallpricevalueyear));
 
                startActivity(intent);
                finish();
            }
        });
 
    }
    @Override
    protected void onStart() {
        super.onStart();
        DatabaseReference mRef = FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportDaily").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(date);
        mRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for(DataSnapshot dataSnapshot1:dataSnapshot.getChildren()){
                    try{
                        String Amount= dataSnapshot1.child("Moneyrequest").getValue().toString();
                        arrayList.add(Amount);
                    }catch (Exception io){
                    }
                }
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
 
        DatabaseReference mRefMonth = FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportMonthly").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(month);
        mRefMonth.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for(DataSnapshot dataSnapshot1:dataSnapshot.getChildren()){
                    try{
                        String Amount= dataSnapshot1.child("Moneyrequest").getValue().toString();
                        arrayListMonth.add(Amount);
                    }catch (Exception io){
                    }
                }
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
        DatabaseReference mRefYear= FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportYearly").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(year);
        mRefYear.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for(DataSnapshot dataSnapshot1:dataSnapshot.getChildren()){
                    try{
                        String Amount= dataSnapshot1.child("Moneyrequest").getValue().toString();
                        arrayListYear.add(Amount);
                    }catch (Exception io){
                    }
                }
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    }
}
 
Invalid Email or Password