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();
}
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);
}
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);
}
}
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);
}
}
Aggregations