示例#1
0
def tao_tin_tim_mua():
	from plugin_ckeditor import CKEditor
	table = cms.define_table('tintuc')
	for field in table.fields:
		if field == 'htmlcontent':
			table[field].label = 'Nội dung tìm mua'
		if field == 'folder':
			table[field].default = 248
			table[field].readable=False
			table[field].writable=False
		row = db(db.dfield.name==field).select().first()
		if row:
			if row.ckeditor: table[field].widget=CKEditor(db).widget		
	form=SQLFORM(table)
	if form.process().accepted:
		from plugin_process import ProcessModel
		objects = ProcessModel().define_objects()
		objects_id = objects.insert(folder=248,foldername='san-pham-tim-mua',tablename='tintuc',table_id=form.vars.id,auth_group=7,process=1)

		# link = form.vars.name.replace('đ','d')
		# link = '%s.html'%IS_SLUG.urlify(link)
		# dcontent = cms.define_dcontent()
		# dcontent.insert(folder=248,dtable='tintuc',table_id=form.vars.id,link=link,name=form.vars.name,avatar=form.vars.avatar,description=form.vars.description,publish_on=request.now,expired_on=None)	
		# cms.db(tin_tuc_edit.id==form.vars.id).update(link=link)
		session.flash = T('Gửi thông tin tìm mua thành công')
		redirect(URL(c='portal',f='folder',args=['san-pham-tim-mua']))
	response.view = 'layout/home_dang_tin-tim-mua.html'	
	return dict(content=form)		
示例#2
0
def edit_cong_ty():
    id_folder = request.args(1)
    name = request.args(0)

    from plugin_ckeditor import CKEditor
    div = DIV(_class='col-md-12')
    div.append(
        H2(SPAN('Khởi tạo gian hàng', _class='title_name'),
           _class='title_page'))

    cong_ty = cms.define_table('cong_ty')
    cong_ty_id = db(cong_ty.folder == folder_id_gian_hang).select().first()
    from gluon.tools import Crud
    crud = Crud(cms.db)
    cong_ty.folder.default = id_folder
    cong_ty.folder.writable = False
    cong_ty.folder.readable = False

    cong_ty.start_time.writable = False
    cong_ty.start_time.readable = False

    cong_ty.danh_gia.writable = False
    cong_ty.danh_gia.readable = False

    cong_ty.is_maps.writable = False
    cong_ty.is_maps.readable = False
    form = crud.update(cong_ty, cong_ty_id)
    if form.process().accepted:

        from plugin_process import ProcessModel
        objects = ProcessModel().define_objects()
        objects_id = objects.insert(folder=id_folder,
                                    foldername=name,
                                    tablename='cong_ty',
                                    table_id=form.vars.id,
                                    auth_group=8,
                                    process=3)

        link = name.replace('đ', 'd')
        link = '%s.html' % IS_SLUG.urlify(link)
        dcontent = cms.define_dcontent()
        dcontent.insert(folder=id_folder,
                        dtable='cong_ty',
                        table_id=form.vars.id,
                        link=link,
                        name=form.vars.name,
                        avatar=form.vars.avatar,
                        description=form.vars.description,
                        publish_on=request.now,
                        expired_on=None)
        cms.db(cong_ty.id == form.vars.id).update(link=link)
        redirect(URL(c='portal', f='folder', args=[name]))
    pass
    div.append(form)
