return ts('Batch %1', array(1 => $batchNo)) . ': ' . date('Y-m-d');
}
- /**
- * Create entity batch entry.
- *
- * @param array $params
- * @return array
- */
- public static function addBatchEntity(&$params) {
- $op = 'edit';
- $entityId = CRM_Utils_Array::value('id', $params);
- if (!$entityId) {
- $op = 'create';
- }
- CRM_Utils_Hook::pre($op, 'EntityBatch', $entityId, $params);
- $entityBatch = new CRM_Batch_DAO_EntityBatch();
- $entityBatch->copyValues($params);
- $entityBatch->save();
- CRM_Utils_Hook::post($op, 'EntityBatch', $entityBatch->id, $entityBatch);
- return $entityBatch;
- }
-
- /**
- * Remove entries from entity batch.
- * @param array $params
- * @return CRM_Batch_DAO_EntityBatch
- */
- public static function removeBatchEntity($params) {
- $entityBatch = new CRM_Batch_DAO_EntityBatch();
- $entityId = CRM_Utils_Array::value('id', $params);
- CRM_Utils_Hook::pre('delete', 'EntityBatch', $entityId, $params);
- $entityBatch->copyValues($params);
- $entityBatch->delete();
- CRM_Utils_Hook::post('delete', 'EntityBatch', $entityBatch->id, $entityBatch);
- return $entityBatch;
- }
-
/**
* Delete batch entry.
*
*/
class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch {
+ /**
+ * Create entity batch entry.
+ *
+ * @param array $params
+ * @return array
+ */
+ public static function create(&$params) {
+ $op = 'edit';
+ $entityId = CRM_Utils_Array::value('id', $params);
+ if (!$entityId) {
+ $op = 'create';
+ }
+ CRM_Utils_Hook::pre($op, 'EntityBatch', $entityId, $params);
+ $entityBatch = new CRM_Batch_DAO_EntityBatch();
+ $entityBatch->copyValues($params);
+ $entityBatch->save();
+ CRM_Utils_Hook::post($op, 'EntityBatch', $entityBatch->id, $entityBatch);
+ return $entityBatch;
+ }
+
+ /**
+ * Remove entries from entity batch.
+ * @param array $params
+ * @return CRM_Batch_DAO_EntityBatch
+ */
+ public static function del($params) {
+ $entityBatch = new CRM_Batch_DAO_EntityBatch();
+ $entityId = CRM_Utils_Array::value('id', $params);
+ CRM_Utils_Hook::pre('delete', 'EntityBatch', $entityId, $params);
+ $entityBatch->copyValues($params);
+ $entityBatch->delete();
+ CRM_Utils_Hook::post('delete', 'EntityBatch', $entityBatch->id, $entityBatch);
+ return $entityBatch;
+ }
+
}
'entity_table' => 'civicrm_financial_trxn',
'entity_id' => $financialTxn->id,
);
- CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
+ CRM_Batch_BAO_EntityBatch::create($entityParams);
}
// when a fee is charged
$entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
$methods = array(
- 'assign' => 'addBatchEntity',
- 'remove' => 'removeBatchEntity',
+ 'assign' => 'create',
+ 'remove' => 'del',
'reopen' => 'create',
'close' => 'create',
'delete' => 'deleteBatch',
'batch_id' => $entityID,
);
if ($action == 'Assign') {
- $updated = CRM_Batch_BAO_Batch::addBatchEntity($params);
+ $updated = CRM_Batch_BAO_EntityBatch::create($params);
}
else {
- $updated = CRM_Batch_BAO_Batch::removeBatchEntity($params);
+ $updated = CRM_Batch_BAO_EntityBatch::del($params);
}
}
}
});
function assignRemove(recordID, op) {
var recordBAO = 'CRM_Batch_BAO_Batch';
+ if (op == 'assign' || op == 'remove') {
+ recordBAO = 'CRM_Batch_BAO_EntityBatch';
+ }
var entityID = {/literal}"{$entityID}"{literal};
if (op == 'close' || op == 'export') {
var mismatch = checkMismatch();