コード例 #1
0
 def showEmployee():
     if os.path.exists('./database/employee.json'):
         with open("./database/employee.json") as json_file:
             data = json.load(json_file)
             x = PrettyTable(["Codigo", "Nome"])
             x.align["Codigo"] = "l"
             x.align["Nome"] = "l"
             for employee in data["list"]:
                 employee = Employee(employee["id"])
                 x.add_row([employee.getCode(), employee.getName()]) 
             print(x)
             
             id = int(input('\nDigite o codigo do funcionario que deseja visualizar: '))
             x = PrettyTable(["Codigo", "Nome", "Idade", "Endereço", "Salario"])
             x.align["Codigo"] = "l"
             x.align["Nome"] = "l"
             x.align["Idade"] = "l"
             x.align["Endereço"] = "l"
             x.align["Salario em Reais"] = "l"                
             for employee in data["list"]:
                 if employee["id"] == id:
                     employee = Employee(employee["id"])
                     x.add_row([employee.getCode(), employee.getName(), employee.getAge(), employee.getAddress(), "R$" + str(employee.getSalary())]) 
             os.system("cls")
             print(x)
     else:
         print("Nenhum funcionario registrado")
コード例 #2
0
 def editEmployee():
     if os.path.exists('./database/employee.json'):
         id = int(input("\nDigite o codigo do funcionario que deseja editar: "))
         employee = Employee(id)
         name, age, address, salary = Functions.__employeeInputs(True)
         if name != '':
             employee.setName(name)
         if age != 0:
             employee.setAge(int(age))
         if address != '':
             employee.setAddress(address)
         if salary != 0:
             employee.setSalary(salary)
     else:
         print("Nenhum funcionario registrado")
コード例 #3
0
    def showAllEmployees():
        if os.path.exists('./database/employee.json'):
            with open("./database/employee.json") as json_file:
                data = json.load(json_file)
                x = PrettyTable(["Codigo", "Nome", "Idade", "Endereço", "Salario"])
                x.align["Codigo"] = "l"
                x.align["Nome"] = "l"
                x.align["Idade"] = "l"
                x.align["Endereço"] = "l"
                x.align["Salario em Reais"] = "l"

                for employee in data["list"]:
                    employee = Employee(employee["id"])
                    x.add_row([employee.getCode(), employee.getName(), employee.getAge(), employee.getAddress(), "R$" + str(employee.getSalary())]) 
                print(x)
        else:
            print("Nenhum funcionario registrado")
コード例 #4
0
 def supply_sample_employee(self):
     employer = Company(1, "Bob's Computer Repair",
                        "Fixing computers since 1992!", 4, 100000, 1992,
                        None)
     employee = Employee(1, "Bob", "Smith", "111-22-3333", "111-222-3333",
                         "123 Anywhere Rd.", "Orlando", "FL", "32830",
                         employer, "Network Engineer", 123200.00,
                         ["Network Security, Class 1"])
     return employee
