本文整理汇总了PHP中pg_cmdtuples函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_cmdtuples函数的具体用法?PHP pg_cmdtuples怎么用?PHP pg_cmdtuples使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_cmdtuples函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_messages
function list_messages()
{
global $_GET;
$Display = "";
$PDisplay = "";
if (isset($_GET["key"]) && isset($_GET["id"])) {
// if we should read, read
if ($_GET["key"] == "view") {
$rslt = db_exec("\r\n\t\t\t\tSELECT sender, message, EXTRACT(month from timesent) as month, \r\n\t\t\t\t\tEXTRACT(day from timesent) as day, EXTRACT(year from timesent) as year, \r\n\t\t\t\t\tEXTRACT(hour from timesent) as hour, EXTRACT(minute from timesent) as minute \r\n\t\t\t\tFROM req \r\n\t\t\t\tWHERE id='{$_GET['id']}'");
if (pg_num_rows($rslt) > 0) {
$row = pg_fetch_array($rslt);
$time = date("j F, Y - H:i", mktime($row["hour"], $row["minute"], 0, $row["month"], $row["day"], $row["year"]));
$PDisplay .= "\r\n\t\t\t\t\t<h3>Output</h3>\r\n\t\t\t\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td width='50'>Sender</td>\r\n\t\t\t\t\t\t\t<td width='200'>{$row['sender']}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td width='50'>Time Sent:</td>\r\n\t\t\t\t\t\t\t<td width='200'>{$time}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td width='50'>Message:</td>\r\n\t\t\t\t\t\t\t<td width='200'>{$row['message']}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t\t<br>";
// mark as read
db_exec("UPDATE req SET viewed='1' WHERE id='{$_GET['id']}'");
}
}
// if we should delete... delete
if ($_GET["key"] == "del") {
$rslt = db_exec("DELETE FROM req WHERE id='{$_GET['id']}'");
if (pg_cmdtuples($rslt) > 0) {
$PDisplay .= "<h3>Output</h3>Message Successfully Deleted.<br><br>";
}
}
}
$user = USER_NAME;
// clear the message notify que
db_exec("DELETE FROM req_new WHERE for_user='{$user}' ");
db_exec("UPDATE req SET alerted='1' WHERE recipient='{$user}'");
// $dep =USER_DPT;
db_conn('cubit');
$n = 0;
$Sql = "\r\n\t\tSELECT id,sender,message,reference, \r\n\t\t\tEXTRACT(month from timesent) as month,\r\n\t\t\tEXTRACT(day from timesent) as day, \r\n\t\t\tEXTRACT(year from timesent) as year,viewed\r\n\t\tFROM req \r\n\t\tWHERE recipient='{$user}' ORDER BY timesent";
$Exs = db_exec($Sql) or errDie("Unable to select cases from database.");
if (pg_numrows($Exs) < 1) {
return "\r\n\t\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th>No Outstanding Messages</th>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr class='odd'>\r\n\t\t\t\t\t<td>You have no outstanding messages</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t<p><p>\r\n\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th>Quick Links</th>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr class='even'>\r\n\t\t\t\t\t<td><a href='req_gen.php'>Add Message</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr class='odd'>\r\n\t\t\t\t\t<td><a href='../doc-index.php'>Main Menu</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t<table>";
}
while ($depts = pg_fetch_array($Exs)) {
$Date = date("j F, Y", mktime(0, 0, 0, $depts["month"], $depts["day"], $depts["year"]));
$n = $n + 1;
$msgid = $depts['id'];
// created the new msg cell data
if ($depts["viewed"] == '0') {
$newmsg = "<li> </li>";
} else {
$newmsg = " ";
}
$Display .= "\r\n\t\t\t\t<tr class='even'>\r\n\t\t\t\t\t<td align='center'>{$newmsg}</td>\r\n\t\t\t\t\t<td>{$Date}</td><td>{$depts['sender']}</td>\r\n\t\t\t\t\t<td>{$depts['message']}</td>\r\n\t\t\t\t\t<td><a href='" . SELF . "?key=view&id={$msgid}'>view</a> / <a href='" . SELF . "?key=del&id={$msgid}'>delete</a></td>\r\n\t\t\t\t</tr>";
}
$list_messages = "\r\n\t\t{$PDisplay}\r\n\t\t<h3>Messages for {$user}</h3>\r\n\t\t<br>\r\n\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>New</th>\r\n\t\t\t\t<th>Date sent</th>\r\n\t\t\t\t<th>From</th>\r\n\t\t\t\t<th>Details</th>\r\n\t\t\t\t<th>Option</th>\r\n\t\t\t</tr>\r\n\t\t\t{$Display}\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='7' align='right'>Total messages: {$n}</th>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t<p>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Quick Links</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='even'>\r\n\t\t\t\t<td><a href='req_gen.php'>Add Message</a></td>\r\n\t\t\t</tr>\r\n\t\t</table>";
return $list_messages;
}
示例2: remPaye
function remPaye($_POST)
{
# clean vars
$id = preg_replace("/[^\\d]/", "", substr($_POST["id"], 0, 9));
# connect to db
db_connect();
# remove job
$sql = "DELETE FROM paye WHERE id='{$id}'";
$payeRslt = db_exec($sql) or errDie("Unable to remove PAYE bracket.", SELF);
if (pg_cmdtuples($payeRslt) < 1) {
return "Failed to delete PAYE bracket.";
}
$remPaye = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>PAYE bracket removed</th></tr>\r\n\t<tr class=datacell><td>PAYE bracket has been successfully removed.</td></tr>\r\n\t</table>";
return $remPaye;
}
示例3: postmemory
//ALTERA A SENHA QUANDO JÁ EXISTE CADASTRO
if (isset($HTTP_POST_VARS["alt_senha"])) {
postmemory($HTTP_POST_VARS);
if ($senha_c1 == '' || $senha_c2 == '') {
msgbox('Nova senha não pode ser em branco.');
redireciona("digitafornecedor.php");
exit;
}
$result = @db_query("select senha from db_usuarios where senha = '{$senha}' ");
if (@pg_num_rows($result) == 0) {
msgbox("ERRO: Senha Inválida.");
redireciona("digitafornecedor.php");
exit;
}
$result = @db_query("update db_usuarios set senha = '" . Encriptacao::encriptaSenha($senha_c1) . "' where login = '{$cgccpf}'") or die(@pg_errormessage());
if (@pg_cmdtuples($result) > 0) {
db_logs("", "", 0, "Solicitação de senha: senha alterada: {$cgccpf}");
msgbox("Senha Alterada com sucesso");
redireciona("digitafornecedor.php");
exit;
} else {
db_logs("", "", 0, "Solicitação de senha: erro alterando senha: {$cgccpf}");
}
//MANDA UM E-MAIL DE CONFIRMAÇÃO
} else {
if (isset($HTTP_POST_VARS["cria_senha"])) {
postmemory($HTTP_POST_VARS);
if ($email == "") {
msgbox("Email em branco");
redireciona("digitafornecedor.php");
exit;
示例4: simpleQuery
/**
* Send a query to PostgreSQL and return the results as a
* PostgreSQL resource identifier.
*
* @param $query the SQL query
*
* @return int returns a valid PostgreSQL result for successful SELECT
* queries, DB_OK for other successful queries. A DB error code
* is returned on failure.
*/
function simpleQuery($query)
{
$ismanip = DB::isManip($query);
$this->last_query = $query;
$query = $this->modifyQuery($query);
if (!$this->autocommit && $ismanip) {
if ($this->transaction_opcount == 0) {
$result = @pg_exec($this->connection, 'begin;');
if (!$result) {
return $this->pgsqlRaiseError();
}
}
$this->transaction_opcount++;
}
$result = @pg_exec($this->connection, $query);
if (!$result) {
return $this->pgsqlRaiseError();
}
// Determine which queries that should return data, and which
// should return an error code only.
if ($ismanip) {
$this->affected = @pg_cmdtuples($result);
return DB_OK;
} elseif (preg_match('/^\\s*\\(?\\s*(SELECT(?!\\s+INTO)|EXPLAIN|SHOW)\\s/si', $query)) {
/* PostgreSQL commands:
ABORT, ALTER, BEGIN, CLOSE, CLUSTER, COMMIT, COPY,
CREATE, DECLARE, DELETE, DROP TABLE, EXPLAIN, FETCH,
GRANT, INSERT, LISTEN, LOAD, LOCK, MOVE, NOTIFY, RESET,
REVOKE, ROLLBACK, SELECT, SELECT INTO, SET, SHOW,
UNLISTEN, UPDATE, VACUUM
*/
$this->row[(int) $result] = 0;
// reset the row counter.
$numrows = $this->numrows($result);
if (is_object($numrows)) {
return $numrows;
}
$this->num_rows[(int) $result] = $numrows;
$this->affected = 0;
return $result;
} else {
$this->affected = 0;
return DB_OK;
}
}
示例5: write
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='« 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;
}
示例6: write_req
function write_req($_POST)
{
global $_SESSION;
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
$user = $_SESSION["USER_NAME"];
# validate input
require_lib("validate");
$v = new validate();
if (!isset($to)) {
$v->addError("", "No user specified");
} else {
foreach ($to as $arr => $arrval) {
$v->isOk($arrval, "string", 1, 200, "Invalid recipient: {$arrval}");
}
}
$v->isOk($des, "string", 1, 200, "Invalid description.");
$v->isOk($user, "string", 1, 200, "Invalid user.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class=err>" . $e["msg"];
}
return "{$confirmCust}</li></li>" . get_req();
}
$id += 0;
$date = date("Y-m-d");
$time = date("H:i:s");
db_conn('cubit');
if (in_array("_ALL_", $to)) {
$to = "";
$rslt = db_exec("SELECT username FROM users");
// if users found
if (pg_num_rows($rslt) > 0) {
while ($row = pg_fetch_array($rslt)) {
$to[] = $row["username"];
}
}
}
# write to db
// create the list of users the messages should get sent to
$msg_results = "";
foreach ($to as $arr => $arrval) {
db_conn('cubit');
$Sql = "INSERT INTO req (sender, recipient, message, timesent, viewed)\r\n\t\t\tVALUES ('{$user}','{$arrval}','{$des}',CURRENT_TIMESTAMP, 0)";
$Rslt = db_exec($Sql) or errDie("Unable to add to database.", SELF);
if (pg_cmdtuples($Rslt) < 1) {
return "Unable to access database.";
} else {
// if it isn't noticed that person has new messages, notify him
$rslt = db_exec("SELECT * from req_new WHERE for_user='{$arrval}' ");
if (pg_num_rows($rslt) == 0) {
db_exec("INSERT INTO req_new VALUES('{$arrval}')");
}
$msg_results .= "<tr class=datacell><td>Your message has been sent to {$arrval}</td></tr>";
}
db_conn('crm');
$Sl = "INSERT INTO token_actions (token,action,donedate,donetime,doneby,donebyid)\r\n\t\tVALUES ('{$id}','Sent message to {$arrval}','{$date}','{$time}','" . USER_NAME . "','" . USER_ID . "')";
$Ry = db_exec($Sl) or errDie("Unable to insert query action.");
}
$OUTPUT .= "<script> window.opener.parent.mainframe.location.reload(); window.close(); </script>";
return $OUTPUT;
$write_req = "\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Message proccessed</th></tr>\r\n\t{$msg_results}\r\n\t</table>";
return $write_req;
}
示例7: isset
// Need to figure out a way to determine whether the primary key for the table has been selected
// If not, then we need to pull it in. This is for use with the actions.
// }
$pri_keys[] = $my_pri_key;
}
$sql_query = isset($sql_query) ? stripslashes($sql_query) : '';
$sql_order = isset($sql_order) ? stripslashes($sql_order) : '';
if (!($result = @pg_exec($link, pre_query($sql_query . $sql_order)))) {
include "header.inc.php";
pg_die(pg_errormessage($link), $sql_query . $sql_order, __FILE__, __LINE__);
}
$num_rows = @pg_numrows($result);
}
if ($num_rows < 1 || $rel_type == "sequence" && eregi($sql_query, "setval")) {
if (eregi("delete|insert|update", $sql_query)) {
$affected_rows = @pg_cmdtuples($result);
} else {
unset($affected_rows);
}
if (file_exists("./{$goto}")) {
include "header.inc.php";
if (isset($zero_rows) && !empty($zero_rows)) {
$message = $zero_rows;
} else {
$message = $strEmptyResultSet;
}
include preg_replace('/\\.\\.*/', '.', $goto);
} else {
$message = $zero_rows;
Header("Location: {$goto}");
}
示例8: remPaye
function remPaye($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($id, "num", 1, 20, "Invalid PAYE ID.");
# 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='« Correct submission'>";
return $confirmCust;
}
# connect to db
db_connect();
# remove job
$sql = "DELETE FROM paye WHERE id='{$id}'";
$payeRslt = db_exec($sql) or errDie("Unable to remove PAYE bracket.", SELF);
if (pg_cmdtuples($payeRslt) < 1) {
return "Failed to delete PAYE bracket.";
}
$remPaye = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>PAYE bracket removed</th></tr>\n<tr class=datacell><td>PAYE bracket has been successfully removed.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
return $remPaye;
}
示例9: sql_affectedrows
function sql_affectedrows($query_id = 0)
{
if (!$query_id) {
$query_id = $this->query_result;
}
return $query_id ? @pg_cmdtuples($query_id) : false;
}
示例10: write
function write($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($accno, "string", 1, 20, "Invalid Account number.");
$v->isOk($surname, "string", 0, 255, "Invalid surname/company.");
$v->isOk($title, "string", 0, 10, "Invalid title.");
$v->isOk($init, "string", 0, 10, "Invalid initials.");
$v->isOk($firstname, "string", 0, 255, "Invalid Customer name.");
$v->isOk($catid, "num", 1, 255, "Invalid Category.");
$v->isOk($clasid, "num", 1, 255, "Invalid Classification.");
$v->isOk($paddr, "string", 0, 255, "Invalid Postal Address.");
$v->isOk($daddr, "string", 0, 255, "Invalid Delivery Address.");
$v->isOk($contname, "string", 0, 255, "Invalid contact name.");
$v->isOk($bustel, "string", 1, 20, "Invalid Bussines telephone.");
$v->isOk($hometel, "string", 1, 20, "Invalid Home telephone.");
$v->isOk($cellno, "string", 0, 20, "Invalid Cell number.");
$v->isOk($faxno, "string", 0, 20, "Invalid Fax number.");
$v->isOk($email, "email", 0, 255, "Invalid email name.");
$v->isOk($saleterm, "num", 1, 20, "Invalid Sale Term.");
$v->isOk($traddisc, "float", 0, 20, "Invalid trade discount.");
$v->isOk($setdisc, "float", 0, 20, "Invalid settlement discount.");
$v->isOk($listid, "num", 1, 20, "Invalid price list.");
$v->isOk($chrgint, "float", 0, 20, "Invalid Charge interest.");
$v->isOk($overdue, "float", 0, 20, "Invalid overdue.");
$v->isOk($chrgvat, "string", 1, 4, "Invalid charge vat.");
$v->isOk($vatinc, "string", 1, 3, "Invalid vat inclusive selection.");
$v->isOk($credterm, "num", 0, 20, "Invalid Credit term.");
$v->isOk($odate, "date", 1, 14, "Invalid account open date.");
$v->isOk($credlimit, "float", 0, 20, "Invalid credit limit.");
$v->isOk($block, "string", 1, 3, "Invalid Block acc selection.");
# 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='« Correct submission'>";
return $confirmCust;
}
# connect to db
db_conn("toms");
# fix numeric
$saleterm += 0;
$traddisc += 0;
$setdisc += 0;
$listid += 0;
$chrgint += 0;
$overdue += 0;
$credterm += 0;
$credlimit += 0;
# write to db
$sql = "INSERT INTO customers(accno, surname, title, init, firstname, category, class, paddr, daddr, contname, bustel, hometel, cellno, faxno, email, saleterm, traddisc, setdisc, pricelist, chrgint, overdue, chrgvat, vatinc, credterm, odate, credlimit, blocked)\r\n\tVALUES ('{$accno}', '{$surname}', '{$title}', '{$init}', '{$firstname}', '{$catid}', '{$clasid}', '{$paddr}', '{$daddr}', '{$contname}', '{$bustel}', '{$hometel}', '{$cellno}', '{$faxno}', '{$email}', '{$saleterm}', '{$traddisc}', '{$setdisc}', '{$listid}', '{$chrgint}', '{$overdue}', '{$chrgvat}', '{$vatinc}', '{$credterm}', '{$odate}', '{$credlimit}', '{$block}')";
$custRslt = db_exec($sql) or errDie("Unable to add fringe benefit to system.", SELF);
if (pg_cmdtuples($custRslt) < 1) {
return "<li class=err>Unable to add customer to database.";
}
$write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Customer added to system</th></tr>\r\n\t<tr class=datacell><td>New Customer <b>{$firstname} {$surname}</b>, has been successfully added to 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<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='cust-view.php'>View Customers</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='index.php'>Index</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='toms-settings.php'>Settings</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
return $write;
}
示例11: write
function write($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($grpid, "num", 1, 50, "Invalid Asset Group id.");
$v->isOk($grpname, "string", 1, 255, "Invalid Asset Group name or Asset Group name is too long.");
# 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='« Correct submission'>";
return $confirmCust;
}
# connect to db
db_connect();
# write to db
$sql = "UPDATE assetgrp SET grpname = '{$grpname}' WHERE grpid = '{$grpid}' AND div = '" . USER_DIV . "'";
$grpRslt = db_exec($sql) or errDie("Unable to add edit Asset Group to system.", SELF);
if (pg_cmdtuples($grpRslt) < 1) {
return "<li class=err>Unable to edit Asset Group to database.";
}
$write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Asset Group edited</th></tr>\r\n\t<tr class=datacell><td>Asset Group <b>{$grpname}</b>, has been edited.</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='assetgrp-new.php'>Add Asset Group</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='assetgrp-view.php'>View Asset Groups</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;
}
示例12: write
function write($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($classcode, "string", 1, 255, "Invalid Classification code.");
$v->isOk($classname, "string", 1, 255, "Invalid Classification name.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirmCust;
}
# check stock code
db_connect();
$sql = "SELECT classcode FROM stockclass WHERE lower(classcode) = lower('{$classcode}') AND div = '" . USER_DIV . "'";
$cRslt = db_exec($sql);
if (pg_numrows($cRslt) > 0) {
$error = "<li class='err'> A Classification with code : <b>{$classcode}</b> already exists.</li>";
$error .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $error;
}
# connect to db
db_connect();
# write to db
$sql = "INSERT INTO stockclass(classcode, classname, div) VALUES ('{$classcode}', '{$classname}', '" . USER_DIV . "')";
$catRslt = db_exec($sql) or errDie("Unable to add class to system.", SELF);
if (pg_cmdtuples($catRslt) < 1) {
return "<li class='err'>Unable to add classname to database.</li>";
}
if (frmupdate_passon()) {
$newlst = new dbSelect("stockclass", "cubit", grp(m("cols", "clasid, classname"), m("where", "div='" . USER_DIV . "'"), m("order", "classname ASC")));
$newlst->run();
$a = array();
if ($newlst->num_rows() > 0) {
while ($row = $newlst->fetch_array()) {
$a[$row["clasid"]] = $row["classname"];
}
}
$js = frmupdate_exec(array($a), true);
} else {
$js = "";
}
$write = "\n\t\t\t\t{$js}\n\t\t\t\t<table " . TMPL_tblDflts . " width='50%'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Classification added to system</th>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>New Classification <b>{$classname}</b>, has been successfully added to the system.</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t<p>\n\t\t\t\t<table border=0 cellpadding='2' cellspacing='1'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td><a href='stockclass-view.php'>View Classifications</a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td><a href='main.php'>Main Menu</a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>";
return $write;
}
示例13: write
function write($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($listname, "string", 1, 255, "Invalid Price list name.");
if (isset($stkids)) {
foreach ($stkids as $key => $value) {
$v->isOk($stkids[$key], "num", 1, 20, "Invalid Stock Item number.");
$v->isOk($prices[$key], "float", 1, 20, "Invalid Stock Item price.");
}
} else {
return "<li class='err'> there is not stock for the price list.</li>";
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirmCust;
}
# connect to db
db_conn("exten");
# write to db
$sql = "INSERT INTO spricelist(listname, div) VALUES ('{$listname}', '" . USER_DIV . "')";
$catRslt = db_exec($sql) or errDie("Unable to price list to system.", SELF);
if (pg_cmdtuples($catRslt) < 1) {
return "<li class='err'>Unable to add price list to database.</li>";
}
# get next ordnum
$listid = pglib_lastid("spricelist", "listid");
# Insert price list items
foreach ($stkids as $key => $value) {
db_connect();
$sql = "SELECT stkid, prdcls, catid FROM stock WHERE stkid = '{$stkids[$key]}' AND div = '" . USER_DIV . "'";
$stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database.");
$stk = pg_fetch_array($stkRslt);
db_conn("exten");
$sql = "\r\n\t\t\tINSERT INTO splist_prices (\r\n\t\t\t\tlistid, stkid, catid, clasid, price, div\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$listid}', '{$stkids[$key]}', '{$stk['catid']}', '{$stk['prdcls']}', '{$prices[$key]}', '" . USER_DIV . "'\r\n\t\t\t)";
$rslt = db_exec($sql) or errDie("Unable to insert price list items to Cubit.", SELF);
}
// Layout
$write = "\r\n\t\t<table " . TMPL_tblDflts . " width='50%'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Supplier Price list added to system</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='datacell'>\r\n\t\t\t\t<td>New Supplier Price list <b>{$listname}</b>, has been successfully added to the system.</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t<p>\r\n\t\t<table border='0' cellpadding='2' cellspacing='1'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Quick Links</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='sup-pricelist-view.php'>View Supplier Price Lists</a></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='../main.php'>Main Menu</a></td>\r\n\t\t\t</tr>\r\n\t\t</table>";
return $write;
}
示例14: writeLoan
function writeLoan($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($empnum, "num", 1, 20, "Invalid employee number.");
$v->isOk($loanid, "num", 1, 20, "Invalid loan ID.");
$v->isOk($loanamt, "float", 1, 10, "Invalid loan amount.");
$v->isOk($loanint, "float", 1, 5, "Invalid loan interest.");
$v->isOk($loanperiod, "num", 1, 3, "Invalid payback period.");
$v->isOk($loaninstall, "float", 1, 10, "Invalid monthly installment.");
$v->isOk($fringebenefit, "float", 1, 10, "Invalid fringe benefit amount.");
$v->isOk($accid, "num", 1, 9, "Invalid bank account selected.");
$v->isOk($account, "num", 1, 9, "Invalid contra account selected.");
$v->isOk($loan_account, "num", 1, 9, "Invalid loan account selected.");
$v->isOk($loan_type, "num", 1, 9, "Invalid loan type selected.");
$ldate = mkdate($lyear, $lmonth, $lday);
$v->isOk($ldate, "date", 1, 1, "Invalid loan date.");
$archdate = mkdate($arch_year, $arch_month, $arch_day);
$v->isOk($archdate, "date", 1, 1, "Invalid approval/denial date.");
if (!checkdate($lmonth, $lday, $lyear)) {
$v->addError("", "Invalid date.");
}
if ($account > 0 && isb($account) || isb($loan_account)) {
$v->addError("", "Main accounts blocked. Please select sub accounts.");
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return enterLoan($confirmCust);
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($ldate) >= strtotime($blocked_date_from) and strtotime($ldate) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($archdate) >= strtotime($blocked_date_from) and strtotime($archdate) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
}
# get employee details
db_connect();
$sql = "SELECT * FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "'";
$empRslt = db_exec($sql) or errDie("Unable to select employees from database.");
if (pg_numrows($empRslt) < 1) {
return "Invalid employee ID.";
}
$myEmp = pg_fetch_array($empRslt);
if (!isset($deny)) {
# check for previous loan
$sql = "SELECT empnum FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "' AND gotloan='t'::bool";
$chkRslt = db_exec($sql) or errDie("Unable to check existing loans for employee.");
if (pg_numrows($chkRslt) > 0) {
return "<li class='err'>Loan already exists for employee number: {$empnum}.</li>";
}
}
$date = date("Y-m-d");
pglib_transaction("BEGIN");
$totamount = sprint($loanperiod * $loaninstall);
$loanint_amt = $totamount - $loanamt;
$sql = "\n\t\tINSERT INTO emp_loanarchive (\n\t\t\tempnum, loanamt, loaninstall, loanint, loanperiod, loandate, archdate, loan_type, \n\t\t\tdiv, status\n\t\t) VALUES (\n\t\t\t'{$empnum}', '{$totamount}', '{$loaninstall}', '{$loanint}', '{$loanperiod}', '{$ldate}', '{$archdate}', '{$loan_type}', \n\t\t\t'" . USER_DIV . "', '" . (isset($deny) ? "D" : "A") . "'\n\t\t)";
$rslt = db_exec($sql) or errDie("Unable to pre archive loan.");
$loanaid = pglib_lastid('emp_loanarchive', 'id');
$rem_sql = "DELETE FROM loan_requests WHERE id = '{$loanid}'";
$run_rem = db_exec($rem_sql) or errDie("Unable to get loan requests information.");
if (!isset($deny)) {
$refnum = getrefnum();
if ($accid > 0) {
$bankacc = getbankaccid($accid);
}
if ($account > 0) {
$bankacc = $account;
}
writetrans($loan_account, $bankacc, $archdate, $refnum, $loanamt, "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.");
if ($accid > 0) {
banktrans($accid, "withdrawal", $archdate, "{$myEmp['fnames']} {$myEmp['sname']}", "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.", 0, $loanamt, $loan_account);
}
# write to db
$sql = "\n\t\t\tUPDATE cubit.employees \n\t\t\tSET loanamt = '{$totamount}', loanint = '{$loanint}', loanint_amt = '{$loanint_amt}', loanint_unpaid = '{$loanint_amt}', \n\t\t\t\tloanperiod = '{$loanperiod}', loaninstall = '{$loaninstall}', gotloan = 't'::bool, loanpayslip = '{$loanamt}', \n\t\t\t\tloanfringe = '{$fringebenefit}', loandate = '{$archdate}', expacc_loan = '{$loan_account}', \n\t\t\t\tloanamt_tot = '{$totamount}', loanid = '{$loanaid}' \n\t\t\tWHERE empnum = '{$empnum}' AND div = '" . USER_DIV . "'";
$loanRslt = db_exec($sql) or errDie("Unable to add loan to system.", SELF);
if (pg_cmdtuples($loanRslt) < 1) {
return "Unable to add loan to system.";
}
}
pglib_transaction("COMMIT");
$OUT = "<table " . TMPL_tblDflts . ">";
if (isset($deny)) {
$OUT .= "\n\t\t\t<tr>\n\t\t\t\t<th>Loan Denied And Request Archived.</th>\n\t\t\t</tr>";
} else {
$OUT .= "\n\t\t\t<tr>\n\t\t\t\t<th>Loan Granted And Added To System</th>\n\t\t\t</tr>";
}
//.........这里部分代码省略.........
示例15: write_req
function write_req($_POST)
{
global $_SESSION;
# get vars
extract($_POST);
$user = $_SESSION["USER_NAME"];
# validate input
require_lib("validate");
$v = new validate();
if (!isset($to)) {
$v->addError("", "No user specified");
} else {
foreach ($to as $arr => $arrval) {
$v->isOk($arrval, "string", 1, 200, "Invalid recipient: {$arrval}");
}
}
// $v->isOk ($des,"string", 1,200, "Invalid message.");
$v->isOk($des, "text", 1, 200, "Invalid message.");
$v->isOk($user, "string", 1, 200, "Invalid user.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return $confirmCust . get_req();
}
db_conn('cubit');
// if should send to all, clear the $to list, and add all users
// it is cleared just incase sum1 selected All option together with another one
// since this could cause the same message sent to the same users twice!!!!
if (in_array("_ALL_", $to)) {
$to = "";
$rslt = db_exec("SELECT username FROM users");
// if users found
if (pg_num_rows($rslt) > 0) {
while ($row = pg_fetch_array($rslt)) {
$to[] = $row["username"];
}
}
}
# write to db
// create the list of users the messages should get sent to
$msg_results = "";
foreach ($to as $arr => $arrval) {
$Sql = "\n\t\t\tINSERT INTO req (\n\t\t\t\tsender, recipient, message, timesent, viewed\n\t\t\t) VALUES (\n\t\t\t\t'{$user}', '{$arrval}', '{$des}', CURRENT_TIMESTAMP, 0\n\t\t\t)";
$Rslt = db_exec($Sql) or errDie("Unable to add to database.", SELF);
if (pg_cmdtuples($Rslt) < 1) {
return "Unable to access database.";
} else {
// if it isn't noticed that person has new messages, notify him
$rslt = db_exec("SELECT * from req_new WHERE for_user='{$arrval}' ");
if (pg_num_rows($rslt) == 0) {
db_exec("INSERT INTO req_new VALUES('{$arrval}')");
}
$msg_results .= "<tr class='datacell'><td>Your message has been sent to {$arrval}</td></tr>";
}
}
$write_req = "\n\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Message proccessed</th>\n\t\t\t</tr>\n\t\t\t<tr class='even'>\n\t\t\t\t<td>{$msg_results}</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\n\t\t\t</tr>\n\t\t\t<tr class='odd'>\n\t\t\t\t<td><a href='" . SELF . "'>Send another message</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='odd'>\n\t\t\t\t<td><a href='view_req.php'>View Messages</a></td>\n\t\t\t</tr>\n\t\t</table>";
return $write_req;
}