示例#3
0
def hoi_dap():
	forlder_id = cms.get_folder(request.args(0))
	hoi_dap = cms.define_table(tablename ='hoi_dap',migrate=True)

	hoi_dap.folder.writable=False
	hoi_dap.folder.readable=False
	hoi_dap.folder.default=forlder_id 

	hoi_dap.avatar.writable=False
	hoi_dap.avatar.readable=False
	hoi_dap.avatar.default=' ' 

	hoi_dap.htmlcontent.writable=False
	hoi_dap.htmlcontent.readable=False

	from gluon.tools import Recaptcha
	public_key='6LdtT_YSAAAAALCH4vbHKl1yjqvhB80JZh1J21Lv'
	private_key='6LdtT_YSAAAAAI6XnBMNNWwSkJeSYtbP_-kW5HUH' ### provided by recaptcha.net

	from gluon.tools import Crud
	crud = Crud(cms.db)
	crud.settings.captcha =  Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'")
	form=crud.create(hoi_dap) 

	# form[0].insert(-1, TR('', Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'"))) 

	if form.process().accepted:
		
		from plugin_process import ProcessModel
		process = ProcessModel()
		objects = process.define_objects(True)
		log     = process.define_process_log(True)

		objects_id =objects.insert(folder=forlder_id ,tablename='hoi_dap',table_id=form.vars.id ,process=2)
		log.insert(objects=objects_id, process=2)
		response.flash=T('done!')
		# scr ='''<script type="text/javascript"> 
   				# setInterval("location.reload();",1000);
			# </script>'''
		# form.append(XML(scr))
	# if form.errors:
		# response.flash=T('Loi nhap du lieu!')
		# scr ='''<script type="text/javascript"> 
   				# setInterval("location.reload();",1000);
			# </script>'''
		# form.append(XML(scr))
	div = DIV(_id='hoi_dap')
	div.append(DIV(H2('Nhập câu hỏi',_class="title_box"),_class="tinlienquan"))
	div.append(form)
	response.view = 'layout/hoi_dap_13.html'
	return dict(content=div)
示例#4
0
def history():
    from plugin_process import ProcessModel
    processmodel = ProcessModel()
    auth = processmodel.auth
    db = processmodel.db
    query = (db.auth_event.id > 0)
    rows = db(query).select()
    content = DIV(_class='panel panel-default', _id='wrapper_history')
    content.append(DIV(A(SPAN(T('Lịch sử truy cập'))), _class='panel-heading'))
    table = TABLE(_class='table', _id='history')
    table.append(
        TR(TH(T('Stt'), _class='stt'), TH(T('User event'),
                                          _class='user_event'),
           TH(T('Content event'), _class='content_event'),
           TH(T('Time event'), _class='time_event'),
           TH(T('ip connect'), _class='ip_connect')))
    i = 1
    for row in rows:
        table.append(
            TR(TD(i), TD(row.user_id.last_name, ' ', row.user_id.first_name),
               TD(row.description), TD(row.time_stamp.strftime("%d/%m/%Y")),
               TD(row.client_ip)))
        i += 1
    input = A(T('Delete all history'),
              _href=URL(c='plugin_report', f='clear_all_history.load'),
              _class='btn btn-danger')
    content.append(DIV(input, _class='btn-group'))
    content.append(DIV(table))
    response.view = 'plugin_report/content.%s' % request.extension
    return dict(content=content)
示例#5
0
def list_user(folder_name):
    from plugin_process import ProcessModel
    db_auth = ProcessModel().db
    rows = db_auth((db_auth.auth_membership.group_id == db_auth.auth_group.id)
                   & (db_auth.auth_group.role == 'gian-hang-%s' %
                      (folder_name))).select()
    if len(rows) > 0:
        div = DIV(H2(T('Danh sách quản trị gian hàng')))
        table = TABLE(_class='table-bordered')
        table.append(
            TR(TH('Stt', _style='with:30px;'), TH(T('Họ tên')), TH(T('Email')),
               TH(T('Ngày tham gia'))))
        i = 1
        for row in rows:
            tr = TR()
            tr.append(TD(i))
            name = row.auth_membership.user_id.last_name + ' ' + row.auth_membership.user_id.first_name
            tr.append(
                TD(
                    A(name,
                      _href=URL(c='plugin_auth',
                                f='users.html',
                                args=[row.auth_membership.user_id]))))
            tr.append(TD(row.auth_membership.user_id.email))
            tr.append(TD(row.auth_membership.user_id.created_on))
            i += 1
            table.append(tr)
        div.append(table)
        return div
    else:
        return T('Chưa có người dùng.')
