Beispiel #1
0
def list_order():
    div = DIV()
    num_car = 0
    tong_tien = 0
    carts = ''
    table = TABLE(_class='table')
    table.append(
        TR(TH('Sản phẩm'), TH('Số lượng'), TH(''), TH('Giá'),
           TH(B('Thành tiền')), TH(B('Chức năng'))))
    if request.cookies.has_key('cart_shop'):
        carts = eval(request.cookies['cart_shop'].value)
        from plugin_cms import CmsModel
        from plugin_cms import CmsFolder
        cms = CmsModel()
        db = cms.db
        cms.define_table('san_pham')
        from plugin_app import number_format

    for cart in carts:
        cart = eval(cart)
        row = db((db.san_pham.id == cart['id'])).select().first()
        if row:
            tong_tien += int(row.gia_san_pham) * int(cart['num'])
            thanh_tien = int(row.gia_san_pham) * int(cart['num'])
            input_num = INPUT(_type='text',
                              _class='integer',
                              _value=cart['num'],
                              _name='number_pr_%s' % (row.id),
                              _style="width: 55px; text-align: center;")
            ajax = "ajax('%s', ['number_pr_%s'], 'wr_list_order')" % (URL(
                c='plugin_app',
                f='update_carts',
                args=[request.args(0), row.id, 'delete']), row.id)
            ajax1 = "ajax('%s', ['number_pr_%s'], 'wr_list_order')" % (URL(
                c='plugin_app',
                f='update_carts',
                args=[request.args(0), row.id, 'update']), row.id)
            table.append(
                TR(
                    TD(row.name, ': '), TD(input_num), TD(' * '),
                    TD(number_format(row.gia_san_pham), ' VNĐ'),
                    TD(B(number_format(thanh_tien), ' VNĐ')),
                    TD(DIV(A(SPAN(_class='glyphicon glyphicon-floppy-save'),
                             'Cập nhật',
                             _onclick=ajax1,
                             _class='btn btn-primary'),
                           _class='btn-group'),
                       A(SPAN(_class='glyphicon glyphicon-remove'),
                         'Xóa',
                         _onclick=ajax,
                         _class='btn btn-danger'),
                       _class='setting')))
            num_car += 1

    div.append(table)
    p_tong = DIV(SPAN('Tổng tiền: '))
    p_tong.append(
        str(number_format(tong_tien) if tong_tien != 0 else '0') + ' VNĐ')
    div.append(B(p_tong, _class='text-right'))
    return div
Beispiel #2
0
def giay_moi_event():
    try:
        content = UL(_id='nt-title')
        from plugin_cms import CmsModel
        from plugin_cms import CmsFolder
        cms = CmsModel()
        cf = CmsFolder()
        cms.define_table('documents')
        date_now = request.now.date()
        rows = cf.get_content(
            tablename='documents',
            folder='giay-moi',
            orderby=cms.db.documents.ngay_ky,
            query=((cms.db.documents.ngay_ky <= date_now) &
                   (cms.db.documents.ngay_het_han > date_now)))
        for row in rows:
            content.append(
                LI(
                    A('GM ' + str(row.name) + ': ' + str(row.description),
                      _href=URL(a='vbvq',
                                c='portal',
                                f='read',
                                args=[row.folder.name, 'documents',
                                      row.link]))))
        content = str(content)
        return content
    except Exception, e:
        return e
Beispiel #3
0
def widget_type():
    if ((not request.vars.fieldtype) &
        ('reference' in request.vars.value)) | ('reference' in str(
            request.vars.fieldtype)):
        from plugin_cms import CmsModel
        cms = CmsModel()
        table = cms.define_dtable()
        rows = cms.db(table).select(orderby=table.name)
        tables = cms.db.tables
        if 'folder' not in cms.db.tables: tables.append('folder')
        for row in rows:
            if row.name not in cms.db.tables: tables.append(row.name)
        tables.sort()
        op = [
            OPTION(T(table),
                   _value=table,
                   _selected=(request.vars.value.endswith(table)))
            for table in tables
        ]
        widget = SELECT(op, _name='tablename', _id="tablename")
        script = SCRIPT(
            '''$('#tablename').change(function() {document.getElementById("dfield_ftype").value = document.getElementById("fieldtype").value+' '+$(this).val(); });'''
        )
        return SPAN(widget, script)
    else:
        script = SCRIPT(
            '''document.getElementById("dfield_ftype").value = document.getElementById("fieldtype").value;'''
        )
        return script
