def login_gpm(): """ Function for login through GPM :return: null """ extras.decorate_break_message('Login For GPM') try: email = str(input(ct.Enter_email)) while not extras.validate_email(email): print("Wrong Email Format. Please enter valid email \n") email = str(input(ct.Enter_email)) password = int(input(ct.Enter_password)) while not extras.validate_password(password): print( "Wrong Password Format. Please enter numeric password between 101 and 999\n" ) password = int(input(ct.Enter_password)) if qb.validate_credential(ct.GPM_TABLE, email, password): gpm_details = qb.get_gpm_or_member_details(ct.GPM_TABLE, email, password) gpm_id = int(gpm_details[0]) gpm_name = str(gpm_details[1]) asignee_bdo_id = int(gpm_details[2]) gpm = GPM(gpm_id, gpm_name, asignee_bdo_id) gpm.welcome_screen() else: print(ct.Wrong_credentials) login_gpm() except ValueError as e: print("Error is {}".format(e)) finally: login_gpm()
def welcome_screen(self): extras.decorate_break_message('Welcome {}'.format(self.name)) print(ct.Choose_Action_For_GPM) choice = input(ct.Enter_choice) if int(choice) in [1, 2, 3, 4, 5, 6, 7]: if int(choice) == 1: create_member(self.id) self.welcome_screen() elif int(choice) == 2: delete_member(self.id) self.welcome_screen() elif int(choice) == 3: update_member(self.id) self.welcome_screen() elif int(choice) == 4: issue_job_card(self.id) elif int(choice) == 5: assign_project(self.id, self.asignee_bdo_id) self.welcome_screen() elif int(choice) == 6: raise_wage_request_for_all_members(self.id, self.asignee_bdo_id) self.welcome_screen() else: view_complaints(self.id) self.welcome_screen() else: print(ct.Wrong_choice) self.welcome_screen()
def login_bdo(): """ Function for login through BDO :return: null """ extras.decorate_break_message('Login For BDO') try: email = str(input(ct.Enter_email)) while not extras.validate_email(email): print("Wrong Email Format. Please enter valid email \n") email = str(input(ct.Enter_email)) password = int(input(ct.Enter_password)) while not extras.validate_password(password): print( "Wrong Password Format. Please enter numeric password between 101 and 999\n" ) password = int(input(ct.Enter_password)) if qb.validate_credential(ct.BDO_TABLE, email, password): bdo_details = qb.get_bdo_details(ct.BDO_TABLE, email, password) bdo_id = int(bdo_details[0]) bdo_name = str(bdo_details[1]) bdo = BDO(bdo_id, bdo_name) bdo.welcome_screen() logging.info("Successfully logged in as BDO {}".format(bdo_name)) else: print(ct.Wrong_credentials) login_bdo() except ValueError as e: print("Error is {}".format(e)) finally: login_bdo()
def raise_wage_request_for_all_members(gpm_id, bdo_id): """ Function to raise the wage request for all the member lying under that gpm :param gpm_id: gpm id :param bdo_id: bdo id :return: null """ table_name_wage_approval = 'WAGE_APPROVAL' table_name_project_details = "PROJECT_MEMBER_DETAIL" table_name_project = 'PROJECT' print(ct.Project_available_in_your_block) project_list = qb.get_item_for_asignee(table_name_project, bdo_id) print("-" * 60) for item in project_list: print('Project Id : {} | Project Name :{}'.format(item[0], item[1])) print("-" * 60) project_id = input(ct.Enter_the_project_id_for_wage_update) if qb.is_project_wage_not_pending(table_name_wage_approval, project_id): member_detail_list = qb.get_member_project_details( table_name_project_details, project_id, gpm_id) for item in member_detail_list: number_of_days_worked = int( (extras.convert_string_to_date(str(item[3]).strip()) - extras.convert_string_to_date(str(item[2]).strip())).days) amount = number_of_days_worked * 100 qb.insert_wage_table(table_name_wage_approval, item[0], item[1], amount, number_of_days_worked, bdo_id) else: print(ct.Request_for_project_still_pending)
def welcome_screen(self): extras.decorate_break_message('Welcome {}'.format(self.name)) print(ct.Choose_Action_For_Bdo) choice = input(ct.Enter_choice) if int(choice) in [1, 2, 3, 4, 5, 6, 7, 8, 9]: if int(choice) == 1: create_gpm(self.id) self.welcome_screen() elif int(choice) == 2: delete_gpm(self.id) self.welcome_screen() elif int(choice) == 3: update_gpm(self.id) self.welcome_screen() elif int(choice) == 4: create_project(self.id) self.welcome_screen() elif int(choice) == 5: delete_project(self.id) self.welcome_screen() elif int(choice) == 6: update_project(self.id) self.welcome_screen() elif int(choice) == 7: approving_projects(self.id) self.welcome_screen() elif int(choice) == 8: approving_wages(self.id) self.welcome_screen() else: view_complaints(self.id) self.welcome_screen() else: print(ct.Wrong_choice) self.welcome_screen()
def assign_project(gpm_id, bdo_id): """ function to assign project to a member :param gpm_id: gpm id :param bdo_id: bdo id :return: null """ table_name_project_detail = 'PROJECT_MEMBER_DETAIL' table_name_project = "PROJECT" table_name_member = 'MEMBER' print(ct.Project_available_in_your_block) project_list = qb.get_item_for_asignee(table_name_project, bdo_id) print("-" * 60) for item in project_list: print('Project Id : {} | Project Name :{}'.format(item[0], item[1])) print("-" * 60) project_id = input(ct.Enter_the_project_id_to_be_member_allotted) project_data = qb.get_project_details(table_name_project, project_id) total_strength = project_data[0] start_date = str(project_data[1]) end_date = str(project_data[2]) current_strength = qb.get_project_allocated_strength( table_name_project_detail, project_id) if current_strength < total_strength: print(ct.Member_available_in_your_zone) member_list = qb.get_item_for_asignee(table_name_member, gpm_id) print("-" * 60) for item in member_list: print('Member Id : {} | Member Name :{}'.format( item[0], item[1])) print("-" * 60) item_id = input(ct.Enter_the_member_id_to_be_allotted) if qb.check_member_not_present(table_name_project_detail, item_id): onboarding_date = input(ct.Enter_project_assigned_date) while extras.convert_string_to_date(start_date) > extras.convert_string_to_date(str(onboarding_date)) \ or extras.convert_string_to_date(end_date) < extras.convert_string_to_date(str(onboarding_date)): print(ct.Warning_invalid_onboarding_date) onboarding_date = input(ct.Enter_project_assigned_date) qb.assign_member_to_project(table_name_project_detail, item_id, project_id, gpm_id, bdo_id, onboarding_date, end_date) else: print(ct.Member_already_in_list) else: print(ct.Project_slots_already_occupied)
def welcome_screen(self): extras.decorate_break_message('Welcome {}'.format(self.name)) print(ct.Choose_Action_For_MEMBER) choice = input(ct.Enter_choice) if int(choice) in [1, 2]: if int(choice) == 1: check_wage(self.id) self.welcome_screen() else: raise_complaint(self.id, self.asignee_gpm_id, self.reviewer_bdo_id) self.welcome_screen() else: print(ct.Wrong_choice) self.welcome_screen()
def issue_job_card(gpm_id): """ Method to issue a job card for a member :param gpm_id: gpm id :return: null """ table_name = 'MEMBER' print(ct.Member_available_in_your_zone) member_list = qb.get_item_for_asignee(table_name, gpm_id) print("-" * 60) for item in member_list: print('Member Id : {} | Member Name :{}'.format(item[0], item[1])) print("-" * 60) item_id = input(ct.Enter_the_member_id_to_be_deleted) member_job_data = qb.fetch_job_id_data(table_name, item_id) extras.display_job_card(member_job_data)
def login_member(): """ Function for login through Member :return: null """ extras.decorate_break_message('Login For MEMBER') try: email = str(input(ct.Enter_email)) while not extras.validate_email(email): print("Wrong Email Format. Please enter valid email \n") email = str(input(ct.Enter_email)) password = int(input(ct.Enter_password)) while not extras.validate_password(password): print( "Wrong Password Format. Please enter numeric password between 101 and 999\n" ) password = int(input(ct.Enter_password)) if qb.validate_credential(ct.MEMBER_TABLE, email, password): member_details = qb.get_gpm_or_member_details( ct.MEMBER_TABLE, email, password) member_id = int(member_details[0]) member_name = str(member_details[1]) asignee_gpm_id = int(member_details[2]) reviewer_bdo_id = int(qb.fetch_bdo_id(asignee_gpm_id)) member = MEMBER(member_id, member_name, asignee_gpm_id, reviewer_bdo_id) member.welcome_screen() else: print(ct.Wrong_credentials) login_member() except ValueError as e: print("Error as {}".format(e)) finally: login_member()
def create_project(bdo_id): """ Function to create a new project as assigned per the the norms by the bdo :param bdo_id: bdo_id :return: null """ table_name = "PROJECT" project_name = input(ct.Enter_name) project_area = input(ct.Enter_area) member_count = input(ct.Enter_total_member_required) project_cost = input(ct.Enter_project_cost_estimate) project_type = input(ct.Enter_project_type) while project_type not in ["RC", "ST", "BC"]: print(ct.Warning_wrong_project_type) project_type = input(ct.Enter_project_type) start_date = input(ct.Enter_start_date) end_date = input(ct.Enter_end_date) project_start_date = extras.convert_string_to_date(start_date) project_end_date = extras.convert_string_to_date(end_date) while project_end_date < project_start_date: print(ct.Warning_wrong_end_date) end_date = input(ct.Enter_end_date) project_end_date = extras.convert_string_to_date(end_date) qb.insert_project_table(table_name, project_name, project_area, member_count, project_cost, project_type, start_date, end_date, bdo_id)
'pincode integer', 'days_worked integer DEFAULT 0', 'wage integer DEFAULT 0', 'asignee_id integer') qb.create_table(ct.PROJECT_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT', 'name varchar(50)', 'area varchar[50]', 'total_member integer', 'cost_estimate integer', 'type varchar(5)', 'start_date varchar(15)', 'end_date varchar(15)', 'asignee_id integer') qb.create_table(ct.PROJECT_MEMBER_DETAIL_TABLE, 'member_id integer PRIMARY KEY', 'project_id integer', 'request_status integer DEFAULT 0', 'onboarding_date varchar(15)', 'end_date varchar(15)', 'asignee_id int', 'reviewer_id int') qb.create_table(ct.WAGE_APPROVAL_TABLE, 'member_id integer PRIMARY KEY', 'project_id integer', 'amount integer', 'days_worked integer', 'reviewer_id integer') qb.create_table(ct.COMPLAINT_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT ', 'member_id integer', 'message varchar(255)', 'raise_to varchar(5)', 'authority_id integer', 'date varchar(15)') if __name__ == '__main__': extras.decorate_break_message(ct.Welcome_to_Application) create_tables() start_application()