forked from science-ation/science-ation
Updated to allow the deleting of contacts
Cleaned up the layout of the contact info form to be smaller and more aesthetic
This commit is contained in:
parent
bfb4c1c586
commit
50eebd3245
114
admin/donors.php
114
admin/donors.php
@ -80,7 +80,6 @@
|
||||
case 'contactsinfo_load':
|
||||
// make sure a donor id has been selected
|
||||
if($_GET['id']){
|
||||
// $sql = "SELECT
|
||||
draw_contactsinfo_form();
|
||||
}
|
||||
exit;
|
||||
@ -88,12 +87,11 @@
|
||||
|
||||
case 'contactsinfo_save':
|
||||
save_contact();
|
||||
|
||||
// draw_contactsinfo_form();
|
||||
exit;
|
||||
break;
|
||||
case 'contactsinfo_delete':
|
||||
delete_contact();
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -103,9 +101,13 @@
|
||||
'Fundraising' => 'admin/fundraising.php')
|
||||
);
|
||||
|
||||
// #FIXME should delete the contact who has been submitted in _POST
|
||||
//delete the contact who has been submitted in _POST
|
||||
function delete_contact(){
|
||||
error_("Not Implemented");
|
||||
if(array_key_exists('userid', $_POST)){
|
||||
$uid = $_POST['userid'];
|
||||
user_delete($uid);
|
||||
happy_("User with ID #" . $uid . " deleted");
|
||||
}
|
||||
}
|
||||
|
||||
// save the contact info
|
||||
@ -123,7 +125,7 @@ function save_contact(){
|
||||
|
||||
}else if($_POST['recordtype'] == 'existing'){
|
||||
// this is an existing record being updated. Load the user.
|
||||
$successMessage = i18n("Contact updated successfully: " . $_POST['userid']);
|
||||
$successMessage = i18n("Contact updated successfully");
|
||||
|
||||
$u = user_load($_POST['userid']);
|
||||
$id = intval($_POST['userid']);
|
||||
@ -216,7 +218,8 @@ function draw_contactsinfo_form($contact = null){
|
||||
WHERE year='" . $config['FAIRYEAR'] . "'
|
||||
AND sponsors_id='" . $sponsor_id . "'
|
||||
AND deleted='no'
|
||||
ORDER BY lastname,firstname");
|
||||
ORDER BY users_sponsor.primary DESC,lastname,firstname");
|
||||
|
||||
while($contact = mysql_fetch_array($query)){
|
||||
// draw a header for this user
|
||||
echo "<h3><a href=\"#\">";
|
||||
@ -235,7 +238,6 @@ function draw_contactsinfo_form($contact = null){
|
||||
}
|
||||
|
||||
// draw a form in which to enter contact info
|
||||
//FIXME - this form needs to be pretty
|
||||
function draw_contact_form($sponsor_id, $contact = null){
|
||||
if($contact != null){
|
||||
$id = $contact["id"];
|
||||
@ -250,35 +252,57 @@ function draw_contact_form($sponsor_id, $contact = null){
|
||||
echo "<input type=\"hidden\" name=\"recordtype\" value=\"existing\">\n";
|
||||
echo "<input type=\"hidden\" name=\"userid\" value=\"" . $id . "\">\n";
|
||||
}
|
||||
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Salutation")."</td><td><input type=\"text\" name=\"salutation\" value=\"".htmlspecialchars($contact['salutation'])."\" size=\"4\" maxlength=\"8\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" value=\"".htmlspecialchars($contact['firstname'])."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" value=\"".htmlspecialchars($contact['lastname'])."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Position")."</td><td><input type=\"text\" name=\"position\" value=\"".htmlspecialchars($contact['position'])."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Work)")."</td><td><input type=\"text\" name=\"phonework\" value=\"".htmlspecialchars($contact['phonework'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Cell)")."</td><td><input type=\"text\" name=\"phonecell\" value=\"".htmlspecialchars($contact['phonecell'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Home)")."</td><td><input type=\"text\" name=\"phonehome\" value=\"".htmlspecialchars($contact['phonehome'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Fax")."</td><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($contact['fax'])."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Email")."</td><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($contact['email'])."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Notes")."</td><td><textarea name=\"notes\" rows=\"8\" cols=\"60\">".htmlspecialchars($contact['notes'])."</textarea></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Primary Contact")."</td><td><select name=\"primary\">";
|
||||
$sel = ($contact['primary'] == 'yes') ? 'selected="selected"': '';
|
||||
echo "<option value=\"yes\" $sel>".i18n('Yes')."</option>";
|
||||
$sel = ($contact['primary'] == 'no') ? 'selected="selected"': '';
|
||||
echo "<option value=\"no\" $sel>".i18n('No')."</option>";
|
||||
echo "</select></td></tr>\n";
|
||||
echo "<tr>";
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<td><?=i18n("Salutation"); ?></td>
|
||||
<td><input type="text" name="salutation" value = "<?=htmlspecialchars($contact['salutation'])?>"></td>
|
||||
<td><?=i18n("Position"); ?></td>
|
||||
<td><input type="text" name="position" value = "<?=htmlspecialchars($contact['position'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("First Name"); ?></td>
|
||||
<td><input type="text" name="firstname" value = "<?=htmlspecialchars($contact['firstname'])?>"></td>
|
||||
<td><?=i18n("Last Name"); ?></td>
|
||||
<td><input type="text" name="lastname" value = "<?=htmlspecialchars($contact['lastname'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Phone (Work)"); ?></td>
|
||||
<td><input type="text" name="phonework" value = "<?=htmlspecialchars($contact['phonework'])?>"></td>
|
||||
<td><?=i18n("Phone (Cell)"); ?></td>
|
||||
<td><input type="text" name="phonecell" value = "<?=htmlspecialchars($contact['phonecell'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Phone (Home)"); ?></td>
|
||||
<td><input type="text" name="phonehome" value = "<?=htmlspecialchars($contact['phonehome'])?>"></td>
|
||||
<td><?=i18n("Fax"); ?></td>
|
||||
<td><input type="text" name="fax" value = "<?=htmlspecialchars($contact['fax'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Email"); ?></td>
|
||||
<td colspan="3"><input type="text" name="email" size="60" value = "<?=htmlspecialchars($contact['email'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Notes"); ?></td>
|
||||
<td colspan="3"><textarea name="notes" cols="60" rows="4"><?=htmlspecialchars($contact['notes'])?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Primary Contact")?></td>
|
||||
<td>
|
||||
<label><?=i18n("Yes")?><input type="radio" name="primary" value="yes" <?php if($contact['primary'] == 'yes') echo "CHECKED";?></label>
|
||||
<label><?=i18n("No")?><input type="radio" name="primary" value="no" <?php if($contact['primary'] != 'yes') echo "CHECKED";?>></label>
|
||||
</td>
|
||||
<?php
|
||||
echo "<td align=\"center\"><input type=\"submit\" value=\"" . i18n("Save") . "\" onClick=\"return contactsinfo_save('" . $id . "')\" /></td>";
|
||||
if( $id == "new"){
|
||||
echo "<td></td>";
|
||||
}else{
|
||||
echo "<td align=\"center\"><input type=\"submit\" value=\"" . i18n("Remove") . "\" onClick=\"return contactsinfo_delete('" . $id . "')\" /></td>";
|
||||
}
|
||||
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
echo "<td>";
|
||||
if($id != "new")
|
||||
echo "<input type=\"submit\" value=\"" . i18n("Remove") . "\" onClick=\"return contactsinfo_delete('" . $id . "')\" />";
|
||||
echo "</td>";
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
@ -416,13 +440,23 @@ function update_contactsinfo()
|
||||
);
|
||||
}
|
||||
|
||||
function contactsinfo_save(id) {
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save", $("#contact_" + id).serializeArray());
|
||||
function contactsinfo_save(uid) {
|
||||
var id=sponsor_id;
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(),
|
||||
function() {
|
||||
$("#levelaccordion").accordion();
|
||||
update_contactsinfo();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function contactsinfo_delete(id) {
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete", $("#contact_" + id).serializeArray());
|
||||
function contactsinfo_delete(uid) {
|
||||
var id=sponsor_id;
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(),
|
||||
function() {
|
||||
$("#levelaccordion").accordion();
|
||||
update_contactsinfo();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user