コード例 #5
0
ファイル: arrangement_info.py プロジェクト: BensGith/Resty
def arrangement_info():
    if request.method == "GET":
        # make sure start_date is before end_date
        user_id = 1  # get logged in user's ID
        same_day_scheduling = False  # get this from user
        start_date = "1-1-2020"  # get this from user
        # start_date = str(datetimeHelp.next_weekday(dt.today(), 6)) - date of next Sunday
        end_date = "7-1-2020"  # get this from user
        # end_time = str(datetimeHelp.next_weekday(dt.today(), 12)) - date of next Saturday
        org_id = db.get_org_by_usr(user_id)[0][0]  # get user org_id
        sol_num = db.sol_exists(org_id)  # gets the max sol number from DB
        if sol_num[0]:  # if solution exists in DB
            session["sol"] = sol_num[0] + 1
        else:
            session["sol"] += 1
        raw_employees = db.get_employees_by_date_range(org_id, start_date, end_date)
        employees = Employee.create_from_DB(raw_employees)
        raw_shifts = db.get_shifts_by_date_range(org_id, start_date, end_date)
        shifts = Shift.create_from_DB(raw_shifts)
        raw_workdays = db.get_wdays_by_date_range(org_id, start_date, end_date)
        workdays = WorkDay.create_from_DB(org_id, raw_workdays)

        # add shifts to corresponding days
        for shift in shifts:
            for i in range(len(workdays)):
                if shift.get_date() == workdays[i].get_date():
                    workdays[i].add_shift(shift)

        ww = WorkWeek(workdays)
        dic, sol = ww.create_arrangement(employees, same_day_scheduling)
        employees, shifts = ww.extract_solution(sol)
        mat = Matrix(employees, shifts)
        # dic is a dictionary that maps number of shifts assigned to a employee
        # sol is the actual solved arrangement
        # for example {1:[E1,E2], 2:[E3,E4]..}

        # add arrangement to DB
        # db.register_arrangement(sol, session["sol"])
        #print(WorkWeek.min_shifts_swap(dic,sol))
        # 2: [Employee 5, tom col, dict_keys(['waitress', 'bartender']), Employee 7, itzik shawarma, dict_keys(['waitress']), Employee 8, roni kofif, dict_keys(['waitress', 'bartender'])],
        # 3: [Employee 6, pagi pagi, dict_keys(['waitress', 'bartender']), Employee 4, niv mali, dict_keys(['bartender']), Employee 9, some guy, dict_keys(['waitress']), Employee 1, ben mali, dict_keys(['bartender']), Employee 2, paz mali, dict_keys(['waitress']), Employee 3, rom mali, dict_keys(['bartender'])],
        # 4: [Employee 10, another guy, dict_keys(['bartender', 'waitress'])], 5: [], 6: [], 7: [], 8: [], 9: [], 10: []}]

        #2: [Employee 5, tom col, dict_keys(['waitress', 'bartender']), Employee 7, itzik shawarma, dict_keys(['waitress']), Employee 8, roni kofif, dict_keys(['waitress', 'bartender'])],
        # 3: [Employee 6, pagi pagi, dict_keys(['waitress', 'bartender']), Employee 4, niv mali, dict_keys(['bartender']), Employee 9, some guy, dict_keys(['waitress']), Employee 1, ben mali, dict_keys(['bartender']), Employee 10, another guy, dict_keys(['bartender', 'waitress']), Employee 3, rom mali, dict_keys(['bartender'])],
        # 4: [Employee 2, paz mali, dict_keys(['waitress'])]
        #swap 2 and 10 set 10 to 4 min
        dic, solution = ww.min_shifts_swap(dic, sol)
        js_dict = {}
        for i in range(len(solution)):
            js_dict["shift {}".format(i+1)] = solution[i].get_json()
        return js_dict
    else:
        return render_template("error_page.html")
コード例 #6
0
    wd4 = WorkDay("4-1-2020", "16:00", "Tom")
    wd5 = WorkDay("5-1-2020", "16:00", "Tom")
    wd6 = WorkDay("6-1-2020", "16:00", "Tom")
    wd7 = WorkDay("7-1-2020", "16:00", "Tom")
    wd.add_shift(s1)
    wd.add_shift(s2)
    wd2.add_shift(s3)
    wd2.add_shift(s4)
    wd3.add_shift(s5)
    wd3.add_shift(s6)
    wd4.add_shift(s7)
    wd4.add_shift(s8)
    wd5.add_shift(s9)
    wd5.add_shift(s10)
    wd6.add_shift(s11)
    wd6.add_shift(s12)
    wd7.add_shift(s13)
    wd7.add_shift(s14)
    ww = WorkWeek([wd, wd2, wd3, wd4, wd5, wd6, wd7])
    shifts = Shift.create_from_DB(
        db.get_shifts_by_date_range(1, "2020-01-01", "2020-01-07"))
    t1 = db.get_employees_by_date_range(1, "2020-01-01", "2020-01-07")
    employees = Employee.create_from_DB(
        db.get_employees_by_date_range(1, "2020-01-01", "2020-01-07"))
    mat = Matrix(shifts,
                 employees)  # get employees and shifts AFTER initial solution~

    print(employees)
    print("sd")
    # db.register_arrangement(sol)
