Esempio n. 1
0
def overtime_iframe_data():
    templates = DocTemplates.templates_vkreport()
    data = {}
    data['manager'] = request.args.get('manager')
    data['add'] = request.args.get('add')
    data['overrate'] = request.args.get('overrate')
    data['overdays'] = request.args.get('overdays')
    data['score'] = request.args.get('score')
    project_id = Project.query.filter_by(manager=current_user.username,
                                         quarter=utils.quarter_calc()).first()
    data['quarter'] = utils.quarter_calc()
    data['project'] = project_id.pname
    if data['add'] == "add":
        db.create_all()
        oday = Oday(quarter=data['quarter'],
                    pname=data['project'],
                    manager=project_id.manager,
                    department=project_id.department,
                    member=data['manager'],
                    rate=data['overrate'],
                    days=data['overdays'],
                    score=data['score'],
                    project_id=project_id.id)
        db.session.add(oday)
        db.session.commit()
    else:
        delid = int(data['add'])
        oday = Oday.query.filter_by(id=delid).first()
        oday.rate = request.args.get('overrate')
        oday.days = request.args.get('overdays')
        oday.score = request.args.get('score')
        db.session.commit()
    return render_template("ProMemDetail/proManager_iframeAdd.html",
                           templates=templates)
Esempio n. 2
0
def create_staff_db():
    querydata = Oday.query.filter_by(quarter=utils.quarter_calc(),
                                     department=current_user.department).all()
    staff_name = []
    backdata = []
    for data in querydata:
        data = data.to_dict()
        confirm_data = Staff.query.filter_by(quarter=utils.quarter_calc(),
                                             name=data['member']).first()
        if confirm_data:
            continue
        if data['member'] in staff_name:
            for backdata_ in backdata:
                if backdata_['member'] == data['member']:
                    backdata_['score'] = str(
                        int(backdata_['score']) + int(data['score']))
                    backdata_['note'] += '{}:{}分;'.format(
                        data['pname'], data['score'])
        else:
            data['note'] = '{}:{}分;'.format(data['pname'], data['score'])
            data['department_score'] = '0'
            staff_name.append(data['member'])
            backdata.append(data)
    for data in backdata:
        staff = Staff(quarter=utils.quarter_calc(),
                      department=data['department'],
                      name=data['member'],
                      project_score=data['score'],
                      other_score=data['department_score'],
                      note=data['note'])
        db.session.add(staff)
        db.session.commit()
Esempio n. 3
0
def vkreport():
    if current_user.is_authenticated:

        flag = utils.information_completion(current_user)
        check_flag = current_user.flag
        if flag and check_flag:
            if current_user.role == 1:
                templates = DocTemplates.templates_vkreport()
                querydata = Project.query.filter_by(
                    manager=current_user.username,
                    quarter=utils.quarter_calc()).first()
                if querydata == None:
                    flash("部门总监暂未创建由您负责的项目,所以暂时还不能访问", 'danger')
                    return redirect(url_for('main.index'))
                else:
                    data = querydata.to_dict()
                    return render_template('WeeklyReport/proManager.html',
                                           templates=templates,
                                           msg=data)
            elif current_user.role == 2:
                return render_template('WeeklyReport/departDirector.html')
            elif current_user.role == 3 or current_user.role == 4:
                return render_template('WeeklyReport/headManager.html')
            elif current_user.role == 5:
                return render_template('WeeklyReport/techDirector.html')
        elif flag:
            flash('请等待或者联系管理员进行信息审核', 'info')
            return redirect(url_for('main.index'))
        else:
            flash('请首先完善个人信息,实名认证,绑定部门', 'danger')
            return redirect(url_for('User.setting'))
    else:
        flash("权限管理页面,请登录后访问!", 'info')
        return redirect(url_for('User.login'))
Esempio n. 4
0
def project(flag):
    if flag == "submit":
        delid = request.get_data('id').decode('utf-8').split('&')
        uid = int(delid[0].split('id=')[-1])
        result = delid[1].split('result=')[-1]
        project = Project.query.filter_by(id=int(uid)).first()
        quarter = utils.quarter_calc()
        pname = project.pname
        manager = project.manager
        department = current_user.department
        name = current_user.username
        project_id = project.id
        result = int(result)
        submit_score = Score.query.filter_by(project_id=project.id).first()
        if submit_score != None and submit_score.name == current_user.username:
            return {"code": 1}
        score = Score(quarter=quarter,
                      pname=pname,
                      manager=manager,
                      department=department,
                      name=name,
                      result=result,
                      project_id=project.id)
        db.session.add(score)
        db.session.commit()
        return {"code": 0}
    else:
        abort(404)
