function view($VAR) { if (!$this->checkLimits()) { return false; } // check account limits global $C_auth; $type = "view"; $this->method["{$type}"] = explode(",", $this->method["{$type}"]); # set the field list for this method: $db =& DB(); $arr = $this->method[$type]; if (isset($VAR["id"])) { $id = explode(',', $VAR["id"]); for ($i = 0; $i < count($id); $i++) { if ($id[$i] != '') { if ($i == 0) { $id_list .= " id = " . $db->qstr($id[$i]) . " "; $ii++; } else { $id_list .= " OR id = " . $db->qstr($id[$i]) . " "; $ii++; } } } } if ($ii > 0) { # generate the full query $q = "SELECT * FROM\n\t\t\t\t " . AGILE_DB_PREFIX . "account\n\t\t\t\t WHERE\t\t\t\t\t\n\t\t\t\t {$id_list}\n\t\t\t\t AND site_id = '" . DEFAULT_SITE . "'"; $result = $db->Execute($q); # error reporting if ($result === false) { global $C_debug; $C_debug->error('account_admin.inc.php', 'view', $db->ErrorMsg() . ' ' . $q); return; } # put the results into a smarty accessable array $i = 0; $class_name = TRUE; while (!$result->EOF) { $smart[$i] = $result->fields; if ($class_name) { $smart[$i]["i"] = $i; } else { $smart[$i]["i"] = $i; } ### Get any authorized groups: $dba =& DB(); $sql = 'SELECT service_id,group_id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE site_id = ' . $dba->qstr(DEFAULT_SITE) . ' AND account_id = ' . $dba->qstr($result->fields['id']) . ' AND active = ' . $dba->qstr("1") . ' ORDER BY group_id'; $groups = $dba->Execute($sql); while (!$groups->EOF) { if ($groups->fields['service_id'] == '') { $group[] = $groups->fields['group_id']; } $groups->MoveNext(); } $smart[$i]["groups"] = $group; ### Verify the user has access to view this account: if (SESS_ACCOUNT != $result->fields['id']) { $smart[$i]['own_account'] = false; $display_this = true; for ($ix = 0; $ix < count($group); $ix++) { if (!$C_auth->auth_group_by_id($group[$ix])) { $display_this = false; } } } else { $display_this = true; $smart[$i]['own_account'] = true; } ### Get the static vars: require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); $arr = $static_var->update_form('account', 'update', $result->fields['id']); if (gettype($arr) == 'array') { $smart[$i]["static_var"] = $arr; } ### Get the last activity date/IP $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "login_log\n\t\t\t\t\t\tWHERE account_id = {$result->fields['id']}\n\t\t\t\t\t\tAND site_id = " . DEFAULT_SITE . "\n\t\t\t\t\t\tORDER BY date_orig DESC "; $rslast = $db->SelectLimit($sql, 1); if ($rslast != false && $rslast->RecordCount() == 1) { $smart[$i]["last_activity"] = $rslast->fields['date_orig']; $smart[$i]["last_ip"] = $rslast->fields['ip']; } else { $smart[$i]["last_activity"] = $result->fields['date_orig']; $smart[$i]["last_ip"] = ''; } ### Get invoice details for this account: $sql = "SELECT id,date_orig,total_amt,billed_amt,process_status FROM " . AGILE_DB_PREFIX . "invoice\n\t\t\t\t\t\tWHERE account_id = {$result->fields['id']}\n\t\t\t\t\t\tAND site_id = " . DEFAULT_SITE . "\n\t\t\t\t\t\tORDER BY id DESC "; $inv = $db->SelectLimit($sql, 10); if ($inv != false && $inv->RecordCount() > 0) { while (!$inv->EOF) { if ($inv->fields['total_amt'] > $inv->fields['billed_amt'] && $inv->fields['suspend_billing'] != 1) { $inv->fields['due'] = $inv->fields['total_amt'] - $inv->fields['billed_amt']; } $smart[$i]["invoice"][] = $inv->fields; $inv->MoveNext(); } } ### Get service details for this account: $sql = "SELECT id,sku,active,type,domain_name,domain_tld FROM " . AGILE_DB_PREFIX . "service\n\t\t\t\t\t\tWHERE account_id = {$result->fields['id']}\n\t\t\t\t\t\tAND site_id = " . DEFAULT_SITE . "\n\t\t\t\t\t\tORDER BY id DESC "; $svc = $db->SelectLimit($sql, 10); if ($svc != false && $svc->RecordCount() > 0) { while (!$svc->EOF) { $smart[$i]["service"][] = $svc->fields; $svc->MoveNext(); } } # define the results if (!$display_this) { unset($smart["{$i}"]); echo "You have selected an account for which you are not authorized,\n\t\t\t\t\t\t your permission settings are to low!<br><br>"; } else { $i++; } unset($group); $result->MoveNext(); } # get the result count: $results = $i; ### No results: if ($i == 0) { global $C_debug; $C_debug->error("CORE:account_admin.inc.php", "view()", "\n\t\t\t\tThe selected record does not exist any longer, or your account is not authorized to view it"); return; } global $smarty; $smarty->assign($this->table, $smart); $smarty->assign('results', $search->results); } }
function view($VAR) { $type = "view"; $this->method["{$type}"] = split(",", $this->method["{$type}"]); $db = new CORE_database(); $db->view($VAR, $this, $type); ### Get the static vars: global $smarty; require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); $ids = explode(',', $VAR['id']); $arr = $static_var->update_form($this->module, 'update', $ids[0]); if (gettype($arr) == 'array') { $smarty->assign('static_var', $arr); } else { $smarty->assign('static_var', false); } }
function view($VAR) { ### Check that user is logged in: if (SESS_LOGGED != '1') { echo "Sorry, you must be logged in!"; return false; } $this->account_construct(); /* check for sub account */ if (!empty($VAR['id']) && $VAR['id'] != SESS_ACCOUNT) { if ($this->isParentAccount($VAR['id'])) { $VAR['account_id'] = $VAR['id']; global $smarty; $smarty->assign('issubaccount', true); } else { return false; } } else { $VAR['id'] = SESS_ACCOUNT; $VAR['account_id'] = SESS_ACCOUNT; } ### Retrieve the record: $type = "view"; $this->method["{$type}"] = split(",", $this->method["{$type}"]); $db = new CORE_database(); $db->view($VAR, $this, $type); ### Get the static vars: global $smarty; require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); $arr = $static_var->update_form('account', 'update', SESS_ACCOUNT); if (gettype($arr) == 'array') { $smarty->assign('static_var', $arr); } else { $smarty->assign('static_var', false); } /* get child accounts */ if (empty($smarty->_tpl_vars['account'][0]['parent_id']) || $smarty->_tpl_vars['account'][0]['parent_id'] == $smarty->_tpl_vars['account'][0]['id']) { $db =& DB(); $rs = $db->Execute(sqlSelect($db, "account", "id,first_name,last_name,email,username", "parent_id=" . $db->qstr(SESS_ACCOUNT))); if ($rs && $rs->RecordCount()) { while (!$rs->EOF) { $smart[] = $rs->fields; $rs->MoveNext(); } $smarty->assign('subaccount', $smart); } } }
function view($VAR) { $type = "view"; $this->method["{$type}"] = explode(",", $this->method["{$type}"]); # set the field list for this method: $db =& DB(); $arr = $this->method[$type]; if (isset($VAR["id"])) { $id = explode(',', $VAR["id"]); for ($i = 0; $i < count($id); $i++) { if ($id[$i] != '') { if ($i == 0) { $id_list .= " id = " . $db->qstr($id[$i]) . " "; $ii++; } else { $id_list .= " OR id = " . $db->qstr($id[$i]) . " "; $ii++; } } } } if ($ii > 0) { # generate the full query $q = "SELECT * FROM\n\t\t\t\t " . AGILE_DB_PREFIX . "affiliate\n\t\t\t\t WHERE\t\t\t\t\t\n\t\t\t\t {$id_list}\n\t\t\t\t AND site_id = '" . DEFAULT_SITE . "'"; $result = $db->Execute($q); # error reporting if ($result === false) { global $C_debug; $C_debug->error('affiliate.inc.php', 'view', $db->ErrorMsg() . ' ' . $q); return; } # put the results into a smarty accessable array $i = 0; $class_name = TRUE; while (!$result->EOF) { $smart[$i] = $result->fields; if ($class_name) { $smart[$i]["i"] = $i; } else { $smart[$i]["i"] = $i; } $plugin_data = unserialize($result->fields["plugin_data"]); ### Get the name of the plugin file to include: $sql1 = "SELECT file FROM " . AGILE_DB_PREFIX . "affiliate_plugin WHERE\n\t\t\t\t\t\tid = " . $db->qstr($result->fields['affiliate_plugin_id']) . " AND\n\t\t\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE); $plgn = $db->Execute($sql1); $smart[$i]["plugin_file"] = "affiliate:plugin_" . $plgn->fields["file"]; ### Get the static vars: require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); $arr = $static_var->update_form('affiliate', 'update', $result->fields['id']); if (gettype($arr) == 'array') { $smart[$i]["static_var"] = $arr; } ############################################################################ ### START AFFILIATE STATISTICS ################## ### Get the sessions referred by this affiliate: $sql2 = "SELECT id FROM " . AGILE_DB_PREFIX . "session WHERE\n\t\t\t\t\t\taffiliate_id = " . $db->qstr($result->fields['id']) . " AND\n\t\t\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE); $result2 = $db->Execute($sql2); $smart[$i]["stats_sessions"] = $result2->RecordCount(); ### Get the accounts referred by this affiliate: $sql2 = "SELECT id FROM " . AGILE_DB_PREFIX . "account WHERE\n\t\t\t\t\t\taffiliate_id = " . $db->qstr($result->fields['id']) . " AND\n\t\t\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE); $result2 = $db->Execute($sql2); $smart[$i]["stats_accounts"] = $result2->RecordCount(); ### Get the invoices referred by this affiliate: $sql2 = "SELECT id,total_amt FROM " . AGILE_DB_PREFIX . "invoice WHERE\n\t\t\t\t\t\taffiliate_id = " . $db->qstr($result->fields['id']) . " AND\n\t\t\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE); $result2 = $db->Execute($sql2); $smart[$i]["stats_invoices"] = $result2->RecordCount(); $total = 0; while (!$result2->EOF) { $total += $result2->fields['total_amt']; $result2->MoveNext(); } $smart[$i]["stats_invoices_amt"] = $total; ### Get the commissions issued to this affiliate: $sql2 = "SELECT commission FROM " . AGILE_DB_PREFIX . "invoice_commission WHERE\n\t\t\t\t\t\taffiliate_id = " . $db->qstr($result->fields['id']) . " AND\n\t\t\t\t\t\tsite_id = " . $db->qstr(DEFAULT_SITE); $result2 = $db->Execute($sql2); $total = 0; while (!$result2->EOF) { $total += $result2->fields['commission']; $result2->MoveNext(); } $smart[$i]["stats_commissions"] = $total; ### Get the commissions (outstanding) to be issued to this affiliate: $smart[$i]["commissions_due"] = $this->commission_due($result->fields['id']); ### END AFFILIATE STATISTICS #################### ############################################################################# $i++; $result->MoveNext(); } # get the result count: $results = $i; ### No results: if ($i == 0) { global $C_debug; $C_debug->error("CORE:affiliate.inc.php", "view()", "\n\t\t\t\tThe selected affiliate does not exist any longer!"); return; } global $smarty; $smarty->assign($this->table, $smart); $smarty->assign('plugin_data', $plugin_data); $smarty->assign('results', $search->results); } }