Exemplo n.º 1
0
 function after_processing_html($orderID)
 {
     $order = ordGetOrder($orderID);
     //get order amount
     if ($this->_getSettingValue('CONF_PAYMENTMODULE_VERISIGNLINK_USD_CURRENCY') > 0) {
         $curr = currGetCurrencyByID($this->_getSettingValue('CONF_PAYMENTMODULE_VERISIGNLINK_USD_CURRENCY'));
         $curr_rate = $curr["currency_value"];
     }
     if (!isset($curr) || !$curr) {
         $curr_rate = 1;
     }
     $order_amount = roundf($order["order_amount"] * $curr_rate);
     //get billing country ISO 2-chars code
     $q = db_query("select country_iso_3 from " . COUNTRIES_TABLE . " where country_name = '" . $order["billing_country"] . "';");
     $row = db_fetch_row($q);
     if ($row) {
         $bcountry = $row[0];
     } else {
         $bcountry = "";
     }
     $res = "";
     $res .= "<table width='100%'>\n" . "        <tr>\n" . "                <td align='center'>\n" . "<form method='POST' name='verisignLINKform' action='https://payments.verisign.com/payflowlink'>\n" . "<input type=\"hidden\" name=\"LOGIN\" value=\"" . $this->_getSettingValue('CONF_PAYMENTMODULE_VERISIGNLINK_LOGIN') . "\">\n" . "<input type=\"hidden\" name=\"PARTNER\" value=\"" . $this->_getSettingValue('CONF_PAYMENTMODULE_VERISIGNLINK_PARTNER') . "\">\n" . "<input type=\"hidden\" name=\"AMOUNT\" value=\"" . $order_amount . "\">" . "<input type=\"hidden\" name=\"TYPE\" value=\"" . $this->_getSettingValue('CONF_PAYMENTMODULE_VERISIGNLINK_TRANSTYPE') . "\">\n" . "<input type=\"hidden\" name=\"DESCRIPTION\" value=\"Order #{$orderID}\">\n" . "<input type=\"hidden\" name=\"NAME\" value=\"" . $order["billing_firstname"] . " " . $order["billing_lastname"] . "\">\n" . "<input type=\"hidden\" name=\"ADDRESS\" value=\"" . str_replace("\n", "", $order["billing_address"]) . "\">\n" . "<input type=\"hidden\" name=\"CITY\" value=\"" . $order["billing_city"] . "\">\n" . "<input type=\"hidden\" name=\"STATE\" value=\"" . $order["billing_state"] . "\">\n" . "<input type=\"hidden\" name=\"COUNTRY\" value=\"" . $bcountry . "\">\n" . "<input type=\"hidden\" name=\"EMAIL\" value=\"" . $order["customer_email"] . "\">\n" . "<input type=\"submit\" value=\"" . CVERISIGNLINK_TXT_AFTER_PROCESSING_HTML_1 . "\">\n" . "                </form>\n" . "                </td>\n" . "        </tr>\n" . "</table>";
     // xMailTxtHTMLDATA($order["customer_email"], "VeriSign payment", $res);
     return $res;
 }