Esempio n. 5
0
def project_query(flag):
    if flag == '1':
        projects = Project.query.filter_by(quarter=utils.quarter_calc()).all()
        datas = []
        for data in projects:
            msg = data.to_dict()
            datas.append(msg)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = datas[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(datas), "data": data_}
        return backdata
    elif flag == '2':
        querydata = Score.query.filter_by(quarter=utils.quarter_calc(),
                                          name=current_user.username).all()
        datas = []
        for data_ in querydata:
            project_id = data_.project_id
            project = Project.query.filter_by(id=project_id).first()
            data_ = data_.to_dict()
            data_['prate'] = project.prate
            data_['schedule'] = project.schedule
            datas.append(data_)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = datas[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(datas), "data": data_}
        return backdata
    elif flag == '3':
        querydata = Score.query.filter_by(quarter=utils.quarter_calc()).all()
        datas = []
        for data_ in querydata:
            project_id = data_.project_id
            project = Project.query.filter_by(id=project_id).first()
            data_ = data_.to_dict()
            data_['prate'] = project.prate
            data_['schedule'] = project.schedule
            datas.append(data_)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = datas[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(datas), "data": data_}
        return backdata
    else:
        abort(404)
Esempio n. 6
0
def weeklyreport(flag):
    if flag == "submit":
        templates = DocTemplates.templates_vkreport()
        data = {}
        data['schedule'] = request.args.get('quiz4')
        data['lastPlan'] = request.args.get('lastPlan')
        data['thisWork'] = request.args.get('thisWeek')
        data['nextPlan'] = request.args.get('nextPlan')
        project = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first()
        project.schedule = data['schedule']
        db.session.commit()
        vkinformation = Vkreport(quarter=project.quarter,
                                 pname=project.pname,
                                 department=project.department,
                                 manager=project.manager,
                                 schedule=data['schedule'],
                                 lastContent=data['lastPlan'],
                                 thisContent=data['thisWork'],
                                 nextContent=data['nextPlan'],
                                 project_id=project.id)
        db.session.add(vkinformation)
        db.session.commit()
        return redirect(url_for('WeeklyReport.vkreport'))
    elif flag == "query":
        project_id = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first().id
        querydata = Vkreport.query.filter_by(project_id=project_id).all()
        data = []
        if querydata != None:
            for msg in querydata:
                msg = msg.to_dict()
                msg['time'] = msg['time'].strftime("%Y-%m-%d %H:%M:%S")
                data.append(msg)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        return backdata
    else:
        abort(404)
Esempio n. 7
0
def qplan():
    if current_user.is_authenticated:
        flag = utils.information_completion(current_user)
        check_flag = current_user.flag
        if flag and check_flag:
            temps = DocTemplates.templates_index()
            quarter = utils.quarter_calc()
            templates = DocTemplates.templates_vkreport()
            if current_user.role == 1:
                querydata = Project.query.filter_by(
                    manager=current_user.username,
                    quarter=utils.quarter_calc()).first()
                if (querydata) != None:
                    data = querydata.to_dict()
                    return render_template('QuarterPlan/proManager.html',
                                           templates=templates,
                                           msg=data)
                else:
                    flash("请确认用户名是否正确,或部门总监暂未创建项目", 'info')
                    return redirect(url_for('main.index'))
            elif current_user.role == 2:
                return render_template('QuarterPlan/departDirector.html',
                                       templates=templates,
                                       quarter=quarter)
            elif current_user.role == 3 or current_user.role == 4:
                return render_template('QuarterPlan/headManager.html',
                                       templates=templates)
            elif current_user.role == 5:
                return render_template('QuarterPlan/techDirector.html',
                                       templates=templates,
                                       quarter=quarter)
            else:
                abort(404)
        elif flag:
            flash('请等待或者联系管理员进行信息审核', 'info')
            return redirect(url_for('main.index'))
        else:
            flash('请首先完善个人信息,实名认证,绑定部门', 'danger')
            return redirect(url_for('User.setting'))
    else:
        flash("权限管理模块,请登录后访问!", 'info')
        return redirect(url_for('User.login'))
Esempio n. 8
0
def staff_manager():
    querydata = Staff.query.filter_by(quarter=utils.quarter_calc()).all()
    data = []
    for qdata in querydata:
        qdata = qdata.to_dict()
        data.append(qdata)
    page = int(request.args["page"])
    limit = int(request.args["limit"])
    qdata = data[(page - 1) * limit:page * limit]
    backdata = {"code": 0, "msg": "", "count": len(data), "data": qdata}
    return backdata
Esempio n. 9
0
def performance_query(flag):
    querydata = Performance.query.filter_by(quarter=utils.quarter_calc()).all()
    data1 = []
    data2 = []
    for data_ in querydata:
        data_ = data_.to_dict()
        if data_['score'] == '0':
            data1.append(data_)
        else:
            data2.append(data_)
    if flag == '1':
        backdata = {"code": 0, "msg": "", "count": 1000, "data": data1}
        return backdata
    else:
        backdata = {"code": 0, "msg": "", "count": 1000, "data": data2}
        return backdata
Esempio n. 10
0
def prodirect(flag):
    if flag == "submit":
        quarter = request.args.get('quiz1')
        department = request.args.get('quiz2')
        project = request.args.get('quiz3')
        manager = request.args.get('quiz4')
        projectdb = Project(quarter=utils.quarter_calc(),
                            department=department,
                            pname=project,
                            manager=manager,
                            submitor=current_user.username)
        db.session.add(projectdb)
        db.session.commit()
        return redirect(url_for('QuarterPlan.qplan'))
    elif flag == "query":
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        querydata = Project.query.filter_by(
            submitor=current_user.username).all()
        data = []
        for msg in querydata:
            msg = msg.to_dict()
            data.append(msg)
        data_ = data[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        print(backdata)
        return backdata
    elif flag == "delete":
        delid = int(request.get_data('id').decode('utf-8').split('id=')[-1])
        querydata = Project.query.filter_by(id=delid).first()
        db.session.delete(querydata)
        db.session.commit()
        querydata = Project.query.filter_by(
            submitor=current_user.username).all()
        data = []
        for msg in querydata:
            msg = msg.to_dict()
            data.append(msg)
        backdata = {"code": 0, "msg": "删除", "count": 1000, "data": data}
        return backdata
    else:
        abort(404)
Esempio n. 11
0
def stuff_query(flag):
    create_staff_db()
    querydata = Staff.query.filter_by(
        quarter=utils.quarter_calc(),
        department=current_user.department).all()
    data1 = []
    data2 = []
    for data_ in querydata:
        if data_.other_score == "0":
            data1.append(data_.to_dict())
        else:
            data2.append(data_.to_dict())
    if flag == '1':
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data1[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data1), "data": data_}
        return backdata
    else:
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data2[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data2), "data": data_}
        return backdata
Esempio n. 12
0
def oquery(flag):
    if flag == '1':
        project_id = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first().id
        querydata = Oday.query.filter_by(project_id=project_id).all()
        data = []
        for msg in querydata:
            msg = msg.to_dict()
            if msg['rate'] == '0' and msg['days'] == '0' and msg[
                    'score'] == '0':
                data.append(msg)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data[(page - 1) * limit:page * limit]

        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        return backdata
    elif flag == '2':
        project_id = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first().id
        querydata = Oday.query.filter_by(project_id=project_id).all()
        data = []
        for msg in querydata:
            msg = msg.to_dict()
            if msg['rate'] == '0' and msg['days'] == '0' and msg[
                    'score'] == '0':
                pass
            else:
                data.append(msg)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        return backdata
    elif flag == '3':
        querydata = Oday.query.filter_by(
            department=current_user.department).all()
        data = []
        for data_ in querydata:
            data_ = data_.to_dict()
            data.append(data_)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        return backdata
    elif flag == '4':
        querydata = Oday.query.filter().all()
        data = []
        for data_ in querydata:
            data_ = data_.to_dict()
            data.append(data_)
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data_ = data[(page - 1) * limit:page * limit]
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        return backdata
    else:
        abort(404)
Esempio n. 13
0
def quarter(flag):
    if flag == "submit":
        data = {}
        data['qplan'] = request.args.get('QPlan')
        data['checker1'] = request.args.get('quiz5')
        data['checker2'] = request.args.get('quiz6')
        data['implementer'] = request.args.get('quiz7')
        project = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first()
        oday = Oday(quarter=project.quarter,
                    pname=project.pname,
                    manager=project.manager,
                    member=data['implementer'],
                    department=project.department,
                    project_id=project.id)

        db.session.add(oday)
        db.session.commit()
        db.create_all()
        qplandb = Qplan(quarter=project.quarter,
                        pname=project.pname,
                        manager=project.manager,
                        department=project.department,
                        qplanContent=data['qplan'],
                        checker1=data['checker1'],
                        checker2=data['checker2'],
                        implementer=data['implementer'],
                        project_id=project.id)
        db.session.add(qplandb)
        db.session.commit()
        flash("数据提交成功", 'success')
        return redirect(url_for('QuarterPlan.qplan'))
    elif flag == "query":
        project_id = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first().id
        querydata = Qplan.query.filter_by(project_id=project_id).all()
        page = int(request.args["page"])
        limit = int(request.args["limit"])
        data = []
        for msg in querydata:
            msg = msg.to_dict()
            data.append(msg)
        data_ = data[(page - 1) * limit:page * limit]
        print(data_)
        print('-------------------------')
        backdata = {"code": 0, "msg": "", "count": len(data), "data": data_}
        print(backdata)
        return backdata
    elif flag == "delete":
        delid = int(request.get_data('id').decode('utf-8').split('id=')[-1])
        querydata = Qplan.query.filter_by(id=delid).first()
        db.session.delete(querydata)
        db.session.commit()
        project_id = Project.query.filter_by(
            manager=current_user.username,
            quarter=utils.quarter_calc()).first().id
        querydata = Qplan.query.filter_by(project_id=project_id).all()
        data = []
        for msg in querydata:
            msg = msg.to_json()
            data.append(msg)
        backdata = {"code": 0, "msg": "删除", "count": 1000, "data": data}
        return backdata
    else:
        abort(404)