Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/PA/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def get_related_work_processes():
template = f'''<select class="js-example-basic-single" name="strategy_activity_id">{items}</select>'''
else:
items = '<option name="process_id" value="">โปรดระบุกระบวนการทำงาน</option>'
for proc in Process.query:
for proc in current_user.processes:
items += f'<option value="{proc.id}" {"selected" if process_id==proc.id else ""}>{proc}</option>'
template = f'''<select class="js-example-basic-single" name="process_id">{items}</select>'''
resp = make_response(template)
Expand Down
52 changes: 20 additions & 32 deletions app/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ def wfh_request_info():
rounds.add(req.start_datetime.year)
org_id = request.args.get('deptid', type=int)
round_year = request.args.get('fiscalyear', type=int)
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
if org_id is None:
if round_year:
wfh = []
Expand Down Expand Up @@ -1386,14 +1386,9 @@ def leave_request_result_by_date():
def leave_request_result_by_person():
org_id = request.args.get('deptid')
fiscal_year = request.args.get('fiscal_year')
if fiscal_year is not None:
start_date, end_date = get_start_end_date_for_fiscal_year(int(fiscal_year))
else:
start_date = None
end_date = None
years = set()
leaves_list = []
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
leave_types = [t.type_ for t in StaffLeaveType.query.all()]
leave_types_r = [t.type_ + u'คงเหลือ' for t in StaffLeaveType.query.all()]
if org_id is None:
Expand All @@ -1403,7 +1398,6 @@ def leave_request_result_by_person():
.filter(or_(StaffAccount.personal_info.has(retired=False),
StaffAccount.personal_info.has(retired=None)))
for account in account_query:
# record = account.personal_info.get_remaining_leave_day
record = {}
record["staffid"] = account.id
record["fullname"] = account.personal_info.fullname
Expand All @@ -1417,8 +1411,17 @@ def leave_request_result_by_person():
record[leave_type] = 0
for leave_remain in leave_types_r:
record[leave_remain] = 0
if fiscal_year:
used_quota = StaffLeaveUsedQuota.query.filter_by(staff=account, fiscal_year=fiscal_year).all()
else:
used_quota = StaffLeaveUsedQuota.query.filter_by(staff=account).all()
if used_quota:
for quota in used_quota:
record["total"] += quota.used_days
record["pending"] += quota.pending_days


quota = StaffLeaveQuota.query.filter_by(employment_id=account.personal_info.employment_id).all()
# ค่ามันไม่ใส่ตรงตามช่อง เช่น pending ไปใส่ใน total ค่า total บางคนครบ3 type
for quota in quota:
leave_type = quota.leave_type.type_
leave_remain = quota.leave_type.type_
Expand All @@ -1428,11 +1431,7 @@ def leave_request_result_by_person():
if used_quota:
record[leave_remain] = used_quota.quota_days - used_quota.used_days
record[leave_type] = used_quota.used_days
record["total"] += used_quota.used_days
record["pending"] += used_quota.pending_days
else:
record["total"] = 0
record["pending"] = 0
record[leave_type] = 0
record[leave_remain] = 0
else:
Expand All @@ -1452,18 +1451,6 @@ def leave_request_result_by_person():
record[leave_remain] = 0
for req in account.leave_requests:
years.add(req.start_datetime.year)
# for req in account.leave_requests:
# if not req.cancelled_at:
# if req.get_approved:
# years.add(req.start_datetime.year)
# if start_date and end_date:
# if req.start_datetime.date() < start_date or req.start_datetime.date() > end_date:
# continue
# leave_type = req.quota.leave_type.type_
# record[leave_type] = record.get(leave_type, 0) + req.total_leave_days
# record["total"] += req.total_leave_days
# if not req.get_approved and not req.get_unapproved:
# record["pending"] += req.total_leave_days
leaves_list.append(record)
years = sorted(years)
if len(years) > 0:
Expand Down Expand Up @@ -1896,7 +1883,7 @@ def wfh_requests_list():
@login_required
def show_wfh_approvers():
org_id = request.args.get('deptid')
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
if org_id is None:
account_query = StaffAccount.query.filter(StaffAccount.personal_info.has(retired=False))
else:
Expand Down Expand Up @@ -3812,7 +3799,7 @@ def staff_create_info():
for staff in StaffAccount.query.all():
if staff.email == getemail:
flash('มีบัญชีนี้อยู่ในระบบแล้ว', 'warning')
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
employments = StaffEmployment.query.all()
return render_template('staff/staff_create_info.html', departments=departments, employments=employments)

Expand All @@ -3828,6 +3815,7 @@ def staff_create_info():
# TODO: try removing localize
employed_date=tz.localize(start_date),
finger_scan_id=form.get('finger_scan_id'),
sap_id=form.get('sap_id'),
employment_id=form.get('employment_id'),
job_position_id=form.get('job_id'),
org_id=form.get('org_id')
Expand Down Expand Up @@ -3864,9 +3852,9 @@ def staff_create_info():
flash('เพิ่มบุคลากรเรียบร้อย และเพิ่มข้อมูล quota การลาให้กับพนักงานใหม่เรียบร้อย', 'success')
staff = StaffPersonalInfo.query.get(createstaff.id)
return render_template('staff/staff_show_info.html', staff=staff)
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
employments = StaffEmployment.query.all()
jobs = StaffJobPosition.query.all()
jobs = StaffJobPosition.query.order_by(StaffJobPosition.id.asc()).all()
return render_template('staff/staff_create_info.html', departments=departments, employments=employments, jobs=jobs)


Expand All @@ -3881,8 +3869,8 @@ def staff_search_info():
resign_date = staff.resignation_date
retired_date = staff.retirement_date
employments = StaffEmployment.query.all()
departments = Org.query.all()
jobs = StaffJobPosition.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
jobs = StaffJobPosition.query.order_by(StaffJobPosition.id.asc()).all()
return render_template('staff/staff_edit_info.html', staff=staff, emp_date=emp_date, retired_date=retired_date,
resign_date=resign_date, employments=employments, departments=departments, jobs=jobs)
return render_template('staff/staff_find_name_to_edit.html')
Expand Down Expand Up @@ -4022,7 +4010,7 @@ def staff_edit_pwd(staff_id):
@login_required
def staff_show_approvers():
org_id = request.args.get('deptid')
departments = Org.query.all()
departments = Org.query.order_by(Org.id.asc()).all()
if org_id is None:
account_query = StaffAccount.query.filter(StaffAccount.personal_info.has(retired=False))
else:
Expand Down
4 changes: 2 additions & 2 deletions app/templates/staff/leave_request_info_by_date.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="container has-text-centered">
<div class="box">
<a href="{{ url_for('staff.leave_request_result_by_person') }}">
<span class="icon is-large"><i class="far fa-search-plus fa-4x"></i></span><br><br>
<span class="icon is-large"><i class="far fa-search fa-4x"></i></span><br><br>
<span class="is-size-4">ค้นหาจากชื่อ/ประเภทการลา</span>
</a>
</div>
Expand All @@ -31,7 +31,7 @@
<div class="container has-text-centered">
<div class="box">
<a href="{{ url_for('staff.leave_request_info') }}">
<span class="icon is-large"><i class="far fa-search-plus fa-4x"></i></span><br><br>
<span class="icon is-large"><i class="far fa-dice-one fa-4x"></i></span><br><br>
<span class="is-size-4">ค้นหารายครั้ง</span>
</a>
</div>
Expand Down
13 changes: 13 additions & 0 deletions app/templates/staff/staff_create_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ <h1 class="title">เพิ่มข้อมูลบุคลากรให
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">รหัสระบบ SAP</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input"
name="sap_id" type="text" required>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">การจ้าง</label>
Expand Down