From 9b15a5094c7fea1e89e43727784011d6738a18ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Sep 2014 19:15:50 +0100 Subject: [PATCH] Ajax return result correction and it's subsequent handling in js file --- CRM/Core/Page/AJAX/RecurringEntity.php | 12 ++++++++---- .../CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index a5e78c91cb..575b6d82fd 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -35,10 +35,14 @@ class CRM_Core_Page_AJAX_RecurringEntity { $dao->entity_id = $entityId; $dao->entityTable = $entityTable; } - $dao->find(TRUE); - $dao->mode = $mode; - $dao->save(); - $finalResult['status'] = 'Done'; + + if($dao->find(TRUE)){ + $dao->mode = $mode; + $dao->save(); + $finalResult['status'] = 'Done'; + }else{ + $finalResult['status'] = 'Error'; + } } echo json_encode($finalResult); CRM_Utils_System::civiExit(); diff --git a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl index 3149c13581..daa6fac1d9 100644 --- a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl @@ -117,9 +117,13 @@ data: data, url: ajaxurl, success: function (result) { - $("#repeat-mode-dailog").dialog('close'); + if(result.status != "" && result.status == 'Done'){ + $("#repeat-mode-dailog").dialog('close'); $('#mainTabContainer div:visible Form').submit(); + }else if(result.status != "" && result.status == 'Error'){ + $("#repeat-mode-dailog").html('').append("Some error ocurred, please try after some time").css('color', 'red'); } + } }); } } -- 2.25.1