def manager_leave(): """ 请假列表 """ data = [] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') get_leave = LeaveInfo.filter(LeaveInfo.Company == companyId) for item in get_leave: base = { "Id": item.Id, 'StartTime': item.StartTime, 'Reason': item.Reason, 'Agree': item.Agree } get_empName = EmployeesInfo.select().where( EmployeesInfo.Id == item.EmployeesId) for getEmp_name in get_empName: base['Name'] = getEmp_name.Name base['Sex'] = getEmp_name.Sex base['Phone'] = getEmp_name.Phone data.append(base) return template(root + "/templates/listleave.tpl", templatedir=root + '/templates/', data=data, companyName=companyName)
def manager_report(): """ 查看打卡报表 """ data = [] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #get_Re = RegistrationInfo.filter(RegistrationInfo.Company == companyId) data_employees = EmployeesInfo.filter(EmployeesInfo.Company == companyId) for item in data_employees: base = {"Id": item.Id, "Name": item.Name, "Position": item.Position} getRegistByEmployeesId = RegistrationInfo.select().where( RegistrationInfo.Company == companyId and RegistrationInfo.EmployeesId == item.Id) base['WorkStatus'] = '' base['SingTime'] = '' base['location'] = '' for emp in getRegistByEmployeesId: if not emp.WorkStatus == '' and emp.SingTime is None and emp.location is None: base['WorkStatus'] = emp.WorkStatus base['SingTime'] = emp.SingTime base['location'] = emp.location data.append(base) return template(root + "/templates/report.tpl", templatedir=root + '/templates/', data=data, companyName=companyName)
def manager_listEmployees(): #员工列表 """ 员工列表 """ data = [] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') get_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId) for item in get_em: base = { "Id": item.Id, 'Name': item.Name, 'Sex': item.Sex, 'Phone': item.Phone, 'Email': item.Email, 'Position': item.Position } get_depart = DepartmentInfo.select().where( DepartmentInfo.Id == item.Department and DepartmentInfo.Company == companyId) base['department'] = '' for depar in get_depart: if not depar.Name == '': base['department'] = depar.Name data.append(base) return template(root + "/templates/listEmployess.tpl", templatedir=root + '/templates/', data=data, companyName=companyName)
def edi_leave(Id,showDetail): """ 请假编辑 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') if showDetail =='true': data_leave = LeaveInfo.filter(LeaveInfo.Company == companyId).filter(LeaveInfo.Id == Id) for item in data_leave: getEmployeesById = EmployeesInfo.filter(EmployeesInfo.Id == item.EmployeesId) for employe in getEmployeesById: data = {"Id":item.Id,"StartTime":item.StartTime,"Reason":item.Reason,"Agree":item.Agree,"Name":employe.Name,"Sex":employe.Sex} form =request.forms if form.reject: #驳回 LeaveInfo.update(Agree = False,reMsg = form.reMsg).where(LeaveInfo.Id==int(Id)).execute() redirect("/manager/listleave/") if form.submit: #批准 LeaveInfo.update(Agree = True,reMsg = form.reMsg).where(LeaveInfo.Id==int(Id)).execute() redirect("/manager/listleave/") return template(root+"/templates/edit_leave.tpl",showDetail=True,templatedir= root+'/templates/',data=data,companyName=companyName)
def manager_listEmployees(): #员工列表 """ 员工列表 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- array_depart = baseClass().getdepart()#调用类 #------------end------------- data = [] get_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId) for item in get_em: base = {"Id": item.Id,'Name':item.Name,'Sex':item.Sex,'Phone':item.Phone,'Email':item.Email,'Position':item.Position} get_depart = DepartmentInfo.filter(DepartmentInfo.Id == item.Department) base['department'] = '' for depar in get_depart: if not depar.Name == '': base['department'] = depar.Name data.append(base) return template(root+"/templates/listEmployess.tpl",array_depart = array_depart,templatedir = root+'/templates/',data=data,companyName=companyName)
def manager_listEmployeesBydepart(Id): """ 根据部门查询 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- array_depart = baseClass().getdepart()#调用类 #------------end------------- data = [] data_em = EmployeesInfo.filter(EmployeesInfo.Company == companyId).filter(EmployeesInfo.Department ==Id) for item in data_em: base = {"Id": item.Id,'Name':item.Name,'Sex':item.Sex,'Phone':item.Phone,'Email':item.Email,'Position':item.Position} get_depart = DepartmentInfo.filter(DepartmentInfo.Id == item.Department) base['department'] = '' for depar in get_depart: if not depar.Name == '': base['department'] = depar.Name data.append(base) return template(root+"/templates/listEmployess.tpl",array_depart = array_depart,templatedir = root+'/templates/',data=data,companyName=companyName)
def manager_report(): """ 查看打卡报表 """ data=[] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #get_Re = RegistrationInfo.filter(RegistrationInfo.Company == companyId) data_employees = EmployeesInfo.filter(EmployeesInfo.Company == companyId) for item in data_employees: base = {"Id":item.Id,"Name":item.Name,"Position":item.Position} getRegistByEmployeesId = RegistrationInfo.select().where(RegistrationInfo.Company == companyId and RegistrationInfo.EmployeesId == item.Id) base['WorkStatus'] = '' base['SingTime'] = '' base['location'] = '' for emp in getRegistByEmployeesId: if not emp.WorkStatus =='' and emp.SingTime is None and emp.location is None: base['WorkStatus'] = emp.WorkStatus base['SingTime'] = emp.SingTime base['location'] = emp.location data.append(base) return template(root+"/templates/report.tpl",templatedir=root+'/templates/',data=data,companyName=companyName)
def del_employees(Id): #删除员工信息 """ 删除员工信息 """ employe = EmployeesInfo.get(Id=Id) if not employe is None: employe.delete_instance() return {"State": "success"}
def del_employees(Id): #删除员工信息 """ 删除员工信息 """ employe = EmployeesInfo.get(Id=Id) if not employe is None: employe.delete_instance() return json.dumps({"State":"success"})
def mlogin(username,passwd): """ API登录 """ user = EmployeesInfo.getOne(loginName = username) passwd_md5 = str(md5.new(passwd).hexdigest())#md5加密,32位 if not user is None: if passwd_md5 == user.loginPwd: token = passwd + str(datetime.datetime.now())+ "_" + user.Id + "_" + user.Company return json.dumps({"msg":"成功","error":"0","token":token,"Cname":user.companyName}) else: return json.dumps({"msg":"用户名或密码错误","error":"1"}) else: return json.dumps({"msg":"不存在%S的账号" % username,"error":"1"})
def manager_leave(): """ 请假列表 """ data = [] app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') get_leave = LeaveInfo.filter(LeaveInfo.Company == companyId) for item in get_leave: base = {"Id":item.Id,'StartTime':item.StartTime,'Reason':item.Reason,'Agree':item.Agree} get_empName = EmployeesInfo.select().where(EmployeesInfo.Id == item.EmployeesId) for getEmp_name in get_empName: base['Name'] = getEmp_name.Name base['Sex'] = getEmp_name.Sex base['Phone'] = getEmp_name.Phone data.append(base) return template(root+"/templates/listleave.tpl",templatedir=root+'/templates/',data=data,companyName=companyName)
def manager_report(): """ 查看打卡报表 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- array_depart = baseClass().getdepart()#调用类 #------------end------------- #---------获取签到位置信息------- SingInfo = baseClass().getSingInfo()#调用类 #---------end-------------------- time_0 = str(date.today()) + " " + "01:00:00" time_0_format = datetime.strptime(time_0,"%Y-%m-%d %H:%M:%S") time_24 =str(date.today())+ " " + "23:59:59" time_24_format = datetime.strptime(time_24,"%Y-%m-%d %H:%M:%S") data=[] data_employees = EmployeesInfo.filter(EmployeesInfo.Company == companyId) for item in data_employees: base = {"Id":item.Id,"Name":item.Name,"Position":item.Position} getRegistByEmployeesId = RegistrationInfo.filter(RegistrationInfo.Company == companyId).filter(RegistrationInfo.EmployeesId == item.Id).filter(RegistrationInfo.SingTime > time_0_format ).filter(RegistrationInfo.SingTime < time_24_format) base['WorkStatus'] = '未签到' base['SingTime'] = '-' base['location'] = '-' if not getRegistByEmployeesId is None: for emp in getRegistByEmployeesId: base['WorkStatus'] = emp.WorkStatus base['SingTime'] = emp.SingTime base['location'] = emp.location data.append(base) return template(root+"/templates/report.tpl",SingInfo = SingInfo,array_depart = array_depart,templatedir=root+'/templates/',data=data,companyName=companyName)
def edi_employees(Id, showDetail): #员工信息管理 """ 员工的添加与编辑 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- data_depart = DepartmentInfo.filter(DepartmentInfo.Company == companyId) array_depart = [] for depart in data_depart: base = {"Id": depart.Id, "Name": depart.Name} array_depart.append(base) #------------end------------- if showDetail == 'true': data_employ = EmployeesInfo.filter(EmployeesInfo.Company == companyId and EmployeesInfo.Id == Id) for item in data_employ: data = { "Id": item.Id, "Name": item.Name, "Department": item.Department, "Sex": item.Sex, "IdCard": item.IdCard, "Phone": item.Phone, "Email": item.Email, "Position": item.Position } form = request.forms res_dic = [] if form.submit: EmployeesInfo.update(Name=form.Name, Sex=form.Sex, IdCard=form.IdCard, Phone=form.Phone, Email=form.Email, Position=form.Position).where( EmployeesInfo.Id == int(Id)).execute() redirect("/manager/listemployees/") return template(root + "/templates/edit_employees.tpl", array_depart=array_depart, showDetail=True, templatedir=root + '/templates/', data=data, companyName=companyName) else: form = request.forms if form.submit: #获取员工根据对应的公司Id查找员工总数,新的员工Id:count+1 count = EmployeesInfo.select().count() employe = EmployeesInfo() employe.Id = count + 1 employe.Name = form.Name employe.LoginName = form.Phone employe.LoginPwd = md5.new("123456").hexdigest() employe.Company = companyId employe.Department = form.department employe.Sex = form.Sex employe.IdCard = form.IdCard employe.Phone = form.Phone employe.Email = form.Email employe.Position = form.Position employe.Imei = "123456xaxahisia" employe.save(force_insert=True) #不管主键是否存在的情况加force_insert = True redirect("/manager/listemployees/") return template(root + "/templates/edit_employees.tpl", array_depart=array_depart, showDetail=False, templatedir=root + '/templates/', companyName=companyName)
def edi_employees(Id,showDetail): #员工信息管理 """ 员工的添加与编辑 """ app_session = bottle.request.environ.get('beaker.session') companyId = app_session.get('company') companyName = app_session.get('companyName') #---------获取部门列表----------- data_depart = DepartmentInfo.filter(DepartmentInfo.Company==companyId) array_depart = [] for depart in data_depart: base = {"Id":depart.Id,"Name":depart.Name} array_depart.append(base) #------------end------------- if showDetail =='true': data_employ = EmployeesInfo.filter(EmployeesInfo.Company==companyId).filter(EmployeesInfo.Id==Id) for item in data_employ: data = {"Id":item.Id,"Name":item.Name,"Department":item.Department,"Sex":item.Sex,"IdCard":item.IdCard,"Phone":item.Phone,"Email":item.Email,"Position":item.Position} form = request.forms res_dic = [] if form.submit: EmployeesInfo.update(Name=form.Name,Sex=form.Sex,IdCard=form.IdCard,Phone=form.Phone,Email=form.Email,Position=form.Position).where(EmployeesInfo.Id==int(Id)).execute() redirect("/manager/listemployees/") return template(root+"/templates/edit_employees.tpl",array_depart = array_depart,showDetail= True,templatedir=root+'/templates/',data=data,companyName=companyName) else: form = request.forms if form.submit: #获取员工根据对应的公司Id查找员工总数,新的员工Id:count+1 employe = EmployeesInfo() employe.Name = form.Name employe.LoginName = form.Phone employe.LoginPwd = md5.new("123456").hexdigest() employe.Company = companyId employe.Department = form.department print [form.department] employe.Sex = form.Sex employe.IdCard = form.IdCard employe.Phone = form.Phone employe.Email = form.Email employe.Position = form.Position employe.Imei = "123456xaxahisia" employe.save(force_insert = True)#不管主键是否存在的情况加force_insert = True,相当于id自动递增 redirect("/manager/listemployees/") return template(root+"/templates/edit_employees.tpl",array_depart = array_depart,showDetail = False,templatedir = root+'/templates/',companyName = companyName)