def insert_course(ws, i, curs, year, month, semester, holidays, parit, C_count, A_count): """Insert a line for every application for a given month""" d = date(year, month, 1) format = dateform() format.update(dw.boxed(1)) start, stop = curs['ore'].split('-') lenght = int(stop) - int(start) j = i # print "month: ", month, "; d.month = ", d.month if d.weekday()>curs['zi']: d = d + timedelta(days=(7 + curs['zi'] - d.weekday())) else: d = d +timedelta(days=(curs['zi'] - d.weekday())) if ws.col(3).width < (len(curs['disciplina']) * 256): ws.col(3).width = len(curs['disciplina']) * 256 # print "month: ", month, "; d.month = ", d.month while d.month == month: if (inside(d, semester) and parit[d.isocalendar()[1]] and ( curs['parit'] == 1 or ( parit[d.isocalendar()[1]] % curs['parit'] == curs['pari_st'])) and outside(d, holidays)) : dw.write(ws, 7 + i, 0, i + 1, dw.boxed(1,0,0,0)) dw.write(ws, 7 + i, 1, curs['functie'] + str(curs['nr_post']), dw.boxed(1)) dw.write(ws, 7 + i, 2, curs['facultate'], dw.boxed(1)) dw.write(ws, 7 + i, 3, curs['disciplina'], dw.boxed(1)) if curs['tip'] == "C": dw.write(ws, 7 + i, 4, lenght, dw.boxed(1)) dw.write(ws, 7 + i, 5, "", dw.boxed(1)) else: dw.write(ws, 7 + i, 5, lenght, dw.boxed(1)) dw.write(ws, 7 + i, 4, "", dw.boxed(1)) dw.write(ws, 7 + i, 6, curs['grupa'], dw.boxed(1)) dw.write(ws, 7 + i, 7, d, format) dw.write(ws, 7 + i, 8, curs['ore'], dw.boxed(1)) i= i + 1 d=d + timedelta(days=7) if curs['tip'] == "C": add_sum(C_count, curs['functie'], 8 + j, 8 + i - 1) else: add_sum(A_count, curs['functie'], 8 + j, 8 + i - 1) return i
def write_header(ws, univ, faculty, department, basecourse, teacher, position, month): """Insert the header of the table""" ws.col(0).width = 4*256 for i in [1,2,3,6,7,8]: ws.col(i).width = 10*256 ws.col(4).width=9*256 ws.col(5).width=9*256 dw.write(ws, 0, 0, univ) dw.write(ws, 0, 6, "Catedra " + department) dw.write(ws, 1, 0, faculty) dw.write(ws, 1, 6, "Luna " + ro_month(month)) dw.write(ws, 3, 3, "Situaţia orelor efectuate de") dw.write(ws, 3, 5, position + " " + teacher) dw.write(ws, 4, 3, "cu funcţia de bază") dw.write(ws, 4, 5, "la " + basecourse) dw.write(ws, 6, 0, "Nr. crt.", dw.boxed(2,1,1)) dw.write(ws, 6, 1, "Felul şi nr. postului", dw.boxed(2,1,1)) dw.write(ws, 6, 2, "Facultatea", dw.boxed(2,1)) dw.write(ws, 6, 3, "Disciplina", dw.boxed(2,1)) dw.write(ws, 6, 4, "Curs", dw.boxed(2,1)) dw.write(ws, 6, 5, "Aplicaţii", dw.boxed(2,1)) dw.write(ws, 6, 6, "An/Grupa", dw.boxed(2,1)) dw.write(ws, 6, 7, "Data", dw.boxed(2,1)) dw.write(ws, 6, 8, "Orele", dw.boxed(2,1))
def write_totals(ws, i, C, A): """Write the totals for a table""" dw.write(ws, i, 7, "Total:") dw.write(ws, i, 8, dw.formula("SUM(E8:F" + str(i) + ")")) dw.write(ws, i + 2, 3, "TOTAL ore:", dw.boxed(2)) dw.write(ws, i + 2, 4, "Curs:", dw.boxed(2)) dw.write(ws, i + 2, 5, "Aplicaţii:", dw.boxed(2)) posts=["Prof", "Conf", "S.l.", "As"] internal=["prof", "conf", "sl", "as"] for post in posts: dw.write(ws, i + 3 + posts.index(post), 3, post, dw.boxed(1)) for j in range(0, 4): dw.write(ws, i+ 3 + j, 4, dw.formula(form_sum(C[internal[j]], C_col)), dw.boxed(1)) dw.write(ws, i + 3+ j, 5, dw.formula(form_sum(A[internal[j]], A_col)), dw.boxed(1))
def write_footer(ws, i, teacher, titular, dept_head, dean): """Write the footer for the table""" dw.write(ws, i , 0, "Întocmit,") dw.write(ws, i , 3, "Titular curs,") dw.write(ws, i , 5, "Şef catedră,") dw.write(ws, i , 7, "Decan,") dw.write(ws, i + 1, 0, teacher) if ws.col(3).width < (len(titular) * 256): ws.col(3).width = len(titular) * 256 dw.write(ws, i + 1, 3, titular) dw.write(ws, i + 1, 5, dept_head) dw.write(ws, i + 1, 7, dean)
def write_header(ws, univ, faculty, department, teacher, position): """Insert the header of the table""" ws.col(0).width = 6*256 for i in range(1, 12): ws.col(i).width = 15*256 dw.write(ws, 0, 0, univ) dw.write(ws, 0, 4, "Catedra " + department) dw.write(ws, 1, 0, faculty) dw.write(ws, 3, 2, "Orarul pentru") dw.write(ws, 3, 3, position + " " + teacher) dw.set_row_h(ws, 6, 3) dw.write(ws, 6, 0, "Ora", dw.boxed(2,1,1)) for i in range(0,5): ws.write_merge(6, 6, 2*i+1, 2*i + 2, ro_days[i], dw.faktup(2)) for i in range(0, 14): dw.write(ws, 7+i, 0, str(i+8)+":00", dw.boxed(1, 1, h_align = 2)) dw.set_row_h(ws, 7 + i, 3)