Exemplo n.º 2
0
function api_data_source_input_fields_validate(&$_fields_data_input, $data_input_field_name_format) {
	require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php");

	/* array containing errored fields */
	$error_fields = array();

	/* data input fields */
	if (isset($_fields_data_source["data_input_type"])) {
		reset($_fields_data_input);
		while (list($_field_name, $_field_array) = each($_fields_data_input)) {
			$form_field_name =  str_replace("|field|", $_field_name, $data_input_field_name_format);

			if (($_fields_data_source["data_input_type"] == DATA_INPUT_TYPE_SCRIPT) && (isset($_fields_data_input["script_id"])) && ($_field_name != "script_id")) {
				$script_input_field = db_fetch_row("select id,regexp_match,allow_empty from data_input_fields where data_input_id = " . $_fields_data_input["script_id"]["value"] . " and data_name = '$_field_name' and input_output = 'in'");

				if (isset($script_input_field["id"])) {
					if (!form_input_validate($_field_array["value"], $form_field_name, $script_input_field["regexp_match"], $script_input_field["allow_empty"])) {
						$error_fields[] = $form_field_name;
					}
				}
			}else if (($data_input_type == DATA_INPUT_TYPE_DATA_QUERY) && ($_field_name == "data_query_field_name")) {
				if (!form_input_validate($value, $form_field_name, "", false)) {
					$error_fields[] = $form_field_name;
				}
			}else if (($data_input_type == DATA_INPUT_TYPE_DATA_QUERY) && ($_field_name == "data_query_field_value")) {
				if (!form_input_validate($value, $form_field_name, "", false)) {
					$error_fields[] = $form_field_name;
				}
			}
		}
	}

	return $error_fields;
}
Exemplo n.º 3
0
function nuBuildTable($J)
{
    $h = '';
    $h .= "<table>";
    $h .= "<tr>";
    $h .= "<th class='id'>ID</th>";
    for ($i = 0; $i < count($J->objects); $i++) {
        $w = $J->objects[$i]->width . 'px';
        $v = $J->objects[$i]->title;
        $h .= "<th class='s{$i}'>{$v}</th>";
    }
    $h .= "</tr>";
    $T = nuRunQuery("SELECT * FROM {$J->records}");
    while ($R = db_fetch_row($T)) {
        $h .= "<tr>";
        $h .= "<td class='id'>" . $R[0] . "</td>";
        for ($i = 0; $i < count($J->objects); $i++) {
            $w = $J->objects[$i]->width . 'px';
            $v = $R[$i + 1];
            $h .= "<td class='s{$i}'>{$v}</td>";
        }
        $h .= "</td>";
        $h .= "</tr>";
    }
    $h .= "</table>";
    return $h;
}
Exemplo n.º 4
0
function api_user_info($array) {

	/* build SQL query */
	$sql_query = "SELECT *, DATE_FORMAT(password_change_last,'%M %e %Y %H:%i:%s') as password_change_last_formatted, DATE_FORMAT(last_login,'%M %e %Y %H:%i:%s') as last_login_formatted FROM user_auth WHERE ";
	$sql_where = "";
	if (($array) && (is_array($array))) {
		foreach ($array as $field => $value) {
			$sql_where .= $field . " = '" . sql_sanitize($value) . "' AND ";
		}
		/* remove trailing AND */
		$sql_where = preg_replace("/ AND\ $/", "", $sql_where);
		$sql_query = $sql_query . $sql_where;
	}else{
		/* error no array */
		return "";
	}

	/* get the user info */
	$user = db_fetch_row($sql_query);
	if ((is_array($user)) && (sizeof($user) > 0)) {
		return $user;
	}else{
		return NULL;
	}

}
Exemplo n.º 5
0
function get_domestic_price($myrow, $stock_id, $qty, $old_std_cost, $old_qty)
{
    if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT) {
        $price = $myrow['price'];
        if ($myrow['type'] == ST_SUPPRECEIVE) {
            // Has the supplier invoice increased the receival price?
            $sql = "SELECT DISTINCT act_price FROM " . TB_PREF . "purch_order_details pod INNER JOIN " . TB_PREF . "grn_batch grn ON pod.order_no =\n\t\t\t\tgrn.purch_order_no WHERE grn.id = " . $myrow['trans_no'] . " AND pod.item_code = '{$stock_id}'";
            $result = db_query($sql, "Could not retrieve act_price from purch_order_details");
            $row = db_fetch_row($result);
            if ($row[0] > 0 and $row[0] != $myrow['price']) {
                $price = $row[0];
            }
        }
        if ($myrow['person_id'] > 0) {
            // Do we have foreign currency?
            $supp = get_supplier($myrow['person_id']);
            $currency = $supp['curr_code'];
            $ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow['tran_date']));
            $price /= $ex_rate;
        }
    } elseif ($myrow['type'] != ST_INVADJUST) {
        // calcutale the price from avg. price
        $price = ($myrow['standard_cost'] * $qty - $old_std_cost * $old_qty) / $myrow['qty'];
    } else {
        $price = $myrow['standard_cost'];
    }
    // Item Adjustments just have the real cost
    return $price;
}
Exemplo n.º 6
0
function repGetProductReportByCategoryID($callBackParam, &$count_row, $navigatorParams = null)
{
    if ($navigatorParams != null) {
        $offset = $navigatorParams["offset"];
        $CountRowOnPage = $navigatorParams["CountRowOnPage"];
    } else {
        $offset = 0;
        $CountRowOnPage = 0;
    }
    $where_clause = "";
    $order_clause = "";
    if (isset($callBackParam["categoryID"])) {
        if ($callBackParam["categoryID"] != 0) {
            $where_clause = " where categoryID=" . (int) $callBackParam["categoryID"];
        }
    }
    if (isset($callBackParam["sort"])) {
        $order_clause = " order by " . xEscSQL($callBackParam["sort"]);
        if (isset($callBackParam["direction"])) {
            $order_clause .= " " . xEscSQL($callBackParam["direction"]);
        }
    }
    $res = array();
    $q = db_query("select name, customers_rating, customer_votes, items_sold, " . " viewed_times, in_stock, sort_order  from " . PRODUCTS_TABLE . " " . $where_clause . " " . $order_clause);
    $i = 0;
    while ($row = db_fetch_row($q)) {
        if ($i >= $offset && $i < $offset + $CountRowOnPage || $navigatorParams == null) {
            $res[] = $row;
        }
        $i++;
    }
    $count_row = $i;
    return $res;
}
Exemplo n.º 7
0
function schVariantIsSetToSearch($categoryID, $optionID, $variantID)
{
    $SQL = "select COUNT(*) FROM " . CATEGORY_PRODUCT_OPTION_VARIANTS . " WHERE categoryID=" . (int) $categoryID . " AND optionID=" . (int) $optionID . " AND variantID=" . (int) $variantID;
    $q = db_query($SQL);
    $row = db_fetch_row($q);
    return $row[0] != 0;
}
Exemplo n.º 8
0
function discGetDiscussion($DID)
{
    $q = db_query("select DID, Author, Body, add_time, Topic, name AS product_name, " . " " . PRODUCTS_TABLE . ".productID AS productID from " . DISCUSSIONS_TABLE . ", " . PRODUCTS_TABLE . " where " . DISCUSSIONS_TABLE . ".productID=" . PRODUCTS_TABLE . ".productID AND DID=" . (int) $DID);
    $row = db_fetch_row($q);
    $row["add_time"] = format_datetime($row["add_time"]);
    return $row;
}
Exemplo n.º 9
0
function get_total_payment($type, $trans_no)
{
    $sql = "SELECT SUM(amt) from " . TB_PREF . "cust_allocations a \n\tINNER JOIN " . TB_PREF . "debtor_trans c on a.trans_type_to=c.type AND a.trans_no_to=c.trans_no\n\twhere a.trans_type_to = " . db_escape($type) . " AND a.trans_no_to = " . db_escape($trans_no) . " AND a.trans_type_from = " . ST_CUSTPAYMENT . "";
    $res = db_query($sql, "Could not retrieve payment at the moment.");
    $ret = db_fetch_row($res);
    return $ret[0];
}
Exemplo n.º 10
0
function _getDirectoryDbInfo($id)
{
    if (!isset($_GLOBALS['cache_directories'][$id])) {
        $_GLOBALS['cache_directories'][$id] = db_fetch_row("select * from " . KFM_DB_PREFIX . "directories where id=" . $id);
    }
    return $_GLOBALS['cache_directories'][$id];
}
Exemplo n.º 11
0
function can_delete($selected_id)
{
    $sql = "SELECT COUNT(*) FROM stock_moves WHERE loc_code='{$selected_id}'";
    $result = db_query($sql, "could not query stock moves");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr("Cannot delete this location because item movements have been created using this location."));
        return false;
    }
    $sql = "SELECT COUNT(*) FROM workorders WHERE loc_code='{$selected_id}'";
    $result = db_query($sql, "could not query work orders");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr("Cannot delete this location because it is used by some work orders records."));
        return false;
    }
    $sql = "SELECT COUNT(*) FROM cust_branch WHERE default_location='{$selected_id}'";
    $result = db_query($sql, "could not query customer branches");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr("Cannot delete this location because it is used by some branch records as the default location to deliver from."));
        return false;
    }
    return true;
}
Exemplo n.º 12
0
 function kfmFile()
 {
     global $kfm;
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::__construct();
         $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id);
         $this->name = $filedata['name'];
         $this->parent = $filedata['directory'];
         $dir = kfmDirectory::getInstance($this->parent);
         $this->dir = $dir;
         $this->directory = $dir->path();
         $this->path = $this->directory . '/' . $filedata['name'];
         if (!$this->exists()) {
             //				$this->error(kfm_lang('File cannot be found')); // removed because it is causing false errors
             $this->delete();
             return false;
         }
         $this->writable = $this->isWritable();
         $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600;
         $this->modified = strftime($kfm->setting('date_format') . ' ' . $kfm->setting('time_format'), filemtime($this->path));
         $mimetype = Mimetype::get($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
Exemplo n.º 13
0
function get_preference($user_urn, $preference)
{
    global $possible_prefs;
    $conn = portal_conn();
    if (array_key_exists($preference, $possible_prefs)) {
        $sql = "SELECT * from user_preferences " . "where user_urn = " . $conn->quote($user_urn, 'text') . "and preference_name = " . $conn->quote($preference, 'text');
        $db_res = db_fetch_row($sql);
        $db_response = db_fetch_row($sql, "Get user preference");
        $db_error = $db_response[RESPONSE_ARGUMENT::OUTPUT];
        $default_option = $possible_prefs[$preference][0];
        if ($db_error != "") {
            // TODO: What do we do here
            error_log("DB error when getting row from user_preferences table: " . $db_error);
            return $default_option;
        } else {
            if ($db_response[RESPONSE_ARGUMENT::VALUE]['preference_value']) {
                return $db_response[RESPONSE_ARGUMENT::VALUE]['preference_value'];
            } else {
                return $default_option;
            }
        }
    } else {
        error_log("Unknown preference '{$preference}' requested for user '{$user_urn}'");
        return "";
    }
}
Exemplo n.º 14
0
function db_select_all_row($sql)
{
    $result = db_select($sql);
    while ($return[] = db_fetch_row($result)) {
    }
    return $return;
}
Exemplo n.º 15
0
function getContactPerson($imc, $debtor_no, $branch_code)
{
    $sql = "Select CONCAT (d.name, d.name2) AS contactName FROM " . TB_PREF . "cust_branch b  INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id where b.salesman = " . db_escape($imc) . "\n\tAND b.debtor_no = " . db_escape($debtor_no) . " AND b.branch_code = " . db_escape($branch_code) . "";
    $result = db_query($sql, "could not get IMC");
    $row = db_fetch_row($result);
    return $row[0];
}
Exemplo n.º 16
0
    public static function searchStudents($value)
    {
        $query = "SELECT\r\n\t\t\t\t  S.last_name,\r\n\t\t\t\t  S.first_name,\r\n\t\t\t\t  S.middle_name,\r\n\t\t\t\t  S.student_id,\r\n\t\t\t\t  GL.title\r\n\t\t\t\t  FROM\r\n\t\t\t\t  SCHOOL_GRADELEVELS GL,\r\n\t\t\t\t  STUDENTS S,\r\n\t\t\t\t  STUDENT_ENROLLMENT SE\r\n\t\t\t\t  WHERE\r\n\t\t\t\t  S.student_id = SE.student_id\r\n\t\t\t\t  and SE.grade_id = GL.id\r\n\t\t\t\t  and\r\n\t\t\t\t  (\r\n\t\t\t\t  lower(S.last_name) like lower('%{$value}%')\r\n\t\t\t\t  or lower(S.first_name) like lower('%{$value}%')\r\n\t\t\t\t  or lower(S.first_name || ' ' || S.last_name) like lower('%{$value}%')\r\n                  )";
        if (is_numeric($value)) {
            $query = $query . " or S.student_id = {$value}";
        }
        $result = DBQuery($query);
        $json = '"users":[';
        while ($row = db_fetch_row($result)) {
            $lastName = $row['LAST_NAME'];
            $firstName = $row['FIRST_NAME'];
            $middle = $row['MIDDLE_NAME'];
            $id = $row['STUDENT_ID'];
            $grade = $row['TITLE'];
            $json = $json . '{
							"id":"' . $id . '",
						    "first":"' . $firstName . '",
						    "last":"' . $lastName . '",
						    "middle":"' . $middle . '",
						    "grade":"' . $grade . '"
                            },';
        }
        $json = rtrim($json, ",");
        $json = $json . ']';
        return $json;
    }
