Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Extensions
Line Item Editor
Commits
3ebbe2df
Unverified
Commit
3ebbe2df
authored
Sep 17, 2018
by
Monish Deb
Committed by
GitHub
Sep 17, 2018
Browse files
Merge pull request #15 from agileware/CIVICRM-868
CIVICRM-868: Hiding tax field on edit line item form if no tax collected.
parents
9578151c
e97ddb76
Changes
2
Hide whitespace changes
Inline
Side-by-side
CRM/Lineitemedit/Form/Edit.php
View file @
3ebbe2df
...
...
@@ -28,7 +28,18 @@ class CRM_Lineitemedit_Form_Edit extends CRM_Core_Form {
$this
->
assignFormVariables
();
}
/**
* Check if there is tax value for selected financial type.
* @param $financialTypeId
* @return bool
*/
private
function
isTaxEnabledInFinancialType
(
$financialTypeId
)
{
$taxRates
=
CRM_Core_PseudoConstant
::
getTaxRates
();
return
(
isset
(
$taxRates
[
$financialTypeId
]))
?
TRUE
:
FALSE
;
}
public
function
assignFormVariables
(
$params
=
[])
{
$this
->
_lineitemInfo
=
civicrm_api3
(
'lineItem'
,
'getsingle'
,
array
(
'id'
=>
$this
->
_id
));
$this
->
_lineitemInfo
[
'tax_amount'
]
=
CRM_Utils_Array
::
value
(
'tax_amount'
,
$this
->
_lineitemInfo
,
0.00
);
foreach
(
CRM_Lineitemedit_Util
::
getLineitemFieldNames
()
as
$attribute
)
{
...
...
@@ -105,6 +116,8 @@ class CRM_Lineitemedit_Form_Edit extends CRM_Core_Form {
$this
->
assign
(
'taxRates'
,
json_encode
(
CRM_Core_PseudoConstant
::
getTaxRates
()));
$this
->
assign
(
'isTaxEnabled'
,
$this
->
isTaxEnabledInFinancialType
(
$this
->
_values
[
'financial_type_id'
]));
$this
->
addFormRule
(
array
(
__CLASS__
,
'formRule'
),
$this
);
$this
->
addButtons
(
array
(
...
...
@@ -148,6 +161,10 @@ class CRM_Lineitemedit_Form_Edit extends CRM_Core_Form {
$this
->
_lineitemInfo
[
'contribution_id'
],
'contact_id'
);
if
(
!
$this
->
isTaxEnabledInFinancialType
(
$values
[
'financial_type_id'
]))
{
$values
[
'tax_amount'
]
=
''
;
}
$params
=
array
(
'id'
=>
$this
->
_id
,
'financial_type_id'
=>
$values
[
'financial_type_id'
],
...
...
@@ -157,6 +174,7 @@ class CRM_Lineitemedit_Form_Edit extends CRM_Core_Form {
'line_total'
=>
$values
[
'line_total'
],
'tax_amount'
=>
CRM_Utils_Array
::
value
(
'tax_amount'
,
$values
,
0.00
),
);
$lineItem
=
CRM_Price_BAO_LineItem
::
create
(
$params
);
$lineItem
=
$lineItem
->
toArray
();
...
...
templates/CRM/Lineitemedit/Form/Edit.tpl
View file @
3ebbe2df
{* HEADER *}
{
foreach
from
=
$fieldNames
item
=
fieldName
}
<div
class=
"crm-section"
>
<div
class=
"crm-section"
{
if
$fieldName
==
'tax_amount'
}
id=
"crm-section-tax-amount"
{/
if
}
{
if
$fieldName
==
'tax_amount'
and
not
$isTaxEnabled
}
style=
"display: none;"
{/
if
}
>
<div
class=
"label"
>
{
$form
.
$fieldName.label
}
</div>
<div
class=
"content"
>
{
if
in_array
(
$fieldName
,
array
(
'unit_price'
,
'line_total'
,
'tax_amount'
))
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment