Ejemplo n.º 1
0
def deleteView(context, args, mid):
    if args == "Booking":
        BookingController.remove(mid)
    elif args == "Fees":
        FeesController.remove(mid)
    elif args == "Field":
        FieldController.remove(mid)
    elif args == "Member":
        MemberController.remove(mid)
    elif args == "Schedule":
        ScheduleController.remove(mid)
    elif args == "Session":
        SessionController.remove(mid)
    context.destroy()
    masterView(args)
Ejemplo n.º 2
0
 def updateValidation(value):
     if value is None:
         toast("Field empty")
     else:
         if args == "Booking":
             BookingController.update(mid, value)
         elif args == "Fees":
             FeesController.update(mid, value)
         elif args == "Field":
             FieldController.update(mid, value)
         elif args == "Member":
             MemberController.update(mid, value)
         elif args == "Schedule":
             ScheduleController.update(mid, value)
         elif args == "Session":
             SessionController.update(mid, value)
Ejemplo n.º 3
0
 def loadData():
     list_box.delete(0, END)
     for booking in BookingController.get()['booking']:
         list_box.insert(
             int(booking['id']), booking['id'] + '.field: ' +
             str(FieldController.read(booking['field_id'])['name']) +
             '.schedule: ' +
             str(ScheduleController.read(booking['schedule_id'])['date']) +
             '.session: ' +
             str(SessionController.read(booking['session_id'])['time']) +
             '.user_id: ' + booking['user_id'] + '.booking_time: ' +
             booking['booking_time'] + '.status: ' + booking['status'])
Ejemplo n.º 4
0
 def payment_confirmation():
     rate = FeesController.read('1')['rate']
     payment_view = Toplevel()
     payment_view.title('Payment')
     detail = 'Payment for:\n'
     for item in loadedBooking:
         detail += 'Booking id: ' + str(item['id']) +\
                   ' Field: ' + str(FieldController.read(item['field_id'])['name']) +\
                   ' Schedule: ' + str(ScheduleController.read(item['schedule_id'])['date']) +\
                   ' Session: ' + str(SessionController.read(item['session_id'])['time']) + '\n'
     Label(payment_view, text=detail).pack()
     Label(payment_view,
           text='Total price : ' +
           str(int(rate) * len(loadedBooking))).pack()
     Button(payment_view, text='Pay',
            command=lambda: payment(payment_view)).pack()
Ejemplo n.º 5
0
def masterView(args):
    global selectedItem
    if isLogin:
        view = Toplevel()
        view.title('System')
        list_box = Listbox(view, width=65)
        list_box.grid(row=1, columnspan=2)
        if args == "Booking":
            for data in BookingController.get()['booking']:
                list_box.insert(
                    int(data['id']), data['id'] + '.field_id: ' +
                    data['field_id'] + '.schedule_id: ' + data['schedule_id'] +
                    '.session_id: ' + data['session_id'] + '.user_id: ' +
                    data['user_id'] + '.booking_time: ' + data['booking_time'])
        elif args == "Fees":
            for data in FeesController.get()['fees']:
                list_box.insert(int(data['id']),
                                data['id'] + '.rate: ' + data['rate'])
        elif args == "Field":
            for data in FieldController.get()['field']:
                list_box.insert(int(data['id']),
                                data['id'] + '.name: ' + data['name'])
        elif args == "Member":
            for data in MemberController.get()['member']:
                list_box.insert(int(data['id']),
                                data['id'] + '.name: ' + data['name'])
        elif args == "Schedule":
            for data in ScheduleController.get()['schedule']:
                list_box.insert(int(data['id']),
                                data['id'] + '.date: ' + data['date'])
        elif args == "Session":
            for data in SessionController.get()['session']:
                list_box.insert(int(data['id']),
                                data['id'] + '.time: ' + data['time'])
        list_box.bind('<<ListboxSelect>>', onSelectItem)
        Button(view, text='Create', width=25, command=lambda: createView(view, args)) \
            .grid(row=2, columnspan=2)
        Button(view, text='Update', width=25, command=lambda: updateView(view, args, selectedItem)) \
            .grid(row=4, columnspan=2)
        Button(view, text='Delete', width=25, command=lambda: deleteView(view, args, selectedItem)) \
            .grid(row=5, columnspan=2)
    else:
        toast("Please Login first")
Ejemplo n.º 6
0
 def loadData():
     if selectedMemberItem == 0:
         toast('Please select member first')
     else:
         list_box.delete(0, END)
         loadedBooking.clear()
         for booking in BookingController.get()['booking']:
             if booking['status'] != 'done' and booking[
                     'user_id'] == selectedMemberItem:
                 loadedBooking.append(booking)
                 list_box.insert(
                     int(booking['id']), booking['id'] + '.field: ' +
                     str(FieldController.read(booking['field_id'])['name'])
                     + '.schedule: ' + str(
                         ScheduleController.read(
                             booking['schedule_id'])['date']) +
                     '.session: ' + str(
                         SessionController.read(
                             booking['session_id'])['time']) +
                     '.user_id: ' + booking['user_id'] + '.booking_time: ' +
                     booking['booking_time'])
