Sindbad~EG File Manager

Current Path : /home/numerotech/membership.numerotech.com/CommonMembershipApp/core/model/
Upload File :
Current File : //home/numerotech/membership.numerotech.com/CommonMembershipApp/core/model/MPaymentType.py

from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from core import app
import json
from .. import engine

class MPaymentType():
	def __init__(self):
		try:
			self.meta               = MetaData()
			self.m_payment_type      = Table("m_payment_type", self.meta, autoload_with=engine)
		   
		except Exception as e:
			print(e)
	
	def count_payment_type(self,is_visible,is_membership,society_id):
		with engine.connect() as conn:
			stmt = self.m_payment_type.select().where(self.m_payment_type.c.is_visible.in_([is_visible])).where(self.m_payment_type.c.is_membership.in_([is_membership])).where(self.m_payment_type.c.society_id.in_([society_id]))
			result = conn.execute(stmt)
			results = result.all()
			conn.close()
			return  [dict(r._mapping) for r in results] if results else None
		
	def get_payment_content(self,payment_type,is_membership,society_id):
		with engine.connect() as conn:
			stmt = self.m_payment_type.select().where(self.m_payment_type.c.payment_type.in_([payment_type])).where(self.m_payment_type.c.is_membership.in_([is_membership])).where(self.m_payment_type.c.society_id.in_([society_id]))
			result = conn.execute(stmt)
			output = result.first()
			conn.close()
			if output :
				return dict(output._mapping)
			else :
				return None

	def get_payment_content_id(self,m_payment_id,is_membership,society_id):
		with engine.connect() as conn:
			stmt = self.m_payment_type.select().where(self.m_payment_type.c.m_payment_id.in_([m_payment_id])).where(self.m_payment_type.c.is_membership.in_([is_membership])).where(self.m_payment_type.c.society_id.in_([society_id]))
			result = conn.execute(stmt)
			output = result.first()
			conn.close()
			if output :
				return dict(output._mapping)
			else :
				return None

	def get_all_payment_type(self,is_membership,society_id):
		with engine.connect() as conn:
			stmt = self.m_payment_type.select().where(self.m_payment_type.c.is_membership.in_([is_membership])).where(self.m_payment_type.c.society_id.in_([society_id]))
			result = conn.execute(stmt)
			results = result.all()
			conn.close()
			return  [dict(r._mapping) for r in results] if results else None

	

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists