Beispiel #1
0
    def get(self):
        # check if any employee is in the system, if not, create an administrator
        users = Employee.query().fetch()
        if len(users) == 0:
            swaiss = Employee(username="******",
                              password="******",
                              email="*****@*****.**",
                              isAdmin=True,
                              isActive=True)
            swaiss.put()

            dummy = Employee(username="******",
                             password="******",
                             email="*****@*****.**",
                             isAdmin=False,
                             isActive=True)
            dummy.put()

        # pulls current year to put into footer for copyrights
        dateTimeNow = datetime.datetime.now()
        curYear = dateTimeNow.year

        values = {"curYear": curYear}
        template = JINJA_ENVIRONMENT.get_template('HTML/Login.html')
        self.response.write(template.render(values))
Beispiel #2
0
def employeeClassEx():
    print("hello world")
    emp1 = Employee("Zara", 2000)
    emp2 = Employee("Manni", 5000)

    emp1.displayEmployee()
    emp2.displayEmployee()

    print("Total employee %d", Employee.empCount)
Beispiel #3
0
 def test_fulName(self):
     print('test_fulName')
     self.emp1 = Employee('Tanvi','Satheesh',5000)
     self.emp2 = Employee('Divya','Satheesh',10000)
     self.assertEqual(self.emp1.fulname,'Tanvi Satheesh')
     self.assertEqual(self.emp2.fulname,'Divya Satheesh')
     self.emp1.first = 'Manasvi'
     self.emp2.last = 'Srirangapatna'
     self.assertEqual(self.emp1.fulname,'Manasvi Satheesh')
     self.assertEqual(self.emp2.fulname,'Divya Srirangapatna')
Beispiel #4
0
    def test_attributes_string(self):
        e = Employee("Joe Namath", "*****@*****.**", "392 493 4939",
                     "Marketing", "Marketing Manager", "U of Minnesota")
        d = Employee("Chris Jones", "*****@*****.**", "(555) 392 5828",
                     "Sales", "Sales Associate", "University of Cambridge")

        assert e.stringify_attrs(
        ) == "[email protected]/392 493 4939/Marketing/Marketing Manager/U of Minnesota/\n"
        assert d.stringify_attrs(
        ) == "[email protected]/(555) 392 5828/Sales/Sales Associate/University of Cambridge/\n"
Beispiel #5
0
    def test_email(self):
        emp1 = Employee('Stan', 'Corpuz', 100000)
        emp2 = Employee('Mari', 'Corpuz', 200000)

        self.assertEqual(emp1.email, '*****@*****.**')
        self.assertEqual(emp2.email, '*****@*****.**')

        emp1.first = 'John'
        emp2.first = 'Leslie'

        self.assertEqual(emp1.email, '*****@*****.**')
        self.assertEqual(emp2.email, '*****@*****.**')
def userInfo(employee_id):
    if request.method=='POST':
        req = request.form.get('offDay')
        Employee(int(employee_id)).setOffDay(int(req))
        penalty = request.form.get('penalty')
        if penalty != "None":
            Employee(int(employee_id)).addPenalty(int(penalty))
            print(penalty)
    employee_id = int(employee_id)
    data = emp.Employee(employee_id)
    penaltyList = list(collection.find({"emp_id":employee_id}))
    attendances = list(data.viewAttendance())[0]['attendance']
    return render_template('userinfo.html', emp_id=employee_id, data=data, attendances=attendances, calendar=calendar,penaltyList=penaltyList)
Beispiel #7
0
def main():
    humans = [
        Employee("Raiden", "Kusumo", 5000000),
        Employee("Norman", "Kamaru", 10000000)
    ]
    for human in humans:
        print("Gajimu perbulang sekarang adalah", human.monthly_salary)

    for human in humans:
        human.monthly_salary += human.monthly_salary * 10 / 100

    print()

    for human in humans:
        print("Gajimu perbulang sekarang adalah", human.monthly_salary)
