Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grant_program
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
grant_program
Commits
dd4800f8
Commit
dd4800f8
authored
11 years ago
by
Mayur Jadhav
Browse files
Options
Downloads
Patches
Plain Diff
worked on RG-103
parent
b4255870
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Grant/BAO/GrantProgram.php
+13
-1
13 additions, 1 deletion
CRM/Grant/BAO/GrantProgram.php
CRM/Grant/Form/GrantProgramView.php
+51
-51
51 additions, 51 deletions
CRM/Grant/Form/GrantProgramView.php
grantprograms.php
+7
-2
7 additions, 2 deletions
grantprograms.php
with
71 additions
and
54 deletions
CRM/Grant/BAO/GrantProgram.php
+
13
−
1
View file @
dd4800f8
...
...
@@ -314,5 +314,17 @@ WHERE civicrm_contact.id = $id ";
CRM_Core_BAO_MessageTemplates
::
sendTemplate
(
$sendTemplateParams
);
}
}
}
}
static
function
getUserAllocatedAmount
(
$userparams
)
{
$where
=
NULL
;
if
(
!
empty
(
$userparams
))
{
foreach
(
$userparams
as
$key
=>
$value
)
{
$where
.
=
" AND
{
$key
}
=
{
$value
}
"
;
}
$query
=
"SELECT SUM(amount_granted) as amount_granted FROM civicrm_grant WHERE "
.
ltrim
(
$where
,
' AND'
);
$amountGranted
=
CRM_Core_DAO
::
singleValueQuery
(
$query
);
}
return
empty
(
$amountGranted
)
?
0
:
$amountGranted
;
}
}
This diff is collapsed.
Click to expand it.
CRM/Grant/Form/GrantProgramView.php
+
51
−
51
View file @
dd4800f8
...
...
@@ -87,7 +87,7 @@ class CRM_Grant_Form_GrantProgramView extends CRM_Core_Form {
public
function
allocate
()
{
$grantStatus
=
CRM_Core_OptionGroup
::
values
(
'grant_status'
,
TRUE
);
$params
=
array
(
'status_id'
=>
$grantStatus
[
'
Eligible
'
],
'status_id'
=>
$grantStatus
[
'
Approved
'
],
'grant_program_id'
=>
$_POST
[
'pid'
],
'amount_granted'
=>
'NULL'
,
'assessment'
=>
'NOT NULL'
,
...
...
@@ -103,77 +103,77 @@ class CRM_Grant_Form_GrantProgramView extends CRM_Core_Form {
$sort_order
=
SORT_DESC
;
array_multisort
(
$order
,
$sort_order
,
$result
);
}
if
(
$_POST
[
'remainder_amount'
]
==
'0.00'
)
{
$totalAmount
=
$_POST
[
'amount'
];
}
else
{
$totalAmount
=
$_POST
[
'remainder_amount'
];
}
$contact
=
array
();
$grantThresholds
=
CRM_Core_OptionGroup
::
values
(
'grant_thresholds'
,
TRUE
);
foreach
(
$result
as
$key
=>
$value
)
{
if
(
!
in_array
(
$value
[
'contact_id'
],
$contact
))
{
if
(
$_POST
[
'algorithm'
]
==
'Best to Worst, Fully Funded'
)
{
if
(
$value
[
'amount_total'
]
>
$grantThresholds
[
'Maximum Grant'
])
{
$value
[
'amount_granted'
]
=
$grantThresholds
[
'Maximum Grant'
];
if
(
$value
[
'amount_granted'
]
<=
$totalAmount
)
{
$grant
[
'granted'
][]
=
$grantThresholds
[
'Maximum Grant'
];
$totalAmount
=
$totalAmount
-
$grantThresholds
[
'Maximum Grant'
];
$contact
[]
=
$value
[
'contact_id'
];
}
else
{
$grant
[
'eligible'
][]
=
$value
[
'amount_granted'
];
continue
;
}
$userparams
[
'contact_id'
]
=
$value
[
'contact_id'
];
$userparams
[
'grant_program_id'
]
=
$_POST
[
'pid'
];
$amountGranted
=
CRM_Grant_BAO_GrantProgram
::
getUserAllocatedAmount
(
$userparams
);
if
(
$_POST
[
'algorithm'
]
==
'Best to Worst, Fully Funded'
)
{
$amountEligible
=
$grantThresholds
[
'Maximum Grant'
]
-
$amountGranted
;
if
(
$value
[
'amount_total'
]
>
$amountEligible
)
{
$value
[
'amount_granted'
]
=
$amountEligible
;
if
(
$value
[
'amount_granted'
]
<=
$totalAmount
)
{
$grant
[
'granted'
][]
=
$amountEligible
;
$totalAmount
=
$totalAmount
-
$amountEligible
;
}
else
{
$grant
[
'eligible'
][]
=
$value
[
'amount_granted'
];
continue
;
}
}
else
{
if
(
$value
[
'amount_total'
]
<=
$totalAmount
)
{
$grant
[
'granted'
][]
=
$value
[
'amount_total'
];
$totalAmount
=
$totalAmount
-
$value
[
'amount_total'
];
$value
[
'amount_granted'
]
=
$value
[
'amount_total'
];
}
else
{
$grant
[
'eligible'
][]
=
$value
[
'amount_granted'
];
continue
;
}
}
$ids
[
'grant'
]
=
$value
[
'grant_id'
];
}
else
{
$requestedAmount
=
((
$value
[
'assessment'
]
/
100
)
*
$value
[
'amount_total'
]
*
(
$grantThresholds
[
'Funding factor'
]
/
100
));
$amountEligible
=
$grantThresholds
[
'Maximum Grant'
]
-
$amountGranted
;
if
(
$requestedAmount
>
$amountEligible
)
{
if
(
$amountEligible
>
$totalAmount
)
{
$grant
[
'eligible'
][]
=
$amountEligible
;
continue
;
}
else
{
if
(
$value
[
'amount_total'
]
<=
$totalAmount
)
{
$grant
[
'granted'
][]
=
$value
[
'amount_total'
];
$totalAmount
=
$totalAmount
-
$value
[
'amount_total'
];
$value
[
'amount_granted'
]
=
$value
[
'amount_total'
];
if
(
$amountEligible
!=
0
)
{
$value
[
'amount_granted'
]
=
$grant
[
'granted'
][]
=
$amountEligible
;
$totalAmount
=
$totalAmount
-
$value
[
'amount_granted'
];
}
else
{
$grant
[
'eligible'
][]
=
$value
[
'amount_granted'
];
continue
;
$grant
[
'nonEligible'
][]
=
$requestedAmount
;
}
}
$ids
[
'grant'
]
=
$value
[
'grant_id'
];
}
else
{
$requestedAmount
=
((
$value
[
'assessment'
]
/
100
)
*
$value
[
'amount_total'
]
*
(
$grantThresholds
[
'Funding factor'
]
/
100
));
if
(
$requestedAmount
>
$grantThresholds
[
'Maximum Grant'
])
{
if
(
$grantThresholds
[
'Maximum Grant'
]
>
$totalAmount
)
{
$grant
[
'eligible'
][]
=
$grantThresholds
[
'Maximum Grant'
];
continue
;
}
else
{
$value
[
'amount_granted'
]
=
$grant
[
'granted'
][]
=
$grantThresholds
[
'Maximum Grant'
];
$contact
[]
=
$value
[
'contact_id'
];
$totalAmount
=
$totalAmount
-
$value
[
'amount_granted'
];
}
if
(
$requestedAmount
>
$totalAmount
)
{
$grant
[
'eligible'
][]
=
$requestedAmount
;
continue
;
}
else
{
if
(
$requestedAmount
>
$totalAmount
)
{
$grant
[
'eligible'
][]
=
$grantThresholds
[
'Maximum Grant'
];
continue
;
}
else
{
$value
[
'amount_granted'
]
=
$grant
[
'granted'
][]
=
$requestedAmount
;
$contact
[]
=
$value
[
'contact_id'
];
$totalAmount
=
$totalAmount
-
$value
[
'amount_granted'
];
}
$value
[
'amount_granted'
]
=
$grant
[
'granted'
][]
=
$requestedAmount
;
$totalAmount
=
$totalAmount
-
$value
[
'amount_granted'
];
}
$ids
[
'grant'
]
=
$key
;
}
$result
=
CRM_Grant_BAO_Grant
::
add
(
&
$value
,
&
$ids
);
}
$ids
[
'grant'
]
=
$key
;
}
else
{
$grant
[
'nonEligible'
][]
=
$value
[
'amount_total'
];
}
$result
=
CRM_Grant_BAO_Grant
::
add
(
&
$value
,
&
$ids
);
}
}
...
...
This diff is collapsed.
Click to expand it.
grantprograms.php
+
7
−
2
View file @
dd4800f8
...
...
@@ -149,9 +149,14 @@ function quickAllocate($grantProgram, $value) {
}
if
(
isset
(
$value
[
'assessment'
]))
{
$userparams
[
'contact_id'
]
=
$value
[
'contact_id'
];
$userparams
[
'grant_program_id'
]
=
$grantProgram
->
id
;
$userAmountGranted
=
CRM_Grant_BAO_GrantProgram
::
getUserAllocatedAmount
(
$userparams
);
$amountEligible
=
$grantThresholds
[
'Maximum Grant'
]
-
$userAmountGranted
;
$requestedAmount
=
(((
$value
[
'assessment'
]
/
100
)
*
$value
[
'amount_total'
])
*
(
$grantThresholds
[
'Funding factor'
]
/
100
));
if
(
$requestedAmount
>
$
grantThresholds
[
'Maximum Grant'
]
)
{
$requestedAmount
=
$
grantThresholds
[
'Maximum Grant'
]
;
if
(
$requestedAmount
>
$
amountEligible
)
{
$requestedAmount
=
$
amountEligible
;
}
if
(
$requestedAmount
<
$totalAmount
)
{
$amountGranted
=
$requestedAmount
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment