def krs_to_transkrip(data):
    try:
        data = data.split('|')
        tahun_id = find_tahun_id_from_message(message.normalize(data[3]))
        if tahun_id:
            tahun_id = tahun_id[0]
            data_npm_begin_and_npm_end = split_and_get_npm(
                message.normalize(data[3]))
            if data_npm_begin_and_npm_end:
                npm_begin, npm_end = data_npm_begin_and_npm_end
                data_mhsw_id_distinct = get_npm_distinct(
                    npm_range_begin=npm_begin,
                    npm_range_end=npm_end,
                    tahunid=tahun_id)

                data_check = [
                    data_check_krs_to_transkrip(data_mahasiswa_krs)
                    for mshw in data_mhsw_id_distinct
                    for data_mahasiswa_krs in data_student_krs(
                        mshw["MhswID"], tahun_id)
                ]

                msg_data_insert = f'Data perpindahan dari KRS to TRANSKRIP:{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}'
                for data_check_loop in data_check:
                    if data_check_loop['status']:
                        msg_data_insert += f'{data_check_loop["mhswid"]} | {data_check_loop["mkkode"]}{config.whatsapp_api_lineBreak}'

                return wa.setOutbox(numbers.normalize(data[0]),
                                    msg_data_insert)
            return wa.setOutbox(numbers.normalize(data[0]),
                                'kata sampai tidak ada')
        return wa.setOutbox(numbers.normalize(data[0]), 'tidak ada tahun id')
    except Exception as e:
        return wa.setOutbox(numbers.normalize(data[0]), f'ERROR: {e}')
Beispiel #2
0
def run(num):
    link = {}
    dmy = datetime.now().strftime("%d-%m-%Y")
    hms = datetime.now().strftime("%H:%M:%S")
    prodiidandsingkatan = getProdiIDAndSingkatan()
    for prodiID, singkatan in prodiidandsingkatan:
        mkkodelist = []
        for i in getJadwalIDFullApproval(prodiID):
            mkkode = getMkKodeFromJadwalID(i[0])
            if mkkode not in mkkodelist:
                mkkodelist.append(mkkode)
            else:
                continue
        foldername = 'bkd'
        pathperprodi = []
        for i in mkkodelist:
            abc = bkd.getFilePath(
                i, foldername,
                str(int(kelas.getTahunID()) - 1)
                if kelas.getTahunID()[-1] == '3' else kelas.getTahunID())
            for i in abc:
                pathperprodi.append(i)
        with ZipFile(f'{singkatan}.zip', 'w') as zip:
            for file in pathperprodi:
                try:
                    zip.write(file)
                except:
                    print(f'file: {file}, ngga ada')
                    continue
        gauth = GoogleAuth()
        gauth.LoadCredentialsFile("mycreds.txt")
        if gauth.credentials is None:
            gauth.LocalWebserverAuth()
        elif gauth.access_token_expired:
            gauth.Refresh()
        else:
            gauth.Authorize()
        gauth.SaveCredentialsFile("mycreds.txt")
        drive = GoogleDrive(gauth)
        file1 = drive.CreateFile({'title': f'{singkatan} {dmy} {hms}.zip'})
        file1.SetContentFile(f'{os.getcwd()}\\{singkatan}.zip')
        file1.Upload()
        file1.InsertPermission({
            'type': 'anyone',
            'value': 'anyone',
            'role': 'reader'
        })
        link[f'{singkatan}'] = file1['alternateLink']
    msgreply = f'ini yaaa link berdasarkan prodinyaa....{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}'
    for data in link.items():
        msgreply += f'{data[0]}: {data[1]}{config.whatsapp_api_lineBreak}'
    wa.setOutbox(num, msgreply)
Beispiel #3
0
def run(data):
    num = data.split(';')[0]
    msg = data.split(';')[1]
    if isKaprodi(getNIPYfromHandphone(num)):
        status = 'kaprodi'
    else:
        status = 'deputi'
    if status == 'kaprodi':
        msgreply = infoBAPKaprodi(
            f'.{kelas.getAllDataDosens(kelas.getKodeDosen(num))[20]}.')
    else:
        msgreply = infoBAPDeputi(msg)
    wa.setOutbox(numbers.normalize(num), msgreply[0])
def replymsg(driver, data):
    msgs=data[3].split(' ')
    npm=''
    for i in msgs:
        if cekIsNpmExist(i):
            npm=i
    if npm == '':
        msgreply='NPM tidak ada/Invalid'
    else:
        if 'catatan' in data[3]:
            sisa_biaya = data[3].split(' sisa pembayaran ')[1].split(' catatan ')[0].replace('.', '')
        else:
            sisa_biaya = data[3].split(' sisa pembayaran ')[1].replace('.', '')
        tipesemester = validTahunID()[-1]
        prodiid = f'{npm[0]}{npm[3]}'
        if app.cekSudahAdaKHS(npm, validTahunID(), 'A'):
            app.updateBiayaKHS(npm, validTahunID(), sisa_biaya)
            msgreply = f'Mahasiswa dengan,\n\nNPM: {npm}\nNama: {kelas.getStudentNameOnly(npm)}\nProdi: {getProdiName(prodiid)}\n\nSudah bisa ambil KRS'
            if cekSudahApprove(npm, validTahunID()):
                data_verif=cekSudahApprove(npm, validTahunID())
                msgreply+=f' dan Sudah diverifikasi oleh,\n\nNama: *{kelas.getNamaDosen(data_verif[2])}*\nTanggal/Waktu: {data_verif[3]}'
        else:
            data_log={}
            data_log['npm']=npm
            data_log['dosen_id']=kelas.getKodeDosen(data[0])
            data_log['session_approval']=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            data_log['sisa_pembayaran']=sisa_biaya
            data_log['tahun_id']=validTahunID()
            if 'catatan' in data[3]:
                catatan=data[3].split(' catatan ')[1]
            else:
                catatan='-'
            insertLogApproval(data_log)
            app.insertnewKHS(npm, validTahunID(), prodiid, app.cekSesiSemester(tipesemester, npm), sisa_biaya)
            wa.setOutbox(kelas.getStudentPhoneNumberFromNPM(npm), f'hai haiiiiii kamu dengan,{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}NPM: {npm}{config.whatsapp_api_lineBreak}Nama: {kelas.getStudentNameOnly(npm)}{config.whatsapp_api_lineBreak}Sisa Pembayaran: {app.floatToRupiah(float(sisa_biaya))}{config.whatsapp_api_lineBreak}Catatan: {catatan}{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}Sudah diverifikasi ya data pembayaran VA kamu oleh,{config.whatsapp_api_lineBreak}Nama: *{kelas.getNamaDosen(kelas.getKodeDosen(data[0]))}*')
            msgreply=f'Sudah {config.bot_name} approve yaaa va dengan data berikut:\n\nNPM: {npm}\nNama: {kelas.getStudentNameOnly(npm)}\nProdi: {getProdiName(prodiid)}\nSisa Pembayaran: {app.floatToRupiah(float(sisa_biaya))}\nCatatan: {catatan}\n\nAkan {config.bot_name} langsung informasikan ke mahasiswanya langsung yaaa'
    return msgreply