Exemplo n.º 17
0
 function kfmFile()
 {
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::__construct();
         $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id);
         if ($filedata === false) {
             return false;
         }
         // does not exist in database
         $this->name = $filedata['name'];
         $this->parent = $filedata['directory'];
         $dir = kfmDirectory::getInstance($this->parent);
         $this->dir = $dir;
         $this->directory = $dir->path();
         $this->path = $this->directory . '/' . $filedata['name'];
         if (!$this->exists()) {
             $this->delete();
             return false;
         }
         $this->writable = $this->isWritable();
         $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600;
         $this->modified = strftime($GLOBALS['kfm']->setting('date_format') . ' ' . $GLOBALS['kfm']->setting('time_format'), filemtime($this->path));
         require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/Core_getMimeType.php';
         $mimetype = Core_getMimeType($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
Exemplo n.º 18
0
 function search($params)
 {
     $input = db_input(strtolower($params['input']), false);
     $len = strlen($input);
     $limit = isset($params['limit']) ? (int) $params['limit'] : 25;
     $items = array();
     $ticketid = false;
     if (is_numeric($input)) {
         $WHERE = ' WHERE ticketID LIKE \'' . $input . '%\'';
         $ticketid = true;
     } else {
         $WHERE = ' WHERE email LIKE \'' . $input . '%\'';
     }
     $sql = 'SELECT DISTINCT ticketID,email FROM ' . TICKET_TABLE . ' ' . $WHERE . ' ORDER BY created LIMIT ' . $limit;
     $resp = db_query($sql);
     if ($resp && db_num_rows($resp)) {
         while (list($id, $email) = db_fetch_row($resp)) {
             $info = $ticketid ? $email : $id;
             $id = $ticketid ? $id : $email;
             $items[] = '{"id": "' . $id . '", "value": "' . $id . '", "info": "' . $info . '"}';
         }
     }
     $result = '{"results": [' . implode(", ", $items) . ']}';
     return $result;
 }
Exemplo n.º 19
0
function adminpgGetadminPage($admin_ID)
{
    $q = db_query("select Login, actions from " . CUSTOMERS_TABLE . " where customerID=" . (int) $admin_ID);
    $row = db_fetch_row($q);
    $row[1] = unserialize($row[1]);
    return $row;
}
Exemplo n.º 20
0
function rrdclean_check_upgrade()
{
    global $config;
    $files = array('index.php', 'plugins.php', 'rrdcleaner.php');
    if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
        return;
    }
    $current = plugin_rrdclean_version();
    $current = $current['version'];
    $old = db_fetch_row("SELECT * FROM plugin_config WHERE directory='rrdclean'");
    if (sizeof($old) && $current != $old["version"]) {
        /* if the plugin is installed and/or active */
        if ($old["status"] == 1 || $old["status"] == 4) {
            /* re-register the hooks */
            plugin_rrdclean_install();
            /* perform a database upgrade */
            rrdclean_database_upgrade();
        }
        # stub for updating tables
        #$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM <table>"), "Field", "Field");
        #if (!in_array("<new column>", $_columns)) {
        #	db_execute("ALTER TABLE <table> ADD COLUMN <new column> VARCHAR(40) NOT NULL DEFAULT '' AFTER <old column>");
        #}
        # new hooks
        #api_plugin_register_hook('rrdclean', 'config_settings',       'rrdclean_config_settings', 'setup.php');
        #if (api_plugin_is_enabled('rrdclean')) {
        # may sound ridiculous, but enables new hooks
        #	api_plugin_enable_hooks('rrdclean');
        #}
        # register new version
        $info = plugin_rrdclean_version();
        $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='rrdclean'");
        db_execute("UPDATE plugin_config\r\n\t\t\tSET name='" . $info["longname"] . "',\r\n\t\t\tauthor='" . $info["author"] . "',\r\n\t\t\twebpage='" . $info["homepage"] . "',\r\n\t\t\tversion='" . $info["version"] . "'\r\n\t\t\tWHERE id='{$id}'");
    }
}
Exemplo n.º 21
0
 function search()
 {
     $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 25;
     $items = array();
     $ticketid = false;
     if (isset($_GET['id'])) {
         $WHERE = ' WHERE ticketID LIKE \'' . db_input($_GET['id'], false) . '%\'';
         $ticketid = true;
     } elseif (isset($_GET['email'])) {
         $WHERE = ' WHERE email LIKE \'' . db_input(strtolower($_GET['email']), false) . '%\'';
     } else {
         Http::response(400, "id or email argument is required");
     }
     $sql = 'SELECT DISTINCT ticketID,email,name FROM ' . TICKET_TABLE . ' ' . $WHERE . ' ORDER BY created LIMIT ' . $limit;
     $res = db_query($sql);
     if ($res && db_num_rows($res)) {
         while (list($id, $email, $name) = db_fetch_row($res)) {
             $info = $ticketid ? $email : $id;
             $id = $ticketid ? $id : $email;
             # TODO: Return 'name' from email address if 'email' argument
             #       specified?
             $items[] = array('id' => $id, 'value' => $id, 'info' => $info, 'name' => $name);
         }
     }
     return $this->encode(array('results' => $items));
 }
