Пример #1
0
def index():
    response.view = 'nas/index.html'
    response.subtitle = T("Home")
    gform = DIV(
        P("Nervatura NAS Admin", _style="font-weight: bold;"),
        P(SPAN(T("Username: "******"font-weight: bold;"),
          session.auth.user.username),
        P(SPAN("Ver.No: " + response.verNo, _class="vernum")),
        TABLE(
            TR(
                TD(IMG(_style="vertical-align: bottom;",
                       _src=URL('static', 'images/icon64_ntura_te.png')),
                   _style="width: 64px;padding-right: 0px;"),
                TD("OPEN SOURCE",
                   BR(),
                   "BUSINESS",
                   BR(),
                   "MANAGEMENT",
                   _style=
                   "width: 120px;color: #616161;vertical-align: middle;font-size: 13px;"
                   ))),
        P(
            A("©2011-2015 Nervatura Framework",
              _href="http://www.nervatura.com",
              _target="_blank",
              _title="Nervatura",
              _style="font-weight: bold;")),
        _align="center",
        _style="padding-top:30px;")
    return dict(form=gform)
Пример #2
0
def update():
    (db, table) = get_table(request)
    keyed = hasattr(db[table], '_primarykey')
    record = None
    if keyed:
        key = [f for f in request.vars if f in db[table]._primarykey]
        if key:
            record = db(
                db[table][key[0]] == request.vars[key[0]]).select().first()
    else:
        record = db(db[table].id == request.args(2)).select().first()

    if not record:
        qry = query_by_table_type(table, db)
        session.flash = T('record does not exist')
        redirect(URL('select', args=request.args[:1], vars=dict(query=qry)))

    if keyed:
        for k in db[table]._primarykey:
            db[table][k].writable = False

    form = SQLFORM(db[table],
                   record,
                   deletable=True,
                   delete_label=T('Check to delete'),
                   ignore_rw=ignore_rw and not keyed,
                   linkto=URL('select', args=request.args[:1]),
                   upload=URL(r=request, f='download', args=request.args[:1]))

    if form.accepts(request.vars, session):
        session.flash = T('done!')
        qry = query_by_table_type(table, db)
        redirect(URL('select', args=request.args[:1], vars=dict(query=qry)))
    return dict(form=form, table=db[table])
Пример #3
0
def createDatabase():
    if session.auth.user.username == "demo":
        return P(
            SPAN(T("Demo user: This action is not allowed!"),
                 _style="color:red;"))
    if request.vars.alias == None:
        return str(T("Error: Missing alias parameter!"))
    return P(dbtool.createDatabase(request.vars.alias))
Пример #4
0
def get_nom_data():
  if validator["valid"]:
    if request.vars.nom:
      fields_lst = create_fieldlist(request.vars.nom)
      return get_view_lst(request.vars.nom)+"||"+get_update_lst(fields_lst)+"||"+get_delete_lst(fields_lst)
    else:
      return T("Missing parameter")+"||"+T("Missing parameter")+"||"+T("Missing parameter")
  else:
    return validator["message"]+"||"+validator["message"]+"||"+validator["message"]
Пример #5
0
def index():
  response.title=T('NDI Wizard')
  response.subtitle=T('Data Interface Wizard')
  lst_nom = ["address","barcode","contact","currency","customer","deffield","employee","event","fieldvalue","groups","item","link",
         "log","movement","numberdef","pattern","payment","place","price","product","project","rate","tax","tool","trans","sql"]
  response.lst_nom = SELECT(*[OPTION(str(nom).upper(), _value=nom) for nom in lst_nom], _id="lst_nom", 
                            _size=len(lst_nom),_style="width: 100%;font-weight: bold;", 
                            _onchange="changeItem();setLabels(this.value.toUpperCase()+'"
                            +T(" fieldname and type values")+"','"+URL('ndr','getResource')+"?file_name=docs/ndi/ndi&content=view&lang=auto#'+this.value+'_fields');")
  return dict()
Пример #6
0
def get_table(request):
    db = get_database(request)
    if len(request.args) > 1 and request.args[1] in db.tables:
        return (db, request.args[1])
    else:
        session.flash = T('invalid request')
        redirect(URL('index'))
Пример #7
0
def get_delete_lst(fields_lst):
  rtable = TABLE(_style="width: 100%;")
  rtable.append(TR(TD(DIV(T("SELECT ROW"),_class="div_label",_style="color: #FFD700;"),_class="td_label",
                      _style="width: auto;border-bottom-style: double;border-width: 4px;border-color: #8B8B83;"),
         TD(SPAN("1",_class="div_label",_style=checklabel_style),
            INPUT(_type="checkbox",_value="on",_checked="checked",_disabled="disabled",_name="selrow",_id="row_1",_class="boolean", _style="vertical-align: middle;"),
            _class="td_input", _style=checkbox_style),
         TD(SPAN("2",_class="div_label",_style=checklabel_style),
            INPUT(_type="checkbox",_value="on",_name="selrow",_id="row_2",_class="boolean", _style="vertical-align: middle;"),
            _class="td_input", _style=checkbox_style),
         TD(SPAN("3",_class="div_label",_style=checklabel_style),
            INPUT(_type="checkbox",_value="on",_name="selrow",_id="row_3",_class="boolean", _style="vertical-align: middle;"),
            _class="td_input", _style=checkbox_style),
         TD(SPAN("4",_class="div_label",_style=checklabel_style),
            INPUT(_type="checkbox",_value="on",_name="selrow",_id="row_4",_class="boolean", _style="vertical-align: middle;"),
            _class="td_input", _style=checkbox_style),
         ))
  for field in fields_lst:
    if field["fieldcat"]==0:
      rtable.append(TR(TD(DIV(field["label"],_class="div_label"),_class="td_label",_style="width: auto;"),
         TD(field["widget"],_class="td_input", _style="width: auto;", _id="1"),
         TD(field["widget"],_class="td_input", _style="width: auto;", _id="2"),
         TD(field["widget"],_class="td_input", _style="width: auto;", _id="3"),
         TD(field["widget"],_class="td_input", _style="width: auto;", _id="4")
         ))
  return rtable
Пример #8
0
def createDataBackup():
    if request.vars.alias == None:
        return P(str(T("Error: Missing alias parameter!")))
    if request.vars.bformat:
        bformat = str(request.vars.bformat)
    else:
        bformat = "backup"
    if ns.local.setEngine(request.vars.alias, True, False) == False:
        if request.vars.filename == "download":
            session.flash = str(ns.error_message)
            redirect(URL("create_backup"))
        else:
            return P("Error: " + str(ns.error_message))
    retbc = dbtool.createDataBackup(alias=request.vars.alias,
                                    bformat=bformat,
                                    filename=request.vars.filename,
                                    verNo=response.verNo)
    if request.vars.filename == "download":
        if (not str(retbc).startswith("<span")) and (
                not str(retbc).startswith("<div")):
            import time
            response.headers['Content-Type'] = 'application/octet-stream'
            response.headers[
                'Content-Disposition'] = 'attachment;filename="' + str(
                    request.vars.alias) + '_' + time.strftime(
                        "%Y%m%d_%H%M") + '.' + bformat + '"'
            return retbc
        else:
            session.flash = str(retbc)
            redirect(URL("create_backup"))
    return P(retbc)
Пример #9
0
def exportToICalendar():
    if request.vars.code and request.vars.database and request.vars.username:
        if request.vars.code == "base64":
            if request.vars.password:
                password = base64.b64decode(request.vars.password)
            else:
                password = None
            validator = getLogin(base64.b64decode(request.vars.database),
                                 base64.b64decode(request.vars.username),
                                 password)
        else:
            if request.vars.password:
                password = request.vars.password
            else:
                password = None
            validator = getLogin(request.vars.database, request.vars.username,
                                 password)
        if validator["valid"] == False:
            return validator["message"]
    else:
        return T('Missing login parameter(s)!')

    if request.vars.calnumber:
        if request.vars.code == "base64":
            calnumber = base64.b64decode(request.vars.calnumber)
        else:
            calnumber = request.vars.calnumber
        events = ns.db(ns.db.event.calnumber == calnumber).select()
        if len(events) > 0:
            event_id = events[0]["id"]
        else:
            return T('Missing calnumber: ' + request.vars.calnumber)
    elif request.vars.event_id:
        if request.vars.code == "base64":
            event_id = base64.b64decode(request.vars.event_id)
        else:
            event_id = request.vars.event_id
    else:
        return T('Missing calnumber or event_id parameter!')
    if request.vars.alldata:
        export_fields = True
    else:
        export_fields = False
    response.headers['Content-Type'] = "text/ics"
    response.headers[
        'Content-Disposition'] = 'attachment;filename="NervaturaEvents.ics"'
    return dbout.exportToICalendar(event_id, export_fields)
Пример #10
0
def get_update_lst(fields_lst):
  rtable = TABLE(_style="width: 100%;")
  rtable.append(TR(
         TD(_style=checkbox_style2),
         TD(SPAN("1",_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-left:10px;padding-right:0px;"),
         TD(SPAN(T("ROW"),_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-left:0px;"),
         TD(SPAN("2",_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-right:0px;"),
         TD(SPAN(T("ROW"),_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-left:0px;"),
         TD(SPAN("3",_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-right:0px;"),
         TD(SPAN(T("ROW"),_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-left:0px;"),
         TD(SPAN("4",_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-right:0px;"),
         TD(SPAN(T("ROW"),_class="div_label",_style=checklabel_style),
            _class="td_input", _style=checkbox_style2+"padding-left:0px;")
         ))
  fieldcat=0
  for field in fields_lst:
    style="width: auto;vertical-align: middle;"
    if field["fieldcat"]==2:
      style += "font-style:italic;"
      if fieldcat<2:
        style+="border-top-style: double;border-width: 4px;border-color: #8B8B83;"
    fieldcat=field["fieldcat"]
    rtable.append(TR(
                     TD(DIV(field["label"],_class="div_label"),
                        _class="td_label",_style=style),
                     TD(INPUT(_type="checkbox",_value="on",_name="selfield",_id="select_"+field["fieldname"]+"_1",_class="boolean", 
                              _style="vertical-align: middle;"),_class="td_input", _style=style+"padding-right:0px;padding-left:10px;"),
                     TD(field["widget"],_class="td_input", _style=style+"padding-left:0px;", _id="1"),
                     TD(INPUT(_type="checkbox",_value="on",_name="selfield",_id="select_"+field["fieldname"]+"_2",_class="boolean", 
                              _style="vertical-align: middle;"),_class="td_input", _style=style+"padding-right:0px;padding-left:5px;"),
                     TD(field["widget"],_class="td_input", _style=style+"padding-left:0px;", _id="2"),
                     TD(INPUT(_type="checkbox",_value="on",_name="selfield",_id="select_"+field["fieldname"]+"_3",_class="boolean", 
                              _style="vertical-align: middle;"),_class="td_input", _style=style+"padding-right:0px;padding-left:5px;"),
                     TD(field["widget"],_class="td_input", _style=style+"padding-left:0px;", _id="3"),
                     TD(INPUT(_type="checkbox",_value="on",_name="selfield",_id="select_"+field["fieldname"]+"_4",_class="boolean", 
                              _style="vertical-align: middle;"),_class="td_input", _style=style+"padding-right:0px;padding-left:5px;"),
                     TD(field["widget"],_class="td_input", _style=style+"padding-left:0px;", _id="4")
       ))
  return rtable
Пример #11
0
def start():
  response.subtitle=T('Welcome')
  if session._language:
    view='default/start_'+str(session._language)+'.html'
    folder = request.folder
    filename = os.path.join(folder, 'views', view)
    if os.path.exists(filename):
      response.view=view
  return dict()
Пример #12
0
def getResource():
    if request.vars.file_name:
        rdir = str(request.vars.file_name).split("/")[0]
        if rdir == "backup":
            file_name = os.path.join(request.folder, 'static',
                                     str(request.vars.file_name))
        elif rdir in ("docs", "download", "report"):
            file_name = os.path.join(request.folder, 'static/resources',
                                     str(request.vars.file_name))
        else:
            return "Valid directories: docs, download, report"
        if request.vars.lang and session._language and session._language != "en":
            file_name += '_' + str(session._language)
        if request.vars.file_type:
            file_name += '.' + str(request.vars.file_type)
        else:
            file_name += '.html'
        if not os.path.isfile(file_name):
            if request.vars.lang and session._language and session._language != "en":
                file_name = str(file_name).replace(
                    '_' + str(session._language), "")
                if not os.path.isfile(file_name):
                    return T('Missing file...')
            else:
                return T('Missing file...')
        if request.vars.content:
            if request.vars.content == "view":
                response.view = "../" + file_name[file_name.find("static"):]
                return dict()
            elif request.vars.content == "xml":
                response.headers['Content-Type'] = 'text/xml'
            else:
                response.headers['Content-Type'] = request.vars.content
                if request.vars.file_type:
                    response.headers[
                        'Content-Disposition'] = 'attachment;filename="' + str(
                            request.vars.file_name).split('/')[
                                len(str(request.vars.file_name).split('/')) -
                                1] + '.' + str(request.vars.file_type) + '"'
        return read_file(file_name)
    else:
        return T('Missing document...')
Пример #13
0
def login():
    if DEMO_MODE:
        return ui.connect.show_disabled(response.title)
    response.view = 'nas/login.html'
    form = auth()
    if type(form).__name__ == "str" or type(form).__name__ == "lazyT":
        if type(form).__name__ == "str":
            session.flash = form
        form = auth.login()
    return dict(form=ui.control.set_input_form(
        form, submit_label=T("Login"), theme="b"))
Пример #14
0
def create_menu():
    ns_menu = []
    ns_menu.append((T('User Accounts'), False, URL("accounts"), []))
    ns_menu.append((T('Customer Databases'), False, URL("databases"), []))
    ns_menu_dbs = (T('Database Management'), False, None, [])
    ns_menu.append(ns_menu_dbs)
    ns_menu.append((T('Report templates'), False, URL("reports"), []))
    ns_menu.append((T('Server Settings'), False, URL("settings"), []))
    ns_menu.append((T('Change Password'), False, URL("change_password"), []))

    ns_menu_dbs[3].append(
        (T('Database Creation'), False, URL("create_db"), []))
    ns_menu_dbs[3].append(
        (T('Database Backup'), False, URL("create_backup"), []))
    ns_menu_dbs[3].append(
        (T('Restore the Database'), False, URL("restore_backup"), []))
    return ns_menu
Пример #15
0
def create_preview_img(ptype, keyname, title):
    if ptype == "button":
        cmd_preview = ui.control.get_mobil_button(T("Preview"),
                                                  href="#" +
                                                  keyname.replace("/", "_"),
                                                  cformat=None,
                                                  icon="info",
                                                  title=title,
                                                  theme="a",
                                                  rel="popup",
                                                  position="window",
                                                  transition="fade")
        ipath = 'static/resources/report'
    else:
        cmd_preview = A(IMG(_src=URL('static/resources/application/images',
                                     keyname + '_min.png'),
                            _title=title,
                            _alt=title),
                        _href="#" + keyname.replace("/", "_"))
        cmd_preview["_data-rel"] = "popup"
        cmd_preview["_data-position-to"] = "window"
        cmd_preview["_data-transition"] = "fade"
        ipath = 'static/resources/application/images'
    cmd_close = A(T("Close"), _href="#", _class="ui-btn-right")
    cmd_close["_data-rel"] = "back"
    cmd_close["_data-role"] = "button"
    cmd_close["_data-theme"] = "b"
    cmd_close["_data-icon"] = "delete"
    cmd_close["_data-iconpos"] = "notext"
    pop = DIV(cmd_close,
              DIV(title,
                  _style="font-weight: bold;padding-bottom:4px;",
                  _align="center"),
              IMG(_src=URL(ipath, keyname + '.png'), _title=title, _alt=title),
              _id=keyname.replace("/", "_"),
              _style="padding:10px;padding-top:5px;")
    pop["_data-role"] = "popup"
    pop["_data-overlay-theme"] = "b"
    pop["_data-theme"] = "b"
    pop["_data-corners"] = "true"
    return DIV(cmd_preview, pop, _style="padding-right:5px;")
Пример #16
0
def index():
  
  company_name = ns.valid.get_own_customer().custname
  customer_count_1 = len(ns.db((ns.db.customer.deleted==0)&(ns.db.customer.custtype!=ns.valid.get_groups_id("custtype", "own"))).select().as_list())
  customer_count_2 = ns.db.executesql(
    "select count(*) as rc from customer where deleted=0 and id not in(select customer.id from customer \
    inner join groups on customer.custtype=groups.id and groups.groupvalue='own')",as_dict = True)[0]["rc"]
  table = TABLE(TR(TD("Database company name: "+company_name)),
        TR(TD("Customer count 1: "+str(customer_count_1))),
        TR(TD("Customer count 2: "+str(customer_count_2))),
        TR(TD("Secret page: ",A(SPAN("Login"), _href=URL("secret_page"), _title=T("Login...")))))
  return table
Пример #17
0
def restoreDataBackup():
    if request.vars.database and request.vars.username:
        if request.vars.code == "base64":
            if request.vars.password:
                password = base64.b64decode(request.vars.password)
            else:
                password = ""
            username = base64.b64decode(request.vars.username)
            database = base64.b64decode(request.vars.database)
        else:
            if request.vars.password:
                password = request.vars.password
            else:
                password = None
            username = request.vars.username
            database = request.vars.database
        if not ns.db:
            if not ns.local.setEngine(database, True):
                if ns.error_message != "":
                    return str(ns.error_message)
                else:
                    return str(ns.T(
                        "Could not connect to the database: ")) + str(database)
        if not ns.connect.setLogin(username, password):
            if ns.error_message != "":
                return str(ns.error_message)
            else:
                return str(ns.T("Invalid user: "******"") and (request.vars.filename == None
                                              or request.vars.filename == ""):
        return T('Missing file parameter(s)!')
    if request.vars.filename:
        if request.vars.filename != "":
            return dbtool.loadBackupData(alias=database,
                                         filename=request.vars.filename)
    return dbtool.loadBackupData(alias=database, bfile=request.vars.bfile)
Пример #18
0
def create_db():
    response.subtitle = T("Database Creation")
    response.view = 'nas/index.html'
    alias = db(
        (db.databases.deleted == False)).select(db.databases.id,
                                                db.databases.alias,
                                                orderby=db.databases.alias)
    cmb_alias = SELECT(
        *[OPTION(field["alias"], _value=field["alias"]) for field in alias],
        _id="cmb_alias",
        _style="margin-top: 0px;")
    if len(cmb_alias) == 0:
        cmb_alias.insert(0, OPTION("", _value=""))
    gform = DIV(
        HR(),
        P(SPAN(T('1. Create a new database alias. See ')),
          A("Customer Databases",
            _href=URL("databases"),
            _style="color:#0069D6;font-style: italic;"),
          BR(),
          SPAN(
              T('2. The sqlite and Google SQL databases are created automatically.'
                )),
          BR(),
          SPAN(
              T('3. Other types of databases must be created manually before.')
          ),
          BR(),
          SPAN(T('4. Please select an alias, and start the creation:')),
          _style="font-style: italic;"),
        DIV(
            SPAN(T('Database alias:'),
                 _style="padding-right: 15px;padding-left: 15px;"), cmb_alias,
            P(SPAN(T('Starting the process?'),
                   _id="msg_result",
                   _style="font-style: italic;"),
              ui.control.get_mobil_button(label=T("Start"),
                                          href="#",
                                          onclick="createDatabase();",
                                          cformat=None,
                                          icon="check",
                                          theme="b",
                                          style="width: 100px;"),
              _style="padding-top: 0px;")),
        HR(),
        _style="font-weight: bold;",
        _align="left")
    return dict(form=gform)
Пример #19
0
def getLogin(database, username, password):
    validator = {}
    validator["valid"] = False
    validator["message"] = "OK"
    if ns.db == None:
        if ns.local.setEngine(database, True) == False:
            validator["valid"] = False
            if ns.error_message != "":
                validator["message"] = str(ns.error_message)
            else:
                validator["message"] = str(
                    T("Could not connect to the database: ") + database)
            return validator
    if ns.connect.setLogin(username, password) == False:
        validator["valid"] = False
        if ns.error_message != "":
            validator["message"] = str(ns.error_message)
        else:
            validator["message"] = str(T("Invalid user: "******"valid"] = True
    validator["message"] = "OK"
    return validator
Пример #20
0
def createDataBackup():
    if request.vars.database and request.vars.username:
        if request.vars.code == "base64":
            if request.vars.password:
                password = base64.b64decode(request.vars.password)
            else:
                password = ""
            username = base64.b64decode(request.vars.username)
            database = base64.b64decode(request.vars.database)
        else:
            if request.vars.password:
                password = request.vars.password
            else:
                password = None
            username = request.vars.username
            database = request.vars.database
        if not ns.db:
            if not ns.local.setEngine(database, True):
                if ns.error_message != "":
                    return str(ns.error_message)
                else:
                    return str(ns.T(
                        "Could not connect to the database: ")) + str(database)
        if not ns.connect.setLogin(username, password):
            if ns.error_message != "":
                return str(ns.error_message)
            else:
                return str(ns.T("Invalid user: "******"backup"

    retbc = dbtool.createDataBackup(alias=request.vars.database,
                                    bformat=bformat,
                                    filename=request.vars.filename,
                                    verNo=response.verNo)
    if request.vars.filename == "download":
        if (not str(retbc).startswith("<span")) and (
                not str(retbc).startswith("<div")):
            response.headers['Content-Type'] = 'application/octet-stream'
            response.headers[
                'Content-Disposition'] = 'attachment;filename="' + request.vars.database + '.' + bformat + '"'
    return retbc
Пример #21
0
def exportToReport():
    if request.vars.database and request.vars.username:
        if request.vars.code in ("base64", "base64all"):
            if request.vars.password:
                password = base64.b64decode(request.vars.password)
            else:
                password = None
            validator = getLogin(base64.b64decode(request.vars.database),
                                 base64.b64decode(request.vars.username),
                                 password)
        else:
            if request.vars.password:
                password = request.vars.password
            else:
                password = None
            validator = getLogin(request.vars.database, request.vars.username,
                                 password)
        if validator["valid"] == False:
            return validator["message"]
    else:
        return T('Missing login parameter(s)!')
    params = {}
    filters = {}
    if request.vars.reportcode:
        if request.vars.code in ("base64", "base64all"):
            params["reportcode"] = base64.b64decode(request.vars.reportcode)
        else:
            params["reportcode"] = request.vars.reportcode
    elif request.vars.report_id:
        if request.vars.code in ("base64", "base64all"):
            params["report_id"] = base64.b64decode(request.vars.report_id)
        else:
            params["report_id"] = request.vars.report_id
    else:
        return T('Missing reportcode or report_id parameter!')
    if request.vars.filters:
        if request.vars.code in ("base64", "base64all"):
            filters = getParamList(base64.b64decode(request.vars.filters))[0]
        else:
            filters = getParamList(request.vars.filters)[0]
    else:
        return T('Missing filters parameter!')

    if request.vars.output:
        if request.vars.code in ("base64", "base64all"):
            params["output"] = base64.b64decode(request.vars.output)
        else:
            params["output"] = request.vars.output
    else:
        params["output"] = "html"

    if request.vars.orientation:
        if request.vars.code in ("base64", "base64all"):
            params["orientation"] = base64.b64decode(request.vars.orientation)
        else:
            params["orientation"] = request.vars.orientation
    else:
        params["orientation"] = "P"

    if request.vars.size:
        if request.vars.code in ("base64", "base64all"):
            params["size"] = base64.b64decode(request.vars.size)
        else:
            params["size"] = request.vars.size
    else:
        params["size"] = "A4"

    if params["output"] == "printer":
        if not request.vars.printername:
            return T('Missing printername parameter!')
        printer_prop = dbout.check_printer(request.vars.printername)
        if printer_prop["state"] == False:
            return printer_prop["error_message"]
        params["output"] = "pdf"
        if request.vars.copies:
            try:
                copies = int(request.vars.copies)
            except:
                copies = 1
        else:
            copies = 1
    else:
        printer_prop = None

    report_tmp = dbout.getReport(params, filters)
    if type(report_tmp).__name__ == "str":
        if report_tmp == "NODATA":
            return HTML(
                HEAD(
                    TITLE("Nervatura Report"),
                    LINK(_rel="shortcut icon",
                         _href=URL('static', 'favicon.ico'),
                         _type="image/x-icon")),
                BODY(
                    DIV(CENTER(
                        TABLE(TR(
                            TD(IMG(
                                _src=URL('static', 'images/nodata.png'),
                                _style="border: solid;border-color: #FFFFFF;"),
                               _style=
                               "text-align: center;vertical-align: middle;font-weight: bold;font-family: sans-serif;font-size: 20px;"
                               )),
                              _style=
                              "background-color:#FFFFFF;color:#444444;margin-top:200px;"
                              )),
                        _style="width:100%;height:100%")),
                _style="background-color:#000000;")
        else:
            return report_tmp

    if printer_prop:
        print_item = dbout.printReport(printer_prop, report_tmp["template"],
                                       "Nervatura Report", copies,
                                       params["orientation"], params["size"])
        if print_item["state"] == False:
            return print_item["error_message"]
        return "OK"
    elif report_tmp["filetype"] == "ntr":
        if params["output"] == "xml":
            response.headers['Content-Type'] = 'text/xml'
        elif params["output"] == "pdf":
            response.headers['Content-Type'] = 'application/pdf'
        if request.vars.code == "base64all":
            return base64.b64encode(report_tmp["template"])
        else:
            return report_tmp["template"]
    elif report_tmp["filetype"] == "xls":
        response.headers['Content-Type'] = "application/vnd.ms-excel"
        response.headers[
            'Content-Disposition'] = 'attachment;filename="NervaturaReport.xls"'
        if request.vars.code == "base64all":
            return base64.b64encode(report_tmp["template"])
        else:
            return report_tmp["template"]
    elif report_tmp["filetype"] == "html":
        response.view = "default/report.html"
        response.title = report_tmp["data"]["title"]
        response.subtitle = ""
        import StringIO
        report_tmp["template"] = response.render(
            StringIO.StringIO(report_tmp["template"]), report_tmp["data"])
        return dict(template=XML(report_tmp["template"]))
    else:
        if request.vars.code == "base64all":
            return base64.b64encode(report_tmp["template"])
        else:
            return report_tmp["template"]
Пример #22
0
def licenses2():
  response.nomenu = True
  response.view='default/licenses.html'
  response.subtitle=T('License Agreement')
  return dict()
Пример #23
0
def get_database(request):
    if request.args and request.args[0] in databases:
        return eval_in_global_env(request.args[0])
    else:
        session.flash = T('invalid request')
        redirect(URL('index'))
Пример #24
0
def about():
  response.subtitle=T('About')
  return dict()
Пример #25
0
def licenses():
  response.subtitle=T('License Agreement')
  return dict()
Пример #26
0
def ndoc():
  response.subtitle=T('Docs & Resources')
  return dict()
Пример #27
0
def insert():
    (db, table) = get_table(request)
    form = SQLFORM(db[table], ignore_rw=ignore_rw)
    if form.accepts(request.vars, session):
        response.flash = T('new record inserted')
    return dict(form=form, table=db[table])
Пример #28
0
def user():
  table = TABLE(TR(TD("Back to home: ",A(SPAN("HOME"), _href=URL("index"), _title=T("HOME")))),
                TR(TD(auth())))
  return table
Пример #29
0
def secret_page():
  table = TABLE(TR(TD("Back to home: ",A(SPAN("HOME"), _href=URL("index"), _title=T("HOME")))),
                TR(TD("Change password: "******"Change password"), _href=URL("user/change_password"), _title=T("Change password...")))),
                TR(TD("Logout: ",A(SPAN("Exit"), _href=URL("user/logout"), _title=T("Logout...")))))
  return table
Пример #30
0
def select():
    import re
    db = get_database(request)
    dbname = request.args[0]
    regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>\d+)')
    if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'):
        regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>.+)')
    if request.vars.query:
        match = regex.match(request.vars.query)
        if match:
            request.vars.query = '%s.%s.%s==%s' % (
                request.args[0], match.group('table'), match.group('field'),
                match.group('value'))
    else:
        request.vars.query = session.last_query
    query = get_query(request)
    if request.vars.start:
        start = int(request.vars.start)
    else:
        start = 0
    nrows = 0
    stop = start + 100
    table = None
    rows = []
    orderby = request.vars.orderby
    if orderby:
        orderby = dbname + '.' + orderby
        if orderby == session.last_orderby:
            if orderby[0] == '~':
                orderby = orderby[1:]
            else:
                orderby = '~' + orderby
    session.last_orderby = orderby
    session.last_query = request.vars.query
    form = FORM(TABLE(
        TR(
            T('Query:'), '',
            INPUT(_style='width:400px',
                  _name='query',
                  _value=request.vars.query or '',
                  requires=IS_NOT_EMPTY(error_message=T("Cannot be empty")))),
        TR(
            T('Update:'),
            INPUT(_name='update_check', _type='checkbox', value=False),
            INPUT(_style='width:400px',
                  _name='update_fields',
                  _value=request.vars.update_fields or '')),
        TR(
            T('Delete:'),
            INPUT(_name='delete_check',
                  _class='delete',
                  _type='checkbox',
                  value=False), ''),
        TR('', '', INPUT(_type='submit', _value='submit'))),
                _action=URL(r=request, args=request.args))
    if request.vars.csvfile != None:
        try:
            import_csv(db[request.vars.table], request.vars.csvfile.file)
            response.flash = T('data uploaded')
        except Exception, e:
            response.flash = DIV(T('unable to parse csv file'), PRE(str(e)))