Beispiel #8
0
def getEmployeeList():
    try:
        employeeList = []
        employeeList.append(Employee("김", "재웅"))
        employeeList.append(Employee("홍", "길동"))
        employeeList.append(Employee("이", "명희"))
        employeeList.append(Employee("박", "찬길"))
        employeeList.append(Employee("최", "호길"))

        jsonStr = json.dumps([e.toJSON() for e in employeeList],
                             ensure_ascii=False,
                             indent=4)

    except:
        pass
    return jsonStr
Beispiel #9
0
def main():
    printIntro()
    # database filename
    dbFilename = "mccEmployees.txt"
    # create management list
    mccManagement = Management()
    # create and add employees to list
    mccManagement.addEmp(
        Parttime("Luke", "Skywalker", mccManagement.getListSize(), 3))
    mccManagement.addEmp(
        Salary("Han", "Solo", mccManagement.getListSize(), 4000))
    removeEmp1 = Hourly("Anakin", "Skywalker", mccManagement.getListSize(), 35,
                        20)
    mccManagement.addEmp(removeEmp1)
    mccManagement.addEmp(
        Hourly("Leia", "Organa", mccManagement.getListSize(), 40, 15))
    # display management list
    print("Adding employees")
    printEmps(mccManagement)
    # remove an employee and display management list
    mccManagement.removeEmp(removeEmp1)
    print("Removing employee ID " + removeEmp1.getEmployeeID())
    printEmps(mccManagement)
    # add a default parent class Employee and display management list
    mccManagement.addEmp(Employee("First", "Last",
                                  mccManagement.getListSize()))
    print("Adding a default parent class Employee")
    printEmps(mccManagement)
    # save management db to file
    print("Saving database to " + dbFilename)
    mccManagement.writeFile(dbFilename)
    # load management db file
    print("Loading database from " + dbFilename)
    for emp in mccManagement.readFile(dbFilename):
        print(emp)
Beispiel #10
0
    def read_file():
        file = '/Users/laurennelson/PersonalProjects/EmployeeScheduler/employee.json'
        array = []
        with open(file) as employee_schedule:
            schedule = json.load(employee_schedule)

        for employee in schedule:
            name = employee
            start_hr = schedule[employee]['start_hr']
            start_min = schedule[employee]['start_min']
            end_hr = schedule[employee]['end_hr']
            end_min = schedule[employee]['end_min']

            start_time = datetime.time(hour=start_hr,
                                       minute=start_min,
                                       second=0,
                                       microsecond=0)
            end_time = datetime.time(hour=end_hr,
                                     minute=end_min,
                                     second=0,
                                     microsecond=0)
            new_employee = Employee(name, start_time, end_time, 0, 0, 0)
            array.append(new_employee)

        array.sort()

        return array
Beispiel #11
0
def getQual(request):
    # if post request came
    if request.method == 'POST':
        # getting values from post
        lastName = request.POST.get('lastName')
        firstName = request.POST.get('firstName')
        qual = request.POST.get('qual')

        # adding the values in a context variable
        context = {
            'lastName': lastName,
            'firstName': firstName,
            'qual': qual,
        }
        engine = create_engine('mysql+pymysql://root:password@localhost/test')
        emp = Employee(firstName, lastName, qual)
        Session = sessionmaker(bind=engine)
        session = Session()
        session.add(emp)
        session.commit()
        # getting our showdata template
        template = loader.get_template('success.html')

        # returing the template
        return HttpResponse(template.render(context, request))
    else:
        # if post request is not true
        # returing the form template
        template = loader.get_template('qual.html')
        return HttpResponse(template.render())
Beispiel #12
0
    def test_employee_constructor(self):
        employee = Employee(103, 'Jill', 65000, 101)

        self.assertEqual(employee.ID, 103)
        self.assertEqual(employee.name, 'Jill')
        self.assertEqual(employee.salary, 65000)
        self.assertEqual(employee.mgr_ID, 101)
Beispiel #13
0
def set():
    if request.method == 'POST':
        if request.form['first'] and request.form['last'] and request.form[
                'pay']:
            first = request.form['first']
            last = request.form['last']
            pay = request.form['pay']
            emp = Employee(first, last, pay)
            conn = sqlite3.connect('employees.db')
            c = conn.cursor()
            c.execute(
                "SELECT * FROM employee WHERE first='{}' AND last='{}'".format(
                    first, last))
            if not c.fetchall():
                flash("There is no any {} {} employee".format(first, last))
            else:
                with conn:
                    c.execute(
                        """UPDATE employee SET pay = '{}' WHERE first = '{}' AND last ='{}'"""
                        .format(emp.pay, emp.first, emp.last))
                c.execute('SELECT * FROM employee')
                flash("{} {}'s salary has been changed".format(
                    emp.first, emp.last))
            c.execute('SELECT * FROM employee')
            query = c.fetchall()
            return render_template('show.html', query=query)
        else:
            flash("You haven't provide all valuses")
            return redirect('show')
    def edit_entry(self, name, update=None, field=None):
        if name in self.directory:
            entry = self.directory[name].split("/")
            temp_employee = Employee(name, entry[0], entry[1], entry[2],
                                     entry[3], entry[4])

            if field is None:
                field = input(
                    "Which field would you like to change? " +
                    "Fields are 'email', 'phone', 'department', 'title', and 'education': "
                )

            field = field.lower()
            fields = ['email', 'phone', 'department', 'title', 'education']

            if field in fields:
                if update is None:
                    update = input("Enter new {} information: ".format(field))

                exec("temp_employee.set_{}('{}')".format(field, update))

                self.directory[name] = temp_employee.stringify_attrs()
                print("Entry updated")
            else:
                print("Invalid field entered")
        else:
            entry_dne()
Beispiel #15
0
    def add_to_db(self, name, month, year, hours):
        try:
            db = sqlite.connect(self.database)
            with db:
                conn = db.cursor()
                id = 1
                try:
                    conn.execute("SELECT MAX(id) FROM {}".format(self.table))
                    db.commit()

                    max_id = conn.fetchall()
                    id = max_id[0][0] + 1
                except Exception as e:
                    print("Inserting into empty table: " + self.table +
                          " new index equals " + str(id))

                employees = Employee().get_all_db_data()
                employeeId = 0
                for employee in employees:
                    if name == employee["name"]:
                        employeeId = employee["id"]

                new_table = (id, employeeId, month, year, hours)

                conn.execute(
                    "INSERT INTO {} (id, employeeId, month, year, hours) VALUES (?,?,?,?,?)"
                    .format(self.table), new_table)

        except Exception as e:
            print("Troubles with add_commodity_to_db: " + e.args[0])
Beispiel #16
0
def addEmp():
    empFName = entry1.get()
    empLName = entry2.get()
    listIndex = list1.curselection()
    listDep = []
    for i in listIndex:
        listDep.append(list1.get(i))
    listIndex = list2.curselection()
    listSkill = []
    for i in listIndex:
        listSkill.append(list2.get(i))
    cap = entry3.get()
    emp = Employee(empFName, empLName, listDep, listSkill, cap)
    connection.post_employee(emp)
    list32.delete(0, tk.END)
    for q in connection.get_all_employees(returnObject=True):
        list32.insert(tk.END, q)
    entry1.delete(0, tk.END)
    entry2.delete(0, tk.END)
    entry3.delete(0, tk.END)
    list1.delete(0, tk.END)
    for q in (employees_schema['department'])['allowed']:
        list1.insert(tk.END, q)
    list2.delete(0, tk.END)
    for q in (employees_schema['skillset'])['allowed']:
        list2.insert(tk.END, q)
    messagebox.showinfo("Message", "Employee added")