示例#6
0
def wr_user(folder_name):
    div = DIV(_class='row')
    div.append(
        DIV(A(T('Thêm người dùng'),
              _class='btn btn-danger',
              _href=URL(c='plugin_auth', f='users.html')),
            _class='col-md-12'))

    from plugin_process import ProcessModel
    db_auth = ProcessModel().db
    # rows = db_auth((db_auth.auth_user.auth_group==8)).select()
    # if len(rows)>0:
    # div2 = DIV(H2(T('Danh sách khách hàng')))
    # table = TABLE(_class='table-bordered')
    # table.append(TR(TH('Stt',_style='with:30px;'),TH(T('Họ tên')),TH(T('Email')),TH(T('Ngày tham gia'))))
    # i = 1
    # for row in rows:
    # tr = TR()
    # tr.append(TD(i))
    # name = row.last_name +' '+row.first_name
    # tr.append(TD(A(name)))
    # tr.append(TD(row.email))
    # tr.append(TD(row.created_on))
    # i+=1
    # table.append(tr)
    # div2.append(table)
    # div.append(DIV(div2,_class='col-md-5'))
    # div.append(DIV(A(T('Thêm vào'),SPAN(_class='glyphicon glyphicon-chevron-right'),_class='btn btn-default',_href=URL(c='plugin_auth',f='users.html')),_class='col-md-2'))
    div.append(DIV(list_user(folder_name), _class='col-md-12'))
    return div
示例#7
0
def clear_all_history():
    from plugin_process import ProcessModel
    processmodel = ProcessModel()
    auth = processmodel.auth
    db = processmodel.db
    db(db.auth_event.id > 0).delete()
    redirect(URL(c='plugin_report', f='history.html'))
示例#8
0
def add_gian_hang_admin():
    template = 'gian_hang.html'
    if request.vars.template:
        if request.vars.template == 't1':
            template = 'gian_hang1.html'
        elif request.vars.template == 't2':
            template = 'gian_hang.html'
        else:
            template = 'gian_hang2.html'
    name = request.vars.ten_gian_hang
    name = name.replace('đ', 'd')
    name = '%s' % IS_SLUG.urlify(name)
    folder = cms.define_folder()
    id = db.folder.insert(parent=241,
                          name=name,
                          label=request.vars.ten_gian_hang,
                          setting="{'TABLES':['tintuc','cong_ty','san_pham']}",
                          layout=template,
                          created_by=auth.user_id)
    try:
        from plugin_process import ProcessModel
        processmodel = ProcessModel()
        if id:
            cong_ty = cms.define_table('cong_ty')
            link = (request.vars.ten_gian_hang).replace('đ', 'd')
            link = '%s.html' % IS_SLUG.urlify(link)
            ct_id = db.cong_ty.insert(name=request.vars.ten_gian_hang,
                                      link=link,
                                      folder=id)
            if ct_id:
                objects = processmodel.define_objects()
                objects_id = objects.insert(folder=id,
                                            foldername=name,
                                            tablename='cong_ty',
                                            table_id=ct_id,
                                            auth_group=8,
                                            process=3)
                dcontent = cms.define_dcontent()
                dcontent.insert(folder=id,
                                dtable='cong_ty',
                                table_id=ct_id,
                                link=link,
                                name=request.vars.ten_gian_hang,
                                publish_on=request.now,
                                expired_on=None)
    except Exception, e:
        return e
