예제 #1
0
 /**
  * Delete all pledge payments.
  *
  * @param int $id
  *   Pledge id.
  *
  * @return bool
  */
 public static function deletePayments($id)
 {
     if (!CRM_Utils_Rule::positiveInteger($id)) {
         return FALSE;
     }
     $transaction = new CRM_Core_Transaction();
     $payment = new CRM_Pledge_DAO_PledgePayment();
     $payment->pledge_id = $id;
     if ($payment->find()) {
         while ($payment->fetch()) {
             //also delete associated contribution.
             if ($payment->contribution_id) {
                 CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
             }
             self::del($payment->id);
         }
     }
     $transaction->commit();
     return TRUE;
 }
예제 #2
0
파일: Pledge.php 프로젝트: hguru/224Civi
 /**
  * Find payments which can be safely canceled.
  *
  * @param int $pledgeID
  * @return array of int (civicrm_pledge_payment.id)
  */
 public static function findCancelablePayments($pledgeID)
 {
     $statuses = array_flip(CRM_Contribute_PseudoConstant::contributionStatus());
     $paymentDAO = new CRM_Pledge_DAO_PledgePayment();
     $paymentDAO->pledge_id = $pledgeID;
     $paymentDAO->whereAdd(sprintf("status_id IN (%d,%d)", $statuses['Overdue'], $statuses['Pending']));
     $paymentDAO->find();
     $paymentIDs = array();
     while ($paymentDAO->fetch()) {
         $paymentIDs[] = $paymentDAO->id;
     }
     return $paymentIDs;
 }
예제 #3
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;
 }