Beispiel #4
0
def add_cong_ty(folder):
	from sqlhtml import SQLFORM
   	from plugin_ckeditor import CKEditor
   	from plugin_cms import CmsModel
	T = current.T
	cms = CmsModel()
	db = cms.db
	div = DIV(_class='col-md-12')
	div.append(H2(SPAN(T('Thông tin chi tiết')),_class='title_name',_id='title_page'))
	cong_ty_edit = cms.define_table('cong_ty')
	cong_ty_id = db(cong_ty_edit.folder==folder).select().first()
	cong_ty_edit.folder.writable=False
	cong_ty_edit.folder.readable=False

	cong_ty_edit.start_time.writable=False
	cong_ty_edit.start_time.readable=False

	cong_ty_edit.danh_gia.writable=False
	cong_ty_edit.danh_gia.readable=False

	cong_ty_edit.is_maps.writable=False
	cong_ty_edit.is_maps.readable=False

	from plugin_app import widget_danh_muc
	cong_ty_edit.linh_vuc.widget=widget_danh_muc
	form=SQLFORM(cong_ty_edit,cong_ty_id)
	if form.process().accepted:
		current.response.flash = T("Cập nhật thành công!")
	div.append(form)
	return form
Beispiel #5
0
def manage():
    table = request.args(0)
    from plugin_cms import CmsModel
    cms = CmsModel()
    cms.define_table(table, True)
    if table not in cms.db.tables: redirect(URL(f='index'))
    content = SQLFORM.grid(cms.db[table], args=request.args[:1])
    response.view = 'plugin_cms/content.html'
    return dict(content=content)
Beispiel #6
0
def add_cart():
	pid = request.vars.pid
	ar_carts =[]
	if request.cookies.has_key ('cart_shop'):
		carts = eval(request.cookies['cart_shop'].value)
		i=0
		for cart in carts:
			cart = eval(cart)
			if cart['id']==pid:
				ar_carts.append(str({'id':str(cart['id']) ,'num':str(int(cart['num'])+1)}))
				i+=1
			else:
				ar_carts.append(str({'id':str(cart['id']) ,'num':str(cart['num'])}))
		if i==0:
			ar_carts.append(str({'id':pid ,'num':str(1)}))
	else:
		ar_carts.append(str({'id':pid ,'num':str(1)}))
		
	response.cookies['cart_shop'] = str(ar_carts) 
	response.cookies['cart_shop']['expires'] = 24 * 3600
	response.cookies['cart_shop']['path'] = '/'
	response.flash = T("Add new cart!")
	
	# load view_carts() nhung ko request duoc cookies moi
	
	div = DIV()
	num_car = 0
	tong_tien = 0
	carts = ar_carts
	from plugin_cms import CmsModel
	from plugin_cms import CmsFolder
	cms = CmsModel()
	db = cms.db
	cms.define_table('san_pham')
	from plugin_app import number_format
	
	for cart in carts:
		cart = eval(cart)
		row  = db((db.san_pham.id==cart['id'])).select().first()
		if row:
			div1 = DIV(_class='list_cart')
			ul = UL()
			ul.append(LI(row.name))
			ul.append(LI(SPAN('Số lượng: '),cart['num']))
			ul.append(LI(SPAN('Giá: '),number_format(row.gia_san_pham),' VNĐ'))
			div1.append(DIV(IMG(_src=cms.get_avatar('san_pham',row.avatar),_class='thumbnail'),_class='col-md-4 box_ivinh'))
			div1.append(DIV(ul,_class='col-md-8 box_ivinh'))
			div.append(div1)
			div.append(HR())
			tong_tien += int(row.gia_san_pham)* int(cart['num'])
			num_car +=1
	p_tong = DIV(SPAN('Tổng tiền: '))
	p_tong.append(str(number_format(tong_tien))+' VNĐ')
	div.append(B(p_tong,_class='text-right'))
	div.append(A('Gửi đơn hàng',_href=URL(c='portal',f='folder',args=['checkout']),_class='btn btn-success'))
	return div
Beispiel #7
0
def view_carts():
    div = DIV()
    num_car = 0
    tong_tien = 0
    carts = ''
    try:
        if request.cookies.has_key('cart_shop'):
            carts = eval(request.cookies['cart_shop'].value)
            from plugin_cms import CmsModel
            from plugin_cms import CmsFolder
            cms = CmsModel()
            db = cms.db
            cms.define_table('san_pham')
            from plugin_app import number_format

            for cart in carts:
                cart = eval(cart)
                row = db((db.san_pham.id == cart['id'])
                         & (db.san_pham.folder == CmsFolder().get_folder(
                             request.args(0)))).select().first()
                if row:
                    div1 = DIV(_class='list_cart')
                    ul = UL()
                    ul.append(LI(row.name))
                    ul.append(LI(SPAN('Số lượng: '), cart['num']))
                    ul.append(
                        LI(SPAN('Giá: '), number_format(row.gia_san_pham),
                           ' VNĐ'))
                    div1.append(
                        DIV(IMG(_src=cms.get_avatar('san_pham', row.avatar),
                                _class='thumbnail'),
                            _class='col-md-4 box_ivinh'))
                    div1.append(DIV(ul, _class='col-md-8 box_ivinh'))
                    div.append(div1)
                    div.append(HR())
                    tong_tien += int(row.gia_san_pham) * int(cart['num'])
                    num_car += 1
        if num_car > 0:
            p_tong = DIV(SPAN('Tổng tiền: '))
            p_tong.append(str(number_format(tong_tien)) + ' VNĐ')
            div.append(B(p_tong, _class='text-right'))
            div.append(
                A('Thanh toán',
                  _href=URL(c='portal',
                            f='folder',
                            args=request.args(0),
                            vars=dict(page='cart')),
                  _class='btn btn-success'))
        else:
            div.append('Giỏ hàng trống')
    except Exception, e:
        return e
Beispiel #8
0
def widget_field():
    from plugin_cms import CmsModel
    cms = CmsModel()
    table = cms.define_dfield()
    ftype = request.vars.fieldtype or request.vars.ftype
    if len(ftype.split(' ')) == 3:
        ftype = ftype.split(' ')[0] + ' ' + ftype.split(' ')[1]
    rows = cms.db(table.ftype.startswith(ftype)).select(orderby=table.name)
    op = [
        OPTION(row.name,
               _value=row.id,
               _selected=(row.id == int(request.vars.value))) for row in rows
    ]
    widget = SELECT(op, _name='dfield', _id='tablefield_dfield')
    return widget
Beispiel #9
0
def widget_danh_muc(field, value):
    from plugin_app import treeview
    from plugin_cms import CmsModel
    cms = CmsModel()
    cms.define_folder()
    db = cms.db
    auth = cms.auth
    if not value: value = []
    tr = TR()
    row = db.folder[246]
    pnode = XML(
        str(
            INPUT(_type='checkbox',
                  _name=field.name,
                  _value=row.id,
                  _checked=(row.id in value),
                  _class='check_all')) + ' ' + row.label)
    tree = treeview(db,
                    auth,
                    'folder',
                    parent=row.id,
                    checkbox='checkbox',
                    pnode=pnode,
                    field='label',
                    key=field.name,
                    selected=value,
                    orderby=db.folder.display_order | db.folder.name,
                    tree=field.name + str(row.id))
    tr.append(TD(tree))
    script = '''<script type="text/javascript">
				$(document).ready(function(){
					$('.check_all').click(function(){
						if ($(this).is(':checked')) {
							$(this).parent().find('input:checkbox').attr('checked', true);
						}
						else{
							$(this).parent().find('input:checkbox').attr('checked', false);
						}
					});
				});
		</script>'''
    return DIV(XML(script), TABLE(tr))
Beispiel #10
0
def index():
    from plugin_cms import CmsModel
    ul = UL()
    for table in ['folder', 'dtable', 'rtable', 'dfield', 'tablefield']:
        ul.append(
            LI(A(T(table), _href=URL(f=table)),
               _class='table_%s' % table,
               _id='table_%s' % table))
    ul.append(
        LI(A(T('dcontent'), _href=URL(f='manage', args=['dcontent'])),
           _class='table_dcontent',
           _id='table_dcontent'))
    ul.append(
        LI(A(T('box'), _href=URL(f='manage', args=['box'])),
           _class='table_box',
           _id='table_box'))
    ul.append(
        LI(A(T('rtable'), _href=URL(f='manage', args=['rtable'])),
           _class='table_box',
           _id='table_box'))
    content = DIV(ul, _class='cmsindex', _id='cmsindex')
    cms = CmsModel()
    table = cms.define_dtable()
    rows = cms.db(table).select(orderby=table.display_order)
    ul1 = UL(_class='table_data')
    ul2 = UL(_class='table_publish')
    for row in rows:
        li = LI(A(T(row.name), _href=URL(f='manage', args=[row.name])),
                _class='table_%s' % row.name,
                _id='table_%s' % row.name)
        if row.publish: ul2.append(li)
        else: ul1.append(li)
    content.append(ul1)
    content.append(ul2)
    response.view = 'plugin_cms/content.html'
    return dict(content=content)
Beispiel #11
0
# -*- coding: utf-8 -*-
###################################################
# This file was developed by ToanLK
# It is released under BSD, MIT and GPL2 licenses
# Version 0.1 Date: 27/02/2014
###################################################

if request.controller == 'plugin_box':
    from plugin_cms import CmsModel
    cms = CmsModel()
    db = cms.db
    cms.define_box()
Beispiel #12
0
def update_carts():
    pid = request.args(1)
    number = 'number_pr_%s' % (pid)
    number_pr = request.vars[number]
    ar_carts = []
    if request.args(2) == 'delete':
        if request.cookies.has_key('cart_shop'):
            carts = eval(request.cookies['cart_shop'].value)
            i = 0
            for cart in carts:
                cart = eval(cart)
                if cart['id'] == pid:
                    i += 1
                else:
                    ar_carts.append(
                        str({
                            'id': str(cart['id']),
                            'num': str(cart['num'])
                        }))
            if i == 0:
                ar_carts.append(str({'id': pid, 'num': str(1)}))
        else:
            ar_carts.append(str({'id': pid, 'num': str(1)}))

    elif request.args(2) == 'update':
        if request.cookies.has_key('cart_shop'):
            carts = eval(request.cookies['cart_shop'].value)
            i = 0
            for cart in carts:
                cart = eval(cart)
                if cart['id'] == pid:
                    ar_carts.append(
                        str({
                            'id': str(cart['id']),
                            'num': str(number_pr)
                        }))
                    i += 1
                else:
                    ar_carts.append(
                        str({
                            'id': str(cart['id']),
                            'num': str(cart['num'])
                        }))
            if i == 0:
                ar_carts.append(str({'id': pid, 'num': str(1)}))
        else:
            ar_carts.append(str({'id': pid, 'num': str(1)}))

    response.cookies['cart_shop'] = str(ar_carts)
    response.cookies['cart_shop']['expires'] = 24 * 3600
    response.cookies['cart_shop']['path'] = '/'

    div = DIV()
    num_car = 0
    tong_tien = 0
    table = TABLE(_class='table')
    table.append(
        TR(TH('Sản phẩm'), TH('Số lượng'), TH(''), TH('Giá'),
           TH(B('Thành tiền')), TH(B('Chức năng'))))

    carts = ar_carts
    from plugin_cms import CmsModel
    from plugin_cms import CmsFolder
    cms = CmsModel()
    db = cms.db
    cms.define_table('san_pham')
    from plugin_app import number_format

    for cart in carts:

        cart = eval(cart)
        row = db((db.san_pham.id == cart['id'])).select().first()
        if row:
            tong_tien += int(row.gia_san_pham) * int(cart['num'])
            thanh_tien = int(row.gia_san_pham) * int(cart['num'])
            input_num = INPUT(_type='text',
                              _value=cart['num'],
                              _name='number_pr_%s' % (row.id),
                              _style="width: 55px; text-align: center;")
            ajax = "ajax('%s', ['number_pr_%s'], 'wr_list_order')" % (URL(
                c='plugin_app',
                f='update_carts',
                args=[request.args(0), row.id, 'delete']), row.id)
            ajax1 = "ajax('%s', ['number_pr_%s'], 'wr_list_order')" % (URL(
                c='plugin_app',
                f='update_carts',
                args=[request.args(0), row.id, 'update']), row.id)
            table.append(
                TR(
                    TD(row.name, ': '), TD(input_num), TD(' * '),
                    TD(number_format(row.gia_san_pham), ' VNĐ'),
                    TD(B(number_format(thanh_tien), ' VNĐ')),
                    TD(DIV(A(SPAN(_class='glyphicon glyphicon-floppy-save'),
                             'Cập nhật',
                             _onclick=ajax1,
                             _class='btn btn-primary'),
                           _class='btn-group'),
                       A(SPAN(_class='glyphicon glyphicon-remove'),
                         'Xóa',
                         _onclick=ajax,
                         _class='btn btn-danger'),
                       _class='setting')))
            num_car += 1

    div.append(table)

    p_tong = DIV(SPAN('Tổng tiền: '))
    p_tong.append(str(number_format(tong_tien)) + ' VNĐ')
    div.append(B(p_tong, _class='text-right'))
    response.flash = T('Cập nhật thành công.')
    return div