コード例 #7
0
ファイル: Mainwindow.py プロジェクト: raikiri24/RFID_MSC_SC
    def register_employee(self):
        self.check_if_empty()

        employee = Employee()
        employee.uid = self.rfid_text.get()
        employee.first_name = self.fname_entry.get()
        employee.middle_name = self.mname_entry.get()
        employee.last_name = self.lname_entry.get()
        employee.age = self.age_entry.get()
        employee.gender = self.gender_var.get()
        employee.address = self.address_entry.get()
        employee.email = self.email_entry.get()
        employee.employee_image = self.image_path_label.cget('text')
        employee.contact_number = self.contact_number_entry.get()
        employee.insert_employee_record()

        self.clear_text()
コード例 #8
0
            # session.pop('_flashes', None)
            # flash("Attendance failed to register")

        if request.method == "GET":
            return render_template("send_hours.html")

        else:
            return render_template("error_page.html")

    except IOError:
        print("Error")


if __name__ == "__main__":

    e1 = Employee(1, 1, {"bartender": 1}, ["01-01-2020", "07-01-2020", "03-01-2020"])
    e2 = Employee(2, 2, {"waitress": 1}, ["01-01-2020", "02-01-2020", "04-01-2020", "07-01-2020"])
    e3 = Employee(3, 3, {"bartender": 1}, ["01-01-2020", "02-01-2020", "03-01-2020", "07-01-2020"])
    e4 = Employee(4, 4, {"bartender": 1}, ["02-01-2020", "04-01-2020", "05-01-2020", "06-01-2020"])
    e5 = Employee(5, 5, {"waitress": 2, "bartender": 1},
                  ["02-01-2020", "03-01-2020"])  # remove 3-1-20 to get best non viable solution
    e6 = Employee(6, 6, {"waitress": 1, "bartender": 1}, ["01-01-2020", "06-01-2020", "05-01-2020"])
    e7 = Employee(7, 7, {"waitress": 1}, ["01-01-2020", "07-01-2020", "05-01-2020"])
    e8 = Employee(8, 8, {"waitress": 1, "bartender": 1}, ["06-01-2020", "05-01-2020"])
    e9 = Employee(9, 9, {"waitress": 1}, ["03-01-2020", "04-01-2020", "06-01-2020"])
    e10 = Employee(10, 10, {"bartender": 1, "waitress": 1}, ["01-01-2020", "02-01-2020", "04-01-2020", "07-01-2020"])
    db = DB("Resty.db")
    for employee in [e1, e2, e3, e4, e5, e6, e7, e8, e9, e10]:
        dates = employee.get_dates()
        user_id = employee.get_id()
        start_time = None
コード例 #9
0
ファイル: setup.py プロジェクト: noitcerid/blackhat.null
DISKS.append(Disk("Standard HDD", "No Frills 7200RPM HDD", 50, 1, 7200, 8000))
DISKS.append(
    Disk("Performance SSD", "Performance SSD Drive", 50, 1, 15000, 500))
DISKS.append(
    Disk("Performance SSD", "Performance SSD Drive", 50, 1, 15000, 1000))
DISKS.append(
    Disk("Performance SSD", "Performance SSD Drive", 50, 1, 15000, 1500))
DISKS.append(
    Disk("Performance SSD", "Performance SSD Drive", 50, 1, 15000, 2000))
DISKS.append(
    Disk("Performance SSD", "Performance SSD Drive", 50, 1, 15000, 4000))

# Employee List
EMPLOYEES.append(
    Employee(1, "Jim", "Bond", "999-88-7777", "123-123-1234",
             "9876 Somewhere St.", "St. Louis", "MO", "11111", None, None, 0,
             None))
EMPLOYEES.append(
    Employee(2, "Bob", "Smith", "111-22-3333", "111-222-3333",
             "123 Anywhere Rd.", "Orlando", "FL", "32830", None,
             "Network Engineer", 123200.00, None))

# Memory List (Size in MB)
MEMORY.append(
    Memory("Dynamix DDR 2100 RAM", "1x1GB Kit - Older but common RAM", 100, 1,
           2100, 1024))
MEMORY.append(
    Memory("Dynamix DDR 2100 RAM", "1x2GB Kit - Older but common RAM", 200, 1,
           2100, 2048))
MEMORY.append(
    Memory("Dynamix DDR 2100 RAM", "2x2GB Kit - Older but common RAM", 450, 2,