Commit fd7abdce authored by Pradeep Nayak's avatar Pradeep Nayak

-- removed hardcoded values, added sql upgrade script to handle civicrm_batch.status_id, CRM-14191

----------------------------------------
* CRM-14191: There are 3 options with value=0 in option group "batch_status"
  https://issues.civicrm.org/jira/browse/CRM-14191
parent c9747604
......@@ -124,7 +124,7 @@ class CRM_Batch_Form_Batch extends CRM_Admin_Form {
}
// always create with data entry status
$params['status_id'] = 3;
$params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status','Data Entry');;
$batch = CRM_Batch_BAO_Batch::create($params);
// redirect to batch entry page.
......
......@@ -370,7 +370,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
$paramValues = array(
'id' => $this->_batchId,
// close status
'status_id' => 2,
'status_id' => CRM_Core_OptionGroup::getValue('batch_status','Closed'),
'total' => $params['actualBatchTotal'],
);
......
......@@ -88,7 +88,7 @@ class CRM_Batch_Page_AJAX {
if ($context != 'financialBatch') {
// data entry status batches
$params['status_id'] = 3;
$params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status','Data Entry');
}
$params['context'] = $context;
......
......@@ -109,7 +109,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
$session = CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches',
"reset=1&batchStatus=5"));
"reset=1&batchStatus={$this->_exportStatusId}"));
}
/**
......
......@@ -55,16 +55,17 @@ class CRM_Financial_Form_Search extends CRM_Core_Form {
$attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
$attributes['total']['class'] = $attributes['item_count']['class'] = 'number';
$this->add('text', 'title', ts('Batch Name'), $attributes['title']);
$batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
$this->add(
'select',
'status_id',
ts('Batch Status'),
array(
'' => ts('- any -' ),
1 => ts('Open'),
2 => ts('Closed'),
5 => ts('Exported'),
array_search('Open', $batchStatus) => ts('Open'),
array_search('Closed', $batchStatus) => ts('Closed'),
array_search('Exported', $batchStatus) => ts('Exported'),
),
false
);
......
......@@ -3,15 +3,34 @@
SELECT @option_group_id_batch_status := max(id) from civicrm_option_group where name = 'batch_status';
SELECT @weight := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value
UPDATE civicrm_option_value
SET value = (Select @weight := @weight +1),
weight = @weight
where option_group_id = @option_group_id_batch_status AND name IN ('Data Entry', 'Reopened', 'Exported') AND value = 0 ORDER BY id;
WHERE option_group_id = @option_group_id_batch_status AND name IN ('Data Entry', 'Reopened', 'Exported') AND value = 0 ORDER BY id;
SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode';
SELECT @weights := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_modes;
UPDATE civicrm_option_value
UPDATE civicrm_option_value
SET value = (Select @weights := @weights +1),
weight = @weights
where option_group_id = @option_group_id_batch_modes AND name IN ('Manual Batch', 'Automatic Batch') AND value = 0;
\ No newline at end of file
WHERE option_group_id = @option_group_id_batch_modes AND name IN ('Manual Batch', 'Automatic Batch') AND value = 0;
SELECT @manual_mode_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_modes AND name = 'Manual Batch';
UPDATE civicrm_batch SET mode_id = @manual_mode_id WHERE (mode_id IS NULL OR mode_id = 0) AND type_id IS NULL;
SELECT @data_entry_status_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status AND name = 'Data Entry';
UPDATE civicrm_batch SET status_id = @data_entry_status_id WHERE status_id = 3 AND type_id IS NOT NULL;
SELECT @exported_status_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status AND name = 'Exported';
UPDATE civicrm_navigation SET url = CONCAT('civicrm/financial/financialbatches?reset=1&batchStatus=', @exported_status_id) WHERE name = 'Exported Batches';
-- update status_id to Exported
SELECT @export_activity_type := max(value) FROM civicrm_option_value cov
INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id
WHERE cog.name = 'activity_type' AND cov.name = 'Export Accounting Batch';
UPDATE civicrm_batch cb
INNER JOIN civicrm_activity ca ON ca.source_record_id = cb.id
SET cb.status_id = @exported_status_id
WHERE cb.status_id = 0 AND ca.activity_type_id = @export_activity_type;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment