Exemplo n.º 1
0
 /**
  * Will trigger the execution of the given suggestion (identified by its hash)
  */
 function execute_suggestion($suggestion_hash, $parameters, $btx_bao, $choices)
 {
     // load BTX object if not provided
     if (!$btx_bao) {
         $btx_bao = new CRM_Banking_BAO_BankTransaction();
         $btx_bao->get('id', $parameters['execute']);
     }
     $suggestion = $btx_bao->getSuggestionByHash($suggestion_hash);
     if ($suggestion) {
         // update the parameters
         $suggestion->update_parameters($parameters);
         $btx_bao->saveSuggestions();
         $suggestion->execute($btx_bao);
         // create a notification bubble for the user
         $text = $suggestion->visualize_execution($btx_bao);
         if ($btx_bao->status_id == $choices['processed']['id']) {
             CRM_Core_Session::setStatus(ts("The transaction was booked.") . "<br/>" . $text, ts("Transaction closed"), 'info');
         } elseif ($btx_bao->status_id == $choices['ignored']['id']) {
             CRM_Core_Session::setStatus(ts("The transaction was ignored.") . "<br/>" . $text, ts("Transaction closed"), 'info');
         } else {
             CRM_Core_Session::setStatus(ts("The transaction could not be closed."), ts("Error"), 'alert');
         }
     } else {
         CRM_Core_Session::setStatus(ts("Selected suggestions disappeared. Suggestion NOT executed!"), ts("Internal Error"), 'error');
     }
 }