Commit 96c2a5fe authored by Sam's avatar Sam

FINAL VERSION

parent f80338d9
...@@ -22,18 +22,16 @@ import androidx.fragment.app.DialogFragment; ...@@ -22,18 +22,16 @@ import androidx.fragment.app.DialogFragment;
import com.example.museumworld.R; import com.example.museumworld.R;
import com.example.museumworld.cafe_shop.cafe_activity; import com.example.museumworld.cafe_shop.cafe_activity;
import com.example.museumworld.checkout.Receipt;
import com.example.museumworld.details.MuseumDetails; import com.example.museumworld.details.MuseumDetails;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class booking extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener, DatePickerDialog.OnDateSetListener { public class booking extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener, DatePickerDialog.OnDateSetListener {
public static String dateSelected, timeSelected; public static String dateSelectedDatabase, timeSelected,dateSelectedReceipt;
private ImageView top_img; private ImageView top_img;
private Spinner spinner; private Spinner spinner;
private TextView date_Text, next_btn; private TextView date_Text, next_btn;
...@@ -58,6 +56,7 @@ public class booking extends AppCompatActivity implements View.OnClickListener, ...@@ -58,6 +56,7 @@ public class booking extends AppCompatActivity implements View.OnClickListener,
calendar_icon = findViewById(R.id.calendar_icon); calendar_icon = findViewById(R.id.calendar_icon);
calendar_icon.setOnClickListener(this); calendar_icon.setOnClickListener(this);
date_Text = findViewById(R.id.date_Text); date_Text = findViewById(R.id.date_Text);
date_Text.setOnClickListener(this);
//SPINNER //SPINNER
String[] times = {"9-11am", "11-1pm", "1-3pm", "3-5pm"}; String[] times = {"9-11am", "11-1pm", "1-3pm", "3-5pm"};
...@@ -75,13 +74,16 @@ public class booking extends AppCompatActivity implements View.OnClickListener, ...@@ -75,13 +74,16 @@ public class booking extends AppCompatActivity implements View.OnClickListener,
@Override @Override
public void onClick(View v) { public void onClick(View v) {
DialogFragment datePick = new DaterPicker();
switch (v.getId()) { switch (v.getId()) {
case R.id.back_arrow_icon: case R.id.back_arrow_icon:
finish(); finish();
break; break;
case R.id.calendar_icon: case R.id.calendar_icon:
DialogFragment datePick = new DaterPicker();
case R.id.date_Text:
datePick.show(getSupportFragmentManager(), "Select Date"); datePick.show(getSupportFragmentManager(), "Select Date");
break; break;
...@@ -131,9 +133,10 @@ public class booking extends AppCompatActivity implements View.OnClickListener, ...@@ -131,9 +133,10 @@ public class booking extends AppCompatActivity implements View.OnClickListener,
date_Text.setHint(dateSelected); date_Text.setHint(dateSelected);
this.dateSelected = year + "-" + (month + 1) + "-" + dayOfMonth; this.dateSelectedDatabase = year + "-" + (month + 1) + "-" + dayOfMonth;
this.dateSelectedReceipt = dayOfMonth + "/" + (month + 1) + "/" + year;
Log.d("dateselect", this.dateSelected);
} else { } else {
snackbarAlert("Select a date that is present or in the future", true); snackbarAlert("Select a date that is present or in the future", true);
} }
...@@ -178,7 +181,7 @@ public class booking extends AppCompatActivity implements View.OnClickListener, ...@@ -178,7 +181,7 @@ public class booking extends AppCompatActivity implements View.OnClickListener,
public void OpenDialogBox(String title) { public void OpenDialogBox(String title) {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme);
builder.setTitle(title) builder.setTitle(title)
.setMessage(getString(R.string.bookingConfirm) +" " +MuseumDetails.MuseumName +"\n"+ getString(R.string.bookingConfirm2)+" " + dateSelected + "\n" + getString(R.string.bookingConfirm3) +" "+ spinner.getSelectedItem().toString()) .setMessage(getString(R.string.bookingConfirm) +" " +MuseumDetails.MuseumName +"\n"+ getString(R.string.bookingConfirm2)+" " + dateSelectedReceipt + "\n" + getString(R.string.bookingConfirm3) +" "+ spinner.getSelectedItem().toString())
.setPositiveButton(getResources().getString(R.string.yes), (dialog, which) -> { .setPositiveButton(getResources().getString(R.string.yes), (dialog, which) -> {
switch (spinner.getSelectedItem().toString()) { switch (spinner.getSelectedItem().toString()) {
......
...@@ -155,7 +155,7 @@ public class Receipt extends AppCompatActivity implements View.OnClickListener { ...@@ -155,7 +155,7 @@ public class Receipt extends AppCompatActivity implements View.OnClickListener {
ArrayList<String> detailInfo = getIntent().getStringArrayListExtra("detailVariables"); ArrayList<String> detailInfo = getIntent().getStringArrayListExtra("detailVariables");
customerName_text.setText(MainActivity.FirstnameG + " " + MainActivity.LastnameG); customerName_text.setText(MainActivity.FirstnameG + " " + MainActivity.LastnameG);
Museum_text.setText(MuseumDetails.MuseumName); Museum_text.setText(MuseumDetails.MuseumName);
Date_text.setText(booking.dateSelected); Date_text.setText(booking.dateSelectedReceipt);
Time_text.setText(booking.timeSelected); Time_text.setText(booking.timeSelected);
totalCost_text.setText("£" + detailInfo.get(0) + ".00"); totalCost_text.setText("£" + detailInfo.get(0) + ".00");
amountEntered_text.setText("£" + detailInfo.get(1) + "0"); amountEntered_text.setText("£" + detailInfo.get(1) + "0");
...@@ -212,7 +212,7 @@ public class Receipt extends AppCompatActivity implements View.OnClickListener { ...@@ -212,7 +212,7 @@ public class Receipt extends AppCompatActivity implements View.OnClickListener {
jsonAllDetails = new JSONObject(); jsonAllDetails = new JSONObject();
jsonAllDetails.putOpt("museumName", MuseumDetails.MuseumName); jsonAllDetails.putOpt("museumName", MuseumDetails.MuseumName);
jsonAllDetails.put("dateSelected", booking.dateSelected); jsonAllDetails.put("dateSelected", booking.dateSelectedReceipt);
jsonAllDetails.put("timeSelected", booking.timeSelected); jsonAllDetails.put("timeSelected", booking.timeSelected);
jsonAllDetails.put("totalCost", totalCost_text.getText().toString().replaceAll("£", "&amp;pound;")); jsonAllDetails.put("totalCost", totalCost_text.getText().toString().replaceAll("£", "&amp;pound;"));
jsonAllDetails.put("amountEntered", amountEntered_text.getText().toString().replaceAll("£", "&amp;pound;")); jsonAllDetails.put("amountEntered", amountEntered_text.getText().toString().replaceAll("£", "&amp;pound;"));
......
...@@ -216,7 +216,7 @@ public class checkout extends AppCompatActivity implements View.OnClickListener ...@@ -216,7 +216,7 @@ public class checkout extends AppCompatActivity implements View.OnClickListener
data.put("bookingID", String.valueOf(bookingID)); data.put("bookingID", String.valueOf(bookingID));
data.put("museumID", String.valueOf(MuseumDetails.MuseumID)); data.put("museumID", String.valueOf(MuseumDetails.MuseumID));
data.put("numberOfItems", String.valueOf(TotalnumberOfItems)); data.put("numberOfItems", String.valueOf(TotalnumberOfItems));
data.put("bookedDate", booking.dateSelected); data.put("bookedDate", booking.dateSelectedDatabase);
data.put("bookedTime", booking.timeSelected); data.put("bookedTime", booking.timeSelected);
data.put("totalCost", String.valueOf(totalOfCheckout)); data.put("totalCost", String.valueOf(totalOfCheckout));
data.put("userEntered", String.valueOf(money_EditText.getText())); data.put("userEntered", String.valueOf(money_EditText.getText()));
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<string name="register_username_contain">*Username cannot contain your first or last name</string> <string name="register_username_contain">*Username cannot contain your first or last name</string>
<string name="reister_password">*Password has to be at least 7 characters long</string> <string name="reister_password">*Password has to be at least 7 characters long</string>
<string name="reister_password2">*Passwords do not match</string> <string name="reister_password2">*Passwords do not match</string>
<string name="date_goes_here">Date goes here</string> <string name="date_goes_here">Date Displays Here</string>
<string name="world_museums">World Museums</string> <string name="world_museums">World Museums</string>
......
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