Exemplo n.º 22
0
function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "")
{
    $host = db_fetch_row("select\n\t\thost.id,\n\t\thost.hostname,\n\t\thost.snmp_community,\n\t\thost.snmp_version,\n\t\thost.snmp_username,\n\t\thost.snmp_password,\n\t\thost.snmp_port,\n\t\thost.snmp_timeout,\n\t\thost.disabled\n\t\tfrom host\n\t\twhere host.id={$host_id}");
    /* the $host_field_override array can be used to override certain host fields in the poller cache */
    if (isset($host)) {
        $host = array_merge($host, $host_field_override);
    }
    if (isset($host["id"]) || isset($host_id)) {
        if (isset($host)) {
            if ($host["disabled"] == "on") {
                return true;
            }
        } else {
            if ($poller_action_id == 0) {
                return true;
            }
            $host["id"] = 0;
            $host["snmp_community"] = "";
            $host["snmp_timeout"] = "";
            $host["snmp_username"] = "";
            $host["snmp_password"] = "";
            $host["snmp_version"] = "";
            $host["snmp_port"] = "";
            $host["hostname"] = "None";
        }
        if ($poller_action_id == 0) {
            if ($host["snmp_version"] < 1 || $host["snmp_version"] > 3 || $host["snmp_community"] == "" && $host["snmp_version"] != 3) {
                return true;
            }
        }
        return db_execute("insert into poller_item (local_data_id,host_id,action,hostname,\n\t\t\tsnmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,\n\t\t\trrd_num,arg1,arg2,arg3) values ({$local_data_id}," . $host["id"] . ",{$poller_action_id},'" . $host["hostname"] . "',\n\t\t\t'" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "',\n\t\t\t'" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "',\n\t\t\t'{$data_source_item_name}','" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',\n\t\t\t'{$num_rrd_items}','{$arg1}','{$arg2}','{$arg3}')");
    }
}
Exemplo n.º 23
0
function getTransactions($debtorno, $branchcode, $date)
{
    $date = date2sql($date);
    $sql = "SELECT SUM((ov_amount+ov_freight+ov_discount)*rate) AS Turnover\n\t\tFROM " . TB_PREF . "debtor_trans\n\t\tWHERE debtor_no=" . db_escape($debtorno) . "\n\t\tAND branch_code=" . db_escape($branchcode) . "\n\t\tAND (type=" . ST_SALESINVOICE . " OR type=" . ST_CUSTCREDIT . ")\n\t\tAND tran_date >='{$date}'";
    $result = db_query($sql, "No transactions were returned");
    $row = db_fetch_row($result);
    return $row[0];
}
Exemplo n.º 24
0
 function cannedResp($params)
 {
     $sql = 'SELECT answer FROM ' . KB_PREMADE_TABLE . ' WHERE isenabled=1 AND premade_id=' . db_input($params['id']);
     if (($res = db_query($sql)) && db_num_rows($res)) {
         list($response) = db_fetch_row($res);
     }
     return $response;
 }
function get_bank_balance_to($to, $account)
{
    $to = date2sql($to);
    $sql = "SELECT SUM(amount) FROM " . TB_PREF . "bank_trans WHERE bank_act='{$account}'\n\tAND trans_date < '{$to}'";
    $result = db_query($sql, "The starting balance on hand could not be calculated");
    $row = db_fetch_row($result);
    return $row[0];
}
Exemplo n.º 26
0
 function getIdByName($name)
 {
     $sql = 'SELECT group_id FROM ' . GROUP_TABLE . ' WHERE group_name=' . db_input(trim($name));
     if (($res = db_query($sql)) && db_num_rows($res)) {
         list($id) = db_fetch_row($res);
     }
     return $id;
 }
Exemplo n.º 27
0
function getTransactions($supplier_id, $date)
{
    $date = date2sql($date);
    $sql = "SELECT SUM((ov_amount+ov_discount)*rate) AS Turnover\n\t\tFROM " . TB_PREF . "supp_trans\n\t\tWHERE supplier_id=" . db_escape($supplier_id) . "\n\t\tAND (type=" . ST_SUPPINVOICE . " OR type=" . ST_SUPPCREDIT . ")\n\t\tAND tran_date >='{$date}'";
    $result = db_query($sql, "No transactions were returned");
    $row = db_fetch_row($result);
    return $row[0];
}
Exemplo n.º 28
0
function getSuppInvTax($taxtype, $from, $to)
{
    $fromdate = date2sql($from);
    $todate = date2sql($to);
    $sql = "SELECT SUM(unit_price * quantity * supp_trans.rate), SUM(amount*supp_trans.rate)\n\t\tFROM supp_invoice_items, supp_invoice_tax_items, supp_trans\n\t\t\t\tWHERE supp_invoice_items.supp_trans_type>=20\n\t\t\t\t\tAND supp_invoice_items.supp_trans_type<=21\n\t\t\t\t\tAND supp_invoice_items.supp_trans_no=supp_invoice_tax_items.supp_trans_no\n\t\t\t\t\tAND supp_invoice_items.supp_trans_type=supp_invoice_tax_items.supp_trans_type\n\t\t\t\t\tAND supp_invoice_items.supp_trans_no=supp_trans.trans_no\n\t\t\t\t\tAND supp_invoice_items.supp_trans_type=supp_trans.type\n\t\t\t\t\tAND supp_invoice_tax_items.tax_type_id={$taxtype}\n\t\t\t\t\tAND supp_trans.tran_date >= '{$fromdate}'\n\t\t\t\t\tAND supp_trans.tran_date <= '{$todate}'";
    $result = db_query($sql, "No transactions were returned");
    return db_fetch_row($result);
}
Exemplo n.º 29
0
function getTransactions($debtorno, $branchcode, $date)
{
    $date = date2sql($date);
    $sql = "SELECT SUM((ov_amount+ov_freight+ov_discount)*rate) AS Turnover\n\t\tFROM debtor_trans\n\t\tWHERE debtor_no='{$debtorno}'\n\t\tAND branch_code='{$branchcode}'\n\t\tAND (type=10 or type=11)\n\t\tAND trandate >='{$date}'";
    $result = db_query($sql, "No transactions were returned");
    $row = db_fetch_row($result);
    return $row[0];
}
Exemplo n.º 30
0
function get_only_budget_trans_from_to($from_date, $to_date, $account, $dimension = 0, $dimension2 = 0)
{
    $from = date2sql($from_date);
    $to = date2sql($to_date);
    $sql = "SELECT SUM(amount) FROM budget_trans\n\t\tWHERE account='{$account}' AND tran_date >= '{$from}' AND tran_date <= '{$to}'\n\t\t AND dimension_id = {$dimension} AND dimension2_id = {$dimension2}";
    $result = db_query($sql, "No budget accounts were returned");
    $row = db_fetch_row($result);
    return $row[0];
}