From 431795db69fa7766aa4d57626b94a95424f5bd52 Mon Sep 17 00:00:00 2001 From: anandnet Date: Wed, 1 Jan 2020 03:12:04 +0530 Subject: [PATCH] Fee info Popup Added --- src/custom_layouts.py | 39 ++++++++-- src/generate_fee_receipt.py | 6 +- src/gui.kv | 139 ++++++++++++++++++++++++++++++++++-- src/popups.py | 40 +++++++++++ 4 files changed, 211 insertions(+), 13 deletions(-) diff --git a/src/custom_layouts.py b/src/custom_layouts.py index 5ccc4e2..5700285 100644 --- a/src/custom_layouts.py +++ b/src/custom_layouts.py @@ -13,7 +13,7 @@ from database import Database from hoverable import HoverBehavior from custom_widgets import LabelForList, LabelForListStudent -from popups import DeleteWarning, AddDataLayout +from popups import DeleteWarning, AddDataLayout ,FeeInfoPopup import os from kivy.utils import platform @@ -107,8 +107,8 @@ def edit(self, root, icon, app): adl.ids.sem.disabled = True adl.ids.late.text = str(late) - adl.height = 60 * (len(data) - 1) + 230 - adl.ids.multipleDataContainer.height = 60 * (len(data) - 1) + adl.height = 60 * len(data) + 230 + adl.ids.multipleDataContainer.height = 60 * len(data) for c, each in enumerate(data): if c == 0: w = adl.ids.multipleDataContainer.children[0] @@ -141,6 +141,37 @@ def delete(self, app, root, icon): callback=app.root.current_screen.populate_screen, ).open() + def open_feeinfo_popup(self,root,app): + popup=FeeInfoPopup() + popup.reg_no=self.parent.reg_no + popup.app=app + popup.sem=root.sem + popup.ids.semLabel.text="Semester[size=100][b]{}[/b][/size]".format(root.sem) + popup.open() + +class FeeInfoData(BoxLayout): + paid="" + date="" + tid="" + filename="" + def __init__(self,paid,date,tid,filename): + self.paid=paid + self.date=date + self.tid=tid + self.filename=filename + super().__init__() + + def view_doc(self): + from generate_fee_receipt import show_doc + if self.filename!="": + extension = os.path.splitext(self.filename)[1] + print(extension) + if os.path.exists("documents/"+self.tid+extension): + show_doc("documents\\"+self.tid+extension) + else: + Snackbar(text="Error in file showing!",duration=2).show() + + print(type(self.filename)) class AddUserDataLayout(FloatLayout): def manage_icon(self, btn): @@ -279,4 +310,4 @@ def _fbrowser_success(self, layoutins, instance): def show_doc(self): import generate_fee_receipt - generate_fee_receipt.show_pdf(self.doc_path) + generate_fee_receipt.show_doc(self.doc_path) diff --git a/src/generate_fee_receipt.py b/src/generate_fee_receipt.py index f51d2e9..e91e36f 100644 --- a/src/generate_fee_receipt.py +++ b/src/generate_fee_receipt.py @@ -43,7 +43,7 @@ def footer(self): self.cell(0, 10, "Page " + str(self.page_no()) + "/{nb}", 0, 0, "C") -def show_pdf(file_path): +def show_doc(file_path): try: if platform.system() == "Windows": os.startfile(file_path) @@ -141,7 +141,7 @@ def generate_pdf(personalinfo, feeinfo, dir): os.mkdir(dir + "/Students") filepath_and_name = dir + "/Students/" + personalinfo["reg"] + ".pdf" pdf.output(filepath_and_name, "F") - show_pdf(filepath_and_name) + show_doc(filepath_and_name) def generate_batch_fee_pdf(basic_details, students_fee_data, dir): @@ -229,7 +229,7 @@ def generate_batch_fee_pdf(basic_details, students_fee_data, dir): filepath_and_name, "F", ) - show_pdf(filepath_and_name) + show_doc(filepath_and_name) if __name__ == "__main__": diff --git a/src/gui.kv b/src/gui.kv index 163d7c1..569f9fe 100644 --- a/src/gui.kv +++ b/src/gui.kv @@ -216,7 +216,7 @@ LabelForList: id: lbl6 text: root.tid - + #-------remarks item--------# ListItemLayoutProfile: id: item7 @@ -226,7 +226,26 @@ text: root.remarks BoxLayout: - size_hint: 0.06,1 + size_hint: None,1 + width:120 + + HoverLayout: + on_enter: + btn0.text_color= [1,1,1,1] + btn0.md_bg_color= [.5,.5,.5,.5] + on_leave: + btn0.text_color=[.4,.4,.4,1] + btn0.md_bg_color= [.5,.5,.5,0] + + AnchorLayout: + MDIconButton: + id: btn0 + icon: "information-outline" + theme_text_color: "Custom" + md_bg_color:[.5,.5,.5,0] + text_color: [.4,.4,.4,1] + on_release: + root.open_feeinfo_popup(root,app) HoverLayout: on_enter: @@ -668,6 +687,114 @@ : write_tab:False +: + size_hint:.45,.8 + BoxLayout: + orientation:"vertical" + canvas: + Color: + rgba:(0,0,0,1) if app.theme_cls.theme_style=="Dark" else (1,1,1,1) + Rectangle: + pos:self.pos + size:self.size + BoxLayout: + size_hint_y:.3 + canvas: + Color: + rgba:app.theme_cls.primary_color + Rectangle: + pos:self.pos + size:self.size + MDLabel: + id:semLabel + markup:True + font_size:root.width/15 + halign:"center" + color:(1,1,1,1) + ScrollView: + BoxLayout: + orientation:"vertical" + BoxLayout: + padding:0,7,0,0 + size_hint_y:None + height:40 + canvas: + Color: + rgba:app.theme_cls.primary_color + Rectangle: + pos:self.pos + size:self.size + MDLabel: + size_hint_x:.25 + halign:"center" + color:(1,1,1,1) + text:"Payment" + bold:True + MDLabel: + size_hint_x:.25 + halign:"center" + color:1,1,1,1 + text:"Date" + bold:True + MDLabel: + size_hint_x:.5 + halign:"center" + color:1,1,1,1 + text:"Trans. Id" + bold:True + Widget: + size_hint_x:None + width:20 + MDLabel: + size_hint_x:None + width:50 + color:1,1,1,1 + text:"Docs" + bold:True + BoxLayout: + id:paymentData + size_hint_y:None + height:len(self.children)*60 + orientation:"vertical" + Widget: + + AnchorLayout: + size_hint_y:None + padding:0,0,15,15 + height:40 + anchor_x:"right" + MDRaisedButton: + text:"Dismiss" + on_release:root.dismiss() +: + orientation:"vertical" + BoxLayout: + size_hint_y:None + height:60 + + MDLabel: + size_hint_x:.25 + halign:"center" + color:(1,1,1,1)if app.theme_cls.theme_style=="Dark" else(0,0,0,1) + text:root.paid + MDLabel: + size_hint_x:.25 + halign:"center" + color:(1,1,1,1)if app.theme_cls.theme_style=="Dark" else(0,0,0,1) + text:root.date + MDLabel: + size_hint_x:.5 + halign:"center" + color:(1,1,1,1)if app.theme_cls.theme_style=="Dark" else(0,0,0,1) + text:root.tid + MDIconButton: + size_hint_x:None + width:70 + icon:"eye" + disabled: True if root.filename=="" else False + on_release:root.view_doc() + MDSeparator: + : size_hint_x:1 size_hint_y:None @@ -1030,11 +1157,11 @@ ScreenManager: Label: text:"Semester" BoxLayout: - size_hint:.13,1 + size_hint:.12,1 Label: text:"Total Paid" BoxLayout: - size_hint:.13,1 + size_hint:.12,1 Label: text:"Due" BoxLayout: @@ -1050,11 +1177,11 @@ ScreenManager: Label: text:"Last Trans.Id" BoxLayout: - size_hint:.23,1 + size_hint:.22,1 Label: text:"Last Remarks" BoxLayout: - size_hint:.06,1 + size_hint:.09,1 BoxLayout: canvas: diff --git a/src/popups.py b/src/popups.py index d11d148..dda4a91 100644 --- a/src/popups.py +++ b/src/popups.py @@ -4,10 +4,12 @@ from kivy.uix.gridlayout import GridLayout from kivy.uix.anchorlayout import AnchorLayout from kivy.uix.label import Label +from kivy.uix.boxlayout import BoxLayout from kivymd.uix.button import MDRaisedButton from kivymd.uix.picker import MDThemePicker from kivymd.uix.snackbar import Snackbar +from kivymd.uix.label import MDLabel from sqlite3 import Error from time import strftime @@ -48,6 +50,44 @@ def check_all_fields(self): return False return True +class FeeInfoPopup(ModalView, Database): + reg_no=None + sem=None + app=None + def on_open(self): + tableName = "_" + str(self.reg_no) + conn = self.connect_database("fee_main.db") + + data = self.search_from_database(tableName, conn, "sem", self.sem, order_by="sem")[0] + conn.close() + + due,late = data[2],data[3] + + tableName = "_" + str(self.reg_no) + "_" + str(self.sem) + data = self.extractAllData("fee_main.db", tableName, order_by="id") + + from custom_layouts import FeeInfoData + total_paid=0 + for each in data: + total_paid=total_paid+each[1] + l=FeeInfoData(str(each[1]),each[2],each[3],each[4]) + self.ids.paymentData.add_widget(l) + + l=BoxLayout() + l.padding=(0,40,0,0) + color=(1,1,1,1)if self.app.theme_cls.theme_style=="Dark" else(0,0,0,1) + mdl1=MDLabel() + mdl2=MDLabel() + mdl3=MDLabel() + mdl1.text="Total Paid: ₹"+str(total_paid) + mdl2.text="Due: ₹"+str(due) + mdl3.text="Late Fine: ₹"+str(late) + mdl1.halign,mdl2.halign,mdl3.halign="center","center","center" + mdl1.color,mdl2.color,mdl3.color=color,color,color + l.add_widget(mdl1) + l.add_widget(mdl2) + l.add_widget(mdl3) + self.ids.paymentData.add_widget(l) # popups class class LoginPopup(ModalView, Database):