forked from science-ation/science-ation
Partially modified to work with new user account system
This commit is contained in:
parent
c81bc0c7da
commit
004c9b64d2
@ -24,6 +24,7 @@
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require_once("../user.inc.php");
|
||||
require_once("../account.inc.php");
|
||||
user_auth_required('admin');
|
||||
require_once("fundraising_common.inc.php");
|
||||
|
||||
@ -213,22 +214,20 @@ switch($_GET['action']) {
|
||||
echo "<tr><td>";
|
||||
echo i18n("Appeal").":";
|
||||
echo "</td><td>";
|
||||
$query = mysql_query(
|
||||
"SELECT accounts.id as acc_id, users.id as usr_id, users.deleted, MAX(users.year) FROM accounts JOIN users ON" .
|
||||
" users.accounts_id = accounts.id" .
|
||||
" WHERE users.sponsors_id = '$id'" .
|
||||
" AND types LIKE '%sponsor%'" .
|
||||
" GROUP BY acc_id" .
|
||||
" HAVING deleted='no'" .
|
||||
" ORDER BY `primary` DESC, lastname, firstname"
|
||||
);
|
||||
|
||||
// loop through each contact in the donor
|
||||
$query = mysql_query("SELECT users.id,users.uid,users.deleted,MAX(year)
|
||||
FROM users
|
||||
LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
|
||||
WHERE
|
||||
sponsors_id='$id'
|
||||
AND types LIKE '%sponsor%'
|
||||
GROUP BY uid
|
||||
HAVING deleted='no'
|
||||
ORDER BY users_sponsor.primary DESC,lastname,firstname
|
||||
");
|
||||
echo mysql_error();
|
||||
$uids=array();
|
||||
while($r=mysql_fetch_object($query)) {
|
||||
$uids[]=$r->uid;
|
||||
$uids[]=$r->usr_id;
|
||||
}
|
||||
|
||||
$q=mysql_query("SELECT * FROM fundraising_campaigns
|
||||
@ -352,12 +351,12 @@ switch($_GET['action']) {
|
||||
case 'newcontactsearch':
|
||||
|
||||
if($_POST['email'])
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE email='".trim($_POST['email'])."' GROUP BY uid HAVING deleted='no'");
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE email='".trim($_POST['email'])."' GROUP BY accounts_id HAVING deleted='no'");
|
||||
|
||||
if($r=mysql_fetch_object($q)) {
|
||||
echo i18n("There is an exact email address match for %1",array($_POST['email']));
|
||||
echo "<ul>";
|
||||
echo "<li><a href=\"#\" onclick=\"useexistingcontact($r->uid)\">$r->firstname $r->lastname $r->email $r->phonehome</a></li>\n";
|
||||
echo "<li><a href=\"#\" onclick=\"useexistingcontact($r->accounts_id)\">$r->firstname $r->lastname $r->email $r->phonehome</a></li>\n";
|
||||
echo "</ul>";
|
||||
|
||||
?>
|
||||
@ -381,7 +380,7 @@ switch($_GET['action']) {
|
||||
if($_POST['email'])
|
||||
$searchstr.=" AND email LIKE '%".$_POST['email']."%'";
|
||||
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE $searchstr GROUP BY uid HAVING deleted='no'");
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE $searchstr GROUP BY accounts_id HAVING deleted='no'");
|
||||
$num=mysql_num_rows($q);
|
||||
if($num==0) {
|
||||
echo i18n("No existing users match, will create a new user");
|
||||
@ -390,7 +389,7 @@ switch($_GET['action']) {
|
||||
echo i18n("Did you mean one of these existing users? (click to choose one)")."<br />";
|
||||
echo "<ul>";
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
echo "<li><a href=\"#\" onclick=\"useexistingcontact($r->uid)\">$r->firstname $r->lastname $r->email $r->phonehome</a></li>\n";
|
||||
echo "<li><a href=\"#\" onclick=\"useexistingcontact($r->accounts_id)\">$r->firstname $r->lastname $r->email $r->phonehome</a></li>\n";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
@ -473,13 +472,13 @@ function delete_contact(){
|
||||
}
|
||||
|
||||
function addexisting_contact() {
|
||||
$uid=intval($_POST['uid']);
|
||||
$sponsors_id=intval($_POST['id']);
|
||||
echo "Linking uid=$uid to sponsors_id=$sponsors_id <br />";
|
||||
$accid = intval($_POST['accounts_id']);
|
||||
$sponsors_id = intval($_POST['id']);
|
||||
echo "Linking accounts_id=$accid to sponsors_id=$sponsors_id <br />";
|
||||
|
||||
echo "uid $uid has users.id {$u['id']}";
|
||||
// echo "uid $uid has users.id {$u['id']}";
|
||||
|
||||
$u=user_load_by_uid($uid);
|
||||
$u=user_load_by_accounts_id($accid);
|
||||
$u['sponsors_id']=$sponsors_id;
|
||||
$u['types'][]="sponsor";
|
||||
user_save($u);
|
||||
@ -498,7 +497,7 @@ function save_contact(){
|
||||
if($_POST['recordtype'] == 'new'){
|
||||
|
||||
if($_POST['email']) {
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE email='".trim($_POST['email'])."' GROUP BY uid HAVING deleted='no'");
|
||||
$q=mysql_query("SELECT *,MAX(year) FROM users WHERE email='".trim($_POST['email'])."' GROUP BY accounts_id HAVING deleted='no'");
|
||||
if(mysql_num_rows($q)) {
|
||||
error_("A user with that email address already exists");
|
||||
exit;
|
||||
@ -508,8 +507,11 @@ function save_contact(){
|
||||
// this is a new record being submitted. Create the user.
|
||||
$successMessage = "Contact created successfully";
|
||||
$successLog = "Added contact ";
|
||||
$u = user_create("sponsor", $_POST['email']);
|
||||
$id = $u['id'];
|
||||
$acc = account_create($_POST['email']);
|
||||
$accid = $acc['id'];
|
||||
$usr = user_create($accid);
|
||||
user_add_role($usr, 'sponsor');
|
||||
//sponsor
|
||||
}else if($_POST['recordtype'] == 'existing'){
|
||||
// this is an existing record being updated. Load the user.
|
||||
$successMessage = "Contact updated successfully";
|
||||
@ -602,15 +604,15 @@ function draw_contactsinfo_form($contact = null){
|
||||
|
||||
|
||||
// loop through each contact and draw a form with their data in it.
|
||||
$query = mysql_query("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
|
||||
WHERE
|
||||
sponsors_id='" . $sponsor_id . "'
|
||||
AND types LIKE '%sponsor%'
|
||||
GROUP BY uid
|
||||
HAVING deleted='no'
|
||||
ORDER BY users_sponsor.primary DESC,lastname,firstname
|
||||
");
|
||||
echo mysql_error();
|
||||
|
||||
$q = "SELECT * , MAX( year )
|
||||
FROM users
|
||||
WHERE sponsors_id = '" . $sponsor_id . "'
|
||||
AND TYPES LIKE '%sponsor%'
|
||||
GROUP BY accounts_id
|
||||
HAVING deleted = 'no'
|
||||
ORDER BY `primary` DESC , lastname, firstname";
|
||||
$query = mysql_query($q);
|
||||
|
||||
while($contact = mysql_fetch_array($query)){
|
||||
// draw a header for this user
|
||||
@ -807,8 +809,8 @@ function draw_activityinfo_form(){
|
||||
FROM fundraising_donor_logs AS fdl
|
||||
LEFT JOIN users ON fdl.users_id=users.id
|
||||
LEFT JOIN fundraising_campaigns ON fdl.fundraising_campaigns_id=fundraising_campaigns.id
|
||||
WHERE sponsors_id=" . $sponsorid. " ORDER BY dt DESC";
|
||||
//echo "<tr><td colspan=\"3\">" . $query . "</td></tr>";
|
||||
WHERE fdl.sponsors_id=" . $sponsorid. " ORDER BY dt DESC";
|
||||
// echo "<tr><td colspan=\"4\">" . $query . "</td></tr>";
|
||||
$q = mysql_query($query);
|
||||
echo mysql_error();
|
||||
if(mysql_num_rows($q)) {
|
||||
@ -1044,9 +1046,9 @@ function update_contactsinfo()
|
||||
);
|
||||
}
|
||||
|
||||
function contactsinfo_save(uid) {
|
||||
function contactsinfo_save(accounts_id) {
|
||||
var id=sponsor_id;
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(),
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + accounts_id).serializeArray(),
|
||||
function() {
|
||||
$("#contactaccordion").accordion();
|
||||
update_contactsinfo();
|
||||
@ -1054,9 +1056,9 @@ function contactsinfo_save(uid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function contactsinfo_delete(uid) {
|
||||
function contactsinfo_delete(accounts_id) {
|
||||
var id=sponsor_id;
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(),
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + accounts_id).serializeArray(),
|
||||
function() {
|
||||
$("#contactaccordion").accordion();
|
||||
update_contactsinfo();
|
||||
@ -1106,9 +1108,9 @@ function donewcontactsearch() {
|
||||
$("#newcontactsearch").load("<?=$_SERVER['PHP_SELF']?>?action=newcontactsearch",$("#contact_new").serializeArray());
|
||||
}
|
||||
|
||||
function useexistingcontact(uid) {
|
||||
function useexistingcontact(accounts_id) {
|
||||
var id=sponsor_id;
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_addexisting",{id: id, uid: uid} ,function() { update_contactsinfo(); });
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_addexisting",{id: id, accounts_id: accounts_id} ,function() { update_contactsinfo(); });
|
||||
}
|
||||
|
||||
function togglefulldonationhistory() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user