Skip to content

Commit

Permalink
Merge pull request #1002 from compucorp/BTHAB-158-invoice-fixes
Browse files Browse the repository at this point in the history
BTHAB-158 Invoice list Fixes
  • Loading branch information
shahrukh-compuco authored Jan 29, 2024
2 parents f9bb8c4 + 9c51d2e commit 212422b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions CRM/Civicase/Hook/BuildForm/RefreshInvoiceListOnUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* Refresh the invoice list upon updating an invoice.
*/
class CRM_Civicase_Hook_BuildForm_RefreshInvoiceListOnUpdate {

/**
* Refresh the invoice list upon updating an invoice.
*
* @param CRM_Core_Form $form
* Form Class object.
* @param string $formName
* Form Name.
*/
public function run(CRM_Core_Form &$form, $formName) {
if (!$this->shouldRun($form, $formName)) {
return;
}

CRM_Core_Resources::singleton()->addScript(
"CRM.$(function($) {
$(\"a[target='crm-popup']\").on('crmPopupFormSuccess', function (e) {
CRM.refreshParent(e);
});
});
");
}

/**
* Determines if the hook will run.
*
* @param CRM_Core_Form $form
* Form Class object.
* @param string $formName
* Form Name.
*
* @return bool
* TRUE if the hook should run, FALSE otherwise.
*/
private function shouldRun($form, $formName) {
if ($formName !== 'CRM_Contribute_Form_Contribution' || $form->getAction() !== CRM_Core_Action::UPDATE || !isset($_GET['snippet'])) {
return FALSE;
}

return TRUE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ <h1 crm-page-title>{{ ts('Quotation Invoices') }}</h1>
</div>
</div>
</div>
<style>
#bootstrap-theme crm-search-display-table p.alert-info {
background-color: transparent;
border: none;
}
</style>
1 change: 1 addition & 0 deletions civicase.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function civicase_civicrm_buildForm($formName, &$form) {
new CRM_Civicase_Hook_BuildForm_AddSalesOrderLineItemsToContribution(),
new CRM_Civicase_Hook_BuildForm_AddEntityReferenceToCustomField(),
new CRM_Civicase_Hook_BuildForm_AttachQuotationToInvoiceMail(),
new CRM_Civicase_Hook_BuildForm_RefreshInvoiceListOnUpdate(),
];

foreach ($hooks as $hook) {
Expand Down

0 comments on commit 212422b

Please sign in to comment.