Пример #1
0
function write($_POST)
{
    # Get vars
    global $DOCLIB_DOCTYPES;
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # Validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($docid, "string", 1, 20, "Invalid document number.");
    # Display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # Connect to db
    db_conn("cubit");
    $docRs = get("cubit", "*", "documents", "docid", $docid);
    $doc = pg_feTch_array($docRs);
    # Write to db
    $sql = "DELETE FROM documents WHERE docid = '{$docid}' AND div = '" . USER_DIV . "'";
    $docRslt = db_exec($sql) or errDie("Unable to remove {$doc['docname']} from system.", SELF);
    if (pg_cmdtuples($docRslt) < 1) {
        return "<li class=err>Unable to remove {$doc['docname']} from Cubit.";
    }
    /*
    //new
    db_conn('cubit');
    */
    # write to db
    $Sql = "INSERT INTO document(typeid,typename,xin,docref,docdate,docname,filename,mimetype,descrip,docu,div)  VALUES ('{$doc['typeid']}', '{$doc['typename']}', '{$doc['xin']}', '{$doc['docref']}', '{$doc['docdate']}', '{$doc['docname']}', '{$doc['filename']}', '{$doc['mimetype']}', '{$doc['descrip']}', '{$doc['docu']}', '" . USER_DIV . "')";
    $Rslt = db_exec($Sql) or errDie("Unable to access database.");
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t<tr><th>Document removed</th></tr>\r\n\t\t<tr class=datacell><td>Document <b>{$doc['docname']}</b>, has been successfully removed from the system.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='tdocadd.php'>Add Document</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='tdocview.php'>View Documents</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
function write($_POST)
{
    # Get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # Validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($typeid, "string", 1, 20, "Invalid document type number.");
    # Display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    $doctRs = get("yr2", "*", "doctypes", "typeid", $typeid);
    $doct = pg_feTch_array($doctRs);
    # Write to db
    db_conn("yr2");
    $sql = "DELETE FROM doctypes WHERE typeid = '{$typeid}'";
    $dRslt = db_exec($sql) or errDie("Unable to remove {$doct['typename']} to system.", SELF);
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Document type removed</th></tr>\r\n\t<tr class=datacell><td>Document type <b>{$doct['typename']}</b>, has been successfully removed from the system.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='doctype-view.php'>View Document types</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Пример #3
0
function edit($VARS = array(), $errors = "")
{
    # Get vars
    global $DOCLIB_DOCTYPES;
    foreach ($VARS as $key => $value) {
        ${$key} = $value;
    }
    # Validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($docid, "string", 1, 20, "Invalid document number.");
    # Display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    if (!isset($typeid)) {
        $docRs = get("yr2", "*", "documents", "docid", $docid);
        $doc = pg_feTch_array($docRs);
        $xin = $doc['xin'];
        $typeid = $doc['typeid'];
        $docname = $doc['docname'];
        $docref = $doc['docref'];
        list($year, $mon, $day) = explode("-", $doc['docdate']);
        $descrip = $doc['descrip'];
    }
    # Extra in
    $xin = isset($xin) ? $xin : "";
    $xins = $xin;
    $xin = xin_gw($typeid, $xin);
    # Select Type
    db_conn("yr2");
    $typs = "<select name='typeid' onchange='document.form1.submit();'>";
    # User types
    $sql = "SELECT * FROM doctypes WHERE div = '" . USER_DIV . "' ORDER BY typename ASC";
    $typRslt = db_exec($sql);
    if (pg_numrows($typRslt) < 1) {
        if (preg_match("/\\d/", $typeid)) {
            $typeid = 'inv';
        }
        $xin = xin_gw($typeid, $xins);
    } else {
        while ($typ = pg_fetch_array($typRslt)) {
            $sel = "";
            if ($typ['typeid'] == $typeid) {
                $sel = "selected";
            }
            $typs .= "<option value='{$typ['typeid']}' {$sel}>({$typ['typeref']}) {$typ['typename']}</option>";
        }
    }
    # Built-in types
    foreach ($DOCLIB_DOCTYPES as $tkey => $val) {
        $sel = "";
        if ($tkey == $typeid) {
            $sel = "selected";
        }
        $typs .= "<option value='{$tkey}' {$sel}>{$DOCLIB_DOCTYPES[$tkey]}</option>";
    }
    $typs .= "</select>";
    $enter = "<h3>Edit Document</h3>\r\n\t<form name=form1 action='" . SELF . "' method=post>\r\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<input type=hidden name=key value=confirm>\r\n\t<input type=hidden name=docid value='{$docid}'>\r\n\t<tr><td colspan=2>{$errors}</td></tr>\r\n\t<tr><th>Field</th><th>Value</th></tr>\r\n\t<tr class='even'><td>Type</td><td>{$typs}</td></tr>\r\n\t{$xin}\r\n\t<tr class='odd'><td>Ref</td><td><input type=text size=10 name=docref value='{$docref}'></td></tr>\r\n\t<tr class='even'><td>Document Name</td><td><input type=text size=20 name=docname value='{$docname}'></td></tr>\r\n\t<tr class='odd'><td>Date</td><td><input type=text size=2 name=day maxlength=2  value='{$day}'>-<input type=text size=2 name=mon maxlength=2  value='{$mon}'>-<input type=text size=4 name=year maxlength=4 value='{$year}'></td></tr>\r\n\t<tr class='even'><td>Decription</td><td><textarea name=descrip rows=4 cols=18>{$descrip}</textarea></td></tr>\r\n\t<tr><td><br></td></tr>\r\n\t<tr><td colspan=2 align=right><input type=submit name=conf value='Confirm &raquo;'></td></tr>\r\n\t</table></form>";
    return $enter;
}
Пример #4
0
function write($_POST)
{
    # Get vars
    global $DOCLIB_DOCTYPES;
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # Validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($docid, "string", 1, 20, "Invalid document number.");
    # Display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # Connect to db
    db_conn("yr2");
    $docRs = get("yr2", "*", "documents", "docid", $docid);
    $doc = pg_feTch_array($docRs);
    # Connect to db
    db_conn("yr2");
    # Write to db
    $sql = "DELETE FROM documents WHERE docid = '{$docid}' AND div = '" . USER_DIV . "'";
    $docRslt = db_exec($sql) or errDie("Unable to remove {$doc['docname']} from system.", SELF);
    if (pg_cmdtuples($docRslt) < 1) {
        return "<li class=err>Unable to remove {$doc['docname']} from Cubit.";
    }
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t<tr><th>Document removed</th></tr>\r\n\t\t<tr class=datacell><td>Document <b>{$doc['docname']}</b>, has been successfully removed from the system.</td></tr>\r\n\t</table>";
    return $write;
}