Skip to content

Commit

Permalink
BTHAB-257: Ensure the PDF option is always hidden in send invoice screen
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed Oct 19, 2023
1 parent 5971179 commit fcd2253
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions CRM/Civicase/Hook/BuildForm/AttachQuotationToInvoiceMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,21 @@ public function run(CRM_Core_Form &$form, $formName) {
return;
}

$form->add('checkbox', 'attach_quote', ts('Attach Quotation'));
$form->setDefaults(array_merge($form->_defaultValues, ['attach_quote' => TRUE]));
$contributionId = CRM_Utils_Request::retrieve('id', 'Positive', $form, FALSE);
$salesOrder = Contribution::get()
->addSelect('Opportunity_Details.Quotation')
->addWhere('Opportunity_Details.Quotation', 'IS NOT EMPTY')
->addWhere('id', 'IN', explode(',', $contributionId))
->addChain('salesOrder', CaseSalesOrder::get()
->addWhere('id', '=', '$Opportunity_Details.Quotation')
)
->execute()
->getArrayCopy();

if (!empty($salesOrder)) {
$form->add('checkbox', 'attach_quote', ts('Attach Quotation'));
$form->setDefaults(array_merge($form->_defaultValues, ['attach_quote' => TRUE]));
}

CRM_Core_Region::instance('page-body')->add([
'template' => "CRM/Civicase/Form/Contribute/AttachQuotation.tpl",
Expand Down Expand Up @@ -53,17 +66,7 @@ private function shouldRun($form, $formName) {
return FALSE;
}

$salesOrder = Contribution::get()
->addSelect('Opportunity_Details.Quotation')
->addWhere('Opportunity_Details.Quotation', 'IS NOT EMPTY')
->addWhere('id', 'IN', explode(',', $contributionId))
->addChain('salesOrder', CaseSalesOrder::get()
->addWhere('id', '=', '$Opportunity_Details.Quotation')
)
->execute()
->getArrayCopy();

return !empty($salesOrder);
return TRUE;
}

}
2 changes: 1 addition & 1 deletion templates/CRM/Civicase/Form/Contribute/AttachQuotation.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table>
<tr class="crm-email-element attach-quote">
<td class="label">{$form.attach_quote.label}</td>
<td class="html-adjust">{$form.attach_quote.html} <span>Yes</span></td>
<td class="html-adjust">{$form.attach_quote.html} {if isset($form.attach_quote.html)}<span>Yes</span>{/if}</td>
</tr>
</table>
<div id="editMessageDetails"></div>
Expand Down

0 comments on commit fcd2253

Please sign in to comment.