def contractedproducts(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from shops import ContractedProduct, Product, Shop from invoices import Order, Orderlist from pagination import Pagination ContractedProduct(db), Product(db), Shop(db), Order(db), Orderlist(db) settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() records=db(db.contractedproducts.id>0).count() items_per_page=settings.orderlistitems pag=Pagination(records, items_per_page) contractedproducts = db(db.contractedproducts.id>0).select( db.contractedproducts.ALL, db.products.ALL, db.shop.ALL, db.auth_user.ALL, db.fiscals.ALL, left=[ db.products.on(db.products.id==db.contractedproducts.product), db.shop.on(db.shop.id==db.contractedproducts.shop), db.auth_user.on(db.auth_user.id==db.contractedproducts.user), db.fiscals.on(db.fiscals.user==db.auth_user.id)], orderby=~db.contractedproducts.expiration, limitby=pag.limitby()) return dict(contractedproducts=contractedproducts, pagination=pag, records=records, items_per_page=items_per_page) else: redirect(URL(request.application,'default','user/login'))
def orders(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from shops import Shop, ContractedProduct from invoices import Order, Orderlist from pagination import Pagination Order(db), Orderlist(db), Shop(db), ContractedProduct(db) settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() records=db(db.orders.status!="CreandoAdmin").count() items_per_page=settings.orderlistitems pag=Pagination(records, items_per_page) #orders = db(db.orders.status!="CreandoAdmin").select(db.orders.ALL, orderby=~db.orders.id, limitby=pag.limitby()) orders=db(db.orders.status!="CreandoAdmin").select(db.orders.ALL, db.shop.host, left=[ db.orderlist.on(db.orderlist.g_order==db.orders.id), db.contractedproducts.on(db.contractedproducts.orderlist==db.orderlist.id), db.shop.on(db.shop.id==db.contractedproducts.shop)], orderby=~db.orders.id, groupby=db.orders.id, limitby=pag.limitby()) return dict(orders=orders, pagination=pag, records=records, items_per_page=items_per_page) else: redirect(URL(request.application,'default','user/login'))
def myservices(): from shops import ContractedProduct, Product, Shop from invoices import Order, Orderlist from pagination import Pagination from adminsettings import Adminsettings Adminsettings(db) ContractedProduct(db), Product(db), Shop(db), Order(db), Orderlist(db) settings = db(db.adminsettings.id > 0).select(db.adminsettings.ALL).first() records = db((db.contractedproducts.id > 0) & (db.contractedproducts.user == auth.user_id)).count() items_per_page = settings.orderlistitems pag = Pagination(records, items_per_page) contractedproducts = db((db.contractedproducts.id > 0) & ( db.contractedproducts.user == auth.user_id)).select( db.contractedproducts.ALL, db.products.ALL, db.shop.ALL, db.auth_user.ALL, db.fiscals.ALL, left=[ db.products.on( db.products.id == db.contractedproducts.product), db.shop.on(db.shop.id == db.contractedproducts.shop), db.auth_user.on(db.auth_user.id == db.contractedproducts.user), db.fiscals.on(db.fiscals.user == db.auth_user.id) ], orderby=~db.contractedproducts.expiration, limitby=pag.limitby()) return dict(contractedproducts=contractedproducts, pagination=pag, records=records, items_per_page=items_per_page)
def bloglist(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from pagination import Pagination from blog import Blog, Draft, Images settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() blog=Blog(db,ckeditor) draft=Draft(db,ckeditor) Images(db) brecords=db(db.blog.id>0).count() drecords=db(db.draft.id>0).count() records = int(brecords) + int(drecords) items_per_page=settings.bloglistitems pag=Pagination(records, items_per_page) drafts =db().select(db.draft.ALL, orderby=~db.draft.id, limitby=pag.limitby()) posts = db().select(db.blog.ALL, orderby=~db.blog.id, limitby=pag.limitby()) return dict(posts=posts, drafts=drafts, pagination=pag, records=records, items_per_page=items_per_page) else: redirect(URL(request.application,'blog','index'))
def emailbox(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() from pagination import Pagination from mailboxing import Mailboxing Mailboxing(db) records=db(db.mailbox.id>0).count() notreads=db(db.mailbox.messread==False).count() items_per_page=settings.messageitems pag=Pagination(records, items_per_page) messages = db().select(db.mailbox.ALL, orderby=~db.mailbox.id, limitby=pag.limitby()) return dict(messages=messages, pagination=pag, records=records, items_per_page=items_per_page, notreads=notreads) else: redirect(URL(request.application,'default','user/login'))
def subscriptions(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from pagination import Pagination from regnews import Regnews settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() try: reg=Regnews(db) reg.define_tables() except: pass records=db(db.regnews.id>0).count() items_per_page=settings.subscriptionitems pag=Pagination(records, items_per_page) subscriptions = db().select(db.regnews.ALL, orderby=~db.regnews.id, limitby=pag.limitby()) return dict(subscriptions=subscriptions, pagination=pag, records=records, items_per_page=items_per_page, actives=db(db.regnews.news==True).count()) else: redirect(URL(request.application,'default','user/login'))
def index(): from pagination import Pagination from blog import Blog, Images from comments import Comments from adminsettings import Adminsettings, Cifrar Adminsettings(db) Blog(db,ckeditor), Images(db) Comments(db) settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() session.publishing=False session.preview=False records=db(db.blog.id>0).count() items_per_page=settings.blogitems pag=Pagination(records, items_per_page) posts = db(db.blog.public==True).select(db.blog.ALL, orderby=~db.blog.id, limitby=pag.limitby(), cache=(cache.ram, 5), cacheable=True) lastposts = db(db.blog.public==True).select(db.blog.ALL, orderby=~db.blog.id, limitby=(0,10), cache=(cache.ram, 150), cacheable=True) return dict(posts=posts, pagination=pag, records=records, items_per_page=items_per_page, lastposts=lastposts)
def billing(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from invoices import Fiscal, Invoice,Order from pagination import Pagination Fiscal(db), Invoice(db), Order(db) settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() count=db.invoices.id.count() records=db((db.invoices.id>0)).select(count, left=[ db.auth_user.on(db.auth_user.id==db.invoices.user), db.fiscals.on(db.fiscals.user==db.auth_user.id)], orderby=~db.invoices.id).first() items_per_page=settings.invoiceitems pag=Pagination(int(records[count]), items_per_page) invoices= db((db.invoices.id>0)).select(db.orders.status, db.orders.invoice, db.invoices.ALL, db.auth_user.id, db.auth_user.first_name, db.auth_user.last_name, db.fiscals.fiscalname, left=[ db.orders.on(db.orders.invoice==db.invoices.id), db.auth_user.on(db.auth_user.id==db.invoices.user), db.fiscals.on(db.fiscals.user==db.auth_user.id), ], orderby=~db.invoices.id, limitby=pag.limitby()) total=0 totaltaxes=0 for invoice in db(db.invoices.created_at>=datetime.date(datetime.datetime.today().year,1,1)).select(): total=total+ invoice.total totaltaxes= totaltaxes + invoice.taxes return dict(invoices=invoices, pagination=pag, records=records[count], items_per_page=items_per_page, total=total, totaltaxes=totaltaxes) else: redirect(URL(request.application,'default','user/login'))
def products(): if auth.has_membership('administradores') or auth.has_membership('superadministradores'): from shops import Product, PricePlan from pagination import Pagination Product(db), PricePlan(db) settings = db(db.adminsettings.id>0).select(db.adminsettings.ALL).first() records=db(db.products.id>0).count() items_per_page=settings.productitems pag=Pagination(records, items_per_page) products=db(db.products.id>0).select(db.products.ALL, db.priceplans.planname, left=[db.priceplans.on(db.priceplans.id==db.products.plan)], orderby=db.products.id, limitby=pag.limitby()) return dict(products=products, pagination=pag, records=records, items_per_page=items_per_page) else: redirect(URL(request.application,'default','user/login'))