TEMPLATE Component [Energy]

Note

Some functions are the same as for Livelihoods Module

Function TEMPLATEREPORT_energy

TEMPLATEREPORT_energy(year, formid, id, filename, pkey)

The function schedules the task to create pdf

Arguments
  • year (string) – the current year

  • formid (string) – the id of template

  • id (string) – data id of beneficiary survey

  • filename (string) – name of the file

  • pkey (Object) – the list of key properties and their values

Returns

keyinputs – list of key parameters.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function TEMPLATEREPORT_energy(Year, formid, id, filename, pkey) {
    if (pkey != null) { key = pkey };

    if (Year < 2017 || key["TEMPLATE" + id] == "OK") { return 3; }
    var mainfolderid = createFolder(0, key["MAINFOLDER"]);
    YearFolder = createFolder(mainfolderid, "ALLFILES" + Year);
    TEMPLATEFOLDER = createFolder(YearFolder, "TEMPLATE" + Year);
    /*extract template on TEMPLATE_REPORT sheet*/
    TEMPLATEOUT(formid, id);
    SpreadsheetApp.flush();
    /*gets the id of the old file and deletes it*/
    var old = getFile(TEMPLATEFOLDER, filename);
    if (old != null) {
        var oldfile = DriveApp.getFileById(old);
        oldfile.setTrashed(true);
    }
    keyinputs["TEMPLATE" + id] = "OK"; key["TEMPLATE" + id] = "OK";

    /*Saving as PDF at rootfolder*/
    var templatereport = ss.getSheetByName("TEMPLATE_REPORT");
    var tpid = templatereport.getSheetId();

    var url = ss.getUrl();
    url = url.replace(/edit$/, '');
    var url_ext = url + 'export?exportFormat=pdf&gid=' + tpid;
    var token = ScriptApp.getOAuthToken();
    var params = { method: "get", headers: { 'Authorization': 'Bearer ' + token } };
    try { var blob = UrlFetchApp.fetch(url_ext, params).getBlob(); } catch (e) { var error = e; Logger.log(error.message); }
    var idSS = DriveApp.createFile(blob).setName(filename).getId();
    var fileSS = DriveApp.getFileById(idSS);

   /*move from rootfolder to the template folder*/
    dest_folder = DriveApp.getFolderById(TEMPLATEFOLDER);
    dest_folder.addFile(fileSS).getId();

   /*registering pdf file link to keys*/
    var newid = createFile(TEMPLATEFOLDER, filename);
    var newurl = DriveApp.getFileById(newid).getUrl();
    var tr = 'TEMPR' + id;
    keyinputs[tr] = newurl; key[tr] = newurl;


    /*Delete temporary file*/
    DriveApp.getRootFolder().removeFile(fileSS);
    /*Function checks the updates on customisation [UPDATE CHECK]*/
    updateOnCustomisation(id);

    /*Generating email*/
    if (key["EMAIL"] == "ON") {
        generateEmailNotice(id,
            "Monitoring Template Created / Updated.",
            "Monitroing Template has been created or updated."
            , newid,
            "Thank you very much for submitting the Energy Monitoring Template." +
            "<br><br>We confirm the receipt and please find below the link to updated Monitoring Template for your kind attention." +
            "<br><br>Please kindly let us know in case you find any information missing, or parts not reflecting correctly what you submitted." +
            "<br><br>We are in process of developing customized mobile survey tools for your operation based on the information provided in the Template, as well as a user training on the tools." +
            "We shall come back to you as soon as they are ready and accesible." +
            "<br><br>Thank you and best regards");
    }

    updateLog("Monitoring Template updated : " + filename);

    if (pkey != null) { return (keyinputs); }
    return 1;
}

Function TEMPLATEOUT_energy

TEMPLATEOUT_energy(formid, id)

The function extracts template on TEMPLATE_REPORT sheet

Arguments
  • formid (string) – the id of template

  • id (string) – data id of beneficiary survey

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
function TEMPLATEOUT_energy(formid, id) {
    var CL = 0;
    var HL = 0;
    var ST = 0;
    var PL = 0;

    var templatereport = ss.getSheetByName("TEMPLATE_REPORT");

    var jsonData = connectKobotoolbox(key["APITOKEN"], formid, id);
    Logger.log(jsonData);

    templatereport.clear();
    x = xx; y = yy;

    //FORMAT
    templatereport.setColumnWidth(1, 50);
    //OTHERS/FORMAT
    {
        for (i = 2; i < 10; i++) {
            templatereport.setColumnWidth(i, 200);
            //templatereport.getRange(y,i).setHorizontalAlignment("right");
        }

        for (i = 2; i < 10; i++) {
            for (ii = 1; ii < 300; ii++) {
                templatereport.getRange(ii, i).setVerticalAlignment("middle");
                templatereport.getRange(ii, i).setFontFamily("Oxygen");
                templatereport.getRange(ii, i).setFontSize(12);
                if (i == 2) { templatereport.setRowHeight(ii, 30); }
            }
        }
    }

    //HEADER
    {
        //TITLE
        {
            y++; y++;
            templatereport.getRange(y, x).setValue("ENERGY MONITORING TEMPLATE");
            templatereport.getRange(y, x).setFontColor(C1);
            templatereport.getRange(y, x).setFontSize(22);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");
            y++;
        }

        //COUNTRY NAME
        {
            templatereport.getRange(y, x, 2, 3).merge();
            templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/Country'].toUpperCase() + "  " + jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Year']);
            templatereport.getRange(y, x).setFontSize(32);
            templatereport.getRange(y, x).setFontWeight("bold");
            y = y + 1;
        }

        //DATE
        {
            templatereport.getRange(y - 1, x + 4).setValue("Last Update:")
            templatereport.getRange(y - 1, x + 4).setHorizontalAlignment("right");
            templatereport.getRange(y - 1, x + 4).setFontWeight("bold");
            templatereport.getRange(y, x + 4).setValue(jsonData['end'].slice(0, 10));
            templatereport.getRange(y, x + 4).setHorizontalAlignment("right");
            templatereport.getRange(y, x + 4).setFontSize(20);

            templatereport.getRange(y - 1, x + 3).setValue("Submition Date:")
            templatereport.getRange(y - 1, x + 3).setHorizontalAlignment("right");
            templatereport.getRange(y - 1, x + 3).setFontWeight("bold");
            templatereport.getRange(y, x + 3).setValue(jsonData['today']);
            templatereport.getRange(y, x + 3).setHorizontalAlignment("right");
            templatereport.getRange(y, x + 3).setFontSize(20);

            y++; y++;
        }

    }

    //SECTION 1: CONTACT INFORMATION
    {
        templatereport.getRange(y, x).setValue("1. ENERGY FOCAL POINT");
        templatereport.getRange(y, x, 1, 6).setBackground(C1);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x).setFontSize(20);
        templatereport.getRange(y, x).setFontFamily("Oxygen");
        templatereport.getRange(y, x).setFontWeight("bold");

        y++;

        templatereport.getRange(y, x, 1, 6).setBackground(C2);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

        templatereport.getRange(y, x).setValue("Country".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Duty Station".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Name".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Title".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Email".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Alternative Email".toUpperCase()); x++;

        y++; x = xx;

        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/Country']); templatereport.getRange(y, x).setFontWeight("bold"); x++;
        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/D_Station']); x++;
        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/F_Point']); x++;
        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/F_Title']); x++;
        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/Email_FP']); x++;
        templatereport.getRange(y, x).setValue(jsonData['CONTACT_INFORMATION/Email_FP2']); x++;
    }

    //SECTION 2: PROBLEM STATEMENT
    {
        y++; y++; y++; x = xx;
        templatereport.getRange(y, x).setValue("2. BACKGROUND INFORMATION");
        templatereport.getRange(y, x, 1, 6).setBackground(C1);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x).setFontSize(20);
        templatereport.getRange(y, x).setFontFamily("Oxygen");
        templatereport.getRange(y, x).setFontWeight("bold");

        //SECTION 2.1 ENERGY Strategy
        {
            y++; templatereport.setRowHeight(y, 10); y++;
            templatereport.getRange(y, x).setValue("2.1 ENERGY Assessments".toUpperCase());
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            y++;
            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x + 4, 1, 2).merge();
            templatereport.getRange(y + 1, x + 4, 1, 2).merge();
            templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("Assessments conducted (Y/N)".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Date".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Locations".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Responsible entity".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Areas".toUpperCase()); x++;

            y++; x = xx;

            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_YN']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Date']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Locations']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Responsible']); x++;

            {
                var areas = "";
                areas = jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Areas'];
                if (jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Areas_Other'] != null) { areas = areas + " (" + jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Areas_Other'] + ")"; }
                templatereport.getRange(y, x).setValue(areas); x++;
            }

            y++; x = xx;
            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x, 1, 6).merge();
            templatereport.getRange(y + 1, x, 1, 6).merge();
            templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("Key findings".toUpperCase()); x++;

            y++; x = xx;

            if (jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_YN'] == "Yes") { templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Findings']); templatereport.getRange(y, x).setWrap(true); x++; }
            if (jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_YN'] == "No") {
                templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/ENERGY_ASSESSMENT/Assessment_Findings2']); templatereport.getRange(y, x).setWrap(true); x++;
            }
        }

        //SECTION 2.2 AGDM Assessment
        {
            y++; templatereport.setRowHeight(y, 10); y++; x = xx;
            templatereport.getRange(y, x).setValue("2.2 Age, Gender and Diversity Participatory Assessment".toUpperCase());
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            y++;
            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x + 1, 1, 5).merge();
            templatereport.getRange(y + 1, x + 1, 1, 5).merge();
            templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("Assessment Year".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Problems/Solutions Related to ENERGY".toUpperCase()); x++;

            y++; x = xx;

            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/AGDM/AGDM_Year']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROBLEM_STATEMENT/AGDM/AGDM_Findings']); templatereport.getRange(y, x).setWrap(true); x++;
        }

    }

    //SECTION 3: PROGRAMME SYNOPSIS
    {
        y++; y++; y++; x = xx;
        templatereport.getRange(y, x).setValue("3. PROGRAMME SYNOPSIS");
        templatereport.getRange(y, x, 1, 6).setBackground(C1);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x).setFontSize(20);
        templatereport.getRange(y, x).setFontFamily("Oxygen");
        templatereport.getRange(y, x).setFontWeight("bold");

        //SECTION 3.1 PROGRAMME INFORMATION
        {
            y++; templatereport.setRowHeight(y, 10); y++;
            templatereport.getRange(y, x).setValue("3.1 Programme Information".toUpperCase());
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            y++;
            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x + 1, 1, 5).merge();
            templatereport.getRange(y + 1, x + 1, 1, 5).merge();
            templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("Programme Year".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("PPG (Population Planning Group) Name".toUpperCase()); x++;

            y++; x = xx;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Year']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/PPG'].replace(/_/g, " ")); x++;

            y++; x = xx;
            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("ENERGY Budget (USD)".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Local Currency".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Year of Arrival".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Total PPG Population".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Total Host Community Population".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("# of Partners".toUpperCase()); x++;

            y++; x = xx;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Objective_Budget']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Local_Currency']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Arrival_Year']); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Population']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Host_Population']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
            templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/N_Partner']); x++;
        }

        //SECTION 3.2 PARTNER INFORMATION
        {
            y++; templatereport.setRowHeight(y, 10); y++; x = xx;
            templatereport.getRange(y, x).setValue("3.2 Partner Project Information".toUpperCase());
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            x++;

            //PARTNER REPEAT  
            for (i = 0; i < jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'].length; i++) {
                //var i=0;
                y++; y++;; x = xx;
                templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Partner_Name'].replace(/_/g, " "));
                templatereport.getRange(y, x).setFontWeight("bold");
                templatereport.getRange(y, x).setFontSize("15");
                y++; x = xx;
                templatereport.getRange(y, x, 1, 6).setBackground(C2);
                templatereport.getRange(y, x, 1, 6).setFontColor('white');
                templatereport.getRange(y, x + 2, 1, 4).merge();
                templatereport.getRange(y + 1, x + 2, 1, 4).merge();
                templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

                templatereport.getRange(y, x).setValue("Name of Partner (".toUpperCase() + (i + 1) + ")"); x++;
                templatereport.getRange(y, x).setValue("Host Community".toUpperCase()); x++;

                var ci = 30;
                //var ci=jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Camp'].length;
                templatereport.getRange(y, x).setValue("Camps/Sites/Villages (".toUpperCase() + ci + ")"); x++;

                y++; x = xx;
                templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Partner_Name'].replace(/_/g, " ")); x++;
                templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Partner_Host']); x++;

                var cnames = "";

                //CAMP REPEAT
                {
                    if (jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Year'] == "2017") {

                        for (r = 0; r < ci; r++) {
                            try {
                                cnames = cnames + jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Camp'][r]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/Camp/P_Camps'];
                                if (r < ci - 1) { cnames = cnames + ", "; }
                            } catch (e) { }
                            templatereport.getRange(y, x).setValue(cnames);
                        }
                    }
                    else {
                        cnames = cnames + jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/P_Camps']; templatereport.getRange(y, x).setWrap(true);
                        cnames = cnames.replace(" Other", "");
                        cnames = cnames.replace(/ /g, ", ");
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/P_Camps_Other'] != null) {
                            cnames = cnames + ", " + jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/P_Camps_Other'];
                        }
                        templatereport.getRange(y, x).setValue(cnames);
                    }
                }

                //3.2.1 OUTPUT1
                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/P_Output1'] == "Yes") {
                    y++; templatereport.setRowHeight(y, 10); y++; x = xx;
                    templatereport.getRange(y, x).setValue("3.2.1 AREA 1: Access to appropriate and sustainable cook stoves & fuel supply".toUpperCase());
                    templatereport.getRange(y, x).setFontColor('black');
                    templatereport.getRange(y, x).setFontFamily("Oxygen");
                    templatereport.getRange(y, x).setFontWeight("bold");

                    y++;
                    templatereport.getRange(y, x, 1, 6).setBackground(C2);
                    templatereport.getRange(y, x, 1, 6).setFontColor('white');
                    templatereport.getRange(y, x + 1, 1, 5).merge();
                    templatereport.getRange(y + 1, x + 1, 1, 5).merge();
                    templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);
                    templatereport.getRange(y, x).setValue("Output Budget (USD)".toUpperCase()); x++;
                    templatereport.getRange(y, x).setValue("Interventions".toUpperCase()); x++;

                    y++; x = xx;
                    templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention_budget']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;


                    {
                        var PO1I = "";
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("FEC") > -1) {
                            PO1I = PO1I + "Fuel-efficient cookstove distributed, ";
                        }
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("FP") > -1) {
                            PO1I = PO1I + "Fuel provided, ";
                        }
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("CFP") > -1) {
                            PO1I = PO1I + "Cash for fuel provided";
                        }

                    }
                    templatereport.getRange(y, x).setValue(PO1I); x++;


                    //FEC
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("FEC") > -1) {

                        interventions("● Fuel-efficient cookstove distributed".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FEC_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FEC_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FEC_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FEC_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FEC_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                    //FP
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("FP") > -1) {

                        interventions("● Fuel provided".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FP_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FP_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FP_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FP_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_FP_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                    //CFP
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("CFP") > -1) {

                        interventions("● Cash for fuel provided".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_CFP_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_CFP_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_CFP_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_CFP_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_CFP_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }
                }

                //3.2.2 OUTPUT2
                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/P_Output2'] == "Yes") {

                    y++; templatereport.setRowHeight(y, 10); y++; x = xx;
                    templatereport.getRange(y, x).setValue("3.2.2 AREA 2: Access to sufficient light including both community and household level".toUpperCase());
                    templatereport.getRange(y, x).setFontColor('black');
                    templatereport.getRange(y, x).setFontFamily("Oxygen");
                    templatereport.getRange(y, x).setFontWeight("bold");

                    y++;
                    templatereport.getRange(y, x, 1, 6).setBackground(C2);
                    templatereport.getRange(y, x, 1, 6).setFontColor('white');
                    templatereport.getRange(y, x + 1, 1, 5).merge();
                    templatereport.getRange(y + 1, x + 1, 1, 5).merge();
                    templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);
                    templatereport.getRange(y, x).setValue("Output Budget (USD)".toUpperCase()); x++;
                    templatereport.getRange(y, x).setValue("Interventions".toUpperCase()); x++;

                    y++; x = xx;
                    templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention_budget']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;

                    {
                        var PO2I = "Community Lighting: ";
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'].indexOf("SLI") > -1) {
                            PO2I = PO2I + "Streetlamps Installed, ";
                        }
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'].indexOf("SLM") > -1) {
                            PO2I = PO2I + "Streetlamps maintained";
                        }

                        PO2I = PO2I + String.fromCharCode(10) + "Household Lighting: "
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'].indexOf("PLD") > -1) {
                            PO2I = PO2I + "Portable lights distributed, ";
                        }
                        if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'].indexOf("CLP") > -1) {
                            PO2I = PO2I + "Cash for lighting provided";
                        }

                    }
                    templatereport.getRange(y, x).setValue(PO2I); x++;


                    //SLI
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'].indexOf("SLI") > -1) {

                        interventions("● Streetlamps Installed".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLI_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLI_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLI_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLI_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLI_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                    //SLM
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_Intervention'].indexOf("SLM") > -1) {

                        interventions("● Streetlamps maintained".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLM_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLM_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLM_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLM_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SLM_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                    //PLD
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'].indexOf("PLD") > -1) {

                        interventions("● Portable lights distributed".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_PLD_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_PLD_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_PLD_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_PLD_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_PLD_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                    //CLP
                    if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'].indexOf("CLP") > -1) {

                        interventions("● Cash for lighting provided".toUpperCase(), x, y);
                        y++; y++; x = xx;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_CLP_text']); templatereport.getRange(y, x).setWrap(true); x++; x++; x++; x++;
                        // templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_CLP_start']); x++;
                        //templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_CLP_duration']); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_CLP_beneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                        templatereport.getRange(y, x).setValue(jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_CLP_hbeneficiaries']); templatereport.getRange(y, x).setNumberFormat(numFormats); x++;
                    }

                }

                //COmmunity/HH

                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SubSector'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SubSector'].indexOf("Light_Community") > -1) { CL++; }

                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SubSector'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_SubSector'].indexOf("Light_HH") > -1) { HL++; }

                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO1_Intervention'].indexOf("FEC") > -1) { ST++; }

                if (jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'] != null && jsonData['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner'][i]['PROGRAMME_SYNOPSIS/PROJECT_INFORMATION/Partner/PARTNER_INFORMATION/PO2_InterventionHH'].indexOf("PLD") > -1) { PL++; }
            }
        }
    }

    //SECTION 4: INDICATOR SELECTION
    {
        y++; y++; y++; x = xx;
        templatereport.getRange(y, x).setValue("4. INDICATOR SELECTION");
        templatereport.getRange(y, x, 1, 6).setBackground(C1);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x).setFontSize(20);
        templatereport.getRange(y, x).setFontFamily("Oxygen");
        templatereport.getRange(y, x).setFontWeight("bold");
        y++;
        //SECTION 4.1: OUTPUT 1

        if (jsonData['INDICATOR_SELECTION/O1'] != null) {
            y++;
            templatereport.getRange(y, x).setValue(" AREA 1: Access to appropriate and sustainable cook stoves & fuel supply".toUpperCase());//+jsonData['INDICATOR_SELECTION/O1']);
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            //FEC1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/FEC1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Fuel-efficient cookstove distributed: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/FEC1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FECC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FECC'].indexOf("Stove_Received") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of targeted Households (HH) receiving a fuel efficient cookstove");

                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FEC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FEC'].indexOf("Stove_Produced_Local_International") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of distributed cookstoves produced locally/internationally");

                }
            }

            //FP1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/FP1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Fuel provided: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/FP1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPC'].indexOf("Fuel_Provided") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   Average # of (kg of solid fuel/ litres of liquid fuel/ kg of LPG for cooking provided) per targeted HH per month");
                }
            }

            //CFP1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/CFP1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Cash for Fuel: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/CFP1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPAC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPAC'].indexOf("A1_Cash_Recieved") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of HHs receiving cash for fuel");

                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPAC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPAC'].indexOf("A1_Cash_Voucher_Spent") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of cash/monetary equivalent of vouchers spent on purchasing fuel last month");

                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPA'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_FPA'].indexOf("A1_Cash_Amount") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   Average cash received per HH per month");
                }
            }

            //UZC1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/UZC1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Utilization of cookstove: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/UZC1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_UZCC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_UZCC'].indexOf("Stove_Utilised") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of targeted HH that self report using the (fuel efficient cookstove/three stone fire/another cookstove) to cook the main meal");

                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_UZCC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_UZCC'].indexOf("Stove_Retained") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of targeted HH that possess/retain the fuel efficient stove");

                }

            }

            //ECP1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/ECP1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Employed in cookstove production: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/ECP1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_ECP'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_ECP'].indexOf("Locals_Employed") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   # of local people employed in production, repair and maintenance of cookstoves");
                }
            }

            //KPT1
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/KPT1'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Kitchen Performance Test (KPT): ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT1/KPT1'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_KPTC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_KPTC'].indexOf("Kicken_Performance") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   Average # of (kg of fuel wood/ litres of liquid fuel/ kg of gas/ kg of other solid fuel used for cooking) per targeted HH per person, per day (for those who self-report cooking on the fuel efficient cookstove for the main meal)"); templatereport.getRange(y, x, 1, 6).merge(); templatereport.getRange(y, x).setWrap(true);
                }
            }

            //WCT
            y++; templatereport.setRowHeight(y, 10); y++;
            header("Wood collection time and frequency: ".toUpperCase() + jsonData['INDICATOR_SELECTION/O1'], x, y);
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_WCT'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_WCT'].indexOf("Wood_Collection_Time") > -1) {
                y++;
                templatereport.getRange(y, x).setValue("   Average # of trips made/change in time spent to collect fuel wood (for those who self-report cooking on the fuel efficient cookstove for the main meal)");

            }


            //EXFC
            y++; templatereport.setRowHeight(y, 10); y++;
            header("Expenditure on fuel: ".toUpperCase() + jsonData['INDICATOR_SELECTION/O1'], x, y);
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_EXFC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_EXFC'].indexOf("Expenditure_Fuel") > -1) {
                y++;
                templatereport.getRange(y, x).setValue("   Average HH expenditure on all fuels for cooking per month (for those who self-report cooking on the fuel efficient cookstove for the main meal)");
            }

            //SKM
            y++; templatereport.setRowHeight(y, 10); y++;
            header("Skipping of meals: ".toUpperCase() + jsonData['INDICATOR_SELECTION/O1'], x, y);
            if (jsonData['INDICATOR_SELECTION/OUTPUT1/O1_SKM'] != null && jsonData['INDICATOR_SELECTION/OUTPUT1/O1_SKM'].indexOf("Meals_Skipped") > -1) {
                y++;
                templatereport.getRange(y, x).setValue("   % HHs self-reporting skipping meals last week due to lack of fuel for cooking (for those who self-report cooking on the fuel efficient cookstove for the main meal)");

            }

            y++;
        }

        //SECTION 4.2: OUTPUT 2

        if (jsonData['INDICATOR_SELECTION/O2'] != null) {
            y++;
            templatereport.getRange(y, x).setValue("AREA 2: Access to sufficient light including both community and household level ".toUpperCase());
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            if (CL > 0) {
                y++; templatereport.setRowHeight(y, 10); y++;
                templatereport.getRange(y, x).setValue("COMMUNITY LIGHTING".toUpperCase());
                templatereport.getRange(y, x).setFontColor('black');
                templatereport.getRange(y, x).setFontSize(12);
                templatereport.getRange(y, x).setFontFamily("Oxygen");
                templatereport.getRange(y, x).setFontWeight("bold");
            }

            //SLI2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/SLI2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Streetlamps Installed: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT2/SLI2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLIC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLIC'].indexOf("Streetlights_Installed") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % street lamps installed as planned");

                }
            }

            //SLM2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/SLM2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Streetlamps maintained: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT2/SLM2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLMC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLMC'].indexOf("Streetlights_Functioning") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of total street lamps that are (functioning/repaired)");
                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLM'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SLM'].indexOf("Streetlights_Maintained") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % completion of (basic/technical) maintenance plan of street lamps");
                }
            }

            //SCC2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/SCC2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Perception of safety and security (community): ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT2/SCC2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SCC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SCC'].indexOf("Feeling_Secure_Outside") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of  individuals who self report feeling secure at night outside in the community");

                }
            }

            if (HL > 0) {
                y++; templatereport.setRowHeight(y, 10); y++;
                templatereport.getRange(y, x).setValue("HOUSEHOLD LIGHTING".toUpperCase());
                templatereport.getRange(y, x).setFontColor('black');
                templatereport.getRange(y, x).setFontSize(12);
                templatereport.getRange(y, x).setFontFamily("Oxygen");
                templatereport.getRange(y, x).setFontWeight("bold");
            }

            //PLD2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/PLD2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Portable lights distributed: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT2/PLD2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_PLDC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_PLDC'].indexOf("PortableL_Recieved") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % population receiving portable light");

                }
            }

            //CLP
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/CLP'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Cash for lighting: ".toUpperCase() + jsonData['INDICATOR_SELECTION/OUTPUT2/CLP'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLPC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLPC'].indexOf("A2_Cash_Recieved") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of  HHs receiving cash/voucher for lighting");
                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLPC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLPC'].indexOf("A2_Cash_Voucher_Spent") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of cash/monetary equivalent of vouchers spent on purchasing light");
                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLP'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_CLP'].indexOf("A2_Cash_Amount") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   Average cash received/monetary equivalent of voucher per HH per month");
                }
            }

            //PLRF2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/PLRF2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Portable lights retained and functioning: ".toUpperCase() + jsonData['INDICATOR_SELECTION/PLRF2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_PLRFC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_PLRFC'].indexOf("PortableL_Functioning") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of HHs (retaining the portable lights/with lights that are functioning)");
                }
            }

            //USPL2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/USPL2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Utilization of portable lights: ".toUpperCase() + jsonData['INDICATOR_SELECTION/USPL2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_USPLC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_USPLC'].indexOf("Use_Solar_Primary") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of HH using portable lights as primary light source");
                }
            }

            //REL2
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/REL2'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Expenditure on HH lighting: ".toUpperCase() + jsonData['INDICATOR_SELECTION/REL2'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_RELC'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_RELC'].indexOf("Expenditure_Lighting") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   Average amount spent on lighting last month");
                }

                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_REL'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_REL'].indexOf("Expenditure_Lighting_Others") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of HH reporting having spent money on other sources of light (not including the portable light)");
                }
            }

            //SCC22
            if (jsonData['INDICATOR_SELECTION/OUTPUT2/SCC22'] != null) {
                y++; templatereport.setRowHeight(y, 10); y++;
                header("Perception of safety and security (HHs): ".toUpperCase() + jsonData['INDICATOR_SELECTION/SCC22'], x, y);
                if (jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SCC2'] != null && jsonData['INDICATOR_SELECTION/OUTPUT2/O2_SCC2'].indexOf("Feeling_Secure_INOUT") > -1) {
                    y++;
                    templatereport.getRange(y, x).setValue("   % of individuals who feel secure at night (inside their homes/outside in the community) (self-reported)");
                }
            }

        }


        //SECTION 4.4: Custom Questions

        if (jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/C_IndicatorYN'] == "Yes") {
            y++; y++;
            templatereport.getRange(y, x).setValue("Custom Quetions: (".toUpperCase() + jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'].length + ")");
            templatereport.getRange(y, x).setFontColor('black');
            templatereport.getRange(y, x).setFontSize(15);
            templatereport.getRange(y, x).setFontFamily("Oxygen");
            templatereport.getRange(y, x).setFontWeight("bold");

            y++; x = xx;

            templatereport.getRange(y, x, 1, 6).setBackground(C2);
            templatereport.getRange(y, x, 1, 6).setFontColor('white');
            templatereport.getRange(y, x, 1, 2).merge();
            templatereport.getRange(y, x + 4, 1, 2).merge();
            templatereport.getRange(y, x, 1, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

            templatereport.getRange(y, x).setValue("Question ".toUpperCase()); x++; x++;
            templatereport.getRange(y, x).setValue("Type".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Output".toUpperCase()); x++;
            templatereport.getRange(y, x).setValue("Multiple Choices".toUpperCase()); x++;

            //CUSTOM INDICATOR REPEAT
            for (r = 0; r < jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'].length; r++) {
                y++; x = xx;
                templatereport.getRange(y, x, 1, 2).merge();
                templatereport.getRange(y, x + 4, 1, 2).merge();
                templatereport.getRange(y, x, 1, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);
                x = xx;
                templatereport.getRange(y, x).setValue(jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/C_Indicator_Question']); templatereport.getRange(y, x).setWrap(true); x++; x++;
                templatereport.getRange(y, x).setValue(jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/C_Indicator_Type']); x++;
                templatereport.getRange(y, x).setValue(jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/C_Indicator_Output']); x++;


                //CCHOICE REPEAT
                if (jsonData['PROGRAMME_SYNOPSIS/PROGRAMME_INFORMATION/Year'] == "2017") {
                    if (jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/CI_RESPONSE'] != null) {
                        var choices = "";
                        for (rr = 0; rr < jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/CI_RESPONSE'].length; rr++) {
                            choices = choices + jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/CI_RESPONSE'][rr]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/CI_RESPONSE/C_Indicator_Response'];
                            choices = choices + ", ";
                        };
                        templatereport.getRange(y, x).setValue(choices); templatereport.getRange(y, x).setWrap(true);
                    }
                }
                else {
                    var choice = "";
                    choice = choice + jsonData['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION'][r]['INDICATOR_SELECTION/CUSTOM_INDICATOR/CI_QUESTION/C_Indicator_Response']; templatereport.getRange(y, x).setWrap(true);
                    templatereport.getRange(y, x).setValue(choice);
                }

            }
        }
    }

    //SECTION 5: LOCALISED UNIT
    {

        //STOVES
        {
            if (ST > 0 || PL > 0) {

                y++; y++; y++; x = xx;
                templatereport.getRange(y, x).setValue("5. LOCALISED INFORMATION");
                templatereport.getRange(y, x, 1, 6).setBackground(C1);
                templatereport.getRange(y, x, 1, 6).setFontColor('white');
                templatereport.getRange(y, x).setFontSize(20);
                templatereport.getRange(y, x).setFontFamily("Oxygen");
                templatereport.getRange(y, x).setFontWeight("bold");
            }

            if (ST > 0) {
                y++; templatereport.setRowHeight(y, 10); y++;
                templatereport.getRange(y, x).setValue("5.1: Type of Stoves provided by UNHCR and/or partners/Partners: ".toUpperCase());
                templatereport.getRange(y, x).setFontColor('black');
                templatereport.getRange(y, x).setFontSize(15);
                templatereport.getRange(y, x).setFontFamily("Oxygen");
                templatereport.getRange(y, x).setFontWeight("bold");
                y++;
                templatereport.getRange(y, x, 1, 6).setBackground(C2);
                templatereport.getRange(y, x, 1, 6).setFontColor('white');
                templatereport.getRange(y, x, 1, 6).merge();
                templatereport.getRange(y + 1, x, 1, 6).merge();
                templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

                templatereport.getRange(y, x).setValue("STOVE TYPE".toUpperCase()); x++;
                y++; x = xx;

                var STOVE = "";

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Fuel_Efficient_Wood_Stove") > -1) { STOVE = STOVE + "Fuel efficient wood stove (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Fuel_Wood_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Charcoal_Stove") > -1) { STOVE = STOVE + "Charcoal Stove (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Charcoal_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Liquid_Fuel_Stove") > -1) { STOVE = STOVE + "Liquid Fuel Stove - Kerosene or Ethanol (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Liquid_Fuel_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Gas_Stove") > -1) { STOVE = STOVE + "Gas Stoves - LPG/LNG (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Gas_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Solar_Stove") > -1) { STOVE = STOVE + "Solar Stoves (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Solar_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("Biogas_Stove") > -1) { STOVE = STOVE + "Biogas Stoves (" + jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove_Biogas_Model'] + "), "; }

                if (jsonData['Local_Type/STOVE_TYPE/PO1_UNHCRStove'].indexOf("other") > -1) {
                    STOVE = STOVE + "Other type (";
                    for (s = 0; s < jsonData['Local_Type/STOVE_TYPE/begin_repeat_dd6f44ae'].length; s++) {
                        STOVE = STOVE + jsonData['Local_Type/STOVE_TYPE/begin_repeat_dd6f44ae'][s]['Local_Type/STOVE_TYPE/begin_repeat_dd6f44ae/PO1_UNHCRStove_Other'];
                        if (s != jsonData['Local_Type/STOVE_TYPE/begin_repeat_dd6f44ae'].length - 1) { STOVE = STOVE + ", "; }
                    }
                    STOVE = STOVE + ")";
                }

                templatereport.getRange(y, x).setValue(STOVE);
                templatereport.getRange(y, x).setWrap(true);

            }
        }

        //HH Lighting
        {
            if (PL > 0) {
                y++; templatereport.setRowHeight(y, 10); y++; x = xx;
                templatereport.getRange(y, x).setValue("5.2: Type of HH lighting provided by UNHCR and/or partners and/or partners and/or partners and/or partners/Partners: ".toUpperCase());
                templatereport.getRange(y, x).setFontColor('black');
                templatereport.getRange(y, x).setFontSize(15);
                templatereport.getRange(y, x).setFontFamily("Oxygen");
                templatereport.getRange(y, x).setFontWeight("bold");
                y++;
                templatereport.getRange(y, x, 1, 6).setBackground(C2);
                templatereport.getRange(y, x, 1, 6).setFontColor('white');
                templatereport.getRange(y, x, 1, 6).merge();
                templatereport.getRange(y + 1, x, 1, 6).merge();
                templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

                templatereport.getRange(y, x).setValue("HH Lighting Type".toUpperCase()); x++;
                y++; x = xx;

                var HHLIGHT = "";

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("SolarL") > -1) { HHLIGHT = HHLIGHT + "Solar/portable light or lantern (including solar powered torch), "; }

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("Electricity") > -1) { HHLIGHT = HHLIGHT + "Electricity, "; }

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("Kerosene_Gas") > -1) { HHLIGHT = HHLIGHT + "Kerosene or gas lamp, "; }

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("Battery_Torch") > -1) { HHLIGHT = HHLIGHT + "Battery powered torch, "; }

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("HomeSolarSystem") > -1) { HHLIGHT = HHLIGHT + "Home solar system (includes batteries connected to solar panel),  "; }

                if (jsonData['Local_Type/LIGHT_TYPE/PO2_HHlighting'].indexOf("other") > -1) {
                    HHLIGHT = HHLIGHT + "Other type (";
                    for (s = 0; s < jsonData['Local_Type/LIGHT_TYPE/begin_repeat_7dc48b7b'].length; s++) {
                        HHLIGHT = HHLIGHT + jsonData['Local_Type/LIGHT_TYPE/begin_repeat_7dc48b7b'][s]['Local_Type/LIGHT_TYPE/begin_repeat_7dc48b7b/PO2_HHlighting_Other'];
                        if (s != jsonData['Local_Type/LIGHT_TYPE/begin_repeat_7dc48b7b'].length - 1) { HHLIGHT = HHLIGHT + ", "; }
                    }
                    HHLIGHT = HHLIGHT + ")";
                }

                templatereport.getRange(y, x).setValue(HHLIGHT);
                templatereport.getRange(y, x).setWrap(true);
            }
        }
    }

    //SECTION 6: MOBILE DATA COLLECTION
    {
        y++; y++; x = xx;
        templatereport.getRange(y, x).setValue("MOBILE DATA COLLECTION");
        templatereport.getRange(y, x, 1, 6).setBackground(C1);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x).setFontSize(20);
        templatereport.getRange(y, x).setFontFamily("Oxygen");
        templatereport.getRange(y, x).setFontWeight("bold");
        y++;
        templatereport.getRange(y, x, 1, 6).setBackground(C2);
        templatereport.getRange(y, x, 1, 6).setFontColor('white');
        templatereport.getRange(y, x + 4, 1, 2).merge();
        templatereport.getRange(y + 1, x + 4, 1, 2).merge();
        templatereport.getRange(y, x, 2, 6).setBorder(true, true, true, true, true, true, "grey", SpreadsheetApp.BorderStyle.SOLID);

        templatereport.getRange(y, x).setValue("Experience".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Device".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Model".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("# of devices".toUpperCase()); x++;
        templatereport.getRange(y, x).setValue("Internet".toUpperCase()); x++;

        y++; x = xx;
        templatereport.getRange(y, x).setValue(jsonData['MDC/MDC_Experience']); x++;
        templatereport.getRange(y, x).setValue(jsonData['MDC/MDC_Device']); x++;
        templatereport.getRange(y, x).setValue(jsonData['MDC/MDC_Model']); x++;
        templatereport.getRange(y, x).setValue(jsonData['MDC/MDC_Number']); x++;
        templatereport.getRange(y, x).setValue(jsonData['MDC/MDC_Internet']); x++;
    }

    //LOGO UNHCR
    {
        //templatereport.insertImage(iurl,1,1);
    }
}