示例#9
0
def thanh_vien_moi():
    import datetime
    div = DIV(_class="panel panel-default giao_dich")
    div.append(
        DIV(SPAN(T('Thành viên mới đăng ký'), _class='pull-left title_name'),
            SPAN(search_date(), _class='pull-right'),
            _class="panel-heading"))

    start_time = request.vars.start_time or datetime.datetime.now().strftime(
        "%Y-%m-%d 00:00:00")
    end_time = request.vars.end_time or datetime.datetime.now().strftime(
        "%Y-%m-%d 23:59:00")

    from plugin_process import ProcessModel
    processmodel = ProcessModel()
    auth = processmodel.auth
    db = processmodel.db

    query = db.auth_user.created_on >= start_time
    query &= db.auth_user.created_on <= end_time
    rows = db(query).select(orderby=~db.auth_user.id)

    table = TABLE(_class='table', _id='san_pham')
    table.append(
        TR(TH('STT', _style="width: 50px; text-align: center;"),
           TH(T('Tên thành viên ')), TH(T('Tài khoản')), TH(T('Email'))))
    i = 1
    for row in rows:
        table.append(
            TR(TD(i), TD(row.first_name + ' ' + row.last_name),
               TD(row.username), TD(row.email)))
        i += 1

    div_body = DIV(_class='panel-body')
    div_body.append(table)

    div_bottom = DIV(_class='input-group ')
    div_bottom.append(
        A('Xuất excel', _class='btn btn-success', _id='ex_button'))
    div_body.append(div_bottom)

    div.append(div_body)
    scr = '''<script type="text/javascript"> 
		$("#ex_button").click(function(){
			$("#san_pham").table2excel({
				exclude: ".noExl",
				name: "San pham ban nhieu"

			});
		});

  
	</script>'''
    div.append(XML(scr))

    response.view = 'plugin_report/content.%s' % request.extension
    return dict(content=div)
示例#10
0
def add_gian_hang():
    template = 'gian_hang.html'
    if request.vars.template:
        if request.vars.template == 't1':
            template = 'gian_hang1.html'
        elif request.vars.template == 't2':
            template = 'gian_hang.html'
        else:
            template = 'gian_hang2.html'
    name = request.vars.ten_url.lower()
    folder = cms.define_folder()
    id = db.folder.insert(parent=241,
                          name=name,
                          label=request.vars.ten_gian_hang,
                          setting="{'TABLES':['tintuc','cong_ty','san_pham']}",
                          layout=template,
                          created_by=auth.user_id)
    from plugin_process import ProcessModel
    processmodel = ProcessModel()
    role = 'gian-hang-' + str(name)
    group_id = processmodel.db.auth_group.insert(role=role,
                                                 parent=8,
                                                 atype='org',
                                                 created_by=1)
    processmodel.db.auth_permission.insert(group_id=group_id,
                                           name='quan_tri_gian_hang',
                                           table_name='folder',
                                           record_id=id)
    processmodel.db.auth_membership.insert(group_id=group_id,
                                           user_id=auth.user_id)

    auth_name = processmodel.db.auth_user[auth.user_id]

    mail = auth.setting_mail()
    mail.send(to=['*****@*****.**'],
              subject='Có 1 gian hàng mới: %s' % (request.vars.ten_gian_hang),
              message='Gian hàng: %s đã được khởi tạo bởi người dùng %s' %
              (request.vars.ten_gian_hang,
               (auth_name.first_name + ' ' + auth_name.last_name)))
    mail.send(
        to=[auth_name.email],
        subject='Bạn đã khởi tạo thành công gian hàng: %s' %
        (request.vars.ten_gian_hang),
        message=
        'Gian hàng: %s. Bạn vui lòng liên hệ ban quản trị để đăng ký duyệt gian hàng của bạn. Xin cảm ơn'
        % (request.vars.ten_gian_hang))

    redirect(URL(c='portal', f='folder', args=['tao-nha-cung-cap', id, name]))
