예제 #1
0
파일: views.py 프로젝트: porzaa/DB_Project
def hourpdf(request): # use to see working of temporary employee.
    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page()
    ganY = [46, 54]  # line bettwen collumn.
    
    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)
    pdf.set_font('Kinnari', '', 12)
    
    gen_single_text(pdf, 60, u'ใบลงเวลาทำงานลูกจ้างชั่วคราวรายชั่วโมง')
    gen_single_text(pdf, 45, u'มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเหนือ')
    gen_single_text(pdf, 70, u'ชื่อ')
    
    pdf.ln(8)
    pdf.cell(0, 18, u'    วัน           วันที่ เดือน ปี          เวลาทำงาน      รวมชั่วโมง       ลายมือชื่อ          หมายเหตุ')
    drawAttr2(pdf, ganY[0], ganY[1], True)
    
    gen_single_text(pdf, 90, u'รวมจำนวนชั่วโมง ' + u'ชั่วโมง') # call spacial funtion to write a text per line.
    gen_single_text(pdf, 90, u'อัตรา 45.45 บาท ชั่วโมง')
    gen_single_text(pdf, 90, u'รวมเป็นเงินทั้งสิ้น' + u'บาท')
    gen_single_text(pdf, 90, u'(                   )')
    gen_single_text(pdf, 90, u'ได้ตรวจสอบถูกต้องแล้ว')
    gen_single_text(pdf, 75, u'ลงชื่อ.......................................................')
    gen_single_text(pdf, 80, u'(...................................................)')
    
    pdf.output("group3/hour.pdf", 'F')
    
    with open('group3/hour.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=hour.pdf'
        return response
    pdf.closed
예제 #2
0
파일: views.py 프로젝트: linhuii/DB_Project
def hourpdf(request):  # use to see working of temporary employee.
    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page()
    ganY = [46, 54]  # line bettwen collumn.

    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)
    pdf.set_font('Kinnari', '', 12)

    gen_single_text(pdf, 60, u'ใบลงเวลาทำงานลูกจ้างชั่วคราวรายชั่วโมง')
    gen_single_text(pdf, 45, u'มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเนือ')
    gen_single_text(pdf, 70, u'ชื่อ')

    pdf.ln(8)
    pdf.cell(
        0, 18,
        u'    วัน           วันที่ เดือน ปี          เวลาทำงาน      รวมชั่วโมง       ลายมือชื่อ          หมายเหตุ'
    )
    drawAttr2(pdf, ganY[0], ganY[1], True)

    gen_single_text(
        pdf, 90, u'รวมจำนวนชั่วโมง ' +
        u'ชั่วโมง')  # call spacial funtion to write a text per line.
    gen_single_text(pdf, 90, u'อัตรา 45.45 บาท ชั่วโมง')
    gen_single_text(pdf, 90, u'รวมเป็นเงินทั้งสิ้น' + u'บาท')
    gen_single_text(pdf, 90, u'(                   )')
    gen_single_text(pdf, 90, u'ได้ตรวจสอบถูกต้องแล้ว')
    gen_single_text(
        pdf, 75,
        u'ลงชื่อ.......................................................')
    gen_single_text(pdf, 80,
                    u'(...................................................)')

    pdf.output("group3/hour.pdf", 'F')

    with open('group3/hour.pdf',
              'rb') as pdf:  # path to pdf in directory views.
        response = HttpResponse(pdf.read(), content_type='application/pdf')
        response['Content-Disposition'] = 'filename=hour.pdf'
        return response
    pdf.closed
예제 #3
0
파일: views.py 프로젝트: linhuii/DB_Project
def genallpdf(request):  # grnerate pdf for show all section data.
    allTeach = Teach.objects.all()
    allsection = Section.objects.all()

    ListSec = [
    ]  # collect teacher each sectoin because a section has more than a teacher.
    for sec in allsection:  # collecting teacher to each section.
        eachSec = []
        for teach in allTeach:
            if teach.section == sec:
                eachSec.append(teach)
        ListSec.append(eachSec)

    pdf = FPDF('L', 'mm', 'A4')  # start pdf 'L' is landscape.
    pdf.add_page()

    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)
    pdf.set_font('Kinnari', '', 8)

    ganY = [10, 18]
    drawAttr(pdf, ganY[0], ganY[1], True)  # call to draw table
    pdf.cell(
        0, ganY[0],
        u'ลำดับ              ชื่อ-สกุล                    ตัวย่อ    รหัสวิชา                ชื่อวิชา                      ตอนเรียน  วัน       เวลา       ห้องเรียน  เบอร์โทรศัพท์                   Email                  บ-ช สหกรณ์      หมายเหตุ    '
    )
    pdf.ln(4)  # width:298 height:210

    cnt_no = 0  # use to fill in number column.
    cnt_line = 0  # use to calculate next line to draw row of table.
    for sec in ListSec:  # drawing table
        cnt_no += 1
        no = str(cnt_no)
        # write no.
        for Prof in sec:  # access all teacher in each section
            cnt_line += 1
            try:
                first_name = Prof.prof.firstName
                last_name = Prof.prof.lastName
                full_name = first_name + '  ' + last_name
            except:
                full_name = 'None'

            try:
                shortname = Prof.prof.shortName
            except:
                shortname = 'None'

            try:
                subjectID = Prof.subject.subjectID
            except:
                subjectID = 'None'

            try:
                subject = Prof.subject.subjectName
            except:
                subject = 'None'

            try:
                section = Prof.section.section
            except:
                section = " "

            try:
                day = Prof.section.date
            except:
                day = ' '

            try:
                starttime = Prof.section.startTime
            except:
                starttime = 'None'

            try:
                room = Prof.section.classroom
            except:
                room = 'None'

            try:
                phone_num = Prof.prof.tell
            except:
                phone_num = 'None'

            try:
                email = Prof.prof.email
            except:
                email = 'None'

            try:
                sahakorn = Prof.prof.sahakornAccount
            except:
                sahakorn = 'None'

            pdf.cell(8, 18, no)
            pdf.cell(45, 18, full_name)
            pdf.cell(8, 18, shortname)
            pdf.cell(17, 18, subjectID)
            pdf.cell(45, 18, subject)
            pdf.cell(12, 18, section)
            pdf.cell(7, 18, day)
            pdf.cell(17, 18, str(starttime))
            pdf.cell(12, 18, room)
            pdf.cell(19, 18, phone_num)
            pdf.cell(43, 18, email)
            pdf.cell(29, 18, sahakorn)

            pdf.ln(8)
            if cnt_line % 16 == 0:  # check for new pae. I set maximun 16 teachers per a page.
                drawAttr(pdf, ganY[0] + (cnt_line * 8),
                         ganY[1] + (cnt_line * 8), True)
            else:
                drawAttr(pdf, ganY[0] + (cnt_line * 8),
                         ganY[1] + (cnt_line * 8))
            no = ''

    pdf.ln(8)
    pdf.cell(230, 18, '')
    pdf.cell(230, 18, u'ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ ')
    pdf.ln(8)
    pdf.cell(240, 18, '')
    pdf.cell(240, 18, u'คณะวิศวกรรมศาสตร์ ')
    pdf.ln(8)
    pdf.output("group3/allTeach.pdf", 'F')

    with open('group3/allTeach.pdf',
              'rb') as pdf:  # use to call pdf page in browser.
        response = HttpResponse(pdf.read(), content_type='application/pdf')
        response['Content-Disposition'] = 'filename=allTeach.pdf'
        return response
    pdf.closed
예제 #4
0
파일: views.py 프로젝트: linhuii/DB_Project
def genpdf(request,
           profID):  # use to generate pdf file for lend another teacher.
    teachObj = Teach.objects.get(pk=int(profID))  # get all objects teacher.
    pdf = FPDF('P', 'mm', 'A4')  # start pdf file
    pdf.add_page()  # begin first page.

    pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)  # add font
    pdf.set_font('DejaVu', '', 14)  # set font and font size

    pdf.image('group3/trarachakarn.png', 20, 20, 20)  # insert image
    pdf.ln(25)  # new line

    proID = ''
    firstname = ''
    lastname = ''
    shortname = ''
    department = ''
    faculty = ''
    sahakornAccount = ''
    tell = ''
    email = ''

    try:  # check all data for beware blank data.
        proID = teachObj.prof.profID
    except:
        proID = 'None'

    try:
        firstname = teachObj.prof.firstName
    except:
        firstname = 'None'

    try:
        lastname = teachObj.prof.lastName
    except:
        lastname = 'None'

    try:
        shortname = teachObj.prof.shortName
    except:
        shortname = 'None'

    try:
        department = teachObj.prof.department
    except:
        department = 'None'

    try:
        faculty = teachObj.prof.faculty
    except:
        faculty = 'None'

    try:
        sahakornAccount = teachObj.prof.sahakornAccount
    except:
        sahakornAccount = 'None'

    try:
        tell = teachObj.prof.tell
    except:
        tell = 'None'

    try:
        email = teachObj.prof.email
    except:
        email = 'None'

    pdf.add_font('Kinnari-Bold', '', 'Kinnari-Bold.ttf',
                 uni=True)  # thai font bold
    pdf.set_font('Kinnari-Bold', '', 18)
    pdf.cell(0, 10, u'                         บันทึกข้อความ')
    pdf.ln(10)
    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)  # thai font
    pdf.set_font('Kinnari', '', 12)
    pdf.cell(
        0, 10,
        u'         ส่วนราชการ ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ คณะวิศวกรรมศาสตร์  โทร. ๘๕๑๘'
    )
    pdf.line(46, 52, 180, 52)
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         ที่  วฟ     /๒๕๕๘                                        วันที่  '
    )
    pdf.line(30, 60, 180, 60)
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         เรื่อง การจัดการเรียนการสอนสำหรับนักศึกษาโครงการพิเศษ(สองภาษา) '
    )
    pdf.line(30, 68, 180, 68)
    pdf.ln(8)
    pdf.cell(0, 10, u'         เรียน หัวหน้าภาควิชา ')
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                     ตามที่ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ได้ขอรับบริการจัดการเรียนการ'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         สอนจากท่านในรายวิชา                                                      สำหรับนักศึกษา'
    )
    pdf.ln(8)
    pdf.cell(0, 10,
             u'         โครงการพิเศษ (สองภาษา)  ภาคเรียนที่            นั้น')
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                    ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ขอให้ท่านยืนยันการจัดการเรียนการสอนใน'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         รายวิชาดังกล่าว ตามแบบฟอร์มด้านล่าง พร้อมตารางสอนและใบเบิกค่าสอนของอาจารย์ผู้สอนและ'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         ส่งคืนกลับภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  เพื่อจะได้ดำเนินการในส่วนที่เกี่ยวข้องต่อไป'
    )
    pdf.ln(8)
    pdf.cell(0, 10, u'                        จึงเรียนมาเพื่อโปรดทราบ')
    pdf.ln(20)
    pdf.cell(
        0, 10,
        u'                                                  (ดร.นภดล   วิวัชรโกเศศ)'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                              หัวหน้าภาควิศวกรรมไฟฟ้าและคอมพิวเตอร์'
    )
    pdf.ln(14)
    pdf.cell(
        0, 10,
        u'            ..................................................................................................................................................'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         ชื่อผู้สอน.................................................................... รหัสผู้สอน.................................ภาควิชา '
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'         คณะ.......................................................................รหัสวิชา...........................................ชื่อวิชา '
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                        ตอนเรียน           วัน              เวลา  ')
    pdf.ln(8)
    pdf.cell(0, 10, u'         ได้จัดการเรียนการสอนเป็น ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                    ภาษาอังกฤษ  ')
    pdf.rect(37, 210, 3, 3)
    pdf.ln(8)
    pdf.cell(0, 10, u'                    ภาษาไทย')
    pdf.rect(37, 218, 3, 3)
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                            ลงชื่อ......................................อาจารย์ผู้สอน '
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                            (..............................................) '
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                            ลงชื่อ......................................'
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                            (..............................................) '
    )
    pdf.ln(8)
    pdf.cell(
        0, 10,
        u'                                            หัวหน้าภาควิชา............................................'
    )
    pdf.ln(8)

    pdf.cell(0, 10, u'' + proID)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + firstname + '   ' + lastname)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + shortname)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + department)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + faculty)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + sahakornAccount)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + tell)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + email)
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.subject.subjectID)
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.subject.subjectName)
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.section.section)
    pdf.ln(20)
    pdf.cell(0, 10, u'' + str(teachObj.section.startTime))
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.section.date)
    pdf.ln(20)
    pdf.output("group3/uni.pdf", 'F')

    # next path will open pdf file in new tab on browser.
    with open('group3/uni.pdf',
              'rb') as pdf:  # path to pdf in directory views.
        response = HttpResponse(pdf.read(), content_type='application/pdf')
        response['Content-Disposition'] = 'filename=uni.pdf'
        return response
    pdf.closed
예제 #5
0
def hourpdf(request, employeeID): # use to see working of temporary employee.
    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page()
    ganY = [46, 54]  # line bettwen collumn.
    
    employeeObj = HourlyEmployee.objects.get(pk=int(employeeID))
    ListWork = employeeObj.work_set.all()
    
    pdf.add_font('THSarabun', '', 'THSarabun.ttf', uni=True)
    pdf.set_font('THSarabun', '', 16)
    
    gen_single_text(pdf, 65, u'ใบลงเวลาทำงานลูกจ้างชั่วคราวรายชั่วโมง')
    gen_single_text(pdf, 57, u'มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเหนือ')
    gen_single_text(pdf, 75, u'ชื่อ' + employeeObj.user.firstname_th + '   '+employeeObj.user.lastname_th)
    
    pdf.ln(8)
    pdf.cell(0, 18, u'      วัน                 วันที่ เดือน ปี           เวลาทำงาน  รวมชั่วโมง          ลายมือชื่อ                       หมายเหตุ')
    drawAttr2(pdf, ganY[0], ganY[1], True)
    pdf.ln(12)

    numLine = 0
    payment = 0
    show_payment = 0
    for working in ListWork:
        numLine += 1
        drawAttr2(pdf, ganY[0] + (numLine*8), ganY[1] + (numLine*8))
        if working.day.weekday() == 0:  # geting day to pdf
            pdf.cell(20, 10, u'วันจันทร์')
        elif working.day.weekday() == 1:
            pdf.cell(20, 10, u'วันอังคาร')
        elif working.day.weekday() == 2:
            pdf.cell(20, 10, u'วันพุธ')
        elif working.day.weekday() == 3:
            pdf.cell(20, 10, u'วันพฤหัสบดี')
        elif working.day.weekday() == 4:
            pdf.cell(20, 10, u'วันศุกร์')
        elif working.day.weekday() == 5:
            pdf.cell(20, 10, u'วันเสาร์')
        else:
            pdf.cell(20, 10, u'วันอาทิตย์')
        
        space = 26
        pdf.cell(5, 10, u''+ str(working.releaseDate.day)) # get day
        if working.releaseDate.month == 1:  # get month
            pdf.cell(space, 10, u' มกราคม พ.ศ. ' )
        elif working.releaseDate.month == 2:
            pdf.cell(space, 10, u' กุมภาพันธ์ พ.ศ. ' )
        elif working.releaseDate.month == 3:
            pdf.cell(space, 10, u' มีนาคม พ.ศ. ' )
        elif working.releaseDate.month == 4:
            pdf.cell(space, 10, u' เมษายน พ.ศ. ' )
        elif working.releaseDate.month == 5:
            pdf.cell(space, 10, u' พฤษภาคม พ.ศ. ' )
        elif working.releaseDate.month == 6:
            pdf.cell(space, 10, u' มิถุนายน พ.ศ. ' )
        elif working.releaseDate.month == 7:
            pdf.cell(space, 10, u' กรกฏาคม พ.ศ. ' )
        elif working.releaseDate.month == 8:
            pdf.cell(space, 10, u' สิงหาคม พ.ศ. ' )
        elif working.releaseDate.month == 9:
            pdf.cell(space, 10, u' กันยายน พ.ศ. ' )
        elif working.releaseDate.month == 10:
            pdf.cell(space, 10, u' ตุลาคม พ.ศ. ' )
        elif working.releaseDate.month == 11:
            pdf.cell(space, 10, u' พฤศจิกายน พ.ศ. ' )
        else:
            pdf.cell(space, 10, u' ธันวาคม พ.ศ. ' )
        
        pdf.cell(17, 10, u''+ str(543+int(str(working.releaseDate.year))) )
        pdf.cell(20, 10, u''+ str(working.startTime.hour)+':'+str(working.startTime.minute))
        come_time = str(working.startTime.hour)+':'+str(working.startTime.minute) # time that employee come to work.
        back_time = str(working.endTime.hour)+':'+str(working.endTime.minute) # time that employee go home
        diff_min = int(back_time.split(':')[1]) - int(come_time.split(':')[1])    # calculate differ value of come_time
        diff_hour = int(back_time.split(':')[0]) - int(come_time.split(':')[0])  # calculate differ value of back_time
        if diff_min < 0:
            diff_min = 60 - diff_min
        diff_min_100 = float(str(diff_min))/60
        
        show_payment = show_payment + ( float(diff_hour)+ (float(diff_min)/100) ) 
        pdf.cell(52, 10, u''+ str(diff_hour)+'.'+str(diff_min))
        pdf.cell(90, 10, u''+working.note)
        pdf.ln(8)
        payment = payment + (float(str(diff_min_100)[:4]) + float(diff_hour))
        
    
    index_str = 0
    show_complete_pay = ''
    for i in str(payment)[:4][::-1]:
        index_str = index_str + 1
        if (index_str % 3) == 0:
            show_complete_pay = ',' + i + show_complete_pay 
        else:
            show_complete_pay = i + show_complete_pay 
    
    gen_single_text(pdf, 90, u'รวมจำนวนชั่วโมง ' +str(show_payment)+ u' ชั่วโมง') # call spacial funtion to write a text per line.
    gen_single_text(pdf, 90, u'อัตรา 45.45 บาท ชั่วโมง')
    payment = payment * 45.45
    gen_single_text(pdf, 85, u'รวมเป็นเงินทั้งสิ้น ' + str(payment)[:4] +u' บาท')
    gen_single_text(pdf, 85, u'(                                     )')
    gen_single_text(pdf, 90, u'ได้ตรวจสอบถูกต้องแล้ว')
    gen_single_text(pdf, 65, u'ลงชื่อ........................................................................................')
    gen_single_text(pdf, 70, u'(.....................................................................................)')
    
    pdf.output("group3/hour.pdf", 'F')
    
    with open('group3/hour.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=hour.pdf'
        return response
    pdf.closed
예제 #6
0
def genallpdf(request): # grnerate pdf for show all section data.
    allTeach = Teach.objects.all()
    allsection = Section.objects.all()
    
    ListSec = [] # collect teacher each sectoin because a section has more than a teacher.
    for sec in allsection: # collecting teacher to each section.
        eachSec = []
        for teach in allTeach:
            if teach.section == sec:
                eachSec.append(teach)
        ListSec.append(eachSec)
        
    pdf = FPDF('L', 'mm', 'A4') # start pdf 'L' is landscape.
    pdf.add_page()
    
    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)
    pdf.set_font('Kinnari', '', 8)
        
    ganY = [10, 18]
    drawAttr(pdf, ganY[0], ganY[1], True) # call to draw table
    pdf.cell(0, ganY[0], u'ลำดับ              ชื่อ-สกุล                    ตัวย่อ    รหัสวิชา                ชื่อวิชา                      ตอนเรียน  วัน       เวลา       ห้องเรียน  เบอร์โทรศัพท์                   Email                  บ-ช สหกรณ์      หมายเหตุ    ')
    pdf.ln(4) # width:298 height:210
    
    cnt_no = 0 # use to fill in number column.
    cnt_line = 0  # use to calculate next line to draw row of table.
    for sec in ListSec: # drawing table
        cnt_no += 1
        no = str(cnt_no)
        # write no.
        for Prof in sec: # access all teacher in each section
            cnt_line += 1
            
            try:
                first_name = Prof.prof.firstName
                last_name = Prof.prof.lastName
                full_name = first_name + '  ' + last_name
            except:
                full_name = 'None'
                
            try:
                shortname = Prof.prof.shortName
            except:
                shortname = 'None'
                
            try:
                subjectID = Prof.subject.subjectID
            except:
                subjectID = 'None'
                
            try:
                subject = Prof.subject.subjectName
            except:
                subject = 'None'
                
            try:
                section = Prof.section.section
            except:
                section = " "
                
            try:
                day = Prof.section.date
            except:
                day = ' '
            
            try:
                starttime = Prof.section.startTime
            except:
                starttime = 'None'
                
            try:
                room = Prof.section.classroom
            except:
                room = 'None'
                
            try:
                phone_num = Prof.prof.tell
            except:
                phone_num = 'None'
            
            try:
                email = Prof.prof.email
            except:
                email = 'None'
            
            try:
                sahakorn = Prof.prof.sahakornAccount
            except:
                sahakorn = 'None'
                
            pdf.cell(8, 18, no)
            pdf.cell(45, 18,full_name)
            pdf.cell(8, 18, shortname)
            pdf.cell(17, 18, subjectID)
            pdf.cell(45, 18, subject)
            pdf.cell(12, 18, section)
            pdf.cell(7, 18, day)
            pdf.cell(16, 18, str(starttime))
            pdf.cell(12, 18, room)
            pdf.cell(19, 18, phone_num)
            pdf.cell(43, 18, email)
            pdf.cell(29, 18, sahakorn)

            pdf.ln(8)
            if cnt_line % 16 == 0: # check for new pae. I set maximun 16 teachers per a page. 
                drawAttr(pdf, ganY[0]+ (cnt_line*8), ganY[1] + (cnt_line*8), True)
            else:
                drawAttr(pdf, ganY[0]+ (cnt_line*8), ganY[1] + (cnt_line*8))
            no = ''
    
    pdf.ln(8)
    pdf.cell(230, 18, '')
    pdf.cell(230, 18, u'ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ ')
    pdf.ln(8)
    pdf.cell(240, 18, '')
    pdf.cell(240, 18, u'คณะวิศวกรรมศาสตร์ ')
    pdf.ln(8)
    pdf.output("group3/allTeach.pdf", 'F')
    
    with open('group3/allTeach.pdf', 'rb') as pdf: # use to call pdf page in browser.
        response = HttpResponse(pdf.read(), content_type='application/pdf')
        response['Content-Disposition'] = 'filename=allTeach.pdf'
        return response
    pdf.closed
