Skip to content

Commit aebd95a

Browse files
committed
Added Delete Donor logic, and check
1 parent 0fca4dc commit aebd95a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

classes/Donor.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,26 @@ public function view(){
207207
}
208208

209209
static public function request_handler(){
210-
if ($_POST['Function']=='MergeDonor' && $_POST['DonorId']){
210+
if ($_POST['table']=='Donor' && $_POST['DonorId'] && $_POST['Function']=="Delete"){
211+
//check if any donations connected to this account or merged ids..
212+
$donations=Donation::get(array('DonorId='.$_POST['DonorId']));
213+
if (sizeof($donations)>0){
214+
self::display_error("Can't delete Donor #".$_POST['DonorId'].". There are ".sizeof($donations)." donation(s) attached to this.");
215+
return false;
216+
}
217+
$donors=Donation::get(array('MergedId='.$_POST['DonorId']));
218+
if (sizeof($donors)>0){
219+
self::display_error("Can't delete Donor #".$_POST['DonorId'].". There are ".sizeof($donors)." donors merged to this entry.");
220+
return false;
221+
}else{
222+
$dSQL="DELETE FROM ".Donor::get_table_name()." WHERE `DonorId`='".$_POST['DonorId']."'";
223+
self::db()->query($dSQL);
224+
self::display_notice("Deleted Donor #".$_POST['DonorId'].".");
225+
return true;
226+
}
227+
228+
229+
}elseif ($_POST['Function']=='MergeDonor' && $_POST['DonorId']){
211230
//self::dump($_POST);
212231
$data=array();
213232
foreach(self::s()->fillable as $field){

0 commit comments

Comments
 (0)