def askTaskInfo(self): availableTasks = AvailableTask() availableTasks.getAllAvailableTasks() print("Select task to be executed: ") printer = Printer() printer.addPrintingObject("ID", True, 3) printer.addPrintingObject("Name", True, 30) printer.addPrintingObject("Description", True, 30) printer.printHeader() tasks = availableTasks.getAllAvailableTasks() for key in tasks: task = tasks[key] print(printer.formatValue(0, key) + printer.formatValue(1, task.name) + printer.formatValue(2, task.description)) return availableTasks.getAvailableTask(int(input("Please enter task's ID: ")))
def listAppoitmentByCustomer(self): customer = self.askCustomerInfo(False) while (customer == None): customer = self.askCustomerInfo(False) clientAppoitments = [n for n in self.repository.appointments if n.customer.cpf == customer.cpf] order = int(input("Enter the order for the report\n1.Task code\n2.Date\n3.Task name\n")) if (order == 1): sortedAppoitments = sorted(clientAppoitments, key=lambda x: x.task.code, reverse=False) elif (order == 2): sortedAppoitments = sorted(clientAppoitments, key=lambda x: x.date, reverse=False) elif (order == 3): sortedAppoitments = sorted(clientAppoitments, key=lambda x: x.task.name, reverse=False) printer = Printer() printer.addPrintingObject("Date", True, 10) printer.addPrintingObject("Hour", True, 4) printer.addPrintingObject("Employee's name", True, 25) printer.addPrintingObject("Customers's name", True, 25) printer.addPrintingObject("Vehicle's model", True, 25) printer.addPrintingObject("Status", True, 25) printer.addPrintingObject("Task", True, 25) printer.printHeader() for appointment in sortedAppoitments: print(printer.formatValue(0, appointment.date) + printer.formatValue(1, appointment.dateHour) + printer.formatValue(2, appointment.employee.name) + printer.formatValue(3, appointment.customer.name) + printer.formatValue(4, appointment.vehicle.model) + printer.formatValue(5, appointment.status) + printer.formatValue(6, appointment.task.name))