예제 #7
0
def genpdf(request, profID): # use to generate pdf file for lend another teacher.
    teachObj = Teach.objects.get(pk= int(profID))   # get all objects teacher.
    pdf = FPDF('P', 'mm', 'A4')    # start pdf file
    pdf.add_page()                   # begin first page.
    
    pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)  # add font
    pdf.set_font('DejaVu', '', 14)              # set font and font size
    
    pdf.image('group3/trarachakarn.png',30,25,15)   # insert image
    pdf.ln(25)    # new line
    
    proID = ''
    firstname = ''
    lastname = ''
    shortname = ''
    department = ''
    faculty = ''
    sahakornAccount = ''
    tell = ''
    email = ''
    
    subjectID = ''
    subjectName = ''
    sec = ''
    time = ''
    day = ''
    
    try: # prefix_name and academic_name
        academicPosition = teachObj.prof.academic_position
        if (academicPosition == '0'):
            academicPosition = u''
            short_academicPosition = u''
            try:
                pre_name = teachObj.prof.prefix_name
                if (pre_name == '3'):
                    pre_name = u'ดร.'
                else:
                    pre_name = u'อ.'
            except:
                pre_name = u'อ. '
        elif academicPosition == '1':
            academicPosition = u'ผู้ช่วยศาสตราจารย์ '
            short_academicPosition = u'ผศ.'
            try:
                pre_name = teachObj.prof.prefix_name
                if pre_name == '3':
                    pre_name = u'ดร.'
                else:
                    pre_name = ''
            except:
                pre_name =''
        elif academicPosition == '2':
            academicPosition =  u'รองศาสตราจารย์ '
            short_academicPosition =  u'รศ.'
            try:
                pre_name = teachObj.prof.prefix_name
                if pre_name == '3':
                    pre_name = u'ดร.'
                else:
                    pre_name = ''
            except:
                pre_name =''
        else:
            academicPosition = u'ศาสตราจารย์ '
            short_academicPosition = u'ศ.'
            try:
                pre_name = teachObj.prof.prefix_name
                if pre_name == '3':
                    pre_name = u'ดร.'
                else:
                    pre_name = ''
            except:
                pre_name =''
    except:
        academicPosition = ''
    
    try: # check all data for beware blank data.
        proID = teachObj.prof.shortName
    except:
        proID = 'None'

    try:
        firstname = teachObj.prof.firstName
    except:
        firstname = 'None'
 
    try:
        lastname = teachObj.prof.lastName
    except:
        lastname = 'None'

    try:
        shortname  = teachObj.prof.shortName
    except:
        shortname = 'None'

    try:
        department = teachObj.prof.department
    except:
        department = 'None'
    
    try:
        faculty = teachObj.prof.faculty
    except:
        faculty = 'None'

    try:
        sahakornAccount = teachObj.prof.sahakornAccount
    except:
        sahakornAccount = 'None'

    try:
        tell = teachObj.prof.tell
    except:
        tell = 'None'

    try:
        email = teachObj.prof.email
    except:
        email = 'None'
    
    try:
        subjectID = teachObj.subject.subjectID
    except:
        subjectID = 'None'
        
    try:
        subjectName = teachObj.subject.subjectName
    except:
        subjectName = 'None'
        
    try:
        sec = teachObj.section.section
    except:
        sec = 'None'
    
    try:
        time = str(teachObj.section.startTime)
    except:
        time = 'None'
        
    try:
        day = teachObj.section.date
        if day == 'M':
            day = u'จันทร์'
        elif day == 'T':
            day = u'อังคาร'
        elif day == 'W':
            day = u'พุธ'
        elif day == 'H':
            day = u'พฤหัสบดี'
        elif day == 'F':
            day = u'ศุกร์'
        elif day == 'S':
            day = u'เสาร์'
        else:
            day = u'อาทิตย์'
    except:
        day = 'None'
        
    pdf.add_font('THSarabun Bold', '', 'THSarabun Bold.ttf', uni=True)  # thai font bold
    pdf.set_font('THSarabun Bold', '', 29)
    pdf.cell(72, 10, u'')
    pdf.cell(0, 10, u' บันทึกข้อความ')
    pdf.ln(10)
    pdf.add_font('THSarabun Bold', '', 'THSarabun Bold.ttf', uni=True)  # thai font
    pdf.set_font('THSarabun Bold', '', 20)
    pdf.cell(19, 10, u'')
    pdf.cell(22, 10, u'ส่วนราชการ')
    pdf.add_font('THSarabun', '', 'THSarabun.ttf', uni=True)
    pdf.set_font('THSarabun', '', 16)
    pdf.cell(0, 11, u'  ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ คณะวิศวกรรมศาสตร์  โทร. ๘๕๑๘')
    pdf.line(55,52.5,180,52.5)
    pdf.ln(8)
    pdf.add_font('THSarabun Bold', '', 'THSarabun Bold.ttf', uni=True)
    pdf.set_font('THSarabun Bold','', 20)
    pdf.cell(19, 10, u'')
    pdf.cell(5, 10, u'ที่')
    pdf.add_font('THSarabun', '', 'THSarabun.ttf', uni=True)
    pdf.set_font('THSarabun', '', 16)
    pdf.cell(70, 10, u'   วฟ')
    pdf.add_font('THSarabun Bold', '', 'THSarabun Bold.ttf', uni=True)
    pdf.set_font('THSarabun Bold','', 20)
    pdf.cell(0, 10, u'วันที่')
    pdf.line(34,60.5,180,60.5)
    pdf.ln(8)
    pdf.cell(19, 10, u'')
    pdf.cell(11, 10, u'เรื่อง')
    pdf.add_font('THSarabun', '', 'THSarabun.ttf', uni=True)
    pdf.set_font('THSarabun', '', 16)
    pdf.cell(0, 11, u'การจัดการเรียนการสอนสำหรับนักศึกษาโครงการพิเศษ(สองภาษา)')
    pdf.line(40,68.5,180,68.5)
    pdf.ln(8)
    pdf.add_font('THSarabun Bold', '', 'THSarabun Bold.ttf', uni=True)
    pdf.set_font('THSarabun Bold','', 20)
    pdf.cell(19, 10, u'')
    pdf.cell(10, 10, u'เรียน')
    pdf.add_font('THSarabun', '', 'THSarabun.ttf', uni=True)
    pdf.set_font('THSarabun', '', 16)
    pdf.cell(24, 11, u'หัวหน้าภาควิชา' + department)
    pdf.ln(8)
    pdf.cell(45, 10, u'')
    pdf.cell(0, 10, u'ตามที่ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ได้ขอรับบริการจัดการเรียนการสอนจาก')
    pdf.ln(8)
    pdf.cell(19, 10, u'')
    pdf.cell(23, 10, u'ท่านในรายวิชา                                                              สำหรับนักศึกษาโครงการพิเศษ (สองภาษา) ')
    pdf.cell(20, 10, u'' + subjectName + '  '  + subjectID) 
    pdf.ln(8)
    pdf.cell(19, 10, u'')
    pdf.cell(0, 10, u'ภาคเรียนที่ .........  นั้น')
    pdf.ln(8)
    pdf.cell(45, 10, u'')
    pdf.cell(0, 10, u'ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ขอให้ท่านยืนยันการจัดการเรียนการสอนในราย')
    pdf.ln(8)
    pdf.cell(19, 0, u'')
    pdf.cell(0, 10, u'วิชาดังกล่าว  ตามแบบฟอร์มด้านล่าง พร้อมตารางสอนและใบเบิกค่าสอนของอาจารย์ผู้สอน  และส่งคืนกลับ ')
    pdf.ln(8)
    pdf.cell(19, 0, u'')
    pdf.cell(0, 10, u'ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  เพื่อจะได้ดำเนินการในส่วนที่เกี่ยวข้องต่อไป')
    pdf.ln(8)
    pdf.cell(45, 10, u'')
    pdf.cell(0, 10, u'จึงเรียนมาเพื่อโปรดทราบ')
    pdf.ln(20)
    pdf.cell(94, 10, u'')
    pdf.cell(100, 10, u'(ผู้ช่วยศาสตราจารย์ ดร.นภดล   วิวัชรโกเศศ)')
    pdf.ln(8)
    pdf.cell(94, 10, u'')
    pdf.cell(90, 10, u'หัวหน้าภาควิศวกรรมไฟฟ้าและคอมพิวเตอร์')
    pdf.ln(14)
    pdf.cell(21, 10, u'')
    pdf.cell(0, 10, u'.........................................................................................................................................................................')
    pdf.ln(8)
    pdf.cell(8, 10,u'')
    pdf.cell(30, 10, u'         ชื่อผู้สอน ' + academicPosition + pre_name + firstname + '   '+ lastname + u'            รหัสผู้สอน ' + proID )
    #pdf.cell(80, 10, u'' + academicPosition +pre_name+ firstname + '   '+ lastname)
    #pdf.cell(80, 10, u'' + proID)
    pdf.ln(8)
    pdf.cell(8, 10,u'')
    pdf.cell(30, 10, u'         ภาควิชา')
    pdf.cell(60, 10, u'' + department)
    pdf.cell(20, 10, u'คณะ')
    pdf.cell(20, 10, u'' + faculty)
    pdf.ln(8)
    pdf.cell(8, 10,u'')
    pdf.cell(30, 10, u'         รหัสวิชา')
    pdf.cell(60, 10, u'' +subjectID)
    pdf.cell(20, 10, u'ชื่อวิชา')
    pdf.cell(20, 10, u'' + subjectName) 
    pdf.ln(8)
    pdf.cell(8, 10,u'')
    pdf.cell(30, 10, u'         ตอนเรียน')
    pdf.cell(40, 10, u'' + sec)
    pdf.cell(10, 10, u'วัน')
    pdf.cell(40, 10, u'' + day)
    pdf.cell(15, 10, u'เวลา')
    pdf.cell(20, 10, u'' + str(time)[:5] + u' น.')
    pdf.ln(8)
    pdf.cell(8, 10,u'')
    pdf.cell(0, 10, u'         ได้ดำเนินการจัดการเรียนการสอนเป็น ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                      ภาษาอังกฤษ  ')
    
    pdf.rect(52, 219, 3, 3)
    pdf.ln(8)
    pdf.cell(0, 10, u'                                      ภาษาไทย')
    pdf.rect(52, 227, 3, 3)
    
    pdf.ln(8)
    pdf.cell(94, 10, u'')
    pdf.cell(100, 10, u'ลงชื่อ................................................อาจารย์ผู้สอน ')
    pdf.ln(8)
    pdf.cell(100, 10, u'')
    pdf.cell(110, 10, u''+u'( ' +short_academicPosition + pre_name + firstname +'   '+ lastname+u' )' )
    pdf.ln(8)
    pdf.cell(94, 10, u'')
    pdf.cell(100, 10, u'ลงชื่อ................................................')
    pdf.ln(8)
    pdf.cell(100, 10, u'')
    pdf.cell(110, 10, u'(..............................................) ')
    pdf.ln(8)
    pdf.cell(94, 10, u'')
    pdf.cell(100, 10, u'หัวหน้าภาควิชา' + department)
    pdf.ln(8)

    pdf.output("group3/uni.pdf", 'F')
    
    # next path will open pdf file in new tab on browser.
    with open('group3/uni.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=uni.pdf'
        return response
    pdf.closed
예제 #8
0
def genpdf(request, profID):
    teachObj = Teach.objects.get(pk= int(profID)) 
    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page()
    
    pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
    pdf.set_font('DejaVu', '', 14)
    
    pdf.image('group3/trarachakarn.png',20,20,20)
    pdf.ln(25)
    
    proID = ''
    firstname = ''
    lastname = ''
    shortname = ''
    department = ''
    faculty = ''
    sahakornAccount = ''
    tell = ''
    email = ''
    
    try:
        proID = teachObj.prof.profID
    except:
        proID = 'None'

    try:
        firstname = teachObj.prof.firstName
    except:
        firstname = 'None'
 
    try:
        lastname = teachObj.prof.lastName
    except:
        lastname = 'None'

    try:
        shortname  = teachObj.prof.shortName
    except:
        shortname = 'None'

    try:
        department = teachObj.prof.department
    except:
        department = 'None'
    
    try:
        faculty = teachObj.prof.faculty
    except:
        faculty = 'None'

    try:
        sahakornAccount = teachObj.prof.sahakornAccount
    except:
        sahakornAccount = 'None'

    try:
        tell = teachObj.prof.tell
    except:
        tell = 'None'

    try:
        email = teachObj.prof.email
    except:
        email = 'None'
        
    pdf.add_font('Kinnari-Bold', '', 'Kinnari-Bold.ttf', uni=True)
    pdf.set_font('Kinnari-Bold', '', 18)
    pdf.cell(0, 10, u'                         บันทึกข้อความ')
    pdf.ln(10)
    pdf.add_font('Kinnari', '', 'Kinnari.ttf', uni=True)
    pdf.set_font('Kinnari', '', 12)
    pdf.cell(0, 10, u'         ส่วนราชการ ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์ คณะวิศวกรรมศาสตร์  โทร. ๘๕๑๘')
    pdf.line(46,52,180,52)
    pdf.ln(8)
    pdf.cell(0, 10, u'         ที่  วฟ     /๒๕๕๘                                        วันที่  ')
    pdf.line(30,60,180,60)
    pdf.ln(8)
    pdf.cell(0, 10, u'         เรื่อง การจัดการเรียนการสอนสำหรับนักศึกษาโครงการพิเศษ(สองภาษา) ')
    pdf.line(30,68,180,68)
    pdf.ln(8)
    pdf.cell(0, 10, u'         เรียน หัวหน้าภาควิชา ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                     ตามที่ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ได้ขอรับบริการจัดการเรียนการ')
    pdf.ln(8)
    pdf.cell(0, 10, u'         สอนจากท่านในรายวิชา                                                      สำหรับนักศึกษา')
    pdf.ln(8)
    pdf.cell(0, 10, u'         โครงการพิเศษ (สองภาษา)  ภาคเรียนที่            นั้น')
    pdf.ln(8)
    pdf.cell(0, 10, u'                    ภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  ขอให้ท่านยืนยันการจัดการเรียนการสอนใน')
    pdf.ln(8)
    pdf.cell(0, 10, u'         รายวิชาดังกล่าว ตามแบบฟอร์มด้านล่าง พร้อมตารางสอนและใบเบิกค่าสอนของอาจารย์ผู้สอนและ')
    pdf.ln(8)
    pdf.cell(0, 10, u'         ส่งคืนกลับภาควิชาวิศวกรรมไฟฟ้าและคอมพิวเตอร์  เพื่อจะได้ดำเนินการในส่วนที่เกี่ยวข้องต่อไป')
    pdf.ln(8)
    pdf.cell(0, 10, u'                        จึงเรียนมาเพื่อโปรดทราบ')
    pdf.ln(20)
    pdf.cell(0, 10, u'                                                  (ดร.นภดล   วิวัชรโกเศศ)')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                              หัวหน้าภาควิศวกรรมไฟฟ้าและคอมพิวเตอร์')
    pdf.ln(14)
    pdf.cell(0, 10, u'            ..................................................................................................................................................')
    pdf.ln(8)
    pdf.cell(0, 10, u'         ชื่อผู้สอน.................................................................... รหัสผู้สอน.................................ภาควิชา ')
    pdf.ln(8)
    pdf.cell(0, 10, u'         คณะ.......................................................................รหัสวิชา...........................................ชื่อวิชา ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                        ตอนเรียน           วัน              เวลา  ')
    pdf.ln(8)
    pdf.cell(0, 10, u'         ได้จัดการเรียนการสอนเป็น ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                    ภาษาอังกฤษ  ')
    pdf.rect(37, 210, 3, 3)
    pdf.ln(8)
    pdf.cell(0, 10, u'                    ภาษาไทย')
    pdf.rect(37, 218, 3, 3)
    pdf.ln(8)
    pdf.cell(0, 10, u'                                            ลงชื่อ......................................อาจารย์ผู้สอน ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                            (..............................................) ')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                            ลงชื่อ......................................')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                            (..............................................) ')
    pdf.ln(8)   
    pdf.cell(0, 10, u'                                            หัวหน้าภาควิชา............................................')
    pdf.ln(8)

    pdf.cell(0, 10, u'' + proID)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + firstname + '   '+ lastname)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + shortname)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + department)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + faculty)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + sahakornAccount)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + tell)
    pdf.ln(8)
    pdf.cell(0, 10, u'' + email)          
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.subject.subjectID)          
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.subject.subjectName)          
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.section.section)          
    pdf.ln(20)
    pdf.cell(0, 10, u'' + str(teachObj.section.startTime))          
    pdf.ln(20)
    pdf.cell(0, 10, u'' + teachObj.section.date)          
    pdf.ln(20)
    pdf.output("group3/uni.pdf", 'F')
    
    # next path will open pdf file in new tab on browser.
    with open('group3/uni.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=uni.pdf'
        return response
    pdf.closed
예제 #9
0
def addpdf2(request, profID): # use to generate pdf file for lend another teacher.
    #template = 'grop4/pdf.html'
    #teachObj = Teach.objects.get(pk= int(profID))   # get all objects teacher.

    Obj = WithdrawCure.objects.get(pk= int(profID))
    print Obj.user
    print WithdrawStudy.user
    #familyObj = Family.objects.get(user=Obj.user)
    lists = Obj.user.family_set.all()
    dad = Obj.user.Father_set.all()
    mom = Obj.user.Monther_set.all()
    ch = Obj.user.Child_set.all()
    presi = EditPresident.objects.all()
    sp = Obj.user.Spouse_set.all()

    pdf = FPDF('P', 'mm', 'A4')
    pdf.add_page()


    try:
        firstname = Obj.user.firstname_th
    except:
        firstname = 'None'

    try:
        lastname = Obj.user.lastname_th
    except:
        lastname = 'None'

    try:
        department = Obj.user.department
    except:
        department = 'None'

    try:
        faculty = Obj.user.faculty
    except:
        faculty = 'None'

    try:
        typeuser = Obj.user.type
    except:
        typeuser = '******'

    try:
        user = Obj.user
    except:
        user = '******'

    try:
        account_id = Obj.account_id
    except:
        account_id = 'None'

    try:
        disease = Obj.disease
    except:
        disease = 'None'

    try:
        hospital = Obj.hospital
    except:
        hospital = 'None'

    try:
        hospitalOf = Obj.hospitalOf
    except:
        hospitalOf = 'None'

    try:
        startDate = Obj.startDate
    except:
        startDate = 'None'

    try:
        stopDate = Obj.stopDate
    except:
        stopDate = 'None'

    try:
        value = Obj.value
    except:
        value = 'None'

    try:
        valueChar = Obj.valueChar
    except:
        valueChar = 'None'

    try:
        numBill = Obj.numBill
    except:
        numBill = 'None'

    try:
        typeWithdraw = Obj.typeWithdraw
    except:
        typeWithdraw = 'None'


    pdf.line(12, 38, 198, 38)
    pdf.line(12, 38, 12, 280)
    pdf.line(12, 280, 198, 280)
    pdf.line(198, 38, 198, 280)

    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',80,27,6)

    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',29,50,6) #ข้าราชการ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',49,50,6) #ลูกจ้างประจำ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',73,50,6) #ข้าราชการบำนาช
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',145,50,6) #พนักงานมหาวิทยาลัย

    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,71,6) #ไม่เป็นข้าราชการหรือลูกจ้างประจำ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,78,6) #เป็นข้าราชการ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',45,78,6) #ลูกจ้างประจำ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',70,78,6) #พนักงานมหาวิทยาลัย
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,85,6) #เป็นพนักงานหรือลูกจ้าง

    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,106,6) #เป็นบิดาชอบด้วยกฏหมาย
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,113,6) #เป็นมารดา
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,120,6) #บุตรอยู่ในความปกครองของข้าพเจ้า
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,127,6) #บุตรอยู่ในความอุปการะการเลี้ยงดูของข้าพเจ้า




    pdf.add_font('THSarabunNew Bold', '', 'THSarabunNew Bold.ttf', uni=True)
    pdf.set_font('THSarabunNew Bold', '', 14)
    pdf.cell(169, 10, u'')
    pdf.cell(0, 10, u'แบบ 7223')
    pdf.ln(8)
    pdf.set_font('THSarabunNew Bold', '', 18)
    pdf.cell(0, 10, u'                                    ใบเบิกเงินสวัสดิการการเกี่ยวกับการศึกษาของบุตร     ')
    pdf.ln(7)
    pdf.set_font('THSarabunNew Bold', '', 14)
    pdf.cell(0, 10, u'                                     โปรดทำเครื่องหมาย      ลงในช่องว่าง  พร้อมทั้งกรอกข้อความให้ครบถ้วน    ')
    pdf.ln(16)
    pdf.add_font('THSarabunNew', '', 'THSarabunNew.ttf', uni=True)
    pdf.set_font('THSarabunNew', '', 14)
    pdf.cell(30, 10, u'     1. ข้าพเจ้า................................................................................................เลขที่บัญชีสหกรณ์ออมทรัพย์ SA-.....................................................')
    pdf.cell(115, 8, u'' + firstname + u'  ' + lastname)
    pdf.cell(20, 8, u'' + account_id)
    pdf.ln(7)
    pdf.cell(0, 10, u'        สถานะ  ข้าราชการ   ลูกจ้างประจำ   ข้าราชการบำนาญ(เปลี่ยนสถานะ และ เกษียณอายุ)   พนักงานมหาวิทยาลัย ')
    if typeuser == '0':
        pdf.image('group4\son2.png',29,50,6)
    elif typeuser == '1':
        pdf.image('group4\son2.png',49,50,6)
    elif typeuser == '2':
        pdf.image('group4\son2.png',73,50,6)
    elif typeuser == '3':
        pdf.image('group4\son2.png',145,50,6)
    pdf.ln(7)
    pdf.cell(40, 10, u'        สังกัด ภาควิชา.................................................................................................คณะ......................................................................................')
    if department == '1':
        pdf.cell(85, 8, u'วิศวกรรมไฟฟ้าและคอมพิวเตอร์')
    if faculty == '1':
        pdf.cell(0, 8, u'วิศวกรรมศาสตร์')
    pdf.ln(7)
    pdf.cell(50, 10, u'     2. คู่สมรสของข้าพเจ้าชื่อ .................................................................................................................................................................................')
    pdf.cell(0, 8, u'' + sp.title + sp.firstname + u'  ' + sp.lastname)
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  ไม่เป็นข้าราชการหรือลูกจ้างประจำ')
    if sp.typeOfWork == '0':
        pdf.image('group4\son2.png',19,71,6)
    pdf.ln(7)
    pdf.cell(109, 10, u'        □  เป็นข้าราชการ  □  ลูกจ้างประจำ  □  พนักงานมหาวิทยาลัย ตำแหน่ง...........................................สังกัด.........................................')
    if sp.typeOfWork == '1':
        pdf.image('group4\son2.png',19,78,6)
        pdf.cell(41, 8, u'' + sp.office)
        pdf.cell(0, 8, u'' + sp.position)
    elif sp.typeOfWork == '2':
        pdf.image('group4\son2.png',45,71,6)
        pdf.cell(41, 8, u'' + sp.office)
        pdf.cell(0, 8, u'' + sp.position)
    elif sp.typeOfWork == '3':
        pdf.image('group4\son2.png',70,71,6)
        pdf.cell(41, 8, u'' + sp.office)
        pdf.cell(0, 8, u'' + sp.position)
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  เป็นพนักงานหรือลูกจ้างในรัฐวิสาหกิจ/หน่วยงานของทางราชการ ราชการส่วนท้องถิ่น กรุงเทพมหานคร องค์กรอิสระ')
    if sp.typeOfWork == '4':
        pdf.image('group4\son2.png',19,85,6)
    pdf.ln(7)
    pdf.cell(80, 10, u'             องค์กรมหาชน หรือ หน่วยงานอื่นใด ตำแหน่ง.........................................................................สังกัด.....................................................')
    if sp.typeOfWork == '4':
        pdf.cell(62, 8, u'' + sp.office)
        pdf.cell(0, 8, u'' + sp.position)
    pdf.ln(7)
    pdf.cell(0, 10, u'     3. ข้าพเจ้าเป็นผู้มีสิทธิและขอใช้สิทธิเนื่องจาก ')
    pdf.ln(7)
    pdf.cell(0, 10, u'        □ เป็นบิดาชอบด้วยกฏหมาย')
    if ch.parentRelate == '0':
        pdf.image('group4\son2.png',19,106,6)
    pdf.ln(7)
    pdf.cell(0, 10, u'        □ เป็นมารดา')
    if ch.parentRelate == '1':
        pdf.image('group4\son2.png',19,113,6)
    pdf.ln(7)
    pdf.cell(0, 10, u'        □ บุตรอยู่ในความปกครองของข้าพเจ้า โดยการสิ้นสุดของการสมรส ')
    if ch.parentRelate == '2':
        pdf.image('group4\son2.png',19,120,6)
    pdf.ln(7)
    pdf.cell(0, 10, u'        □ บุตรอยู่ในความอุปการะการเลี้ยงดูของข้าพเจ้าเนื่องจากแยกกันอยู่ โดยมิได้หย่าขาดตามกฏหมาย')
    if ch.parentRelate == '3':
        pdf.image('group4\son2.png',19,127,6)
    pdf.ln(7)
    pdf.cell(0, 10, u'     4. ข้าพเจ้าได้จ่ายเงินสำหรับการศึกษาของบุตร ดังนี้')
    pdf.ln(7)
    pdf.cell(0, 10, u'        (1) เงินบำรุงการศึกษา                                    (2) เงินค่าเล่าเรียน ')
    pdf.ln(7)
    pdf.cell(33, 10, u'            1)  บุตรชื่อ........................................................................................เกิดเมื่อ...........................................................................................')
    pdf.cell(90, 8, u'' + ch.title + ch.firstname + u'  ' + ch.lastname)
    pdf.cell(0, 8, u'' + ch.birthDate)
    pdf.ln(7)
    pdf.cell(70, 10, u'                เป็นบุตรลำดับที่(ของบิดา)...........................................................เป็นบุตรลำดับที่(ของมารดา)..........................................................')
    pdf.cell(80, 8, u'' + ch.orderF)
    pdf.cell(0, 8, u'' + ch.orderM)
    pdf.ln(7)
    pdf.cell(120, 10, u'                (กรณีเป็นบุตรแทนที่บุตรซึ่งถึงแก่กรรมแล้ว) แทนที่บุตรลำดับที่........................................................................................................')
    pdf.cell(0, 8, u'')
    pdf.ln(7)
    pdf.cell(27, 10, u'                ชื่อ...........................................................................เกิดเมื่อ................................................ถึงแก่กรรมเมื่อ........................................')
    pdf.cell(70, 8, u'นายกิตติพงศ์ จันทร์นัณทยงว์ป่า')
    pdf.cell(58, 8, u'11/11/1111')
    pdf.cell(0, 8, u'11/11/1111')
    pdf.ln(7)
    pdf.cell(35, 10, u'                สถานศึกษา.................................................................................อำเภอ........................................จังหวัด..........................................')
    pdf.cell(75, 8, u'มหาวิทยาลัยหหหหหหหหหหหหหหหหหหห')
    pdf.cell(40, 8, u'เมือง')
    pdf.cell(0, 8, u'ราชบุรี')
    pdf.ln(7)
    pdf.cell(35, 10, u'                ชั้นที่ศึกษา..........................................................................................................จำนวน..............................................................บาท')
    pdf.cell(100, 8, u'ประถมศึกษาปีที่4')
    pdf.cell(0, 8, u'2,000')
    pdf.ln(7)
    pdf.cell(0, 10, u'            2)  บุตรชื่อ........................................................................................เกิดเมื่อ...........................................................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                เป็นบุตรลำดับที่(ของบิดา)...........................................................เป็นบุตรลำดับที่(ของมารดา)..........................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                (กรณีเป็นบุตรแทนที่บุตรซึ่งถึงแก่กรรมแล้ว) แทนที่บุตรลำดับที่........................................................................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ชื่อ...........................................................................เกิดเมื่อ................................................ถึงแก่กรรมเมื่อ........................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                สถานศึกษา.................................................................................อำเภอ........................................จังหวัด..........................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ชั้นที่ศึกษา..........................................................................................................จำนวน..............................................................บาท')
    pdf.ln(7)
    pdf.cell(0, 10, u'            3)  บุตรชื่อ........................................................................................เกิดเมื่อ...........................................................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                เป็นบุตรลำดับที่(ของบิดา)...........................................................เป็นบุตรลำดับที่(ของมารดา)..........................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                (กรณีเป็นบุตรแทนที่บุตรซึ่งถึงแก่กรรมแล้ว) แทนที่บุตรลำดับที่........................................................................................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ชื่อ...........................................................................เกิดเมื่อ................................................ถึงแก่กรรมเมื่อ........................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                สถานศึกษา.................................................................................อำเภอ........................................จังหวัด..........................................')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ชั้นที่ศึกษา..........................................................................................................จำนวน..............................................................บาท')



    pdf.add_page()

    #frame
    pdf.line(12, 15, 198, 15)
    pdf.line(12, 15, 12, 253)
    pdf.line(12, 253, 198, 253)
    pdf.line(198, 15, 198, 253)
    pdf.line(12, 124, 198, 124)
    pdf.line(12, 175, 198, 175)

    #table
    pdf.line(20, 205, 83, 205)
    pdf.line(20, 205, 20, 250)
    pdf.line(20, 250, 83, 250)
    pdf.line(83, 205, 83, 250)

    pdf.line(20, 213, 83, 213)
    pdf.line(20, 220, 83, 220)
    pdf.line(20, 228, 83, 228)
    pdf.line(20, 235, 83, 235)
    pdf.line(48, 205, 48, 235)

    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,26,6) #ตามสิทธิ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',59,26,6) #เฉพาะส่วน
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,47,6) #ข้าพเจ้ามีสิทธิได้รับเงินช่วยเหลือ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,61,6) #บุตรของข้าพเจ้าอยู่ในข่าย
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,68,6) #เป็นผู้ใช้สิทธิเบิกเงินช่วยเหลือ
    pdf.image('C:\Users\Artty\PycharmProjects\untitled\son2.png',19,75,6) #คู่สมรสของข้าพเจ้าได้รับการช่วยเหลือ

    pdf.add_font('THSarabunNew', '', 'THSarabunNew.ttf', uni=True)
    pdf.set_font('THSarabunNew', '', 14)
    pdf.ln(7)
    pdf.cell(0, 10, u'     5. ข้าพเจ้าขอรับเงินสวัสดิการเกี่ยวกับการศึกษาของบุตร')
    pdf.ln(7)
    pdf.cell(120, 10, u'        □  ตามสิทธิ                      □  เฉพาะส่วนที่ยังขาดจากสิทธิ เป็นจำนวนเงิน ............................................................. บาท')
    pdf.cell(0, 8, u'20000')
    pdf.ln(7)
    pdf.cell(20, 10, u'        (...............................................................................................................................................)')
    pdf.cell(0, 8, u'เก้าพันเก้าร้อยเก้าสิบเก้าบาทถ้วน')
    pdf.ln(7)
    pdf.cell(0, 10, u'     6. เสนอ........................................... ')
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  ข้าพเจ้ามีสิทธิได้รับเงินช่วยเหลือตามพระราชกฤษฎีกาเงินสวัสดิการเกี่ยวกับการศึกษาของบุตร')
    pdf.ln(7)
    pdf.cell(0, 10, u'             และข้อความระบุข้างต้นเป็นความจริง ')
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  บุตรของข้าพเจ้าอยู่ในข่ายได้บการช่วยเหลือตามพระราชกฤษฎีกาเงินสวัสดิการเกี่ยวกับการศึกษาของบุตร')
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  เป็นผู้ใช้สิทธิเบิกเงินช่วยเหลือตามพระราชกฤษฎีกาเงินสวัสดิการเกี่ยวกับการศึกษาของบุตรแต่เพียงฝ่ายเดียว')
    pdf.ln(7)
    pdf.cell(0, 10, u'        □  คู่สมรสของข้าพเจ้าได้รับการช่วยเหลือจากรัฐวิสาหกิจ หน่วยงานของทางราชการ ราชการส่วนท้องถิ่นกรุงเทพมหานคร')
    pdf.ln(7)
    pdf.cell(0, 10, u'             องค์กรอิสระ องค์การมหาชน หรือหน่วยงานอื่นใด ต่ำกว่าจำนวนเงินที่ได้รับจากทางราชการเป็นจำนวนเงิน.....................บาท')
    pdf.ln(7)
    pdf.cell(0, 10, u'        ข้าพเจ้าขอรับรองว่ามีสิทธิเบิกได้ตามกฏหมายตามจำนวนเงินที่ขอเบิก')
    pdf.ln(12)
    pdf.cell(0, 10, u'                                                                                            (ลงชื่อ)........................................................ผู้ขอรับเงินสวัสดิการ')
    pdf.ln(7)
    pdf.cell(110, 10, u'                                                                                                   (..........................................................)')
    pdf.cell(0, 8, u'' + firstname + u'   ' + lastname)
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                                               วันที่............เดือน..........................พ.ศ...............')
    pdf.ln(12)
    pdf.cell(0, 10, u'    7. คำอนุมัติ ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                  อนุมัติให้เบิกได้')
    pdf.ln(10)
    pdf.cell(0, 10, u'                                                                                             (ลงชื่อ)......................................................... ')
    pdf.ln(7)
    pdf.cell(110, 10, u'                                                                                                    (..........................................................)')
    pdf.cell(0, 8, u'' + presi.presidentName)
    pdf.ln(7)
    pdf.cell(115, 10, u'                                                                                             ตำแหน่ง..........................................................')
    pdf.cell(0, 8, u'' + presi.position)
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                                             วันที่............เดือน..........................พ.ศ............... ')
    pdf.ln(12)
    pdf.cell(0, 10, u'    8. ใบรับเงิน')
    pdf.ln(7)
    pdf.cell(95, 10, u'                 ได้รับเงินสวัสดิการเกี่ยวกับการรักษาพยาบาล จำนวน...........................................................................บาท ')
    pdf.cell(0, 8, u'66,000')
    pdf.ln(7)
    pdf.cell(35, 10, u'          (..............................................................................................................................................................................)ไปถูกต้องแล้ว ')
    pdf.cell(0, 8, u'หกพันบาทถ้วน')
    pdf.ln(15)
    pdf.cell(45, 10, u'           อัตราที่เบิกได้ต่อปี                                                                   (ลงชื่อ)......................................................ผู้รับเงิน')
    pdf.cell(0, 10, u'66,000')
    pdf.ln(7)
    pdf.cell(45, 10, u'           เบิกครั้งก่อน                                                                                 (..........................................................)    ')
    pdf.cell(73, 10, u'6,000')
    pdf.cell(0, 8, u'นายกิตติพงศ์ จันทร์นัณทยงว์ป่า')
    pdf.ln(7)
    pdf.cell(45, 10, u'           เบิกครั้งนี้ ')
    pdf.cell(0, 10, u'6,000')
    pdf.ln(7)
    pdf.cell(45, 10, u'           คงเหลือ                                                                               (ลงชื่อ)......................................................ผู้จ่ายเงิน ')
    pdf.cell(0, 10, u'6,000')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                                                          (..........................................................)')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ....................................ผู้คุมยอดการเบิก                                     วันที่...........เดือน.........................พ.ศ...............')
    pdf.ln(13)
    pdf.cell(0, 10, u'     คำชี้แจง')
    pdf.ln(7)
    pdf.cell(0, 10, u'                   ให้ระบุการมีสิทธิเพียงใด เมื่อเทียบกับสิทธิที่ได้รับตามพระราชกฤษฎีกาเงินสวัสดิการเกี่ยวกับการศึกษาของบุตร')
    pdf.ln(7)
    pdf.cell(0, 10, u'                   ให้เสนอต่อผู่มีอำนาจอนุมัติ')
    pdf.ln(7)


    pdf.output("group4/bursary.pdf", 'F')

    # next path will open pdf file in new tab on browser.
    with open('group4/bursary.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=bursary.pdf'
        return response
    pdf.closed
예제 #10
0
def addpdf(request, profID): # use to generate pdf file for lend another teacher.

    obj = WithdrawCure.objects.get(pk= int(profID))
    if obj.spouseW == '1':
        sp = Spouse.objects.get(user=obj.user)
    if obj.fatherW == '1':
        dad = Father.objects.get(user=obj.user)
    if obj.motherW == '1':
        mom = Mother.objects.get(user=obj.user)
    if obj.childW1 == '1':
        ch = Child.objects.all()
        ch1list = []
        for i in ch:
            if i.user == obj.user:
                ch1list.append(i)
        for j in ch1list:
            if obj.orderChildW1 == j.OrderF:
                ch1 = j

    if obj.childW2 == '1':
        ch = Child.objects.all()
        ch2list = []
        for i in ch:
            if i.user == obj.user:
                ch2list.append(i)
        for j in ch2list:
            if obj.orderChildW1 == j.OrderF:
                ch2 = j

    pres = EditPresident.objects.all()
    presi = pres[0]
    pdf = FPDF('P', 'mm', 'A4')    # start pdf file
    pdf.add_page()                 # begin first page.


    try:
        firstname = obj.user.firstname_th
    except:
        firstname = 'None'

    try:
        lastname = obj.user.lastname_th
    except:
        lastname = 'None'

    try:
        department = obj.user.department
    except:
        department = 'None'

    try:
        faculty = obj.user.faculty
    except:
        faculty = 'None'

    try:
        if obj.user.type=='1':
            typeu = Teacher.objects.get(userprofile=obj.user)
            typeuser = typeu.position
        elif obj.user.type=='2':
            typeu = Officer.objects.get(userprofile=obj.user)
            typeuser = typeu.position
    except:
        typeuser = '******'

    try:
        user = obj.user
    except:
        user = '******'

    try:
        account_id = obj.account_id
    except:
        account_id = 'None'

    try:
        disease = obj.disease
    except:
        disease = 'None'

    try:
        hospital = obj.hospital
    except:
        hospital = 'None'

    try:
        hospitalOf = obj.hospitalOf
    except:
        hospitalOf = 'None'

    try:
        startDate = obj.startDate
    except:
        startDate = 'None'

    try:
        stopDate = obj.stopDate
    except:
        stopDate = 'None'

    try:
        value = obj.value
    except:
        value = 'None'

    try:
        valueChar = obj.valueChar
    except:
        valueChar = 'None'

    try:
        numBill = obj.numBill
    except:
        numBill = 'None'

    try:
        typeWithdraw = obj.typeWithdraw
    except:
        typeWithdraw = 'None'

    pdf.line(12, 31, 198, 31)
    pdf.line(12, 31, 12, 285)
    pdf.line(12, 285, 198, 285)
    pdf.line(198, 31, 198, 285)
    pdf.line(12, 179, 198, 179)

    pdf.image('group4\A.png',145,113,6) #ก
    pdf.image('group4\B.png',140,190,6) #ข
    pdf.image('group4\C.png',27,254,6) #ค

    pdf.add_font('THSarabunNew Bold', '', 'THSarabunNew Bold.ttf', uni=True)
    pdf.set_font('THSarabunNew Bold', '', 18)
    pdf.cell(169, 10, u'                                    ใบเบิกเงินสวัสดิการเกี่ยวกับการรักษาพยาบาล     ')
    pdf.set_font('THSarabunNew Bold', '', 14)
    pdf.cell(0, 10, u'แบบ 7131')
    pdf.ln(8)
    pdf.cell(0, 10, u'                                     โปรดทำเครื่องหมาย      ลงในช่องว่าง  พร้อมทั้งกรอกข้อความให้ครบถ้วน    ')
    pdf.image('group4\son2.png',80,20,6)
    pdf.ln(16)
    pdf.add_font('THSarabunNew', '', 'THSarabunNew.ttf', uni=True)
    pdf.set_font('THSarabunNew', '', 14)
    pdf.cell(30, 10, u'     1. ข้าพเจ้า................................................................................................เลขที่บัญชีสหกรณ์ออมทรัพย์ SA-.....................................................')
    pdf.cell(115, 8, u'' + firstname + u'  ' + lastname)
    pdf.cell(20, 8, u'' + account_id)
    pdf.ln(7)
    pdf.cell(0, 10, u'        สถานะ  ข้าราชการ   ลูกจ้างประจำ   ข้าราชการบำนาญ(เปลี่ยนสถานะ และ เกษียณอายุ)   พนักงานมหาวิทยาลัย ')
    if typeuser == '0':
        pdf.image('group4\son2.png',29,43,6)
    elif typeuser == '1':
        pdf.image('group4\son2.png',49,43,6)
    elif typeuser == '2':
        pdf.image('group4\son2.png',73,43,6)
    elif typeuser == '3':
        pdf.image('group4\son2.png',145,43,6)
    pdf.ln(7)

    pdf.cell(40, 10, u'        สังกัด ภาควิชา.................................................................................................คณะ......................................................................................')
    if department == '1':
        pdf.cell(85, 8, u'วิศวกรรมไฟฟ้าและคอมพิวเตอร์')
    if faculty == '1':
        pdf.cell(0, 8, u'วิศวกรรมศาสตร์')
    pdf.ln(7)
    pdf.cell(0, 10, u'     2. ขอเบิกเงินค่ารักษาพยาบาลของ')
    pdf.ln(7)
    pdf.cell(0, 10, u'           ตนเอง')
    if obj.selfW == '1':
        pdf.image('group4/son2.png',20,64,6)
    pdf.ln(7)
    pdf.cell(40, 10, u'           คู่สมรส  ชื่อ...............................................................................เลขประจำตัวประชาชน......................................................')
    if obj.spouseW == '1':
        pdf.image('group4\son2.png',20,71,6)
        pdf.cell(90, 8, u'' + sp.title + sp.firstname +u'  '+sp.lastname)
        pdf.cell(0, 8, u''+ sp.pid)
    pdf.ln(7)
    pdf.cell(45, 10, u'                         ที่ทำงาน......................................................................ตำแหน่ง..............................................................................')
    if obj.spouseW == '1':
        pdf.cell(70, 8, u''+ sp.office)
        pdf.cell(0, 8, u''+sp.position)
    pdf.ln(7)

    pdf.cell(40, 10, u'           บิดา      ชื่อ..............................................................................เลขประจำตัวประชาชน......................................................')
    if obj.fatherW == '1':
        pdf.image('group4\son2.png',20,85,6)
        pdf.cell(90, 8, u'' + dad.title + dad.firstname+u'  '+ dad.lastname)
        pdf.cell(0, 8, u''+ dad.pid)
    pdf.ln(7)

    pdf.cell(40, 10, u'           มารดา   ชื่อ..............................................................................เลขประจำตัวประชาชน......................................................')
    if obj.motherW == '1':
        pdf.image('group4\son2.png',20,92,6)
        pdf.cell(90, 8, u''+ mom.title + mom.firstname + u'  '+ mom.lastname)
        pdf.cell(0, 8, u''+ mom.pid)
    pdf.ln(7)

    pdf.cell(40, 10, u'           บุตร      ชื่อ..............................................................................เลขประจำตัวประชาชน......................................................')
    if obj.childW1 == '1':
        pdf.image('group4\son2.png',20,99,6)
        pdf.cell(90, 8, u''+ ch1.title + ch1.firstname +u'  '+ch1.lastname)
        pdf.cell(0, 8, u''+ch1.pid)
    pdf.ln(7)
    pdf.cell(42, 10, u'                          เกิดเมื่อ.................................................เป็นบุตรลำดับที่(ของบิดา)..................เป็นบุตรลำดับที่(ของมารดา)................... ')
    if obj.childW1 == '1':
        pdf.cell(75, 8, u'' + str(ch1.birthDate))
        pdf.cell(50, 8, u'' + str(ch1.orderF))
        pdf.cell(0, 8, u'' + str(ch1.orderM))
    pdf.ln(7)
    pdf.cell(0, 10, u'                           ยังไม่บรรลุนิติภาวะ    เป็นบุตรไร้ความสามารถ หรือเสมือนไร้ความสามารถ ')
    if obj.childW1 == '1':
        if ch1.disable=='1':
            pdf.image('group4\son2.png',71,113,6)
        year = timezone.now().year
        month = timezone.now().month
        today = timezone.now().day
        print today
        birthdate = str(ch1.birthDate).split('-')
        year = year-int(birthdate[0])
        month = month-int(birthdate[1])
        today = today-int(birthdate[2])
        if year > 20   :
             pdf.image('group4\son2.png',38,113,6)
        elif year == 20 and month > 0 :
             pdf.image('group4\son2.png',38,113,6)
        elif year == 20 and today >= 0 and month == 0:
             pdf.image('group4\son2.png',38,113,6)

    pdf.ln(7)
    pdf.cell(40, 10, u'           บุตร      ชื่อ..............................................................................เลขประจำตัวประชาชน.....................................................')
    pdf.ln(7)
    pdf.cell(42, 10, u'                          เกิดเมื่อ.................................................เป็นบุตรลำดับที่(ของบิดา)..................เป็นบุตรลำดับที่(ของมารดา)................... ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                           ยังไม่บรรลุนิติภาวะ    เป็นบุตรไร้ความสามารถ หรือเสมือนไร้ความสามารถ ')
    pdf.ln(7)

    pdf.cell(35, 10, u'         ป่วยเป็นโรค............................................................................................................................................................................................')
    pdf.cell(20, 8, u'' + disease)
    pdf.ln(7)
    pdf.cell(95, 10, u'         และได้รับการตรวจรักษาพยาบาลจาก(ชื่อสถานพยาบาล).....................................................................................................................')
    pdf.cell(20, 8, u'' + hospital)
    pdf.ln(7)
    pdf.cell(115, 10, u'         ซึ่งเป็นสถานพยาบาลของ    ของทางราชการ     เอกชน   ตั้งแต่วันที่.........................................................................................')
    pdf.cell(20, 8, u'' + str(startDate) )
    if hospitalOf == '0':
        pdf.image('group4\son2.png',55,155,6)
    elif hospitalOf == '1':
        pdf.image('group4\son2.png',85,155,6)
    pdf.ln(7)
    pdf.cell(30, 10, u'         ถึงวันที่...........................................................................................เป็นเงินรวมทั้งสิ้น.....................................................................บาท')
    pdf.cell(100, 8, u'' + str(stopDate))
    pdf.cell(20, 8, u'' + str(value))
    pdf.ln(7)
    pdf.cell(30, 10, u'         (.......................................................................................................................) ตามใบเสร็จรับเงินที่แนบ จำนวน.........................ฉบับ')
    pdf.cell(128, 8, u'' + valueChar)
    pdf.cell(20, 8, u'' + str(numBill))
    pdf.ln(14)

    pdf.cell(0, 10, u'    3. ข้าพเจ้ามีสิทธิได้รับเงินสวัสดิการเกี่ยวกับการรักษาพยาบาล ตามพระราชกฤษฎีกาเงินสวัสดิการเกี่ยวกับการรักษาพยาบาล ')
    pdf.ln(7)
    pdf.cell(0, 10, u'         ตามสิทธิ                     เฉพาะส่วนที่ขาดอยู่จากสิทธิที่ได้รับจากหน่วยงานอื่น ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                            เฉพาะส่วนที่ขาดอยู่จากสัญญาประกันภัย ')
    pdf.ln(7)

    pdf.cell(30, 10, u'       เป็นเงิน.....................................................บาท (............................................................................................................................) และ ')
    pdf.cell(55, 8, u'' + str(value))
    pdf.cell(0, 8, u'' + valueChar)
    pdf.ln(12)
    pdf.cell(0, 10, u'       (1)  ข้าพเจ้า                ไม่มีสิทธิได้รับค่ารักษาพยาบาลจากหน่วยงานอื่น  ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      มีสิทธิได้รับค่ารักษาพยาบาลจากหน่วยงานอื่นแต่เลือกใช้สิทธิจากทางราชการ ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      มีสิทธิได้รับค่ารักษาพยาบาลตามสัญญาประกันภัย  ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      เป็นผู้ใช้สิทธิเบิกค่ารักษาพยาบาลสำหรับบุตรแค่เพียงฝ่ายเดียว ')
    pdf.ln(10)


    pdf.cell(0, 10, u'       (2) ................ข้าพเจ้า     ไม่มีสิทธิได้รับค่ารักษาพยาบาลจากหน่วยงานอื่น                      ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      มีสิทธิได้รับค่ารักษาพยาบาลจากหน่วยงานอื่นแต่ค่ารักษาพยาบาลที่ได้รับต่ำกว่าสิทธิตามพระราชกฤษฎีกาฯ ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      มีสิทธิได้รับค่ารักษาพยาบาลตามสัญญาประกันภัย ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                      มีสิทธิได้รับค่ารักษาพยาบาลจากหน่วยงานอื่นในฐานะเป็นผู้อาศัยสิทธิของผู้อื่น ')
    pdf.ln(7)



    pdf.add_page()

    #frame
    pdf.line(12, 15, 198, 15)
    pdf.line(12, 15, 12, 282)
    pdf.line(12, 282, 198, 282)
    pdf.line(198, 15, 198, 282)
    pdf.line(12, 80, 198, 80)
    pdf.line(12, 137, 198, 137)

    #table
    pdf.line(20, 170, 80, 170)
    pdf.line(20, 170, 20, 215)
    pdf.line(20, 215, 80, 215)
    pdf.line(80, 170, 80, 215)
    pdf.line(20, 178, 80, 178)
    pdf.line(20, 185, 80, 185)
    pdf.line(20, 193, 80, 193)
    pdf.line(20, 200, 80, 200)
    pdf.line(42, 170, 42, 200)

    pdf.image('group4\D.png',55,19,6) #ง

    pdf.image('group4\A.png',19,239,6) #A
    pdf.image('group4\B.png',19,246,6) #B
    pdf.image('group4\C.png',19,260,6) #C
    pdf.image('group4\D.png',19,267,6) #D


    pdf.add_font('THSarabunNew', '', 'THSarabunNew.ttf', uni=True)
    pdf.set_font('THSarabunNew', '', 14)
    pdf.cell(0, 10, u'')
    pdf.ln(7)
    pdf.cell(0, 10, u'     4. เสนอ อธิการบดี')
    pdf.ln(14)
    pdf.cell(0, 10, u'                      ข้าพเจ้าขอรับรองว่าข้าพเจ้ามีสิทธิเบิกค่ารักษาพยาบาลสำหรับตนเองและบุคคลในครอบครัวตามจำนวนที่ขอเบิก ซึ่งกำหนด')
    pdf.ln(7)
    pdf.cell(0, 10, u'      ไว้ในกฏหมายและข้อความข้างต้นเป็นจริงทุกประการ')
    pdf.ln(16)
    pdf.cell(0, 10, u'                                                                                       (ลงชื่อ)........................................................ผู้รับเงินสวัสดิการ')
    pdf.ln(7)
    pdf.cell(103, 10, u'                                                                                             (..........................................................)')
    pdf.cell(0, 8, u'' + firstname + u'  ' + lastname)
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                                          วันที่............เดือน..........................พ.ศ...............')
    pdf.ln(14)

    pdf.cell(0, 10, u'    5. คำอนุมัติ ')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                  อนุมัติให้เบิกได้')
    pdf.ln(14)
    pdf.cell(0, 10, u'                                                                       (ลงชื่อ)........................................................ ')
    pdf.ln(7)
    pdf.cell(86, 10, u'                                                                             (..........................................................)')
    pdf.cell(0, 8, u'' + presi.presidentName)
    pdf.ln(7)
    pdf.cell(90, 10, u'                                                                      ตำแหน่ง..........................................................')
    pdf.cell(0, 8, u'' + presi.position)
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                     วันที่............เดือน..........................พ.ศ............... ')
    pdf.ln(14)

    pdf.cell(0, 10, u'    6. ใบรับเงิน')
    pdf.ln(7)
    pdf.cell(100, 10, u'                 ได้รับเงินสวัสดิการเกี่ยวกับการรักษาพยาบาล จำนวน...........................................................................บาท ')
    pdf.cell(0, 8, u'' + str(value))
    pdf.ln(7)
    pdf.cell(30, 10, u'          (................................................................................................................................................)ไปถูกต้องแล้ว ')
    pdf.cell(0, 8, u'' + valueChar)
    pdf.ln(18)
    pdf.cell(40, 10, u'           วงเงินที่ได้รับ                                                                          (ลงชื่อ)......................................................ผู้รับเงิน')
    pdf.cell(0, 8, u'20,000')
    pdf.ln(7)
    pdf.cell(40, 10, u'           เบิกครั้งก่อน                                                                                 (..........................................................)    ')
    pdf.cell(78, 8, u'9,999')
    pdf.cell(0, 8, u'' + firstname + u'  ' + lastname)
    pdf.ln(7)
    pdf.cell(40, 10, u'           เบิกครั้งนี้ ')
    pdf.cell(0, 8, u'9,999')
    pdf.ln(7)
    pdf.cell(40, 10, u'           คงเหลือ                                                                               (ลงชื่อ)......................................................ผู้จ่ายเงิน ')
    pdf.cell(0, 8, u'9,999')
    pdf.ln(7)
    pdf.cell(0, 10, u'                                                                                                          (..........................................................)')
    pdf.ln(7)
    pdf.cell(0, 10, u'                ....................................ผู้คุมยอดการเบิก                                     วันที่...........เดือน.........................พ.ศ...............')
    pdf.ln(22)
    pdf.cell(0, 10, u'                                                                            คำชี้แจง')
    pdf.ln(10)
    pdf.cell(0, 10, u'              ให้แนบสำเนาคำสั่งศาลที่สั่ง/พิพากษาให้เป็นบุคคลไร้ความสามารถ  หรือเสมือนไร้ความสามารถ ')
    pdf.ln(7)
    pdf.cell(0, 10, u'              ให้มีคำชี้แจงด้วยว่ามีสิทธิเพียงใด และขาดอยู่เท่าใด กรณีที่ได้รับจากหน่วยงานอื่นเมื่อเทียบสิทธิตามพระราชกฤษฎีกาเงินสวัสดิการ')
    pdf.ln(7)
    pdf.cell(0, 10, u'               เกี่ยวกับการรักษาพยาบาลหรือขาดอยู่เท่าใดเมื่อได้รับค่ารักษาพยาบาลตามสัญญาประกันภัย ')
    pdf.ln(7)
    pdf.cell(0, 10, u'              ให้เติมคำว่า คู่สมรส บิดา มารดา หรือบุตรแล้วแต่กรณี')
    pdf.ln(7)
    pdf.cell(0, 10, u'              ให้เสนอต่อผู้มีอำนาจอนุมัติ')
    pdf.ln(7)

    pdf.output("group4/safe.pdf", 'F')

    # next path will open pdf file in new tab on browser.
    with open('group4/safe.pdf', 'rb') as pdf: # path to pdf in directory views.
        response = HttpResponse(pdf.read(),content_type='application/pdf')
        response['Content-Disposition'] = 'filename=safe.pdf'
        return response
    pdf.closed
예제 #11
0
    def get(self, request, *args, **kwargs):
        from fpdf import FPDF

        pdf = FPDF()
        pdf.add_font('DejaVu','','rink/fonts/DejaVuSansCondensed.ttf',uni=True)

        roster = Roster.objects.filter(event__slug=self.event.slug)

        for roster_entry in roster:

            registration_data = roster_entry.registrationdata_set.first()

            pdf.add_page()
            pdf.set_margins(16, 2)
            pdf.ln(20)

            pdf.set_font('DejaVu','',16)
            pdf.cell(40,40,'Derby Name:')
            pdf.set_font('DejaVu','',48)
            pdf.cell(40,40, roster_entry.user.derby_name)
            pdf.ln(20)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(40,40,'Real Name:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(40,40, roster_entry.user.first_name + " " + roster_entry.user.last_name)
            pdf.ln(20)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Date of Birth:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, str(registration_data.emergency_date_of_birth))
            pdf.ln(10)
            
            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Emergency Contact:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, registration_data.emergency_contact)
            pdf.ln(10)
            pdf.cell(60,40,'')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, registration_data.emergency_phone)
            pdf.ln(10)
            pdf.cell(60,40,'')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, registration_data.emergency_relationship)
            pdf.ln(15)
            
            if registration_data.emergency_contact_second:
                pdf.set_font('DejaVu','',16)
                pdf.cell(60,40,'Emergency Contact #2:')
                pdf.set_font('DejaVu','',24)
                pdf.cell(0,40, registration_data.emergency_contact_second)
                pdf.ln(10)
                pdf.cell(60,40,'')
                pdf.set_font('DejaVu','',24)
                pdf.cell(0,40, registration_data.emergency_phone_second)
                pdf.ln(10)
                pdf.cell(60,40,'')
                pdf.set_font('DejaVu','',24)
                pdf.cell(0,40, registration_data.emergency_relationship_second)
                pdf.ln(15)

            pdf.set_font('DejaVu','',16)
            pdf.cell(60,40,'Hosptial Preference:')
            pdf.set_font('DejaVu','',24)
            pdf.cell(0,40, registration_data.emergency_hospital)
            pdf.ln(15)
            
            pdf.set_font('DejaVu','',12)
            pdf.multi_cell(0,40,'Medical Conditions:')
            pdf.ln(-15)
            pdf.set_font('DejaVu','',24)
            if registration_data.emergency_allergies == "":
                details = "<none>"
            else:
                details = registration_data.emergency_allergies
            
            pdf.write(12, details)
            pdf.ln(25)

            wftda = ""
            try:
                wftda = int(registration_data.derby_insurance_number)
            except:
                pass

            pdf.set_font('Courier','',7)
            pdf.write(4, 'RINK #' + str(registration_data.user.id) + " | " + str(registration_data.user.email) + " | WFTDA #" + str(wftda) + " | generated on " + strftime("%Y-%m-%d", gmtime()))

        pdf.output('/tmp/rink_medical.pdf', 'F')

        with open('/tmp/rink_medical.pdf', 'rb') as pdf:
            response = HttpResponse(pdf.read(), content_type='application/pdf')
            response['Content-Disposition'] = 'inline;filename=rink_medical.pdf'

        os.remove('/tmp/rink_medical.pdf')
        return response