generated from compucorp/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESEB-76: Add Exchange Rate settings page
- Loading branch information
1 parent
5a0cc23
commit 5c73c72
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
use CRM_Financeextras_ExtensionUtil as E; | ||
|
||
/** | ||
* Exchange Rate Settings form controller | ||
*/ | ||
class CRM_Financeextras_Form_ExchangeRateSettings extends CRM_Core_Form { | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildQuickForm() { | ||
CRM_Utils_System::setTitle(ts('Exchange Rate Settings')); | ||
|
||
$this->add( | ||
'checkbox', | ||
'display_on_invoice', | ||
ts('Display currency conversion for Tax on invoices') | ||
); | ||
|
||
$this->addCurrency('sales_tax_currency', ts('Sales Tax Currency'), FALSE); | ||
|
||
$this->addButtons([ | ||
[ | ||
'type' => 'submit', | ||
'name' => E::ts('Save'), | ||
'isDefault' => TRUE, | ||
], | ||
[ | ||
'type' => 'cancel', | ||
'name' => E::ts('Cancel'), | ||
'class' => 'btn-secondary-outline', | ||
], | ||
]); | ||
|
||
$elementWithHelpTexts = ['display_on_invoice', 'sales_tax_currency']; | ||
|
||
$this->assign('help', $elementWithHelpTexts); | ||
$this->assign('elementNames', $this->getRenderableElementNames()); | ||
} | ||
|
||
/** | ||
* Called after form has been successfully submitted | ||
*/ | ||
public function postProcess() { | ||
$values = $this->exportValues(); | ||
|
||
Civi::settings()->set('fe_exchange_rate_settings', $values); | ||
|
||
CRM_Core_Session::setStatus('Currency Exchange settings saved successfully', '', 'success'); | ||
} | ||
|
||
public function setDefaultValues() { | ||
return Civi::settings()->get('fe_exchange_rate_settings'); | ||
} | ||
|
||
/** | ||
* Get the fields/elements defined in this form. | ||
* | ||
* @return array (string) | ||
*/ | ||
public function getRenderableElementNames() { | ||
$elementNames = []; | ||
foreach ($this->_elements as $element) { | ||
/** @var HTML_QuickForm_Element $element */ | ||
$label = $element->getLabel(); | ||
if (!empty($label)) { | ||
$elementNames[] = $element->getName(); | ||
} | ||
} | ||
return $elementNames; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{htxt id="display_on_invoice"} | ||
{ts}Enabling this will display a section on an invoice or credit note with the currency conversation for any tax amounts from the invoice currency to the CiviCRM default currency.{/ts} | ||
{/htxt} | ||
{htxt id="sales_tax_currency"} | ||
{ts}Specify the sales tax currency that any new invoice or credit note will display a currency conversion to.{/ts} | ||
{/htxt} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div id="bootstrap-theme"> | ||
<div class="panel panel-default fe__create-form-panel"> | ||
<div class="crm-submit-buttons panel-heading"> | ||
{include file="CRM/common/formButtons.tpl" location="bottom"} | ||
</div> | ||
<div class=" panel-body"> | ||
<div class="form-hoizontal"> | ||
{foreach from=$elementNames item=elementName} | ||
<div class="form-group row {$elementName}"> | ||
<div class="col-sm-2 control-label"> | ||
{$form.$elementName.label} | ||
{if in_array($elementName, $help)} | ||
{help id="$elementName" file="CRM/Financeextras/Form/ExchangeRateSettings.hlp"} | ||
{/if} | ||
</div> | ||
<div class="col-sm-7 col-md-5"> | ||
{$form.$elementName.html} | ||
{if $elementName eq 'display_on_invoice'} | ||
<span class="invoice-check"> Enable</span> | ||
{/if} | ||
</div> | ||
</div> | ||
{/foreach} | ||
</div> | ||
</div> | ||
|
||
<div class="crm-submit-buttons panel-footer"> | ||
{include file="CRM/common/formButtons.tpl" location="bottom"} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{literal} | ||
<style> | ||
#bootstrap-theme > .fe__create-form-panel.panel > div.panel-body > div div.col-sm-2.control-label { | ||
text-align: right; | ||
} | ||
#bootstrap-theme > .fe__create-form-panel.panel > div.panel-body > div div.col-sm-2.control-label > label { | ||
display: inline; | ||
text-align: right; | ||
} | ||
.invoice-check { | ||
vertical-align: sub; | ||
} | ||
</style> | ||
{/literal} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters