Beispiel #1
0
 /**
  * Function to delete the pledge
  *
  * @param int $id  pledge id
  *
  * @access public
  * @static
  *
  */
 static function deletePledge($id)
 {
     CRM_Utils_Hook::pre('delete', 'Pledge', $id, CRM_Core_DAO::$_nullArray);
     $transaction = new CRM_Core_Transaction();
     //check for no Completed Payment records with the pledge
     $payment = new CRM_Pledge_DAO_PledgePayment();
     $payment->pledge_id = $id;
     $payment->find();
     while ($payment->fetch()) {
         //also delete associated contribution.
         if ($payment->contribution_id) {
             CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
         }
         $payment->delete();
     }
     $dao = new CRM_Pledge_DAO_Pledge();
     $dao->id = $id;
     $results = $dao->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Pledge', $dao->id, $dao);
     // delete the recently created Pledge
     $pledgeRecent = array('id' => $id, 'type' => 'Pledge');
     CRM_Utils_Recent::del($pledgeRecent);
     return $results;
 }
Beispiel #2
0
 /**
  * Function to delete the pledge
  *
  * @param int $id  pledge id
  *
  * @access public
  * @static
  *
  */
 static function deletePledge($id)
 {
     CRM_Utils_Hook::pre('delete', 'Pledge', $id, CRM_Core_DAO::$_nullArray);
     //check for no Completed Payment records with the pledge
     require_once 'CRM/Pledge/DAO/Payment.php';
     $payment = new CRM_Pledge_DAO_Payment();
     $payment->pledge_id = $id;
     $payment->find();
     while ($payment->fetch()) {
         //also delete associated contribution.
         if ($payment->contribution_id) {
             require_once 'CRM/Contribute/BAO/Contribution.php';
             CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
         }
         $payment->delete();
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $results = null;
     $dao = new CRM_Pledge_DAO_Pledge();
     $dao->id = $id;
     $results = $dao->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Pledge', $dao->id, $dao);
     // delete the recently created Activity
     require_once 'CRM/Utils/Recent.php';
     CRM_Utils_Recent::del($id);
     return $results;
 }