def get_all_employees(self): """Reads the Crew CSV file and returns a list whith all employees sorted by they're liecence """ all_employee_list = [] NAFokkerF100_list = [] NABAE146_list = [] NAFokkerF28_list = [] N_A_list = [] final_list = [] with open("./DATA/Crew.csv", "r", newline="") as all_crew: reader = csv.DictReader(all_crew) for line in reader: crew = Employee(line["ssn"], line["name"], line["address"], line["home_phone"], line["mobile_phone"], line["email_address"], line["role"], line["rank"], line["licence"], line["active"]) all_employee_list.append( crew ) #Creates a employee class for each employee and appends it to a list for employee in all_employee_list: if employee.get_licence() == 'NAFokkerF100': NAFokkerF100_list.append(employee) elif employee.get_licence() == 'NABAE146': NABAE146_list.append(employee) elif employee.get_licence() == 'NAFokkerF28': NAFokkerF28_list.append(employee) elif employee.get_licence() == 'N/A': N_A_list.append(employee) final_list.extend(NAFokkerF100_list) #adds all the lists together final_list.extend(NABAE146_list) final_list.extend(NAFokkerF28_list) final_list.extend(N_A_list) return final_list
def get_start_staff(): start_staff = Staff() employee = Employee("Дорофеев", "Валентин", "Игоревич", datetime.date(2000, 2, 17), "Администратор", 500, "komilfo", "1312", True, False, True, False, True, False) start_staff.recruit(employee) return start_staff
def add_employee(self): employee = Employee(self.ui.surnameEdit.currentText(), self.ui.nameEdit.text(), self.ui.patronymicEdit.text(), self.ui.birthDateEdit.date(), self.ui.positionEdit, self.ui.salaryEdit, self.ui.loginEdit, self.ui.passwordEdit, self.ui.menuAccess.isChecked(), self.ui.menuReadonly.isChecked(), self.ui.staffAccess.isChecked(), self.ui.staffReadonly.isChecked(), self.ui.ordersAccess.isChecked(), self.ui.ordersReadonly.isChecked()) DB.add_employee(employee) self.open_administration_page()
def __init__(self): self.instance_list = [] list( map( lambda employee: self.instance_list.append( Employee(employee['id'], employee['employee_full_name'], employee['in_work'], employee['out_work'], employee['bonus_code'], employee['base_salary'])), Employees))
def add_employee(self): add_menu = [" ", "Provide employee info:", "name", "surname", "salary", "rec_date", "position", "mark"] for e in add_menu: print(e) tmpEmp = Employee() tmpEmp.emp_id = "1" tmpEmp.name = input() tmpEmp.surname = input() tmpEmp.salary = input() tmpEmp.rec_date = input() tmpEmp.position = input() tmpEmp.mark = input() self.list.append(tmpEmp)
def get_all_employees_dict(self): """Reads the Crew CSV file and returns a dictionary whith all employees and the key is their ssn""" all_employee_dict = {} with open("./DATA/Crew.csv", "r", newline="") as all_crew: reader = csv.DictReader(all_crew) for line in reader: emp = Employee(line["ssn"], line["name"], line["address"], line["home_phone"], line["mobile_phone"], line["email_address"], line["role"], line["rank"], line["licence"], line["active"]) all_employee_dict[line["ssn"]] = emp return all_employee_dict
def get_staff(): collection = dbHandler.db["staff"].find() staff = Staff() for employee in collection: staff.recruit( Employee(employee["surname"], employee["name"], employee["patronymic"], employee["birth_date"], employee["position"], employee["salary"], employee["login"], employee["password"], employee["menu_access"], employee["menu_readonly"], employee["staff_access"], employee["staff_readonly"], employee["orders_access"], employee["orders_readonly"])) return staff
def employee(): """Returns employee with random data in it from Dummy()""" return Employee( D.make_name(), D.make_address(), D.make_postal_code(), D.make_ssn(), D.make_phone(), D.make_phone(), D.make_email(), D.make_title(), D.make_airport_after_title(), D.make_country_after_airport(), )
def readEmployees(): emp_list = [] with open(globals.file_path, mode='r', encoding='utf-8', errors='ignore') as csvfile: reader = csv.DictReader(csvfile) for row in reader: emp = Employee(f'row["emp_id"]', f'row["name"]', f'row["surname"]', f'row["salary"]', f'row["rec_date"]', f'row["position"]', f'row["mark"]') emp_list.append(emp) print(emp_list.count) return emp_list
def login(login, password): account = dbHandler.db["staff"].find_one({ "login": login, "password": password }) if not account: return False dbHandler.account = Employee( account["surname"], account["name"], account["patronymic"], account["birth_date"], account["position"], account["salary"], account["login"], account["password"], account["menu_access"], account["menu_readonly"], account["staff_access"], account["staff_readonly"], account["orders_access"], account["orders_readonly"]) return True
def edit_employee(self): employee = Employee(self.ui.employeeSurnameEdit.text(), self.ui.employeeNameEdit.text(), self.ui.employeePatronymicEdit.text(), self.ui.employeeBirthDateEdit.date(), self.ui.employeePositionEdit, self.ui.employeeSalaryEdit, self.ui.employeeLoginEdit, self.ui.employeePasswordEdit, self.ui.menuCheckBox.isChecked(), self.ui.menuReadOnlyCheckBox.isChecked(), self.ui.employeesReadOnlyCheckBox.isChecked(), self.ui.employeesReadOnlyCheckBox.isChecked(), self.ui.ordersCheckBox.isChecked(), self.ui.ordersReadOnlyCheckBox.isChecked()) self.delete_employee() DB.add_employee(employee) self.staff.recruit(employee) self.show_staff()
def __init__(self, lapi, ui): self.logicAPI = lapi self.ui = ui self.verify = Input_Verifiers(lapi) # Get the number of required parameters to the init method of the class self.contract = [ Contract( *[None for i in range(len(signature(Contract).parameters))]), lapi.contract ] self.customer = [ Customer( *[None for i in range(len(signature(Customer).parameters))]), lapi.customer ] self.destination = [ Destination( *[None for i in range(len(signature(Destination).parameters))]), lapi.destination ] self.employee = [ Employee( *[None for i in range(len(signature(Employee).parameters))]), lapi.employee ] self.vehicle = [ Vehicle(*[None for i in range(len(signature(Vehicle).parameters))]), lapi.vehicle ] self.vehicle_type = [ Vehicle_Type( * [None for i in range(len(signature(Vehicle_Type).parameters))]), lapi.vehicle_type ] self.display = Display()
def add_employee(self): '''The method will add new employee to the Crew.csv file. User have to input SSN number, Name, Adress, Home and Mobile number, Email and chose role and rank for the employee. If pilot is chosen then the user has to enter a licence number for the aircraft that he is allowed to fly. ''' self.app.print_create_employee() plane_list = [] role_list = ["Pilot", "Cabincrew"] pilot_rank_list = ["Captain", "Copilot"] cabincrew_rank_list = ["Flight Service Manager", "Flight Attendant"] emp = Employee() employee_list = self.ll.get_all_employees() emp.set_ssn( self.ll.validate_already_emp(input("SSN number: "), employee_list)) emp.set_name(self.ll.validate_name(input("Name: "))) emp.set_address(self.ll.validate_home(input("Adress: "))) emp.set_home_phone(self.ll.validate_phone_number( input("Home phone: "))) emp.set_mobile_number( self.ll.validate_phone_number(input("Mobile number: "))) emp.set_email_address(self.ll.validate_email(input("Email: "))) print("Role: ") self.app.print_selection_list(role_list) role_input = input("Select a role: ") role_selection = self.ll.validate_selection(role_input, 2) for role_index in range(len(role_list)): if role_selection == str(role_index + 1) and int(role_selection) == 1: role_selection = role_list[role_index] selected_rank_list = pilot_rank_list elif role_selection == str(role_index + 1) and int(role_selection) == 2: role_selection = role_list[role_index] selected_rank_list = cabincrew_rank_list emp.set_role(role_selection) self.app.print_selection_list(selected_rank_list) rank_input = input("select a rank: ") rank_selection = self.ll.validate_selection(rank_input, 2) if role_selection == "Cabincrew": if rank_selection == "1": rank_selection = "Flight Service Manager" elif rank_selection == "2": rank_selection = "Flight Attendant" elif role_selection == "Pilot": if rank_selection == "1": rank_selection = "Captain" elif rank_selection == "2": rank_selection = "Copilot" emp.set_rank(rank_selection) airplane_obj = self.ll.get_all_airplanes() for index in range(len(airplane_obj)): plane = airplane_obj[index] plane_type = plane.get_planeID() if plane_type not in plane_list: plane_list.append(plane_type) if role_selection == "Cabincrew": plane_selection = "N/A" elif role_selection == "Pilot": self.app.print_selection_list(plane_list) plane_selection = self.ll.validate_selection( input("Select a licence: "), len(plane_list)) for selected_numb in range(len(plane_list)): if plane_selection == str(selected_numb + 1): plane_selection = plane_list[selected_numb] emp.set_licence(plane_selection) emp.set_activity(1) self.ll.add_employee(emp) print("\nYou have created a new employee\n")
def edit(self, form, id): """Passes an edited employee through a form editor before passing it onto the data API""" new_form = employee_editor(form) new_employee = Employee(**new_form) self.dataAPI.edit_employee(new_employee, id)
def register(self, form): """Passes a new employee through a form filler before passing it onto the data API""" new_form = employee_filler(form) new_employee = Employee(**new_form) self.dataAPI.append_employee(new_employee)
def viewList(self): print("[emp_id]\t[name]\t[surname]\t[salary]\t[rec_date]\t[position]\t[mark]") emp = Employee() for emp in self.list: print(emp.printEmp())