I have a booking application. So I have a table called description where a company can add their informations. Second table is called booking, and in this table, people can make a booking to one of the company informations.
Table description:
- company_id Auto-Increment
- companytitle Text
- jobtitle Text
- description Text
- startDate Text
- endDate text
Table bookings:
- id Auto-Increment
- companytitle Text In this field, when you make a booking, it will display the company name of the company
- name Text
- surname Text - Your surname
- date Text - the date when you can make a booking
- company_booking_id - Here, when you make a booking you have an ID, that will be the FK of the companyid that is in the first table.
Php script:
"insert into bookings (companytitle, name, surname, date, company_booking_id) values ('$companytitle','$name', '$surname', '$date','$company_booking_id' )";
Now, lets say you are logging in as a User, you have a customLayout with the informations that every company has put, you choose one company, how can you make a booking to that specific company ? How the app will know for which company you made a booking ?
Exemple: First company
- Company Title - X
- Company Description - Selling carrots
- Start Date - 20 july 9:00 PM
- End Date - 21 july 9:00 pm
Second company:
- Company Title - Y
- Company Description - Selling potatoes
- Start Date - 20 july 9:00 PM
- End Date - 21 july 9:00 pm
These are 2 different companies, I'm logging in as a user and I want to make a booking to one of these, how the app will know for which company I made the booking ? :D
BookingAddClass:
> public class BookingAdd {
> String companytitle;
> String name;
> String surname;
> String data;
>
> public BookingAdd(){}
>
> public BookingAdd(String companytitle, String name, String surname, String date) {
> this.companytitle = companytitle;
> this.nume = nume;
> this.prenume = prenume;
> this.data = data;
> }
>
> public String getCompanytitle() {
> return companytitle;
> }
>
> public void setCompanytitle(String companytitle) {
> this.companytitle = companytitle;
> }
>
> public String getNume() {
> return nume;
> }
>
> public void setNume(String nume) {
> this.nume = nume;
> }
>
> public String getName() {
> return name;
> }
>
> public void setSurname(String surname) {
> this.surname = surname;
> }
>
> public String getData() {
> return data;
> }
>
> public void setData(String data) {
> this.data = data;
> } }
Every user when is making an account has to complete their personal info.
> public class BookingsAdapter extends BaseAdapter {
> Context c;
> ArrayList<CompanyData> informations = new ArrayList<>();
> LayoutInflater inflater;
> Button makeABooking;
>
> public Button getMakeABooking() {
> return makeABooking;
> }
>
> public void setMakeABooking(Button makeABooking) {
> this.makeABooking = makeABooking;
> }
>
> public BookingsAdapter(Context c, ArrayList<CompanyData> informations) {
> this.c = c;
> this.informations = informations;
> inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
> }
>
> public BookingsAdapter() {
> super();
> }
>
> @Override
> public int getCount() {
> return informations.size();
> }
>
> @Override
> public Object getItem(int i) {
> return informations.get(i);
> }
>
> @Override
> public long getItemId(int i) {
> return i;
> }
>
> @Override
> public View getView(int i, View view, ViewGroup viewGroup) {
> CompanyData companyData = informations.get(i);
>
> if(view == null) {
> inflater = (LayoutInflater) c.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
> view = inflater.inflate(R.layout.bookingslayout, null);
> }
> // ImageView logo = (ImageView)view.findViewById(R.id.logoImageView);
> TextView title = (TextView) view.findViewById(R.id.companyTitletextview);
> TextView description = (TextView) view.findViewById(R.id.companyDescriptiontextview);
> TextView startDate = (TextView) view.findViewById(R.id.textviewstart);
> TextView endDate = (TextView) view.findViewById(R.id.textviewend);
>
> title.setText(companyData.getTitle());
> description.setText(companyData.getDescription());
> startDate.setText(companyData.getStartDate());
> endDate.setText(companyData.getEndDate());
>
>
> return view;
>
>
> }
>
> @Override
> public CharSequence[] getAutofillOptions() {
> return new CharSequence[0];
}
}
Layout with the listview, I dont have any special info in it at the moment..
> public class Bookings extends AppCompatActivity {
> ListView listView;
> final static String urlAdress = "http://localhost/bookingslist.php";
>
> public void makebookingbutton(View view){
> BookingAdd addbooking = new BookingAdd();
> //add the booking
> Toast.makeText(Bookings.this, "Test", Toast.LENGTH_SHORT).show();
> }
>
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_bookings);
> listView = (ListView)findViewById(R.id.listView1);
>
> BookingsDownloader downloader = new BookingsDownloader(Bookings.this,urlAdress,listView);
> downloader.execute();
> } }