forked from science-ation/science-ation
Add ability to create new sponsors usign the popup editor - basically it posts a sponsor_id=-1 and which causes it to insert a new record, then do the normal save, then it closes and re-opens the editor with the id that is returned by the save post via json
This commit is contained in:
parent
c3b532b161
commit
ed72fb3944
@ -35,7 +35,13 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'organizationinfo_save':
|
case 'organizationinfo_save':
|
||||||
$id=$_POST['sponsor_id'];
|
$id=intval($_POST['sponsor_id']);
|
||||||
|
if($id==-1) {
|
||||||
|
$q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
|
||||||
|
$id=mysql_insert_id();
|
||||||
|
echo json_encode(array("id"=>$id));
|
||||||
|
}
|
||||||
|
|
||||||
if($id) {
|
if($id) {
|
||||||
$exec="UPDATE sponsors SET ".
|
$exec="UPDATE sponsors SET ".
|
||||||
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
|
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
|
||||||
@ -59,7 +65,6 @@
|
|||||||
//FIXME accept the logo
|
//FIXME accept the logo
|
||||||
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
|
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
|
||||||
|
|
||||||
happy_("Organization Info Saved");
|
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
break;
|
break;
|
||||||
@ -126,8 +131,15 @@ function popup_editor(id)
|
|||||||
$('#popup_editor').dialog('option', 'height', h);
|
$('#popup_editor').dialog('option', 'height', h);
|
||||||
$("#popup_editor").dialog('open');
|
$("#popup_editor").dialog('open');
|
||||||
|
|
||||||
$('#editor_tabs').tabs('option', 'disabled', []);
|
if(id==-1) {
|
||||||
$('#editor_tabs').tabs('option', 'selected', 0);
|
$('#editor_tabs').tabs('option', 'selected', 0);
|
||||||
|
$('#editor_tabs').tabs('option', 'disabled', [1,2,3]);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#editor_tabs').tabs('option', 'selected', 0);
|
||||||
|
$('#editor_tabs').tabs('option', 'disabled', []);
|
||||||
|
}
|
||||||
|
|
||||||
update_organizationinfo();
|
update_organizationinfo();
|
||||||
return false;
|
return false;
|
||||||
@ -136,7 +148,12 @@ function popup_editor(id)
|
|||||||
function update_organizationinfo()
|
function update_organizationinfo()
|
||||||
{
|
{
|
||||||
var id=sponsor_id;
|
var id=sponsor_id;
|
||||||
if(!sponsor_id) return false;
|
if(!sponsor_id)
|
||||||
|
return false;
|
||||||
|
if(sponsor_id==-1) {
|
||||||
|
$("#sponsor_id").val(-1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id,
|
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id,
|
||||||
function(json){
|
function(json){
|
||||||
@ -161,7 +178,18 @@ function update_organizationinfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
function organizationinfo_save() {
|
function organizationinfo_save() {
|
||||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray());
|
|
||||||
|
//if we're creating we need to do the post, and get the id it returns, so we can re-open the popup window with that id
|
||||||
|
if($("#sponsor_id").val()==-1) {
|
||||||
|
$.post("<?$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray(),
|
||||||
|
function(json) {
|
||||||
|
$("#popup_editor").dialog('close');
|
||||||
|
popup_editor(json.id);
|
||||||
|
},
|
||||||
|
"json");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,43 +297,6 @@ function activityinfo_save() {
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
|
|
||||||
if($_POST['save']=="edit" || $_POST['save']=="add")
|
|
||||||
{
|
|
||||||
if($_POST['save']=="add")
|
|
||||||
{
|
|
||||||
$q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
|
|
||||||
$id=mysql_insert_id();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$id=$_POST['id'];
|
|
||||||
|
|
||||||
|
|
||||||
$exec="UPDATE sponsors SET ".
|
|
||||||
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
|
|
||||||
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
|
|
||||||
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
|
|
||||||
"province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
|
|
||||||
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
|
|
||||||
"phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
|
|
||||||
"tollfree='".mysql_escape_string(stripslashes($_POST['tollfree']))."', ".
|
|
||||||
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
|
|
||||||
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
|
|
||||||
"website='".mysql_escape_string(stripslashes($_POST['website']))."', ".
|
|
||||||
"notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
|
|
||||||
"donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ".
|
|
||||||
"fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ".
|
|
||||||
"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
|
|
||||||
"waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."', ".
|
|
||||||
"taxreceiptrequired='".mysql_escape_string(stripslashes($_POST['taxreceiptrequired']))."' ".
|
|
||||||
"WHERE id='$id'";
|
|
||||||
mysql_query($exec);
|
|
||||||
|
|
||||||
if($_POST['save']=="add")
|
|
||||||
echo happy("Sponsor successfully added");
|
|
||||||
else
|
|
||||||
echo happy("Successfully saved changes to sponsor");
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_GET['action']=="delete" && $_GET['delete'])
|
if($_GET['action']=="delete" && $_GET['delete'])
|
||||||
{
|
{
|
||||||
//dont allow any deleting until we figure out what we need to do, infact, i think we never should hard delete
|
//dont allow any deleting until we figure out what we need to do, infact, i think we never should hard delete
|
||||||
@ -314,73 +305,7 @@ function activityinfo_save() {
|
|||||||
// echo happy("Sponsors cannot be deleted");
|
// echo happy("Sponsors cannot be deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['action']=="edit" || $_GET['action']=="add")
|
echo "<a href=\"#\" onclick=\"popup_editor(-1)\">Add New Sponsor</a>\n";
|
||||||
{
|
|
||||||
|
|
||||||
echo "<a href=\"sponsors.php\"><< ".i18n("Back to Award Sponsors")."</a>\n";
|
|
||||||
if($_GET['action']=="edit")
|
|
||||||
{
|
|
||||||
echo "<h3>".i18n("Edit Award Sponsor")."</h3>\n";
|
|
||||||
$buttontext="Save Sponsor";
|
|
||||||
$q=mysql_query("SELECT * FROM sponsors WHERE id='".$_GET['edit']."'");
|
|
||||||
$r=mysql_fetch_object($q);
|
|
||||||
}
|
|
||||||
else if($_GET['action']=="add")
|
|
||||||
{
|
|
||||||
echo "<h3>".i18n("Add New Award Sponsor")."</h3>\n";
|
|
||||||
$buttontext="Add Sponsor";
|
|
||||||
}
|
|
||||||
$buttontext=i18n($buttontext);
|
|
||||||
|
|
||||||
echo "<form method=\"post\" action=\"sponsors.php\">\n";
|
|
||||||
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
|
|
||||||
|
|
||||||
if($_GET['action']=="edit")
|
|
||||||
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
|
|
||||||
|
|
||||||
echo "<table class=\"tableedit\">\n";
|
|
||||||
echo "<tr><th>".i18n("Organization Name")."</th><td><input class=\"translatable\" type=\"text\" id=\"organization\" name=\"organization\" value=\"".htmlspecialchars($r->organization)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Address")."</th><td><input type=\"text\" name=\"address\" value=\"".htmlspecialchars($r->address)."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("City")."</th><td><input type=\"text\" name=\"city\" value=\"".htmlspecialchars($r->city)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n($config['provincestate'])."</th><td>";
|
|
||||||
emit_province_selector("province_code",$r->province_code);
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n($config['postalzip'])."</th><td><input type=\"text\" name=\"postalcode\" value=\"$r->postalcode\" size=\"8\" maxlength=\"7\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Phone")."</th><td><input type=\"text\" name=\"phone\" value=\"".htmlspecialchars($r->phone)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Toll Free")."</th><td><input type=\"text\" name=\"tollfree\" value=\"".htmlspecialchars($r->tollfree)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Fax")."</th><td><input type=\"text\" name=\"fax\" value=\"".htmlspecialchars($r->fax)."\" size=\"16\" maxlength=\"32\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Email")."</th><td><input type=\"text\" name=\"email\" value=\"".htmlspecialchars($r->email)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Website")."</th><td><input type=\"text\" name=\"website\" value=\"".htmlspecialchars($r->website)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Donation Policy URL")."</th><td><input type=\"text\" name=\"donationpolicyurl\" value=\"".htmlspecialchars($r->donationpolicyurl)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Funding Selection Date")."</th><td>";
|
|
||||||
emit_date_selector("fundingselectiondate",$r->fundingselectiondate);
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Logo")."</th><td><input type=\"file\" name=\"logo\" size=\"16\" /></td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Waiver Accepted")."</th><td>";
|
|
||||||
if($r->waiveraccepted=="no") $ch="checked=\"checked\""; else $ch="";
|
|
||||||
echo "<input type=\"radio\" $ch name=\"waiveraccepted\" value=\"no\">".i18n("No")." ";
|
|
||||||
if($r->waiveraccepted=="yes") $ch="checked=\"checked\""; else $ch="";
|
|
||||||
echo "<input type=\"radio\" $ch name=\"waiveraccepted\" value=\"yes\">".i18n("Yes")." ";
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
echo "<tr><th>".i18n("Tax Receipt Required")."</th><td>";
|
|
||||||
if($r->taxreceiptrequired=="no") $ch="checked=\"checked\""; else $ch="";
|
|
||||||
echo "<input type=\"radio\" $ch name=\"taxreceiptrequired\" value=\"no\">".i18n("No")." ";
|
|
||||||
if($r->taxreceiptrequired=="yes") $ch="checked=\"checked\""; else $ch="";
|
|
||||||
echo "<input type=\"radio\" $ch name=\"taxreceiptrequired\" value=\"yes\">".i18n("Yes")." ";
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
|
|
||||||
echo "<tr><th>".i18n("Notes")."</th><td><textarea name=\"notes\" rows=\"4\" cols=\"60\">".htmlspecialchars($r->notes)."</textarea></td></tr>\n";
|
|
||||||
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
|
|
||||||
|
|
||||||
echo "</table>\n";
|
|
||||||
echo "</form>\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "<a href=\"sponsors.php?action=add\">Add New Sponsor</a>\n";
|
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo "<table class=\"tableview\">";
|
echo "<table class=\"tableview\">";
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
@ -388,7 +313,7 @@ function activityinfo_save() {
|
|||||||
echo " <th># of Sponsorships</th>";
|
echo " <th># of Sponsorships</th>";
|
||||||
echo " <th># of Awards</th>";
|
echo " <th># of Awards</th>";
|
||||||
echo " <th># of Contacts</th>";
|
echo " <th># of Contacts</th>";
|
||||||
echo " <th>Action</th>";
|
// echo " <th>Action</th>";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
|
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
|
||||||
@ -429,22 +354,11 @@ function activityinfo_save() {
|
|||||||
echo "$numcontacts ";
|
echo "$numcontacts ";
|
||||||
echo "<a href=\"sponsor_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
|
echo "<a href=\"sponsor_contacts.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo " <td align=\"center\">";
|
|
||||||
echo "<a href=\"sponsors.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
|
|
||||||
/* cannot delete sponsors, we need to be able to link to them from other years, etc... this could be turned back on as a soft delete eventually
|
|
||||||
echo " ";
|
|
||||||
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this sponsor?')\" href=\"sponsors.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo " </td>\n";
|
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user