Skip to content

Commit

Permalink
Merge pull request #34 from anandnet/master
Browse files Browse the repository at this point in the history
Fee info Popup Added
  • Loading branch information
anandnet authored Dec 31, 2019
2 parents 0335f28 + 431795d commit e2f6423
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 11 deletions.
35 changes: 33 additions & 2 deletions src/custom_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions src/generate_fee_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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__":
Expand Down
139 changes: 133 additions & 6 deletions src/gui.kv
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
LabelForList:
id: lbl6
text: root.tid

#-------remarks item--------#
ListItemLayoutProfile:
id: item7
Expand All @@ -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:
Expand Down Expand Up @@ -668,6 +687,114 @@
<InputFields@MDTextField>:
write_tab:False

<FeeInfoPopup>:
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()
<FeeInfoData>:
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:

<AddDataLayout>:
size_hint_x:1
size_hint_y:None
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
40 changes: 40 additions & 0 deletions src/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e2f6423

Please # to comment.