· 4 years ago · Jul 26, 2021, 01:24 PM
1<?php
2
3/**
4 * @file
5 * Application form, including Supporting Documentation.
6 */
7
8// Include LOPSugarCRM.
9module_load_include(
10 'inc',
11 'lop_sugarcrm',
12 'includes/LopSugarCrmClient'
13);
14module_load_include(
15 'inc',
16 'lop_applications',
17 'includes/lop_applications_validation_functions'
18);
19module_load_include(
20 'inc',
21 'lop_applications',
22 'forms/steps/lop_applications_form_applications_cancel_validate_submit'
23);
24module_load_include(
25 'inc',
26 'lop_applications',
27 'forms/steps/lop_applications_form_applications_draft_submit'
28);
29module_load_include(
30 'inc',
31 'lop_applications',
32 'forms/steps/lop_applications_form_applications_draft_validate'
33);
34module_load_include(
35 'inc',
36 'lop_applications',
37 'forms/steps/lop_applications_form_applications_pay_submit'
38);
39module_load_include(
40 'inc',
41 'lop_applications',
42 'forms/steps/lop_applications_form_applications_pay_validate'
43);
44
45/**
46 * Edit an existing application.
47 *
48 * Path: /applications/{Application-ID}/application_details.
49 *
50 * @param mixed $form
51 * The form.
52 * @param mixed $form_state
53 * The form state.
54 * @param object|null $application
55 * Application class or NULL if new.
56 *
57 * @return Object
58 * The Form object to be rendered by Drupal.
59 *
60 * @throws \Exception
61 * Throws an exception on error.
62 */
63function lop_applications_edit_application_details(
64 $form,
65 &$form_state,
66 $application = NULL
67) {
68
69 // This shouldn't happen.
70 if (is_null($application)) {
71 drupal_goto('/applications/new');
72 }
73
74 switch ($application->status) {
75 case "draft":
76 break;
77
78 case "further_information":
79 drupal_goto(
80 '/applications/edit/' . $application->id . '/further_information'
81 );
82 break;
83
84 default:
85 drupal_goto(
86 '/applications/view/' . $application->id . '/application_details'
87 );
88 break;
89 }
90
91 // Add validate and submit hooks.
92 $form['#validate'] = [
93 // 'lop_applications_form_application_payment_validate', //.
94 'lop_applications_form_application_details_validate',
95 ];
96 $form['#submit'] = [
97 // 'lop_applications_form_application_payment_submit', //.
98 'lop_applications_form_application_details_submit',
99 ];
100
101 // Application into form state.
102 $form_state['application'] = $application;
103
104 $user = entity_metadata_wrapper('user', $GLOBALS['user']);
105 drupal_set_title(t('Add new application'));
106 // phpcs:disable Drupal.Semantics.FunctionT.NotLiteralString
107 if (!empty($application)) {
108 // Allow PASS_THROUGH - sanitisation at CRM level.
109 drupal_set_title(
110 t('@name',
111 ['@name' => $application->name]
112 ),
113 PASS_THROUGH
114 );
115 }
116 // phpcs:enable
117
118 // In case the user hasn't completed the registration yet, show a message and
119 // redirect.
120 if ($user->field_bcms_unique_key->value() == NULL) {
121 // In case other messages is in the stack, clear them. Else, there might be
122 // other messages telling the same as the message below.
123 drupal_get_messages();
124 drupal_set_message(
125 t('You can not create a new application before you have completed your registration.'),
126 'warning');
127 drupal_goto('dashboard/user/' . $GLOBALS['user']->uid . '/edit');
128 }
129 $bcms_key = $user->field_bcms_unique_key->value();
130 $required_fields = [
131 'first_name',
132 'last_name',
133 'primary_address_street',
134 'primary_address_state',
135 'phone_work',
136 ];
137
138 $all_contacts = [
139 'role_type',
140 'primary_address_city',
141 'primary_address_postalcode',
142 'primary_address_country',
143 'email1',
144 'phone_mobile',
145 ];
146
147 $all_contacts = array_merge($all_contacts, $required_fields);
148
149 // Fetch and order local authorities so they can be used in a select.
150 $sugarCrmClient = new LopSugarCrmClient();
151 $sugarCrmClient->setAccessTokens();
152 $access_token = variable_get('sugarcrm_wrapper_access_token');
153 $contact = $sugarCrmClient->getRecordById(
154 'Contacts',
155 $bcms_key,
156 $access_token,
157 $all_contacts
158 );
159 if (!empty($contact->error) && $contact->error == "invalid_grant") {
160 $sugarCrmClient->setAccessTokens(TRUE);
161 }
162 $empty_fields = FALSE;
163 foreach ($required_fields as $required) {
164 if (empty($contact->$required) && $empty_fields === FALSE) {
165 $empty_fields = TRUE;
166 }
167 }
168 if ($empty_fields === TRUE) {
169 drupal_get_messages();
170 drupal_set_message(
171 t('You can not create a new application before you have completed your registration.'), 'warning');
172 drupal_goto('dashboard/user/' . $GLOBALS['user']->uid . '/edit');
173 }
174
175 $yes_or_no = $sugarCrmClient->enum_from_cache(
176 'PR_Part4',
177 'architectural_conservation_area',
178 TRUE
179 );
180
181 $legal_interest_in_land = $sugarCrmClient->enum_from_cache(
182 'PR_Part4',
183 'legal_interest_in_land'
184 );
185
186 $planning_permission = $sugarCrmClient->enum_from_cache(
187 'PR_Part4',
188 'planning_permission'
189 );
190
191 $surface_water_disposal = $sugarCrmClient->enum_from_cache(
192 'PR_Part4',
193 'surface_water_disposal'
194 );
195
196 $waste_water_connection = $sugarCrmClient->enum_from_cache(
197 'PR_Part4',
198 'waste_water_connection'
199 );
200
201 $water_supply = $sugarCrmClient->enum_from_cache(
202 'PR_Part4',
203 'water_supply'
204 );
205
206 $new_or_existing = $sugarCrmClient->enum_from_cache(
207 'PR_Part4',
208 'type_of_waste_water_system'
209 );
210
211 $documents = $sugarCrmClient->getDocumentsForApplication(
212 $application->id,
213 $access_token
214 );
215
216 $la = $sugarCrmClient->getRecordById(
217 'PR_Local_Authorities',
218 $application->localauthority_id,
219 $access_token,
220 [
221 'id',
222 'name',
223 'newspapers',
224 'part_b_url',
225 ]
226 );
227
228 $search = [
229 "abp_reference_number",
230 "agent_address_line_1",
231 "agent_address_line_2",
232 "agent_address_line_3",
233 "agent_address_line_4",
234 "agent_email",
235 "agent_forename",
236 "agent_phone_number",
237 "agent_surname",
238 "any_previous_planning_applications_on_site",
239 "applicant_address_line_1",
240 "applicant_address_line_2",
241 "applicant_address_line_3",
242 "applicant_address_line_4",
243 "applicant_email",
244 "applicant_mobile",
245 "applicant_name",
246 "applicant_phone_number",
247 "applicant_surname",
248 "architectural_conservation_area",
249 "car_parking_spaces_existing",
250 "car_parking_spaces_proposed",
251 "car_parking_spaces_total",
252 "close_to_monument",
253 "company",
254 "company_address_line_1",
255 "company_address_line_2",
256 "company_address_line_3",
257 "company_address_line_4",
258 "company_director_name",
259 "company_name",
260 "company_reg_number",
261 "correspondence_to_agent",
262 "creator_id",
263 "date_modified",
264 "date_of_publication",
265 "date_site_notice_erected",
266 "description_of_other_type",
267 "details_of_preplanning",
268 "development_address_line_1",
269 "development_address_line_2",
270 "development_address_line_3",
271 "development_address_line_4",
272 "does_part_v_apply",
273 "dumping_quarrying_details",
274 "eft",
275 "eft_reference",
276 "existing_use",
277 "explain_interest",
278 "explain_part_v_compliance_exemption_not_applicable",
279 "fee_payable",
280 "fee_payable_calculation_basis",
281 "flooding_details",
282 "grid_eastings",
283 "grid_northings",
284 "gross_floor_space_demolition",
285 "gross_floor_space_existing_buildings",
286 "gross_floor_space_proposed_work",
287 "gross_floor_space_retained",
288 "group_water_scheme_name",
289 "id",
290 "involve_demolition",
291 "is_there_an_appeal_to_abp_on_site",
292 "land_owner_address_line_1",
293 "land_owner_address_line_2",
294 "land_owner_address_line_3",
295 "land_owner_address_line_4",
296 "land_owner_forename",
297 "land_owner_surname",
298 "legal_interest_in_land",
299 "localauthority_id",
300 "local_authorities_pr_part4_name",
301 "major_accident_regulations",
302 "material_change_of_use",
303 "name",
304 "natural_heritage_area",
305 "nature_extended_proposed",
306 "ordnance_survey_map",
307 "other_treatment_system_desc",
308 "outline_permission_file_number",
309 "outline_permission_grant_date",
310 "payment_exempted",
311 "person_responsible_for_drawings",
312 "planning_permission",
313 "pr_public_notice_newspaper",
314 "preplanning_date",
315 "preplanning_meeting",
316 "preplanning_persons_involved",
317 "preplanning_reference",
318 "previous_planning_receipt_date",
319 "previous_reference_number",
320 "proposed_development_description",
321 "proposed_use",
322 "protected_structure",
323 "require_eis",
324 "require_ipc_licence",
325 "require_waste_licence",
326 "residev_total_apt",
327 "residev_total_house",
328 "site_area",
329 "site_previously_dumping_quarrying",
330 "site_previously_flooded",
331 "status",
332 "strategic_development_zone",
333 "surface_water_disposal",
334 "surface_water_other_description",
335 "type_of_waste_water_system",
336 "type_of_water_supply_connection",
337 "waste_water_connection",
338 "water_supply",
339 ];
340 $application = $sugarCrmClient->getRecordById(
341 'PR_Part4',
342 $application->id,
343 $access_token,
344 $search
345 );
346
347 $buildings = $sugarCrmClient->getAllBuildingsForApplication(
348 $application->id,
349 $access_token
350 );
351 $building_class = [
352 'house' => [
353 'studio' => 0,
354 '1_bed' => 0,
355 '2_bed' => 0,
356 '3_bed' => 0,
357 '4_bed_plus' => 0,
358 ],
359 'apartment' => [
360 'studio' => 0,
361 '1_bed' => 0,
362 '2_bed' => 0,
363 '3_bed' => 0,
364 '4_bed_plus' => 0,
365 ],
366 ];
367 $development_class = [];
368 $all_development_classes =
369 $sugarCrmClient->getAllDevelopmentClassesForApplication(
370 $application->id,
371 $access_token
372 );
373
374 if (!empty($buildings)) {
375 $building_class = [];
376 foreach ($buildings as $key => $building_to_sort) {
377 $building = $sugarCrmClient->getRecordById(
378 'PR_Building',
379 $building_to_sort->id,
380 $access_token
381 );
382 // Default to 0.
383 $building_class[$building->type][$building->subtype] = 0;
384 if (!empty($building->quantity)) {
385 $building_class[$building->type][$building->subtype] =
386 $building->quantity;
387 }
388 }
389 }
390
391 $i = 0;
392 foreach ($all_development_classes as $key => $development_class_to_sort) {
393 $development_class[$i] = [];
394 $dc = $sugarCrmClient->getRecordById(
395 'PR_Development_Class',
396 $development_class_to_sort->id,
397 $access_token
398 );
399 $development_class[$i][$dc->id] = [];
400 $development_class[$i][$dc->id][$dc->class] =
401 $dc->gross_floor_area_of_class;
402 $i++;
403 }
404
405 // Tabs.
406 $form['tab_placeholder'] = [
407 '#type' => 'horizontal_tabs',
408 '#weight' => 0,
409 '#default_tab' => 'edit-tab-place',
410 ];
411
412 $form['tab_place'] = [
413 '#type' => 'fieldset',
414 '#title' => t('Place'),
415 '#group' => 'tab_placeholder',
416 '#weight' => 2,
417 ];
418
419 $form['tab_proposal'] = [
420 '#type' => 'fieldset',
421 '#title' => t('Proposal'),
422 '#group' => 'tab_placeholder',
423 '#weight' => 4,
424 ];
425
426 $form['tab_supporting_documents'] = [
427 '#type' => 'fieldset',
428 '#title' => t('Supporting documents'),
429 '#group' => 'tab_placeholder',
430 '#weight' => 6,
431 ];
432
433 $form['tab_people'] = [
434 '#type' => 'fieldset',
435 '#title' => t('People'),
436 '#group' => 'tab_placeholder',
437 '#weight' => 8,
438 ];
439
440 $form['tab_payment'] = [
441 '#type' => 'fieldset',
442 '#title' => t('Payment'),
443 '#group' => 'tab_placeholder',
444 '#weight' => 10,
445 ];
446
447 $form['actions'] = [
448 '#type' => 'fieldset',
449 '#weight' => 50,
450 ];
451
452 $form['actions_top'] = [
453 '#type' => 'fieldset',
454 '#weight' => -5,
455 '#attributes' => [
456 'data-spy' => ["affix"],
457 'data-offset-top' => ["630"],
458 ],
459 ];
460
461 // Local Planning Authority Fieldset.
462 $form['authority_details'] = [
463 '#type' => 'fieldset',
464 '#collapsible' => TRUE,
465 '#collapsed' => FALSE,
466 '#title' => t('Application Details'),
467 '#weight' => -10,
468 '#parent' => 'tab_place',
469 ];
470
471 $default_value = (!empty($application->id)) ?
472 trim(decode_entities(check_plain($application->id))) :
473 NULL;
474 $form['authority_details']['id'] = [
475 '#type' => 'hidden',
476 '#default_value' => $default_value,
477 '#required' => FALSE,
478 '#weight' => -4,
479 ];
480 $default_value = (!empty($application->creator_id)) ?
481 trim(decode_entities(check_plain($application->creator_id))) :
482 NULL;
483 $form['authority_details']['creator_id'] = [
484 '#type' => 'hidden',
485 '#default_value' => $default_value,
486 '#required' => FALSE,
487 '#weight' => -2,
488 ];
489 $default_value = (!empty($application->status)) ?
490 trim(decode_entities(check_plain($application->status))) :
491 NULL;
492 $form['authority_details']['status'] = [
493 '#type' => 'hidden',
494 '#default_value' => $default_value,
495 '#required' => FALSE,
496 '#weight' => 0,
497 ];
498 $default_value = (!empty($application->date_modified)) ?
499 trim(decode_entities(check_plain($application->date_modified))) :
500 NULL;
501 $form['authority_details']['date_modified'] = [
502 '#type' => 'hidden',
503 '#default_value' => $default_value,
504 '#required' => FALSE,
505 '#weight' => 1,
506 ];
507 $default_value = (!empty($application->name)) ?
508 trim(decode_entities(check_plain($application->name))) :
509 NULL;
510 $form['authority_details']['name'] = [
511 '#type' => 'textfield',
512 '#title' => t('Application title'),
513 '#description' => t('Please choose an application title'),
514 '#default_value' => $default_value,
515 '#required' => FALSE,
516 '#weight' => 2,
517 ];
518
519 // Field on SugarCRM of Type: "Relationship" (UUID).
520 $default_value = (!empty($application->localauthority_id)) ?
521 trim(decode_entities(check_plain($application->localauthority_id))) :
522 NULL;
523 $form['authority_details']['localauthority_id'] = [
524 '#type' => 'hidden',
525 '#default_value' => $default_value,
526 '#required' => TRUE,
527 '#weight' => 4,
528 ];
529
530 // Field on SugarCRM of Type: "Relationship" (UUID).
531 $default_value = (!empty($application->local_authorities_pr_part4_name)) ?
532 trim(decode_entities(check_plain($application->local_authorities_pr_part4_name))) :
533 trim(decode_entities(check_plain($la->name)));
534 $form['authority_details']['local_authorities_pr_part4_name'] = [
535 '#type' => 'textfield',
536 '#title' => t('Local Authority'),
537 '#description' => t('The Local Authority you are submitting your application to'),
538 '#default_value' => $default_value,
539 '#disabled' => TRUE,
540 '#required' => TRUE,
541 '#weight' => 4,
542 '#attributes' => ['disabled' => TRUE],
543 ];
544
545 $url = l(
546 t('terms and conditions'),
547 '/terms-and-conditions',
548 [
549 'attributes' => ['_target' => 'blank'],
550 ]
551 );
552 $form['authority_details']['gdpr_consent'] = [
553 '#type' => 'checkbox',
554 '#title' => t(
555 'I have read and understood the !url of using this site',
556 ['!url' => $url]
557 ),
558 '#description' => t(
559 'I have read and understood the !url of using this site',
560 ['!url' => $url]
561 ),
562 '#required' => TRUE,
563 '#disabled' => TRUE,
564 '#weight' => 6,
565 ];
566
567 // Pre-fill ONLY when $application exists.
568 if (!empty($application)) {
569 $form['authority_details']['gdpr_consent']['#default_value'] = 1;
570 $form['authority_details']['gdpr_consent']['#attributes'] = [
571 'checked' => ['TRUE'],
572 'disabled' => ['TRUE'],
573 ];
574 }
575
576 $form['actions_top']['submit_top'] = [
577 '#type' => 'submit',
578 '#value' => t('Save as draft'),
579 '#weight' => 0,
580 ];
581
582 $form['actions_top']['upload_top'] = [
583 '#type' => 'submit',
584 '#value' => t('Upload'),
585 '#weight' => 5,
586 '#attributes' => [
587 'style' => ['display:none'],
588 ],
589 ];
590
591 if (!empty($application)) {
592 $form['actions_top']['cancel_top'] = [
593 '#type' => 'submit',
594 '#value' => t('Discard changes'),
595 '#validate' => ['lop_applications_cancel_validate'],
596 '#submit' => ['lop_applications_cancel_submit'],
597 '#weight' => 10,
598 ];
599 }
600
601 $faq_url = l(
602 t('FAQs'),
603 '/faqs',
604 [
605 'attributes' => ['_target' => 'blank'],
606 ]
607 );
608 $form['actions_top']['faqs_top'] = [
609 '#type' => 'item',
610 '#markup' => t(
611 'If you have any questions, please see our !url page',
612 ['!url' => $faq_url]
613 ),
614 '#weight' => 12,
615 '#prefix' => '<div style="float: right;">',
616 '#suffix' => '</div>',
617 ];
618
619 // Fields in Place Tab.
620 // Development location details.
621 $form['tab_place']['development_location'] = [
622 '#type' => 'fieldset',
623 '#title' => t('Location of Development'),
624 '#description' => t('The Postal Address OR Townland OR Location (as may best identify the land or structure in question)'),
625 '#weight' => 10,
626 '#parent' => 'tab_place',
627 ];
628
629 // Planning Permission.
630 $form['tab_place']['development_planning'] = [
631 '#type' => 'fieldset',
632 '#title' => t('Type of Planning Permission'),
633 '#weight' => 12,
634 '#parent' => 'tab_place',
635 ];
636
637 // Planning Consequent.
638 $form['tab_place']['development_planning_type'] = [
639 '#type' => 'fieldset',
640 '#title' => t('Where planning permission is consequent on grant of outline permission'),
641 '#weight' => 14,
642 '#parent' => 'tab_place',
643 '#states' => [
644 'visible' => [
645 'select[name="planning_permission"]' => [
646 'value' => 'C',
647 ],
648 ],
649 ],
650 ];
651
652 // Site History.
653 $form['tab_place']['site_history'] = [
654 '#type' => 'fieldset',
655 '#title' => t('Site history'),
656 '#weight' => 16,
657 '#parent' => 'tab_place',
658 ];
659
660 // Pre Application.
661 $form['tab_place']['pre_application'] = [
662 '#type' => 'fieldset',
663 '#title' => t('Pre-Application Consultation'),
664 '#weight' => 18,
665 '#parent' => 'tab_place',
666 ];
667
668 // Pre Application.
669 $form['tab_place']['services'] = [
670 '#type' => 'fieldset',
671 '#title' => t('Services'),
672 '#weight' => 20,
673 '#parent' => 'tab_place',
674 ];
675
676 // Field on SugarCRM of Type: varchar(255).
677 $default_value = (!empty($application->development_address_line_1)) ?
678 trim(decode_entities(
679 check_plain($application->development_address_line_1)
680 )) :
681 NULL;
682 $form['tab_place']['development_location']['development_address_line_1'] =
683 [
684 '#type' => 'textfield',
685 '#title' => t('Development Address'),
686 '#size' => 255,
687 '#maxlength' => 255,
688 '#default_value' => $default_value,
689 '#required' => FALSE,
690 '#description' => t('Enter the first line of the development address'),
691 '#weight' => 10,
692 ];
693
694 // Field on SugarCRM of Type: varchar(255).
695 $default_value = (!empty($application->development_address_line_2)) ?
696 trim(decode_entities(
697 check_plain($application->development_address_line_2)
698 )) :
699 NULL;
700 $form['tab_place']['development_location']['development_address_line_2'] =
701 [
702 '#type' => 'textfield',
703 '#title' => t('Development Address Line 2'),
704 '#size' => 255,
705 '#maxlength' => 255,
706 '#default_value' => $default_value,
707 '#required' => FALSE,
708 '#description' => t('Enter the second line of the development address'),
709 '#weight' => 12,
710 ];
711
712 // Field on SugarCRM of Type: varchar(255).
713 $default_value = (!empty($application->development_address_line_3)) ?
714 trim(decode_entities(
715 check_plain($application->development_address_line_3)
716 )) :
717 NULL;
718 $form['tab_place']['development_location']['development_address_line_3'] =
719 [
720 '#type' => 'textfield',
721 '#title' => t('Development Address Line 3'),
722 '#size' => 255,
723 '#maxlength' => 255,
724 '#default_value' => $default_value,
725 '#required' => FALSE,
726 '#description' => t('Enter the third line of the development address'),
727 '#weight' => 14,
728 ];
729
730 // Field on SugarCRM of Type: varchar(255).
731 $default_value = (!empty($application->development_address_line_4)) ?
732 trim(decode_entities(
733 check_plain($application->development_address_line_4)
734 )) :
735 NULL;
736 $form['tab_place']['development_location']['development_address_line_4'] =
737 [
738 '#type' => 'textfield',
739 '#title' => t('Eircode'),
740 '#size' => 255,
741 '#maxlength' => 255,
742 '#default_value' => $default_value,
743 '#required' => FALSE,
744 '#description' => t('Enter the Eircode of the development address.'),
745 '#weight' => 16,
746 // Temporary removal.
747 // '#attributes' => [//.
748 // 'pattern' => ("(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ ]?[0-9AC-FHKNPRTV-Y]{4}$"), //.
749 // ], //.
750 ];
751
752 // Field on SugarCRM of Type: varchar(15).
753 $default_value = (!empty($application->ordnance_survey_map)) ?
754 trim(decode_entities(check_plain($application->ordnance_survey_map))) :
755 NULL;
756 $form['tab_place']['development_location']['ordnance_survey_map'] = [
757 '#type' => 'textfield',
758 '#title' => t('Ordnance Survey Map'),
759 '#size' => 15,
760 '#maxlength' => 15,
761 '#default_value' => $default_value,
762 '#required' => FALSE,
763 '#description' => t('Enter the map reference for the location of the proposed development'),
764 '#weight' => 22,
765 ];
766
767 // Field on SugarCRM of Type: int(11).
768 $default_value = (!empty($application->grid_eastings)) ?
769 trim(decode_entities(check_plain($application->grid_eastings))) :
770 NULL;
771 $form['tab_place']['development_location']['grid_eastings'] = [
772 '#type' => 'textfield',
773 '#title' => t('Grid Eastings'),
774 '#size' => 8,
775 '#maxlength' => 8,
776 '#default_value' => $default_value,
777 '#required' => FALSE,
778 '#description' => t('Enter the Grid Eastings of the proposed development in Irish Transverse Mercator format'),
779 '#weight' => 18,
780 ];
781
782 // Field on SugarCRM of Type: int(11).
783 $default_value = (!empty($application->grid_northings)) ?
784 trim(decode_entities(check_plain($application->grid_northings))) :
785 NULL;
786 $form['tab_place']['development_location']['grid_northings'] = [
787 '#type' => 'textfield',
788 '#title' => t('Grid Northings'),
789 '#size' => 8,
790 '#maxlength' => 8,
791 '#default_value' => $default_value,
792 '#required' => FALSE,
793 '#description' => t('Enter the Grid Northings of the proposed development in Irish Transverse Mercator format'),
794 '#weight' => 20,
795 ];
796
797 // Field on SugarCRM of Type: varchar(255).
798 $default_value = (!empty($application->planning_permission)) ?
799 trim(decode_entities(check_plain($application->planning_permission))) :
800 NULL;
801 $form['tab_place']['development_planning']['planning_permission'] = [
802 '#title' => t('Type of planning permission'),
803 '#type' => 'select',
804 '#options' => $planning_permission,
805 '#default_value' => $default_value,
806 '#required' => FALSE,
807 '#weight' => 10,
808 ];
809
810 // Field on SugarCRM of Type: varchar(8).
811 $default_value = (!empty($application->outline_permission_file_number)) ?
812 trim(decode_entities(
813 check_plain($application->outline_permission_file_number)
814 )) :
815 NULL;
816 $form['tab_place']['development_planning_type']['outline_permission_file_number'] =
817 [
818 '#type' => 'textfield',
819 '#title' => t('Outline Permission Regular Reference Number'),
820 '#size' => 8,
821 '#maxlength' => 8,
822 '#default_value' => $default_value,
823 '#description' => t('Enter the Outline Permission File Number'),
824 '#weight' => 14,
825 ];
826
827 // Field on SugarCRM of Type: date.
828 $default_value = (!empty($application->outline_permission_grant_date)) ?
829 trim(decode_entities(
830 check_plain($application->outline_permission_grant_date)
831 )) :
832 NULL;
833 $form['tab_place']['development_planning_type']['outline_permission_grant_date'] =
834 [
835 '#type' => 'date_popup',
836 '#title' => t('Outline Permission Grant Date'),
837 '#date_year_range' => '-1:+3',
838 '#date_format' => 'd/m/Y',
839 '#default_value' => $default_value,
840 '#description' => t('Enter the date the Outline Permission was granted'),
841 '#weight' => 16,
842 ];
843
844 // Field on SugarCRM of Type: varchar(25).
845 $default_value = (!empty($application->site_previously_flooded)) ?
846 trim(decode_entities(check_plain($application->site_previously_flooded))) :
847 NULL;
848 $form['tab_place']['site_history']['site_previously_flooded'] = [
849 '#type' => 'radios',
850 '#title' => t('Has the site in question ever, to your knowledge, been flooded'),
851 '#options' => $yes_or_no,
852 '#default_value' => $default_value,
853 '#weight' => 10,
854 ];
855
856 // Field on SugarCRM of Type: varchar(255).
857 $default_value = (!empty($application->flooding_details)) ?
858 trim(decode_entities(check_plain($application->flooding_details))) :
859 NULL;
860 $form['tab_place']['site_history']['flooding_details'] = [
861 '#type' => 'textfield',
862 '#title' => t('Please give details'),
863 '#size' => 255,
864 '#maxlength' => 255,
865 '#default_value' => $default_value,
866 '#description' => t('E.g. year, extent'),
867 '#weight' => 12,
868 '#states' => [
869 'visible' => [
870 'input[name="site_previously_flooded"]' => [
871 'value' => 'Yes',
872 ],
873 ],
874 ],
875 ];
876
877 // Field on SugarCRM of Type: varchar(25).
878 $default_value = (!empty($application->site_previously_dumping_quarrying)) ?
879 trim(decode_entities(
880 check_plain($application->site_previously_dumping_quarrying)
881 )) :
882 NULL;
883 $form['tab_place']['site_history']['site_previously_dumping_quarrying'] = [
884 '#type' => 'radios',
885 '#title' => t('Are you aware of previous uses of the site e.g. dumping or quarrying'),
886 '#options' => $yes_or_no,
887 '#default_value' => $default_value,
888 '#weight' => 14,
889 '#required' => FALSE,
890 ];
891
892 // Field on SugarCRM of Type: varchar(255).
893 $default_value = (!empty($application->dumping_quarrying_details)) ?
894 trim(decode_entities(
895 check_plain($application->dumping_quarrying_details)
896 )) :
897 NULL;
898 $form['tab_place']['site_history']['dumping_quarrying_details'] = [
899 '#type' => 'textfield',
900 '#title' => t('Please enter specific details including year and extent'),
901 '#size' => 255,
902 '#maxlength' => 255,
903 '#default_value' => $default_value,
904 '#description' => t('Enter specific of the dumping or quarrying including year and extent.'),
905 '#weight' => 16,
906 '#states' => [
907 'visible' => [
908 'input[name="site_previously_dumping_quarrying"]' => ['value' => 'Yes'],
909 ],
910 ],
911 ];
912
913 // Spelling as per field on Sugar, kept for simplicity.
914 // Field on SugarCRM of Type: varchar(25).
915 $default_value = (!empty($application->any_previous_planning_applications_on_site)) ?
916 trim(decode_entities(
917 check_plain($application->any_previous_planning_applications_on_site)
918 )) :
919 NULL;
920 $form['tab_place']['site_history']['any_previous_planning_applications_on_site'] = [
921 '#type' => 'radios',
922 '#title' => t('Are you aware of any valid Planning Applications previously made in respect of this land / structure?'),
923 '#options' => $yes_or_no,
924 '#default_value' => $default_value,
925 '#weight' => 18,
926 '#required' => FALSE,
927 ];
928
929 // Spelling as per field on Sugar, kept for simplicity.
930 // Field on SugarCRM of Type: varchar(8).
931 $default_value = (!empty($application->previous_reference_number)) ?
932 trim(decode_entities(
933 check_plain($application->previous_reference_number)
934 )) :
935 NULL;
936 $form['tab_place']['site_history']['previous_reference_number'] = [
937 '#type' => 'textfield',
938 '#title' => t('If yes, please state the 1st planning reference number(s)'),
939 '#size' => 8,
940 '#maxlength' => 8,
941 '#default_value' => $default_value,
942 '#description' => t('If a valid planning application has been made in respect of this land or structure in the past 6 months prior to the submission of this application, then the site notice must be on a yellow background in accordance with Article 19(4) of the Planning and Development Regulations 2001 as amended.'),
943 '#weight' => 20,
944 '#states' => [
945 'visible' => [
946 'input[name="any_previous_planning_applications_on_site"]' => [
947 'value' => 'Yes',
948 ],
949 ],
950 ],
951 ];
952
953 // Spelling as per field on Sugar, kept for simplicity.
954 // Field on SugarCRM of Type: date.
955 $default_value = (!empty($application->previous_planning_receipt_date)) ?
956 trim(
957 decode_entities(
958 check_plain(
959 $application->previous_planning_receipt_date
960 )
961 )
962 ) :
963 NULL;
964 $form['tab_place']['site_history']['previous_planning_receipt_date'] = [
965 '#type' => 'textfield',
966 '#title' => t('If yes, please provide the submission date(s) of 1st previous application(s)'),
967 '#default_value' => $default_value,
968 '#description' => t('If known please enter the date(s) of receipt of the planning application(s) by the planning authority'),
969 '#weight' => 22,
970 '#states' => [
971 'visible' => [
972 'input[name="any_previous_planning_applications_on_site"' => [
973 'value' => 'Yes',
974 ],
975 ],
976 ],
977 ];
978
979 // Spelling as per field on Sugar, kept for simplicity.
980 // Field on SugarCRM of Type: varchar(8).
981 $default_value = (!empty($application->previous_reference_number_2)) ?
982 trim(decode_entities(
983 check_plain($application->previous_reference_number_2)
984 )) :
985 NULL;
986 $form['tab_place']['site_history']['previous_reference_number_2'] = [
987 '#type' => 'textfield',
988 '#title' => t('Please state the 2nd planning reference number(s)'),
989 '#size' => 8,
990 '#maxlength' => 8,
991 '#default_value' => $default_value,
992 '#description' => t('If a valid planning application has been made in respect of this land or structure in the past 6 months prior to the submission of this application, then the site notice must be on a yellow background in accordance with Article 19(4) of the Planning and Development Regulations 2001 as amended.'),
993 '#weight' => 24,
994 '#states' => [
995 'visible' => [
996 'input[name="any_previous_planning_applications_on_site"]' => [
997 'value' => 'Yes',
998 ],
999 ],
1000 ],
1001 ];
1002
1003 // Spelling as per field on Sugar, kept for simplicity.
1004 // Field on SugarCRM of Type: date.
1005 $default_value = (!empty($application->previous_planning_receipt_date_2)) ?
1006 trim(
1007 decode_entities(
1008 check_plain(
1009 $application->previous_planning_receipt_date_2
1010 )
1011 )
1012 ) :
1013 NULL;
1014 $form['tab_place']['site_history']['previous_planning_receipt_date_2'] = [
1015 '#type' => 'textfield',
1016 '#title' => t('Please provide the submission date(s) of 2nd previous application(s)'),
1017 '#default_value' => $default_value,
1018 '#description' => t('If known please enter the date(s) of receipt of the planning application(s) by the planning authority'),
1019 '#weight' => 26,
1020 '#states' => [
1021 'visible' => [
1022 'input[name="any_previous_planning_applications_on_site"' => [
1023 'value' => 'Yes',
1024 ],
1025 ],
1026 ],
1027 ];
1028 // Spelling as per field on Sugar, kept for simplicity.
1029 // Field on SugarCRM of Type: varchar(8).
1030 $default_value = (!empty($application->previous_reference_number_3)) ?
1031 trim(decode_entities(
1032 check_plain($application->previous_reference_number_3)
1033 )) :
1034 NULL;
1035 $form['tab_place']['site_history']['previous_reference_number_3'] = [
1036 '#type' => 'textfield',
1037 '#title' => t('Please state the 3rd planning reference number(s)'),
1038 '#size' => 8,
1039 '#maxlength' => 8,
1040 '#default_value' => $default_value,
1041 '#description' => t('If a valid planning application has been made in respect of this land or structure in the past 6 months prior to the submission of this application, then the site notice must be on a yellow background in accordance with Article 19(4) of the Planning and Development Regulations 2001 as amended.'),
1042 '#weight' => 28,
1043 '#states' => [
1044 'visible' => [
1045 'input[name="any_previous_planning_applications_on_site"]' => [
1046 'value' => 'Yes',
1047 ],
1048 ],
1049 ],
1050 ];
1051
1052 // Spelling as per field on Sugar, kept for simplicity.
1053 // Field on SugarCRM of Type: date.
1054 $default_value = (!empty($application->previous_planning_receipt_date_3)) ?
1055 trim(
1056 decode_entities(
1057 check_plain(
1058 $application->previous_planning_receipt_date_3
1059 )
1060 )
1061 ) :
1062 NULL;
1063 $form['tab_place']['site_history']['previous_planning_receipt_date_3'] = [
1064 '#type' => 'textfield',
1065 '#title' => t('Please provide the submission date(s) of 3rd previous application(s)'),
1066 '#default_value' => $default_value,
1067 '#description' => t('If known please enter the date(s) of receipt of the planning application(s) by the planning authority'),
1068 '#weight' => 30,
1069 '#states' => [
1070 'visible' => [
1071 'input[name="any_previous_planning_applications_on_site"' => [
1072 'value' => 'Yes',
1073 ],
1074 ],
1075 ],
1076 ];
1077
1078 // Spelling as per field on Sugar, kept for simplicity.
1079 // Field on SugarCRM of Type: varchar(8).
1080 $default_value = (!empty($application->previous_reference_number_4)) ?
1081 trim(decode_entities(
1082 check_plain($application->previous_reference_number_4)
1083 )) :
1084 NULL;
1085 $form['tab_place']['site_history']['previous_reference_number_4'] = [
1086 '#type' => 'textfield',
1087 '#title' => t('Please state the 4th planning reference number(s)'),
1088 '#size' => 8,
1089 '#maxlength' => 8,
1090 '#default_value' => $default_value,
1091 '#description' => t('If a valid planning application has been made in respect of this land or structure in the past 6 months prior to the submission of this application, then the site notice must be on a yellow background in accordance with Article 19(4) of the Planning and Development Regulations 2001 as amended.'),
1092 '#weight' => 32,
1093 '#states' => [
1094 'visible' => [
1095 'input[name="any_previous_planning_applications_on_site"]' => [
1096 'value' => 'Yes',
1097 ],
1098 ],
1099 ],
1100 ];
1101
1102 // Spelling as per field on Sugar, kept for simplicity.
1103 // Field on SugarCRM of Type: date.
1104 $default_value = (!empty($application->previous_planning_receipt_date_4)) ?
1105 trim(
1106 decode_entities(
1107 check_plain(
1108 $application->previous_planning_receipt_date_4
1109 )
1110 )
1111 ) :
1112 NULL;
1113 $form['tab_place']['site_history']['previous_planning_receipt_date_4'] = [
1114 '#type' => 'textfield',
1115 '#title' => t('If yes, please provide the submission date(s) 4th previous application(s)'),
1116 '#default_value' => $default_value,
1117 '#description' => t('If known please enter the date(s) of receipt of the planning application(s) by the planning authority'),
1118 '#weight' => 34,
1119 '#states' => [
1120 'visible' => [
1121 'input[name="any_previous_planning_applications_on_site"' => [
1122 'value' => 'Yes',
1123 ],
1124 ],
1125 ],
1126 ];
1127
1128 // Field on SugarCRM of Type: varchar(25).
1129 $default_value = (!empty($application->is_there_an_appeal_to_abp_on_site)) ?
1130 trim(decode_entities(
1131 check_plain($application->is_there_an_appeal_to_abp_on_site)
1132 )) :
1133 NULL;
1134 $form['tab_place']['site_history']['is_there_an_appeal_to_abp_on_site'] = [
1135 '#type' => 'radios',
1136 '#title' => t('Is the site of the proposal subject to a current appeal to An Bord Pleanala in respect of a similar development'),
1137 '#options' => $yes_or_no,
1138 '#default_value' => $default_value,
1139 '#weight' => 36,
1140 '#description' => t('The appeal must be determined or withdrawn before another similar application can be made.'),
1141 '#required' => FALSE,
1142 ];
1143
1144 // Field on SugarCRM of Type: varchar(255).
1145 $default_value = (!empty($application->abp_reference_number)) ?
1146 trim(decode_entities(check_plain($application->abp_reference_number))) :
1147 NULL;
1148 $form['tab_place']['site_history']['abp_reference_number'] = [
1149 '#type' => 'textfield',
1150 '#title' => t('An Bord Pleanala reference number'),
1151 '#size' => 8,
1152 '#maxlength' => 8,
1153 '#default_value' => $default_value,
1154 '#weight' => 38,
1155 '#states' => [
1156 'visible' => [
1157 'input[name="is_there_an_appeal_to_abp_on_site"]' => [
1158 'value' => 'Yes',
1159 ],
1160 ],
1161 ],
1162 ];
1163
1164 // Field on SugarCRM of Type: varchar(25).
1165 $default_value = (!empty($application->preplanning_meeting)) ?
1166 trim(decode_entities(check_plain($application->preplanning_meeting))) :
1167 NULL;
1168 $form['tab_place']['pre_application']['preplanning_meeting'] = [
1169 '#type' => 'radios',
1170 '#title' => t('Has a pre-application consultation taken place in relation to the proposed development'),
1171 '#options' => $yes_or_no,
1172 '#default_value' => $default_value,
1173 '#weight' => 10,
1174 '#description' => t('A formal pre-application consultation may only occur under Section 247 of the Planning and Development Act 2000. An applicant should contact his or her planning authority if he/she wishes to avail of a pre-application consultation. In the case of residential development to which Part V of the 2000 Act applies, applicants are advised to avail of the pre-application consultation facility in order to ensure that a Part V agreement in principle can be reached in advance of the planning application being submitted.'),
1175 '#required' => FALSE,
1176 ];
1177
1178 // Field on SugarCRM of Type: varchar(255).
1179 $default_value = (!empty($application->details_of_preplanning)) ?
1180 trim(decode_entities(check_plain($application->details_of_preplanning))) :
1181 NULL;
1182 $form['tab_place']['pre_application']['details_of_preplanning'] = [
1183 '#type' => 'textfield',
1184 '#title' => t('Please give details'),
1185 '#size' => 100,
1186 '#maxlength' => 100,
1187 '#default_value' => $default_value,
1188 '#description' => t('Enter details of the preplanning meeting'),
1189 '#weight' => 12,
1190 '#states' => [
1191 'visible' => [
1192 'input[name="preplanning_meeting"]' => [
1193 'value' => 'Yes',
1194 ],
1195 ],
1196 ],
1197 ];
1198
1199 // Field on SugarCRM of Type: varchar(255).
1200 $default_value = (!empty($application->preplanning_reference)) ?
1201 trim(decode_entities(check_plain($application->preplanning_reference))) :
1202 NULL;
1203 $form['tab_place']['pre_application']['preplanning_reference'] = [
1204 '#type' => 'textfield',
1205 '#title' => t('Enter pre-planning reference number'),
1206 '#size' => 100,
1207 '#maxlength' => 100,
1208 '#default_value' => $default_value,
1209 '#description' => t('Enter the pre-planning reference number'),
1210 '#weight' => 14,
1211 '#states' => [
1212 'visible' => [
1213 'input[name="preplanning_meeting"]' => [
1214 'value' => 'Yes',
1215 ],
1216 ],
1217 ],
1218 ];
1219
1220 // Field on SugarCRM of Type: date.
1221 $default_value = (!empty($application->preplanning_date)) ?
1222 trim(decode_entities(check_plain($application->preplanning_date))) :
1223 NULL;
1224 $form['tab_place']['pre_application']['preplanning_date'] = [
1225 '#type' => 'date_popup',
1226 '#title' => t('Date(s) of consultation'),
1227 '#date_year_range' => '-1:+1',
1228 '#date_format' => 'd/m/Y',
1229 '#default_value' => $default_value,
1230 '#description' => t('Enter the previous application dates'),
1231 '#weight' => 16,
1232 '#states' => [
1233 'visible' => [
1234 'input[name="preplanning_meeting"]' => [
1235 'value' => 'Yes',
1236 ],
1237 ],
1238 ],
1239 ];
1240
1241 // Field on SugarCRM of Type: varchar(255).
1242 $default_value = (!empty($application->preplanning_persons_involved)) ?
1243 trim(decode_entities(
1244 check_plain($application->preplanning_persons_involved)
1245 )) :
1246 NULL;
1247 $form['tab_place']['pre_application']['preplanning_persons_involved'] = [
1248 '#type' => 'textarea',
1249 '#title' => t('Persons Involved'),
1250 '#size' => 255,
1251 '#maxlength' => 255,
1252 '#default_value' => $default_value,
1253 '#description' => t('Enter details of the persons involved in the preplanning meeting'),
1254 '#weight' => 18,
1255 '#states' => [
1256 'visible' => [
1257 'input[name="preplanning_meeting"]' => [
1258 'value' => 'Yes',
1259 ],
1260 ],
1261 ],
1262 ];
1263
1264 // Field on SugarCRM of Type: varchar(255).
1265 $default_value = (!empty($application->type_of_water_supply_connection)) ?
1266 trim(decode_entities(
1267 check_plain($application->type_of_water_supply_connection)
1268 )) :
1269 NULL;
1270 $form['tab_place']['services']['type_of_water_supply_connection'] = [
1271 '#type' => 'select',
1272 '#title' => t('Proposed Source of Water Supply'),
1273 '#options' => $new_or_existing,
1274 '#default_value' => $default_value,
1275 '#weight' => 10,
1276 '#required' => FALSE,
1277 ];
1278
1279 // Field on SugarCRM of Type: varchar(255).
1280 $default_value = (!empty($application->water_supply)) ?
1281 trim(decode_entities(check_plain($application->water_supply))) :
1282 NULL;
1283 $form['tab_place']['services']['water_supply'] = [
1284 '#type' => 'select',
1285 '#title' => t('Water Supply'),
1286 '#options' => $water_supply,
1287 '#default_value' => $default_value,
1288 '#weight' => 12,
1289 '#required' => FALSE,
1290 ];
1291
1292 // Field on SugarCRM of Type: varchar(255).
1293 $default_value = (!empty($application->description_of_other_type)) ?
1294 trim(decode_entities(
1295 check_plain($application->description_of_other_type)
1296 )) :
1297 NULL;
1298 $form['tab_place']['services']['description_of_other_type'] = [
1299 '#type' => 'textarea',
1300 '#title' => t('Description of the other Water Supply'),
1301 '#size' => 255,
1302 '#maxlength' => 255,
1303 '#default_value' => $default_value,
1304 '#description' => t('Enter a description of the "other" water supply'),
1305 '#weight' => 14,
1306 '#states' => [
1307 'visible' => [
1308 'select[name="water_supply"]' => [
1309 'value' => 'other',
1310 ],
1311 ],
1312 ],
1313 ];
1314
1315 // Field on SugarCRM of Type: varchar(255).
1316 $default_value = (!empty($application->group_water_scheme_name)) ?
1317 trim(decode_entities(check_plain($application->group_water_scheme_name))) :
1318 NULL;
1319 $form['tab_place']['services']['group_water_scheme_name'] = [
1320 '#type' => 'textfield',
1321 '#title' => t('Name of Group Water Scheme'),
1322 '#size' => 255,
1323 '#maxlength' => 255,
1324 '#default_value' => $default_value,
1325 '#description' => t('Enter group name for the water supply'),
1326 '#weight' => 16,
1327 '#states' => [
1328 'visible' => [
1329 'select[name="water_supply"]' => [
1330 'value' => 'group_water_scheme',
1331 ],
1332 ],
1333 ],
1334 ];
1335
1336 // Field on SugarCRM of Type: varchar(25).
1337 $default_value = (!empty($application->type_of_waste_water_system)) ?
1338 trim(
1339 decode_entities(
1340 check_plain(
1341 $application->type_of_waste_water_system
1342 )
1343 )
1344 ) :
1345 NULL;
1346 $form['tab_place']['services']['type_of_waste_water_system'] = [
1347 '#type' => 'select',
1348 '#title' => t('Proposed Wastewater Management/Treatment'),
1349 '#options' => $new_or_existing,
1350 '#default_value' => $default_value,
1351 '#weight' => 18,
1352 '#required' => FALSE,
1353 ];
1354
1355 $default_value = (!empty($application->waste_water_connection)) ?
1356 trim(decode_entities(check_plain($application->waste_water_connection))) :
1357 NULL;
1358 $form['tab_place']['services']['waste_water_connection'] = [
1359 '#type' => 'select',
1360 '#title' => t('Please specify on-site treatment system'),
1361 '#options' => $waste_water_connection,
1362 '#default_value' => $default_value,
1363 '#weight' => 20,
1364 '#required' => FALSE,
1365 ];
1366
1367 // Field on SugarCRM of Type: varchar(255).
1368 $default_value = (!empty($application->other_treatment_system_desc)) ?
1369 trim(decode_entities(
1370 check_plain($application->other_treatment_system_desc)
1371 )) :
1372 NULL;
1373 $form['tab_place']['services']['other_treatment_system_desc'] = [
1374 '#type' => 'textarea',
1375 '#title' => t('Other treatment system description'),
1376 '#default_value' => $default_value,
1377 '#description' => t('Enter a description of the "other" waste water system'),
1378 '#weight' => 22,
1379 '#states' => [
1380 'visible' => [
1381 'select[name="waste_water_connection"]' => [
1382 'value' => 'other_on_site_treatment_system',
1383 ],
1384 ],
1385 ],
1386 ];
1387
1388 $default_value = (!empty($application->surface_water_disposal)) ?
1389 trim(decode_entities(check_plain($application->surface_water_disposal))) :
1390 NULL;
1391 $form['tab_place']['services']['surface_water_disposal'] = [
1392 '#type' => 'select',
1393 '#title' => t('Proposed Surface Water Disposal'),
1394 '#options' => $surface_water_disposal,
1395 '#default_value' => $default_value,
1396 '#weight' => 24,
1397 '#required' => FALSE,
1398 ];
1399
1400 // Field on SugarCRM of Type: text (Default varchar(2048)).
1401 $default_value = (!empty($application->surface_water_other_description)) ?
1402 trim(decode_entities(
1403 check_plain($application->surface_water_other_description)
1404 )) :
1405 NULL;
1406 $form['tab_place']['services']['surface_water_other_description'] = [
1407 '#type' => 'textarea',
1408 '#title' => t('Other surface water disposal system description'),
1409 '#default_value' => $default_value,
1410 '#description' => t('Enter a description of the "other" surface water disposal'),
1411 '#weight' => 26,
1412 '#states' => [
1413 'visible' => [
1414 'select[name="surface_water_disposal"]' => [
1415 'value' => 'other',
1416 ],
1417 ],
1418 ],
1419 ];
1420
1421 // Tab Proposal.
1422 // Site Area.
1423 $form['tab_proposal']['application_description'] = [
1424 '#type' => 'fieldset',
1425 '#title' => t('Description of Proposed Development'),
1426 '#weight' => 10,
1427 ];
1428
1429 // Site Area.
1430 $form['tab_proposal']['site_area_section'] = [
1431 '#type' => 'fieldset',
1432 '#title' => t('Site area'),
1433 '#weight' => 11,
1434 ];
1435
1436 // Site Area.
1437 $form['tab_proposal']['area'] = [
1438 '#type' => 'fieldset',
1439 '#title' => t('Where the application relates to a building or buildings'),
1440 '#description' => t('Gross floor space means the area ascertained by the internal measurement of the floor space on each floor of a building, that is, floor areas must be measured from inside the external wall.'),
1441 '#weight' => 12,
1442 ];
1443
1444 // Development Classes.
1445 $form['tab_proposal']['development_class'] = [
1446 '#type' => 'fieldset',
1447 '#tree' => TRUE,
1448 '#title' => t('In the case of mixed development (e.g. residential, commercial, industrial, etc)'),
1449 '#description' => t('Please provide a breakdown of the different classes of development and breakdown of the gross floor area of each class of development'),
1450 '#weight' => 14,
1451 ];
1452
1453 // Development Classes.
1454 $form['tab_proposal']['residential_mix'] = [
1455 '#type' => 'fieldset',
1456 '#title' => t('In the case of residential development'),
1457 '#description' => t('Please provide breakdown of residential mix'),
1458 '#weight' => 16,
1459 ];
1460
1461 // Development Classes.
1462 $form['tab_proposal']['material'] = [
1463 '#type' => 'fieldset',
1464 '#title' => t('Where the application refers to a material change of use'),
1465 '#description' => t('Where the application refers to a material change of use of any land or structure or the retention of such a material change of use'),
1466 '#weight' => 18,
1467 ];
1468
1469 // Development Classes.
1470 $form['tab_proposal']['social_affordable'] = [
1471 '#type' => 'fieldset',
1472 '#title' => t('Social and Affordable Housing'),
1473 '#weight' => 20,
1474 ];
1475
1476 // Development Classes.
1477 $form['tab_proposal']['development_details'] = [
1478 '#type' => 'fieldset',
1479 '#title' => t('Development Details'),
1480 '#weight' => 22,
1481 ];
1482
1483 // Public Notices.
1484 $form['tab_proposal']['public_notice'] = [
1485 '#type' => 'fieldset',
1486 '#title' => t('Details of Public Notice'),
1487 '#weight' => 24,
1488 ];
1489
1490 // Field on SugarCRM of Type: varchar(255).
1491 $default_value = (!empty($application->proposed_development_description)) ?
1492 trim(decode_entities(
1493 check_plain($application->proposed_development_description)
1494 )) :
1495 NULL;
1496 $form['tab_proposal']['application_description']['proposed_development_description'] = [
1497 '#type' => 'textarea',
1498 '#title' => t('Brief description of nature and extent of development'),
1499 '#maxlength' => 2500,
1500 '#maxlength_js' => TRUE,
1501 '#default_value' => $default_value,
1502 '#required' => FALSE,
1503 '#description' => t('A brief description of the nature and extent of the development, including reference to the number and height of buildings, protected structures, etc'),
1504 '#weight' => 10,
1505 ];
1506
1507 // Field on SugarCRM of Type: float.
1508 $default_value = (!empty($application->site_area)) ?
1509 trim(decode_entities(check_plain($application->site_area))) :
1510 NULL;
1511 $form['tab_proposal']['site_area_section']['site_area'] = [
1512 '#type' => 'numberfield',
1513 '#step' => 0.001,
1514 '#min' => 0,
1515 '#title' => t('Area of site to which the application relates in hectares'),
1516 '#size' => 25,
1517 '#maxlength' => 25,
1518 '#default_value' => number_format(floatval($default_value), 3, '.', ''),
1519 '#weight' => 10,
1520 '#required' => FALSE,
1521 ];
1522
1523 // Field on SugarCRM of Type: float.
1524 $default_value = (!empty($application->gross_floor_space_existing_buildings)) ?
1525 trim(decode_entities(
1526 check_plain($application->gross_floor_space_existing_buildings)
1527 )) :
1528 NULL;
1529 $form['tab_proposal']['area']['gross_floor_space_existing_buildings'] = [
1530 '#type' => 'numberfield',
1531 '#step' => 0.001,
1532 '#min' => 0,
1533 '#title' => t('Gross floor space of any existing building(s) in ㎡'),
1534 '#size' => 255,
1535 '#maxlength' => 255,
1536 '#default_value' => number_format(floatval($default_value), 3, '.', ''),
1537 '#weight' => 10,
1538 '#required' => FALSE,
1539 ];
1540
1541 // Field on SugarCRM of Type: float.
1542 $default_value = (!empty($application->gross_floor_space_proposed_work)) ?
1543 trim(decode_entities(
1544 check_plain($application->gross_floor_space_proposed_work)
1545 )) :
1546 NULL;
1547 $form['tab_proposal']['area']['gross_floor_space_proposed_work'] = [
1548 '#type' => 'numberfield',
1549 '#step' => 0.001,
1550 '#min' => 0,
1551 '#title' => t('Gross floor space of any proposed work in ㎡'),
1552 '#size' => 255,
1553 '#maxlength' => 255,
1554 '#default_value' => number_format(floatval($default_value), 3, '.', ''),
1555 '#weight' => 12,
1556 '#required' => FALSE,
1557 ];
1558
1559 // Field on SugarCRM of Type: float.
1560 $default_value = (!empty($application->gross_floor_space_retained)) ?
1561 trim(decode_entities(
1562 check_plain($application->gross_floor_space_retained)
1563 )) :
1564 NULL;
1565 $form['tab_proposal']['area']['gross_floor_space_retained'] = [
1566 '#type' => 'numberfield',
1567 '#step' => 0.001,
1568 '#min' => 0,
1569 '#title' => t('Gross floor space to be retained in ㎡ (if appropriate)'),
1570 '#size' => 255,
1571 '#maxlength' => 255,
1572 '#default_value' => number_format(floatval($default_value), 3, '.', ''),
1573 '#weight' => 14,
1574 '#required' => FALSE,
1575 ];
1576
1577 // Field on SugarCRM of Type: float.
1578 $default_value = (!empty($application->gross_floor_space_demolition)) ?
1579 trim(decode_entities(
1580 check_plain($application->gross_floor_space_demolition)
1581 )) :
1582 NULL;
1583 $form['tab_proposal']['area']['gross_floor_space_demolition'] = [
1584 '#type' => 'numberfield',
1585 '#step' => 0.001,
1586 '#min' => 0,
1587 '#title' => t('Gross floor space of any demolition in ㎡ (if appropriate)'),
1588 '#size' => 255,
1589 '#maxlength' => 255,
1590 '#default_value' => number_format(floatval($default_value), 3, '.', ''),
1591 '#weight' => 16,
1592 '#required' => FALSE,
1593 ];
1594
1595 $development_class_options = $sugarCrmClient->enum_from_cache(
1596 'PR_Development_Class',
1597 'class'
1598 );
1599
1600 $payment_url = l(
1601 t('Click here'),
1602 '/fees',
1603 [
1604 'attributes' => ['_target' => 'blank'],
1605 ]
1606 );
1607 $form['tab_proposal']['development_class']['fee_text'] = [
1608 '#type' => 'item',
1609 '#markup' => t('!link for more information on development classes',
1610 [
1611 '!link' => $payment_url,
1612 ]
1613 ),
1614 '#weight' => -6,
1615 ];
1616
1617 $form['tab_proposal']['development_class']['dc_required'] = [
1618 '#type' => 'checkbox',
1619 '#title' => t('Not applicable'),
1620 '#description' => t('Please check if this is not applicable'),
1621 '#weight' => -4,
1622 ];
1623
1624 if (empty($development_class)) {
1625 $form['tab_proposal']['development_class']['dc_required']['#attributes'] =
1626 [
1627 'checked' => ['checked'],
1628 ];
1629 }
1630
1631 $form['tab_proposal']['development_class']['dc_table_header'] = [
1632 '#type' => 'item',
1633 '#markup' => '<table id="table-class-development"><thead><tr><th>Class of Development</th><th>Gross Floor Area in ㎡</th></tr></thead><tbody>',
1634 '#weight' => -2,
1635 ];
1636
1637 $limit = (count($development_class) <= 4) ?
1638 4 :
1639 count($development_class);
1640 for ($i = 0; $i <= $limit; $i++) {
1641
1642 if (is_array($development_class)) {
1643 @reset($development_class[$i]);
1644 }
1645
1646 $idKey = (!empty($development_class[$i])) ?
1647 @key($development_class[$i]) :
1648 '';
1649 $class = (!empty($development_class[$i][$idKey])) ?
1650 $development_class[$i][$idKey] :
1651 '';
1652 $form['tab_proposal']['development_class'][$i]['id']
1653 = [
1654 '#type' => 'hidden',
1655 '#title' => t('ID of Development class'),
1656 '#default_value' => $idKey,
1657 '#prefix' => '<tr class="row-development-class"><td>',
1658 '#weight' => 2,
1659 '#required' => FALSE,
1660 ];
1661
1662 $form['tab_proposal']['development_class'][$i]['class_of_development'] =
1663 [
1664 '#type' => 'select',
1665 '#title' => t('Class of development'),
1666 '#options' => $development_class_options,
1667 '#default_value' => @key($class),
1668 '#suffix' => '</td>',
1669 '#weight' => 4,
1670 '#description' => t('Enter the class of development'),
1671 '#required' => FALSE,
1672 ];
1673
1674 // Field on SugarCRM of Type: float.
1675 $form['tab_proposal']['development_class'][$i]['gross_floor_area_of_class'] = [
1676 '#type' => 'numberfield',
1677 '#step' => 0.1,
1678 '#min' => 0,
1679 '#title' => t('Gross Floor Area in ㎡'),
1680 '#size' => 255,
1681 '#maxlength' => 255,
1682 '#default_value' => @current($class),
1683 '#prefix' => '<td>',
1684 '#suffix' => '</td></tr>',
1685 '#weight' => 6,
1686 '#description' => t('Enter the gross floor space of development class selected'),
1687 '#required' => FALSE,
1688 ];
1689 }
1690
1691 $form['tab_proposal']['development_class']['dc_table_footer'] = [
1692 '#type' => 'item',
1693 '#markup' => '</tbody></table>',
1694 '#weight' => 36,
1695 ];
1696
1697 // phpcs:disable Drupal.Semantics.FunctionT.ConcatString
1698 $form['tab_proposal']['residential_mix']['table_header'] = [
1699 '#type' => 'item',
1700 '#markup' => '<table id="table-residential-mix"><thead><tr><th>' .
1701 t('Number of') .
1702 '</th><th>Studio</th><th>' .
1703 t('1 Bed') .
1704 '</th><th>' .
1705 t('2 Bed') .
1706 '</th><th>' .
1707 t('3 Bed') .
1708 '</th><th>' .
1709 t('4+ Bed') .
1710 '</th><th>' .
1711 t('Total') .
1712 '</th></tr></thead><tbody>',
1713 '#weight' => -2,
1714 ];
1715 // phpcs:enable
1716
1717 // Field on SugarCRM of Type: int(11).
1718 $default_value = (!empty($application) &&
1719 !empty($building_class) &&
1720 array_key_exists('house', $building_class)) ?
1721 $building_class['house'] :
1722 [
1723 'studio' => 0,
1724 '1_bed' => 0,
1725 '2_bed' => 0,
1726 '3_bed' => 0,
1727 '4_bed_plus' => 0,
1728 ];
1729 // phpcs:disable Drupal.Semantics.FunctionT.ConcatString
1730 $form['tab_proposal']['residential_mix']['residential_houses_studio'] = [
1731 '#type' => 'numberfield',
1732 '#step' => 1,
1733 '#min' => 0,
1734 '#title' => t('Studio houses'),
1735 '#size' => 3,
1736 '#maxlength' => 3,
1737 '#default_value' => (array_key_exists('studio', $default_value)) ?
1738 $default_value['studio'] :
1739 NULL,
1740 '#prefix' => '<tr id="row-houses"><td>' . t('Houses') . '</td><td>',
1741 '#suffix' => '</td>',
1742 '#weight' => 2,
1743 '#description' => t('Enter the number of studio houses'),
1744 '#required' => FALSE,
1745 ];
1746 // phpcs:enable
1747
1748 $form['tab_proposal']['residential_mix']['residential_houses_1'] = [
1749 '#type' => 'numberfield',
1750 '#step' => 1,
1751 '#min' => 0,
1752 '#title' => t('1 bed houses'),
1753 '#size' => 3,
1754 '#maxlength' => 3,
1755 '#default_value' => (array_key_exists('1_bed', $default_value)) ?
1756 $default_value['1_bed'] :
1757 NULL,
1758 '#prefix' => '<td>',
1759 '#suffix' => '</td>',
1760 '#weight' => 4,
1761 '#description' => t('Enter the number of 1 bed houses'),
1762 '#required' => FALSE,
1763 ];
1764
1765 $form['tab_proposal']['residential_mix']['residential_houses_2'] = [
1766 '#type' => 'numberfield',
1767 '#step' => 1,
1768 '#min' => 0,
1769 '#title' => t('2 bed houses'),
1770 '#size' => 3,
1771 '#maxlength' => 3,
1772 '#default_value' => (array_key_exists('2_bed', $default_value)) ?
1773 $default_value['2_bed'] :
1774 NULL,
1775 '#prefix' => '<td>',
1776 '#suffix' => '</td>',
1777 '#weight' => 6,
1778 '#description' => t('Enter the number of 2 bed houses'),
1779 '#required' => FALSE,
1780 ];
1781
1782 $form['tab_proposal']['residential_mix']['residential_houses_3'] = [
1783 '#type' => 'numberfield',
1784 '#step' => 1,
1785 '#min' => 0,
1786 '#title' => t('3 bed houses'),
1787 '#size' => 3,
1788 '#maxlength' => 3,
1789 '#default_value' => (array_key_exists('3_bed', $default_value)) ?
1790 $default_value['3_bed'] :
1791 NULL,
1792 '#prefix' => '<td>',
1793 '#suffix' => '</td>',
1794 '#weight' => 8,
1795 '#description' => t('Enter the number of 3 bed houses'),
1796 '#required' => FALSE,
1797 ];
1798
1799 $form['tab_proposal']['residential_mix']['residential_houses_4plus'] = [
1800 '#type' => 'numberfield',
1801 '#step' => 1,
1802 '#min' => 0,
1803 '#title' => t('4+ bed houses'),
1804 '#size' => 3,
1805 '#maxlength' => 3,
1806 '#default_value' => (array_key_exists('4_bed_plus', $default_value)) ?
1807 $default_value['4_bed_plus'] :
1808 NULL,
1809 '#prefix' => '<td>',
1810 '#suffix' => '</td>',
1811 '#weight' => 12,
1812 '#description' => t('Enter the number of 4+ bed houses'),
1813 '#required' => FALSE,
1814 ];
1815
1816 $default_value = (!empty($application->residev_total_house)) ?
1817 trim(decode_entities(check_plain($application->residev_total_house))) :
1818 NULL;
1819 $form['tab_proposal']['residential_mix']['residev_total_house'] = [
1820 '#type' => 'numberfield',
1821 '#step' => 1,
1822 '#min' => 0,
1823 '#title' => t('Total number of houses'),
1824 '#size' => 3,
1825 '#maxlength' => 3,
1826 '#default_value' => $default_value,
1827 '#prefix' => '<td>',
1828 '#suffix' => '</td></tr>',
1829 '#weight' => 14,
1830 '#disabled' => TRUE,
1831 '#required' => FALSE,
1832 ];
1833
1834 // Field on SugarCRM of Type: int(11).
1835 $default_value = (!empty($application) &&
1836 !empty($building_class) &&
1837 array_key_exists('apartment', $building_class)) ?
1838 $building_class['apartment'] :
1839 [
1840 'studio' => 0,
1841 '1_bed' => 0,
1842 '2_bed' => 0,
1843 '3_bed' => 0,
1844 '4_bed_plus' => 0,
1845 ];
1846 // phpcs:disable Drupal.Semantics.FunctionT.ConcatString
1847 $form['tab_proposal']['residential_mix']['residential_apartments_studio'] =
1848 [
1849 '#type' => 'numberfield',
1850 '#step' => 1,
1851 '#min' => 0,
1852 '#title' => t('Studio apartments'),
1853 '#size' => 3,
1854 '#maxlength' => 3,
1855 '#default_value' => (array_key_exists('studio', $default_value)) ?
1856 $default_value['studio'] :
1857 NULL,
1858 '#prefix' => '<tr id="row-apartments"><td>' . t('Apartments') .
1859 '</td><td>',
1860 '#suffix' => '</td>',
1861 '#weight' => 16,
1862 '#description' => t('Enter the number of studio apartments'),
1863 '#required' => FALSE,
1864 ];
1865 //phpcs:enable
1866
1867 $form['tab_proposal']['residential_mix']['residential_apartments_1'] = [
1868 '#type' => 'numberfield',
1869 '#step' => 1,
1870 '#min' => 0,
1871 '#title' => t('1 bed apartments'),
1872 '#size' => 3,
1873 '#maxlength' => 3,
1874 '#default_value' => (array_key_exists('1_bed', $default_value)) ?
1875 $default_value['1_bed'] :
1876 NULL,
1877 '#prefix' => '<td>',
1878 '#suffix' => '</td>',
1879 '#weight' => 18,
1880 '#description' => t('Enter the number of 1 bed apartments'),
1881 '#required' => FALSE,
1882 ];
1883
1884 $form['tab_proposal']['residential_mix']['residential_apartments_2'] = [
1885 '#type' => 'numberfield',
1886 '#step' => 1,
1887 '#min' => 0,
1888 '#title' => t('2 bed apartments'),
1889 '#size' => 3,
1890 '#maxlength' => 3,
1891 '#default_value' => (array_key_exists('2_bed', $default_value)) ?
1892 $default_value['2_bed'] :
1893 NULL,
1894 '#prefix' => '<td>',
1895 '#suffix' => '</td>',
1896 '#weight' => 20,
1897 '#description' => t('Enter the number of 2 bed apartments'),
1898 '#required' => FALSE,
1899 ];
1900
1901 $form['tab_proposal']['residential_mix']['residential_apartments_3'] = [
1902 '#type' => 'numberfield',
1903 '#step' => 1,
1904 '#min' => 0,
1905 '#title' => t('3 bed apartments'),
1906 '#size' => 3,
1907 '#maxlength' => 3,
1908 '#default_value' => (array_key_exists('3_bed', $default_value)) ?
1909 $default_value['3_bed'] :
1910 NULL,
1911 '#prefix' => '<td>',
1912 '#suffix' => '</td>',
1913 '#weight' => 22,
1914 '#description' => t('Enter the number of 3 bed apartments'),
1915 '#required' => FALSE,
1916 ];
1917
1918 $form['tab_proposal']['residential_mix']['residential_apartments_4plus'] =
1919 [
1920 '#type' => 'numberfield',
1921 '#step' => 1,
1922 '#min' => 0,
1923 '#title' => t('4+ bed apartments'),
1924 '#size' => 3,
1925 '#maxlength' => 3,
1926 '#default_value' => (array_key_exists('4_bed_plus', $default_value)) ?
1927 $default_value['4_bed_plus'] :
1928 NULL,
1929 '#prefix' => '<td>',
1930 '#suffix' => '</td>',
1931 '#weight' => 26,
1932 '#description' => t('Enter the number of 4+ bed apartments'),
1933 '#required' => FALSE,
1934 ];
1935
1936 $default_value = (!empty($application->residev_total_apt)) ?
1937 trim(decode_entities(check_plain($application->residev_total_apt))) :
1938 NULL;
1939 $form['tab_proposal']['residential_mix']['residev_total_apt'] = [
1940 '#type' => 'numberfield',
1941 '#step' => 1,
1942 '#min' => 0,
1943 '#title' => t('Total number of apartments'),
1944 '#size' => 3,
1945 '#maxlength' => 3,
1946 '#default_value' => $default_value,
1947 '#prefix' => '<td>',
1948 '#suffix' => '</td></tr>',
1949 '#weight' => 28,
1950 '#disabled' => TRUE,
1951 '#required' => FALSE,
1952 ];
1953
1954 // Field on SugarCRM of Type: int(11).
1955 $default_value = (
1956 !empty($application) &&
1957 !empty(trim(decode_entities(check_plain(
1958 $application->car_parking_spaces_existing
1959 ))))
1960 ) ?
1961 trim(decode_entities(
1962 check_plain($application->car_parking_spaces_existing)
1963 )) :
1964 0;
1965 // phpcs:disable Drupal.Semantics.FunctionT.ConcatString
1966 $form['tab_proposal']['residential_mix']['car_parking_spaces_existing'] =
1967 [
1968 '#type' => 'numberfield',
1969 '#step' => 1,
1970 '#min' => 0,
1971 '#title' => t('Existing car parking spaces'),
1972 '#size' => 3,
1973 '#maxlength' => 3,
1974 '#default_value' => $default_value,
1975 '#prefix' => '<tr id="row-cars"><td>' . t('Number of car park spaces') .
1976 '</td><td colspan="3">',
1977 '#suffix' => '</td>',
1978 '#weight' => 30,
1979 '#description' => t('Enter the number of existing car parking spaces'),
1980 '#required' => FALSE,
1981 ];
1982 // phpcs:enable
1983 $default_value = (
1984 !empty($application) &&
1985 !empty(trim(decode_entities(check_plain(
1986 $application->car_parking_spaces_proposed
1987 ))))
1988 ) ?
1989 trim(decode_entities(
1990 check_plain($application->car_parking_spaces_proposed)
1991 )) :
1992 0;
1993 $form['tab_proposal']['residential_mix']['car_parking_spaces_proposed'] =
1994 [
1995 '#type' => 'numberfield',
1996 '#step' => 1,
1997 '#min' => 0,
1998 '#title' => t('Proposed car parking spaces'),
1999 '#size' => 3,
2000 '#maxlength' => 3,
2001 '#default_value' => $default_value,
2002 '#prefix' => '<td colspan="2">',
2003 '#suffix' => '</td>',
2004 '#weight' => 32,
2005 '#description' => t('Enter the number of proposed car parking spaces'),
2006 '#required' => FALSE,
2007 ];
2008 $default_value = (
2009 !empty($application) &&
2010 !empty(trim(decode_entities(check_plain(
2011 $application->car_parking_spaces_total
2012 ))))
2013 ) ?
2014 trim(decode_entities(
2015 check_plain($application->car_parking_spaces_total)
2016 )) :
2017 0;
2018 $form['tab_proposal']['residential_mix']['car_parking_spaces_total'] = [
2019 '#type' => 'numberfield',
2020 '#step' => 1,
2021 '#min' => 0,
2022 '#title' => t('Total car parking spaces'),
2023 '#size' => 3,
2024 '#maxlength' => 3,
2025 '#default_value' => $default_value,
2026 '#prefix' => '<td>',
2027 '#suffix' => '</td></tr>',
2028 '#weight' => 34,
2029 '#disabled' => TRUE,
2030 '#required' => FALSE,
2031 ];
2032
2033 $form['tab_proposal']['residential_mix']['table_footer'] = [
2034 '#type' => 'item',
2035 '#markup' => '</tbody></table>',
2036 '#weight' => 36,
2037 ];
2038
2039 // Field on SugarCRM of Type: varchar(25).
2040 $default_value = (!empty($application->material_change_of_use)) ?
2041 trim(decode_entities(check_plain($application->material_change_of_use))) :
2042 NULL;
2043 $form['tab_proposal']['material']['material_change_of_use'] = [
2044 '#type' => 'radios',
2045 '#title' => t('Does the application have a change of use?'),
2046 '#options' => $yes_or_no,
2047 '#default_value' => $default_value,
2048 '#weight' => 0,
2049 '#required' => FALSE,
2050 ];
2051
2052 // Field on SugarCRM of Type: varchar(500).
2053 $default_value = (!empty($application->existing_use)) ?
2054 trim(decode_entities(check_plain($application->existing_use))) :
2055 NULL;
2056 $form['tab_proposal']['material']['existing_use'] = [
2057 '#type' => 'textarea',
2058 '#title' => t('Existing use (or previous use where retention permission is sought)'),
2059 '#maxlength' => 500,
2060 '#maxlength_js' => TRUE,
2061 '#default_value' => $default_value,
2062 '#weight' => 2,
2063 '#description' => t('Where the existing land or structure is not in use, please state most recent authorised use of the land or structure.'),
2064 '#required' => FALSE,
2065 '#states' => [
2066 'visible' => [
2067 'input[name="material_change_of_use"]' => [
2068 'value' => 'Yes',
2069 ],
2070 ],
2071 ],
2072 ];
2073
2074 // Field on SugarCRM of Type: varchar(500).
2075 $default_value = (!empty($application->proposed_use)) ?
2076 trim(decode_entities(check_plain($application->proposed_use))) :
2077 NULL;
2078 $form['tab_proposal']['material']['proposed_use'] = [
2079 '#type' => 'textarea',
2080 '#title' => t('Proposed use (or use it is proposed to retain)'),
2081 '#maxlength' => 500,
2082 '#maxlength_js' => TRUE,
2083 '#default_value' => $default_value,
2084 '#weight' => 4,
2085 '#required' => FALSE,
2086 '#states' => [
2087 'visible' => [
2088 'input[name="material_change_of_use"]' => [
2089 'value' => 'Yes',
2090 ],
2091 ],
2092 ],
2093 ];
2094
2095 // Field on SugarCRM of Type: varchar(500).
2096 $default_value = (!empty($application->nature_extended_proposed)) ?
2097 trim(decode_entities(check_plain($application->nature_extended_proposed))) :
2098 NULL;
2099 $form['tab_proposal']['material']['nature_extended_proposed'] = [
2100 '#type' => 'textarea',
2101 '#title' => t('Nature and extent of any such proposed use (or use it is proposed to retain)'),
2102 '#maxlength' => 500,
2103 '#maxlength_js' => TRUE,
2104 '#default_value' => $default_value,
2105 '#weight' => 6,
2106 '#required' => FALSE,
2107 '#states' => [
2108 'visible' => [
2109 'input[name="material_change_of_use"]' => [
2110 'value' => 'Yes',
2111 ],
2112 ],
2113 ],
2114 ];
2115
2116 // Field on SugarCRM of Type: varchar(25).
2117 $default_value = (!empty($application->does_part_v_apply)) ?
2118 trim(decode_entities(check_plain($application->does_part_v_apply))) :
2119 NULL;
2120 $form['tab_proposal']['social_affordable']['does_part_v_apply'] = [
2121 '#type' => 'radios',
2122 '#title' => t('Is the application an application for permission for development to which Part V of the Planning and Development Act 2000 (as Amended) applies?'),
2123 '#options' => $yes_or_no,
2124 '#default_value' => $default_value,
2125 '#weight' => 8,
2126 '#description' => t('Part V of the Planning and Development Act 2000 applies where the land is zoned for residential use or for a mixture of residential and other uses, there is an objective in the Development Plan for the area for a percentage of the land to be made available for social and/or affordable housing, and the proposed development is not exempt from Part V.'),
2127 '#required' => FALSE,
2128 ];
2129 $label = t(
2130 '<p>If the answer to the above question is “yes” and the development is not exempt (see below), you
2131 must provide, as part of your application, details as to how you propose to comply with section 96 of
2132 Part V of the Act including, for example,</p>
2133 <ol><li>details of such part or parts of the land which is subject to the application for permission or is or
2134 are specified by the Part V agreement, or houses situated on such aforementioned land or
2135 elsewhere in the planning authority’s functional area proposed to be transferred to the planning
2136 authority, or details of houses situated on such aforementioned land or elsewhere in the planning
2137 authority’s functional area proposed to be leased to the planning authority, or details of any
2138 combination of the foregoing and</li>
2139 <li> details of the calculations and methodology for calculating values of land, site costs, normal
2140 construction and development costs and profit on those costs and other related costs such as an
2141 appropriate share of any common development works as required to comply with the provisions in
2142 Part V of the Act.</li></ol><br />
2143 <p>If the answer to the above question is “yes” but you consider the development to be exempt by
2144 virtue of section 97 of the Planning and Development Act 2000, a copy of the Certificate of
2145 Exemption under section 97 must be submitted (or, where an application for a certificate of
2146 exemption has been made but has not yet been decided, a copy of the application should be
2147 submitted).</p>'
2148 );
2149 $desc = t('Under section 97 of the Planning and Development Act 2000, applications involving development of 9 or fewer houses or development on land of less than 0.1 hectare may be exempt from Part V.');
2150 if ($default_value == "No") {
2151 $label = t('If the answer to the above question is "No" by virtue of section 96 (13) of the Planning and Development Act 2000 (as Amended), details indicating the basis on which section 96 (13) is considered to apply should be submitted.');
2152 $desc = t('Under section 96(13) of the Planning and Development Act 2000, Part V does not apply to certain housing developments by approved voluntary housing bodies, certain conversions, the carrying out of works to an existing house or the development of houses under an agreement made under section 96 of the Act.');
2153 }
2154
2155 // Field on SugarCRM of Type: text (Default: varchar(2048)).
2156 $default_value = (!empty($application->explain_part_v_compliance_exemption_not_applicable)) ?
2157 trim(decode_entities(check_plain(
2158 $application->explain_part_v_compliance_exemption_not_applicable
2159 ))) :
2160 NULL;
2161 $form['tab_proposal']['social_affordable']['explain_part_v_compliance_exemption_not_applicable'] = [
2162 '#type' => 'textarea',
2163 '#title' => $label,
2164 '#maxlength' => 2000,
2165 '#maxlength_js' => TRUE,
2166 '#default_value' => $default_value,
2167 '#weight' => 10,
2168 '#description' => $desc,
2169 '#required' => FALSE,
2170 '#states' => [
2171 'invisible' => [
2172 'input[name="does_part_v_apply"]' => [
2173 'value' => '',
2174 ],
2175 ],
2176 ],
2177 ];
2178
2179 // Field on SugarCRM of Type: varchar(25).
2180 $default_value = (!empty($application->protected_structure)) ?
2181 trim(decode_entities(check_plain($application->protected_structure))) :
2182 NULL;
2183 $form['tab_proposal']['development_details']['protected_structure'] = [
2184 '#type' => 'radios',
2185 '#title' => t('Does the proposed development consist of work to a protected structure and / or its curtilage or proposed protected structure and / or it curtilage?'),
2186 '#options' => $yes_or_no,
2187 '#default_value' => $default_value,
2188 '#weight' => 34,
2189 '#required' => FALSE,
2190 ];
2191
2192 // Field on SugarCRM of Type: varchar(25).
2193 $default_value = (!empty($application->architectural_conservation_area)) ?
2194 trim(decode_entities(
2195 check_plain($application->architectural_conservation_area)
2196 )) :
2197 NULL;
2198 $form['tab_proposal']['development_details']['architectural_conservation_area'] = [
2199 '#type' => 'radios',
2200 '#title' => t('Does the proposed development consist of work to the exterior of a structure which is located within an architectural conservation area (ACA)'),
2201 '#options' => $yes_or_no,
2202 '#default_value' => $default_value,
2203 '#weight' => 36,
2204 '#required' => FALSE,
2205 ];
2206
2207 // Field on SugarCRM of Type: varchar(255).
2208 $default_value = (!empty($application->close_to_monument)) ?
2209 trim(decode_entities(check_plain($application->close_to_monument))) :
2210 NULL;
2211 $form['tab_proposal']['development_details']['close_to_monument'] = [
2212 '#type' => 'radios',
2213 '#title' => t('Does the application relate to development which affects or is close to a monument or place recorded under section 12 of the National Monuments (Amendment) Act 1994?'),
2214 '#options' => $yes_or_no,
2215 '#default_value' => $default_value,
2216 '#weight' => 38,
2217 '#description' => t('The Record of Monuments and Places, under section 12 of the National Monuments Amendment Act 1994, is available, for each county, in the local authorities and public libraries in that county. Please note also that if the proposed development affects or is close to a national monument which, under the National Monuments Acts 1930 to 2004, is in the ownership or guardianship of the Minister for Culture, Heritage and the Gaeltacht or a local authority, or is the subject of a preservation order or a temporary preservation order, a separate statutory consent is required, under the National Monuments Acts, from the Minister for Culture, Heritage and the Gaeltacht. For information on whether national monuments are in the ownership or guardianship of the Minister for Culture, Heritage and the Gaeltacht or a local authority or are the subject of preservation orders, contact the National Monuments Section, Department of Culture, Heritage and the Gaeltacht.'),
2218 '#required' => FALSE,
2219 ];
2220
2221 // Field on SugarCRM of Type: varchar(25).
2222 $default_value = (!empty($application->require_eis)) ?
2223 trim(decode_entities(check_plain($application->require_eis))) :
2224 NULL;
2225 $form['tab_proposal']['development_details']['require_eis'] = [
2226 '#type' => 'radios',
2227 '#title' => t('Does the proposed development require the preparation of an Environmental Impact Assessment Report'),
2228 '#options' => $yes_or_no,
2229 '#default_value' => $default_value,
2230 '#weight' => 40,
2231 '#description' => t('Except in the case of peat extraction that would involve an area of 30 hectares or more, an environmental impact assessment report (EIAR) and the confirmation notice from the EIA portal are required to accompany a planning application for development of a class set out in Schedule 5 of the Planning and Development Regulations 2001-2018 which equals or exceeds, as the case may be, a limit, quantity or threshold set for that class of development. An EIAR and confirmation notice from the EIA portal will also be required by the planning authority in respect of sub-threshold development where the authority considers that the development would be likely to have significant effects on the environment (article 103).'),
2232 '#required' => FALSE,
2233 ];
2234
2235 // Field on SugarCRM of Type: varchar(25).
2236 $default_value = (!empty($application->natural_heritage_area)) ?
2237 trim(decode_entities(check_plain($application->natural_heritage_area))) :
2238 NULL;
2239 $form['tab_proposal']['development_details']['natural_heritage_area'] = [
2240 '#type' => 'radios',
2241 '#title' => t('Does the application relate to work within or close to a European Site (under S.I. No. 94 of 1997) or a Natural Heritage Area?'),
2242 '#options' => $yes_or_no,
2243 '#default_value' => $default_value,
2244 '#weight' => 42,
2245 '#description' => t('An appropriate assessment of proposed development is required in cases where it cannot be excluded that the proposed development would have a significant effect on a European site. It is the responsibility of the planning authority to screen proposed developments to determine whether an appropriate assessment is required and where the authority determines that an appropriate assessment is required, the authority will normally require the applicant to submit a Natura impact statement (NIS). Where the applicant considers that the proposed development is likely to have a significant effect on a European site it is open to him/her to submit a NIS with the planning application.'),
2246 '#required' => FALSE,
2247 ];
2248
2249 // Field on SugarCRM of Type: varchar(25).
2250 $default_value = (!empty($application->require_ipc_licence)) ?
2251 trim(decode_entities(check_plain($application->require_ipc_licence))) :
2252 NULL;
2253 $form['tab_proposal']['development_details']['require_ipc_licence'] = [
2254 '#type' => 'radios',
2255 '#title' => t('Does the application relate to a development which comprises or is for the purposes of an activity requiring an integrated pollution prevention and control licence'),
2256 '#options' => $yes_or_no,
2257 '#default_value' => $default_value,
2258 '#weight' => 44,
2259 '#required' => FALSE,
2260 ];
2261
2262 // Field on SugarCRM of Type: varchar(25).
2263 $default_value = (!empty($application->require_waste_licence)) ?
2264 trim(decode_entities(check_plain($application->require_waste_licence))) :
2265 NULL;
2266 $form['tab_proposal']['development_details']['require_waste_licence'] = [
2267 '#type' => 'radios',
2268 '#title' => t('Does the application relate to a development which comprises or is for the purposes of an activity requiring a waste licence?'),
2269 '#options' => $yes_or_no,
2270 '#default_value' => $default_value,
2271 '#weight' => 46,
2272 '#required' => FALSE,
2273 ];
2274
2275 // Field on SugarCRM of Type: varchar(25).
2276 $default_value = (!empty($application->major_accident_regulations)) ?
2277 trim(decode_entities(
2278 check_plain($application->major_accident_regulations)
2279 )) :
2280 NULL;
2281 $form['tab_proposal']['development_details']['major_accident_regulations'] = [
2282 '#type' => 'radios',
2283 '#title' => t('Do the Major Accident Regulations apply to the proposed development'),
2284 '#options' => $yes_or_no,
2285 '#default_value' => $default_value,
2286 '#weight' => 48,
2287 '#required' => FALSE,
2288 ];
2289
2290 // Field on SugarCRM of Type: varchar(25).
2291 $default_value = (!empty($application->strategic_development_zone)) ?
2292 trim(decode_entities(
2293 check_plain($application->strategic_development_zone)
2294 )) :
2295 NULL;
2296 $form['tab_proposal']['development_details']['strategic_development_zone'] = [
2297 '#type' => 'radios',
2298 '#title' => t('Does the application relate to a development in a Strategic Development Zone?'),
2299 '#options' => $yes_or_no,
2300 '#default_value' => $default_value,
2301 '#weight' => 50,
2302 '#required' => FALSE,
2303 ];
2304
2305 // Field on SugarCRM of Type: varchar(25).
2306 $default_value = (!empty($application->involve_demolition)) ?
2307 trim(decode_entities(check_plain($application->involve_demolition))) :
2308 NULL;
2309 $form['tab_proposal']['development_details']['involve_demolition'] = [
2310 '#type' => 'radios',
2311 '#title' => t('Does the proposed development involve the demolition of any structure'),
2312 '#options' => $yes_or_no,
2313 '#default_value' => $default_value,
2314 '#weight' => 52,
2315 '#required' => FALSE,
2316 ];
2317
2318 // Field on SugarCRM of Type: varchar(255).
2319 $default_value = (!empty($application->pr_public_notice_newspaper)) ?
2320 trim(decode_entities(
2321 check_plain($application->pr_public_notice_newspaper)
2322 )) :
2323 NULL;
2324 $form['tab_proposal']['public_notice']['pr_public_notice_newspaper'] = [
2325 '#type' => 'textfield',
2326 '#title' => t('Approved Newspaper in which notice was published'),
2327 '#size' => 255,
2328 '#maxlength' => 255,
2329 '#default_value' => $default_value,
2330 '#weight' => 10,
2331 '#description' => t(
2332 'Enter the name of the approved newspaper in which notice was published. A full list for the !name local authority can be found at <a href="!link">!link</a>',
2333 [
2334 '!name' => $la->name,
2335 '!link' => $la->newspapers,
2336 ]
2337 ),
2338 '#required' => FALSE,
2339 ];
2340
2341 // Field on SugarCRM of Type: date.
2342 $default_value = (!empty($application->date_of_publication)) ?
2343 trim(decode_entities(check_plain($application->date_of_publication))) :
2344 NULL;
2345 $form['tab_proposal']['public_notice']['date_of_publication'] = [
2346 '#type' => 'date_popup',
2347 '#title' => t('Date of Publication'),
2348 '#date_year_range' => '-1:+0',
2349 '#date_format' => 'd/m/Y',
2350 '#datepicker_options' => ['minDate' => '-13d', 'maxDate' => '0'],
2351 '#default_value' => $default_value,
2352 '#weight' => 12,
2353 '#description' => t('Enter the date of publication'),
2354 '#required' => FALSE,
2355 ];
2356
2357 // Field on SugarCRM of Type: date.
2358 $default_value = (!empty($application->date_site_notice_erected)) ?
2359 trim(decode_entities(check_plain($application->date_site_notice_erected))) :
2360 NULL;
2361 $site_notice_url = l(t('Please click here'),
2362 '/site-notice-template',
2363 ['attributes' => ['_target' => 'blank']]
2364 );
2365
2366 $form['tab_proposal']['public_notice']['date_site_notice_erected'] = [
2367 '#type' => 'date_popup',
2368 '#title' => t('Date on which site notice was erected'),
2369 '#date_year_range' => '-1:+0',
2370 '#date_format' => 'd/m/Y',
2371 '#datepicker_options' => ['minDate' => '-13d', 'maxDate' => '0'],
2372 '#default_value' => $default_value,
2373 '#weight' => 14,
2374 '#description' => t(
2375 'Enter the date the site notice was erected. !link to download a blank site notice template',
2376 ['!link' => $site_notice_url]
2377 ),
2378 '#required' => FALSE,
2379 ];
2380
2381 // Supporting Documentation.
2382 $form['tab_supporting_documents']['documents'] = [
2383 '#type' => 'fieldset',
2384 '#title' => t('Documents'),
2385 '#weight' => 10,
2386 ];
2387
2388 $form['tab_supporting_documents']['documents']['instructions'] = [
2389 '#type' => 'fieldset',
2390 '#weight' => 1,
2391 ];
2392
2393 $supporting_docs_url = l(
2394 t('supporting documentation'),
2395 '/documents-help',
2396 ['attributes' => ['_target' => '_blank']]
2397 );
2398
2399 $form['tab_supporting_documents']['documents']['instructions'] = [
2400 '#type' => 'item',
2401 '#markup' => t(
2402 'It should be noted that each planning authority has its own development plan, which sets out local development policies and objectives for its own area. The authority may therefore need supplementary information (i.e. other than that required in this on line application) in order to determine whether the application conforms with the development plan and may request this on a <a href="!link">part B application form (supplementary application form)</a>.',
2403 [
2404 '!name' => $la->name,
2405 '!link' => $la->part_b_url,
2406 ]
2407 ),
2408 '#weight' => 1,
2409 ];
2410 $form['tab_supporting_documents']['documents']['instructions2'] = [
2411 '#type' => 'item',
2412 '#markup' => t(
2413 'Failure to supply the supplementary information will not invalidate your planning application but may delay the decision-making process or lead to a refusal of permission. Therefore applicants should contact the relevant planning authority to determine what local policies and objectives would apply to the development proposed and whether additional information is required. Instructions for uploading !url can be found here.',
2414 ['!url' => $supporting_docs_url]
2415 ),
2416 '#description' => t('The location of the site notice(s) should be shown on site location map.<br /><br />All plans, drawings and maps submitted to the planning authority should be in accordance with the requirements of the Planning and Development Regulations 2001-2018.'),
2417 '#weight' => 2,
2418 ];
2419
2420 $compulsory_header = [
2421 t('Document type'),
2422 t('Uploaded'),
2423 ];
2424
2425 $doctypes = _get_all_required_doc_types_by_key($sugarCrmClient, $application);
2426 $allDocTypes = _get_all_part_a_doc_types($sugarCrmClient, $application);
2427 $docs_uploaded = [];
2428
2429 foreach ($documents as $key => $document) {
2430 $docs_uploaded[] = $document->pr_doctype_id;
2431 }
2432
2433 foreach ($doctypes as $key => $value) {
2434 $uploaded = t("No");
2435 if ($key !== 'PARTVDOCS' && in_array($key, $docs_uploaded)) {
2436 $uploaded = t("Yes");
2437 }
2438
2439 if ($key == 'PARTVDOCS') {
2440 $exemption_required = _get_named_doc_types(
2441 $sugarCrmClient,
2442 'Part V Exemption Application Form'
2443 );
2444 $cert_required = _get_named_doc_types(
2445 $sugarCrmClient,
2446 'Part V Exemption Cert'
2447 );
2448 $compliance_required = _get_named_doc_types(
2449 $sugarCrmClient,
2450 'Part V compliance'
2451 );
2452 $financial_required = _get_named_doc_types(
2453 $sugarCrmClient,
2454 'Part V Financial Proposals'
2455 );
2456 if (
2457 in_array($exemption_required[0]->id, $docs_uploaded) ||
2458 in_array($cert_required[0]->id, $docs_uploaded) ||
2459 in_array($compliance_required[0]->id, $docs_uploaded) ||
2460 in_array($financial_required[0]->id, $docs_uploaded)
2461 ) {
2462 $uploaded = t("Yes");
2463 }
2464 }
2465 $row['data'] = [
2466 $value,
2467 $uploaded,
2468 ];
2469 $compulsory_rows[] = $row;
2470 }
2471
2472 $compulsory_table = [
2473 'header' => $compulsory_header,
2474 'rows' => $compulsory_rows,
2475 ];
2476
2477 $themed_compulsory_table = theme('table', $compulsory_table);
2478
2479 $form['tab_supporting_documents']['documents']['compulsory_docs'] = [
2480 '#type' => 'item',
2481 '#markup' => render($themed_compulsory_table),
2482 '#weight' => 4,
2483 ];
2484
2485 $form['tab_supporting_documents']['documents']['document_upload'] = [
2486 '#type' => 'fieldset',
2487 '#weight' => 5,
2488 '#tree' => TRUE,
2489 ];
2490
2491 $form['tab_supporting_documents']['documents']['documentation'] = [
2492 '#type' => 'fieldset',
2493 '#weight' => 15,
2494 '#tree' => TRUE,
2495 ];
2496
2497 if (empty($form_state['num_uploads'])) {
2498 $form_state['num_uploads'] = 4;
2499 }
2500
2501 $form['tab_supporting_documents']['documents']['document_upload'][0]['document_type'] =
2502 [
2503 '#title' => t('Type'),
2504 '#type' => 'select',
2505 '#options' => $allDocTypes,
2506 '#weight' => -50,
2507 ];
2508
2509 $form['tab_supporting_documents']['documents']['document_upload'][0]['document_description'] =
2510 [
2511 '#type' => 'textfield',
2512 '#title' => t('Description'),
2513 '#weight' => -48,
2514 ];
2515
2516 $form['tab_supporting_documents']['documents']['document_upload'][0]['document_file'] =
2517 [
2518 '#type' => 'file',
2519 '#name' => 'files[]',
2520 '#title' => t('PDF to upload'),
2521 '#attributes' => [
2522 'multiple' => 'multiple',
2523 ],
2524 '#weight' => -46,
2525 ];
2526
2527 for ($i = 1; $i <= $form_state['num_uploads']; $i++) {
2528 $j = 1 * $i;
2529 $k = 2 * $i;
2530 $l = 3 * $i;
2531 $form['tab_supporting_documents']['documents']['document_upload'][$i]['document_type'] =
2532 [
2533 '#title' => t('Type'),
2534 '#type' => 'select',
2535 '#options' => $allDocTypes,
2536 '#default_value' => '-',
2537 '#weight' => $j,
2538 ];
2539
2540 $form['tab_supporting_documents']['documents']['document_upload'][$i]['document_description'] =
2541 [
2542 '#type' => 'textfield',
2543 '#title' => t('Description'),
2544 '#weight' => $k,
2545 ];
2546
2547 $form['tab_supporting_documents']['documents']['document_upload'][$i]['document_file'] =
2548 [
2549 '#type' => 'file',
2550 '#name' => 'files[]',
2551 '#title' => t('PDF to upload'),
2552 '#attributes' => [
2553 'multiple' => 'multiple',
2554 ],
2555 '#weight' => $l,
2556 ];
2557 }
2558
2559 $form['tab_supporting_documents']['documents']['documentation']['docdel_table_header'] = [
2560 '#type' => 'item',
2561 '#markup' => '<table id="table-class-documents"><thead><tr><th>' .
2562 t('File Name') .
2563 '</th><th>' .
2564 t('Document Type') .
2565 '</th><th>' .
2566 t('Description') .
2567 '</th><th>' .
2568 t('Download') .
2569 '</th><th>' .
2570 t('Delete') .
2571 '</th></tr></thead><tbody>',
2572 '#weight' => -2,
2573 ];
2574
2575 if (empty($documents)) {
2576 $form['tab_supporting_documents']['documents']['documentation'][0]['docdel_table_row'] = [
2577 '#type' => 'item',
2578 '#markup' => '<tr><td colspan="5">' .
2579 t('You have yet to upload documents') .
2580 "</td></tr>",
2581 '#weight' => 0,
2582 ];
2583 }
2584 else {
2585
2586 $count = count($documents);
2587 for ($i = 0; $i < $count; $i++) {
2588 $document = $documents[$i];
2589 $link = l(t('Download'), '/applications/download/' . $document->id,
2590 [
2591 'attributes' => [
2592 'target' => '_blank',
2593 ],
2594 ]
2595 );
2596
2597 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_id'] = [
2598 '#type' => 'hidden',
2599 '#default_value' => trim(check_plain($document->id)),
2600 '#weight' => $i,
2601 ];
2602 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_name'] = [
2603 '#type' => 'item',
2604 '#prefix' => '<tr class="document-delete-row"><td>',
2605 '#markup' => trim(check_plain($document->name)),
2606 '#suffix' => '</td>',
2607 '#weight' => $i,
2608 ];
2609 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_type'] = [
2610 '#type' => 'item',
2611 '#prefix' => '<td>',
2612 '#markup' => trim(check_plain($document->pr_doctype_documents_name)),
2613 '#suffix' => '</td>',
2614 '#weight' => $i,
2615 ];
2616 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_description'] = [
2617 '#type' => 'item',
2618 '#prefix' => '<td>',
2619 '#markup' => trim(check_plain($document->description)),
2620 '#suffix' => '</td>',
2621 '#weight' => $i,
2622 ];
2623 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_link'] = [
2624 '#type' => 'item',
2625 '#prefix' => '<td>',
2626 '#markup' => $link,
2627 '#suffix' => '</td>',
2628 '#weight' => $i,
2629 ];
2630 $form['tab_supporting_documents']['documents']['documentation'][$i]['document_delete'] = [
2631 '#type' => 'checkbox',
2632 '#description' => t('Please tick the checkbox if you wish to delete this document and press "Upload".'),
2633 '#prefix' => '<td>',
2634 '#suffix' => '</td></tr>',
2635 '#weight' => $i,
2636 ];
2637 }
2638 }
2639
2640 $form['tab_supporting_documents']['documents']['documentation']['docdel_table_footer'] = [
2641 '#type' => 'item',
2642 '#markup' => '</tbody></table>',
2643 '#weight' => 36,
2644 ];
2645
2646 // Applicant details.
2647 $form['tab_people']['applicant_details'] = [
2648 '#type' => 'fieldset',
2649 '#title' => t('Applicant Contact Details'),
2650 '#weight' => 16,
2651 ];
2652
2653 $form['tab_people']['applicant_details']['applicant_name'] = [
2654 '#type' => 'fieldset',
2655 '#title' => t('Applicant Name'),
2656 '#weight' => 10,
2657 ];
2658
2659 $form['tab_people']['applicant_details']['applicant_address'] = [
2660 '#type' => 'fieldset',
2661 '#title' => t('Applicant Address'),
2662 '#weight' => 12,
2663 ];
2664
2665 $form['tab_people']['applicant_details']['applicant_contact'] = [
2666 '#type' => 'fieldset',
2667 '#title' => t('Applicant Contact Details'),
2668 '#weight' => 14,
2669 ];
2670
2671 // Company Details.
2672 $form['tab_people']['company_details'] = [
2673 '#type' => 'fieldset',
2674 '#title' => t('Where Applicant is a company (Registered under the Companies Act)'),
2675 '#weight' => 18,
2676 ];
2677
2678 $form['tab_people']['company_details']['company_address'] = [
2679 '#type' => 'fieldset',
2680 '#title' => t('Company Address'),
2681 '#weight' => 12,
2682 '#states' => [
2683 'invisible' => [
2684 [
2685 [
2686 'input[name="is_an_company_involved"]' => ['value' => 'No'],
2687 ],
2688 'or',
2689 [
2690 'input[name="is_an_company_involved"]' => ['value' => ''],
2691 ],
2692 ],
2693 ],
2694 ],
2695 ];
2696
2697 // Agent Details.
2698 $form['tab_people']['agent_details'] = [
2699 '#type' => 'fieldset',
2700 '#title' => t('Person / Agent acting on behalf of the Applicant (if any)'),
2701 '#weight' => 20,
2702 ];
2703
2704 $form['tab_people']['agent_details']['agent_name'] = [
2705 '#type' => 'fieldset',
2706 '#title' => t('Agent Name'),
2707 '#weight' => 10,
2708 '#states' => [
2709 'invisible' => [
2710 [
2711 [
2712 'input[name="is_an_agent_involved"]' => ['value' => 'No'],
2713 ],
2714 'or',
2715 [
2716 'input[name="is_an_agent_involved"]' => ['value' => ''],
2717 ],
2718 ],
2719 ],
2720 ],
2721 ];
2722
2723 $form['tab_people']['agent_details']['agent_address'] = [
2724 '#type' => 'fieldset',
2725 '#title' => t('Agent Address'),
2726 '#weight' => 12,
2727 '#states' => [
2728 'invisible' => [
2729 [
2730 [
2731 'input[name="is_an_agent_involved"]' => ['value' => 'No'],
2732 ],
2733 'or',
2734 [
2735 'input[name="is_an_agent_involved"]' => ['value' => ''],
2736 ],
2737 ],
2738 ],
2739 ],
2740 ];
2741
2742 $form['tab_people']['agent_details']['agent_contact'] = [
2743 '#type' => 'fieldset',
2744 '#title' => t('Agent Contact Details'),
2745 '#weight' => 14,
2746 '#states' => [
2747 'invisible' => [
2748 [
2749 [
2750 'input[name="is_an_agent_involved"]' => ['value' => 'No'],
2751 ],
2752 'or',
2753 [
2754 'input[name="is_an_agent_involved"]' => ['value' => ''],
2755 ],
2756 ],
2757 ],
2758 ],
2759 ];
2760
2761 // Drawing Details.
2762 $form['tab_people']['drawing_details'] = [
2763 '#type' => 'fieldset',
2764 '#title' => t('Drawing Details'),
2765 '#weight' => 22,
2766 ];
2767
2768 // Land owner Details.
2769 $form['tab_people']['land_details'] = [
2770 '#type' => 'fieldset',
2771 '#title' => t('Legal Interest of Applicant in the Land or Structure'),
2772 '#weight' => 24,
2773 ];
2774
2775 $form['tab_people']['land_details']['land_owner_name'] = [
2776 '#type' => 'fieldset',
2777 '#title' => t('Land Owner Name'),
2778 '#weight' => 16,
2779 '#states' => [
2780 'invisible' => [
2781 [
2782 [
2783 'select[name="legal_interest_in_land"]' => ['value' => 'Owner'],
2784 ],
2785 'or',
2786 [
2787 'select[name="legal_interest_in_land"]' => ['value' => ''],
2788 ],
2789 ],
2790 ],
2791 ],
2792 ];
2793
2794 $form['tab_people']['land_details']['land_owner_address'] = [
2795 '#type' => 'fieldset',
2796 '#title' => t('Land Owner Address'),
2797 '#weight' => 18,
2798 '#states' => [
2799 'invisible' => [
2800 [
2801 [
2802 'select[name="legal_interest_in_land"]' => ['value' => 'Owner'],
2803 ],
2804 'or',
2805 [
2806 'select[name="legal_interest_in_land"]' => ['value' => ''],
2807 ],
2808 ],
2809 ],
2810 ],
2811 ];
2812
2813 // Form details.
2814 // Field on SugarCRM of Type: varchar(255).
2815 $default_value = (!empty($application->id)) ?
2816 trim(decode_entities(check_plain($application->id))) :
2817 NULL;
2818 $form['id'] = [
2819 '#type' => 'hidden',
2820 '#title' => t('Application ID'),
2821 '#size' => 255,
2822 '#maxlength' => 255,
2823 '#default_value' => $default_value,
2824 ];
2825
2826 // Logic for auto-filling agent details.
2827 $role = $contact->role_type;
2828 $applicant_contact_first_name = !empty($application->applicant_name) ?
2829 trim(decode_entities(check_plain($application->applicant_name))) :
2830 NULL;
2831 $applicant_contact_last_name = !empty($application->applicant_surname) ?
2832 trim(decode_entities(check_plain($application->applicant_surname))) :
2833 NULL;
2834 $applicant_contact_street = !empty($application->applicant_address_line_1) ?
2835 trim(decode_entities(check_plain($application->applicant_address_line_1))) :
2836 NULL;
2837 $applicant_contact_city = !empty($application->applicant_address_line_2) ?
2838 trim(decode_entities(check_plain($application->applicant_address_line_2))) :
2839 NULL;
2840 $applicant_contact_state = !empty($application->applicant_address_line_3) ?
2841 trim(decode_entities(check_plain($application->applicant_address_line_3))) :
2842 NULL;
2843 $applicant_contact_postalcode = !empty($application->applicant_address_line_4) ?
2844 trim(decode_entities(check_plain($application->applicant_address_line_4))) :
2845 NULL;
2846 $applicant_contact_email = !empty($application->applicant_email) ?
2847 trim(decode_entities(check_plain($application->applicant_email))) :
2848 NULL;
2849 $applicant_contact_phone = !empty($application->applicant_phone_number) ?
2850 trim(decode_entities(check_plain($application->applicant_phone_number))) :
2851 NULL;
2852 $applicant_contact_mobile = !empty($application->applicant_mobile) ?
2853 trim(decode_entities(check_plain($application->applicant_mobile))) :
2854 NULL;
2855 $applicant_contact_country = NULL;
2856
2857 if ($role == "applicant") {
2858 if (empty($applicant_contact_first_name)) {
2859 $applicant_contact_first_name = $contact->first_name;
2860 }
2861 if (empty($applicant_contact_last_name)) {
2862 $applicant_contact_last_name = $contact->last_name;
2863 }
2864 if (empty($applicant_contact_street)) {
2865 $applicant_contact_street = $contact->primary_address_street;
2866 }
2867 if (empty($applicant_contact_city)) {
2868 $applicant_contact_city = $contact->primary_address_city;
2869 }
2870 if (empty($applicant_contact_state)) {
2871 $applicant_contact_state = $contact->primary_address_state;
2872 }
2873 if (empty($applicant_contact_postalcode)) {
2874 $applicant_contact_postalcode = $contact->primary_address_postalcode;
2875 }
2876 if (empty($applicant_contact_country)) {
2877 $applicant_contact_country = $contact->primary_address_country;
2878 }
2879 if (empty($applicant_contact_email)) {
2880 $applicant_contact_email = $contact->email1;
2881 }
2882 if (empty($applicant_contact_phone)) {
2883 $applicant_contact_phone = $contact->phone_work;
2884 }
2885 if (empty($applicant_contact_mobile)) {
2886 $applicant_contact_mobile = $contact->phone_mobile;
2887 }
2888 }
2889 // Field on SugarCRM of Type: varchar(255).
2890 $form['tab_people']['applicant_details']['applicant_name']['applicant_name'] =
2891 [
2892 '#type' => 'textfield',
2893 '#title' => t('Applicant Forename'),
2894 '#size' => 25,
2895 '#maxlength' => 25,
2896 '#default_value' => $applicant_contact_first_name,
2897 '#required' => FALSE,
2898 ];
2899
2900 // Typo is in SugarCRM, we're using same field names for simplicity.
2901 // Field on SugarCRM of Type: varchar(255).
2902 $default_value = (!empty($application->applicant_surname)) ?
2903 trim(decode_entities(check_plain($application->applicant_surname))) :
2904 NULL;
2905 $form['tab_people']['applicant_details']['applicant_name']['applicant_surname'] =
2906 [
2907 '#type' => 'textfield',
2908 '#title' => t('Applicant Surname'),
2909 '#size' => 100,
2910 '#maxlength' => 100,
2911 '#default_value' => $applicant_contact_last_name,
2912 '#description' => t('“The applicant” means the person seeking the planning permission, not an agent acting on his or her behalf.'),
2913 '#required' => FALSE,
2914 ];
2915
2916 // Field on SugarCRM of Type: varchar(255).
2917 $form['tab_people']['applicant_details']['applicant_address']['applicant_address_line_1'] =
2918 [
2919 '#type' => 'textfield',
2920 '#title' => t('Applicant Address'),
2921 '#size' => 255,
2922 '#maxlength' => 255,
2923 '#default_value' => $applicant_contact_street,
2924 '#description' => t('Enter the first line of the applicants address'),
2925 '#required' => FALSE,
2926 ];
2927
2928 // Field on SugarCRM of Type: varchar(255).
2929 $form['tab_people']['applicant_details']['applicant_address']['applicant_address_line_2'] =
2930 [
2931 '#type' => 'textfield',
2932 '#title' => t('Applicant Address Line 2'),
2933 '#size' => 255,
2934 '#maxlength' => 255,
2935 '#default_value' => $applicant_contact_city,
2936 '#description' => t('Enter the second line of the applicants address'),
2937 '#required' => FALSE,
2938 ];
2939
2940 // Field on SugarCRM of Type: varchar(255).
2941 $form['tab_people']['applicant_details']['applicant_address']['applicant_address_line_3'] =
2942 [
2943 '#type' => 'textfield',
2944 '#title' => t('Applicant Address Line 3'),
2945 '#size' => 255,
2946 '#maxlength' => 255,
2947 '#default_value' => $applicant_contact_state,
2948 '#description' => t('Enter the third line of the applicants address'),
2949 '#required' => FALSE,
2950 ];
2951
2952 // Field on SugarCRM of Type: varchar(255).
2953 $form['tab_people']['applicant_details']['applicant_address']['applicant_address_line_4'] =
2954 [
2955 '#type' => 'textfield',
2956 '#title' => t('Eircode'),
2957 '#size' => 255,
2958 '#maxlength' => 255,
2959 '#default_value' => $applicant_contact_postalcode,
2960 '#description' => t('Enter the Eircode of the applicants address'),
2961 '#required' => FALSE,
2962 // Temporary removal
2963 // '#attributes' => [//.
2964 // 'pattern' => ("(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ ]?[0-9AC-FHKNPRTV-Y]{4}$"), //.
2965 // ], //.
2966 ];
2967
2968 // Field on SugarCRM of Type: varchar(100).
2969 $form['tab_people']['applicant_details']['applicant_contact']['applicant_email'] =
2970 [
2971 '#type' => 'textfield',
2972 '#title' => t('Applicant email'),
2973 '#size' => 100,
2974 '#maxlength' => 100,
2975 '#default_value' => $applicant_contact_email,
2976 '#required' => FALSE,
2977 ];
2978 if ($role == "applicant") {
2979 $form['tab_people']['applicant_details']['applicant_contact']['applicant_email']['#disabled'] = TRUE;
2980 $form['tab_people']['applicant_details']['applicant_contact']['applicant_email']['#attributes'] = [
2981 'disabled' => ['disabled'],
2982 ];
2983 }
2984
2985 // Field on SugarCRM of Type: varchar(25).
2986 $form['tab_people']['applicant_details']['applicant_contact']['applicant_phone_number'] =
2987 [
2988 '#type' => 'textfield',
2989 '#title' => t('Applicant Phone Number'),
2990 '#size' => 25,
2991 '#maxlength' => 25,
2992 '#default_value' => $applicant_contact_phone,
2993 '#required' => FALSE,
2994 ];
2995
2996 // Field on SugarCRM of Type: varchar(25).
2997 $form['tab_people']['applicant_details']['applicant_contact']['applicant_mobile'] =
2998 [
2999 '#type' => 'textfield',
3000 '#title' => t('Applicant mobile'),
3001 '#size' => 25,
3002 '#maxlength' => 25,
3003 '#default_value' => $applicant_contact_mobile,
3004 '#required' => FALSE,
3005 ];
3006
3007 $default_value = (
3008 !empty($application) &&
3009 !empty($application->company_name)
3010 ) ?
3011 'Yes' :
3012 'No';
3013 $form['tab_people']['company_details']['is_an_company_involved'] = [
3014 '#type' => 'radios',
3015 '#title' => t('Is the applicant a company?'),
3016 '#options' => $yes_or_no,
3017 '#default_value' => $default_value,
3018 '#weight' => 5,
3019 '#required' => FALSE,
3020 ];
3021
3022 // Field on SugarCRM of Type: varchar(50).
3023 $default_value = (!empty($application->company_name)) ?
3024 trim(decode_entities(check_plain($application->company_name))) :
3025 NULL;
3026 $form['tab_people']['company_details']['company_name'] = [
3027 '#type' => 'textfield',
3028 '#title' => t('Company Name'),
3029 '#size' => 50,
3030 '#maxlength' => 50,
3031 '#default_value' => $default_value,
3032 '#required' => FALSE,
3033 '#description' => t('Enter the company name'),
3034 '#weight' => 10,
3035 '#states' => [
3036 'invisible' => [
3037 [
3038 [
3039 'input[name="is_an_company_involved"]' => ['value' => 'No'],
3040 ],
3041 'or',
3042 [
3043 'input[name="is_an_company_involved"]' => ['value' => ''],
3044 ],
3045 ],
3046 ],
3047 ],
3048 ];
3049
3050 // Field on SugarCRM of Type: varchar(255).
3051 $default_value = (!empty($application->company_address_line_1)) ?
3052 trim(decode_entities(check_plain($application->company_address_line_1))) :
3053 NULL;
3054 $form['tab_people']['company_details']['company_address']['company_address_line_1'] =
3055 [
3056 '#type' => 'textfield',
3057 '#title' => t('Company Address'),
3058 '#size' => 255,
3059 '#maxlength' => 255,
3060 '#default_value' => $default_value,
3061 '#description' => t('Enter the first line of the company address'),
3062 '#required' => FALSE,
3063 ];
3064
3065 // Field on SugarCRM of Type: varchar(255).
3066 $default_value = (!empty($application->company_address_line_2)) ?
3067 trim(decode_entities(check_plain($application->company_address_line_2))) :
3068 NULL;
3069 $form['tab_people']['company_details']['company_address']['company_address_line_2'] =
3070 [
3071 '#type' => 'textfield',
3072 '#title' => t('Company Address line 2'),
3073 '#size' => 255,
3074 '#maxlength' => 255,
3075 '#default_value' => $default_value,
3076 '#description' => t('Enter the second line of the company address'),
3077 '#required' => FALSE,
3078 ];
3079
3080 // Field on SugarCRM of Type: varchar(255).
3081 $default_value = (!empty($application->company_address_line_3)) ?
3082 trim(decode_entities(check_plain($application->company_address_line_3))) :
3083 NULL;
3084 $form['tab_people']['company_details']['company_address']['company_address_line_3'] =
3085 [
3086 '#type' => 'textfield',
3087 '#title' => t('Company Address line 3'),
3088 '#size' => 255,
3089 '#maxlength' => 255,
3090 '#default_value' => $default_value,
3091 '#description' => t('Enter the third line of the company address'),
3092 '#required' => FALSE,
3093 ];
3094
3095 // Field on SugarCRM of Type: varchar(255).
3096 $default_value = (!empty($application->company_address_line_4)) ?
3097 trim(decode_entities(check_plain($application->company_address_line_4))) :
3098 NULL;
3099 $form['tab_people']['company_details']['company_address']['company_address_line_4'] =
3100 [
3101 '#type' => 'textfield',
3102 '#title' => t('Company Eircode'),
3103 '#size' => 255,
3104 '#maxlength' => 255,
3105 '#default_value' => $default_value,
3106 '#description' => t('Enter the Eircode of the company address'),
3107 '#required' => FALSE,
3108 // Temporary removal
3109 // '#attributes' => [//.
3110 // 'pattern' => ("(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ ]?[0-9AC-FHKNPRTV-Y]{4}$"), //.
3111 // ], //.
3112 ];
3113
3114 // Field on SugarCRM of Type: varchar(25).
3115 $default_value = (!empty($application->company_director_name)) ?
3116 trim(decode_entities(check_plain($application->company_director_name))) :
3117 NULL;
3118 $form['tab_people']['company_details']['company_director_name'] = [
3119 '#type' => 'textfield',
3120 '#title' => t('Company Director Name'),
3121 '#default_value' => $default_value,
3122 '#required' => FALSE,
3123 '#weight' => 12,
3124 '#states' => [
3125 'invisible' => [
3126 [
3127 [
3128 'input[name="is_an_company_involved"]' => ['value' => 'No'],
3129 ],
3130 'or',
3131 [
3132 'input[name="is_an_company_involved"]' => ['value' => ''],
3133 ],
3134 ],
3135 ],
3136 '#description' => t('Enter the company director names'),
3137 ],
3138 ];
3139
3140 // Field on SugarCRM of Type: varchar(25).
3141 $default_value = (!empty($application->company_reg_number)) ?
3142 trim(decode_entities(check_plain($application->company_reg_number))) :
3143 NULL;
3144 $form['tab_people']['company_details']['company_reg_number'] = [
3145 '#type' => 'textfield',
3146 '#title' => t('Company Reg. Number'),
3147 '#size' => 25,
3148 '#maxlength' => 25,
3149 '#default_value' => $default_value,
3150 '#required' => FALSE,
3151 '#weight' => 14,
3152 '#states' => [
3153 'invisible' => [
3154 [
3155 [
3156 'input[name="is_an_company_involved"]' => ['value' => 'No'],
3157 ],
3158 'or',
3159 [
3160 'input[name="is_an_company_involved"]' => ['value' => ''],
3161 ],
3162 ],
3163 ],
3164 ],
3165 '#description' => t('Enter the company registration number'),
3166 ];
3167
3168 // Logic for auto-filling agent details.
3169 $agent_contact_first_name = !empty($application->agent_forename) ?
3170 trim(decode_entities(check_plain($application->agent_forename))) :
3171 NULL;
3172 $agent_contact_last_name = !empty($application->agent_surname) ?
3173 trim(decode_entities(check_plain($application->agent_surname))) :
3174 NULL;
3175 $agent_contact_street = !empty($application->agent_address_line_1) ?
3176 trim(decode_entities(check_plain($application->agent_address_line_1))) :
3177 NULL;
3178 $agent_contact_city = !empty($application->agent_address_line_2) ?
3179 trim(decode_entities(check_plain($application->agent_address_line_2))) :
3180 NULL;
3181 $agent_contact_state = !empty($application->agent_address_line_3) ?
3182 trim(decode_entities(check_plain($application->agent_address_line_3))) :
3183 NULL;
3184 $agent_contact_postalcode = !empty($application->agent_address_line_4) ?
3185 trim(decode_entities(check_plain($application->agent_address_line_4))) :
3186 NULL;
3187 $agent_contact_email = !empty($application->agent_email) ?
3188 trim(decode_entities(check_plain($application->agent_email))) :
3189 NULL;
3190 $agent_contact_phone = !empty($application->agent_phone_number) ?
3191 trim(decode_entities(check_plain($application->agent_phone_number))) :
3192 NULL;
3193 $agent_contact_country = NULL;
3194
3195 $default_value = 'No';
3196 if ($role == "agent") {
3197 $default_value = 'Yes';
3198 if (empty($agent_contact_first_name)) {
3199 $agent_contact_first_name = $contact->first_name;
3200 }
3201 if (empty($agent_contact_last_name)) {
3202 $agent_contact_last_name = $contact->last_name;
3203 }
3204 if (empty($agent_contact_street)) {
3205 $agent_contact_street = $contact->primary_address_street;
3206 }
3207 if (empty($agent_contact_city)) {
3208 $agent_contact_city = $contact->primary_address_city;
3209 }
3210 if (empty($agent_contact_state)) {
3211 $agent_contact_state = $contact->primary_address_state;
3212 }
3213 if (empty($agent_contact_postalcode)) {
3214 $agent_contact_postalcode = $contact->primary_address_postalcode;
3215 }
3216 if (empty($agent_contact_country)) {
3217 $agent_contact_country = $contact->primary_address_country;
3218 }
3219 if (empty($agent_contact_email)) {
3220 $agent_contact_email = $contact->email1;
3221 }
3222 if (empty($agent_contact_phone)) {
3223 $agent_contact_phone = $contact->phone_work;
3224 }
3225 }
3226
3227 $form['tab_people']['agent_details']['is_an_agent_involved'] = [
3228 '#type' => 'hidden',
3229 '#default_value' => $default_value,
3230 '#weight' => 5,
3231 ];
3232
3233 // Field on SugarCRM of Type: varchar(25).
3234 $form['tab_people']['agent_details']['agent_name']['agent_forename'] = [
3235 '#type' => 'textfield',
3236 '#title' => t('Agent Forename'),
3237 '#size' => 25,
3238 '#maxlength' => 25,
3239 '#default_value' => $agent_contact_first_name,
3240 '#description' => t('Enter the agents forename'),
3241 '#required' => FALSE,
3242 ];
3243
3244 // Typo is in SugarCRM, we're using same spellings for simplicity.
3245 // Field on SugarCRM of Type: varchar(40).
3246 $form['tab_people']['agent_details']['agent_name']['agent_surname'] = [
3247 '#type' => 'textfield',
3248 '#title' => t('Agent Surname'),
3249 '#size' => 40,
3250 '#maxlength' => 40,
3251 '#default_value' => $agent_contact_last_name,
3252 '#description' => t('Enter the agents surname'),
3253 '#required' => FALSE,
3254 ];
3255
3256 // Field on SugarCRM of Type: varchar(255).
3257 $form['tab_people']['agent_details']['agent_address']['agent_address_line_1'] =
3258 [
3259 '#type' => 'textfield',
3260 '#title' => t('Agent Address'),
3261 '#size' => 255,
3262 '#maxlength' => 255,
3263 '#default_value' => $agent_contact_street,
3264 '#description' => t('Enter the first line of the agents address'),
3265 '#required' => FALSE,
3266 ];
3267
3268 // Field on SugarCRM of Type: varchar(255).
3269 $form['tab_people']['agent_details']['agent_address']['agent_address_line_2'] =
3270 [
3271 '#type' => 'textfield',
3272 '#title' => t('Agent Address Line 2'),
3273 '#size' => 255,
3274 '#maxlength' => 255,
3275 '#default_value' => $agent_contact_city,
3276 '#description' => t('Enter the second line of the agents address'),
3277 '#required' => FALSE,
3278 ];
3279
3280 // Field on SugarCRM of Type: varchar(255).
3281 $form['tab_people']['agent_details']['agent_address']['agent_address_line_3'] =
3282 [
3283 '#type' => 'textfield',
3284 '#title' => t('Agent Address Line 3'),
3285 '#size' => 255,
3286 '#maxlength' => 255,
3287 '#default_value' => $agent_contact_state,
3288 '#description' => t('Enter the third line of the agents address'),
3289 '#required' => FALSE,
3290 ];
3291
3292 // Field on SugarCRM of Type: varchar(255).
3293 $form['tab_people']['agent_details']['agent_address']['agent_address_line_4'] =
3294 [
3295 '#type' => 'textfield',
3296 '#title' => t('Eircode'),
3297 '#size' => 255,
3298 '#maxlength' => 255,
3299 '#default_value' => $agent_contact_postalcode,
3300 '#description' => t('Enter the Eircode of the agents address'),
3301 '#required' => FALSE,
3302 // Temporary removal
3303 // '#attributes' => [//.
3304 // 'pattern' => ("(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ ]?[0-9AC-FHKNPRTV-Y]{4}$"), //.
3305 // ], //.
3306 ];
3307
3308 // Spelling error found in Data Dictionary, using for simplicity.
3309 // Field on SugarCRM of Type: varchar(100).
3310 $form['tab_people']['agent_details']['agent_contact']['agent_email'] = [
3311 '#type' => 'textfield',
3312 '#title' => t('Agent email address'),
3313 '#size' => 100,
3314 '#maxlength' => 100,
3315 '#default_value' => $agent_contact_email,
3316 '#description' => t('Enter the agents email address'),
3317 '#required' => FALSE,
3318 ];
3319 if ($role == "agent") {
3320 $form['tab_people']['agent_details']['agent_contact']['agent_email']['#attributes'] =
3321 [
3322 'disabled' => ['TRUE'],
3323 ];
3324 $form['tab_people']['agent_details']['agent_contact']['agent_email']['#disabled'] = TRUE;
3325 }
3326
3327 // Field on SugarCRM of Type: varchar(100).
3328 $form['tab_people']['agent_details']['agent_contact']['agent_phone_number'] = [
3329 '#type' => 'textfield',
3330 '#title' => t('Agent Contact number'),
3331 '#size' => 100,
3332 '#maxlength' => 100,
3333 '#default_value' => $agent_contact_phone,
3334 '#description' => t('Enter the agents contact number'),
3335 '#required' => FALSE,
3336 ];
3337
3338 // Field on SugarCRM of Type: ENUM.
3339 $contact_email = ($role == "agent") ?
3340 $agent_contact_email :
3341 $applicant_contact_email;
3342 $default_value = (!empty($application->correspondence_to_agent) &&
3343 trim(
3344 decode_entities(check_plain($application->correspondence_to_agent))
3345 ) == "Yes") ?
3346 1 :
3347 0;
3348 $form['tab_people']['agent_details']['correspondence_to_agent'] = [
3349 '#type' => 'checkbox',
3350 '#title' => t('Correspondence'),
3351 '#default_value' => $default_value,
3352 '#weight' => 16,
3353 '#description' => t(
3354 'I understand/confirm that all email correspondence related to this application will be sent to @email',
3355 [
3356 '@email' => $contact_email,
3357 ]
3358 ),
3359 '#required' => FALSE,
3360 ];
3361
3362 if (
3363 trim(
3364 decode_entities(check_plain($application->correspondence_to_agent))
3365 ) == "Yes"
3366 ) {
3367 $form['tab_people']['agent_details']['correspondence_to_agent']['#attributes'] =
3368 [
3369 'checked' => ['TRUE'],
3370 ];
3371 }
3372
3373 // Field on SugarCRM of Type: varchar(255).
3374 $default_value = (!empty($application->person_responsible_for_drawings)) ?
3375 trim(decode_entities(
3376 check_plain($application->person_responsible_for_drawings)
3377 )) :
3378 NULL;
3379 $form['tab_people']['drawing_details']['person_responsible_for_drawings'] =
3380 [
3381 '#type' => 'textfield',
3382 '#title' => t('Person Responsible for Drawings and Plans'),
3383 '#size' => 35,
3384 '#maxlength' => 35,
3385 '#default_value' => $default_value,
3386 '#required' => FALSE,
3387 ];
3388
3389 // Field on SugarCRM of Type: varchar(100).
3390 $default_value = (!empty($application->company)) ?
3391 trim(decode_entities(check_plain($application->company))) :
3392 NULL;
3393 $form['tab_people']['drawing_details']['company'] = [
3394 '#type' => 'textfield',
3395 '#title' => t('Firm/Company'),
3396 '#size' => 100,
3397 '#maxlength' => 100,
3398 '#default_value' => $default_value,
3399 '#description' => t('Where the plans have been drawn up by a firm/company the name of the person primarily responsible for the preparation of the drawings and plans, on behalf of that firm/company, should be given.'),
3400 '#required' => FALSE,
3401 ];
3402
3403 // Field on SugarCRM of Type: varchar(255). (Assumption)
3404 $default_value = (!empty($application->legal_interest_in_land)) ?
3405 trim(decode_entities(check_plain($application->legal_interest_in_land))) :
3406 NULL;
3407 $form['tab_people']['land_details']['legal_interest_in_land'] = [
3408 '#type' => 'select',
3409 '#title' => t('What is the Legal Interest in the Land or Structure'),
3410 '#options' => $legal_interest_in_land,
3411 '#default_value' => $default_value,
3412 '#description' => t('Enter the legal interest in the land'),
3413 '#required' => FALSE,
3414 ];
3415
3416 // Field on SugarCRM of Type: varchar(500).
3417 $default_value = (!empty($application->explain_interest)) ?
3418 trim(decode_entities(check_plain($application->explain_interest))) :
3419 NULL;
3420 $form['tab_people']['land_details']['explain_interest'] = [
3421 '#type' => 'textarea',
3422 '#title' => t('Please expand further on your legal interest in the land'),
3423 '#maxlength' => 500,
3424 '#maxlength_js' => TRUE,
3425 '#default_value' => $default_value,
3426 '#description' => t('Enter an explanation for your interest'),
3427 '#required' => FALSE,
3428 '#states' => [
3429 'visible' => [
3430 [
3431 [
3432 'select[name="legal_interest_in_land"]' => ['value' => 'Other'],
3433 ],
3434 ],
3435 ],
3436 ],
3437 ];
3438
3439 // Field on SugarCRM of Type: varchar(25).
3440 $default_value = (!empty($application->land_owner_forename)) ?
3441 trim(decode_entities(check_plain($application->land_owner_forename))) :
3442 NULL;
3443 $form['tab_people']['land_details']['land_owner_name']['land_owner_forename'] =
3444 [
3445 '#type' => 'textfield',
3446 '#title' => t('Land Owner Forename'),
3447 '#size' => 25,
3448 '#maxlength' => 25,
3449 '#description' => t('Enter the land owners forename'),
3450 '#default_value' => $default_value,
3451 ];
3452
3453 // Typo in SugarCRM, we're using the same field names for simplicity.
3454 // Field on SugarCRM of Type: varchar(40).
3455 $default_value = (!empty($application->land_owner_surname)) ?
3456 trim(decode_entities(check_plain($application->land_owner_surname))) :
3457 NULL;
3458 $form['tab_people']['land_details']['land_owner_name']['land_owner_surname'] =
3459 [
3460 '#type' => 'textfield',
3461 '#title' => t('Land Owner Surname'),
3462 '#size' => 40,
3463 '#maxlength' => 40,
3464 '#description' => t('Enter the land owners surname'),
3465 '#default_value' => $default_value,
3466 ];
3467
3468 // Field on SugarCRM of Type: varchar(255). Assumption.
3469 $default_value = (!empty($application->land_owner_address_line_1)) ?
3470 trim(decode_entities(check_plain($application->land_owner_address_line_1))) :
3471 NULL;
3472 $form['tab_people']['land_details']['land_owner_address']['land_owner_address_line_1'] =
3473 [
3474 '#type' => 'textfield',
3475 '#title' => t('Land Owner Address'),
3476 '#size' => 255,
3477 '#maxlength' => 255,
3478 '#description' => t('Enter the first line of the land owners address'),
3479 '#default_value' => $default_value,
3480 ];
3481
3482 // Field on SugarCRM of Type: varchar(255). Assumption.
3483 $default_value = (!empty($application->land_owner_address_line_2)) ?
3484 trim(decode_entities(check_plain($application->land_owner_address_line_2))) :
3485 NULL;
3486 $form['tab_people']['land_details']['land_owner_address']['land_owner_address_line_2'] =
3487 [
3488 '#type' => 'textfield',
3489 '#title' => t('Land Owner Address Line 2'),
3490 '#size' => 255,
3491 '#maxlength' => 255,
3492 '#description' => t('Enter the second line of the land owners address'),
3493 '#default_value' => $default_value,
3494 ];
3495
3496 // Field on SugarCRM of Type: varchar(255). Assumption.
3497 $default_value = (!empty($application->land_owner_address_line_3)) ?
3498 trim(decode_entities(check_plain($application->land_owner_address_line_3))) :
3499 NULL;
3500 $form['tab_people']['land_details']['land_owner_address']['land_owner_address_line_3'] =
3501 [
3502 '#type' => 'textfield',
3503 '#title' => t('Land Owner Address Line 3'),
3504 '#size' => 255,
3505 '#maxlength' => 255,
3506 '#description' => t('Enter the third line of the land owners address'),
3507 '#default_value' => $default_value,
3508 ];
3509
3510 // Field on SugarCRM of Type: varchar(255). Assumption.
3511 $default_value = (!empty($application->land_owner_address_line_4)) ?
3512 trim(decode_entities(check_plain($application->land_owner_address_line_4))) :
3513 NULL;
3514 $form['tab_people']['land_details']['land_owner_address']['land_owner_address_line_4'] =
3515 [
3516 '#type' => 'textfield',
3517 '#title' => t('Land Owner Eircode'),
3518 '#size' => 255,
3519 '#maxlength' => 255,
3520 '#description' => t('Enter the Eircode of the land owners address'),
3521 '#default_value' => $default_value,
3522 // Temporary removal
3523 // '#attributes' => [//.
3524 // 'pattern' => ("(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ ]?[0-9AC-FHKNPRTV-Y]{4}$"), //.
3525 // ], //.
3526 ];
3527
3528 // Payment Tab.
3529 $form['tab_payment']['fee_payment'] = [
3530 '#type' => 'fieldset',
3531 '#title' => t('Payment'),
3532 '#weight' => 10,
3533 '#parent' => 'tab_payment',
3534 ];
3535
3536 $form['tab_payment']['fee_payment']['payment_exempted'] = [
3537 '#type' => 'checkbox',
3538 '#title' => t('This application is exempt from a payment fee'),
3539 '#description' => t('Is this application exempt from payment'),
3540 '#weight' => 8,
3541 '#states' => [
3542 'visible' => [
3543 [
3544 [
3545 'input[name="eft"]' => ['checked' => FALSE],
3546 ],
3547 ],
3548 ],
3549 ],
3550 ];
3551
3552 $minimum_fee = 34;
3553 $maximum_fee = 125000;
3554 if (!empty($application->payment_exempted)) {
3555 $form['tab_payment']['fee_payment']['payment_exempted']['#attributes'] =
3556 [
3557 'checked' => ['checked'],
3558 ];
3559 $disableEft = TRUE;
3560 $minimum_fee = 0;
3561 }
3562
3563 $form['tab_payment']['fee_payment']['eft'] = [
3564 '#type' => 'checkbox',
3565 '#title' => t('This application is being paid by electronic fund transfer'),
3566 '#description' => t('Is this application apid by electronic fund transfer'),
3567 '#weight' => 10,
3568 '#states' => [
3569 'visible' => [
3570 [
3571 [
3572 'input[name="payment_exempted"]' => ['checked' => FALSE],
3573 ],
3574 ],
3575 ],
3576 ],
3577 ];
3578
3579 if ($disableEft) {
3580 $form['tab_payment']['fee_payment']['eft']['#attributes'] =
3581 [
3582 'disabled' => ['disabled'],
3583 ];
3584 }
3585
3586 if (!empty($application->eft)) {
3587 $form['tab_payment']['fee_payment']['eft']['#attributes'] =
3588 [
3589 'checked' => ['checked'],
3590 ];
3591 $form['tab_payment']['fee_payment']['payment_exempted']['#attributes'] =
3592 [
3593 'disabled' => ['disabled'],
3594 ];
3595 $maximum_fee = 1000000;
3596 }
3597
3598 $default_value = (!empty($application->eft_reference)) ?
3599 trim(decode_entities(check_plain($application->eft_reference))) :
3600 NULL;
3601 $form['tab_payment']['fee_payment']['eft_reference'] = [
3602 '#type' => 'textfield',
3603 '#title' => t('Please provide the EFT reference'),
3604 '#default_value' => $default_value,
3605 '#description' => t('Please provide the EFT reference'),
3606 '#weight' => 12,
3607 '#states' => [
3608 'visible' => [
3609 [
3610 [
3611 'input[name="eft"]' => ['checked' => TRUE],
3612 ],
3613 ],
3614 ],
3615 ],
3616 ];
3617
3618 // Field on SugarCRM of Type: decimal.
3619 $payment_url = l(
3620 t('fee payable'),
3621 '/fees',
3622 [
3623 'attributes' => ['_target' => 'blank'],
3624 ]);
3625 $default_value = (!empty($application->fee_payable)) ?
3626 number_format(
3627 floatval(trim(decode_entities(check_plain($application->fee_payable)))),
3628 2, '.', '') :
3629 NULL;
3630 $form['tab_payment']['fee_payment']['fee_payable'] = [
3631 '#type' => 'numberfield',
3632 '#step' => 0.01,
3633 '#min' => $minimum_fee,
3634 '#max' => $maximum_fee,
3635 '#element_validate' => ['_validate_fee_payable'],
3636 '#title' => t('Fee Payable'),
3637 '#size' => 9,
3638 '#maxlength' => 9,
3639 '#default_value' => $default_value,
3640 '#weight' => 14,
3641 '#description' => t('Enter the !link', ['!link' => $payment_url]),
3642 '#required' => FALSE,
3643 '#states' => [
3644 'invisible' => [
3645 [
3646 [
3647 'input[name="payment_exempted"]' => ['checked' => TRUE],
3648 ],
3649 ],
3650 ],
3651 ],
3652 ];
3653
3654 // Field on SugarCRM of Type: varchar(500).
3655 $default_value = (!empty($application->fee_payable_calculation_basis)) ?
3656 trim(decode_entities(check_plain($application->fee_payable_calculation_basis))) :
3657 NULL;
3658 $form['tab_payment']['fee_payment']['fee_payable_calculation_basis'] = [
3659 '#type' => 'textarea',
3660 '#title' => t('Basis of calculation'),
3661 '#maxlength' => 500,
3662 '#maxlength_js' => TRUE,
3663 '#default_value' => $default_value,
3664 '#weight' => 16,
3665 '#description' => t('Enter the basis for the fee calculation'),
3666 '#required' => FALSE,
3667 '#states' => [
3668 'invisible' => [
3669 [
3670 [
3671 'input[name="payment_exempted"]' => [
3672 'checked' => TRUE,
3673 ],
3674 ],
3675 ],
3676 ],
3677 ],
3678 ];
3679
3680 $form['actions']['submit_bottom'] = [
3681 '#type' => 'submit',
3682 '#value' => t('Save as draft'),
3683 '#weight' => 0,
3684 ];
3685
3686 $form['actions']['upload_bottom'] = [
3687 '#type' => 'submit',
3688 '#value' => t('Upload'),
3689 '#weight' => 5,
3690 '#attributes' => [
3691 'style' => ['display:none'],
3692 ],
3693 ];
3694
3695 if (!empty($application)) {
3696 $form['actions']['cancel_bottom'] = [
3697 '#type' => 'submit',
3698 '#value' => t('Discard changes'),
3699 '#validate' => ['lop_applications_cancel_validate'],
3700 '#submit' => ['lop_applications_cancel_submit'],
3701 '#weight' => 10,
3702 ];
3703 }
3704
3705 $form['actions']['faqs_bottom'] = [
3706 '#type' => 'item',
3707 '#markup' => t(
3708 'If you have any questions, please see our !url page',
3709 [
3710 '!url' => $faq_url,
3711 ]
3712 ),
3713 '#weight' => 12,
3714 '#prefix' => '<div style="float: right;">',
3715 '#suffix' => '</div>',
3716 ];
3717
3718 $form['tab_payment']['fee_payment']['pay_now_button'] = [
3719 '#type' => 'submit',
3720 '#value' => t('Submit application and pay now'),
3721 '#validate' => ['lop_applications_form_application_payment_validate'],
3722 '#submit' => ['lop_applications_form_application_payment_submit'],
3723 '#weight' => 18,
3724 ];
3725
3726 return $form;
3727}
3728