diff --git a/.gitignore b/.gitignore index 4c03667..4c633a5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ config.json .DS_Store package-lock.json static/exports +.env \ No newline at end of file diff --git a/templates/incidents/complaints/daily_summery_report_categorywise.js b/templates/incidents/complaints/daily_summery_report_categorywise.js index 5d8e1d4..8815e3f 100644 --- a/templates/incidents/complaints/daily_summery_report_categorywise.js +++ b/templates/incidents/complaints/daily_summery_report_categorywise.js @@ -2,13 +2,11 @@ const config = require("../../../config"); const baseURL = config("BASE_URL"); module.exports = data => { - console.log("data",data); let date = data.date; let categories = data.categories; let otherComplaintCount = data.other; let totalComplaintCount = data.total; - let totalOpenedCount = data.totalOpenedCount; - let language = data.language; + let template = ` @@ -65,28 +63,29 @@ module.exports = data => { /> -
ජනාධිපති ලේකම් කාර්යාලය
-
ஜனாதிபதி செயலகம்
-
Presidential Secretariat
+
මහමැතිවරණය - 2020
+
பாராளுமன்றத் தேர்தல் - 2020
+
Parliamentary Election - 2020
- elections-logo + elections-logo
- දෛනික සාරාංශ වාර්තාව - කාණ්ඩය අනුව ලැබෙන මුළු ඉල්ලීම් ගණන + මැතිවරණ පැමිණිලි 24 පැය සාරාංශ වාර්තාව (මැතිවරණ පැමිණිලි කළමනාකරණ මධ්‍යස්ථානය)
- தினசரி சுருக்க அறிக்கை - வகை மூலம் பெறப்பட்ட மொத்த கோரிக்கைகளின் எண்ணிக்கை + தேர்தல் முறைப்பாடுகள் 24 மணித்தியால சுருக்க அறிக்கை (தேர்தல்கள் முறைப்பாட்டு முகாமைத்துவ மத்திய நிலையம்)
- Daily Summary Report - Total number of requests received by category + Election Complaints 24 hour summery (Election Complaints Management + Centre)
@@ -96,107 +95,48 @@ module.exports = data => { ${date} - + -
කාණ්ඩය
-
வகை
-
Category
+
පැමිණිලි වර්ගය
+
முறைப்பாட்டு வகை
+
Complaints Category
-
අනු කාණ්ඩය
-
உப வகை
-
Subcategory
+
පැමිණිලි අනු වර්ගය
+
முறைப்பாட்டு உப வகை
+
Complaints Sub-Category
සංඛ්‍යාව
எண்ணிக்கை
-
No
+
Counts
`; - template += generateCategoryRows(categories, 0, 0, 3, 6, language); - template += ` -



- - - - - - `; - -template += generateCategoryRows(categories, 3, 0, 7, 3, language); -template += `
-
කාණ්ඩය
-
வகை
-
Category
-
-
අනු කාණ්ඩය
-
உப வகை
-
Subcategory
-
-
සංඛ්‍යාව
-
எண்ணிக்கை
-
No
-
-




- - - - - - `; -template += generateCategoryRows(categories, 8, 0, 13, 4, language); -template += `
-
කාණ්ඩය
-
வகை
-
Category
-
-
අනු කාණ්ඩය
-
உப வகை
-
Subcategory
-
-
සංඛ්‍යාව
-
எண்ணிக்கை
-
No
-
-

- - - + template += generateCategoryRows(categories); + template += ` + - - `; -template += generateCategoryRows(categories, 13, 0, 16, 4, language); -template += ` - - - + + + + - - + + + - +
-
කාණ්ඩය
-
வகை
-
Category
-
-
අනු කාණ්ඩය
-
உப வகை
-
Subcategory
-
-
සංඛ්‍යාව
-
எண்ணிக்கை
-
No
+
වෙනත්
+
வேறு
- එකතුව / மொத்தம் / Total - ${totalComplaintCount}
${otherComplaintCount}
- විවෘත ගැටළු ගණන / திறந்த சிக்கல்கள் எண்ணிக்கை / No. of issues open - ${totalOpenedCount} + එකතුව / மொத்தம் / Total + ${totalComplaintCount}
`; @@ -204,177 +144,41 @@ template += ` return template; }; -function generateCategoryRows(categories = [], startCat, startSubCat, endCat, endSubCat, language) { +function generateCategoryRows(categories = []) { let rowCollection = ""; -if(language=='"en"'){ - for (let i = startCat; i < endCat; i++) { + + for (let i = 0; i < categories.length; i++) { let row = ""; // check if sub categories exist if (categories[i].subCategories && categories[i].subCategories.length > 0) { let subCategories = categories[i].subCategories; -console.log(subCategories); - if (i == endCat-1) { - row = ` - -
${categories[i].categoryNameEnglish}
-
${categories[i].categoryNameSinhala}
- `; - - for (let j = 0; j < endSubCat; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } - } - } else { - row = ` - -
${categories[i].categoryNameEnglish}
-
${categories[i].categoryNameSinhala}
- `; - for (let j = 0; j < subCategories.length; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } - } - } + row = ` + +
${categories[i].categoryNameSinhala}
+
${categories[i].categoryNameTamil}
+ `; + for (let j = 0; j < subCategories.length; j++) { + if (j == 0) { + row += ` + ${subCategories[j].name} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].name} + ${subCategories[j].count} + `; + } + } } else { break; } rowCollection += row; } -}else if(language=='"si"'){ - for (let i = startCat; i < endCat; i++) { - let row = ""; - - // check if sub categories exist - if (categories[i].subCategories && categories[i].subCategories.length > 0) { - let subCategories = categories[i].subCategories; - console.log(subCategories); - if (i == endCat-1) { - row = ` - -
${categories[i].categoryNameSinhala}
-
${categories[i].categoryNameTamil}
- `; - - for (let j = 0; j < endSubCat; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameSinhala} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameSinhala} - ${subCategories[j].count} - `; - } - } - } else { - row = ` - -
${categories[i].categoryNameSinhala}
-
${categories[i].categoryNameTamil}
- `; - - for (let j = 0; j < subCategories.length; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameSinhala} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameSinhala} - ${subCategories[j].count} - `; - } - } - } - - } else { - break; - } - - rowCollection += row; - } - }else if(language=='"ta"'){ - for (let i = startCat; i < endCat; i++) { - let row = ""; - - // check if sub categories exist - if (categories[i].subCategories && categories[i].subCategories.length > 0) { - let subCategories = categories[i].subCategories; - console.log(subCategories); - if (i == endCat-1) { - row = ` - -
${categories[i].categoryNameSinhala}
-
${categories[i].categoryNameTamil}
- `; - - for (let j = 0; j < endSubCat; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } - } - } else { - row = ` - -
${categories[i].categoryNameSinhala}
-
${categories[i].categoryNameTamil}
- `; - - for (let j = 0; j < subCategories.length; j++) { - if (j == 0) { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } else { - row += ` - ${subCategories[j].nameEnglish} - ${subCategories[j].count} - `; - } - } - } - - } else { - break; - } - - rowCollection += row; - } - } return rowCollection; } diff --git a/templates/incidents/complaints/daily_closed_request_report_organizationwise.js b/templates/requests/complaints/daily_closed_request_report_organizationwise.js similarity index 100% rename from templates/incidents/complaints/daily_closed_request_report_organizationwise.js rename to templates/requests/complaints/daily_closed_request_report_organizationwise.js diff --git a/templates/incidents/complaints/daily_closed_summery_report_categorywise.js b/templates/requests/complaints/daily_closed_summery_report_categorywise.js similarity index 100% rename from templates/incidents/complaints/daily_closed_summery_report_categorywise.js rename to templates/requests/complaints/daily_closed_summery_report_categorywise.js diff --git a/templates/requests/complaints/daily_summary_report.js b/templates/requests/complaints/daily_summary_report.js new file mode 100644 index 0000000..638ff67 --- /dev/null +++ b/templates/requests/complaints/daily_summary_report.js @@ -0,0 +1,236 @@ +const config = require("../../../config"); +const baseURL = config("BASE_URL"); + +module.exports = data => { + const options = { + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + hour12: false + }; + const today = new Intl.DateTimeFormat("en-LK", options).format(new Date()); + + return ` + + + + + + + + Daily Summary For Media + + + +
+
+
+ emblem-srilanka +
+
+

මැතිවරණ කොමිෂන් සභාව

+

தேர்தல் ஆணையம்

+
+
+ +
+
+
+ දුරකථන අංක : 011-2868441, 2868442, 2868443
+ ෆැක්ස් : 011-2868426
+
+ web : www.elections.gov.lk     e-mail : info@elections.gov.lk +
+
+ මැතිවරණ කොමිෂන් සභා කාර්යාලය
+ සරණ මාවත , රාජගිරිය (10107)
+ தேர்தல் ஆணையத்தின் அலுவலகம்
+ சரணா மாவதா, ராஜகிரிய (10107)
+
+
+
+
+
+
+ ගතවූ පැය 24 කාලය තුළ (${today}) මැතිවරණ පැමිණිලි සාරාංශ සටහන +
+
+ Summary of the complaints during the past 24 hours (${today}) +
+
+ கடந்த 24 மணி நேரத்தில் புகார்களின் சுருக்கம் (${today}) +
+
+
+ +
+
+
+ + + + + + + + + + + + ${generateRows(data.complaintsPast24hours)} + +
+ පැමිණිලි ලැබීම්
+ Receiving Complaints
+ புகார்களைப் பெறுதல்
+
+ ප්‍රචණ්ඩ ක්‍රියා
+ Disputes
+ வன்ெசல்க
+
+ නීති උල්ලංඝනය කිරීම්
Violations of laws
+ மீண்டும்
+
+ වෙනත්
+ Others
+ மற்ற
+
+ පැමිණිලි සංඛ්‍යාව
+ Amount of Complaints
+ புகார்களின் எண்ணிக்கை
+
+
+
+
+
+
+
මුළු පැමිණිලි සාරාංශ සටහන
+
+ Summary of the total recorded complaints +
+
+ பதிவுசெய்யப்பட்ட மொத்த புகார்களின் சுருக்கம் +
+
+
+ +
+
+
+ + + + + + + + + + + + ${generateRows(data.complaintsSummary)} + + +
+ පැමිණිලි ලැබීම්
+ Receiving Complaints
+ புகார்களைப் பெறுதல்
+
+ ප්‍රචණ්ඩ ක්‍රියා
+ Disputes
+ வன்ெசல்க
+
+ නීති උල්ලංඝනය කිරීම්
Violations of laws
+ மீண்டும்
+
+ වෙනත්
+ Others
+ மற்ற
+
+ පැමිණිලි සංඛ්‍යාව
+ Amount of Complaints
+ புகார்களின் எண்ணிக்கை
+
+
+
+ + + `; +}; + +function generateRows(rowData) { + return ` + + ජාතික මැතිවරණ පැමිණිලි කළමනාකරණ මධ්‍යස්ථානය
+ National Election Complaint Management Centre
+ தேசிய தேர்தல் புகார் மேலாண்மை மையம்
+ + ${rowData.national.disputes} + ${rowData.national.violationOfLaws} + ${rowData.national.others} + ${rowData.national.amount} + + + + දිස්ත්‍රික් මැතිවරණ පැමිණිලි කළමනාකරණ මධ්‍යස්ථානය
+ District Election Complaint Management Centres
+ மாவட்ட தேர்தல் புகார் மேலாண்மை மையங்கள்
+ + ${rowData.district.disputes} + ${rowData.district.violationOfLaws} + ${rowData.district.others} + ${rowData.district.amount} + + + + දෛනික මුළු පැමිණිලි සංඛ්‍යාව
+ Total of daily complaints
+ தினசரி புகார்களின் மொத்தம்
+ + ${rowData.totals.disputes} + ${rowData.totals.violationOfLaws} + ${rowData.totals.others} + ${rowData.totals.amount} + `; +} diff --git a/templates/requests/complaints/daily_summary_report.md b/templates/requests/complaints/daily_summary_report.md new file mode 100644 index 0000000..086167e --- /dev/null +++ b/templates/requests/complaints/daily_summary_report.md @@ -0,0 +1,51 @@ +### Sample JSON for populating the report + +Use the following JSON as request body to populate report. + +```JSON +{ + "file": { + "template": "incidents/complaints/daily_summary_report.js", + "complaintsPast24hours": { + "national": { + "disputes": 21, + "violationOfLaws": 17, + "others": 8, + "amount": 46 + }, + "district": { + "disputes": 11, + "violationOfLaws": 7, + "others": 4, + "amount": 22 + }, + "totals": { + "disputes": 33, + "violationOfLaws": 24, + "others": 12, + "amount": 68 + } + }, + "complaintsSummary": { + "national": { + "disputes": 21, + "violationOfLaws": 17, + "others": 8, + "amount": 46 + }, + "district": { + "disputes": 11, + "violationOfLaws": 7, + "others": 4, + "amount": 22 + }, + "totals": { + "disputes": 33, + "violationOfLaws": 24, + "others": 12, + "amount": 68 + } + } + } +} +``` diff --git a/templates/requests/complaints/daily_summary_report_districtwise.js b/templates/requests/complaints/daily_summary_report_districtwise.js new file mode 100644 index 0000000..3f6df4b --- /dev/null +++ b/templates/requests/complaints/daily_summary_report_districtwise.js @@ -0,0 +1,231 @@ +const config = require("../../../config"); +const baseURL = config("BASE_URL"); +const today = new Date(); + +module.exports = data => { + const electionDate = new Date(data.electionDate); + const complaintTotalsByType = data.complaintTotalsByType; + + return ` + + + + + + + + + +
+
+
+
මහමැතිවරණය - 2020.${electionDate.getMonth() + + 1}.${electionDate.getDate()}
+
நாடாளுமன்றத் தேர்தல் - 2020.${electionDate.getMonth() + + 1}.${electionDate.getDate()}
+
Parliamentary Election - 2020.${electionDate.getMonth() + + 1}.${electionDate.getDate()}
+
+
+
+
+
+
මැතිවරණ පැමිණිලි සාරාංශ වාර්තාව
+
(දිස්ත්‍රික් මැතිවරණ පැමිණිලි කළමනාකරණ මධ්‍යස්ථාන)
+
தேர்தல் முறைப்பாடுகள் சுருக்க அறிக்கை
+
(மாவட்ட தேர்தல்கள் முறைப்பாட்டு முகாமைத்துவ மத்திய நிலையங்கள்)
+
Election Complaints Summary
+
(District Complaint Management Centers)
+
+
+
+
+
+ 2020.${today.getMonth() + + 1}.${today.getDate()} - 00.00 pm +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${generateRows(data.complaintByDistrict)} + + + + + + + + + + + + + +
+ දිස්ත්‍රික්කය
+ மாவட்டம்
+ District +
+ පැමිණිලි වර්ගය හා අංකය /
+ முறைப்பாட்டின் வகை மற்றும் இலக்கம் /
+ Category and the Number of Complaint +
+ පැමිණිල්ලේ ස්වභාවය/
+ முறைப்பாட்டின் தன்மை/
+ Nature of Complaint +
+ ප්‍රචන්ඩ ක්‍රියා/
+ வன்செயல்கள்/
+ Violence +
+ මැතිවරණ නීති උල්ලංඝනය/
+ தேர்தல் சட்டமீறல்கள்/
+ Breach of Election Law +
+ වෙනත්/
+ ஏனையவை/
+ Other +
+ සුළු/
+ சிறிய/
+ Minor +
+ සාමාන්‍ය/
+ சாதாரணமான/
+ General +
+ බරපතල/
+ கடுமையான/
+ Serious +
+ එකතුව/
+ மொத்தம்/
+ Total +
+ එකතුව/ மொத்தம்/ Total + ${complaintTotalsByType.violence}${complaintTotalsByType.breachOfElectionLaws}${complaintTotalsByType.other}${complaintTotalsByType.minor}${complaintTotalsByType.general}${complaintTotalsByType.major}${complaintTotalsByType.total}
+
+
+
+
+ + + `; +}; + +function generateRows(complaintByDistrict) { + const districts = [ + "කොළඹ/கொழும்பு/Colombo", + "ගම්පහ/கம்பஹா/Gampaha", + "කළුතර/களுத்தறை/Kalutara", + "මහනුවර/கண்டி/Kandy", + "මාතලේ/மாத்தளை/Matale", + "නුවරඑළිය/நுவரெலியா/Nuwaraeliya", + "ගාල්ල/காலி/Galle", + "මාතර/மாத்தறை/Matara", + "හම්බන්තොට/ஹம்பாந்தோட்டை/Hambantota", + "යාපනය/யாழ்ப்பாணம்/Jaffna", + "කිලිනොච්චි/கிளிநொச்சி/Killinochchi", + "වවුනියා/வவுனியா/Vavuniya", + "මන්නාරම/மன்னார்/Mannar", + "මුලතිව්/முல்லைத்தீவு/Mulaitivu", + "මඩකලපුව/மட்டக்களப்பு/Baticaloa", + "අම්පාර/அம்பாறை/Ampara", + "ත්‍රිකුණාමලය/திருகோணமலை/Trincomalee", + "කුරුණෑගල/குருநாகல்/Kurunagala", + "පුත්තලම/புத்தளம்/Puttalam", + "අනුරාධපුර/அனுராதபுரம்/Anuradhapura", + "පොළොන්නරුව/பொலநறுவை/Polonnaruwa", + "බදුල්ල/பதுளை/Badulla", + "මොනරාගල/மொனராகலை/Monaragala", + "රත්නපුර/இரத்தினபரி/Ratnapura", + "කෑගල්ල/கேகாலை/Kagalle" + ]; + + return districts + .map( + (districtName, index) => + ` + ${index + 1} + ${districtName} + ${complaintByDistrict[index].violence} + ${complaintByDistrict[index].breachOfElectionLaws} + ${complaintByDistrict[index].other} + ${complaintByDistrict[index].minor} + ${complaintByDistrict[index].general} + ${complaintByDistrict[index].major} + ${complaintByDistrict[index].total} + ` + ) + .join(""); +} diff --git a/templates/requests/complaints/daily_summary_report_districtwise.md b/templates/requests/complaints/daily_summary_report_districtwise.md new file mode 100644 index 0000000..7715323 --- /dev/null +++ b/templates/requests/complaints/daily_summary_report_districtwise.md @@ -0,0 +1,257 @@ +### Sample JSON for populating the report + +Use the following JSON as request body to populate report. + +```JSON +{ + "file": { + "template": "incidents/complaints/daily_summary_report_districtwise.js", + "electionDate": "2020-04-16T07:22Z", + "complaintTotalsByType": { + "violence": 54, + "breachOfElectionLaws": 23, + "other": 34, + "minor": 234, + "general": 23, + "major": 234, + "total": 3423 + }, + "complaintByDistrict": [ + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + }, + { + "violence": 4, + "breachOfElectionLaws": 8, + "other": 2, + "minor": 3, + "general": 55, + "major": 0, + "total": 23 + } + ] + } +} +``` diff --git a/templates/requests/complaints/daily_summery_report_categorywise.js b/templates/requests/complaints/daily_summery_report_categorywise.js new file mode 100644 index 0000000..5d8e1d4 --- /dev/null +++ b/templates/requests/complaints/daily_summery_report_categorywise.js @@ -0,0 +1,380 @@ +const config = require("../../../config"); +const baseURL = config("BASE_URL"); + +module.exports = data => { + console.log("data",data); + let date = data.date; + let categories = data.categories; + let otherComplaintCount = data.other; + let totalComplaintCount = data.total; + let totalOpenedCount = data.totalOpenedCount; + let language = data.language; + let template = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + + template += generateCategoryRows(categories, 0, 0, 3, 6, language); + template += `
+ emblem-srilanka + +
ජනාධිපති ලේකම් කාර්යාලය
+
ஜனாதிபதி செயலகம்
+
Presidential Secretariat
+
+ elections-logo +
+
+ දෛනික සාරාංශ වාර්තාව - කාණ්ඩය අනුව ලැබෙන මුළු ඉල්ලීම් ගණන +
+
+ தினசரி சுருக்க அறிக்கை - வகை மூலம் பெறப்பட்ட மொத்த கோரிக்கைகளின் எண்ணிக்கை +
+
+ Daily Summary Report - Total number of requests received by category +
+
+ දිනය/திகதி/Date + ${date} +
+
කාණ්ඩය
+
வகை
+
Category
+
+
අනු කාණ්ඩය
+
உப வகை
+
Subcategory
+
+
සංඛ්‍යාව
+
எண்ணிக்கை
+
No
+
+



+ + + + + + `; + +template += generateCategoryRows(categories, 3, 0, 7, 3, language); +template += `
+
කාණ්ඩය
+
வகை
+
Category
+
+
අනු කාණ්ඩය
+
உப வகை
+
Subcategory
+
+
සංඛ්‍යාව
+
எண்ணிக்கை
+
No
+
+




+ + + + + + `; +template += generateCategoryRows(categories, 8, 0, 13, 4, language); +template += `
+
කාණ්ඩය
+
வகை
+
Category
+
+
අනු කාණ්ඩය
+
உப வகை
+
Subcategory
+
+
සංඛ්‍යාව
+
எண்ணிக்கை
+
No
+
+

+ + + + + + `; +template += generateCategoryRows(categories, 13, 0, 16, 4, language); +template += ` + + + + + + + + +
+
කාණ්ඩය
+
வகை
+
Category
+
+
අනු කාණ්ඩය
+
உப வகை
+
Subcategory
+
+
සංඛ්‍යාව
+
எண்ணிக்கை
+
No
+
+ එකතුව / மொத்தம் / Total + ${totalComplaintCount}
+ විවෘත ගැටළු ගණන / திறந்த சிக்கல்கள் எண்ணிக்கை / No. of issues open + ${totalOpenedCount}
+ + `; + + return template; +}; + +function generateCategoryRows(categories = [], startCat, startSubCat, endCat, endSubCat, language) { + let rowCollection = ""; +if(language=='"en"'){ + for (let i = startCat; i < endCat; i++) { + let row = ""; + + // check if sub categories exist + if (categories[i].subCategories && categories[i].subCategories.length > 0) { + let subCategories = categories[i].subCategories; +console.log(subCategories); + if (i == endCat-1) { + row = ` + +
${categories[i].categoryNameEnglish}
+
${categories[i].categoryNameSinhala}
+ `; + + for (let j = 0; j < endSubCat; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } + } + } else { + row = ` + +
${categories[i].categoryNameEnglish}
+
${categories[i].categoryNameSinhala}
+ `; + + for (let j = 0; j < subCategories.length; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } + } + } + + } else { + break; + } + + rowCollection += row; + } +}else if(language=='"si"'){ + for (let i = startCat; i < endCat; i++) { + let row = ""; + + // check if sub categories exist + if (categories[i].subCategories && categories[i].subCategories.length > 0) { + let subCategories = categories[i].subCategories; + console.log(subCategories); + if (i == endCat-1) { + row = ` + +
${categories[i].categoryNameSinhala}
+
${categories[i].categoryNameTamil}
+ `; + + for (let j = 0; j < endSubCat; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameSinhala} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameSinhala} + ${subCategories[j].count} + `; + } + } + } else { + row = ` + +
${categories[i].categoryNameSinhala}
+
${categories[i].categoryNameTamil}
+ `; + + for (let j = 0; j < subCategories.length; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameSinhala} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameSinhala} + ${subCategories[j].count} + `; + } + } + } + + } else { + break; + } + + rowCollection += row; + } + }else if(language=='"ta"'){ + for (let i = startCat; i < endCat; i++) { + let row = ""; + + // check if sub categories exist + if (categories[i].subCategories && categories[i].subCategories.length > 0) { + let subCategories = categories[i].subCategories; + console.log(subCategories); + if (i == endCat-1) { + row = ` + +
${categories[i].categoryNameSinhala}
+
${categories[i].categoryNameTamil}
+ `; + + for (let j = 0; j < endSubCat; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } + } + } else { + row = ` + +
${categories[i].categoryNameSinhala}
+
${categories[i].categoryNameTamil}
+ `; + + for (let j = 0; j < subCategories.length; j++) { + if (j == 0) { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } else { + row += ` + ${subCategories[j].nameEnglish} + ${subCategories[j].count} + `; + } + } + } + + } else { + break; + } + + rowCollection += row; + } + } + + return rowCollection; +} diff --git a/templates/requests/complaints/daily_summery_report_categorywise.md b/templates/requests/complaints/daily_summery_report_categorywise.md new file mode 100644 index 0000000..daee309 --- /dev/null +++ b/templates/requests/complaints/daily_summery_report_categorywise.md @@ -0,0 +1,41 @@ +## sample json +``` +{ + "file": { + "template": "/incidents/complaints/daily_summery_report_categorywise.js", + "date": "2020/05/18", + "categories": [ + { + "categoryNameSinhala": "ප්‍රචණ්ඩ ක්‍රියා", + "categoryNameTamil": "வன் செயல்கள்", + "subCategories": [ + { + "name": "වාචික බිය ගැන්වීම", + "count": "10" + }, + { + "name": "ආයුධ පෙන්වා බිය ගැන්වීම වෙඩි තබා මැරීමට තැත් කිරීම", + "count": "1" + }, + { + "name": "පහර දීම / මැර ප්‍රහාර එල්ල කිරීම", + "count": "5" + } + ] + }, + { + "categoryNameSinhala": "නීති උල්ලංඝන", + "categoryNameTamil": "சட்ட மீறல்கள்", + "subCategories": [ + { + "name": "මැතිවරණ ප්‍රචාරණ කටයුතු වලට බාධා කිරීම", + "count": "3" + } + ] + } + ], + "other": "23", + "total": "35" + } +} + ``` diff --git a/templates/incidents/complaints/daily_summery_report_categorywise_with_timefilter.js b/templates/requests/complaints/daily_summery_report_categorywise_with_timefilter.js similarity index 100% rename from templates/incidents/complaints/daily_summery_report_categorywise_with_timefilter.js rename to templates/requests/complaints/daily_summery_report_categorywise_with_timefilter.js diff --git a/templates/incidents/complaints/summery_report_organizationwise_with_timefilter.js b/templates/requests/complaints/summery_report_organizationwise_with_timefilter.js similarity index 100% rename from templates/incidents/complaints/summery_report_organizationwise_with_timefilter.js rename to templates/requests/complaints/summery_report_organizationwise_with_timefilter.js diff --git a/templates/incidents/complaints/weekly_closed_request_report_categorywise.js b/templates/requests/complaints/weekly_closed_request_report_categorywise.js similarity index 100% rename from templates/incidents/complaints/weekly_closed_request_report_categorywise.js rename to templates/requests/complaints/weekly_closed_request_report_categorywise.js diff --git a/templates/incidents/complaints/weekly_closed_request_report_organizationwise.js b/templates/requests/complaints/weekly_closed_request_report_organizationwise.js similarity index 100% rename from templates/incidents/complaints/weekly_closed_request_report_organizationwise.js rename to templates/requests/complaints/weekly_closed_request_report_organizationwise.js diff --git a/templates/incidents/complaints/weekly_summery_report_organizationwise.md b/templates/requests/complaints/weekly_summery_report_organizationwise.md similarity index 100% rename from templates/incidents/complaints/weekly_summery_report_organizationwise.md rename to templates/requests/complaints/weekly_summery_report_organizationwise.md