示例#11
0
def act_delete_folder():
    if request.args(0):
        folder = cms.define_folder()
        folder_d = cms.db.folder[request.args(0)]
        name = folder_d.name
        id = cms.db(cms.db.folder.id == request.args(0)).delete()
        if id:
            from plugin_process import ProcessModel
            processmodel = ProcessModel()
            role = 'gian-hang-' + str(name)
            processmodel.db(
                (processmodel.db.auth_permission.record_id == request.args(0))
                &
                (processmodel.db.auth_permission.name == 'quan_tri_gian_hang')
                & (processmodel.db.auth_permission.table_name == 'folder')
            ).delete()
            processmodel.db(processmodel.db.auth_group.role == role).delete()
        response.flash = T('Xóa thành công.')
    scr = '''<script type="text/javascript">
			$('#exampleModal').modal('hide')
		</script>
		'''
    return XML(scr)
示例#12
0
def view_new():
    tin_tuc_id = request.vars.tin_tuc_id
    div = DIV(_class='col-md-12')
    folder_id_ivinh = folder_id_gian_hang.id
    if auth.has_permission('quan_tri_gian_hang', 'folder', folder_id_ivinh):
        name = request.args(0)
        from plugin_ckeditor import CKEditor

        if not tin_tuc_id:
            div.append(
                H2(SPAN('Thêm mới tin tức', _class='title_name'),
                   _id='title_page'))

        tin_tuc_edit = cms.define_table('tintuc')
        tin_tuc_edit.folder.default = folder_id_ivinh
        tin_tuc_edit.folder.writable = False
        tin_tuc_edit.folder.readable = False
        tin_tuc_edit.htmlcontent.widget = CKEditor(cms.db).widget

        form = SQLFORM(tin_tuc_edit, tin_tuc_id)
        if tin_tuc_id:
            ajax = "ajax('%s', [''], 'news_detail')" % (URL(
                c='plugin_app',
                f='act_delete',
                args=[request.args(0)],
                vars=dict(table_name='tintuc', table_id=tin_tuc_id)))
            form[0][-1] = TR(TD(INPUT(_type='submit', _value=T('Submit')),
                                INPUT(_type='button',
                                      _value=T('Xóa bài viết'),
                                      _onclick=ajax,
                                      _class='btn btn-danger'),
                                _colspan="3"),
                             _class='act_ivinh')
        if form.process().accepted:
            dcontent = cms.define_dcontent()
            if not tin_tuc_id:
                from plugin_process import ProcessModel
                objects = ProcessModel().define_objects()
                objects_id = objects.insert(folder=folder_id_ivinh,
                                            foldername=name,
                                            tablename='tintuc',
                                            table_id=form.vars.id,
                                            auth_group=7,
                                            process=3)

                link = form.vars.name.replace('đ', 'd')
                link = '%s.html' % IS_SLUG.urlify(link)

                from plugin_cms import CmsPublish
                link = CmsPublish().get_link('tintuc', link)

                dcontent.insert(folder=folder_id_ivinh,
                                dtable='tintuc',
                                table_id=form.vars.id,
                                link=link,
                                name=form.vars.name,
                                avatar=form.vars.avatar,
                                description=form.vars.description,
                                publish_on=request.now,
                                expired_on=None)
                cms.db(tin_tuc_edit.id == form.vars.id).update(link=link)

        div.append(form)
    return dict(content=div)
