Commit e86eb612 authored by Bhavesh Yadav's avatar Bhavesh Yadav

Fixed ticket details, now fetched from firebase

parent d5d40a76
...@@ -12,7 +12,11 @@ import android.widget.LinearLayout; ...@@ -12,7 +12,11 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.lang.reflect.Array;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
public class checkout extends Activity { public class checkout extends Activity {
EditText tkt_no,slot_no; EditText tkt_no,slot_no;
...@@ -139,17 +143,24 @@ public class checkout extends Activity { ...@@ -139,17 +143,24 @@ public class checkout extends Activity {
if(!slotStr.isEmpty()){ if(!slotStr.isEmpty()){
sqlite_ops so=new sqlite_ops(this); sqlite_ops so=new sqlite_ops(this);
ArrayList data=so.fetch_slot_details(slotStr.toUpperCase()); so.fetch_slot_details(slotStr.toUpperCase(),this);
}
}
public void showTicketDetails(ArrayList data) {
name.setText(data.get(4).toString()); name.setText(data.get(4).toString());
slot.setText(data.get(1).toString()); slot.setText(data.get(1).toString());
date_tv.setText(data.get(3).toString()); long datetime = Long.parseLong(data.get(3).toString());
Date date = new Date(datetime*1000);
Format format = new SimpleDateFormat("dd/MM/yy HH:mm");
String dateString = format.format(date);
date_tv.setText(dateString);
vehicle.setText(data.get(2).toString()); vehicle.setText(data.get(2).toString());
mobile.setText(data.get(5).toString()); mobile.setText(data.get(5).toString());
tkt_tv.setText(data.get(0).toString()); tkt_tv.setText(data.get(0).toString().toUpperCase().substring(0,4));
slot_number=data.get(1).toString(); slot_number=data.get(1).toString();
ticket_number=data.get(0).toString(); ticket_number=data.get(0).toString();
innerll.setVisibility(View.VISIBLE); innerll.setVisibility(View.VISIBLE);
} }
}
} }
...@@ -20,6 +20,7 @@ import com.google.firebase.firestore.Query; ...@@ -20,6 +20,7 @@ import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot; import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot; import com.google.firebase.firestore.QuerySnapshot;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
...@@ -344,7 +345,7 @@ public class sqlite_ops extends SQLiteOpenHelper{ ...@@ -344,7 +345,7 @@ public class sqlite_ops extends SQLiteOpenHelper{
public ArrayList fetch_ticket_detail(long ticket){ public ArrayList fetch_ticket_detail(long ticket){
ArrayList al=new ArrayList(); ArrayList al=new ArrayList();
SQLiteDatabase db=this.getWritableDatabase(); SQLiteDatabase db=this.getWritableDatabase();
Cursor cr=db.query("records",new String []{"name","mobile","tkt_no","slot","vehicle","check_in","isempty"},"tkt_no=?",new String[]{Long.toString(ticket)},null,null,null,null); Cursor cr=db.query("records",new 'String []{"name","mobile","tkt_no","slot","vehicle","check_in","isempty"},"tkt_no=?",new String[]{Long.toString(ticket)},null,null,null,null);
if(cr!=null){ if(cr!=null){
cr.moveToFirst(); cr.moveToFirst();
if(cr.getCount()>0){ if(cr.getCount()>0){
...@@ -373,37 +374,66 @@ public class sqlite_ops extends SQLiteOpenHelper{ ...@@ -373,37 +374,66 @@ public class sqlite_ops extends SQLiteOpenHelper{
db.close(); db.close();
return al; return al;
} }
public ArrayList fetch_slot_details(String slot){ public void fetch_slot_details(String slot,final checkout co){
ArrayList al=new ArrayList(); // ArrayList al=new ArrayList();
SQLiteDatabase db=this.getWritableDatabase(); // SQLiteDatabase db=this.getWritableDatabase();
Cursor cr=db.query("records",new String []{"name","mobile","tkt_no","slot","vehicle","check_in","isempty"},"slot=? and isempty=?",new String[]{slot,"0"},null,null,null,null); // Cursor cr=db.query("records",new String []{"name","mobile","tkt_no","slot","vehicle","check_in","isempty"},"slot=? and isempty=?",new String[]{slot,"0"},null,null,null,null);
if(cr!=null){ // if(cr!=null){
cr.moveToFirst(); // cr.moveToFirst();
if(cr.getCount()>0){ // if(cr.getCount()>0){
al.add(0,cr.getString(cr.getColumnIndex("tkt_no"))); // al.add(0,cr.getString(cr.getColumnIndex("tkt_no")));
al.add(1,cr.getString(cr.getColumnIndex("slot"))); // al.add(1,cr.getString(cr.getColumnIndex("slot")));
al.add(2,cr.getString(cr.getColumnIndex("vehicle"))); // al.add(2,cr.getString(cr.getColumnIndex("vehicle")));
al.add(3,cr.getString(cr.getColumnIndex("check_in"))); // al.add(3,cr.getString(cr.getColumnIndex("check_in")));
al.add(4,cr.getString(cr.getColumnIndex("name"))); // al.add(4,cr.getString(cr.getColumnIndex("name")));
al.add(5,cr.getString(cr.getColumnIndex("mobile"))); // al.add(5,cr.getString(cr.getColumnIndex("mobile")));
al.add(6,cr.getString(cr.getColumnIndex("isempty"))); // al.add(6,cr.getString(cr.getColumnIndex("isempty")));
//
//
// }
// else{
// al.add("none");
// al.add("none");
// al.add("none");
// al.add("none");
// al.add("none");
// al.add("none");
// al.add("0");
//
// }
//
// }
// db.close();
fdb = FirebaseFirestore.getInstance();
fdb.collection("records").whereEqualTo("uname",userInfo.getInstance().getName())
.whereEqualTo("status",1)
.whereEqualTo("slot",slot).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()) {
ArrayList al = new ArrayList();
for (QueryDocumentSnapshot document : task.getResult()) {
// slots.add(document);
// ArrayList al = new ArrayList();
al.add(0,document.getId());
al.add(1,document.getData().get("slot"));
al.add(2,document.getData().get("vehicle"));
al.add(3,document.getData().get("checkInTimeDate"));
al.add(4,document.getData().get("name"));
al.add(5,document.getData().get("mobile"));
al.add(6,document.getData().get("status"));
Log.d("Ticket","getting slot ticket"+document.getData().toString());
}
co.showTicketDetails(al);
return;
} }
else{ else {
al.add("none"); Log.d("Checkin","slot update failed");
al.add("none");
al.add("none");
al.add("none");
al.add("none");
al.add("none");
al.add("0");
} }
} }
db.close(); });
return al;
} }
public boolean check_out(String slot,Long tkt){ public boolean check_out(String slot,Long tkt){
SQLiteDatabase db= this.getWritableDatabase(); SQLiteDatabase db= this.getWritableDatabase();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment