Example #1
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
Example #2
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
Example #3
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)
Example #4
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
Example #5
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
Example #6
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
Example #7
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
Example #8
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