Ejemplo n.º 1
0
 /**
  * Function to delete all pledge payments
  *
  * @param int $id  pledge id
  *
  * @access public
  * @static
  *
  */
 static function deletePayments($id)
 {
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::positiveInteger($id)) {
         return false;
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $payment = new CRM_Pledge_DAO_Payment();
     $payment->pledge_id = $id;
     if ($payment->find(true)) {
         //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();
     }
     $transaction->commit();
     return true;
 }
Ejemplo n.º 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);
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     //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();
     }
     $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
     require_once 'CRM/Utils/Recent.php';
     $pledgeRecent = array('id' => $id, 'type' => 'Pledge');
     CRM_Utils_Recent::del($pledgeRecent);
     return $results;
 }
Ejemplo n.º 3
0
 /**
  * Function to delete all pledge payments
  *
  * @param int $id  pledge id
  *
  * @access public
  * @static
  *
  */
 static function deletePayments($id)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $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();
     }
     $transaction->commit();
     return true;
 }