Skip to content

Commit

Permalink
CSTMM-37: Fix inavalid price field alert
Browse files Browse the repository at this point in the history
Applying changes from :

civicrm#28322

 which is included in civicrm 5.69.0
  • Loading branch information
Muhammad Shahrukh authored and shahrukh-compuco committed Sep 9, 2024
1 parent 5fbf17b commit 336078b
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions CRM/Utils/Check/Component/PriceFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
+--------------------------------------------------------------------+
*/

use Psr\Log\LogLevel;

/**
*
* @package CRM
Expand All @@ -27,6 +29,17 @@ public function checkPriceFields() {
INNER JOIN civicrm_price_field psf ON psf.price_set_id = ps.id
INNER JOIN civicrm_price_field_value pfv ON pfv.price_field_id = psf.id
LEFT JOIN civicrm_financial_type cft ON cft.id = pfv.financial_type_id
INNER JOIN civicrm_price_set_entity pse ON entity_table = 'civicrm_contribution_page' AND ps.id = pse.price_set_id
INNER JOIN civicrm_contribution_page cp ON cp.id = pse.entity_id AND cp.is_active = 1
WHERE cft.id IS NULL OR cft.is_active = 0
UNION
SELECT DISTINCT ps.title as ps_title, ps.id as ps_id, psf.label as psf_label
FROM civicrm_price_set ps
INNER JOIN civicrm_price_field psf ON psf.price_set_id = ps.id
INNER JOIN civicrm_price_field_value pfv ON pfv.price_field_id = psf.id
LEFT JOIN civicrm_financial_type cft ON cft.id = pfv.financial_type_id
INNER JOIN civicrm_price_set_entity pse ON entity_table = 'civicrm_event' AND ps.id = pse.price_set_id
INNER JOIN civicrm_event ce ON ce.id = pse.entity_id AND ce.is_active = 1
WHERE cft.id IS NULL OR cft.is_active = 0";
$dao = CRM_Core_DAO::executeQuery($sql);
$count = 0;
Expand All @@ -39,20 +52,20 @@ public function checkPriceFields() {
'action' => 'browse',
'sid' => $dao->ps_id,
]);
$html .= "<tr><td>$dao->ps_title</td><td>$dao->psf_label</td><td><a href='$url'>View Price Set Fields</a></td></tr>";
$html .= "<tr><td>$dao->ps_title</td><td>$dao->psf_label</td><td><a href='$url'>" . ts('View Price Set Fields') . '</a></td></tr>';
}
if ($count > 0) {
$msg = "<p>the following Price Set Fields use disabled or invalid financial types and need to be fixed if they are to still be used.<p>
<p><table><thead><tr><th>Price Set</th><th>Price Set Field</th><th>Action Link</th>
</tr></thead><tbody>
$html
</tbody></table></p>";
$msg = '<p>' . ts('The following Price Set Fields use disabled or invalid financial types and need to be fixed if they are to still be used.') . '<p>'
. '<p><table><thead><tr><th>' . ts('Price Set') . '</th><th>' . ts('Price Set Field') . '</th><th>' . ts('Action') . '</th>'
. '</tr></thead><tbody>'
. $html
. '</tbody></table></p>';
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts($msg),
ts('Invalid Price Fields'),
\Psr\Log\LogLevel::WARNING,
'fa-lock'
$msg,
ts('Invalid Price Fields'),
LogLevel::WARNING,
'fa-lock'
);
}
return $messages;
Expand Down

0 comments on commit 336078b

Please sign in to comment.