1. Trang chủ
  2. » Luận Văn - Báo Cáo

(Luận văn) xây dựng website giới thiệu và quản lý gia công cơ khí cho công ty tnhh tmdv cơ khí hiệp hòa

115 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

TRƯỜNG ĐẠI HỌC BÀ RỊA – VŨNG TÀU KHOA CNKT – NN - CNC - - lu an n va p ie gh tn to nl w BÁO CÁO ĐỒ ÁN TỐT NGHIỆP d oa ĐỀ TÀI: XÂY DỰNG WEBSITE VÀ QUẢN LÝ GIA CÔNG an lu CƠ KHÍ CHO CƠNG TY TNHH TM&DV CƠ KHÍ HIỆP HỊA : Đại học ul nf va Trình độ đào tạo : Công nghệ thông tin : Công nghệ thông tin z at nh Chuyên ngành oi lm Ngành : 2017-2021 Lớp : DH17CT Sinh viên thực : Nguyễn Thị Minh Thắm Mã số sinh viên : 17032486 GVHD : TS Phan Ngọc Hồng z Khóa học m co l gm @ an Lu n va ac th BÀ RỊA - VŨNG TÀU, NĂM 2021 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu LỜI CẢM ƠN Để hoàn thành đề tài báo cáo đồ án trước hết, em xin gửi đến quý thầy, cô giáo khoa Công nghệ kỹ thuật – Nông nghiệp công nghệ cao trường Đại học Bà Rịa – Vũng Tàu lời cảm ơn chân thành Đặc biệt, em xin gửi đến thầy Phan Ngọc Hoàng, người tận tình hướng dẫn, giúp đỡ em hồn thành đề tài đồ án tốt nghiệp lời cảm ơn sâu sắc Em xin chân thành cảm ơn Ban Lãnh Đạo, phịng ban cơng ty TNHH TM & lu DV Cơ Khí Hiệp Hịa, tạo điều kiện thuận lợi cho em tìm hiểu thực tiễn suốt an q trình thực tập cơng ty va n Đồng thời xin chân thành cảm ơn Ban lãnh đạo trường Đại học Bà Rịa – Vũng Tàu to tn cho môi trường học tập lành mạnh động Kính chúc Trường Đại học Bà Rịa – ie gh Vũng Tàu tiếp túc gặt hái nhiều thành công đường giáo dục hệ trẻ p Vì kiến thức thân cịn hạn chế trình độ lý luận kinh nghiệm thực tiễn nl w hạn chế nên báo cáo khơng thể tránh khỏi thiếu sót, em mong nhận oa ý kiến đóng góp thầy, để em học thêm nhiều kinh nghiệm hoàn thiện d thân đáp ứng với nhu cầu công việc thực tế tương lai lu oi lm ul nf va an Em xin chân thành cảm ơn! z at nh z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu LỜI CAM ĐOAN Tôi xin cam đoan kết đạt đồ án sản phẩm riêng cá nhân, khơng chép lại người khác Trong tồn nội dung luận văn, điều trình bày cá nhân tổng hợp từ nhiều nguồn tài liệu Tất tài liệu tham khảo có xuất xứ rõ ràng trích dẫn hợp pháp Tơi xin hồn tồn chịu trách nhiệm chịu hình thức kỷ luật theo quy định cho lời cam đoan lu an Vũng Tàu, ngày 01 tháng 01 năm 2021 va n Sinh viên thực p ie gh tn to d oa nl w Nguyễn Thị Minh Thắm oi lm ul nf va an lu z at nh z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu NHẬN XÉT CỦA GIẢNG VIÊN HƯỚNG DẪN lu an va n tn to ie gh p oa nl w d lu va an oi lm ul nf z at nh z Vũng Tàu, ngày … tháng … năm 20… m co l gm @ Người hướng dẫn TS Phan Ngọc Hoàng an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu NHẬN XÉT CỦA GIẢNG VIÊN PHẢN BIỆN lu an va n tn to ie gh p oa nl w d lu va an oi lm ul nf z at nh z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu MỤC LỤC DANH MỤC BẢNG _ DANH MỤC SƠ ĐỒ 10 DANH MỤC HÌNH _ 11 LỜI NÓI ĐẦU _ 15 CHƯƠNG TỔNG QUAN 1.1 Lý chọn đề tài _ lu an 1.2 Mục tiêu chức hệ thống va n 1.2.1 Mục tiêu _ gh tn to 1.2.2 Chức _ p ie 1.3 Mô tả toán nl w CHƯƠNG CƠ SỞ LÝ THUYẾT d oa 2.1 Giới thiệu ngôn ngữ Python _ an lu 2.1.1 Tổng quát nf va 2.1.2 Lịch sử phát triển củaPython _ oi lm ul 2.1.3 Đặc điểm ngôn ngữ Python _ 2.1.4 Tại nên chọn Python z at nh 2.1.5 Ứng dụng ngôn ngữ Python _ 2.2 Giới thiệu Flask-Python z @ gm 2.2.1 Tổng quát m co l 2.2.2 Giới thiệu Werkzeug _ 2.2.3 Giới thiệu Jinja2 _ 10 an Lu 2.2.4 Giới thiệu Flask-WTForms _ 10 n va 2.2.5 Giới thiệu Flask-SQLALchemy _ 10 ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu 2.2.6 Giới thiệu SQLite 11 2.2.7 Một số thư việc khác 11 CHƯƠNG PHÂN TÍCH HỆ THỐNG _ 12 3.1 Mô tả hệ thống 12 3.1.1 Website giới thiệu 12 3.1.2 Quản trị website 12 lu 3.1.3 Quản lý thiết bị 13 an n va 3.1.4 Quản lý nhân công 13 tn to 3.1.5 Quản lý danh sách yêu cầu _ 14 gh 3.1.6 Quản lý phiếu báo giá/hóa đơn 14 p ie 3.2 Xây dựng chức hệ thống 15 nl w 3.2.1 Mô tả chức chi tiết 15 d oa 3.2.2 Xác định use case 18 an lu 3.2.3 Đặc tả use case _ 20 nf va 3.2.4 Quy trình nghiệp vụ _ 24 oi lm ul 3.3 Thiết kế hệ thống 25 3.3.1 Sơ đồ sở liệu _ 25 z at nh 3.3.2 Chi tiết sở liệu 26 z CHƯƠNG XÂY DỰNG WEBSITE _ 30 @ l gm 4.1 Giao diện chức người dùng _ 30 4.2 Giao diện chức Admin _ 37 m co 4.3 Giao diện báo lỗi _ 67 an Lu CHƯƠNG KẾT LUẬN _ 68 n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu 5.1 Kết đạt _ 68 5.2 Hướng phát triển _ 68 CHƯƠNG TÀI LIỆU THAM KHẢO 70 PHỤ LỤC _ 71 Sơ đồ cấu trúc 71 Code xử lý _ 72 lu File models.py _ 72 an n va File forms.py _ 75 p ie gh tn to File main.py _ 77 d oa nl w oi lm ul nf va an lu z at nh z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu DANH MỤC BẢNG Bảng 3-1 Bảng mô tả chức quản lý loại sản phẩm _ 15 Bảng 3-2 Bảng mô tả chức quản lý sản phẩm 15 Bảng 3-3 Bảng mô tả chức quản lý ảnh sản phẩm 15 Bảng 3-4 Bảng mô tả chứa quản lý loại thiết bị 16 Bảng 3-5 Bảng mô tả chức quản lý thiết bị 16 Bảng 3-6 Bảng mô tả chức quản lý nhân công _ 16 Bảng 3-7 Bảng mô tả chức điểm danh 17 lu an Bảng 3-8 Bảng mô tả chức quản lý bảng lương _ 17 n va Bảng 3-9 Bảng mô tả chức quản lý phiếu yêu cầu _ 17 tn to Bảng 3-10 Bảng mô tả chức quản lý phiếu báo giá 18 gh Bảng 3-11 Bảng mô tả chức quản lý hóa đơn _ 18 p ie Bảng 3-12 Cơ sở liệu bảng loại sản phẩm _ 26 w Bảng 3-13 Cơ sở liệu bảng sản phẩm _ 26 oa nl Bảng 3-14 Cơ sở liệu bảng ảnh sản phẩm _ 26 d Bảng 3-15 Cơ sở liệu bảng loại thiết bị _ 27 an lu Bảng 3-16 Cơ sở liệu bảng thiết bị _ 27 nf va Bảng 3-17 Cơ sở liệu bảng phiếu yêu cầu _ 27 oi lm ul Bảng 3-18 Cơ sở liệu bảng nhân công 28 Bảng 3-19 Cơ sở liệu bảng lương 28 z at nh Bảng 3-20 Cơ sở liệu bảng phiếu báo giá/chiết tính _ 28 Bảng 3-21 Cơ sở liệu bảng hóa đơn 29 z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu DANH MỤC SƠ ĐỒ Sơ đồ 3-1 Sơ đồ Use case ADMIN 19 Sơ đồ 3-2 Sơ đồ Use case User _ 20 Sơ đồ 3-3 Sơ đồ đăng nhập thành công 20 Sơ đồ 3-4 Sơ đồ hợp tác đăng nhập thành công _ 21 Sơ đồ 3-5 Sơ đồ đăng nhập thất bại _ 21 Sơ đồ 3-6 Sơ đồ hợp tác đăng nhập thất bại 21 Sơ đồ 3-7 Sơ đồ trình quản lý 22 lu an Sơ đồ 3-8 Sơ đồ hợp tác trình quản lý _ 22 n va Sơ đồ 3-9 Sơ đồ trình điểm danh _ 23 tn to Sơ đồ 3-10 Sơ đồ hợp tác trình điểm danh 23 gh Sơ đồ 3-11 Quy trình kiểm tra máy móc thiết bị _ 24 p ie Sơ đồ 3-12 Sơ đồ sở liệu 25 d oa nl w oi lm ul nf va an lu z at nh z m co l gm @ an Lu n va ac th si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu db.session.commit() return redirect('/imgIndex/1') @app.route('/employeeIndex/',methods=['GET','POST']) def employeeIndex(page_num): employees = db.session.query(models.Employee).all() pages =models.Employee.query.paginate(per_page=15, page=page_num, error_out=True) print(employees) return render_template('admin/employee/employeeIndex.html',employees=employees,pages=pages ) @app.route('/newEmployee',methods=['GET','POST']) def newEmployee(): form = EmployeeForm() lu if form.validate_on_submit(): an _name=form.inputName.data va _phone=form.inputPhone.data n _address =form.inputAddress.data _cmnd =form.inputCmnd.data _position =form.inputPosition.data gh tn to _wage =form.inputWage.data ie _emp_id =request.form['hiddenEmployeeId'] p if(_emp_id == "0"): employee = models.Employee(name=_name,phone=_phone,address=_address,wage=_wage,ide nl w ntity_card_number=_cmnd,position=_position) else: d oa db.session.add(employee) lu employee = db.session.query(models.Employee).filter_by(emp_id =_emp_id).first() an employee.name =_name va employee.phone=_phone ul employee.wage=_wage nf employee.address=_address oi lm employee.identity_card_number=_cmnd employee.position=_position return redirect('/employeeIndex/1') print('add fail') z at nh db.session.commit() z return render_template('admin/employee/newEmployee.html', form = form) if(_emp_id): m co print(_emp_id) l form = EmployeeForm() gm def editEmployee(_emp_id): @ @app.route('/editEmployee/',methods=['GET','POST']) employee = db.session.query(models.Employee).filter_by(emp_id =_emp_id).first() form.inputPhone.default=employee.phone an Lu form.inputName.default=employee.name n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 86 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu form.inputAddress.default=employee.address form.inputWage.default=employee.wage form.inputCmnd.dafault=employee.identity_card_number form.inputPosition.default=employee.position form.inputCmnd.default=employee.identity_card_number form.process() return render_template('admin/employee/newEmployee.html',form=form,employee=employee) @app.route('/deleteEmployee',methods=['GET','POST']) def deleteEmployee(): _emp_id = request.form['hiddenEmployeeId'] if _emp_id: employee = db.session.query(models.Employee).filter_by(emp_id=_emp_id).first() lu print('delete complete') an db.session.delete(employee) va db.session.commit() n return redirect('/employeeIndex/1') to @app.route('/cateIndex/',methods=['GET','POST']) tn def cateIndex(page_num): gh category = db.session.query(models.Cate).all() ie pages =models.Cate.query.paginate(per_page=15, page=page_num, error_out=True) p return render_template('admin/category/cateIndex.html',category=category,pages=pages) @app.route('/newCate',methods=['GET','POST']) nl w def newCate(): oa form = CategoryObjForm() if form.validate_on_submit(): d lu _name=form.inputNameObj.data if(_cate_id == "0"): va an _cate_id =request.form['hiddenCateId'] db.session.add(catgory) oi lm else: ul nf catgory = models.Cate(name=_name) catgory = db.session.query(models.Cate).filter_by(cate_id =_cate_id).first() return redirect('/cateIndex/1') z print('add fail') z at nh catgory.name =_name db.session.commit() @ return render_template('admin/category/newCate.html', form = form) form = CategoryObjForm() m co if(_cate_id): l def editCate(_cate_id): gm @app.route('/editCate/',methods=['GET','POST']) category = db.session.query(models.Cate).filter_by(cate_id =_cate_id).first() form.process() an Lu form.inputNameObj.default=category.name n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 87 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu return render_template('admin/category/newCate.html',form=form,category=category) @app.route('/deleteCate',methods=['GET','POST']) def deleteCate(): _cate_id = request.form['hiddenCateId'] if _cate_id: category = db.session.query(models.Cate).filter_by(cate_id=_cate_id).first() if(db.session.query(models.Object).filter_by(cate_id=_cate_id).count()==0): db.session.delete(category) db.session.commit() else: flash('Khơng thể xóa loại thiết bị có thiết bị') print('delete complete') lu return redirect('/cateIndex/1') an @app.route('/categoryIndex/',methods=['GET','POST']) category = db.session.query(models.Category).all() n va def categoryIndex(page_num): return render_template('admin/category/categoryIndex.html',category=category,pages=pages) tn to pages =models.Category.query.paginate(per_page=15, page=page_num, error_out=True) gh @app.route('/newCategory',methods=['GET','POST']) ie def newCategory(): p form = CategoryForm() if form.validate_on_submit(): nl w _name=form.inputName.data oa _cate_id =request.form['hiddenCateId'] if(_cate_id == "0"): d lu catgory = models.Category(name=_name) va else: an db.session.add(catgory) oi lm ul catgory.name =_name db.session.commit() nf catgory = db.session.query(models.Category).filter_by(cate_id =_cate_id).first() return redirect('/categoryIndex/1') z at nh print('add fail') return render_template('admin/category/newCategory.html', form = form) @app.route('/editCategory/',methods=['GET','POST']) z def editCategory(_cate_id): gm if(_cate_id): @ form = CategoryForm() form.inputName.default=category.name m co form.process() l category = db.session.query(models.Category).filter_by(cate_id =_cate_id).first() return render_template('admin/category/newCategory.html',form=form,category=category) def deleteCategory(): an Lu @app.route('/deleteCategory',methods=['GET','POST']) n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 88 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu _cate_id = request.form['hiddenCateId'] if _cate_id: category = db.session.query(models.Category).filter_by(cate_id=_cate_id).first() pd=db.session.query(models.Product).all() print(_cate_id) print(category) if(db.session.query(models.Product).filter_by(cate_id=_cate_id).count()==0): print('hi') db.session.delete(category) db.session.commit() else: print('hello') lu flash('Khơng thể xóa loại sản phẩm có sản phẩm') an return redirect('/categoryIndex/1') def objectIndex(page_num): n va @app.route('/objectIndex/',methods=['GET','POST']) wos=db.session.query(models.Workorder).all() tn to objects = db.session.query(models.Object).all() gh pages =models.Object.query.paginate(per_page=15, page=page_num, error_out=True) ie return render_template('admin/object/objectIndex.html',objects=objects,pages=pages) p @app.route('/newAsset',methods=['GET','POST']) def newAsset(): nl w form = ObjectForm() oa form.inputCategory.choices=[(a.cate_id,a.name)for a in db.session.query(models.Cate).all() ] d lu if form.validate_on_submit(): an _name=form.inputName.data va _amount =form.inputAmount.data nf _model=form.inputModel.data _cate=form.inputCategory.data oi lm _man=form.inputMan.data ul _status=form.inputStatus.data st=form.inputCategory.data z at nh _date=form.inputDate_install.data _obj_id =request.form['hiddenObjectId'] z if(_obj_id == "0"): m co l gm db.session.add(asset) else: @ asset = models.Object(name=_name,amount=_amount,model=_model,status=st,install_day =_date,manufacturer=_man,cate_id=_cate) asset = db.session.query(models.Object).filter_by(obj_id =_obj_id).first() asset.name=_name asset.model=_model an Lu asset.amount=_amount n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 89 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu asset.status=_status asset.manufacturer=_man asset.cate_id=_cate asset.install_day=_date db.session.commit() print("create successly") return redirect('/objectIndex/1') print('add fail') return render_template('admin/object/newAsset.html', form = form) @app.route('/editAsset/',methods=['GET','POST']) def editAsset(_obj_id): form = ObjectForm() lu form.inputCategory.choices=[(a.cate_id,a.name)for a in db.session.query(models.Cate).a an ll()] va if(_obj_id): n st="0" to asset = db.session.query(models.Object).filter_by(obj_id =_obj_id).first() form.inputAmount.default=asset.amount form.inputModel.default=asset.model ie gh tn form.inputName.default=asset.name p form.inputMan.default=asset.manufacturer form.inputCategory.default=asset.cate_id nl w form.inputStatus.default=asset.status oa form.inputDate_install.default=asset.install_day form.process() d lu return render_template('admin/object/newAsset.html',form=form,asset=asset) va def deleteAsset(): an @app.route('/deleteAsset',methods=['GET','POST']) ul if _obj_id: nf _obj_id = request.form['hiddenObjectId'] obj.status='0' z at nh db.session.commit() return redirect('/objectIndex/1') oi lm obj = db.session.query(models.Object).filter_by(obj_id=_obj_id).first() @app.route('/payrollIndex/',methods=['GET','POST']) z def payrollIndex(page_num): gm emp= db.session.query(models.Employee).all() @ salary = db.session.query(models.Payrolls).all() l pages =models.Payrolls.query.paginate(per_page=15, page=page_num, error_out=True) return render_template('admin/Payroll/payrollIndex.html',salary=salary,emp=emp,pages=pages @app.route('/prinpayroll',methods=['GET','POST']) day=today.day an Lu def prinpayroll(): m co ) n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 90 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu month=today.month year=today.year salary = db.session.query(models.Payrolls).all() emp= db.session.query(models.Employee).all() render= render_template('admin/Payroll/prinpayroll.html',salary=salary,emp=emp,day=day,mon th=month,year=year) wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' config = pdfkit.configuration(wkhtmltopdf=wkt_path) options = {'encoding': "UTF-8"} pdf=pdfkit.from_string(render,False,configuration=config,options=options) response=make_response(pdf) response.headers['Content-type']='payroll/pdf' lu response.headers['Content-Disposition']='inline;filename=output.pdf' an return response def printpayroll_current(): n va @app.route('/printpayroll_current',methods=['GET','POST']) day=today.day tn to month=today.month gh year=today.year ie days_per_month = {1: 31, 2: 29, 3: 31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31} p # lower bound first = today.replace(day=1).strftime('%Y-%m-%d') nl w # upper bound oa try: last = today.replace(day=days_per_month[today.month]).strftime('%Y-%m-%d') d lu except ValueError: # Not a leap year an if today.month == 2: # just to be safe, in case there's some other error I missed ul raise nf va last = today.replace(day=28).strftime('%Y-%m-%d') else: oi lm salary = models.Payrolls.query.filter(models.Payrolls.date.between(first,last)) emp= db.session.query(models.Employee).all() z at nh render= render_template('admin/Payroll/prinpayroll.html',salary=salary,emp=emp,day=day,mon th=month,year=year) wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' z config = pdfkit.configuration(wkhtmltopdf=wkt_path) @ options = {'encoding': "UTF-8"} response.headers['Content-type']='payroll/pdf' m co l response=make_response(pdf) gm pdf=pdfkit.from_string(render,False,configuration=config,options=options) response.headers['Content-Disposition']='inline;filename=output.pdf' return response def payroll(_pr_id): an Lu @app.route('/payroll/',methods=['GET','POST']) n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 91 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu form = PayForm() emp= db.session.query(models.Employee).all() pay = db.session.query(models.Payrolls).filter_by(pr_id =_pr_id).first() emp_id=pay.emp_id if(_pr_id): print('hello') if form.validate_on_submit(): _reward=form.inputReward.data sa=pay.salary sumsalary=int(sa)+_reward s= db.session.query(models.Payrolls).filter_by(pr_id =_pr_id).first() s.reward=_reward lu s.salary=sumsalary an db.session.commit() va return redirect('/payrollIndex/1') n return render_template('admin/Payroll/payroll.html',form=form,emp_id=emp_id,emp=emp,_pr_id to =_pr_id) tn @app.route('/deleteSalary',methods=['GET','POST']) gh def deleteSalary(): ie _pay_id = request.form['hiddenSalaryId'] p if _pay_id: pay = db.session.query(models.Payrolls).filter_by(pr_id=_pay_id).first() nl w print('delete complete') oa db.session.delete(pay) db.session.commit() d va def not_found_error(error): an lu return redirect('/payrollIndex/1') @app.errorhandler(404) nf return render_template('error.html'), 404 oi lm def wosIndex(page_num): ul @app.route('/wosIndex/',methods=['GET','POST']) wo=db.session.query(models.Workorder).all() z at nh obj=db.session.query(models.Object).all() pages=models.Workorder.query.paginate(per_page=15, page=page_num, error_out=True) return render_template('admin/workorder/woIndex.html',wo=wo,pages=pages,obj=obj) z @app.route('/workOrder',methods=['GET','POST']) gm form = WorkorderForm() @ def workOrder(): l form.inputObj.choices=[(p.obj_id,p.name)for p in db.session.query(models.Object).all()] form.inputEmp.choices=[(p.emp_id,p.name)for p in db.session.query(models.Employee).all()] _obj_id= form.inputObj.data _name= form.inputName.data an Lu _emp_id=form.inputEmp.data m co if form.validate_on_submit(): n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 92 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu _type=form.inputType.data _Priority=form.inputPriority.data if(_type == "0"): type_ = False else: type_=True _cmt=form.inputCmt.data _deadline=form.inputDeadline.data _date= datetime.now() _wo_id =request.form['hiddenWoId'] if(_wo_id == "0"): wos=models.Workorder(obj_id=_obj_id,emp_id=_emp_id,wo_name=_name,wo_type=type_,wo_ lu priority=_Priority,wo_deadline=_deadline,wo_status=False,wo_date=_date,wo_cmt=_cmt) an db.session.add(wos) va else: n wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() to wo.obj_id=_obj_id wo.wo_name=_name wo.wo_type=type_ ie gh tn wo.emp_id=_emp_id p wo.wo_priority=_Priority wo.wo_status=False nl w wo.wo_date=_date oa wo.wo_deadline=_deadline wo.wo_cmt=_cmt d lu db.session.commit() an return redirect('/wosIndex/1') va return render_template('admin/workorder/wos.html',form=form) month=today.month z at nh year=today.year oi lm day=today.day ul def printWO(_wo_id): nf @app.route('/printWO/',methods=['GET','POST']) wo= db.session.query(models.Workorder).filter_by(wo_id=_wo_id) emp=db.session.query(models.Employee).all() z obj=db.session.query(models.Object).all() gm @ render= render_template('admin/workorder/printWO.html',wo=wo,emp=emp,obj=obj,day=day,month =month,year=year) config = pdfkit.configuration(wkhtmltopdf=wkt_path) m co options = {'encoding': "UTF-8"} l wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' pdf=pdfkit.from_string(render,False,configuration=config,options=options) response.headers['Content-type']='Workorder/pdf' an Lu response=make_response(pdf) n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 93 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/editWO/',methods=['GET','POST']) def editWO(_wo_id): form = WorkorderForm() form.inputObj.choices=[(p.obj_id,p.name)for p in db.session.query(models.Object).all() ] form.inputEmp.choices=[(p.emp_id,p.name)for p in db.session.query(models.Employee).all ()] if(_wo_id): wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() form.inputObj.default=wo.obj_id lu form.inputEmp.default=wo.emp_id an form.inputName.default=wo.wo_name va form.inputType.default=wo.wo_type n form.inputPriority.default=wo.wo_priority to form.inputDeadline.default=wo.wo_deadline gh tn form.inputCmt.default=wo.wo_cmt form.process() ie return render_template('admin/workorder/wos.html',form=form,wo=wo) p @app.route('/deleteWos',methods=['GET','POST']) def deleteWos(): oa if _wo_id: nl w _wo_id = request.form['hiddenWoId'] wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() d lu print('delete complete') va db.session.commit() an db.session.delete(wo) nf return redirect('/wosIndex/1') oi lm def doneWos(): ul @app.route('/doneWos',methods=['GET','POST']) _wo_id = request.form['hiddenWoId'] z at nh if _wo_id: wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() print('delete complete') z wo.wo_status=True if _wo_id: m co _wo_id = request.form['hiddenWoId'] l def cancelWos(): gm @app.route('/cancelWos',methods=['GET','POST']) @ db.session.commit() return redirect('/wosIndex/1') an Lu wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() print('delete complete') n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 94 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu wo.wo_status=False db.session.commit() return redirect('/wosIndex/1') @app.route('/listtt',methods=['GET','POST']) def listtt(): wo=db.session.query(models.Workorder).filter_by(wo_type =False) return render_template('admin/workorder/listtt.html',wo=wo) @app.route('/listtm',methods=['GET','POST']) def listtm(): wo=db.session.query(models.Workorder).filter_by(wo_type =True) return render_template('admin/workorder/listtm.html',wo=wo) @app.route('/quotation',methods=['GET','POST']) lu def quotation(): an form= QuotationForm() va if form.validate_on_submit(): n _qt_name= form.inputQtName.data _cus_add=form.inputCusAdd.data _qt_num=form.inputQtNubmer.data gh tn to _cus_name=form.inputCusName.data ie _contnet=form.inputContent.data p _date= datetime.now() _qt_id =request.form['hiddenQtId'] nl w if(_qt_id == "0"): oa qt= models.Quotation(qt_name=_qt_name,cus_name=_cus_name,cus_add=_cus_add,qt_numbe r=_qt_num,qt_date=_date,qt_content=_contnet) d an lu db.session.add(qt) else: qt.qt_name=_qt_name qt.qt_number=_qt_num qt.qt_date=_date db.session.commit() z return redirect('/quotationIndex') z at nh qt.qt_content=_contnet oi lm qt.cus_add=_cus_add ul qt.cus_name=_cus_name nf va qt = db.session.query(models.Quotation).filter_by(qt_id =_qt_id).first() m co l qt=db.session.query(models.Quotation).all() gm def quotationIndex(): @ return render_template('admin/workorder/quotation.html',form=form) @app.route('/quotationIndex',methods=['GET','POST']) return render_template('admin/workorder/quotationIndex.html',qt=qt) @app.route('/viewQuotation/',methods=['GET','POST']) detail= db.session.query(models.Quotation).filter_by(qt_id=_qt_id) an Lu def viewQuotation(_qt_id): n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 95 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu return render_template('admin/workorder/viewQuotation.html',detail=detail) @app.route('/editQt/',methods=['GET','POST']) def editQt(_qt_id): form = QuotationForm() if(_qt_id): qt = db.session.query(models.Quotation).filter_by(qt_id =_qt_id).first() form.inputQtName.default=qt.qt_name form.inputCusName.default=qt.cus_name form.inputCusAdd.default=qt.cus_add form.inputQtNubmer.default=qt.qt_number form.inputContent.default=qt.qt_content form.process() lu return render_template('admin/workorder/quotation.html',form=form,qt=qt) an @app.route('/printQT/',methods=['GET','POST']) detail= db.session.query(models.Quotation).filter_by(qt_id=_qt_id) n va def printQT(_qt_id): wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' tn to render= render_template('admin/workorder/printQT.html',detail=detail) gh config = pdfkit.configuration(wkhtmltopdf=wkt_path) ie options = {'encoding': "UTF-8"} p pdf=pdfkit.from_string(render,False,configuration=config,options=options) response=make_response(pdf) nl w response.headers['Content-type']='quotation/pdf' return response d oa response.headers['Content-Disposition']='inline;filename=output.pdf' an def deleteQt(): lu @app.route('/deleteQt',methods=['GET','POST']) nf if _qt_id: va _qt_id = request.form['hiddenQtId'] db.session.delete(qt) return redirect('/quotationIndex') @app.route('/bill',methods=['GET','POST']) z def bill(): z at nh db.session.commit() oi lm print('delete complete') ul qt = db.session.query(models.Quotation).filter_by(qt_id =_qt_id).first() _cus_name=form.inputCus_name.data _bill_content=form.inputBill_content.data _tem=_date.month an Lu _date=form.inputDate.data m co _cus_add=form.inputCus_add.data l _bill_num=form.inputBill_num.data gm if form.validate_on_submit(): @ form= BillForm() n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 96 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu _ad_money=form.inputAdmoney.data _sum=form.inputSum.data _complete=form.inputComplete.data if(_complete == "0"): complete_ = False else: complete_=True sum_=_sum money=_ad_money total= float(sum_) -float(money) _bill_id =request.form['hiddenBillId'] if(_bill_id == "0"): lu bill=models.Invoice(bill_num=_bill_num,cus_name=_cus_name,cus_add=_cus_add,bill_co an ntent=_bill_content,bill_date=_date,bill_sumprice=_sum,bill_ad_money=_ad_money,bill_total=tota db.session.add(bill) n va l,bill_complete=complete_) bill = db.session.query(models.Invoice).filter_by(bill_id =_bill_id).first() bill.bill_num=_bill_num bill.cus_name=_cus_name ie gh tn to else: p bill.cus_add=_cus_add bill.bill_content=_bill_content nl w bill.bill_date=_date oa bill.bill_ad_money=_ad_money bill.bill_sumprice=_sum d lu bill.bill_complete=complete_ va db.session.commit() an bill.bill_total=total nf return redirect('/billIndex/1') ul return render_template('admin/bill/bill.html',form=form) def billIndex(page_num): oi lm @app.route('/billIndex/',methods=['GET','POST']) z at nh bill=db.session.query(models.Invoice).all() pages =models.Invoice.query.paginate(per_page=10, page=page_num, error_out=True) return render_template('admin/bill/billIndex.html',bill=bill,pages=pages) z @app.route('/editBill/',methods=['GET','POST']) l if(_bill_id): gm form = BillForm() @ def editBill(_bill_id): bill = db.session.query(models.Invoice).filter_by(bill_id =_bill_id).first() form.inputCus_name.default=bill.cus_name form.inputBill_content.default=bill.bill_content an Lu form.inputCus_add.default=bill.cus_add m co form.inputBill_num.default=bill.bill_num n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 97 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu form.inputAdmoney.default=bill.bill_ad_money form.inputSum.default=bill.bill_sumprice form.inputDate.default=bill.bill_date form.inputComplete.default=bill.bill_complete form.process() return render_template('admin/bill/bill.html',form=form,bill=bill) @app.route('/deleteBill',methods=['GET','POST']) def deleteBill(): _bill_id = request.form['hiddenBillId'] if _bill_id: bill = db.session.query(models.Invoice).filter_by(bill_id =_bill_id).first() print('delete complete') lu db.session.delete(bill) an db.session.commit() @app.route('/prinAllInvoice',methods=['GET','POST']) n va return redirect('/billIndex/1') day=today.day tn to def prinAllInvoice(): gh month=today.month ie year=today.year p invoice = db.session.query(models.Invoice).all() render= render_template('admin/bill/printallInvoice.html',invoice=invoice,day=day,month=mo nl w nth,year=year) oa wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' config = pdfkit.configuration(wkhtmltopdf=wkt_path) d lu options = {'encoding': "UTF-8"} an pdf=pdfkit.from_string(render,False,configuration=config,options=options) va response=make_response(pdf) nf response.headers['Content-type']='invoice/pdf' oi lm return response ul response.headers['Content-Disposition']='inline;filename=output.pdf' @app.route('/prinInvoice',methods=['GET','POST']) monhth=today.month day=today.day z year=today.year z at nh def prinInvoice(): @ print(monhth) first = today.replace(day=1).strftime('%Y-%m-%d') try: m co # upper bound l # lower bound gm days_per_month = {1: 31, 2: 29, 3: 31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31} an Lu last = today.replace(day=days_per_month[today.month]).strftime('%Y-%m-%d') except ValueError: n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 98 si Đồ án tốt nghiệp khóa 2017-2021 if today.month == 2: Trường Đại học Bà Rịa- Vũng Tàu # Not a leap year last = today.replace(day=28).strftime('%Y-%m-%d') else: raise # just to be safe, in case there's some other error I missed bill = models.Invoice.query.filter(models.Invoice.bill_date.between(first,last)) render= render_template('admin/bill/print.html',bill=bill,day=day,monhth=monhth,year=year) wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' config = pdfkit.configuration(wkhtmltopdf=wkt_path) options = {'encoding': "UTF-8"} pdf=pdfkit.from_string(render,False,configuration=config,options=options) response=make_response(pdf) response.headers['Content-type']='invoice/pdf' lu response.headers['Content-Disposition']='inline;filename=output.pdf' an return response def attendance(): n va @app.route('/attendance',methods=['GET','POST']) form.inputEmployee.choices=[(p.emp_id,p.name)for p in db.session.query(models.Employee).al l()] gh tn to form = AttendanceForm() ie if form.validate_on_submit(): p _emp_id= form.inputEmployee.data _date= form.inputDate.data nl w qt=db.session.query(models.Attendance).all() oa for i in qt: if(i.emp_id ==_emp_id and i.date==_date): d lu flash('Nhân viên điểm danh hôm nay') an return render_template('admin/attendance/attendance.html',form=form) oi lm db.session.commit() ul print('Success') nf db.session.add(ad) va ad=models.Attendance(emp_id=_emp_id,date=_date,working_day=1) return render_template('admin/attendance/attendance.html',form=form) def pay(_emp_id): count=0 z _s=0 z at nh @app.route('/pay/',methods=['GET','POST']) l print(day) gm day=today @ month=today.month ad= db.session.query(models.Attendance).filter_by(emp_id=_emp_id) if(i.date.month==month): print(count) an Lu count+=i.working_day m co for i in ad: n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 99 si Đồ án tốt nghiệp khóa 2017-2021 Trường Đại học Bà Rịa- Vũng Tàu _wage=db.session.query(models.Employee.wage).filter_by(emp_id=_emp_id).first() y = ''.join(map(str, _wage)) z = int(y) _s=count*z pay=db.session.query(models.Payrolls).all() for i in pay: if(i.emp_id ==_emp_id and i.date.month==month): flash('Nhân viên tính lương tháng '+str(month)) return redirect('/employeeIndex/1') salary=models.Payrolls(emp_id=_emp_id,date=day,reward=0,salary=_s) db.session.add(salary) print('Success') lu db.session.commit() an return redirect('/payrollIndex/1') @app.route('/prinAllObject',methods=['GET','POST']) n va return redirect('/employeeIndex/1') day=today.day tn to def prinAllObject(): gh month=today.month ie year=today.year p obj = db.session.query(models.Object).all() render= render_template('admin/object/printObject.html',obj=obj,day=day,month=month,year=y nl w ear) oa wkt_path='C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe' config = pdfkit.configuration(wkhtmltopdf=wkt_path) d lu options = {'encoding': "UTF-8"} an pdf=pdfkit.from_string(render,False,configuration=config,options=options) va response=make_response(pdf) nf response.headers['Content-type']='object/pdf' oi lm return response ul response.headers['Content-Disposition']='inline;filename=output.pdf' @app.route('/list_overdue',methods=['GET','SET']) print(today) z at nh def list_overdue(): emp = db.session.query(models.Employee).all() z obj = db.session.query(models.Object).all() @ wo = models.Workorder.query.filter(models.Workorder.wo_deadline >today) app.run(debug=True) m co l if name == ' main ': gm return render_template('admin/workorder/list_overdue.html',wo=wo,emp=emp,obj=obj) an Lu n va GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM ac th 100 si

Ngày đăng: 17/07/2023, 09:48

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w