def load_group_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.ids['allorgscroll'].clear_widgets() #To clear list of orgs query = f'''SELECT ORG_ID,NAME,REGISTRATION FROM ORG WHERE ORG_ID IN ( SELECT ORG_ID FROM ORG MINUS SELECT ORG_ID FROM CONTACT_ORG WHERE CONTACT_ID = {globalvariables.var_userid} AND STATUS='Y')''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) orglist = ibm_db.fetch_both(stmt) item = TwoLineAvatarListItem() while (orglist): file_found = download_org_image(str(orglist[0])) if file_found == True: image = ImageLeftWidget(source="resources/org/" + str(orglist[0]) + ".png") else: image = ImageLeftWidget(source="resources/org/default.jpg") item = TwoLineAvatarListItem(text=str(orglist[1]), secondary_text=str(orglist[2])) item.add_widget(image) item.bind(on_release=self.row_press) self.ids['allorgscroll'].add_widget(item) orglist = ibm_db.fetch_both( stmt) #for incrementing rows inside while loop
def load_page(self, greg): ContentNavigationDrawer.populateNavDrawerValues(self) query = "SELECT ORG_ID,NAME,REGISTRATION,DESC FROM ORG WHERE REGISTRATION='" + greg + "'" # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) userrow = ibm_db.fetch_tuple(stmt) org_id = "" org_name = "" org_reg = "" org_desc = "" if userrow != False: org_id = userrow[0] org_name = userrow[1] org_reg = userrow[2] org_desc = userrow[3] globalvariables.var_org_id = org_id self.ids['gname'].text = org_name self.ids['greg'].text = org_reg self.ids['gdesc'].text = org_desc #USED TO POPULATE DROP DOWN OF ACTIVITY FOR PAYMENTS FOR NON JOINERS query = "SELECT ACTIVITY_ID,NAME FROM ACTIVITY WHERE ORG_ID=" + str( globalvariables.var_org_id) stmt = ibm_db.exec_immediate(connection.conn, query) act = ibm_db.fetch_both(stmt) actlist = [] while (act): actlist.append(str(act[1])) act = ibm_db.fetch_both(stmt) self.menu = MDDropdownMenu(caller=self.ids['activity_item'], position="center", width_mult=5, callback=self.set_item) for i in actlist: self.menu.items.append({"text": str(i)})
def load_settings_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) query = f'''SELECT CONTACT_ID, EMAIL FROM CONTACT WHERE CONTACT_ID={globalvariables.var_userid} ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) contact = ibm_db.fetch_both(stmt) print(globalvariables.var_email) self.ids['uname'].text = globalvariables.var_email
def create_org(self, groupname, regnum, desc): ContentNavigationDrawer.populateNavDrawerValues(self) groupname = groupname.text regnum = regnum.text desc = desc.text valid_str = "" if groupname == "": valid_str = "Name is blank" elif regnum == "": valid_str = "Registration is blank" elif desc == "": valid_str = "Description is blank" if valid_str != "": ok_button = MDFlatButton(text='OK', on_release=self.dialog_close) self.dialog = MDDialog(title='Alert !', text=valid_str, size_hint=(0.7, 1), buttons=[ok_button]) self.dialog.open() else: status = "Y" query1 = f'''INSERT INTO ORG(NAME, REGISTRATION, DESC, OWNER_ID, STATUS) VALUES (UPPER('{groupname}'),UPPER('{regnum}'),'{desc}',{globalvariables.var_userid}, '{status}')''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query1) if ibm_db.num_rows(stmt) > 0: query2 = f'''SELECT ORG_ID FROM ORG WHERE REGISTRATION=UPPER('{regnum}') ''' stmt = ibm_db.exec_immediate(connection.conn, query2) orglist = ibm_db.fetch_both(stmt) orgid = "" while (orglist): orgid = orglist[0] query3 = f'''INSERT INTO CONTACT_ORG(ORG_ID, CONTACT_ID, MEMBER_FLAG, STATUS) VALUES ({orgid},{globalvariables.var_userid},'Y', '{status}')''' stmt1 = ibm_db.exec_immediate(connection.conn, query3) orglist = ibm_db.fetch_both(stmt) self.ids[ 'groupname'].text = "" #Setting the values to NULL after sucessfull registration self.ids['regnum'].text = "" self.ids['desc'].text = "" #To upload Org Logo if globalvariables.var_img_path != "": logo_path = globalvariables.var_img_path tgt_logo_path = "org_" + str(orgid) + ".png" upload_org_logo(logo_path, tgt_logo_path) globalvariables.var_img_path = "" ok_button = MDFlatButton(text='OK', on_release=self.dialog_close) self.dialog = MDDialog(title='Successfully Registered', text="Lets start helping!", size_hint=(0.7, 1), buttons=[ok_button]) self.dialog.open() self.manager.transition.direction = 'left' self.manager.current = 'home_window' self.manager.get_screen('home_window').load_home_page()
def load_nav_drawer(self): ContentNavigationDrawer.populateNavDrawerValues(self) #Load menu items disaster_list = get_disasters() self.menu = MDDropdownMenu(caller=self.ids['drop_item'], position="center", width_mult=5, callback=self.set_item) for i in disaster_list: self.menu.items.append({"text": str(i)})
def load_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.rsrcmenu = MDDropdownMenu(caller=self.ids['name'], width_mult=5, callback=self.set_item, position="center") items = [ "Medicine", "Biscuit", "Salt", "Tarpaulin", "Rice", "Daal", "Baby Food", "Sugar" ] for i in items: self.rsrcmenu.items.append({"text": str(i)})
def load_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) actual_amount = 0 spent_amount = 0 print(type(actual_amount)) print(globalvariables.var_org_id) print(globalvariables.var_act_name) query = f'''SELECT ACTIVITY_ID,NAME,LOCATION,DISASTER,TARGET_AMT FROM ACTIVITY WHERE NAME='{globalvariables.var_act_name}' AND ORG_ID = {globalvariables.var_org_id} AND STATUS='Y' ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) userrow = ibm_db.fetch_tuple(stmt) act_id = "" act_name = "" act_loc = "" act_dis = "" act_target = "" if userrow != False: act_id = userrow[0] act_name = userrow[1] act_loc = userrow[2] act_dis = userrow[3] act_target = userrow[4] globalvariables.var_act_id = act_id globalvariables.var_act_name = act_name self.ids['actname'].text = act_name self.ids['location'].text = act_loc self.ids['actdis'].text = act_dis self.ids['acttarget'].text = str(act_target) query = f'''SELECT SUM(AMOUNT) FROM TRANSACTION WHERE ACTIVITY_ID= {globalvariables.var_act_id}''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) userrow = ibm_db.fetch_tuple(stmt) if userrow != None: if userrow[0] != None: self.ids['actactual'].text = str(userrow[0]) actual_amount = userrow[0] else: self.ids['actactual'].text = "0" query = f'''SELECT SUM(AMOUNT) FROM RESOURCES WHERE ACTIVITY_ID= {globalvariables.var_act_id}''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) userrow = ibm_db.fetch_tuple(stmt) if userrow != None: if userrow[0] != None: self.ids['amountspent'].text = str(userrow[0]) spent_amount = userrow[0] else: self.ids['amountspent'].text = "0" globalvariables.var_bal_amt = actual_amount - spent_amount
def update_settings(self, uname, pwd1, pwd2): email = uname.text pwd1 = pwd1.text pwd2 = pwd2.text regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$' valid_str = "" if globalvariables.var_email != email: if email == "": valid_str = "Email is blank" if re.search(regex, email) is None: valid_str = "Email is not valid" if pwd1 != None: if pwd1 != pwd2: valid_str = "Passwords not matching" if valid_str != "": ok_button = MDFlatButton(text='OK', on_release=self.dialog_close) self.dialog = MDDialog(title='Alert !', text=valid_str, size_hint=(0.7, 1), buttons=[ok_button]) self.dialog.open() else: if globalvariables.var_email != email: query = f'''UPDATE CONTACT SET EMAIL='{email}' WHERE CONTACT_ID={globalvariables.var_userid} ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) email_change_mail(globalvariables.var_email, globalvariables.var_fname) globalvariables.var_email = email self.ids['uname'].text = globalvariables.var_email if pwd1 != "": encrypted_pwd = encrypt_pwd(pwd1) query = f'''UPDATE CONTACT SET PASSCODE={repr(encrypted_pwd)} WHERE CONTACT_ID={globalvariables.var_userid} ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) password_change_mail(globalvariables.var_email, globalvariables.var_fname) self.ids['pwd1'].text = "" self.ids['pwd2'].text = "" if globalvariables.var_img_path != "": img_path = globalvariables.var_img_path img_tgt_name = str(globalvariables.var_userid) + ".png" upload_contact_image(img_path, img_tgt_name) globalvariables.var_img_path = "" ContentNavigationDrawer.populateNavDrawerValues(self) self.snackbar = Snackbar(text="Profile Updated!") self.snackbar.show()
def load_activity_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.ids['actscroll'].clear_widgets() query = f'''SELECT ACTIVITY_ID, ORG_ID, NAME, LOCATION, DISASTER, TARGET_AMT FROM ACTIVITY WHERE ORG_ID = {globalvariables.var_org_id} AND STATUS='Y' ''' # run direct SQL print(globalvariables.var_org_id) stmt = ibm_db.exec_immediate(connection.conn, query) actlist = ibm_db.fetch_both(stmt) item = TwoLineIconListItem() while (actlist): icon = IconLeftWidget(icon="bank") item = TwoLineIconListItem(text=str(actlist[2]), secondary_text=str(actlist[3])) item.add_widget(icon) item.bind(on_release=self.row_press) self.ids['actscroll'].add_widget(item) actlist = ibm_db.fetch_both( stmt) #for incrementing rows inside while loop
def load_hist_page(self): self.ids['float_lay'].clear_widgets() ContentNavigationDrawer.populateNavDrawerValues(self) query = f'''SELECT RES.DATE, CON.FIRST_NAME||' '||CON.LAST_NAME AS NAME, RES.NAME AS ITEM, RES.DESC AS DESC, RES.UNITS, RES.AMOUNT FROM RESOURCES RES, CONTACT CON WHERE RES.ACTIVITY_ID = {globalvariables.var_act_id} AND CON.CONTACT_ID = RES.CONTACT_ID ORDER BY RES.DATE DESC ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) txnlist = ibm_db.fetch_both(stmt) if txnlist is False : warn_label = MDLabel(pos_hint = {'center_x':0.5, 'center_y':0.5},font_size = '10sp', text = "No Resources yet") self.ids['float_lay'].add_widget(warn_label) else: print(txnlist) tlist=[] while(txnlist): tlist.append([txnlist[0],txnlist[1],txnlist[2], str(txnlist[3]), str(txnlist[4]), str(txnlist[5]) ]) txnlist = ibm_db.fetch_both(stmt) data_tables = MDDataTable( size_hint=(0.8, 0.8), rows_num=100, background_color=[1,0,0,1], pos_hint = {'center_x':0.5, 'center_y':0.5}, column_data=[ ("Date", dp(30)), ("Name", dp(30)), ("Item", dp(30)), ("Description", dp(30)), ("Units", dp(30)), ("Amount", dp(30)), ], row_data=[(f"{i[0]}",f"{i[1]}",f"{i[2]}",f"{i[3]}",f"{i[4]}",f"{i[5]}") for i in tlist] ) self.ids['float_lay'].add_widget(data_tables) self.ids['float_lay'].add_widget(MDFillRoundFlatButton(text="BACK", pos_hint={'center_x':0.5, 'center_y':0.1}, theme_text_color="Custom", text_color= (0, 0, 1, 1), on_release=lambda x: self.to_previous_page() ))
def load_resources_page(self): self.ids['float_lay'].clear_widgets() ContentNavigationDrawer.populateNavDrawerValues(self) query = f'''SELECT NAME,SUM(UNITS) AS UNITS, SUM(AMOUNT) AS AMOUNT FROM RESOURCES WHERE ACTIVITY_ID = {globalvariables.var_act_id} GROUP BY NAME ORDER BY NAME ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) txnlist = ibm_db.fetch_both(stmt) if txnlist is False : warn_label = MDLabel(pos_hint = {'center_x':0.5, 'center_y':0.5},font_size = '10sp', text = "No Resources yet") self.ids['float_lay'].add_widget(warn_label) else: print(txnlist) tlist=[] while(txnlist): tlist.append([txnlist[0],str(txnlist[1]),str(txnlist[2])]) txnlist = ibm_db.fetch_both(stmt) data_tables = MDDataTable( size_hint=(0.8, 0.8), rows_num=100, background_color=[1,0,0,1], pos_hint = {'center_x':0.5, 'center_y':0.5}, column_data=[ ("Resource", dp(50)), ("Units", dp(50)), ("Amount", dp(50)), ], row_data=[(f"{i[0]}",f"{i[1]}",f"{i[2]}") for i in tlist] ) self.ids['float_lay'].add_widget(data_tables) self.ids['float_lay'].add_widget(MDFillRoundFlatButton(text="BACK", pos_hint={'center_x':0.3, 'center_y':0.1}, theme_text_color="Custom", text_color= (0, 0, 1, 1), on_release=lambda x: self.to_previous_page() )) self.ids['float_lay'].add_widget(MDFillRoundFlatButton(text="DETAILS", pos_hint={'center_x':0.7, 'center_y':0.1}, theme_text_color="Custom", text_color= (0, 0, 1, 1), on_release=lambda x: self.to_details_page() ))
def load_txn_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) query = f'''SELECT TXN_DATE, ORG.NAME as ORG_NAME, ACT.NAME as ACT_NAME, TXN.AMOUNT FROM TRANSACTION TXN, ACTIVITY ACT, ORG ORG WHERE TXN.CONTACT_ID={globalvariables.var_userid} AND TXN.ACTIVITY_ID = ACT.ACTIVITY_ID AND ACT.ORG_ID=ORG.ORG_ID ORDER BY TXN_DATE DESC''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) txnlist = ibm_db.fetch_both(stmt) if txnlist is False : warn_label = MDLabel(pos_hint = {'center_x':0.5, 'center_y':0.5},font_size = '10sp', text = "You have not made any donations yet") self.ids['float_lay'].add_widget(warn_label) else: print(txnlist) tlist=[] while(txnlist): tlist.append([str(txnlist[0]),txnlist[1],txnlist[2],str(txnlist[3])]) txnlist = ibm_db.fetch_both(stmt) data_tables = MDDataTable( size_hint=(0.8, 0.8), rows_num=100, background_color=[1,0,0,1], pos_hint = {'center_x':0.5, 'center_y':0.5}, column_data=[ ("Date", dp(50)), ("Group", dp(50)), ("Activity", dp(50)), ("Amount", dp(30)), ], row_data=[(f"{i[0]}",f"{i[1]}",f"{i[2]}",f"{i[3]}") for i in tlist] ) self.ids['float_lay'].add_widget(data_tables) self.ids['float_lay'].add_widget(MDFillRoundFlatIconButton(text="BACK", pos_hint={'center_x':0.5, 'center_y':0.1}, icon="arrow-left-bold-circle",theme_text_color="Custom", text_color= (0, 0, 1, 1), on_release=lambda x: self.to_home_page() ))
def load_approval_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) query = f'''SELECT MEMORG.NAME AS ONAME, NEWCON.FIRST_NAME||' '||NEWCON.LAST_NAME AS NAME, NEWCON.EMAIL AS EMAIL FROM CONTACT NEWCON, CONTACT_ORG CONORG, CONTACT_ORG MEMCON, ORG MEMORG WHERE NEWCON.CONTACT_ID = CONORG.CONTACT_ID AND CONORG.STATUS='N' AND CONORG.MEMBER_FLAG='P' AND MEMORG.ORG_ID = CONORG.ORG_ID AND CONORG.ORG_ID = MEMCON.ORG_ID AND MEMCON.CONTACT_ID={globalvariables.var_userid} AND MEMCON.STATUS='Y' AND MEMCON.MEMBER_FLAG='Y' ''' # run direct SQL stmt = ibm_db.exec_immediate(connection.conn, query) txnlist = ibm_db.fetch_both(stmt) if txnlist is False: warn_label = MDLabel(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, font_size='10sp', text="You do not have any approvals") self.ids['approval_float_lay'].add_widget(warn_label) else: print(txnlist) alist = [] while (txnlist): alist.append([str(txnlist[0]), txnlist[1], txnlist[2]]) txnlist = ibm_db.fetch_both(stmt) data_tables = MDDataTable(size_hint=(1, 1), rows_num=100, check=True, pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, column_data=[ ("Group", dp(40)), ("Name", dp(40)), ("Email", dp(40)), ], row_data=[(f"{i[0]}", f"{i[1]}", f"{i[2]}") for i in alist]) data_tables.bind(on_check_press=self.on_check_press) self.ids['approval_float_lay'].add_widget(data_tables) #Approve Button approve_button = MDFillRoundFlatIconButton( text="APPROVE", pos_hint={ 'center_x': 0.3, 'center_y': 0.2 }, icon="thumb-up-outline", on_release=lambda x: self.approvereq()) approve_button.md_bg_color = 0.211, 0.678, 0.054, 1 #Green color self.ids['approval_float_lay'].add_widget(approve_button) #Reject Button reject_button = MDFillRoundFlatIconButton( text="REJECT", pos_hint={ 'center_x': 0.7, 'center_y': 0.2 }, icon="thumb-down-outline", on_release=lambda x: self.rejectreq()) reject_button.md_bg_color = 0.858, 0.239, 0.086, 1 #Red color self.ids['approval_float_lay'].add_widget(reject_button) self.ids['approval_float_lay'].add_widget( MDFillRoundFlatIconButton( text="BACK", pos_hint={ 'center_x': 0.5, 'center_y': 0.1 }, icon="arrow-left-bold-circle", theme_text_color="Custom", text_color=(0, 0, 1, 1), on_release=lambda x: self.to_home_page()))
def load_settings_page(self): ContentNavigationDrawer.populateNavDrawerValues(self)
def load_nav_drawer(self): ContentNavigationDrawer.populateNavDrawerValues(self)
def load_home_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.load_org_list()
def load_home_page(self): ContentNavigationDrawer.populateNavDrawerValues(self) self.ids['nogroupwarning'].text = "" self.load_org_list()