commit
6e9f302655
9 changed files with 2761 additions and 0 deletions
-
132APIController.java
-
96MainController.java
-
205WorksService.java
-
642dashboard page/cmworkstradelicense.html
-
127hari cm works dashboard files/APIController.java
-
166hari cm works dashboard files/CmDashboardService.java
-
84hari cm works dashboard files/MainController.java
-
434hari cm works dashboard files/alldetails.html
-
875hari cm works dashboard files/index1.html
@ -0,0 +1,132 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmworks.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpEntity; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.HttpMethod; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cmworks.service.WorksService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("/gcc/api/works") |
|||
@RestController("worksRest") |
|||
public class APIController { |
|||
|
|||
private WorksService worksservice; |
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public APIController(WorksService worksservice) { |
|||
this.worksservice=worksservice; |
|||
} |
|||
|
|||
|
|||
@GetMapping(value="/getCmDashboardReports") |
|||
public List getCombinedCmDashboardReports(@RequestParam ("zonename") String zonename) { |
|||
|
|||
return worksservice.getCombinedCmDashboardReports(zonename); |
|||
} |
|||
|
|||
@GetMapping(value="/getCmDashboardAllReports") |
|||
public List getCmDashboardAllReports() { |
|||
|
|||
return worksservice.getCmDashboardAllReports(); |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping(value="/getRegionCounts") |
|||
public List<Map<String, Object>> getRegionCounts() { |
|||
return worksservice.getRegionCounts(); |
|||
} |
|||
|
|||
|
|||
@GetMapping(value="/getZoneCounts") |
|||
public List<Map<String, Object>> getZoneCounts() { |
|||
return worksservice.getZoneCounts(); |
|||
} |
|||
|
|||
@GetMapping(value="/getImageUrl") |
|||
public List<Map<String, Object>> getImageUrl() { |
|||
return worksservice.getImageUrl(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/all-list/{id}") |
|||
public Map<String, Object> getCMDetails(@PathVariable int id) { |
|||
return worksservice.getCMDetails(id); |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping(value="/getTradelicenseReports") |
|||
public List getTradelicenseReports(@RequestParam("divisionName")String divisionName) { |
|||
System.out.println("selected region:"+ divisionName); |
|||
return worksservice.getTradelicenseReports(divisionName); |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping(value="/getTradelicenseReportsAll") |
|||
public List getTradelicenseReportsAll() { |
|||
|
|||
return worksservice.getTradelicenseReportsAll(); |
|||
} |
|||
|
|||
|
|||
// Rest Api From ERP |
|||
@GetMapping(value = "/getZoneNo") |
|||
public String getZoneNo() { |
|||
|
|||
String urlString = appConfig.getErpUrl()+"serviceId=getZones"; |
|||
ResponseEntity<String> response = null; |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String bodyMessage = ""; |
|||
HttpHeaders headers = new HttpHeaders(); |
|||
try { |
|||
HttpEntity<String> postData = new HttpEntity<String>(headers); |
|||
response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); |
|||
bodyMessage = response.getBody(); |
|||
//System.out.println("BodyMessage" + bodyMessage); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
//System.out.print("\n ERROR---: " + e); |
|||
bodyMessage = "Error"; |
|||
} |
|||
return bodyMessage; |
|||
} |
|||
|
|||
@GetMapping(value = "/getDiv") |
|||
public String getDiv(@RequestParam String zoneId) { |
|||
String urlString = appConfig.getErpUrl()+"serviceId=getWards&Zoneid="+zoneId+""; |
|||
ResponseEntity<String> response = null; |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String bodyMessage = ""; |
|||
HttpHeaders headers = new HttpHeaders(); |
|||
try { |
|||
HttpEntity<String> postData = new HttpEntity<String>(headers); |
|||
response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); |
|||
bodyMessage = response.getBody(); |
|||
//System.out.println("bodyMessage" + bodyMessage); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
//System.out.print("\n ERROR---: " + e); |
|||
bodyMessage = "Error"; |
|||
} |
|||
return bodyMessage; |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmworks.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cmworks.service.WorksService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/works") |
|||
@Controller("worksController") |
|||
public class MainController { |
|||
|
|||
private final LoginUserInfo loginUserInfo; |
|||
private final WorksService dashboards; |
|||
|
|||
|
|||
@Autowired |
|||
public MainController(LoginUserInfo loginUserInfo, |
|||
WorksService dashboards) { |
|||
this.loginUserInfo = loginUserInfo; |
|||
this.dashboards = dashboards; |
|||
} |
|||
|
|||
|
|||
// This method to show the dashboard of regionwise,zonewise,typeofwork,scheme wise works counts |
|||
|
|||
@GetMapping({"", "/", "/dashboard"}) |
|||
public String main(@RequestParam(value = "zonename", required = false, defaultValue = "all") String zonename, Model model) { |
|||
|
|||
// Fetch data for the dashboard based on the regionname |
|||
List<Map<String, Object>> regionData = dashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> schemeData = dashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> typeOfWorkData = dashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> zoneData = dashboards.getCombinedCmDashboardReports(zonename); |
|||
|
|||
// Add data to the model |
|||
model.addAttribute("regionData", regionData); |
|||
model.addAttribute("schemeData", schemeData); |
|||
model.addAttribute("typeOfWorkData", typeOfWorkData); |
|||
model.addAttribute("zoneData", zoneData); |
|||
// Log the user ID |
|||
String userId = LoginUserInfo.getLoginUserId(); |
|||
if (userId != null && !userId.isEmpty()) { |
|||
System.out.println("String UserID: " + userId); |
|||
} |
|||
|
|||
return "modules/cmworks/dashboard"; |
|||
} |
|||
|
|||
|
|||
//This method used to show the image and estimate number details of works |
|||
|
|||
@GetMapping("/cmworksdetails") |
|||
public String worksdetails(Model model) { |
|||
|
|||
List<Map<String, Object>> workslist = dashboards.getImageUrl(); |
|||
|
|||
model.addAttribute("workslist",workslist); |
|||
return "modules/cmworks/cmworksdetails"; |
|||
} |
|||
|
|||
//This method used to show the all related details of works |
|||
|
|||
@GetMapping("/all-list") |
|||
public String allList(Model model) { |
|||
|
|||
List<Map<String, Object>> cmLists = dashboards.getCmDashboardAllReports(); |
|||
model.addAttribute("cmlist", cmLists); |
|||
return "modules/cmworks/cmworksdetails1"; |
|||
} |
|||
|
|||
//This method used to show the tradelicense details dashboard |
|||
|
|||
|
|||
@GetMapping("/tradedashboard") |
|||
public String tradelicense(@RequestParam(value = "divisionName", required = false, defaultValue = "All") String divisionName,Model model) { |
|||
|
|||
List<Map<String, Object>> tradelicense = new ArrayList<>(); |
|||
|
|||
if(divisionName!=null && divisionName.isEmpty()) { |
|||
tradelicense = dashboards.getTradelicenseReports(divisionName); |
|||
} |
|||
model.addAttribute("tradelicense", tradelicense); |
|||
return "modules/cmworks/cmworkstradelicense"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,205 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmworks.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
@Service |
|||
public class WorksService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
// @Autowired |
|||
// public void setDataSourcemysql(@Qualifier("mysqlAppDataSource") DataSource dataSource) { |
|||
// this.jdbcTemplate = new JdbcTemplate(dataSource); } |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("oracleDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCombinedCmDashboardReports(String zonename) { |
|||
String sqlQuery; |
|||
Object[] params; |
|||
|
|||
if (zonename != null && !zonename.equalsIgnoreCase("all")) { |
|||
sqlQuery = "SELECT cm.schemename AS name, " + |
|||
"COUNT(*) AS count, " + |
|||
"SUM(cm.valueofwork) AS total_value_of_work, " + |
|||
"'Scheme' AS type " + |
|||
"FROM gcc_apps.cmworks cm " + |
|||
"WHERE cm.zonename = ? " + |
|||
"GROUP BY cm.schemename " + |
|||
"UNION ALL " + |
|||
"SELECT cm.workcategory AS name, " + |
|||
"COUNT(*) AS count, " + |
|||
"SUM(cm.valueofwork) AS total_value_of_work, " + |
|||
"'Category' AS type " + |
|||
"FROM gcc_apps.cmworks cm " + |
|||
"WHERE cm.zonename = ? " + |
|||
"GROUP BY cm.workcategory"; |
|||
params = new Object[]{zonename, zonename}; |
|||
} else { |
|||
sqlQuery = "SELECT cm.schemename AS name, " + |
|||
"COUNT(*) AS count, " + |
|||
"SUM(cm.valueofwork) AS total_value_of_work, "+ |
|||
"'Scheme' AS type " + |
|||
"FROM gcc_apps.cmworks cm " + |
|||
"GROUP BY cm.schemename " + |
|||
"UNION ALL " + |
|||
"SELECT cm.workcategory AS name, " + |
|||
"COUNT(*) AS count, " + |
|||
"SUM(cm.valueofwork) AS total_value_of_work,"+ |
|||
"'Category' AS type " + |
|||
"FROM gcc_apps.cmworks cm " + |
|||
"GROUP BY cm.workcategory"; |
|||
params = new Object[]{}; |
|||
} |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, params); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getRegionCounts() { |
|||
String sqlQuery = "SELECT regionname, COUNT(*) AS region_count FROM gcc_apps.cmworks GROUP BY regionname"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getZoneCounts() { |
|||
String sqlQuery = "SELECT zonename, COUNT(*) AS zone_count FROM gcc_apps.cmworks GROUP BY zonename"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public List<Map<String,Object>> getImageUrl(){ |
|||
String sqlQuery = "SELECT abs_est_number ,MAX(imageurl) AS imageurl FROM gcc_apps.cmworks GROUP BY abs_est_number"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getCmDashboardAllReports() { |
|||
String sqlQuery ="SELECT * FROM gcc_apps.cmworks"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public Map<String, Object> getCMDetails(int id) { |
|||
String sql = "SELECT * FROM gcc_apps.cmworks WHERE data_id = ?"; |
|||
return jdbcTemplate.queryForMap(sql, id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String,Object>> getTradelicenseReports(String divisionName){ |
|||
String sqlquery = ""; |
|||
|
|||
|
|||
sqlquery ="select " |
|||
+ "region.name region, " |
|||
+ "zone.name Zone,boun.name Ward,NVL(new_lic,0) NEW_LIC,NVL(new_lic_amt,0) NEW_LIC_AMT,NVL(curr_lic_ren,0) REN_WITH_PENALTY, " |
|||
+ "NVL(curr_lic_ren_amt,0) REN_WITH_PENALTY_AMT ,NVL(curr_lic_ren_before,0) REN_WITH_OUT_PENALTY, " |
|||
+ "NVL(curr_lic_ren_before_amt,0) REN_WITH_OUT_PENALTY_AMT,NVL(nonrnwdcnt,0) NON_RENEWED, NVL(NONRNWDCNTAMT ,0) AS NONRNWDCNTAMT " |
|||
+ "from eg_boundary@erp boun left outer join " |
|||
+ " (SELECT ward_id ,SUM(NVL(new_lic ,0)) AS new_lic ,SUM(NVL(new_lic_amt ,0)) AS new_lic_amt ,SUM(NVL(totalCnt ,0)) AS totalCnt , " |
|||
+ " SUM(NVL(NONRNWDCNT ,0)) AS NONRNWDCNT,SUM(NVL(NONRNWDCNTAMT ,0)) AS NONRNWDCNTAMT " |
|||
+ " FROM (SELECT " |
|||
+ " CASE WHEN lic.ID_INSTALLMENT =ins.ID_INSTALLMENT AND ins.ID_INSTALLMENT = (SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN 1 ELSE 0 END AS new_lic , " |
|||
+ " CASE WHEN lic.ID_INSTALLMENT =ins.ID_INSTALLMENT AND ins.ID_INSTALLMENT = (SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN lic.total_fee ELSE 0 END AS new_lic_amt , " |
|||
+ " CASE WHEN lic.id is not null AND LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN 1 ELSE 0 END AS totalCnt , " |
|||
+ " CASE WHEN LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) AND LIC.ID NOT IN (SELECT R1.LICENSE_ID FROM egtl_renewal@erp R1 where R1.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and R1.paid_status =1) THEN 1 ELSE 0 END AS NONRNWDCNT " |
|||
+ " ,CASE WHEN LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) AND LIC.ID NOT IN (SELECT R1.LICENSE_ID FROM egtl_renewal@erp R1 where R1.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and R1.paid_status =1) THEN lic.total_fee ELSE 0 END AS NONRNWDCNTAMT " |
|||
+ " ,trade.division_id ward_id from EGTL_LICENSE@erp lic " |
|||
+ " inner join EGTL_TRADE@erp trade on trade.ID =lic.TRADE_ID " |
|||
+ " inner join eg_installment_master@erp ins on ins.id_installment = lic.id_installment " |
|||
+ "where trade.active=1 and LIC.STATUS IN (2 ,4 ,8)) group by ward_id) new on boun.id_bndry=new.ward_id " |
|||
+ "left outer join (select trade.division_id ward_id , " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN 1 ELSE 0 END) old_lic_ren, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date THEN 1 ELSE 0 END) curr_lic_ren, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date < ins.start_Date THEN 1 ELSE 0 END) curr_lic_ren_before, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT >(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN 1 ELSE 0 END) lic_ren_adv, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN re.total_fee ELSE 0 END) old_lic_ren_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date THEN re.total_fee ELSE 0 END) curr_lic_ren_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date < ins.start_Date THEN re.total_fee ELSE 0 END) curr_lic_ren_before_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT >(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN re.total_fee ELSE 0 END) lic_ren_adv_amt " |
|||
+ "from egtl_renewal@erp re ,EGTL_LICENSE@erp li ,EGTL_TRADE@erp trade ,eg_installment_master@erp ins " |
|||
+ "where trade.ID =li.TRADE_ID " |
|||
+ "and ins.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) " |
|||
+ "and li.STATUS IN (2 ,4 ,8) AND re.paid_status = 1 and li.id = re.license_id group by trade.division_id) ren on ren.ward_id=boun.id_bndry " |
|||
+ "left outer join eg_boundary@erp zone on zone.id_bndry=boun.parent " |
|||
+ "left outer join eg_boundary@erp region on region.id_bndry=zone.parent " |
|||
+ "where boun.id_bndry_type=3 and boun.name like 'N%' "; |
|||
|
|||
//and boun.name='"+divisionName+"' order by zone.name,boun.name" |
|||
|
|||
// Append division name filtering based on the selected division |
|||
if (divisionName != null && !divisionName.isEmpty() && !"All".equalsIgnoreCase(divisionName)) { |
|||
sqlquery += "and boun.name = '"+divisionName+"' "; |
|||
} |
|||
|
|||
sqlquery += "order by zone.name, boun.name"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlquery); |
|||
|
|||
return result; |
|||
} |
|||
//and zone.name='N01' and boun.name='N009' |
|||
|
|||
@Transactional |
|||
public List<Map<String,Object>> getTradelicenseReportsAll(){ |
|||
String sqlquery = ""; |
|||
|
|||
|
|||
sqlquery ="select " |
|||
+ "region.name region, " |
|||
+ "zone.name Zone,boun.name Ward,NVL(new_lic,0) NEW_LIC,NVL(new_lic_amt,0) NEW_LIC_AMT,NVL(curr_lic_ren,0) REN_WITH_PENALTY, " |
|||
+ "NVL(curr_lic_ren_amt,0) REN_WITH_PENALTY_AMT ,NVL(curr_lic_ren_before,0) REN_WITH_OUT_PENALTY, " |
|||
+ "NVL(curr_lic_ren_before_amt,0) REN_WITH_OUT_PENALTY_AMT,NVL(nonrnwdcnt,0) NON_RENEWED, NVL(NONRNWDCNTAMT ,0) AS NONRNWDCNTAMT " |
|||
+ "from eg_boundary@erp boun left outer join " |
|||
+ " (SELECT ward_id ,SUM(NVL(new_lic ,0)) AS new_lic ,SUM(NVL(new_lic_amt ,0)) AS new_lic_amt ,SUM(NVL(totalCnt ,0)) AS totalCnt , " |
|||
+ " SUM(NVL(NONRNWDCNT ,0)) AS NONRNWDCNT,SUM(NVL(NONRNWDCNTAMT ,0)) AS NONRNWDCNTAMT " |
|||
+ " FROM (SELECT " |
|||
+ " CASE WHEN lic.ID_INSTALLMENT =ins.ID_INSTALLMENT AND ins.ID_INSTALLMENT = (SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN 1 ELSE 0 END AS new_lic , " |
|||
+ " CASE WHEN lic.ID_INSTALLMENT =ins.ID_INSTALLMENT AND ins.ID_INSTALLMENT = (SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN lic.total_fee ELSE 0 END AS new_lic_amt , " |
|||
+ " CASE WHEN lic.id is not null AND LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) THEN 1 ELSE 0 END AS totalCnt , " |
|||
+ " CASE WHEN LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) AND LIC.ID NOT IN (SELECT R1.LICENSE_ID FROM egtl_renewal@erp R1 where R1.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and R1.paid_status =1) THEN 1 ELSE 0 END AS NONRNWDCNT " |
|||
+ " ,CASE WHEN LIC.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) AND LIC.ID NOT IN (SELECT R1.LICENSE_ID FROM egtl_renewal@erp R1 where R1.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and R1.paid_status =1) THEN lic.total_fee ELSE 0 END AS NONRNWDCNTAMT " |
|||
+ " ,trade.division_id ward_id from EGTL_LICENSE@erp lic " |
|||
+ " inner join EGTL_TRADE@erp trade on trade.ID =lic.TRADE_ID " |
|||
+ " inner join eg_installment_master@erp ins on ins.id_installment = lic.id_installment " |
|||
+ "where trade.active=1 and LIC.STATUS IN (2 ,4 ,8)) group by ward_id) new on boun.id_bndry=new.ward_id " |
|||
+ "left outer join (select trade.division_id ward_id , " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN 1 ELSE 0 END) old_lic_ren, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date THEN 1 ELSE 0 END) curr_lic_ren, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date < ins.start_Date THEN 1 ELSE 0 END) curr_lic_ren_before, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT >(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN 1 ELSE 0 END) lic_ren_adv, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT <(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN re.total_fee ELSE 0 END) old_lic_ren_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date THEN re.total_fee ELSE 0 END) curr_lic_ren_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT =(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date < ins.start_Date THEN re.total_fee ELSE 0 END) curr_lic_ren_before_amt, " |
|||
+ "sum(CASE WHEN re.ID_INSTALLMENT >(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) and re.renewed_Date >= ins.start_Date and re.renewed_Date <= ins.end_Date THEN re.total_fee ELSE 0 END) lic_ren_adv_amt " |
|||
+ "from egtl_renewal@erp re ,EGTL_LICENSE@erp li ,EGTL_TRADE@erp trade ,eg_installment_master@erp ins " |
|||
+ "where trade.ID =li.TRADE_ID " |
|||
+ "and ins.ID_INSTALLMENT=(SELECT ID_INSTALLMENT FROM EG_INSTALLMENT_MASTER@erp WHERE ID_MODULE = 185 AND START_DATE < SYSDATE AND END_DATE > SYSDATE) " |
|||
+ "and li.STATUS IN (2 ,4 ,8) AND re.paid_status = 1 and li.id = re.license_id group by trade.division_id) ren on ren.ward_id=boun.id_bndry " |
|||
+ "left outer join eg_boundary@erp zone on zone.id_bndry=boun.parent " |
|||
+ "left outer join eg_boundary@erp region on region.id_bndry=zone.parent " |
|||
+ "where boun.id_bndry_type=3 and boun.name like 'N%' order by zone.name,boun.name"; |
|||
//region.name='North Region' |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlquery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,642 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" dir=""> |
|||
<html xmlns:th="http://www.thymeleaf.org"> |
|||
<head th:replace="~{fragments/modules/base/head :: head}"></head> |
|||
|
|||
<style> |
|||
.chart-container { |
|||
width: 100%; |
|||
height: 350px; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
@media (max-width: 768px) { |
|||
.chart-container { |
|||
height: 200px; /* Adjust height for mobile view */ |
|||
} |
|||
} |
|||
.highlight-red{ |
|||
color:red; |
|||
} |
|||
</style> |
|||
|
|||
<body> |
|||
<link rel="stylesheet" href="/assets/node_modules/amcharts3/amcharts/plugins/export/export.css" type="text/css" media="all" /> |
|||
<!--[if lt IE 8]> |
|||
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> |
|||
<![endif]--> |
|||
|
|||
<div class="wrapper"> |
|||
<!-- header top menu Start --> |
|||
<header th:replace="~{fragments/modules/base/header :: header}"></header> |
|||
<!-- header top menu end --> |
|||
|
|||
<div class="page-wrap"> |
|||
<!--=============== Left Menu side Start ================--> |
|||
<div th:replace="~{fragments/modules/base/menu :: menu}"></div> |
|||
<!--=============== Left side End ================--> |
|||
<div class="main-content"> |
|||
<div class="container-fluid"> |
|||
<div class="page-header mb-2"> |
|||
<div class="row align-items-end"> |
|||
<div class="col-lg-8"> |
|||
<div class="page-header-title"> |
|||
<i class="ik ik-bar-chart-2 bg-blue"></i> |
|||
<div class="d-inline"> |
|||
<h5>CM Works</h5> |
|||
<span>CM Works TradeLicense</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-lg-4"> |
|||
<nav class="breadcrumb-container" aria-label="breadcrumb"> |
|||
<ol class="breadcrumb"> |
|||
<li class="breadcrumb-item"> |
|||
<a href="index"><i class="ik ik-home"></i></a> |
|||
</li> |
|||
<li class="breadcrumb-item active" aria-current="page">TradeLicense</li> |
|||
</ol> |
|||
</nav> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<h4 class="h4 text-right text-mute" style="font-size: 12px;">Auto refresh in <font id="refresh-countdown">00</font> seconds</h4> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<div class="card sale-card"> |
|||
<div class="card-header"> |
|||
|
|||
<h3> |
|||
<i class="fas fa-chart-pie pr-2"></i><b>Trade Analysis:</b> |
|||
</h3> |
|||
</div> |
|||
<div class="card-block" style="text-align:center;"> |
|||
<div class="col-sm-12 d-flex justify-content-center align-items-center mt-10 mb-30"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 col-lg-6 mb-3" > |
|||
<label class="pr-2" for="zone1" style="font-size:large;margin-bottom: 0px;"><b>Select Zone:</b></label> |
|||
<select class="form-select custom-select" name="zone1" id="zone1" onchange="getDiv(this);"> |
|||
<option>---Select Zone---</option> |
|||
</select> |
|||
</div> |
|||
<div class="col-sm-12 col-lg-6"> |
|||
<label for="division" class="pr-2" style="font-size:large;margin-bottom: 0px;"><b>Select Ward:</b></label> |
|||
<select id="division" name="division" class="form-select custom-select"> |
|||
<option value="All">Overall Zone Wise</option> |
|||
<!-- Add options dynamically --> |
|||
</select> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
<div class="col-12"> |
|||
<h4><b><span id="license_counts" class="highlight-red"></span> </b></h4> |
|||
<h3 id="load_card" style="font-size:14px"></h3> |
|||
<div id="newLicChart" class="chart-container" style= "height:450px; width:100%;"> |
|||
</div> |
|||
</div> |
|||
<hr> |
|||
<div class="col-md-12"> |
|||
<h4><b><span id="license_amounts" class="highlight-red"></span> </b></h4> |
|||
<div id="amtChart" class="chart-container" style= "height:600px; width:100%;"></div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer> |
|||
</div> |
|||
</div> |
|||
|
|||
<div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div> |
|||
|
|||
<script th:replace="~{fragments/modules/base/script :: script}"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/amcharts.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/serial.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/plugins/export/export.min.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/pie.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/themes/light.js"></script> |
|||
|
|||
<script src="/assets/node_modules/amcharts3/amcharts/plugins/responsive/responsive.js"></script> |
|||
<script src="/assets/node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script> |
|||
|
|||
<script> |
|||
|
|||
|
|||
var loading_text_msg = getLoadingMessage(); |
|||
|
|||
const loading = $("#load_card"); |
|||
|
|||
|
|||
//This function To show the selected zone and division display in UI part |
|||
|
|||
function updateChartTitles() { |
|||
const wardSelect = document.getElementById("division"); |
|||
const selectedWard = wardSelect.options[wardSelect.selectedIndex].text; |
|||
|
|||
const lic_count = document.getElementById("license_counts"); |
|||
const lic_amt = document.getElementById("license_amounts"); |
|||
|
|||
lic_count.innerHTML = selectedWard; |
|||
lic_amt.innerHTML = selectedWard; |
|||
} |
|||
|
|||
var initialData = []; |
|||
|
|||
getZoneNo(); |
|||
|
|||
updateChart(); |
|||
|
|||
$("#zone1").change(function() { |
|||
getDiv(this); |
|||
}); |
|||
|
|||
$("#division").change(function () { |
|||
filterAndRenderCharts(); |
|||
//updateChart(); |
|||
|
|||
}); |
|||
|
|||
|
|||
//Getting Zone No |
|||
function getZoneNo() { |
|||
|
|||
$.ajax({ |
|||
type: "GET", |
|||
url: '/gcc/api/works/getZoneNo', |
|||
dataType: 'json', |
|||
success: function (bodyMessage) { |
|||
var tempJson = bodyMessage['ZoneDetailsResult']; |
|||
//alert("tempJson---:"+tempJson); |
|||
for (var i = 0; i < tempJson.length; i++) { |
|||
var tempJsonValue = tempJson[i]['ZoneId']; |
|||
//var tempJsonValue = tempJson[i]['ZoneName'].replace('N', ''); |
|||
var tempJsonLabel = tempJson[i]['ZoneName'].replace('N', ''); |
|||
$('#zone1').append("<option value='" + tempJsonValue + "'>" + tempJsonLabel + "</option>"); |
|||
} |
|||
}, error: function (e, ts, et) { |
|||
// alert(ts) |
|||
} |
|||
|
|||
}); |
|||
} |
|||
|
|||
//Getting Div |
|||
|
|||
function getDiv($this) { |
|||
|
|||
|
|||
$('#division').empty(); // Clear existing options |
|||
$('#division').append("<option value='All'>OverAll Zone Wise</option>"); // Add 'All' option |
|||
var zoneId = $this.value; |
|||
//var zone = $this.value; |
|||
//alert("zone---:"+zone); |
|||
|
|||
$.ajax({ |
|||
type: "GET", |
|||
url: '/gcc/api/works/getDiv', |
|||
data: {'zoneId': zoneId}, |
|||
dataType: 'json', |
|||
success: function (bodyMessage) { |
|||
var tempJson = bodyMessage['DivisionDetailsResult']; |
|||
for (var i = 0; i < tempJson.length; i++) |
|||
{ |
|||
var tempJsonValue = tempJson[i]['DivisionName']; |
|||
//var tempJsonValue = tempJson[i]['DivisionId']; |
|||
var tempJsonLabel = tempJson[i]['DivisionName']; |
|||
$('#division').append("<option value='" + tempJsonValue + "'>" + tempJsonLabel + "</option>"); |
|||
|
|||
} |
|||
|
|||
|
|||
}, error: function (e, ts, et) { |
|||
// alert(ts) |
|||
} |
|||
|
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
function updateChart() { |
|||
const divisionName = $("#division").val(); |
|||
//console.log("Selected region:", divisionName); |
|||
|
|||
updateChartTitles(); |
|||
// Show loading animation |
|||
loading.html(searchinfo("<b>" + loading_text_msg + "</b>")); |
|||
call_loading('newLicChart', 'amtChart', 'start'); |
|||
|
|||
// Clear existing charts |
|||
$("#newLicChart").html(""); |
|||
$("#amtChart").html(""); |
|||
|
|||
|
|||
$.ajax({ |
|||
url: '/gcc/api/works/getTradelicenseReports', // Corrected endpoint URL |
|||
type: 'GET', |
|||
data: { divisionName: divisionName }, // Send regionName parameter |
|||
success: function(response) { |
|||
//console.log('Data from API:', response); |
|||
initialData = response; |
|||
filterAndRenderCharts(); |
|||
//renderCharts(response); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching data:", error); |
|||
// Hide loading animation on error |
|||
loading.html(""); |
|||
call_loading('newLicChart', 'amtChart', 'stop'); |
|||
} |
|||
}); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
function filterAndRenderCharts() { |
|||
updateChartTitles(); |
|||
const divisionName = $("#division").val(); |
|||
//console.log("selected division",divisionName); |
|||
let filteredData = initialData; |
|||
|
|||
if (divisionName !== 'All') { |
|||
filteredData = initialData.filter(item => item.WARD === divisionName); |
|||
} |
|||
|
|||
renderCharts(filteredData); |
|||
} |
|||
|
|||
|
|||
function formatValue(value) { |
|||
if (value >= 1e9) { |
|||
return (value / 1e9).toFixed(2) + ' Billion'; |
|||
} else if (value >= 1e7) { |
|||
return (value / 1e7).toFixed(2) + ' Crore'; |
|||
} else if (value >= 1e6) { |
|||
return (value / 1e6).toFixed(2) + ' Million'; |
|||
} else if (value >= 1e5) { |
|||
return (value / 1e5).toFixed(2) + ' Lakh'; |
|||
} else if (value >= 1e4) { |
|||
return (value / 1e4).toFixed(2) + ' Thousand'; |
|||
} |
|||
return value.toFixed(2); |
|||
} |
|||
|
|||
|
|||
|
|||
function renderCharts(data) { |
|||
|
|||
if (data.length === 1 && data[0].REGION === 'All') { |
|||
// Calculate total sum for all regions |
|||
const totalNewLic = data.reduce((sum, item) => sum + item.NEW_LIC, 0); |
|||
const totalRenWithPenalty = data.reduce((sum, item) => sum + item.REN_WITH_PENALTY, 0); |
|||
const totalRenWithoutPenalty = data.reduce((sum, item) => sum + item.REN_WITH_OUT_PENALTY, 0); |
|||
const totalNonRenewed = data.reduce((sum, item) => sum + item.NON_RENEWED, 0); |
|||
const totalNewLicAmt = data.reduce((sum, item) => sum + item.NEW_LIC_AMT, 0); |
|||
const totalRenWithPenaltyAmt = data.reduce((sum, item) => sum + item.REN_WITH_PENALTY_AMT, 0); |
|||
const totalRenWithoutPenaltyAmt = data.reduce((sum, item) => sum + item.REN_WITH_OUT_PENALTY_AMT, 0); |
|||
const totalNonRenewedAmt = data.reduce((sum, item) => sum + item.NONRNWDCNTAMT, 0); |
|||
|
|||
// Create chart data for 'total counts' |
|||
const collectionsChartData = [{ |
|||
//zone: 'All', |
|||
zone: divisionName === 'All' ? 'All' : divisionName, |
|||
newLic: totalNewLic, |
|||
renWithPenalty: totalRenWithPenalty, |
|||
renWithoutPenalty: totalRenWithoutPenalty, |
|||
nonRenewed: totalNonRenewed |
|||
}]; |
|||
|
|||
// Create chart data for 'total amounts' |
|||
const amountsChartData = [{ |
|||
//zone: 'All', |
|||
zone: divisionName === 'All' ? 'All' : divisionName, |
|||
newLicamt: totalNewLicAmt, |
|||
renWithPenaltyamt: totalRenWithPenaltyAmt, |
|||
renWithoutPenaltyamt: totalRenWithoutPenaltyAmt, |
|||
nonRenewedamt: totalNonRenewedAmt |
|||
}]; |
|||
|
|||
// Render charts |
|||
renderColumnChart("newLicChart", collectionsChartData); |
|||
renderColumnChartAmt("amtChart", amountsChartData, ); |
|||
|
|||
|
|||
|
|||
} else { |
|||
// Group data by zone and calculate totals |
|||
const zoneData = data.reduce((acc, item) => { |
|||
if (!acc[item.ZONE]) { |
|||
acc[item.ZONE] = { |
|||
newLic: 0, |
|||
renWithPenalty: 0, |
|||
renWithoutPenalty: 0, |
|||
nonRenewed: 0, |
|||
newLicamt: 0, |
|||
renWithPenaltyamt: 0, |
|||
renWithoutPenaltyamt: 0, |
|||
nonRenewedamt: 0 |
|||
}; |
|||
} |
|||
acc[item.ZONE].newLic += item.NEW_LIC; |
|||
acc[item.ZONE].renWithPenalty += item.REN_WITH_PENALTY; |
|||
acc[item.ZONE].renWithoutPenalty += item.REN_WITH_OUT_PENALTY; |
|||
acc[item.ZONE].nonRenewed += item.NON_RENEWED; |
|||
acc[item.ZONE].newLicamt += item.NEW_LIC_AMT; |
|||
acc[item.ZONE].renWithPenaltyamt += item.REN_WITH_PENALTY_AMT; |
|||
acc[item.ZONE].renWithoutPenaltyamt += item.REN_WITH_OUT_PENALTY_AMT; |
|||
acc[item.ZONE].nonRenewedamt += item.NONRNWDCNTAMT; |
|||
return acc; |
|||
}, {}); |
|||
|
|||
// Convert to array format for charts |
|||
const collectionsChartData = Object.keys(zoneData).map(zone => ({ |
|||
zone: zone, |
|||
newLic: zoneData[zone].newLic, |
|||
renWithPenalty: zoneData[zone].renWithPenalty, |
|||
renWithoutPenalty: zoneData[zone].renWithoutPenalty, |
|||
nonRenewed: zoneData[zone].nonRenewed |
|||
})); |
|||
|
|||
const amountsChartData = Object.keys(zoneData).map(zone => ({ |
|||
zone: zone, |
|||
newLicamt: zoneData[zone].newLicamt, |
|||
renWithPenaltyamt: zoneData[zone].renWithPenaltyamt, |
|||
renWithoutPenaltyamt: zoneData[zone].renWithoutPenaltyamt, |
|||
nonRenewedamt: zoneData[zone].nonRenewedamt |
|||
})); |
|||
|
|||
// Render charts |
|||
renderColumnChart("newLicChart", collectionsChartData); |
|||
renderColumnChartAmt("amtChart", amountsChartData, ); |
|||
|
|||
|
|||
} |
|||
|
|||
loading.html(""); |
|||
call_loading('newLicChart', 'amtChart', 'stop'); |
|||
} |
|||
|
|||
|
|||
|
|||
function renderColumnChart(elementId, chartData) { |
|||
AmCharts.makeChart(elementId, { |
|||
"type": "serial", |
|||
"theme": "light", |
|||
"dataProvider": chartData, |
|||
"startEffect":"easeOutSine", |
|||
"startDuration": 1, |
|||
"valueAxes": [{ |
|||
"id": "v1", |
|||
"position": "left", |
|||
"autoGridCount": false, |
|||
"labelFunction": function (value) { |
|||
return value; |
|||
} |
|||
}], |
|||
"graphs": [ |
|||
{ |
|||
"id": "g1", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#2ed8b6", |
|||
"fillColors": "#2ed8b6", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
"title": "New License", |
|||
"valueField": "newLic", |
|||
"labelPosition":"right", |
|||
"labelRotation": 270, |
|||
"labelText":"[[[[value]]]]", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
}, |
|||
{ |
|||
"id": "g2", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#F22613", |
|||
"fillColors": "#F22613", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
"title": "Rent With Penalty", |
|||
"valueField": "renWithPenalty", |
|||
"labelPosition":"right", |
|||
"labelRotation": 270, |
|||
"labelText":"[[[[value]]]]", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
}, |
|||
{ |
|||
"id": "g3", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#FFC107", |
|||
"fillColors": "#FFC107", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
"title": "Rent Without Penalty", |
|||
"valueField": "renWithoutPenalty", |
|||
"labelPosition":"top", |
|||
"labelRotation": 270, |
|||
"labelText":"[[[[value]]]]", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
}, |
|||
{ |
|||
"id": "g4", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#8E44AD", |
|||
"fillColors": "#8E44AD", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
"title": "Non Renewed", |
|||
"valueField": "nonRenewed", |
|||
"labelPosition":"right", |
|||
"labelRotation": 270, |
|||
"labelText":"[[[[value]]]]", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
} |
|||
], |
|||
"chartCursor": { |
|||
"pan": true, |
|||
"valueLineEnabled": true, |
|||
"valueLineBalloonEnabled": true, |
|||
"cursorAlpha": 0, |
|||
"valueLineAlpha": 0.2 |
|||
}, |
|||
"categoryField": "zone", |
|||
"categoryAxis": { |
|||
"gridPosition": "start", |
|||
"axisAlpha": 0, |
|||
"tickLength": 0 |
|||
}, |
|||
"legend": { |
|||
"useGraphSettings": true, |
|||
"position": "bottom", |
|||
"spacing":350, |
|||
"markerType":"diamond" |
|||
}, |
|||
"balloon": { |
|||
"borderThickness": 2, |
|||
"shadowAlpha": 0 |
|||
}, |
|||
"export": { |
|||
"enabled": true, |
|||
"position":"top-right" |
|||
}, |
|||
"titles": [{ |
|||
"text": "Trade License collection Chart", |
|||
"size": 20 |
|||
}], |
|||
|
|||
}); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
function renderColumnChartAmt(elementId,chartData) { |
|||
AmCharts.makeChart(elementId, { |
|||
"type": "serial", |
|||
"theme": "light", |
|||
"dataProvider": chartData, |
|||
"startEffect":"easeOutSine", |
|||
"startDuration": 1, |
|||
"valueAxes": [{ |
|||
"id": "v1", |
|||
"position": "left", |
|||
"gridAlpha":0, |
|||
"autoGridCount": false, |
|||
"labelFunction": function (value) { |
|||
return formatValue(value); |
|||
} |
|||
}], |
|||
"graphs": [ |
|||
{ |
|||
"id": "g1", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#2ed8b6", |
|||
"fillColors": "#2ed8b6", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
//"columnWidth":0.9, |
|||
"title": "New License Amt", |
|||
"valueField": "newLicamt", |
|||
"labelText":"[[[[value]]]]", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
"labelFunction": function(graphDataItem) { |
|||
return formatValue(graphDataItem.values.value); |
|||
}, |
|||
"labelPosition":"right", |
|||
"labelRotation": 270, |
|||
"balloonFunction": function(graphDataItem, graph) { |
|||
return "<b>" + graph.title + "</b><br />" + formatValue(graphDataItem.values.value); |
|||
} |
|||
}, |
|||
{ |
|||
"id": "g2", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#F22613", |
|||
"fillColors": "#F22613", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
//"columnWidth":0.9, |
|||
"title": "Rent With Penalty Amt", |
|||
"valueField": "renWithPenaltyamt", |
|||
"labelText":"[[[[value]]]]", |
|||
"labelPosition":"right", |
|||
"labelFunction": function(graphDataItem) { |
|||
return formatValue(graphDataItem.values.value); |
|||
}, |
|||
"labelRotation": 270, |
|||
"balloonFunction": function(graphDataItem, graph) { |
|||
return "<b>" + graph.title + "</b><br />" + formatValue(graphDataItem.values.value); |
|||
}, |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
}, |
|||
{ |
|||
"id": "g3", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#FFC107", |
|||
"fillColors": "#FFC107", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
// "columnWidth":0.9, |
|||
"title": "Rent Without Penalty Amt", |
|||
"valueField": "renWithoutPenaltyamt", |
|||
"labelText":"[[[[value]]]]", |
|||
"labelPosition":"top", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
"labelFunction": function(graphDataItem) { |
|||
return formatValue(graphDataItem.values.value); |
|||
}, |
|||
"labelRotation": 270, |
|||
"balloonFunction": function(graphDataItem, graph) { |
|||
return "<b>" + graph.title + "</b><br />" + formatValue(graphDataItem.values.value); |
|||
} |
|||
}, |
|||
{ |
|||
"id": "g4", |
|||
"valueAxis": "v1", |
|||
"lineColor": "#8E44AD", |
|||
"fillColors": "#8E44AD", |
|||
"type": "column", |
|||
"fillAlphas": 0.8, |
|||
//"columnWidth":0.9, |
|||
"title": "Non Renewed Amt", |
|||
"valueField": "nonRenewedamt", |
|||
"labelText":"[[[[value]]]]", |
|||
"labelPosition":"right", |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
"labelFunction": function(graphDataItem) { |
|||
return formatValue(graphDataItem.values.value); |
|||
}, |
|||
"labelRotation": 270, |
|||
"balloonFunction": function(graphDataItem, graph) { |
|||
return "<b>" + graph.title + "</b><br />" + formatValue(graphDataItem.values.value); |
|||
} |
|||
} |
|||
], |
|||
//"rotate":true, |
|||
"chartCursor": { |
|||
"pan": true, |
|||
"valueLineEnabled": true, |
|||
"valueLineBalloonEnabled": true, |
|||
"cursorAlpha": 0, |
|||
"valueLineAlpha": 0.2 |
|||
}, |
|||
"categoryField": "zone", |
|||
"categoryAxis": { |
|||
"gridPosition": "start", |
|||
//"axisAlpha": 0, |
|||
"tickLength": 0 |
|||
}, |
|||
"legend": { |
|||
"useGraphSettings": true, |
|||
"position": "bottom", |
|||
"spacing":350, |
|||
"markerType":"diamond", |
|||
"valueWidth":100, |
|||
"labelWidth":100 |
|||
}, |
|||
"balloon": { |
|||
"borderThickness": 2, |
|||
"shadowAlpha": 0 |
|||
}, |
|||
"export": { |
|||
"enabled": true, |
|||
"position":"top-right" |
|||
}, |
|||
"titles": [{ |
|||
"text": "Trade License Amount Chart", |
|||
"size": 20 |
|||
}], |
|||
|
|||
}); |
|||
} |
|||
|
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,127 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmdashboard.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpEntity; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.HttpMethod; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
|
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cmdashboard.service.CmDashboardService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
|
|||
@RequestMapping("/gcc/api/cmdashboard") |
|||
@RestController("cmdashboard") |
|||
public class APIController |
|||
{ |
|||
private CmDashboardService cmdashboards; |
|||
|
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public APIController(CmDashboardService cmdashboards) { |
|||
this.cmdashboards = cmdashboards; |
|||
} |
|||
|
|||
@GetMapping(value = "/getCmDashboardReports") |
|||
public List getCombinedCmDashboardReports(@RequestParam("zonename") String zonename) { |
|||
|
|||
return cmdashboards.getCombinedCmDashboardReports(zonename); |
|||
} |
|||
|
|||
@GetMapping(value = "/getCmDashboardAllReports") |
|||
public List getCmDashboardAllReports() { |
|||
|
|||
return cmdashboards.getCmDashboardAllReports(); |
|||
} |
|||
|
|||
@GetMapping(value = "/getRegionCounts") |
|||
public List<Map<String, Object>> getRegionCounts() { |
|||
return cmdashboards.getRegionCounts(); |
|||
} |
|||
|
|||
@GetMapping(value = "/getZoneCounts") |
|||
public List<Map<String, Object>> getZoneCounts() { |
|||
return cmdashboards.getZoneCounts(); |
|||
} |
|||
|
|||
@GetMapping(value = "/getSchemeDetails") |
|||
public Map<String, Object> getSchemeDetails(@RequestParam("schemename") String schemename, @RequestParam("zonename") String zonename) { |
|||
return cmdashboards.getSchemeDetails(schemename, zonename); |
|||
} |
|||
|
|||
@GetMapping(value="/getTypeOfWorkDetails") |
|||
public Map<String, Object> getTypeOfWorkDetails(@RequestParam("typeofwork") String typeofwork, @RequestParam("zonename") String zonename){ |
|||
return cmdashboards.getTypeOfWorkDetails(typeofwork, zonename); |
|||
} |
|||
|
|||
@GetMapping(value="/getRegionzones") |
|||
public Map<String,Object> getRegionsZonesDetails(@RequestParam("regionname") String regionname){ |
|||
return cmdashboards.getRegionDetails(regionname); |
|||
} |
|||
|
|||
@GetMapping("/all-list/{id}") |
|||
public Map<String, Object> getCMDetails(@PathVariable int id) |
|||
{ |
|||
return cmdashboards.getCMDetails(id); |
|||
} |
|||
|
|||
// Rest Api From ERP |
|||
// @GetMapping(value = "/getZoneNo") |
|||
// public String getZoneNo() { |
|||
// |
|||
// String urlString = appConfig.getErpUrl()+"serviceId=getZones"; |
|||
// ResponseEntity<String> response = null; |
|||
// RestTemplate restTemplate = new RestTemplate(); |
|||
// String bodyMessage = ""; |
|||
// HttpHeaders headers = new HttpHeaders(); |
|||
// try { |
|||
// HttpEntity<String> postData = new HttpEntity<String>(headers); |
|||
// response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); |
|||
// bodyMessage = response.getBody(); |
|||
// //System.out.println("BodyMessage" + bodyMessage); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// //System.out.print("\n ERROR---: " + e); |
|||
// bodyMessage = "Error"; |
|||
// } |
|||
// return bodyMessage; |
|||
// } |
|||
// |
|||
// @GetMapping(value = "/getDiv") |
|||
// public String getDiv(@RequestParam String zoneId) { |
|||
// String urlString = appConfig.getErpUrl()+"serviceId=getWards&Zoneid="+zoneId+""; |
|||
// ResponseEntity<String> response = null; |
|||
// RestTemplate restTemplate = new RestTemplate(); |
|||
// String bodyMessage = ""; |
|||
// HttpHeaders headers = new HttpHeaders(); |
|||
// try { |
|||
// HttpEntity<String> postData = new HttpEntity<String>(headers); |
|||
// response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); |
|||
// bodyMessage = response.getBody(); |
|||
// //System.out.println("bodyMessage" + bodyMessage); |
|||
// |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// //System.out.print("\n ERROR---: " + e); |
|||
// bodyMessage = "Error"; |
|||
// } |
|||
// return bodyMessage; |
|||
// } |
|||
|
|||
} |
|||
@ -0,0 +1,166 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmdashboard.service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class CmDashboardService { |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysqlAppDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCombinedCmDashboardReports(String zonename) { |
|||
String sqlQuery; |
|||
Object[] params; |
|||
|
|||
if (zonename != null && !zonename.equalsIgnoreCase("all")) { |
|||
sqlQuery = "SELECT cm.schemename AS name, " + "COUNT(*) AS count, " + "'Scheme' AS type " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.zonename = ? " + "GROUP BY cm.schemename " + "UNION ALL " |
|||
+ "SELECT cm.typeofwork AS name, " + "COUNT(*) AS count, " + "'TypeOfWork' AS type " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.zonename = ? " + "GROUP BY cm.typeofwork"; |
|||
params = new Object[] { zonename, zonename }; |
|||
} else { |
|||
sqlQuery = "SELECT cm.schemename AS name, " + "COUNT(*) AS count, " + "'Scheme' AS type " |
|||
+ "FROM gcc_apps.mytable cm " + "GROUP BY cm.schemename " + "UNION ALL " |
|||
+ "SELECT cm.typeofwork AS name, " + "COUNT(*) AS count, " + "'TypeOfWork' AS type " |
|||
+ "FROM gcc_apps.mytable cm " + "GROUP BY cm.typeofwork"; |
|||
params = new Object[] {}; |
|||
} |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, params); |
|||
} |
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getRegionCounts() { |
|||
String sqlQuery = "SELECT regionname, COUNT(*) AS region_count FROM gcc_apps.mytable GROUP BY regionname"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getZoneCounts() { |
|||
String sqlQuery = "SELECT zonename, COUNT(*) AS zone_count FROM gcc_apps.mytable GROUP BY zonename"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public Map<String, Object> getRegionDetails(String regionname) { |
|||
|
|||
String sqlQuery = "SELECT SUM(cm.valueofwork) AS totalValueOfWork, COUNT(*) AS totalWorkCounts " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.regionname = ? "; |
|||
|
|||
Object[] params = new Object[] { regionname }; |
|||
|
|||
Map<String, Object> regiondetails = jdbcTemplate.queryForMap(sqlQuery, params); |
|||
|
|||
String sqlQueryRegionZone = "SELECT zonename AS name, " + |
|||
"COUNT(*) AS regionszones_count, " + |
|||
"SUM(valueofwork) AS totalValueOfWork, " + |
|||
"COUNT(*) AS totalWorkCounts " + |
|||
"FROM gcc_apps.mytable " + |
|||
"WHERE regionname = ? " + |
|||
"GROUP BY zonename;"; |
|||
|
|||
List<Map<String, Object>> regionzonedetails = jdbcTemplate.queryForList(sqlQueryRegionZone, params); |
|||
regiondetails.put("regionzonedetails", regionzonedetails); |
|||
|
|||
return regiondetails; |
|||
} |
|||
|
|||
@Transactional |
|||
public Map<String, Object> getSchemeDetails(String schemename, String zonename) { |
|||
String sqlQuery = "SELECT SUM(cm.valueofwork) AS totalValueOfWork, COUNT(*) AS totalWorkCounts " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.schemename = ? " |
|||
+ (zonename != null && !zonename.equalsIgnoreCase("all") ? " AND cm.zonename = ?" : ""); |
|||
|
|||
Object[] params = zonename != null && !zonename.equalsIgnoreCase("all") ? new Object[] { schemename, zonename } |
|||
: new Object[] { schemename }; |
|||
|
|||
Map<String, Object> schemeDetails = jdbcTemplate.queryForMap(sqlQuery, params); |
|||
|
|||
String sqlQueryTypeOfWork = "SELECT cm.typeofwork AS name, COUNT(*) AS count, SUM(cm.valueofwork) AS totalValueOfWork " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.schemename = ? " |
|||
+ (zonename != null && !zonename.equalsIgnoreCase("all") ? " AND cm.zonename = ?" : "") |
|||
+ "GROUP BY cm.typeofwork"; |
|||
|
|||
List<Map<String, Object>> typeOfWorkDetails = jdbcTemplate.queryForList(sqlQueryTypeOfWork, params); |
|||
|
|||
schemeDetails.put("typeOfWorkDetails", typeOfWorkDetails); |
|||
|
|||
return schemeDetails; |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public Map<String, Object> getTypeOfWorkDetails(String typeofwork, String zonename) { |
|||
String sqlQuery = "SELECT SUM(cm.valueofwork) AS totalValueOfWork, COUNT(*) AS totalWorkCounts " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.typeofwork = ? " |
|||
+ (zonename != null && !zonename.equalsIgnoreCase("all") ? " AND cm.zonename = ?" : ""); |
|||
Object[] params = zonename != null && !zonename.equalsIgnoreCase("all") ? new Object[] { typeofwork, zonename } |
|||
: new Object[] { typeofwork }; |
|||
|
|||
Map<String, Object> typeOfWorkDetail = jdbcTemplate.queryForMap(sqlQuery, params); |
|||
|
|||
String sqlQueryTypeOfWork = "SELECT cm.schemename AS name, COUNT(*) AS count, SUM(cm.valueofwork) AS totalValueOfWork " |
|||
+ "FROM gcc_apps.mytable cm " + "WHERE cm.typeofwork = ? " |
|||
+ (zonename != null && !zonename.equalsIgnoreCase("all") ? " AND cm.zonename = ?" : "") |
|||
+ "GROUP BY cm.schemename"; |
|||
|
|||
List<Map<String, Object>> schemeNameDetails = jdbcTemplate.queryForList(sqlQueryTypeOfWork, params); |
|||
|
|||
typeOfWorkDetail.put("schemeNameDetails", schemeNameDetails); |
|||
|
|||
return typeOfWorkDetail; |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getCmDashboardAllReports() { |
|||
String sqlQuery = "SELECT * FROM gcc_apps.mytable"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public Map<String, Object> getCMDetails(int id) { |
|||
String sql = "SELECT * FROM gcc_apps.mytable WHERE data_id = ?"; |
|||
return jdbcTemplate.queryForMap(sql, id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCmDashboardAllReportsFiltered(String zonename, String schemename, String typeofwork) { |
|||
String sqlQuery = "SELECT * FROM gcc_apps.mytable WHERE 1=1"; |
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (zonename != null && !zonename.equalsIgnoreCase("all")) { |
|||
sqlQuery += " AND zonename = ?"; |
|||
params.add(zonename); |
|||
} |
|||
if (schemename != null && !schemename.equalsIgnoreCase("all")) { |
|||
sqlQuery += " AND schemename = ?"; |
|||
params.add(schemename); |
|||
} |
|||
if (typeofwork != null && !typeofwork.equalsIgnoreCase("all")) { |
|||
sqlQuery += " AND typeofwork = ?"; |
|||
params.add(typeofwork); |
|||
} |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, params.toArray()); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cmdashboard.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cmdashboard.service.CmDashboardService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/dashboards") |
|||
@Controller("cmdashboardcontroller") |
|||
public class MainController |
|||
{ |
|||
private final LoginUserInfo loginUserInfo; |
|||
private final CmDashboardService cmdashboards; |
|||
|
|||
@Autowired |
|||
public MainController(LoginUserInfo loginUserInfo, CmDashboardService cmdashboards) |
|||
{ |
|||
this.cmdashboards=cmdashboards; |
|||
this.loginUserInfo=loginUserInfo; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/dashboard1") |
|||
public String main(Model model) { |
|||
String userId = LoginUserInfo.getLoginUserId(); |
|||
if (userId != null && !userId.isEmpty()) { |
|||
System.out.println("String UserID: " + userId); |
|||
} |
|||
|
|||
return "modules/cmdashboard/index"; |
|||
} |
|||
|
|||
@GetMapping("/dashboard2") |
|||
public String viewpage(@RequestParam(value = "zonename", required = false, defaultValue = "all") String zonename, Model model) { |
|||
// Fetch data for the dashboard based on the regionname |
|||
List<Map<String, Object>> regionData = cmdashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> schemeData = cmdashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> typeOfWorkData = cmdashboards.getCombinedCmDashboardReports(zonename); |
|||
List<Map<String, Object>> zoneData = cmdashboards.getCombinedCmDashboardReports(zonename); |
|||
|
|||
// Add data to the model |
|||
model.addAttribute("regionData", regionData); |
|||
model.addAttribute("schemeData", schemeData); |
|||
model.addAttribute("typeOfWorkData", typeOfWorkData); |
|||
model.addAttribute("zoneData", zoneData); |
|||
|
|||
String userId = LoginUserInfo.getLoginUserId(); |
|||
if (userId != null && !userId.isEmpty()) { |
|||
System.out.println("String UserID: " + userId); |
|||
} |
|||
|
|||
return "modules/cmdashboard/index1"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/all-list") |
|||
public String allList(@RequestParam(value = "zonename", required = false, defaultValue = "all") String zonename, |
|||
@RequestParam(value = "schemename", required = false, defaultValue = "all") String schemename, |
|||
@RequestParam(value = "typeofwork", required = false, defaultValue = "all") String typeofwork, |
|||
Model model) { |
|||
List<Map<String, Object>> cmLists = cmdashboards.getCmDashboardAllReportsFiltered(zonename, schemename, typeofwork); |
|||
model.addAttribute("cmlist", cmLists); |
|||
return "modules/cmdashboard/alldetails"; |
|||
} |
|||
|
|||
@GetMapping("/dashboard3") |
|||
public String view(Model model) { |
|||
String userId = LoginUserInfo.getLoginUserId(); |
|||
if (userId != null && !userId.isEmpty()) { |
|||
System.out.println("String UserID: " + userId); |
|||
} |
|||
|
|||
return "modules/cmdashboard/index2"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,434 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head th:replace="~{fragments/modules/base/head :: head}"></head> |
|||
<style> |
|||
|
|||
.form-group { |
|||
margin-bottom: 20px; /* Add space between form groups */ |
|||
} |
|||
|
|||
.form-select.custom-select { |
|||
width: 100%; /* Ensure select elements take full width of their container */ |
|||
} |
|||
</style> |
|||
<body> |
|||
<div class="wrapper"> |
|||
<!-- Header --> |
|||
<header th:replace="~{fragments/modules/base/header :: header}"></header> |
|||
|
|||
<div class="page-wrap"> |
|||
<!-- Left Menu --> |
|||
<div th:replace="~{fragments/modules/base/menu :: menu}"></div> |
|||
|
|||
<div class="main-content"> |
|||
<div class="container-fluid"> |
|||
<div class="page-header"> |
|||
<div class="row align-items-end"> |
|||
<div class="col-lg-8"> |
|||
<div class="page-header-title"> |
|||
<i class="fas fa-th-large bg-blue"></i> |
|||
<div class="d-inline"> |
|||
<h5>CM Dashboard</h5> |
|||
<span>All Details</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-lg-4"> |
|||
<nav class="breadcrumb-container" aria-label="breadcrumb"> |
|||
<ol class="breadcrumb"> |
|||
<li class="breadcrumb-item"><a href="/index"><i class="ik ik-home"></i></a></li> |
|||
<li class="breadcrumb-item">CM Dashboard</li> |
|||
<li class="breadcrumb-item active" aria-current="page">All Details</li> |
|||
</ol> |
|||
</nav> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<hr> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<div class="card"> |
|||
<div class="card-header"> |
|||
<div class="row"> |
|||
<div class="col-md-4"> |
|||
<div class="form-group"> |
|||
<label for="zone-select"><b>Zone Name:</b></label> |
|||
<select id="zone-select" class="form-select custom-select"> |
|||
<option value="all">--All--</option> |
|||
<option value="B-Buildings">B-Buildings</option> |
|||
<option value="BR-Bus Route Roads">BR-Bus Route Roads</option> |
|||
<option value="D-Storm Water Drains">D-Storm Water Drains</option> |
|||
<option value="J-Bridges">J-Bridges</option> |
|||
<option value="L-Electrical">L-Electrical</option> |
|||
<option value="P-Parks and Playfields">P-Parks and Playfields</option> |
|||
<option value="Q-Solid Waste Management">Q-Solid Waste Management</option> |
|||
<option value="SP-SPECIAL PROJECTS">SP-SPECIAL PROJECTS</option> |
|||
<option value="01 - NA-THIRUVOTTIYUR">01 - NA-THIRUVOTTIYUR</option> |
|||
<option value="02 - NB-MANALI">02 - NB-MANALI</option> |
|||
<option value="03 - NC-MADHAVARAM">03 - NC-MADHAVARAM</option> |
|||
<option value="04 - ND-TONDIARPET">04 - ND-TONDIARPET</option> |
|||
<option value="05 - NE-ROYAPURAM">05 - NE-ROYAPURAM</option> |
|||
<option value="06 - NF-THIRU-VI-KA NAGAR">06 - NF-THIRU-VI-KA NAGAR</option> |
|||
<option value="07 - NG-AMBATTUR">07 - NG-AMBATTUR</option> |
|||
<option value="08 - NH-ANNA NAGAR">08 - NH-ANNA NAGAR</option> |
|||
<option value="09 - NJ-TEYNAMPET">09 - NJ-TEYNAMPET</option> |
|||
<option value="10 - NK-KODAMBAKKAM">10 - NK-KODAMBAKKAM</option> |
|||
<option value="11 - NL-VALASARAVAKKAM">11 - NL-VALASARAVAKKAM</option> |
|||
<option value="12 - NM-ALANDUR">12 - NM-ALANDUR</option> |
|||
<option value="13 - NN-ADYAR">13 - NN-ADYAR</option> |
|||
<option value="14 - NP-PERUNGUDI">14 - NP-PERUNGUDI</option> |
|||
<option value="15 - NQ-SHOZHINGANALLUR">15 - NQ-SHOZHINGANALLUR</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<div class="form-group"> |
|||
<label for="scheme-select"><b>Scheme Name:</b></label> |
|||
<select id="scheme-select" class="form-select custom-select"> |
|||
<option value="all">--All--</option> |
|||
<option value="CAPITAL GRANT FUND">CAPITAL GRANT FUND</option> |
|||
<option value="CHENNAI MEGA CITY DEVELOPMENT MISSION">CHENNAI MEGA CITY DEVELOPMENT MISSION</option> |
|||
<option value="HEALTH BUILDINGS-NUHM">HEALTH BUILDINGS-NUHM</option> |
|||
<option value="NULM - NIGHT SHELTER (SPL)">NULM - NIGHT SHELTER (SPL)</option> |
|||
<option value="Own Source Fund">Own Source Fund</option> |
|||
<option value="SMART CITY">SMART CITY</option> |
|||
<option value="SMART CITY-SPECIAL PROJECT">SMART CITY-SPECIAL PROJECT</option> |
|||
<option value="SWACHH BHARAT MISSION">SWACHH BHARAT MISSION</option> |
|||
<option value="TURIF - 2020-2021">TURIF - 2020-2021</option> |
|||
<option value="TURIF (2018-2019)">TURIF (2018-2019)</option> |
|||
<option value="TURIF (2019-2020)">TURIF (2019-2020)</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<div class="form-group"> |
|||
<label for="work-select"><b>Type of Work Name:</b></label> |
|||
<select id="work-select" class="form-select custom-select"> |
|||
<option value="all">--All--</option> |
|||
<option value="Bridges">Bridges</option> |
|||
<option value="Buildings">Buildings</option> |
|||
<option value="Culvert">Culvert</option> |
|||
<option value="Electrical">Electrical</option> |
|||
<option value="Flyovers">Flyovers</option> |
|||
<option value="Footpath">Footpath</option> |
|||
<option value="Overbridges">Overbridges</option> |
|||
<option value="Parks">Parks</option> |
|||
<option value="Playfields">Playfields</option> |
|||
<option value="Road Cut Restoration">Road Cut Restoration</option> |
|||
<option value="Roads">Roads</option> |
|||
<option value="Storm Water Drain">Storm Water Drain</option> |
|||
<option value="Subway">Subway</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="card-block"> |
|||
<div> |
|||
<table id="worksDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid" width="99.5%"> |
|||
<thead class="thead-dark"> |
|||
<tr role="row"> |
|||
<th>S.No</th> |
|||
<th>EST ID</th> |
|||
<th>Region Name</th> |
|||
<th>Zone Name</th> |
|||
<th>Scheme Name</th> |
|||
<th>Category of Work</th> |
|||
<th>Type of Work</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr th:each="cmlistinfo, i : ${cmlist}"> |
|||
<td th:text="${i.count}">0</td> |
|||
<td> |
|||
<a style="color: blue;" href="javascript:void(0)" th:onclick="'showModal(' + ${cmlistinfo.data_id} + ')'" |
|||
th:text="${cmlistinfo.abs_est_number}"></a> |
|||
</td> |
|||
<td th:text="${cmlistinfo.regionname}"></td> |
|||
<td th:text="${cmlistinfo.zonename}"></td> |
|||
<td th:text="${cmlistinfo.schemename}"></td> |
|||
<td th:text="${cmlistinfo.workcategory}"></td> |
|||
<td th:text="${cmlistinfo.typeofwork}"></td> |
|||
</tr> |
|||
</tbody> |
|||
<tfoot class="thead-dark"> |
|||
<tr> |
|||
<th>S.No</th> |
|||
<th>EST ID</th> |
|||
<th>Region Name</th> |
|||
<th>Zone Name</th> |
|||
<th>Scheme Name</th> |
|||
<th>Category of Work</th> |
|||
<th>Type of Work</th> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Modal --> |
|||
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="detailModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"> |
|||
<div class="modal-dialog modal-lg" role="document"> |
|||
<div class="modal-content"> |
|||
<div class="modal-header"> |
|||
<h5 class="modal-title" id="detailModalLabel"><span id="modal_abs_est_number"></span></h5> |
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<table class="table table-striped table-bordered"> |
|||
<tbody> |
|||
<tr><th>Name of Work</th><td id="modal_nameofwork"></td></tr> |
|||
<tr><th>Region Name</th><td id="modal_regionname"></td></tr> |
|||
<tr><th>Zone Name</th><td id="modal_zonename"></td></tr> |
|||
<tr><th>Ward Name</th><td id="modal_wardname"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Agreement Details:</span></thead> |
|||
<tbody> |
|||
<tr><th>Administration Sanctioned</th><td id="modal_administrationsanctioned"></td></tr> |
|||
<tr><th>Agreement Date</th><td id="modal_agreementdate"></td></tr> |
|||
<tr><th>Agreement Period</th><td id="modal_agreementperiod"></td></tr> |
|||
<tr><th>Council Resolution Date</th><td id="modal_councilresolutiondate"></td></tr> |
|||
<tr><th>LOA Issued</th><td id="modal_loaissued"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Scheme Details:</span></thead> |
|||
<tbody> |
|||
<tr><th>Scheme Name</th><td id="modal_schemename"></td></tr> |
|||
<tr><th>Technical Sanction Date</th><td id="modal_technicalsanctiondate"></td></tr> |
|||
<tr><th>Technical Bid Finalized</th><td id="modal_technicalbidfinalized"></td></tr> |
|||
<tr><th>Tender Announced</th><td id="modal_tenderannounced"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Work Category Details:</span></thead> |
|||
<tbody> |
|||
<tr><th>Work Category</th><td id="modal_workcategory"></td></tr> |
|||
<tr><th>Work Commenced</th><td id="modal_workcommenced"></td></tr> |
|||
<tr><th>Work Order Issued</th><td id="modal_workorderissued"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Completed Date Wise Details:</span></thead> |
|||
<tbody> |
|||
<tr><th>Completed Date 25%</th><td id="modal_completeddate_25_percent"></td></tr> |
|||
<tr><th>Completed Date 50%</th><td id="modal_completeddate_50_percent"></td></tr> |
|||
<tr><th>Completed Date 75%</th><td id="modal_completeddate_75_percent"></td></tr> |
|||
<tr><th>Completed Date 100%</th><td id="modal_completeddate_100_percent"></td></tr> |
|||
<tr><th>Completion Report Date</th><td id="modal_completionreportdate"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Payment Details:</span></thead> |
|||
<tbody> |
|||
<tr><th>Type of Work</th><td id="modal_typeofwork"></td></tr> |
|||
<tr><th>Value of Work</th><td>Rs.<span id="modal_valueofwork"></span></td></tr> |
|||
<tr><th>Price Bid Finalize Date</th><td id="modal_pricebidfinalized"></td></tr> |
|||
<tr><th>Paymentfully Settled Date</th><td id="modal_paymentfullysettleddate"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead><span style="font-weight: bold;color: red; font-size: 20px;">Image:</span></thead> |
|||
<tbody> |
|||
<tr><td><img id="modal_workimage" src="" alt="Work Image" style="width:100%;"></td></tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<div class="modal-footer"> |
|||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Include jQuery and Bootstrap JavaScript --> |
|||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> |
|||
|
|||
<script th:replace="~{fragments/modules/base/script :: script}"></script> |
|||
<script type="text/javascript"> |
|||
$(document).ready(function() { |
|||
|
|||
var table = $('#worksDatatable').DataTable({ |
|||
dom: 'Bftip', |
|||
columnDefs: [ |
|||
{ targets: 'no-sort', orderable: false } |
|||
], |
|||
lengthMenu: [ |
|||
[50, 100, 200, 500, -1], |
|||
['50 rows', '100 rows', '200 rows', 'Show all'] |
|||
], |
|||
scrollY: '50vh', |
|||
fixedColumns: { |
|||
left: 1, |
|||
right: 1 |
|||
}, |
|||
buttons: [ |
|||
{ |
|||
extend: 'pageLength', |
|||
className: 'btn btn-warning' |
|||
}, |
|||
{ |
|||
title: 'Data export', |
|||
extend: 'copyHtml5', |
|||
text: 'Copy', |
|||
className: 'btn btn-secondary', |
|||
id: 'copyBtn' |
|||
}, |
|||
{ |
|||
extend: 'excelHtml5', |
|||
text: 'Excel', |
|||
className: 'btn btn-secondary', |
|||
id: 'excelBtn' |
|||
}, |
|||
{ |
|||
extend: 'csvHtml5', |
|||
text: 'CSV', |
|||
className: 'btn btn-secondary', |
|||
id: 'csvBtn' |
|||
}, |
|||
{ |
|||
extend: 'pdfHtml5', |
|||
text: 'PDF', |
|||
className: 'btn btn-secondary', |
|||
id: 'pdfBtn' |
|||
} |
|||
], |
|||
fixedHeader: true, |
|||
autoWidth: true, |
|||
responsive: true, |
|||
searching: false, |
|||
select: false, |
|||
processing: false |
|||
}); |
|||
|
|||
function getUrlParameter(name) { |
|||
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); |
|||
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); |
|||
var results = regex.exec(location.search); |
|||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); |
|||
} |
|||
|
|||
// Get URL parameters |
|||
let zoneParam = getUrlParameter('zonename'); |
|||
let schemeParam = getUrlParameter('schemename'); |
|||
let workParam = getUrlParameter('typeofwork'); |
|||
|
|||
// Set the dropdown values if parameters exist |
|||
if (zoneParam) { |
|||
$('#zone-select').val(zoneParam); |
|||
} |
|||
if (schemeParam) { |
|||
$('#scheme-select').val(schemeParam); |
|||
} |
|||
if (workParam) { |
|||
$('#work-select').val(workParam); |
|||
} |
|||
|
|||
// Trigger the DataTable filter |
|||
$('#zone-select, #scheme-select, #work-select').trigger('change'); |
|||
|
|||
// Custom filter function |
|||
$.fn.dataTable.ext.search.push( |
|||
function(settings, data, dataIndex) { |
|||
let zoneValue = $('#zone-select').val(); |
|||
let schemeValue = $('#scheme-select').val(); |
|||
let workValue = $('#work-select').val(); |
|||
|
|||
let zoneText = data[3]; // Index of zone column |
|||
let schemeText = data[4]; // Index of scheme column |
|||
let workText = data[6]; // Index of work column |
|||
|
|||
if ( |
|||
(zoneValue === "all" || zoneText.includes(zoneValue)) && |
|||
(schemeValue === "all" || schemeText.includes(schemeValue)) && |
|||
(workValue === "all" || workText.includes(workValue)) |
|||
) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
); |
|||
|
|||
// Event listener for filter dropdowns |
|||
$('#zone-select, #scheme-select, #work-select').on('change', function() { |
|||
table.draw(); |
|||
}); |
|||
|
|||
|
|||
|
|||
}); |
|||
|
|||
function showModal(dataId) { |
|||
// Fetch the data based on dataId |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/all-list/' + dataId, |
|||
method: 'GET', |
|||
success: function(data) { |
|||
// Update the modal content |
|||
document.getElementById('modal_abs_est_number').innerText = data.abs_est_number; |
|||
document.getElementById('modal_nameofwork').innerText = data.nameofwork; |
|||
|
|||
document.getElementById('modal_regionname').innerText = data.regionname; |
|||
document.getElementById('modal_zonename').innerText = data.zonename; |
|||
document.getElementById('modal_wardname').innerText = data.wardname; |
|||
|
|||
document.getElementById('modal_administrationsanctioned').innerText = data.administrationsanctioned; |
|||
document.getElementById('modal_agreementdate').innerText = data.agreementdate; |
|||
document.getElementById('modal_agreementperiod').innerText = data.agreementperiod; |
|||
|
|||
document.getElementById('modal_councilresolutiondate').innerText = data.councilresolutiondate; |
|||
document.getElementById('modal_loaissued').innerText = data.loaissued; |
|||
|
|||
document.getElementById('modal_schemename').innerText = data.schemename; |
|||
document.getElementById('modal_technicalsanctiondate').innerText = data.technicalsanctiondate; |
|||
document.getElementById('modal_technicalbidfinalized').innerText = data.technicalbidfinalized; |
|||
document.getElementById('modal_tenderannounced').innerText = data.tenderannounced; |
|||
|
|||
document.getElementById('modal_workcategory').innerText = data.workcategory; |
|||
document.getElementById('modal_workcommenced').innerText = data.workcommenced; |
|||
document.getElementById('modal_workorderissued').innerText = data.workorderissued; |
|||
|
|||
document.getElementById('modal_completeddate_25_percent').innerText = data.completeddate_25_percent; |
|||
document.getElementById('modal_completeddate_50_percent').innerText = data.completeddate_50_percent; |
|||
document.getElementById('modal_completeddate_75_percent').innerText = data.completeddate_75_percent; |
|||
document.getElementById('modal_completeddate_100_percent').innerText = data.completeddate_100_percent; |
|||
document.getElementById('modal_completionreportdate').innerText = data.completionreportdate; |
|||
|
|||
document.getElementById('modal_typeofwork').innerText = data.typeofwork; |
|||
document.getElementById('modal_valueofwork').innerText = data.valueofwork; |
|||
document.getElementById('modal_pricebidfinalized').innerText = data.pricebidfinalized; |
|||
document.getElementById('modal_paymentfullysettleddate').innerText = data.paymentfullysettleddate; |
|||
|
|||
$('#modal_workimage').attr('src', data.imageurl); |
|||
|
|||
// Show the modal |
|||
$('#detailModal').modal('show'); |
|||
}, |
|||
error: function(err) { |
|||
console.error(err); |
|||
alert('Failed to fetch data'); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,875 @@ |
|||
<html xmlns:th="http://www.thymeleaf.org"> |
|||
<head th:replace="~{fragments/modules/base/head :: head}"></head> |
|||
|
|||
<style> |
|||
.chart-container { |
|||
width: 100%; |
|||
height: 350px; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
@media ( max-width : 768px) { |
|||
.chart-container { |
|||
height: 200px; /* Adjust height for mobile view */ |
|||
} |
|||
} |
|||
|
|||
.highlight-red { |
|||
color: red; |
|||
} |
|||
|
|||
.scheme-count, .typeofwork-count { |
|||
cursor: pointer; |
|||
color:blue; |
|||
} |
|||
|
|||
.scheme-count:hover, .typeofwork-count:hover { |
|||
background-color: darkgrey; /* Change this color to your preference */ |
|||
|
|||
} |
|||
|
|||
</style> |
|||
<body> |
|||
<link rel="stylesheet" |
|||
href="/assets/node_modules/amcharts3/amcharts/plugins/export/export.css" |
|||
type="text/css" media="all" /> |
|||
<!--[if lt IE 8]> |
|||
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> |
|||
<![endif]--> |
|||
|
|||
<div class="wrapper"> |
|||
<!-- header top menu Start --> |
|||
<header th:replace="~{fragments/modules/base/header :: header}"></header> |
|||
<!-- header top menu end --> |
|||
|
|||
<div class="page-wrap"> |
|||
<!--=============== Left Menu side Start ================--> |
|||
<div th:replace="~{fragments/modules/base/menu :: menu}"></div> |
|||
<!--=============== Left side End ================--> |
|||
<div class="main-content"> |
|||
<div class="container-fluid"> |
|||
<div class="page-header mb-2"> |
|||
<div class="row align-items-end"> |
|||
<div class="col-lg-8"> |
|||
<div class="page-header-title"> |
|||
<i class="ik ik-bar-chart-2 bg-blue"></i> |
|||
<div class="d-inline"> |
|||
<h5>Works</h5> |
|||
<span>CM Works Dashboard</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-lg-4"> |
|||
<nav class="breadcrumb-container" aria-label="breadcrumb"> |
|||
<ol class="breadcrumb"> |
|||
<li class="breadcrumb-item"><a href="/index"><i class="ik ik-home"></i></a></li> |
|||
<li class="breadcrumb-item">CM Dashboard</li> |
|||
<li class="breadcrumb-item active" aria-current="page">Dashboard2</li> |
|||
</ol> |
|||
</nav> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<div class="card sale-card"> |
|||
<div class="card-header"> |
|||
|
|||
<h3> |
|||
<i class="fas fa-chart-pie pr-2"></i><b>Works Analysis:</b> |
|||
</h3> |
|||
<br> <br> |
|||
</div> |
|||
|
|||
<div class="card-block" style="text-align: center;"> |
|||
<div id="chart" class="row"> |
|||
|
|||
<div class="col-sm-12 col-xl-6"> |
|||
<h6> |
|||
<b>Over all Region wise works count</b> |
|||
</h6> |
|||
<div id="region-chartdiv" class="chart-shadow" |
|||
style="height: 500px; width: 100%;"></div> |
|||
</div> |
|||
<hr> |
|||
|
|||
<div class="col-sm-12 col-xl-6"> |
|||
<h6> |
|||
<b>Overall Zonewise works count</b> |
|||
</h6> |
|||
<div id="zone-chartdiv" class="chart-shadow" |
|||
style="height: 500px; width: 100%;"></div> |
|||
</div> |
|||
|
|||
|
|||
<hr> |
|||
|
|||
<div class="col-sm-12 d-flex justify-content-center align-items-center mt-20 mb-20"> |
|||
<label for="region-select" class="pr-2"><b>Select Zone:</b></label> |
|||
<select id="region-select" onchange="updateSchemeAndTypeOfWorkCharts()" class="form-select custom-select" style="width: 30%"> |
|||
<option value="all">--All--</option> |
|||
<option value="B-Buildings">B-Buildings</option> |
|||
<option value="BR-Bus Route Roads">BR-Bus Route Roads</option> |
|||
<option value="D-Storm Water Drains">D-Storm Water Drains</option> |
|||
<option value="J-Bridges">J-Bridges</option> |
|||
<option value="L-Electrical">L-Electrical</option> |
|||
<option value="P-Parks and Playfields">P-Parks and Playfields</option> |
|||
<option value="Q-Solid Waste Management">Q-Solid Waste Management</option> |
|||
<option value="SP-SPECIAL PROJECTS">SP-SPECIAL PROJECTS</option> |
|||
<option value="01 - NA-THIRUVOTTIYUR">01 - NA-THIRUVOTTIYUR</option> |
|||
<option value="02 - NB-MANALI">02 - NB-MANALI</option> |
|||
<option value="03 - NC-MADHAVARAM">03 - NC-MADHAVARAM</option> |
|||
<option value="04 - ND-TONDIARPET">04 - ND-TONDIARPET</option> |
|||
<option value="05 - NE-ROYAPURAM">05 - NE-ROYAPURAM</option> |
|||
<option value="06 - NF-THIRU-VI-KA NAGAR">06 - NF-THIRU-VI-KA NAGAR</option> |
|||
<option value="07 - NG-AMBATTUR">07 - NG-AMBATTUR</option> |
|||
<option value="08 - NH-ANNA NAGAR">08 - NH-ANNA NAGAR</option> |
|||
<option value="09 - NJ-TEYNAMPET">09 - NJ-TEYNAMPET</option> |
|||
<option value="10 - NK-KODAMBAKKAM">10 - NK-KODAMBAKKAM</option> |
|||
<option value="11 - NL-VALASARAVAKKAM">11 - NL-VALASARAVAKKAM</option> |
|||
<option value="12 - NM-ALANDUR">12 - NM-ALANDUR</option> |
|||
<option value="13 - NN-ADYAR">13 - NN-ADYAR</option> |
|||
<option value="14 - NP-PERUNGUDI">14 - NP-PERUNGUDI</option> |
|||
<option value="15 - NQ-SHOZHINGANALLUR">15 - NQ-SHOZHINGANALLUR</option> |
|||
</select> |
|||
</div> |
|||
|
|||
|
|||
<div class="col-sm-12 col-xl-6"> |
|||
<h6 id="scheme-title"> |
|||
<b><span id="scheme-region" class="highlight-red"></span> |
|||
Scheme Names</b> |
|||
</h6> |
|||
<div id="scheme-chartdiv" class="chart-shadow" |
|||
style="height: 400px; width: 100%;"></div> |
|||
</div> |
|||
|
|||
<hr> |
|||
<div class="col-sm-12 col-xl-6"> |
|||
<h6 id="workcategory-title"> |
|||
<b><span id="typeofwork-region" class="highlight-red"></span> |
|||
Type of Works</b> |
|||
</h6> |
|||
<div id="typeOfWork-chartdiv" class="chart-shadow" |
|||
style="height: 400px; width: 100%;"></div> |
|||
</div> |
|||
|
|||
<hr> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Modal --> |
|||
<div class="modal fade" id="zoneDetailsModal" tabindex="-1" |
|||
role="dialog" aria-labelledby="zoneDetailsModalLabel" |
|||
aria-hidden="true" data-backdrop="static" data-keyboard="false"> |
|||
<div class="modal-dialog modal-lg" role="document"> |
|||
<div class="modal-content"> |
|||
<div id="zone-details-content"></div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div> |
|||
|
|||
<script th:replace="~{fragments/modules/base/script :: script}"></script> |
|||
<script th:replace="~{fragments/modules/pgr/script :: script}"></script> |
|||
|
|||
<script src="/assets/node_modules/amcharts3/amcharts/amcharts.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/serial.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/plugins/export/export.min.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/pie.js"></script> |
|||
<script src="/assets/node_modules/amcharts3/amcharts/themes/light.js"></script> |
|||
|
|||
<script src="/assets/node_modules/amcharts3/amcharts/plugins/responsive/responsive.js"></script> |
|||
<script src="/assets/node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.min.js"></script> |
|||
|
|||
<script> |
|||
|
|||
|
|||
|
|||
// Function to update the chart titles based on the selected region |
|||
function updateChartTitles() { |
|||
const regionSelect = document.getElementById("region-select"); |
|||
const selectedRegion = regionSelect.options[regionSelect.selectedIndex].text; |
|||
|
|||
const schemeRegion = document.getElementById("scheme-region"); |
|||
const typeofworkRegion = document.getElementById("typeofwork-region"); |
|||
|
|||
schemeRegion.innerHTML = selectedRegion; |
|||
typeofworkRegion.innerHTML = selectedRegion; |
|||
} |
|||
|
|||
|
|||
updateSchemeAndTypeOfWorkCharts(); |
|||
|
|||
// Function to update scheme and type of work charts based on zone selection |
|||
function updateSchemeAndTypeOfWorkCharts() { |
|||
const zoneName = $("#region-select").val(); |
|||
|
|||
|
|||
console.log("Updating charts for zone in updateSchemeAndTypeOfWorkCharts:", zoneName); // Log the zone name |
|||
|
|||
updateChartTitles(); |
|||
|
|||
|
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getCmDashboardReports', |
|||
type: 'GET', |
|||
data: { zonename: zoneName }, |
|||
success: function(response) { |
|||
console.log('Data from API in updateSchemeAndTypeOfWorkCharts:', response); |
|||
const { schemeData, typeOfWorkData } = processCombinedData(response); |
|||
createSchemeChart('scheme-chartdiv', schemeData); |
|||
createTypeofworkChart('typeOfWork-chartdiv', typeOfWorkData); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching data in updateSchemeAndTypeOfWorkCharts:", error); |
|||
console.error("Error details:", error.responseText); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
// Function to fetch region counts on page load |
|||
function fetchRegionCounts() { |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getRegionCounts', |
|||
type: 'GET', |
|||
success: function(response) { |
|||
console.log('Region Counts:', response); |
|||
|
|||
const regionData = processRegionData(response); |
|||
createRegionChart('region-chartdiv', regionData); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching region counts:", error); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// Function to fetch zone counts on page load |
|||
function fetchZoneCounts() { |
|||
const zoneName = $("#region-select").val(); |
|||
console.log("Selected zone from fetchZoneCounts:", zoneName); // Log the selected zone |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getZoneCounts', |
|||
type: 'GET', |
|||
data: { zonename: zoneName }, |
|||
success: function(response) { |
|||
console.log('Zone Counts:', response); |
|||
|
|||
const zoneData = processZoneData(response); |
|||
createZoneChart('zone-chartdiv', zoneData); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching zone counts:", error); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// Function to initialize charts on page load |
|||
function initializeCharts() { |
|||
fetchRegionCounts(); |
|||
fetchZoneCounts(); |
|||
updateSchemeAndTypeOfWorkCharts("all"); // Initialize with "all" parameter |
|||
// Removed redundant call to updateSchemeAndTypeOfWorkCharts |
|||
} |
|||
|
|||
$(document).ready(function () { |
|||
initializeCharts(); |
|||
|
|||
}); |
|||
|
|||
|
|||
|
|||
//region work counts |
|||
function processRegionData(data) { |
|||
let regionData = []; // This gives the count of regions |
|||
data.forEach(item => { |
|||
if (item.regionname && item.region_count) { |
|||
regionData.push({ title: item.regionname, value: item.region_count }); |
|||
} |
|||
}); |
|||
return regionData; |
|||
} |
|||
|
|||
//zone work counts |
|||
function processZoneData(data) { |
|||
let zoneData = []; |
|||
data.forEach(item => { |
|||
if (item.zonename && item.zone_count) { |
|||
zoneData.push({ category: item.zonename, count: item.zone_count }); |
|||
} |
|||
}); |
|||
zoneData.sort((a, b) => b.count - a.count); |
|||
return zoneData; |
|||
} |
|||
|
|||
//scheme and typeofwork work counts |
|||
function processCombinedData(data) { |
|||
let schemeData = []; |
|||
let typeOfWorkData = []; |
|||
|
|||
data.forEach(item => { |
|||
if (item.type === 'Scheme') { |
|||
schemeData.push({ category: item.name, count: item.count }); |
|||
} else if (item.type === 'TypeOfWork') { |
|||
typeOfWorkData.push({ category: item.name, count: item.count }); |
|||
} |
|||
}); |
|||
schemeData.sort((a, b) => b.count - a.count); |
|||
typeOfWorkData.sort((a, b) => b.count - a.count); |
|||
return { schemeData, typeOfWorkData }; |
|||
} |
|||
|
|||
//function of random color for chart |
|||
function getRandomDarkColor() { |
|||
const letters = '0123456789ABCDEF'; |
|||
let color = '#'; |
|||
for (let i = 0; i < 6; i++) { |
|||
color += letters[Math.floor(Math.random() * 16)]; |
|||
} |
|||
return color; |
|||
} |
|||
|
|||
//REGION CHART |
|||
//creating region chart |
|||
function createRegionChart(chartId, chartData) { |
|||
chartData.forEach(data => { |
|||
data.color = getRandomDarkColor(); |
|||
}); |
|||
|
|||
|
|||
AmCharts.makeChart(chartId, { |
|||
"type": "pie", |
|||
"theme": "dark", |
|||
"dataProvider": chartData, |
|||
"valueField": "value", |
|||
"titleField": "title", |
|||
"colorField": "color", |
|||
"startEffect":"easeInSine", |
|||
"innerRadius": "50%", |
|||
"labelText": "[[[[value]]]]", |
|||
"labelsEnabled": true, |
|||
"gradientRatio": [-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, 0, 0.1, 0.2, 0.1, 0, -0.2, -0.5], |
|||
"balloonText": "[[[[title]]]]<br><span style='font-size:14px'><b>[[[[value]]]]</b> ([[[[percents]]]]%)</span>", |
|||
"export": { |
|||
"enabled": true, |
|||
}, |
|||
"responsive": { |
|||
"enabled": true, |
|||
}, |
|||
"pullOutRadius":0, |
|||
"legend": { |
|||
"position": "bottom", |
|||
"markerType": "diamond", |
|||
"valueAlign": "left", |
|||
"align": "center", |
|||
"reversedOrder": true, |
|||
"labelText": "[[[[title]]]] - ", |
|||
"enabled": true |
|||
}, |
|||
"listeners": [{ |
|||
"event": "clickSlice", |
|||
"method": function(event) { |
|||
let regionname = event.dataItem.dataContext.title; |
|||
fetchRegionZoneDetails(regionname); |
|||
} |
|||
}] |
|||
}); |
|||
} |
|||
|
|||
//fetching region details |
|||
function fetchRegionZoneDetails(regionname) { |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getRegionzones', |
|||
type: 'GET', |
|||
data: { regionname: regionname }, |
|||
success: function(response) { |
|||
displayRegionZoneDetails(response, regionname); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching region details:", error); |
|||
} |
|||
}); |
|||
} |
|||
// display region details |
|||
function displayRegionZoneDetails(data, regionname) { |
|||
let totalValueOfWork = formatValue(data.totalValueOfWork); |
|||
let totalWorkCounts = data.totalWorkCounts; |
|||
let regionzonedetails=data.regionzonedetails; |
|||
|
|||
let regionZonesContent = ''; |
|||
regionzonedetails.forEach(item => { |
|||
let formattedTotalValue = formatValue(item.totalValueOfWork); |
|||
regionZonesContent += `<tr><td>${item.name}</td><td>${item.regionszones_count}</td><td>${formattedTotalValue}</td></tr>`; |
|||
}); |
|||
|
|||
let modalContent = ` |
|||
<div class="modal-header"> |
|||
<h5 class="modal-title"><b>Region: ${regionname}</b></h5> |
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead class="thead-dark"> |
|||
<tr> |
|||
<th>Zone Name</th> |
|||
<th>Works</th> |
|||
<th>Total Value of Work</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
${regionZonesContent} |
|||
</tbody> |
|||
</table> |
|||
<div class="d-flex justify-content-between"> |
|||
<h6><b>Total Work Counts: </b>${totalWorkCounts}</h6> |
|||
<h6><b>Total Value of Work: </b>${totalValueOfWork}</h6> |
|||
</div> |
|||
</div> |
|||
`; |
|||
|
|||
document.getElementById('zone-details-content').innerHTML = modalContent; |
|||
|
|||
// Show the modal |
|||
$('#zoneDetailsModal').modal('show'); |
|||
} |
|||
|
|||
//ZONE CHART |
|||
//creating zone chart |
|||
function createZoneChart(chartId, chartData) { |
|||
chartData.forEach(data => { |
|||
data.color = getRandomDarkColor(); |
|||
}); |
|||
AmCharts.makeChart(chartId, { |
|||
"type": "serial", |
|||
"theme": "light", |
|||
"valueField": "value", |
|||
"titleField": "title", |
|||
"colorField": "color", |
|||
"dataProvider": chartData, |
|||
"depth3D": 2, |
|||
"angle": 10, |
|||
"valueAxes": [{ |
|||
"gridColor": "#808080", |
|||
"axisAlpha": 0, |
|||
"gridAlpha": 0, |
|||
"labelsEnabled": false, |
|||
"dashLength": 0 |
|||
}], |
|||
"startDuration": 1, |
|||
"startEffect":"easeInSine", |
|||
"graphs": [{ |
|||
"balloonText": "[[[[category]]]]<br><span style='font-size:14px'><b>[[[[count]]]]</b></span>", |
|||
"fillAlphas": 0.8, |
|||
"lineAlpha": 0.2, |
|||
"topRadius": 1, |
|||
"type": "column", |
|||
"valueField": "count", |
|||
"fillColorsField": "color", |
|||
"labelText": "[[[[value]]]]", |
|||
"labelColorField": "#ffffff", |
|||
"lineThickness": 1, |
|||
}], |
|||
"chartCursor": { |
|||
"valueLineEnabled": false, |
|||
"valueLineBalloonEnabled": false, |
|||
"cursorAlpha": 0, |
|||
"valueLineAlpha": 0.2, |
|||
"pan": false |
|||
}, |
|||
"categoryField": "category", |
|||
"categoryAxis": { |
|||
"gridPosition": "start", |
|||
"gridAlpha": 0, |
|||
"autoWrap": false, |
|||
"axisAlpha": 0, |
|||
}, |
|||
"rotate": true, |
|||
"export": { |
|||
"enabled": true, |
|||
"position": "bottom-right" |
|||
}, |
|||
"listeners": [{ |
|||
"event": "clickGraphItem", |
|||
"method": function(event) { |
|||
let zoneName = event.item.category; |
|||
fetchZoneDetails(zoneName); |
|||
} |
|||
}] |
|||
}); |
|||
} |
|||
|
|||
function fetchZoneDetails(zoneName) { |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getCmDashboardReports', |
|||
type: 'GET', |
|||
data: { zonename: zoneName }, |
|||
success: function(response) { |
|||
displayZoneDetails(response, zoneName); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching zone details:", error); |
|||
} |
|||
}); |
|||
} |
|||
function displayZoneDetails(data, zoneName) { |
|||
let schemeDetails = ''; |
|||
let workCategoryDetails = ''; |
|||
let typeOfWorkDetails = ''; |
|||
|
|||
data.forEach(item => { |
|||
if (item.type === 'Scheme') { |
|||
schemeDetails += `<tr><td>${item.name}</td><td class="scheme-count" data-schemename="${item.name}" data-zonename="${zoneName}">${item.count}</td></tr>`; |
|||
} else if (item.type === 'TypeOfWork') { |
|||
typeOfWorkDetails += `<tr><td>${item.name}</td><td class="typeofwork-count" data-typeofwork="${item.name}" data-zonename="${zoneName}">${item.count}</td></tr>`; |
|||
} |
|||
}); |
|||
|
|||
let modalContent = ` |
|||
<div class="modal-header"> |
|||
<h5 class="modal-title"><b>Zone: ${zoneName}</b></h5> |
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 col-md-12 col-lg-6"> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead class="thead-dark"> |
|||
<tr> |
|||
<th>Scheme Names</th> |
|||
<th>Works</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
${schemeDetails} |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="col-sm-12 col-md-12 col-lg-6"> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead class="thead-dark"> |
|||
<tr> |
|||
<th>Type of Works</th> |
|||
<th>Works</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
${typeOfWorkDetails} |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
`; |
|||
|
|||
document.getElementById('zone-details-content').innerHTML = modalContent; |
|||
|
|||
// Show the modal |
|||
$('#zoneDetailsModal').modal('show'); |
|||
|
|||
// Add click event listeners |
|||
addModalEventListeners(); |
|||
} |
|||
|
|||
function addModalEventListeners() { |
|||
// Capture click event on scheme counts |
|||
$(".scheme-count").click(function () { |
|||
var schemename = $(this).data("schemename"); |
|||
var zonename = $(this).data("zonename"); |
|||
window.location.href = "/gcc/dashboards/all-list?zonename=" + zonename + "&schemename=" + schemename; |
|||
}); |
|||
|
|||
// Capture click event on typeofwork counts |
|||
$(".typeofwork-count").click(function () { |
|||
var typeofwork = $(this).data("typeofwork"); |
|||
var zonename = $(this).data("zonename"); |
|||
window.location.href = "/gcc/dashboards/all-list?zonename=" + zonename + "&typeofwork=" + typeofwork; |
|||
}); |
|||
} |
|||
|
|||
function createSchemeChart(chartId, chartData) { |
|||
chartData.forEach(data => { |
|||
data.color = getRandomDarkColor(); |
|||
}); |
|||
AmCharts.makeChart(chartId, { |
|||
"type": "serial", |
|||
"theme": "light", |
|||
"valueField": "value", |
|||
"titleField": "title", |
|||
"colorField": "color", |
|||
"dataProvider": chartData, |
|||
"depth3D": 3, |
|||
"angle": 10, |
|||
"valueAxes": [{ |
|||
"gridColor": "#808080", |
|||
"axisAlpha": 0, |
|||
"gridAlpha": 0, |
|||
"labelsEnabled": false, |
|||
"dashLength": 0 |
|||
}], |
|||
"startDuration": 1, |
|||
"startEffect":"easeInSine", |
|||
"graphs": [{ |
|||
"balloonText": "[[[[category]]]]<br><span style='font-size:14px'><b>[[[[count]]]]</b></span>", |
|||
"fillAlphas": 0.8, |
|||
"lineAlpha": 0.2, |
|||
"topRadius": 1, |
|||
"type": "column", |
|||
"valueField": "count", |
|||
"fillColorsField": "color", |
|||
"labelText": "[[[[value]]]]", |
|||
"labelColorField": "#ffffff", |
|||
"lineThickness": 1, |
|||
}], |
|||
"chartCursor": { |
|||
"valueLineEnabled": false, |
|||
"valueLineBalloonEnabled": false, |
|||
"cursorAlpha": 0, |
|||
"valueLineAlpha": 0.2, |
|||
"pan": false |
|||
}, |
|||
"categoryField": "category", |
|||
"categoryAxis": { |
|||
"gridPosition": "start", |
|||
"gridAlpha": 0, |
|||
"autoWrap": false, |
|||
"axisAlpha": 0, |
|||
}, |
|||
"rotate": true, |
|||
"export": { |
|||
"enabled": true, |
|||
|
|||
}, |
|||
"listeners": [{ |
|||
"event": "clickGraphItem", |
|||
"method": function(event) { |
|||
let schemename = event.item.category; |
|||
let zonename = $("#region-select").val(); |
|||
fetchSchemeDetails(schemename, zonename); |
|||
} |
|||
}] |
|||
}); |
|||
} |
|||
//Function for Formatting the valueofwork |
|||
function formatValue(value) { |
|||
value = Number(value); // Ensure the value is a number |
|||
|
|||
if (value >= 1e9) { |
|||
return (value / 1e9).toFixed(2) + ' Billion'; |
|||
} else if (value >= 1e6) { |
|||
return (value / 1e6).toFixed(2) + ' Million'; |
|||
} else if (value >= 1e5) { |
|||
return (value / 1e5).toFixed(2) + ' Lakh'; |
|||
} else if (value >= 1e4) { |
|||
return (value / 1e4).toFixed(2) + ' Thousand'; |
|||
} |
|||
return value.toFixed(2); |
|||
} |
|||
function fetchSchemeDetails(schemename, zonename) { |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getSchemeDetails', |
|||
type: 'GET', |
|||
data: { schemename: schemename, zonename: zonename }, |
|||
success: function(response) { |
|||
displaySchemeDetails(response, schemename); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching scheme details:", error); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
function displaySchemeDetails(data, schemename) { |
|||
let totalValueOfWork = formatValue(data.totalValueOfWork); |
|||
let totalWorkCounts = data.totalWorkCounts; // get totalWorkCounts |
|||
let typeOfWorkDetails = data.typeOfWorkDetails; |
|||
|
|||
let typeOfWorkContent = ''; |
|||
typeOfWorkDetails.forEach(item => { |
|||
let formattedTotalValue = formatValue(item.totalValueOfWork); |
|||
typeOfWorkContent += `<tr><td>${item.name}</td><td>${item.count}</td><td>${formattedTotalValue}</td></tr>`; |
|||
}); |
|||
|
|||
let modalContent = ` |
|||
<div class="modal-header"> |
|||
<h5 class="modal-title"><b>Scheme: ${schemename}</b></h5> |
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead class="thead-dark"> |
|||
<tr> |
|||
<th>Type of Work</th> |
|||
<th>Works</th> |
|||
<th>Cost</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
${typeOfWorkContent} |
|||
</tbody> |
|||
</table> |
|||
<div class="d-flex justify-content-between"> |
|||
<h6><b>Total Work Counts: </b>${totalWorkCounts}</h6> |
|||
<h6><b>Total Value of Work: </b>${totalValueOfWork}</h6> |
|||
</div> |
|||
</div> |
|||
`; |
|||
|
|||
document.getElementById('zone-details-content').innerHTML = modalContent; |
|||
|
|||
// Show the modal |
|||
$('#zoneDetailsModal').modal('show'); |
|||
} |
|||
|
|||
function createTypeofworkChart(chartId, chartData) { |
|||
chartData.forEach(data => { |
|||
data.color = getRandomDarkColor(); |
|||
}); |
|||
AmCharts.makeChart(chartId, { |
|||
"type": "serial", |
|||
"theme": "light", |
|||
"valueField": "value", |
|||
"titleField": "title", |
|||
"colorField": "color", |
|||
"dataProvider": chartData, |
|||
"depth3D": 3, |
|||
"angle": 10, |
|||
"valueAxes": [{ |
|||
"gridColor": "#808080", |
|||
"axisAlpha": 0, |
|||
"gridAlpha": 0, |
|||
"labelsEnabled": false, |
|||
"dashLength": 0, |
|||
"position": "top", |
|||
"reversed":true |
|||
}], |
|||
"startDuration": 1, |
|||
"startEffect":"easeInSine", |
|||
"graphs": [{ |
|||
"balloonText": "[[[[category]]]]<br><span style='font-size:14px'><b>[[[[count]]]]</b></span>", |
|||
"fillAlphas": 0.8, |
|||
"lineAlpha": 0.2, |
|||
"topRadius": 1, |
|||
"type": "column", |
|||
"valueField": "count", |
|||
"fillColorsField": "color", |
|||
"labelText": "[[[[value]]]]", |
|||
"labelColorField": "#ffffff", |
|||
"lineThickness": 1, |
|||
}], |
|||
"chartCursor": { |
|||
"valueLineEnabled": false, |
|||
"valueLineBalloonEnabled": false, |
|||
"cursorAlpha": 0, |
|||
"valueLineAlpha": 0.2, |
|||
"pan": false |
|||
}, |
|||
"categoryField": "category", |
|||
"categoryAxis": { |
|||
"gridPosition": "start", |
|||
"gridAlpha": 0, |
|||
"autoWrap": false, |
|||
"axisAlpha": 0, |
|||
"reversed":true, |
|||
"position": "right", |
|||
}, |
|||
"rotate": true, |
|||
"export": { |
|||
"enabled": true, |
|||
}, |
|||
"listeners": [{ |
|||
"event": "clickGraphItem", |
|||
"method": function(event) { |
|||
let typeofwork = event.item.category; |
|||
let zonename = $("#region-select").val(); |
|||
fetchTypeOfWorkDetails(typeofwork, zonename); |
|||
} |
|||
}] |
|||
}); |
|||
} |
|||
function fetchTypeOfWorkDetails(typeofwork, zonename) { |
|||
$.ajax({ |
|||
url: '/gcc/api/cmdashboard/getTypeOfWorkDetails', |
|||
type: 'GET', |
|||
data: { typeofwork: typeofwork, zonename: zonename }, |
|||
success: function(response) { |
|||
displayTypeOfWorkDetails(response, typeofwork); |
|||
}, |
|||
error: function(error) { |
|||
console.error("Error fetching typeofwork details:", error); |
|||
} |
|||
}); |
|||
} |
|||
function displayTypeOfWorkDetails(data, typeofwork) { |
|||
let totalValueOfWork = formatValue(data.totalValueOfWork); |
|||
let totalWorkCounts = data.totalWorkCounts; // get totalWorkCounts |
|||
let schemeNameDetails = data.schemeNameDetails; |
|||
|
|||
let schemeNameContent = ''; |
|||
schemeNameDetails.forEach(item => { |
|||
let formattedTotalValue = formatValue(item.totalValueOfWork); |
|||
schemeNameContent += `<tr><td>${item.name}</td><td>${item.count}</td><td>${formattedTotalValue}</td></tr>`; |
|||
}); |
|||
|
|||
let modalContent = ` |
|||
<div class="modal-header"> |
|||
<h5 class="modal-title"><b>TypeOfWork: ${typeofwork}</b></h5> |
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|||
<span aria-hidden="true">×</span> |
|||
</button> |
|||
</div> |
|||
<div class="modal-body"> |
|||
<table class="table table-striped table-bordered"> |
|||
<thead class="thead-dark"> |
|||
<tr> |
|||
<th>Scheme Name</th> |
|||
<th>Works</th> |
|||
<th>Total Cost</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
${schemeNameContent} |
|||
</tbody> |
|||
</table> |
|||
<div class="d-flex justify-content-between"> |
|||
<h6><b>Total Work Counts: </b>${totalWorkCounts}</h6> |
|||
<h6><b>Total Value of Work: </b>${totalValueOfWork}</h6> |
|||
</div> |
|||
</div> |
|||
`; |
|||
|
|||
document.getElementById('zone-details-content').innerHTML = modalContent; |
|||
|
|||
// Show the modal |
|||
$('#zoneDetailsModal').modal('show'); |
|||
} |
|||
|
|||
|
|||
</script> |
|||
|
|||
</body> |
|||
</html> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue