Beispiel #1
0
    def commited_table(self, data):
        # data = "no_ifca"
        # sql = "SELECT * FROM onprogress WHERE no_ifca LIKE %s"
        sql = "SELECT date_update,commit_update,auth_by,auth_dept \
                FROM onprogress WHERE no_ifca LIKE %s ORDER BY date_update ASC"

        val = ("%{}%".format(data), )
        results = getdata_all(sql, val)
        self.tabelcomm.delete(
            *self.tabelcomm.get_children())  #refresh, hapus dulu tabel lama
        for kolom in kolomCommIfca:
            self.tabelcomm.heading(kolom, text=kolom)
        # self.tabelcomm.column("No", width=10,anchor="w")
        self.tabelcomm.column("TANGGAL", width=110, anchor="w")
        self.tabelcomm.column("UPDATE", width=500, anchor="w")
        self.tabelcomm.column("OLEH", width=120, anchor="w")
        self.tabelcomm.column("DEPT", width=70, anchor="w")

        i = 0
        for dat in results:
            if (i % 2):
                baris = "genap"
            else:
                baris = "ganjil"
            self.tabelcomm.insert('', 'end', values=dat, tags=baris)
            i += 1
        self.tabelcomm.tag_configure("ganjil", background="gainsboro")
        self.tabelcomm.tag_configure("genap", background="floral white")
Beispiel #2
0
    def progress_table(self, opsi):
        '''
        opsi = <status WO>
        '''
        # sql = "SELECT * FROM logbook WHERE status_ifca LIKE %s"
        # sql = "SELECT no_wo, no_ifca, unit FROM logbook WHERE status_ifca LIKE %s OR status_ifca LIKE %s OR status_ifca LIKE %s"
        sql = "SELECT no_wo, no_ifca, unit FROM logbook WHERE status_ifca LIKE %s ORDER BY no_ifca DESC"
        val = ("%{}%".format(opsi), )
        results = getdata_all(sql, val)
        self.tabelProg.delete(
            *self.tabelProg.get_children())  #refresh, hapus dulu tabel lama
        for kolom in kolomProgIfca:
            self.tabelProg.heading(kolom, text=kolom)
        # self.tabelProg.column("No", width=10,anchor="w")
        self.tabelProg.column("WO", width=50, anchor="w")
        self.tabelProg.column("IFCA", width=80, anchor="w")
        self.tabelProg.column("UNIT", width=80, anchor="w")

        i = 0
        for dat in results:
            if (i % 2):
                baris = "genap"
            else:
                baris = "ganjil"
            #tampilkan hanya wo ifca unit
            # self.tabelProg.insert('', 'end', values=dat[1]+" "+dat[2]+" "+dat[4], tags=baris)
            self.tabelProg.insert('', 'end', values=dat, tags=baris)
            i += 1
        self.tabelProg.tag_configure("ganjil", background="gainsboro")
        self.tabelProg.tag_configure("genap", background="floral white")
Beispiel #3
0
    def refresh(self):
        self.entryset("clear")
        # sql = "SELECT * FROM acct"
        sql = "SELECT `uid`,`username`,`dept`,`date_create`,`activated`,`lock`,\
            `date_lock`,`last_login`,`last_host`,`last_ip`,`last_logout`,`email` FROM `acct`"

        val = ()
        results = getdata_all(sql, val)
        self.tabelUser.delete(
            *self.tabelUser.get_children())  #refresh, hapus dulu tabel lama
        for kolom in kolomUser:
            self.tabelUser.heading(kolom, text=kolom)
        self.tabelUser.column("UID", width=30, anchor="w")
        self.tabelUser.column("Username", width=100, anchor="w")
        self.tabelUser.column("Class", width=50, anchor="w")
        self.tabelUser.column("Date Created", width=120, anchor="w")
        self.tabelUser.column("Activated", width=30, anchor="w")
        self.tabelUser.column("Locked", width=30, anchor="w")
        self.tabelUser.column("Date Locked", width=120, anchor="w")
        self.tabelUser.column("Last Login", width=120, anchor="w")
        self.tabelUser.column("Last Host", width=80, anchor="w")
        self.tabelUser.column("Last IP", width=80, anchor="w")
        self.tabelUser.column("Last Logout", width=80, anchor="w")
        self.tabelUser.column("Email", width=80, anchor="w")

        i = u = 0
        for dat in results:
            if (i % 2):
                baris = "genap"
            else:
                baris = "ganjil"
            # checking temporary user for delete them
            # dat[0] = uid, dat[3] = date_create, dat[4] = activated -lihat sql = ...
            datetodrop = GetSeconds(
                str(dat[3])
            ).value + 604800  # 86400*7 (7 hari). Lebih baik buat custom
            if (dat[4] != True and (datetodrop - time.time()) <= 0
                    and RemoveAcct(dat[0]).result == True):
                # messagebox.showwarning(title="Account Info",message="Account Deleted successfully")
                u += 1
            else:  # tampilkan user yang tidak di delete pada tabel
                self.tabelUser.insert('', 'end', values=dat, tags=baris)
            i += 1
        self.tabelUser.tag_configure("ganjil", background="gainsboro")
        self.tabelUser.tag_configure("genap", background="floral white")
        if u > 0:  # berikan info jika ada username yang berhasil dihapus
            messagebox.showwarning(
                title="Account Info",
                message="Ditemukan {} Account telah berhasil dihapus.".format(
                    u))
Beispiel #4
0
 def auto_ifca(self):
     tipe = str(self.btnselect.get())
     sql = "SELECT MAX(no_ifca) FROM logbook WHERE no_ifca LIKE %s"
     val = ("%{}%".format(tipe), )
     hasil = getdata_all(sql, val)  # max IFCA dalam tupple
     lastifca = hasil[len(hasil) - 1][0]  # Max num ifca terakhir
     print("Last IFca:", lastifca)
     if lastifca == None:  # prevent error jika belum ada data
         lastifca = "XX10000000"
     newIfcaNum = (int(lastifca[2:]) + 1
                   )  # cari lastifca, hapus tipe(BM/TN) + 1
     getNewIfca = tipe + str(newIfcaNum)  # Ifca baru siap dipakai
     print("Get new ifca:", getNewIfca)
     self.entIfca.delete(0, END)
     self.entIfca.insert(0, getNewIfca)
Beispiel #5
0
 def auto_wo(self):
     sql = "SELECT no_wo FROM logbook"
     val = ()
     hasil = getdata_all(sql, val)  # list wo dalam tupple
     if len(hasil) <= 0:  # prevent error jika belum ada data
         hasil = "0"
     lastwo = hasil[len(hasil) - 1][
         0]  # ambil last wo dari tupple terakhir dan ambil datanya
     print("last Wo:", lastwo)
     print("Jumlah Wo:", len(hasil))  # Jumlah wo didapat
     if lastwo == "":
         newWoNum = ""  # prevent error, ketika IFCA terakhir tanpa no. WO (blank)
     else:
         newWoNum = (int(lastwo) + 1)  # cari wo, + 1
     print("Get new Wo:", newWoNum)
     self.entWo.delete(0, END)
     if len(str(newWoNum)) <= 6:
         self.entWo.insert(0, newWoNum)
         self.entIfca.focus_set()
     else:
         messagebox.showwarning(title="Peringatan", \
                 message="maaf lebar data untuk no WO hanya sampai 6 digit")
Beispiel #6
0
 def onSearch(self, event=None):
     self.entrySet("mainclear")
     self.opsiStatus.current(0)
     self.querySearch()  # set dulu variabel self.sql dan self.val
     results = getdata_all(self.sql, self.val)
     self.showtable(results)