Beispiel #17
0
        def confirm_employee():
            nonlocal edited_info
            nonlocal new_employee
            new_employee = Employee(edited_info[0][1],
                                    edited_info[1][1],
                                    edited_info[2][1],
                                    edited_info[3][1],
                                    edited_info[4][1],
                                    edited_info[5][1],
                                    edited_info[6][1],
                                    flight_history=[])

            # Making sure python creates a new list
            all_employee_list = [] + LL_API.get_employee_list()

            # Finding employee in that list and replacing it
            for i, employee_i in enumerate(all_employee_list):
                if employee_i == employee:
                    all_employee_list[i] = new_employee

            # Writing new list
            LL_API.write_employee_list(all_employee_list)

            # Killing function
            nonlocal running
            running = False
Beispiel #18
0
 def insert_data(self):
     try:
         if self._table_exists():
             self.get_connection()
             emp = Employee()
             _id = self._numeric_input(constants.enter_id)
             if self._search_data(_id) == False:
                 emp.set_employee_id(_id)
                 emp.set_employee_title(input(constants.enter_title))
                 emp.set_forename(input(constants.enter_forename))
                 emp.set_surname(input(constants.enter_surname))
                 emp.set_email(input(constants.enter_email))
                 emp.set_salary(self._numeric_input(constants.enter_salary))
                 args = (emp.get_employee_id(), emp.get_employee_title(),
                         emp.get_forename(), emp.get_surname(),
                         emp.get_email(), emp.get_salary())
                 self.cur.execute(constants.sql_insert, args)
                 self.conn.commit()
                 print(constants.data_added)
             else:
                 print(constants.emp_id_exists)
         else:
             print(constants.table_not_exist)
     except Exception as e:
         print(e)
     finally:
         self.conn.close()
Beispiel #19
0
 def __init__(self):
     self.user = User()
     self.account = Account()
     self.employee = Employee()
     self.service = Service()
     self.utilities = Utilities()
     self.initAmt = 0
Beispiel #20
0
 def searchFunction(self):
     global currentEmployee
     currentEmployee = Employee(self.employeeIdSearchBox.get())
     if currentEmployee.exists:
         self.goToUserPage()
     else:
         tk.Label(self.frame, text="Cannot find employee").grid(row=4, column=1)
Beispiel #21
0
    def __import_employees(cls):
        try:
            with open('../Data/EmployeesData.txt', 'r') as f:

                lines_arr = []

                for line in f:
                    line = line.strip()
                    lines_arr.append(line)

                    if line == '#':
                        for company in cls.companies_list:
                            if company.get_tax_id() == lines_arr[0]:

                                company_tax_id = lines_arr[0]
                                personal_id = lines_arr[1]
                                name = lines_arr[2]
                                surname = lines_arr[3]
                                address = lines_arr[4]
                                birthday = lines_arr[5]
                                salary = lines_arr[6]

                                lines_arr.clear()

                                employee = Employee(name, surname, personal_id,
                                                    address, birthday,
                                                    company_tax_id, salary)
                                cls.employees_list.append(employee)

                                break

                lines_arr.clear()
        except BaseException:
            pass
Beispiel #22
0
def main():
    file_name = input("Enter file name: ")
    while not Validation.file_exists(file_name):
        file_name = input("Reenter file name: ")
    employees = Collection()
    employees.read(file_name)
    menu_choice = 0
    # print(employees.get_len())
    while menu_choice != 4:
        print("You are in main menu. Possible options:\n"
              "1 - add an employee\n"
              "2 - show all salary\n"
              "3 - show all employees\n"
              "4 - exit program\n"
              "Choose your option: ")
        menu_choice = input()
        print("choice =", menu_choice)
        if int(menu_choice) == 1:
            # print("went elif 1")
            data = input(
                "Enter a LINE which is similar to (with a ', ' as a delimiter or enter 0 to skip)\n"
            )
            if data == 0:
                pass
            new_employee = Employee(data)
            employees.add_worker(new_employee)
        elif int(menu_choice) == 2:
            # print("went elif 2")
            print(employees.all_salary())
        elif int(menu_choice) == 3:
            # print("went elif 3")
            employees.print()
        elif int(menu_choice) == 4:
            print("Have a nice day! Goodbye!")