Ejemplo n.º 7
0
def updateView(context, args, mid):
    view = Toplevel()
    view.title('Edit')
    Label(view, text='Edit Existing Data').grid(row=0, columnspan=2)
    if args == "Booking":
        Label(view, text='field_id').grid(row=1)
        p1 = Entry(view)
        p1.insert(0, BookingController.read(mid)['field_id'])
        p1.grid(row=1, column=1)
        Label(view, text='schedule_id').grid(row=2)
        p2 = Entry(view)
        p2.insert(0, BookingController.read(mid)['schedule_id'])
        p2.grid(row=2, column=1)
        Label(view, text='session_id').grid(row=3)
        p3 = Entry(view)
        p3.insert(0, BookingController.read(mid)['session_id'])
        p3.grid(row=3, column=1)
        Label(view, text='user_id').grid(row=4)
        p4 = Entry(view)
        p4.insert(0, BookingController.read(mid)['user_id'])
        p4.grid(row=4, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(
            p1.get()
            + ' ' + p2.get()
            + ' ' + p3.get()
            + ' ' + p4.get()
            + ' ' + Time.TimeHelper.returnTimeNow())) \
            .grid(row=5, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=6, columnspan=2)
    elif args == "Fees":
        Label(view, text='Rate').grid(row=1)
        p = Entry(view)
        p.insert(0, FeesController.read(mid)['rate'])
        p.grid(row=1, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(p.get())) \
            .grid(row=2, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=3, columnspan=2)
    elif args == "Field":
        Label(view, text='Field').grid(row=1)
        p = Entry(view)
        p.insert(0, FieldController.read(mid)['name'])
        p.grid(row=1, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(p.get())) \
            .grid(row=2, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=3, columnspan=2)
    elif args == "Member":
        Label(view, text='Name').grid(row=1)
        p = Entry(view)
        p.insert(0, MemberController.read(mid)['name'])
        p.grid(row=1, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(p.get())) \
            .grid(row=2, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=3, columnspan=2)
    elif args == "Schedule":
        Label(view, text='Date').grid(row=1)
        p = Entry(view)
        p.insert(0, ScheduleController.read(mid)['date'])
        p.grid(row=1, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(p.get())) \
            .grid(row=2, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=3, columnspan=2)
    elif args == "Session":
        Label(view, text='Time').grid(row=1)
        p = Entry(view)
        p.insert(0, SessionController.read(mid)['time'])
        p.grid(row=1, column=1)
        Button(view, text='Update', width=25, command=lambda: updateValidation(p.get())) \
            .grid(row=2, columnspan=2)
        Button(view, text='Done', width=25,
               command=lambda: done()).grid(row=3, columnspan=2)

    def updateValidation(value):
        if value is None:
            toast("Field empty")
        else:
            if args == "Booking":
                BookingController.update(mid, value)
            elif args == "Fees":
                FeesController.update(mid, value)
            elif args == "Field":
                FieldController.update(mid, value)
            elif args == "Member":
                MemberController.update(mid, value)
            elif args == "Schedule":
                ScheduleController.update(mid, value)
            elif args == "Session":
                SessionController.update(mid, value)

    def done():
        view.destroy()
        context.destroy()
        masterView(args)
Ejemplo n.º 8
0
def bookingView():
    global selectedScheduleItem
    global selectedFieldItem
    global selectedSessionItem
    global selectedMemberItem
    if isLogin:
        view = Toplevel()
        view.title('System')
        schedule_list_box = Listbox(view)
        schedule_list_box.grid(row=1, column=1)
        for data in ScheduleController.get()['schedule']:
            schedule_list_box.insert(int(data['id']),
                                     data['id'] + '.date: ' + data['date'])
        schedule_list_box.bind('<<ListboxSelect>>', onSelectScheduleItem)
        field_list_box = Listbox(view)
        field_list_box.grid(row=1, column=2)
        for data in FieldController.get()['field']:
            field_list_box.insert(int(data['id']),
                                  data['id'] + '.name: ' + data['name'])
        field_list_box.bind('<<ListboxSelect>>', onSelectFieldItem)
        session_list_box = Listbox(view)
        session_list_box.grid(row=2, column=1)
        session_list_box.bind('<<ListboxSelect>>', onSelectSessionItem)
        Button(view, text='Check Session', command=lambda: checkAvailableSession()) \
            .grid(row=3, column=1)
        Button(view, text='Book Session', command=lambda: bookSession()) \
            .grid(row=3, column=2)
        member_list_box = Listbox(view)
        member_list_box.grid(row=2, column=2)
        for data in MemberController.get()['member']:
            member_list_box.insert(int(data['id']),
                                   data['id'] + '.name: ' + data['name'])
        member_list_box.bind('<<ListboxSelect>>', onSelectMemberItem)
    else:
        toast("Please Login first")

    def checkAvailableSession():
        if selectedScheduleItem == 0 and selectedFieldItem == 0:
            toast('Please select item first')
        else:
            taken_session = []
            session_list_box.delete(0, END)
            for b in BookingController.get()['booking']:
                if b['schedule_id'] == selectedScheduleItem and b[
                        'field_id'] == selectedFieldItem:
                    taken_session.append(b['session_id'])
            for session in SessionController.get()['session']:
                if session['id'] not in taken_session:
                    session_list_box.insert(
                        int(session['id']),
                        session['id'] + '.time: ' + session['time'])

    def bookSession():
        if selectedSessionItem == 0:
            toast('Please make sure you have selected session item')
        elif selectedMemberItem == 0:
            toast('Please make sure you have selected member item')
        else:
            booking = str(selectedFieldItem) \
                      + ' ' + str(selectedScheduleItem) \
                      + ' ' + str(selectedSessionItem) \
                      + ' ' + str(selectedMemberItem) \
                      + ' ' + str(Time.TimeHelper.returnTimeNow()) \
                      + ' ' + 'book'
            BookingController.create(booking)
            toast('Session booked')
            checkAvailableSession()
            clearSelection()

    def clearSelection():
        global selectedSessionItem
        selectedSessionItem = 0
        global selectedMemberItem
        selectedMemberItem = 0