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
44806b87
Commit
44806b87
authored
Feb 18, 2019
by
Edselopez
Committed by
Edsel Lopez
May 22, 2019
Browse files
Added chapter and fund for each lineitem
parent
8a50c9ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
CRM/Lineitemedit/Form/Edit.php
View file @
44806b87
...
...
@@ -127,7 +127,7 @@ class CRM_Lineitemedit_Form_Edit extends CRM_Core_Form {
// Add fund codes.
$fundCodes
=
CRM_Core_OptionGroup
::
values
(
'fund_codes'
);
$this
->
add
(
'select'
,
'fund_code'
,
ts
(
'
Chapter
Code'
),
ts
(
'
Fund
Code'
),
$fundCodes
);
$this
->
assign
(
'fieldNames'
,
$fieldNames
);
...
...
CRM/Lineitemedit/Util.php
View file @
44806b87
...
...
@@ -868,6 +868,8 @@ ORDER BY ps.id, pf.weight ;
public
static
function
buildLineItemRows
(
&
$form
,
$contributionID
=
NULL
)
{
$fields
=
CRM_Lineitemedit_Util
::
getLineitemFieldNames
(
TRUE
);
$submittedValues
=
$pvIDs
=
[];
$chapterCodes
=
CRM_Core_OptionGroup
::
values
(
'chapter_codes'
);
$fundCodes
=
CRM_Core_OptionGroup
::
values
(
'fund_codes'
);
if
(
!
empty
(
$contributionID
))
{
$options
=
CRM_Lineitemedit_Util
::
getPriceFieldLists
(
$contributionID
)
+
[
'new'
=>
ts
(
'Create new item'
)];
$pvIDs
=
array_keys
(
$options
);
...
...
@@ -877,6 +879,14 @@ ORDER BY ps.id, pf.weight ;
if
(
!
empty
(
$_POST
[
'item_unit_price'
])
&&
!
empty
(
$_POST
[
'item_unit_price'
][
$rowNumber
]))
{
$submittedValues
[]
=
$rowNumber
;
}
$form
->
add
(
'select'
,
"item_chapter_code[
$rowNumber
]"
,
ts
(
'Chapter Code'
),
$chapterCodes
);
$form
->
add
(
'select'
,
"item_fund_code[
$rowNumber
]"
,
ts
(
'Fund Code'
),
$fundCodes
);
foreach
(
$fields
as
$fieldName
)
{
if
(
$fieldName
!=
'price_field_value_id'
)
{
if
(
in_array
(
$fieldName
,
[
'line_total'
,
'tax_amount'
]))
{
...
...
lineitemedit.php
View file @
44806b87
...
...
@@ -215,7 +215,7 @@ function lineitemedit_civicrm_pre($op, $entity, $entityID, &$params) {
for
(
$i
=
0
;
$i
<=
10
;
$i
++
)
{
$lineItemParams
[
$i
]
=
[];
$notFound
=
TRUE
;
foreach
([
'item_label'
,
'item_financial_type_id'
,
'item_qty'
,
'item_unit_price'
,
'item_line_total'
,
'item_price_field_value_id'
,
'item_tax_amount'
]
as
$attribute
)
{
foreach
([
'item_label'
,
'item_financial_type_id'
,
'item_chapter_code'
,
'item_fund_code'
,
'item_qty'
,
'item_unit_price'
,
'item_line_total'
,
'item_price_field_value_id'
,
'item_tax_amount'
]
as
$attribute
)
{
if
(
!
empty
(
$params
[
$attribute
])
&&
!
empty
(
$params
[
$attribute
][
$i
]))
{
if
(
$attribute
==
'item_line_total'
)
{
$notFound
=
FALSE
;
...
...
@@ -257,7 +257,16 @@ function lineitemedit_civicrm_pre($op, $entity, $entityID, &$params) {
'financial_type_id'
=>
$lineItem
[
'financial_type_id'
],
'tax_amount'
=>
CRM_Utils_Array
::
value
(
'tax_amount'
,
$lineItem
),
);
$newLineItem
[]
=
civicrm_api3
(
'LineItem'
,
'create'
,
$newLineItemParams
)[
'id'
];
$newLineItem
[]
=
$newId
=
civicrm_api3
(
'LineItem'
,
'create'
,
$newLineItemParams
)[
'id'
];
$chapterFundParams
=
[
'entity_id'
=>
$newId
,
'entity_table'
=>
'civicrm_line_item'
,
'chapter'
=>
$lineItem
[
'chapter_code'
],
'fund'
=>
$lineItem
[
'fund_code'
],
];
CRM_Core_Session
::
singleton
()
->
set
(
'noUpdate'
,
TRUE
);
CRM_EFT_BAO_EFT
::
saveChapterFund
(
$chapterFundParams
);
CRM_Core_Session
::
singleton
()
->
set
(
'noUpdate'
,
FALSE
);
}
if
(
!
empty
(
$lineItemParams
))
{
...
...
templates/CRM/Lineitemedit/Form/Add.tpl
View file @
44806b87
...
...
@@ -45,3 +45,5 @@
{/
literal
}
{
include
file
=
"CRM/Lineitemedit/Form/CalculateLineItemFields.tpl"
}
{
include
file
=
"CRM/EFT/AddChapterFundCode.tpl"
}
templates/CRM/Lineitemedit/Form/AddLineItems.tpl
View file @
44806b87
...
...
@@ -190,6 +190,7 @@ CRM.$(function($) {
if
(
pvid
==
'
new
'
)
{
$
(
'
input[id^="item_label"]
'
,
row
).
val
(
ts
(
'
Additional line item
'
));
$
(
'
select[id^="item_financial_type_id"]
'
,
row
).
select2
(
'
val
'
,
$
(
'
#financial_type_id
'
).
val
());
$
(
'
select[id^="item_chapter_code"]
'
,
row
).
val
(
1000
);
$
(
'
input[id^="item_qty"]
'
,
row
).
val
(
1
);
total_amount
=
CRM
.
formatMoney
(
1
,
true
);
$
(
'
input[id^="item_unit_price"], input[id^="item_line_total"]
'
,
row
).
val
(
total_amount
);
...
...
@@ -207,6 +208,7 @@ CRM.$(function($) {
}
$
(
'
input[id^="item_label"]
'
,
row
).
val
(
result
.
label
);
$
(
'
select[id^="item_financial_type_id"]
'
,
row
).
select2
(
'
val
'
,
result
.
financial_type_id
);
$
(
'
select[id^="item_chapter_code"]
'
,
row
).
val
(
1000
);
$
(
'
input[id^="item_qty"]
'
,
row
).
val
(
1
);
total_amount
=
CRM
.
formatMoney
(
result
.
amount
,
true
);
$
(
'
input[id^="item_unit_price"], input[id^="item_line_total"]
'
,
row
).
val
(
total_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