@@ -215,6 +215,55 @@ function ccgn_application_mc_review_form ( $applicant_id ) {
215
215
);
216
216
}
217
217
}
218
+ function ccgn_application_institutional_agreement_form ( $ applicant_id , $ state ) {
219
+ if ( ccgn_current_user_is_legal_team () && ($ state == CCGN_APPLICATION_STATE_LEGAL ) ) {
220
+ echo '<h2>Institutional Agreement</h2> ' ;
221
+ $ institutional_agreement_meta = get_user_meta ($ applicant_id , 'ccgn-institutional-agreement ' , true );
222
+ if (!empty ($ institutional_agreement_meta ) && ($ institutional_agreement_meta ['status ' ] == 'sent-agreement ' )) {
223
+ $ now = new DateTime ('now ' );
224
+ $ agreement_date = new DateTime ($ institutional_agreement_meta ['date ' ]);
225
+ echo '<p>Agreement sent: ' .date ('Y-m-d ' ,strtotime ($ institutional_agreement_meta ['date ' ])).' ( ' .$ agreement_date ->diff ($ now )->days .' days ago) ' ;
226
+ }
227
+ $ existing_entry = ccgn_entries_referring_to_user (
228
+ $ applicant_id ,
229
+ CCGN_GF_INSTITUTIONAL_AGREEMENT ,
230
+ CCGN_GF_INSTITUTIONAL_AGREEMENT_ID
231
+ )[0 ];
232
+ gravity_form (
233
+ CCGN_GF_INSTITUTIONAL_AGREEMENT ,
234
+ false ,
235
+ false ,
236
+ false ,
237
+ array (
238
+ CCGN_GF_INSTITUTIONAL_AGREEMENT_CHECKBOX_PARAMETER
239
+ => $ existing_entry [
240
+ CCGN_GF_INSTITUTIONAL_AGREEMENT_CHECKBOX
241
+ ],
242
+ CCGN_GF_INSTITUTIONAL_AGREEMENT_ID_PARAMETER
243
+ => $ applicant_id
244
+ )
245
+ );
246
+ }
247
+ }
248
+ function ccgn_application_institutional_agreement_submit_handler ( $ entry , $ form ) {
249
+ if ( $ form [ 'title ' ] == CCGN_GF_INSTITUTIONAL_AGREEMENT ) {
250
+ $ applicant_id = $ entry [ CCGN_GF_INSTITUTIONAL_AGREEMENT_ID ];
251
+ if ($ entry [ CCGN_GF_INSTITUTIONAL_AGREEMENT_CHECKBOX ] == 'yes ' ) {
252
+ //The institutional agreement has been sent
253
+ $ institutional_agreement_meta = array (
254
+ 'status ' => 'sent-agreement ' ,
255
+ 'date ' => date ('Y-m-d H:i:s ' , strtotime ('now ' )),
256
+ );
257
+ update_user_meta ($ applicant_id , 'ccgn-institutional-agreement ' , $ institutional_agreement_meta );
258
+ } else {
259
+ $ institutional_agreement_meta = array (
260
+ 'status ' => 'agreement-not-sent ' ,
261
+ 'date ' => date ('Y-m-d H:i:s ' , strtotime ('now ' )),
262
+ );
263
+ update_user_meta ($ applicant_id , 'ccgn-institutional-agreement ' , $ institutional_agreement_meta );
264
+ }
265
+ }
266
+ }
218
267
function ccgn_application_mc_review_submit_handler ( $ entry , $ form ) {
219
268
if ( $ form [ 'title ' ] == CCGN_GF_MC_REVIEW ) {
220
269
$ applicant_id = $ entry [ CCGN_GF_MC_REVIEW_APPLICANT_ID ];
@@ -811,6 +860,7 @@ function ccgn_application_users_page () {
811
860
ccgn_application_users_page_render_details ( $ applicant_id , $ state );
812
861
ccgn_application_users_page_render_state ( $ applicant_id , $ state );
813
862
if ( ccgn_user_is_institutional_applicant ( $ applicant_id ) ) {
863
+ ccgn_application_institutional_agreement_form ( $ applicant_id , $ state );
814
864
ccgn_application_format_legal_approval ( $ applicant_id , $ state );
815
865
}
816
866
}
0 commit comments