(Luận văn tốt nghiệp) 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 3 0
(Luận văn tốt nghiệp) 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

Đ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

TRƯỜNG ĐẠI HỌC BÀ RỊA – VŨNG TÀU KHOA CNKT – NN - CNC - - BÁO CÁO ĐỒ ÁN TỐT NGHIỆP ĐỀ TÀI: XÂY DỰNG WEBSITE VÀ QUẢN LÝ GIA CƠNG CƠ KHÍ CHO CƠNG TY TNHH TM&DV CƠ KHÍ HIỆP HỊA Trình độ đào tạo : Đại học Ngành : Công nghệ thông tin Chuyên ngành : Cơng nghệ thơng tin Khóa học : 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 Hoàng BÀ RỊA - VŨNG TÀU, NĂM 2021 Luan van Đồ á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 Hồng, người tận tình hướng dẫn, giúp đỡ em hoà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 & 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 trình thực tập công ty Đồ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 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 – 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ẻ Vì kiến thức thân cịn hạn chế trình độ lý luận kinh nghiệm thực tiễn hạn chế nên báo cáo khơng thể tránh khỏi thiếu sót, em mong nhận ý kiến đóng góp thầy, để em học thêm nhiều kinh nghiệm hồn thiện thân đáp ứng với nhu cầu cơng việc thực tế tương lai Em xin chân thành cảm ơn! Luan van Đồ á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 toà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 Vũng Tàu, ngày 01 tháng 01 năm 2021 Sinh viên thực Nguyễn Thị Minh Thắm Luan van Đồ á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 Vũng Tàu, ngày … tháng … năm 20… Người hướng dẫn TS Phan Ngọc Hoàng Luan van Đồ á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 Luan van Đồ á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 _ 1.2 Mục tiêu chức hệ thống 1.2.1 Mục tiêu _ 1.2.2 Chức _ 1.3 Mơ tả tốn CHƯƠNG CƠ SỞ LÝ THUYẾT 2.1 Giới thiệu ngôn ngữ Python _ 2.1.1 Tổng quát 2.1.2 Lịch sử phát triển củaPython _ 2.1.3 Đặc điểm ngôn ngữ Python _ 2.1.4 Tại nên chọn Python 2.1.5 Ứng dụng ngôn ngữ Python _ 2.2 Giới thiệu Flask-Python 2.2.1 Tổng quát 2.2.2 Giới thiệu Werkzeug _ 2.2.3 Giới thiệu Jinja2 _ 10 2.2.4 Giới thiệu Flask-WTForms _ 10 2.2.5 Giới thiệu Flask-SQLALchemy _ 10 Luan van Đồ á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 3.1.3 Quản lý thiết bị 13 3.1.4 Quản lý nhân công 13 3.1.5 Quản lý danh sách yêu cầu _ 14 3.1.6 Quản lý phiếu báo giá/hóa đơn 14 3.2 Xây dựng chức hệ thống 15 3.2.1 Mô tả chức chi tiết 15 3.2.2 Xác định use case 18 3.2.3 Đặc tả use case _ 20 3.2.4 Quy trình nghiệp vụ _ 24 3.3 Thiết kế hệ thống 25 3.3.1 Sơ đồ sở liệu _ 25 3.3.2 Chi tiết sở liệu 26 CHƯƠNG XÂY DỰNG WEBSITE _ 30 4.1 Giao diện chức người dùng _ 30 4.2 Giao diện chức Admin _ 37 4.3 Giao diện báo lỗi _ 67 CHƯƠNG KẾT LUẬN _ 68 Luan van Đồ á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 File models.py _ 72 File forms.py _ 75 File main.py _ 77 Luan van Đồ á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 Bảng 3-8 Bảng mô tả chức quản lý bảng lương _ 17 Bảng 3-9 Bảng mô tả chức quản lý phiếu yêu cầu _ 17 Bảng 3-10 Bảng mô tả chức quản lý phiếu báo giá 18 Bảng 3-11 Bảng mô tả chức quản lý hóa đơn _ 18 Bảng 3-12 Cơ sở liệu bảng loại sản phẩm _ 26 Bảng 3-13 Cơ sở liệu bảng sản phẩm _ 26 Bảng 3-14 Cơ sở liệu bảng ảnh sản phẩm _ 26 Bảng 3-15 Cơ sở liệu bảng loại thiết bị _ 27 Bảng 3-16 Cơ sở liệu bảng thiết bị _ 27 Bảng 3-17 Cơ sở liệu bảng phiếu yêu cầu _ 27 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 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 Luan van Đồ á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 Sơ đồ 3-8 Sơ đồ hợp tác trình quản lý _ 22 Sơ đồ 3-9 Sơ đồ trình điểm danh _ 23 Sơ đồ 3-10 Sơ đồ hợp tác trình điểm danh 23 Sơ đồ 3-11 Quy trình kiểm tra máy móc thiết bị _ 24 Sơ đồ 3-12 Sơ đồ sở liệu 25 Luan van Đồ á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() if form.validate_on_submit(): _name=form.inputName.data _phone=form.inputPhone.data _address =form.inputAddress.data _wage =form.inputWage.data _cmnd =form.inputCmnd.data _position =form.inputPosition.data _emp_id =request.form['hiddenEmployeeId'] if(_emp_id == "0"): employee = models.Employee(name=_name,phone=_phone,address=_address,wage=_wage,ide ntity_card_number=_cmnd,position=_position) db.session.add(employee) else: employee = db.session.query(models.Employee).filter_by(emp_id =_emp_id).first() employee.name =_name employee.phone=_phone employee.address=_address employee.wage=_wage employee.identity_card_number=_cmnd employee.position=_position db.session.commit() return redirect('/employeeIndex/1') print('add fail') return render_template('admin/employee/newEmployee.html', form = form) @app.route('/editEmployee/',methods=['GET','POST']) def editEmployee(_emp_id): form = EmployeeForm() if(_emp_id): print(_emp_id) employee = db.session.query(models.Employee).filter_by(emp_id =_emp_id).first() form.inputName.default=employee.name form.inputPhone.default=employee.phone GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 86 Đồ á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() print('delete complete') db.session.delete(employee) db.session.commit() return redirect('/employeeIndex/1') @app.route('/cateIndex/',methods=['GET','POST']) def cateIndex(page_num): category = db.session.query(models.Cate).all() pages =models.Cate.query.paginate(per_page=15, page=page_num, error_out=True) return render_template('admin/category/cateIndex.html',category=category,pages=pages) @app.route('/newCate',methods=['GET','POST']) def newCate(): form = CategoryObjForm() if form.validate_on_submit(): _name=form.inputNameObj.data _cate_id =request.form['hiddenCateId'] if(_cate_id == "0"): catgory = models.Cate(name=_name) db.session.add(catgory) else: catgory = db.session.query(models.Cate).filter_by(cate_id =_cate_id).first() catgory.name =_name db.session.commit() return redirect('/cateIndex/1') print('add fail') return render_template('admin/category/newCate.html', form = form) @app.route('/editCate/',methods=['GET','POST']) def editCate(_cate_id): form = CategoryObjForm() if(_cate_id): category = db.session.query(models.Cate).filter_by(cate_id =_cate_id).first() form.inputNameObj.default=category.name form.process() GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 87 Đồ á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') return redirect('/cateIndex/1') @app.route('/categoryIndex/',methods=['GET','POST']) def categoryIndex(page_num): category = db.session.query(models.Category).all() pages =models.Category.query.paginate(per_page=15, page=page_num, error_out=True) return render_template('admin/category/categoryIndex.html',category=category,pages=pages) @app.route('/newCategory',methods=['GET','POST']) def newCategory(): form = CategoryForm() if form.validate_on_submit(): _name=form.inputName.data _cate_id =request.form['hiddenCateId'] if(_cate_id == "0"): catgory = models.Category(name=_name) db.session.add(catgory) else: catgory = db.session.query(models.Category).filter_by(cate_id =_cate_id).first() catgory.name =_name db.session.commit() return redirect('/categoryIndex/1') print('add fail') return render_template('admin/category/newCategory.html', form = form) @app.route('/editCategory/',methods=['GET','POST']) def editCategory(_cate_id): form = CategoryForm() if(_cate_id): category = db.session.query(models.Category).filter_by(cate_id =_cate_id).first() form.inputName.default=category.name form.process() return render_template('admin/category/newCategory.html',form=form,category=category) @app.route('/deleteCategory',methods=['GET','POST']) def deleteCategory(): GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 88 Đồ á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') flash('Khơng thể xóa loại sản phẩm có sản phẩm') return redirect('/categoryIndex/1') @app.route('/objectIndex/',methods=['GET','POST']) def objectIndex(page_num): objects = db.session.query(models.Object).all() wos=db.session.query(models.Workorder).all() pages =models.Object.query.paginate(per_page=15, page=page_num, error_out=True) return render_template('admin/object/objectIndex.html',objects=objects,pages=pages) @app.route('/newAsset',methods=['GET','POST']) def newAsset(): form = ObjectForm() form.inputCategory.choices=[(a.cate_id,a.name)for a in db.session.query(models.Cate).all() ] if form.validate_on_submit(): _name=form.inputName.data _amount =form.inputAmount.data _model=form.inputModel.data _status=form.inputStatus.data _man=form.inputMan.data _cate=form.inputCategory.data _date=form.inputDate_install.data st=form.inputCategory.data _obj_id =request.form['hiddenObjectId'] if(_obj_id == "0"): asset = models.Object(name=_name,amount=_amount,model=_model,status=st,install_day =_date,manufacturer=_man,cate_id=_cate) db.session.add(asset) else: asset = db.session.query(models.Object).filter_by(obj_id =_obj_id).first() asset.name=_name asset.amount=_amount asset.model=_model GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 89 Đồ á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() form.inputCategory.choices=[(a.cate_id,a.name)for a in db.session.query(models.Cate).a ll()] if(_obj_id): st="0" asset = db.session.query(models.Object).filter_by(obj_id =_obj_id).first() form.inputName.default=asset.name form.inputAmount.default=asset.amount form.inputModel.default=asset.model form.inputMan.default=asset.manufacturer form.inputCategory.default=asset.cate_id form.inputStatus.default=asset.status form.inputDate_install.default=asset.install_day form.process() return render_template('admin/object/newAsset.html',form=form,asset=asset) @app.route('/deleteAsset',methods=['GET','POST']) def deleteAsset(): _obj_id = request.form['hiddenObjectId'] if _obj_id: obj = db.session.query(models.Object).filter_by(obj_id=_obj_id).first() obj.status='0' db.session.commit() return redirect('/objectIndex/1') @app.route('/payrollIndex/',methods=['GET','POST']) def payrollIndex(page_num): salary = db.session.query(models.Payrolls).all() emp= db.session.query(models.Employee).all() 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']) def prinpayroll(): day=today.day GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 90 Đồ á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' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/printpayroll_current',methods=['GET','POST']) def printpayroll_current(): month=today.month day=today.day year=today.year 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} # lower bound first = today.replace(day=1).strftime('%Y-%m-%d') # upper bound try: last = today.replace(day=days_per_month[today.month]).strftime('%Y-%m-%d') except ValueError: if today.month == 2: # 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 salary = models.Payrolls.query.filter(models.Payrolls.date.between(first,last)) 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' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/payroll/',methods=['GET','POST']) def payroll(_pr_id): GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 91 Đồ á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 s.salary=sumsalary db.session.commit() return redirect('/payrollIndex/1') return render_template('admin/Payroll/payroll.html',form=form,emp_id=emp_id,emp=emp,_pr_id =_pr_id) @app.route('/deleteSalary',methods=['GET','POST']) def deleteSalary(): _pay_id = request.form['hiddenSalaryId'] if _pay_id: pay = db.session.query(models.Payrolls).filter_by(pr_id=_pay_id).first() print('delete complete') db.session.delete(pay) db.session.commit() return redirect('/payrollIndex/1') @app.errorhandler(404) def not_found_error(error): return render_template('error.html'), 404 @app.route('/wosIndex/',methods=['GET','POST']) def wosIndex(page_num): wo=db.session.query(models.Workorder).all() 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) @app.route('/workOrder',methods=['GET','POST']) def workOrder(): 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 form.validate_on_submit(): _obj_id= form.inputObj.data _emp_id=form.inputEmp.data _name= form.inputName.data GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 92 Đồ á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_ priority=_Priority,wo_deadline=_deadline,wo_status=False,wo_date=_date,wo_cmt=_cmt) db.session.add(wos) else: wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() wo.obj_id=_obj_id wo.emp_id=_emp_id wo.wo_name=_name wo.wo_type=type_ wo.wo_priority=_Priority wo.wo_status=False wo.wo_date=_date wo.wo_deadline=_deadline wo.wo_cmt=_cmt db.session.commit() return redirect('/wosIndex/1') return render_template('admin/workorder/wos.html',form=form) @app.route('/printWO/',methods=['GET','POST']) def printWO(_wo_id): day=today.day month=today.month year=today.year wo= db.session.query(models.Workorder).filter_by(wo_id=_wo_id) emp=db.session.query(models.Employee).all() obj=db.session.query(models.Object).all() render= render_template('admin/workorder/printWO.html',wo=wo,emp=emp,obj=obj,day=day,month =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']='Workorder/pdf' GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 93 Đồ á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 form.inputEmp.default=wo.emp_id form.inputName.default=wo.wo_name form.inputType.default=wo.wo_type form.inputPriority.default=wo.wo_priority form.inputDeadline.default=wo.wo_deadline form.inputCmt.default=wo.wo_cmt form.process() return render_template('admin/workorder/wos.html',form=form,wo=wo) @app.route('/deleteWos',methods=['GET','POST']) def deleteWos(): _wo_id = request.form['hiddenWoId'] if _wo_id: wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() print('delete complete') db.session.delete(wo) db.session.commit() return redirect('/wosIndex/1') @app.route('/doneWos',methods=['GET','POST']) def doneWos(): _wo_id = request.form['hiddenWoId'] if _wo_id: wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() print('delete complete') wo.wo_status=True db.session.commit() return redirect('/wosIndex/1') @app.route('/cancelWos',methods=['GET','POST']) def cancelWos(): _wo_id = request.form['hiddenWoId'] if _wo_id: wo = db.session.query(models.Workorder).filter_by(wo_id =_wo_id).first() print('delete complete') GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 94 Đồ á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']) def quotation(): form= QuotationForm() if form.validate_on_submit(): _qt_name= form.inputQtName.data _cus_name=form.inputCusName.data _cus_add=form.inputCusAdd.data _qt_num=form.inputQtNubmer.data _contnet=form.inputContent.data _date= datetime.now() _qt_id =request.form['hiddenQtId'] if(_qt_id == "0"): 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) db.session.add(qt) else: qt = db.session.query(models.Quotation).filter_by(qt_id =_qt_id).first() qt.qt_name=_qt_name qt.cus_name=_cus_name qt.cus_add=_cus_add qt.qt_number=_qt_num qt.qt_content=_contnet qt.qt_date=_date db.session.commit() return redirect('/quotationIndex') return render_template('admin/workorder/quotation.html',form=form) @app.route('/quotationIndex',methods=['GET','POST']) def quotationIndex(): qt=db.session.query(models.Quotation).all() return render_template('admin/workorder/quotationIndex.html',qt=qt) @app.route('/viewQuotation/',methods=['GET','POST']) def viewQuotation(_qt_id): detail= db.session.query(models.Quotation).filter_by(qt_id=_qt_id) GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 95 Đồ á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() return render_template('admin/workorder/quotation.html',form=form,qt=qt) @app.route('/printQT/',methods=['GET','POST']) def printQT(_qt_id): detail= db.session.query(models.Quotation).filter_by(qt_id=_qt_id) render= render_template('admin/workorder/printQT.html',detail=detail) 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']='quotation/pdf' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/deleteQt',methods=['GET','POST']) def deleteQt(): _qt_id = request.form['hiddenQtId'] if _qt_id: qt = db.session.query(models.Quotation).filter_by(qt_id =_qt_id).first() print('delete complete') db.session.delete(qt) db.session.commit() return redirect('/quotationIndex') @app.route('/bill',methods=['GET','POST']) def bill(): form= BillForm() if form.validate_on_submit(): _bill_num=form.inputBill_num.data _cus_name=form.inputCus_name.data _cus_add=form.inputCus_add.data _bill_content=form.inputBill_content.data _date=form.inputDate.data _tem=_date.month GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 96 Đồ á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"): bill=models.Invoice(bill_num=_bill_num,cus_name=_cus_name,cus_add=_cus_add,bill_co ntent=_bill_content,bill_date=_date,bill_sumprice=_sum,bill_ad_money=_ad_money,bill_total=tota l,bill_complete=complete_) db.session.add(bill) else: bill = db.session.query(models.Invoice).filter_by(bill_id =_bill_id).first() bill.bill_num=_bill_num bill.cus_name=_cus_name bill.cus_add=_cus_add bill.bill_content=_bill_content bill.bill_date=_date bill.bill_ad_money=_ad_money bill.bill_sumprice=_sum bill.bill_complete=complete_ bill.bill_total=total db.session.commit() return redirect('/billIndex/1') return render_template('admin/bill/bill.html',form=form) @app.route('/billIndex/',methods=['GET','POST']) def billIndex(page_num): 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) @app.route('/editBill/',methods=['GET','POST']) def editBill(_bill_id): form = BillForm() if(_bill_id): bill = db.session.query(models.Invoice).filter_by(bill_id =_bill_id).first() form.inputBill_num.default=bill.bill_num form.inputCus_name.default=bill.cus_name form.inputCus_add.default=bill.cus_add form.inputBill_content.default=bill.bill_content GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 97 Đồ á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') db.session.delete(bill) db.session.commit() return redirect('/billIndex/1') @app.route('/prinAllInvoice',methods=['GET','POST']) def prinAllInvoice(): day=today.day month=today.month year=today.year invoice = db.session.query(models.Invoice).all() render= render_template('admin/bill/printallInvoice.html',invoice=invoice,day=day,month=mo nth,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' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/prinInvoice',methods=['GET','POST']) def prinInvoice(): monhth=today.month day=today.day year=today.year print(monhth) 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} # lower bound first = today.replace(day=1).strftime('%Y-%m-%d') # upper bound try: last = today.replace(day=days_per_month[today.month]).strftime('%Y-%m-%d') except ValueError: GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 98 Đồ á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' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/attendance',methods=['GET','POST']) def attendance(): form = AttendanceForm() form.inputEmployee.choices=[(p.emp_id,p.name)for p in db.session.query(models.Employee).al l()] if form.validate_on_submit(): _emp_id= form.inputEmployee.data _date= form.inputDate.data qt=db.session.query(models.Attendance).all() for i in qt: if(i.emp_id ==_emp_id and i.date==_date): flash('Nhân viên điểm danh hôm nay') return render_template('admin/attendance/attendance.html',form=form) ad=models.Attendance(emp_id=_emp_id,date=_date,working_day=1) db.session.add(ad) print('Success') db.session.commit() return render_template('admin/attendance/attendance.html',form=form) @app.route('/pay/',methods=['GET','POST']) def pay(_emp_id): count=0 _s=0 month=today.month day=today print(day) ad= db.session.query(models.Attendance).filter_by(emp_id=_emp_id) for i in ad: if(i.date.month==month): count+=i.working_day print(count) GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 99 Đồ á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') db.session.commit() return redirect('/payrollIndex/1') return redirect('/employeeIndex/1') @app.route('/prinAllObject',methods=['GET','POST']) def prinAllObject(): day=today.day month=today.month year=today.year obj = db.session.query(models.Object).all() render= render_template('admin/object/printObject.html',obj=obj,day=day,month=month,year=y ear) 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']='object/pdf' response.headers['Content-Disposition']='inline;filename=output.pdf' return response @app.route('/list_overdue',methods=['GET','SET']) def list_overdue(): print(today) emp = db.session.query(models.Employee).all() obj = db.session.query(models.Object).all() wo = models.Workorder.query.filter(models.Workorder.wo_deadline >today) return render_template('admin/workorder/list_overdue.html',wo=wo,emp=emp,obj=obj) if name == ' main ': app.run(debug=True) GVHD: PHAN NGỌC HOÀNG - SVTH: NGUYỄN THỊ MINH THẮM Luan van 100 ... Công ty TNHH TM&DV Cơ khí Hiệp Hịa doanh nghiệp nhỏ - vừa ngành khí gặp bất cập khơng áp dụng cơng nghệ q trình quản lý Chính lý đề tài ? ?Xây dựng website giới thiệu quản lý gia cơng khí cho cơng... Hịa ✓ Quản trị website ✓ Giới thiệu sản phẩm ✓ Quản lý thiết bị ✓ Quản lý nhân công ✓ Quản lý cơng việc ✓ Quản lý hóa đơn ✓ Lưu trữ, trích xuất liệu 1.3 Mơ tả tốn ➢ Mục đích website giới thiệu. .. công nghệ thông tin không thay đổi cách thức người thực công việc quản lý mà thay đổi cách thức họ thông tin cho nhau, xử lý thông tin định 1.2.2 Chức ✓ Giới thiệu công ty TNHH TM&DV Cơ khí Hiệp

Ngày đăng: 11/02/2023, 16:24

Tài liệu cùng người dùng

Tài liệu liên quan