示例#13
0
def view_order():
    div = DIV(_id="view_order")
    div.append(DIV(list_order(), _id='wr_list_order'))
    from plugin_process import ProcessModel
    auth_login = ProcessModel().db.auth_user[auth.user_id]
    form = FORM()
    div1 = DIV(_class="form-group")
    div1.append(
        LABEL('Họ và tên', SPAN('(*)',
                                _style="color: #f00;margin-left: 5px;")))
    div1.append(
        INPUT(_id='ho_ten',
              _name='ho_ten',
              _type='text',
              _class="form-control",
              _placeholder="Họ và tên",
              _value=auth_login.last_name + ' ' +
              auth_login.first_name if auth_login else ''))
    form.append(div1)

    div1 = DIV(_class="form-group")
    div1.append(LABEL('Email'))
    div1.append(
        INPUT(_id='email',
              _name='email',
              _type='text',
              _class="form-control",
              _placeholder="Email",
              _value=auth_login.email if auth_login else ''))
    form.append(div1)

    div1 = DIV(_class="form-group")
    div1.append(
        LABEL('Điện thoại', SPAN('(*)',
                                 _style="color: #f00;margin-left: 5px;")))
    div1.append(
        INPUT(_id='dien_thoai',
              _name='dien_thoai',
              _type='text',
              _class="form-control integer",
              _placeholder="Điện thoại"))
    form.append(div1)

    div1 = DIV(_class="form-group")
    div1.append(
        LABEL('Địa chỉ nhận hàng',
              SPAN('(*)', _style="color: #f00;margin-left: 5px;")))
    div1.append(
        INPUT(_id='dia_chi',
              _name='dia_chi',
              _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(_id='loi_nhan',
                 _name='loi_nhan',
                 _class="form-control",
                 _rows="3",
                 _placeholder="Lời nhắn"))
    form.append(div1)

    div1 = DIV(_class="form-group")
    ul = UL(_class="pttt")
    ul.append(
        LI(INPUT(_value=1, _type="radio", _name='pttt', _checked=True),
           SPAN('Thanh toán khi nhận hàng')))
    div1.append(ul)
    form.append(div1)

    ajax = "ajax('%s', ['ho_ten','email','dien_thoai','dia_chi','loi_nhan','pttt'], 'order_view')" % (
        URL(c='plugin_sgd', f='act_add_cart', args=request.args))
    script = '''
	<script type="text/javascript">
		function check_form(){
		var result = check_form_cart();
		if (result==true) {
			%s
		}
	}
	function check_form_cart(){
		if (document.getElementById("ho_ten").value=='') {
			alert('Chưa nhập tên');
			document.getElementById("ho_ten").focus();
			return false;
	
		}
		if (document.getElementById("dien_thoai").value=='') {
			alert('Chưa nhập số điện thoại');
			document.getElementById("dien_thoai").focus();
			return false;
	
		}
		if (document.getElementById("dia_chi").value=='') {
			alert('Chưa nhập địa chỉ nhận hàng');
			document.getElementById("dia_chi").focus();
			return false;
	
		}
		
		else{
			return true;
		}
			
	}

	</script>''' % (ajax)
    form.append(
        A('Gửi đặt hàng', _onclick='check_form();', _class='btn btn-success'))
    div.append(form)
    div.append(XML(script))
    return div
示例#14
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 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
示例#15
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
示例#16
0
cms = Cms()

from plugin_ckeditor import CKEditor
CKEditor(cms.db).define_tables()

if request.controller in [
        'plugin_cms', 'portal', 'plugin_app', 'plugin_box', 'plugin_sgd',
        'plugin_folder', 'plugin_manager', 'plugin_report'
]:
    from plugin_process import ProcessModel
    db = cms.db
    cms.define_dcontent(False)
    cms.define_box(False)
    cms.define_folder(False)
    cms.define_rtable(False)
    auth = ProcessModel().auth
    folder_id_gian_hang = ''
    if auth.user_id:
        folder = cms.define_folder()
        db_auth = ProcessModel().db
        rows = db_auth(
            db_auth.auth_membership.user_id == auth.user_id).select()
        list_group = []
        for r in rows:
            list_group.append(r.group_id)

        if 3 in list_group:
            # from plugin_cms import CmsFolder
            # folder_id = CmsFolder().get_folder(request.args(0))
            folder_id = db(folder.name == request.args(0)).select().first()
        else:
示例#17
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_auth':
    from plugin_process import ProcessModel
    from plugin_cms import CmsModel
    process = ProcessModel()
    db = process.db
    auth = process.auth
    cms = CmsModel()