Merge pull request #23960 from seamuslee001/fix_static_calling_trait
[civicrm-core.git] / CRM / Core / Page / AJAX / RecurringEntity.php
1 <?php
2 /*
3 * To change this license header, choose License Headers in Project Properties.
4 * To change this template file, choose Tools | Templates
5 * and open the template in the editor.
6 */
7
8 /**
9 * Description of EntityApplyChangesTo
10 *
11 * @author Priyanka
12 */
13 class CRM_Core_Page_AJAX_RecurringEntity {
14
15 public static function updateMode() {
16 $finalResult = [];
17 if (!empty($_REQUEST['mode']) && !empty($_REQUEST['entityId']) && !empty($_REQUEST['entityTable'])) {
18 $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer');
19 $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer');
20 $entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String');
21 $priceSet = CRM_Utils_Type::escape($_REQUEST['priceSet'], 'String');
22
23 // CRM-21764 fix
24 // Retrieving existing priceset if price set id is not passed
25 if ($priceSet == "") {
26 $priceSetEntity = new CRM_Price_DAO_PriceSetEntity();
27 $priceSetEntity->entity_id = $entityId;
28 $priceSetEntity->entity_table = $entityTable;
29 $priceSetEntity->find(TRUE);
30 $priceSet = $priceSetEntity->price_set_id;
31 }
32 $linkedEntityTable = $_REQUEST['linkedEntityTable'];
33 $finalResult = CRM_Core_BAO_RecurringEntity::updateModeAndPriceSet($entityId, $entityTable, $mode, $linkedEntityTable, $priceSet);
34 }
35 CRM_Utils_JSON::output($finalResult);
36 }
37
38 }