Beispiel #13
0
# This file was developed by ToanLK
# It is released under BSD, MIT and GPL2 licenses
# Version 0.1 Date: 27/02/2014
###################################################

if request.controller in ['plugin_process', 'plugin_comment']:
    from plugin_process import ProcessModel
    from plugin_cms import CmsModel
    processmodel = ProcessModel()
    processmodel.define_process()
    processmodel.define_procedures()
    processmodel.define_process_log()
    processmodel.define_process_lock()
    auth = processmodel.auth
    db = processmodel.db
    cms = CmsModel()

elif request.controller in ['appadmin', 'plugin_tools']:
    from plugin_process import ProcessModel
    from plugin_cms import CmsModel
    processmodel = ProcessModel()
    processmodel.define_process(False)
    processmodel.define_procedures(False)
    processmodel.define_process_log(False)
    processmodel.define_process_lock(False)
    auth = processmodel.auth
    db = processmodel.db
    cms = CmsModel()
    cmsdb = cms.db
    cms.define_tables(False)
    # cms.define_table('san_pham',True)
Beispiel #14
0
# -*- coding: utf-8 -*-
###################################################
# This file was developed by ToanLK
# It is released under BSD, MIT and GPL2 licenses
# Version 0.1 Date: 28/07/2014
###################################################

if request.controller in ['plugin_upload']:
    from plugin_process import ProcessModel
    from plugin_cms import CmsModel
    auth = ProcessModel().auth
    cms = CmsModel()
    db = cms.db
Beispiel #15
0
def view_order():
	div = DIV(_id="view_order")
	num_car = 0
	tong_tien = 0
	carts =''
	if request.cookies.has_key('cart_shop'):
		carts = eval(request.cookies['cart_shop'].value)
		from plugin_cms import CmsModel
		from plugin_cms import CmsFolder
		cms = CmsModel()
		db = cms.db
		cms.define_table('san_pham')
		from plugin_app import number_format
		table = TABLE(_class='table')
		
		table.append(TR(TH('Sản phẩm'),TH('Số lượng'),TH(''),TH('Giá'),TH(B('Thành tiền'))))
        for cart in carts:
			cart = eval(cart)
			row  = db((db.san_pham.id==cart['id'])&(db.san_pham.folder== CmsFolder().get_folder(request.args(0)))).select().first()
			if row:
				tong_tien += int(row.gia_san_pham)* int(cart['num'])
				input_num = INPUT(_type='text',_value=cart['num'])
				table.append(TR(TD(row.name,': '),TD(input_num),TD(' * '),TD(number_format(row.gia_san_pham),' VNĐ'),TD(B(number_format(tong_tien),' VNĐ'))))
				div.append(table)
				num_car +=1
	p_tong = DIV(SPAN('Tổng tiền: '))
	p_tong.append(str(number_format(tong_tien))+' VNĐ')
	div.append(B(p_tong,_class='text-right'))
	
	form = FORM()
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Họ và tên'))
	div1.append(INPUT(_type='text',_class="form-control",_placeholder="Họ và tên" ))
	form.append(div1)
	
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Email'))
	div1.append(INPUT(_type='text',_class="form-control",_placeholder="Email"))
	form.append(div1)
	
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Điện thoại'))
	div1.append(INPUT(_type='text',_class="form-control",_placeholder="Điện thoại"))
	form.append(div1)
	
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Địa chỉ nhận hàng'))
	div1.append(INPUT(_type='text',_class="form-control",_placeholder="Địa chỉ nhận hàng"))
	form.append(div1)
	
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Lời nhắn'))
	div1.append(TEXTAREA(_class="form-control",_rows="3",_placeholder="Lời nhắn"))
	form.append(div1)
	
	div1 = DIV(_class="form-group")
	div1.append(LABEL('Lời nhắn'))
	div1.append(TEXTAREA(_class="form-control",_rows="3",_placeholder="Lời nhắn"))
	form.append(div1)
	
	ajax = "ajax('%s', [], 'order_view')"%(URL(f='act_add_cart',args=request.args))
	form.append(A('Gửi đặt hàng',_onclick=ajax, _class='btn btn-success'))
	div.append(form)
	return div