Search in sources :

Example 1 with SalesReport

use of com.example.asus.onlinecanteen.model.SalesReport in project OnlineCanteen by josephgunawan97.

the class MerchantSettingsActivity method generateReport.

public void generateReport() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.salesReport_confirmation).setCancelable(false).setPositiveButton(R.string.salesReport_confirm, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            database = FirebaseDatabase.getInstance().getReference("salesreportrequest");
            SalesReport salesReport = new SalesReport(merchant.getUid());
            database.push().setValue(salesReport);
            Toast.makeText(MerchantSettingsActivity.this, R.string.salesReport_reply, Toast.LENGTH_SHORT).show();
        }
    }).setNegativeButton(R.string.salesReport_cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.setTitle(R.string.salesReport_title);
    alert.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SalesReport(com.example.asus.onlinecanteen.model.SalesReport)

Example 2 with SalesReport

use of com.example.asus.onlinecanteen.model.SalesReport in project OnlineCanteen by josephgunawan97.

the class AdminSalesReportsListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_admin_sales_reports_list);
    getSupportActionBar().setTitle("Send Sales Report");
    reportReqs = new ArrayList<SalesReport>();
    adapter = new SalesReportAdapter(reportReqs);
    recyclerView = findViewById(R.id.list);
    layoutManager = new LinearLayoutManager(this);
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) SalesReport(com.example.asus.onlinecanteen.model.SalesReport) SalesReportAdapter(com.example.asus.onlinecanteen.adapter.SalesReportAdapter)

Example 3 with SalesReport

use of com.example.asus.onlinecanteen.model.SalesReport in project OnlineCanteen by josephgunawan97.

the class AdminSalesReportsListActivity method attachDatabaseReadListener.

private void attachDatabaseReadListener() {
    if (EventListener == null) {
        EventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                SalesReport salesReport = dataSnapshot.getValue(SalesReport.class);
                adapter.addSalesReport(salesReport);
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        };
        SalesReportUtil.query().addChildEventListener(EventListener);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) DataSnapshot(com.google.firebase.database.DataSnapshot) SalesReport(com.example.asus.onlinecanteen.model.SalesReport) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 4 with SalesReport

use of com.example.asus.onlinecanteen.model.SalesReport in project OnlineCanteen by josephgunawan97.

the class SalesReportAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    // Get sales report
    final SalesReport salesReport = salesReportHistory.get(position);
    FirebaseDatabase.getInstance().getReference("store").child(salesReport.getUid()).addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            holder.storeName.setText(dataSnapshot.child("storeName").getValue().toString());
            holder.storeEmail = dataSnapshot.child("email").getValue().toString();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    holder.dateReq.setText(salesReport.getRequestDateString(salesReport.getRequestdate()));
    holder.date = salesReport.getRequestdate();
    holder.uid = salesReport.getUid();
    if (salesReport.getRequeststatus().equals(0)) {
        holder.status.setText("Pending");
    } else {
        holder.status.setText("Completed");
        holder.sendButton.setVisibility(View.INVISIBLE);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot) SalesReport(com.example.asus.onlinecanteen.model.SalesReport)

Aggregations

SalesReport (com.example.asus.onlinecanteen.model.SalesReport)4 DataSnapshot (com.google.firebase.database.DataSnapshot)2 DatabaseError (com.google.firebase.database.DatabaseError)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 SalesReportAdapter (com.example.asus.onlinecanteen.adapter.SalesReportAdapter)1 ChildEventListener (com.google.firebase.database.ChildEventListener)1 ValueEventListener (com.google.firebase.database.ValueEventListener)1