Beispiel #23
0
 def createEmployee(self):
     name = self._inputName()
     birthday = self._inputBirthday()
     salary = self._inputSalary()
     newEmployee = Employee(name, birthday, salary)
     self.employesList.append(newEmployee)
     self.showEmployee()
Beispiel #24
0
 def getInsertitems():
     first = entFirst.get()
     last = entLast.get()
     pay = entpay.get()
     emp = Employee(first, last, pay)
     insertemp(emp)
     lableinsert = ttk.Label(insert, text="Row inserted").pack()
Beispiel #25
0
    def post(self):
        # check for correct cookie
        name = self.request.cookies.get("name")
        admins = Employee.query(Employee.username == name,
                                Employee.isAdmin == True).fetch()

        # if cookie is correct, render page
        if len(admins) != 0:
            # pulls current year to put into footer for copyrights
            dateTimeNow = datetime.datetime.now()
            curYear = dateTimeNow.year

            # pull form data
            postedUsername = self.request.get('username')
            postedPassword = self.request.get('password')
            postedEmail = self.request.get('email')
            postedIsAdminList = self.request.get('admin')

            if postedIsAdminList != "":
                postedIsAdminBool = True
            else:
                postedIsAdminBool = False

            # check if username already exists, if yes, throw error
            matchingUsernames = Employee.query(
                Employee.username == postedUsername).fetch()

            if len(matchingUsernames) != 0:
                values = {
                    "username": name,
                    "alreadyExists": 1,
                    "curYear": curYear
                }
                template = JINJA_ENVIRONMENT.get_template(
                    'HTML/AdminManageEmployeesCreate.html')
                self.response.write(template.render(values))
                return

            # create employee and add to datastore
            newEmployee = Employee(username=postedUsername,
                                   password=postedPassword,
                                   email=postedEmail,
                                   isAdmin=postedIsAdminBool,
                                   isActive=True)
            newEmployee.put()

            values = {
                "username": name,
                "employee": newEmployee,
                "curYear": curYear
            }

            template = JINJA_ENVIRONMENT.get_template(
                'HTML/AdminManageEmployeesCreateSuccess.html')
            self.response.write(template.render(values))

        else:
            self.redirect('/')
            return
Beispiel #26
0
    def __init__(self, pos):
        self.pos = pos
        self.employees = []

        for name in EmployeeData:
            self.employees.append(Employee(name))

        self.pos.db.insert_many(self.employees, commit=True)
Beispiel #27
0
 def addNewEmployee():
     employee = Employee()
     employee.name = input("Please enter the employee name :")
     employee.position = input("Please enter the job position : ")
     employee.salary = input("Please enter the salary : ")
     MainController.displayAllDepartments()
     employee.department_id = input("Please enter department id : ")
     employee.save()
Beispiel #28
0
def create_emp():
    # TODO add logging info
    with open('empData.txt', 'a') as f:
        add_first = input("Enter the employee's first name: ")
        add_last = input("Enter the employee's last name: ")
        new_emp = Employee(add_first, add_last)
        f.write(f'Name: {new_emp.full_name}, Email: {new_emp.email}\n')
        print("Employee successfully added.")
Beispiel #29
0
 def addNormalEmployee(self, employeeUserName, employeePassword, reporting):
     enUserType = "Employee"
     employee = Employee()
     employee.setEnUserType(enUserType)
     employee.setsUserid(employeeUserName)
     employee.setsPassword(employeePassword)
     employee.SetRA(reporting)
     return employee
Beispiel #30
0
 def getUser(permission):
     if (permission == 0):
         return Employee()
     elif (permission == 1):
         return Manager()
     elif (permission == 2):
         return Administrator()
     else:
         return None