Commit | Line | Data |
---|---|---|
23dba589 SL |
1 | <?php |
2 | ||
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
23dba589 | 6 | | | |
bc77d7c0 TO |
7 | | This work is published under the GNU AGPLv3 license with some | |
8 | | permitted exceptions and without any warranty. For full license | | |
9 | | and copyright information, see https://civicrm.org/licensing | | |
23dba589 SL |
10 | +--------------------------------------------------------------------+ |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
23dba589 SL |
17 | */ |
18 | class CRM_Utils_Check_Component_PriceFields extends CRM_Utils_Check_Component { | |
19 | ||
20 | /** | |
21 | * Display warning about invalid priceFields | |
22 | * | |
23 | */ | |
24 | public function checkPriceFields() { | |
25 | $sql = "SELECT DISTINCT ps.title as ps_title, ps.id as ps_id, psf.label as psf_label | |
26 | FROM civicrm_price_set ps | |
27 | INNER JOIN civicrm_price_field psf ON psf.price_set_id = ps.id | |
28 | INNER JOIN civicrm_price_field_value pfv ON pfv.price_field_id = psf.id | |
29 | LEFT JOIN civicrm_financial_type cft ON cft.id = pfv.financial_type_id | |
30 | WHERE cft.id IS NULL OR cft.is_active = 0"; | |
31 | $dao = CRM_Core_DAO::executeQuery($sql); | |
32 | $count = 0; | |
33 | $html = ''; | |
be2fb01f | 34 | $messages = []; |
23dba589 SL |
35 | while ($dao->fetch()) { |
36 | $count++; | |
be2fb01f | 37 | $url = CRM_Utils_System::url('civicrm/admin/price/field', [ |
23dba589 SL |
38 | 'reset' => 1, |
39 | 'action' => 'browse', | |
6714d8d2 SL |
40 | 'sid' => $dao->ps_id, |
41 | ]); | |
23dba589 SL |
42 | $html .= "<tr><td>$dao->ps_title</td><td>$dao->psf_label</td><td><a href='$url'>View Price Set Fields</a></td></tr>"; |
43 | } | |
44 | if ($count > 0) { | |
45 | $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> | |
46 | <p><table><thead><tr><th>Price Set</th><th>Price Set Field</th><th>Action Link</th> | |
47 | </tr></thead><tbody> | |
48 | $html | |
49 | </tbody></table></p>"; | |
50 | $messages[] = new CRM_Utils_Check_Message( | |
51 | __FUNCTION__, | |
52 | ts($msg), | |
53 | ts('Invalid Price Fields'), | |
54 | \Psr\Log\LogLevel::WARNING, | |
55 | 'fa-lock' | |
56 | ); | |
57 | } | |
58 | return $messages; | |
59 | } | |
60 | ||
61 | } |