def totalNilai(npm, MINIMUM_PERTEMUAN, dosenid): data=approve_kambing.getDataPembimbing(npm, dosenid) pembimbingke=approve_kambing.pembimbingPositionAs(data, dosenid) if pembimbingke == 'pembimbing2': MINIMUM_PERTEMUAN=5 ALL_DATA_BIMBINGAN = getAllDataBimbinganByDosenID(npm, dosenid) if ALL_DATA_BIMBINGAN: ALL_NILAI_BIMBINGAN = getAllNilaiBimbingan(npm, dosenid) LAST_PERTEMUAN_BIMBINGAN = ALL_DATA_BIMBINGAN[0][5] if len(ALL_DATA_BIMBINGAN) < MINIMUM_PERTEMUAN: status, totalnilai = False, 0 else: if LAST_PERTEMUAN_BIMBINGAN < MINIMUM_PERTEMUAN: totalnilai = 0 for nilai in ALL_NILAI_BIMBINGAN: totalnilai += nilai[0] status, totalnilai = True, totalnilai / (MINIMUM_PERTEMUAN) else: totalnilai = 0 for nilai in ALL_NILAI_BIMBINGAN: totalnilai += nilai[0] status, totalnilai = True, totalnilai / (LAST_PERTEMUAN_BIMBINGAN) else: status, totalnilai=True, 0 return status, totalnilai
def replymsg(driver, data): kode_dosen_approve = message.normalize(data[3]).split(' ')[-1] if kelas.getNamaDosen(kode_dosen_approve): npm_mahasiswa_list = berita_acara_pitak.getListMahasiswa( kode_dosen_approve.upper()) datamahasiswa = '' for npm in npm_mahasiswa_list: data = approve_kambing.getDataPembimbing( npm, kode_dosen_approve.upper()) pembimbingke = approve_kambing.pembimbingPositionAs( data, kode_dosen_approve.upper()) updateApprovalKoordinator( npm, pembimbingke, pembimbingke.replace('pembimbing', 'koordinator'), kode_dosen_approve.upper(), 'true') datamahasiswa += f'NPM: {npm}\nNama: {kelas.getStudentNameOnly(npm)}\n\n' msgreply = f'sudah di approve yaaa dengan Dosen {kelas.getNamaDosen(kode_dosen_approve.upper())} dan ini daftar mahasiswa bimbingannya:\n\n{datamahasiswa}' else: msgreply = f'aduhhhh #BOTNAME# nggak tau nih kode dosen {kode_dosen_approve} ini siapa yaaa.... ga bisa nemuin nih #BOTNAME# coba yaaaa diperhatikan lagiii....' return msgreply
def makePdf(npm_mahasiswa, nama_mahasiswa, tipe_bimbingan, kode_dosen_pembimbing, nama_pembimbing, nidn_pembimbing, tahun_ajaran, photo, judul, total_nilai, elements, logo, styles, kode_dosen_koordinator): checkDir() makeQrcodeVerifySign(link=makeLinkVerify(kode_dosen=kode_dosen_pembimbing, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=tipe_bimbingan, total_nilai=total_nilai), kode_dosen=kode_dosen_pembimbing, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=tipe_bimbingan) makeQrcodeVerifySign(link=makeLinkVerify(kode_dosen=kode_dosen_koordinator, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=tipe_bimbingan, total_nilai=total_nilai), kode_dosen=kode_dosen_koordinator, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=tipe_bimbingan) bulan = date.today().strftime("%m") d2 = date.today().strftime(f"%d {bkd.bulanSwitcher(bulan)} %Y") elements.append(logo) ptext = '<font name="Times" size="14">BERITA ACARA</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 12)) ptext = f'<font name="Times" size="14">{switcherTipeBimbingan(tipe_bimbingan)}</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 12)) ptext = '<font name="Times" size="14">TA. ' + tahun_ajaran + '</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 0.5 * inch)) image = Image(photo, 1.1 * inch, 1.5 * inch) image.hAlign = "RIGHT" elements.append(image) elements.append(Spacer(1, 1.5 * inch)) ptext = '<font size=12> </font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, -3 * inch)) table = [[ '<font name="Times" size="12">Nama</font>', '<font name="Times" size="12">: ' + nama_mahasiswa + '</font>' ], [ '<font name="Times" size="12">Npm</font>', '<font name="Times" size="12">: ' + npm_mahasiswa + '</font>' ], [ '<font name="Times" size="12">Judul</font>', '<font name="Times" size="12">: ' + judul + '</font>' ], [ '<font name="Times" size="12">Pembimbing</font>', '<font name="Times" size="12">: ' + nama_pembimbing + '</font>' ]] style = TableStyle([('ALIGN', (1, 1), (-2, -2), 'RIGHT'), ('VALIGN', (0, 0), (0, -1), 'TOP'), ('ALIGN', (0, -1), (-1, -1), 'LEFT'), ('VALIGN', (0, -1), (-1, -1), 'MIDDLE')]) s = getSampleStyleSheet() s = s["BodyText"] s.wordWrap = 'CJK' data1 = [[Paragraph(cell, s) for cell in row] for row in table] tab = Table(data1, hAlign='LEFT', colWidths=[75, 290]) tab.setStyle(style) elements.append(tab) elements.append(Spacer(1, 0.6 * inch)) data = [[ 'Pertemuan', 'Tanggal', 'Sudah Dikerjakan', 'Pekerjaan Selanjutnya', 'Nilai' ]] inner_data_list = makeListDataBimbinganByDosens(npm_mahasiswa, kode_dosen_pembimbing) for i in inner_data_list: data.append(i) nilai_data_list = [ '', '', '', 'Rata-Rata: ', "%.2f" % round(float(total_nilai), 2) ] data.append(nilai_data_list) style = TableStyle([('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'), ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ('VALIGN', (0, 0), (0, -1), 'MIDDLE'), ('ALIGN', (0, 0), (0, -1), 'CENTER'), ('VALIGN', (0, -1), (-1, -1), 'MIDDLE'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('INNERGRID', (0, 0), (-1, -1), 0.50, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]) s = getSampleStyleSheet() s = s["Normal"] s.wordWrap = 'CJK' data2 = [[Paragraph(cell, s) for cell in row] for row in data] t = Table(data2, hAlign='CENTER', colWidths=[62.5, 65, 180, 180, 40]) t.setStyle(style) elements.append(t) elements.append(Spacer(1, 10)) # ptext = '<font size=12> </font>' # elements.append(Paragraph(ptext, styles["Right"])) # elements.append(Spacer(1, .5 * inch)) bulan = date.today().strftime("%m") tanggal = date.today().strftime(f"%d {bkd.bulanSwitcher(bulan)} %Y") data = approve_kambing.getDataPembimbing(npm_mahasiswa, kode_dosen_pembimbing) pembimbingke = approve_kambing.pembimbingPositionAs( data, kode_dosen_pembimbing) qrcode_pembimbing = f"./beritaacarapitakqrcode/{npm_mahasiswa}-{kode_dosen_pembimbing}-{tipe_bimbingan}.PNG" if approve_kambing.cekApprovalTrueorFalse( npm_mahasiswa, pembimbingke.replace('pembimbing', 'koordinator')): qrcode_koordinator = f"./beritaacarapitakqrcode/{npm_mahasiswa}-{kode_dosen_koordinator}-{tipe_bimbingan}.PNG" else: qrcode_koordinator = f"./beritaacarapitakqrcode/whiteimage.png" image_pembimbing = Image(qrcode_pembimbing, 1.4 * inch, 1.4 * inch) image_pembimbing.vAlign = "CENTER" image_pembimbing.hAlign = "CENTER" image_koordinator = Image(qrcode_koordinator, 1.4 * inch, 1.4 * inch) image_koordinator.hAlign = "CENTER" image_koordinator.vAlign = "CENTER" data = [ [ '', Paragraph(f'<font name="Times">Bandung, {tanggal}</font>', styles["Center"]), '' ], [ Paragraph('<font name="Times"><b>Koordinator</b></font>', styles["Center"]), '', Paragraph('<font name="Times"><b>Pembimbing</b></font>', styles["Center"]) ], [image_koordinator, '', image_pembimbing], [ Paragraph( f'<font name="Times"><b>{kelas.getNamaDosen(kode_dosen_koordinator)}</b></font>', styles["Justify"]), '', Paragraph( f'<font name="Times"><b>{kelas.getNamaDosen(kode_dosen_pembimbing)}</b></font>', styles["Justify"]) ], [ Paragraph( f'<font name="Times"><b>NIDN. {kelas.getAllDataDosens(kode_dosen_koordinator)[2]}</b></font>', styles["Justify"]), '', Paragraph( f'<font name="Times"><b>NIDN. {nidn_pembimbing}</b></font>', styles["Justify"]) ], ] table = Table(data, [7 * cm, 4.3 * cm, 7 * cm], [1 * cm, .5 * cm, 3.5 * cm, .5 * cm, .5 * cm]) table.setStyle( TableStyle([ ('FONT', (0, 0), (-1, -1), 'Times-Roman', 12), ('ALIGN', (0, 0), (-1, -1), 'CENTER'), # ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), # ('BOX', (0,0), (-1,-1), 0.25, colors.black), ])) elements.append(table)
def makePdf(npm_mahasiswa, nama_mahasiswa, tipe_bimbingan, kode_dosen_pembimbing, nama_pembimbing, nidn_pembimbing, tahun_ajaran, photo, judul, total_nilai): checkDir() makeQrcodeVerifySign( link=makeLinkVerify(kode_dosen=kode_dosen_pembimbing, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=switcherTipeBimbingan(tipe_bimbingan), total_nilai=total_nilai), kode_dosen=kode_dosen_pembimbing, npm_mahasiswa=npm_mahasiswa, tipe_bimbingan=switcherTipeBimbingan(tipe_bimbingan) ) bulan = date.today().strftime("%m") d2 = date.today().strftime(f"%d {bkd.bulanSwitcher(bulan)} %Y") STUDENT_EMAIL=getStudentEmail(npm_mahasiswa) doc = SimpleDocTemplate(f'./kambing/{npm_mahasiswa}-{kode_dosen_pembimbing}-{STUDENT_EMAIL}-{switcherTipeBimbingan(tipe_bimbingan)}.pdf', pagesize=A4, rightMargin=30, leftMargin=30, topMargin=30, bottomMargin=18) doc.pagesize = portrait(A4) elements = [] logo = Image("logoKAMBING.PNG", 3.5 * inch, 1 * inch) logo.hAlign = "LEFT" elements.append(logo) styles = getSampleStyleSheet() styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY)) styles.add(ParagraphStyle(name='Center', alignment=TA_CENTER)) styles.add(ParagraphStyle(name='Right', alignment=TA_RIGHT)) ptext = '<font name="Times" size="14">FORMULIR KEGIATAN</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 12)) ptext = f'<font name="Times" size="14">{switcherTipeBimbingan(tipe_bimbingan)}</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 12)) ptext = '<font name="Times" size="14">TA. ' + tahun_ajaran + '</font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, 0.5 * inch)) image = Image(photo, 1.1 * inch, 1.5 * inch) image.hAlign = "RIGHT" elements.append(image) elements.append(Spacer(1, 1.5 * inch)) ptext = '<font size=12> </font>' elements.append(Paragraph(ptext, styles["Center"])) elements.append(Spacer(1, -3 * inch)) table = [['<font name="Times" size="12">Nama</font>', '<font name="Times" size="12">: ' + nama_mahasiswa + '</font>'], ['<font name="Times" size="12">Npm</font>', '<font name="Times" size="12">: ' + npm_mahasiswa + '</font>'], ['<font name="Times" size="12">Judul</font>', '<font name="Times" size="12">: ' + judul + '</font>'], ['<font name="Times" size="12">Pembimbing</font>', '<font name="Times" size="12">: ' + nama_pembimbing + '</font>']] style = TableStyle([('ALIGN', (1, 1), (-2, -2), 'RIGHT'), ('VALIGN', (0, 0), (0, -1), 'TOP'), ('ALIGN', (0, -1), (-1, -1), 'LEFT'), ('VALIGN', (0, -1), (-1, -1), 'MIDDLE') ]) s = getSampleStyleSheet() s = s["BodyText"] s.wordWrap = 'CJK' data1 = [[Paragraph(cell, s) for cell in row] for row in table] tab = Table(data1, hAlign='LEFT', colWidths=[75, 290]) tab.setStyle(style) elements.append(tab) elements.append(Spacer(1, 0.6 * inch)) data = [['Pertemuan', 'Tanggal', 'Sudah Dikerjakan', 'Pekerjaan Selanjutnya', 'Nilai']] inner_data_list=makeListDataBimbinganByDosens(npm_mahasiswa, kode_dosen_pembimbing, tipe_bimbingan) for i in inner_data_list: data.append(i) nilai_data_list=['', '', '', 'Rata-Rata: ', '%.2f' % round(float(total_nilai), 2)] data.append(nilai_data_list) # Get this line right instead of just copying it from the docs style = TableStyle([('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'), ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ('VALIGN', (0, 0), (0, -1), 'MIDDLE'), ('ALIGN', (0, 0), (0, -1), 'CENTER'), ('VALIGN', (0, -1), (-1, -1), 'MIDDLE'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('INNERGRID', (0, 0), (-1, -1), 0.50, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black) ]) # Configure style and word wrap s = getSampleStyleSheet() s = s["Normal"] s.wordWrap = 'CJK' data2 = [[Paragraph(cell, s) for cell in row] for row in data] t = Table(data2, hAlign='CENTER', colWidths=[62.5, 65, 180, 180, 40]) t.setStyle(style) elements.append(t) elements.append(Spacer(1, 10)) ptext = '<font size=12> </font>' elements.append(Paragraph(ptext, styles["Right"])) elements.append(Spacer(1, .5 * inch)) ptext = '<font name="Times" size="12">Bandung, ' + d2 + '</font>' elements.append(Paragraph(ptext, styles["Right"])) elements.append(Spacer(1, 12)) ptext = '<font name="Times" size="12">Pembimbing,</font>' elements.append(Paragraph(ptext, styles["Right"])) elements.append(Spacer(1, .1 * inch)) data = approve_kambing.getDataPembimbing(npm_mahasiswa, kode_dosen_pembimbing) pembimbingke = approve_kambing.pembimbingPositionAs(data, kode_dosen_pembimbing) if approve_kambing.cekApprovalTrueorFalse(npm_mahasiswa, pembimbingke): qrcode = f"./kambingqrcode/{npm_mahasiswa}-{kode_dosen_pembimbing}-{switcherTipeBimbingan(tipe_bimbingan)}.PNG" else: qrcode = f"./kambingqrcode/whiteimage.png" im = Image(qrcode, 1.5 * inch, 1.5 * inch) im.hAlign = "RIGHT" elements.append(im) ptext = '<font name="Times" size="12">' + nama_pembimbing + '</font>' elements.append(Paragraph(ptext, styles["Right"])) elements.append(Spacer(1, 1)) ptext = '<font name="Times" size="12">NIDN. ' + nidn_pembimbing + '</font>' elements.append(Paragraph(ptext, styles["Right"])) elements.append(Spacer(1, 12)) doc.build(elements)