Beispiel #5
0
def makePDFandSend(num):
    checkDir()
    lecturercode = kelas.getKodeDosen(num)
    lecturername = kelas.getNamaDosen(lecturercode)
    dosenHomeBase = getDosenHomebase(num)
    checkDirQrcode()
    # generate dosen barcode
    link = makeLinkVerifiy(lecturercode)
    makeQrcodeLinkVerifySign(link, 'dosen', lecturercode)

    # generate kaprodi barcode
    kaprodinipycode = getNipyKaProdi(dosenHomeBase)
    kaprodiDosenID = getDosenIDfromNIPY(kaprodinipycode)
    link = makeLinkVerifiy(kaprodiDosenID)
    makeQrcodeLinkVerifySign(link, 'kaprodi', lecturercode)

    # generate deputi barcode
    deputinipycode = getNipyDeputi(9)
    deputiDosenID = getDosenIDfromNIPY(deputinipycode)
    link = makeLinkVerifiy(deputiDosenID)
    makeQrcodeLinkVerifySign(link, 'deputi', lecturercode)

    pertemuankurang = []

    mkkodes = getMkKode(lecturercode)
    for mkkode in mkkodes:
        jadwalids = getJadwalID(mkkode[0], lecturercode)
        try:
            pdf = makePDFHeader()
            for jadwalid in jadwalids:
                print(jadwalid)
                matkuldetailsfix = kelas.getMkDetails(jadwalid[0])
                if getRencanaKehadiran(jadwalid[0]) == 0:
                    print('rencana kehadiran 0')
                elif getProgramID(jadwalid[0]) == '.KER.' and getKehadiran(
                        jadwalid[0]) < getRencanaKehadiran(jadwalid[0]):
                    print(
                        'program kerja sama dan jumlah kehadiran kurang dari rencana kehadiran'
                    )
                else:
                    matkuldetails = kelas.getMkDetails(jadwalid[0])
                    datamatkulbap = getBKDMatkul(jadwalid[0])
                    semester = countSemester(jadwalid[0])
                    sks = getSks(jadwalid[0])
                    nama_kelas = kelas.toKelas(matkuldetails[6])
                    kode_matkul = matkuldetails[1]
                    nama_matkul = matkuldetails[2]
                    datenow = datetime.date(
                        datetime.now()).strftime('%d-%m-%Y')
                    tanggalbap = datenow.split('-')[0]
                    bulanbap = datenow.split('-')[1]
                    tahunbap = datenow.split('-')[2]
                    kode_nomor = f'ITeung/{tanggalbap}/{bulanbap}/{tahunbap}'
                    tanggalpdfbap = f'{tanggalbap} {bulanSwitcher(bulanbap)} {tahunbap}'
                    datafixbap = []
                    datawkwkbap = [
                        'Pertemuan', 'Tanggal', 'Materi Perkuliahan',
                        'Jam Mulai', 'Jam Selesai'
                    ]
                    datafixbap.append(datawkwkbap)
                    for i in datamatkulbap:
                        matkuldatalist = []
                        matkuldatalist.append(i[0])
                        matkuldatalist.append(i[1].strftime('%d-%m-%Y'))
                        matkuldatalist.append(i[2])
                        matkuldatalist.append(str(i[3]))
                        matkuldatalist.append(str(i[4]))
                        datafixbap.append(matkuldatalist)
                    makePDFBAP(pdf, datafixbap, kode_nomor, tanggalpdfbap,
                               kode_matkul, nama_matkul, nama_kelas, semester,
                               sks)
                    studentid, studentname = getandsetStudentIDandStudentNAME(
                        jadwalid[0])
                    presensidosens1 = getPresensiDosen(jadwalid[0], 0, 8)
                    presensidosens2 = getPresensiDosen(jadwalid[0], 7, 15)
                    for i in range(2):
                        if i == 0:
                            pertemuan = countPertemuan(presensidosens1)
                            pdfpertemuan = ['1', '2', '3', '4', '5', '6', '7']
                        else:
                            pertemuan = countPertemuan(presensidosens2)
                            pdfpertemuan = [
                                '8', '9', '10', '11', '12', '13', '14'
                            ]
                        datas = list(
                            zip(pertemuan[0], pertemuan[1], pertemuan[2],
                                pertemuan[3], pertemuan[4], pertemuan[5],
                                pertemuan[6]))
                        total = countTotal(datas)
                        datas = list(
                            zip(studentid, studentname, pertemuan[0],
                                pertemuan[1], pertemuan[2], pertemuan[3],
                                pertemuan[4], pertemuan[5], pertemuan[6]))
                        number = countNumber(studentid)
                        datapdf = list(
                            zip(number, studentid, studentname, pertemuan[0],
                                pertemuan[1], pertemuan[2], pertemuan[3],
                                pertemuan[4], pertemuan[5], pertemuan[6],
                                total))
                        tanggal = tanggalBKDPresensi(
                            getTanggalFromPresensiDosen(jadwalid[0]))
                        datapdf.append(tanggal)
                        statusapprove = cekStatusApproveBAP(jadwalid[0])
                        makePDFInner(datapdf, matkuldetails, lecturername, pdf,
                                     pdfpertemuan, lecturercode, statusapprove)
                        matkuldetailsfix = matkuldetails
            makePDFFooter(matkuldetailsfix, lecturercode, pdf)
        except Exception as e:
            print(str(e))
            print(f'pertemuan kurang dari {config.kehadiran}')
            pertemuankurang.append(jadwalid[0])
    cekkurangmateri = cekKurangMateri(cekMateriByGrouping(lecturercode))
    cekkurangapproval = cekKurangApproval(
        cekApprovalBAPByGrouping(lecturercode))
    if len(pertemuankurang) > 0 or cekkurangmateri[
            0] == False or cekkurangapproval[0] == False:
        msgkurang = ''
        if len(pertemuankurang) > 0:
            msgkurang += f'hai haiii, kamu yang request BAP yaaa?{config.whatsapp_api_lineBreak}wahhh ada yang kurang nih pertemuannya ini Jadwal ID nya yaaa:'
            for i in pertemuankurang:
                kelasdetails = kelas.getMkDetails(i)
                msgkurang += f'{config.whatsapp_api_lineBreak}{i} | {kelasdetails[2]} | {kelas.toKelas(kelasdetails[-1])}'
        if cekkurangmateri[0] == False:
            kurangmateri = ''
            for i in cekkurangmateri[1]:
                kelasdetails = kelas.getMkDetails(i[0])
                kurangmateri += f'{config.whatsapp_api_lineBreak}{i[0]} | {kelasdetails[2]} | {kelas.toKelas(kelasdetails[-1])}'
            msgkurang += f'{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}aduhhhh ternyata ada yang kurang nih ketika kamu request BAP, matkul dengan Jadwal ID:{kurangmateri}{config.whatsapp_api_lineBreak}materinya kurang nihhhhh, tolong lengkapi lagiii yaaa caranya ketik ini *iteung panduan dosen kelas online* dan baca panduan nomor 13 dan 14'
        if cekkurangapproval[0] == False:
            kurangapprove = ''
            for i in cekkurangapproval[1]:
                siapayangkurang = ''
                kelasdetails = kelas.getMkDetails(i[0])
                if i[1] == False:
                    siapayangkurang += ' | KAPRODI'
                if i[2] == False:
                    siapayangkurang += ' | DEPUTI AKADEMIK'
                kurangapprove += f'{config.whatsapp_api_lineBreak}{i[0]} | {kelasdetails[2]} | {kelas.toKelas(kelasdetails[-1])} {siapayangkurang}'
            msgkurang += f'{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}wuowwww ada yang kurang nih ketika kamu request BAP, status approval nya masih belum di ACC nih dengan Jadwal ID:{kurangapprove}{config.whatsapp_api_lineBreak}'
        wa.setOutbox(numbers.normalize(num), msgkurang)
    else:
        mail(
            getLecturerMail(lecturercode),
            f'Halooooo, {config.bot_name} ngirim file nich....',
            f'ini ya file Absensi BKD yang Bapak/Ibu minta silahkan di cek... ehee....',
            getFilePath(getLecturerMail(lecturercode), 'bkd'))
def callback_api_va(token):
    try:
        datenow = datetime.date(datetime.now()).strftime('%d-%m-%Y')
        yearnow=datetime.date(datetime.now()).strftime('%Y')
        req=request.json
        trxid=req['trx_id']
        npm=cekNpmInTrxID(trxid)
        tipesemester=cekTipeSemester(trxid)
        tahunid=f'{yearnow}{tipesemester}'
        prodiid=f'{npm[0]}{npm[3]}'
        virtual_account=req['virtual_account']
        customer_name=req['customer_name']
        trx_amount=req['trx_amount']
        payment_amount=req['payment_amount']
        cumulative_payment_amount=req['cumulative_payment_amount']
        payment_ntb=req['payment_ntb']
        datetime_payment=req['datetime_payment']
        datetime_payment_iso8601=req['datetime_payment_iso8601']
        resultpasscode, status = decryptToken(config.key_va, config.iv_va, token)
        if 'SPP' in trxid.split('-'):
            if status:
                passcodetrxid=resultpasscode.split(';')[0].replace('\n', '').replace(' ', '')
                passcodevirtualaccount=resultpasscode.split(';')[1].replace('\n', '').replace(' ', '')
                passcodedatetime=resultpasscode.split(';')[2].replace('\n', '').replace(' ', '')
                if passcodetrxid == trxid and passcodevirtualaccount == virtual_account and passcodedatetime == datenow:
                    message = f'Hai haiiiii kamu sudah transfer pembayaran semester yaaaa dengan{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}*NPM: {npm}*{config.whatsapp_api_lineBreak}*Nama: {customer_name}*{config.whatsapp_api_lineBreak}*Virtual Account: {virtual_account}*{config.whatsapp_api_lineBreak}*Tanggal: {datetime_payment}*{config.whatsapp_api_lineBreak}*Jumlah Transfer: {floatToRupiah(payment_amount)}*{config.whatsapp_api_lineBreak}*Total Sudah Bayar: {floatToRupiah(cumulative_payment_amount)}*{config.whatsapp_api_lineBreak}*Total Harus Bayar: {floatToRupiah(trx_amount)}*'
                    ws = openfile().active
                    prodi_singkatan = getProdiSingkatanFromProdiID(kelas.getProdiIDwithStudentID(npm)).lower()
                    tingkat = f"tk{int(datetime.now().strftime('%Y')) - int(kelas.getTahunAngkatanWithStudentID(npm)) + 1}"
                    angkatan = kelas.getTahunAngkatanWithStudentID(npm)
                    key = f'{prodi_singkatan}{tingkat}{angkatan}'
                    default_amount_payment = getDataDefault(key, ws)
                    if int(trx_amount) > int(default_amount_payment):
                        amount_tunggakan = int(trx_amount) - int(default_amount_payment)
                        fifty_percent_default_payment = int(default_amount_payment) / 2
                        minimum_payment = int(amount_tunggakan) + int(fifty_percent_default_payment)
                    else:
                        minimum_payment = int(trx_amount) / 2
                    openfile().close()
                    if float(cumulative_payment_amount) >= float(minimum_payment):
                        if cekSudahAdaKHS(npm, tahunid, 'A'):
                            updateBiayaKHS(npm, tahunid, trx_amount-cumulative_payment_amount)
                            message += f'{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}terima kasih yaaa sudah bayar semester, semangat kuliahnya kakaaaa......'
                        else:
                            message += f'{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}Kamu *sudah bisa* isi KRS yaaa coba cek di *SIAP* yaaa...., #BOTNAME# ucapkan terima kasihhhh dan jangan salah saat isi KRS yaaa....'
                            message = message.replace('#BOTNAME#', config.bot_name)
                            insertnewKHS(npm, tahunid, prodiid, cekSesiSemester(tipesemester, npm), trx_amount-cumulative_payment_amount)
                        wa.setOutbox(kelas.getHandphoneMahasiswa(npm), message)
                        return make_response(jsonify(
                            {
                                "message": "success",
                                "status": "krs otomatis"
                            }
                        ), 200)
                    else:
                        message+=f'{config.whatsapp_api_lineBreak}{config.whatsapp_api_lineBreak}Yahhhh kamu *belum bisa* isi KRS nihhhh coba *buat surat* lalu *ajukan ke pihak BAUK* agar kamu bisa isi KRS..... Suratnya udah {config.bot_name} kirim ke *{kelas.getStudentEmail(npm)}*'
                        wa.setOutbox(kelas.getHandphoneMahasiswa(npm), message)
                        tes=surat_va.makePdfAndSendToEmail(npm)
                        return make_response(jsonify(
                            {
                                "message": "success",
                                "status": "kirim whatsapp bikin surat"
                            }
                        ), 200)
                else:
                    return make_response(jsonify({'message': 'bad token'}), 401)
            else:
                return make_response(jsonify({'message': 'bad token'}), 401)
        else:
            return make_response(jsonify({'message': 'not spp'}), 200)
    except Exception as e:
        return {
            "code": 404,
            "message": f"ERROR={e}"
        }