Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

userdesignlobsummary.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Transact;
  6. (function (Transact) {
  7. let Components;
  8. (function (Components) {
  9. let Invoices;
  10. (function (Invoices) {
  11. class LobSummary extends Unibase.Platform.Core.BaseComponent {
  12. constructor() {
  13. super(...arguments);
  14. this.appsHtml = '';
  15. this.palettecolors = [];
  16. this.onEditPalettes = '';
  17. this.IsAppRefresh = false;
  18. }
  19. jsFiles() {
  20. return ['libs/chartjs/chart.min.js'];
  21. }
  22. cssFiles() {
  23. return ["libs/chartjs/chart.min.css"];
  24. }
  25. html(id, containerid) {
  26. var instance = this;
  27. let html = ``;
  28. return html;
  29. }
  30. load(id, containerid, callback) {
  31. var instance = this;
  32. }
  33. init(containerid) {
  34. var instance = this;
  35. instance.loadMenu(containerid);
  36. }
  37. loadMenu(containerid) {
  38. var instance = this;
  39. $(`.${containerid}`).append(`<div class="card mb-0 border-0 BindData_` + containerid + ` findcontainer h-100" style="background:0 0">
  40. <div class="card-header py-2 px-3 search-bar-main-wrapper position-sticky t-0 bg-white z-index-2 border-0 viewer-header d-flex flex-wrap justify-content-between align-items-center" id="ViewerHeader_` + containerid + `">
  41. <div> <span class="biz-highlight-bg-color text-left font-weight-600">LoB Outstanding Summary</span></div>
  42. <div>
  43. <div id="select_new_Palette_Section" class=" floating-label-form-group-with-value d-none select_new_Palette_Section">
  44. <select id="select_new_Palette" class="form-control type-control required value-control dropdown_phonetype select_new_Palette" placeholder="Select" data-placeholder="Select" data-label="Palette" data-isparent="false">
  45. </select>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="card-body p-2 userDesignWidgetCardBody">
  50. <ul class="lob_summary row px-3" id="lob_summary"></ul>
  51. <div class="text-danger w-100 font-12">* The Outstanding data will be auto-refreshed for every 24 hours.</div>
  52. </div>
  53. </div>`);
  54. $(".designsPreviewAppend").find(".select_new_Palette_Section").removeClass("d-none");
  55. $(`.BindData_` + containerid + ``).find(".lob_summary").html('');
  56. let height = $(`.${containerid}`).siblings('#hf_portletwidgetheight').val();
  57. if (height != '0px') {
  58. $('.userDesignWidgetCardBody').css({ "height": `` + height + ``, "overflow-x": "hidden" }).addClass("biz-custom-scrollbar");
  59. }
  60. instance.fileCacheHelper.loadJsFiles(["libs/chartjs/chart.min.js"], () => {
  61. Bizgaze.Apps.Crm.Palettes.Managers.PaletteManager.Instance().getPallettes().then((res) => {
  62. var instance = this;
  63. let indexInstance = Unibase.Themes.Compact.Components.Index.Instance();
  64. let currentuserpalleteid = indexInstance.currentTheme.paletteId;
  65. if (res.result != "" && res.result != null && res.length != 0) {
  66. let data = Array();
  67. for (let p = 0; p < res.result.length; p++) {
  68. data.push(res.result[p]);
  69. }
  70. data.sort(function (a, b) {
  71. var a1 = a.palletteid, b1 = b.palletteid;
  72. if (a1 == b1)
  73. return 0;
  74. return a1 > b1 ? 1 : -1;
  75. });
  76. for (let z = 0; z < data.length; z++) {
  77. let palletId = data[z].paletteid;
  78. let palletName = data[z].name;
  79. let html = '';
  80. if (currentuserpalleteid == palletId) {
  81. html = `<option value='` + palletId + `' selected >` + palletName + `</option>`;
  82. }
  83. else {
  84. html = `<option value='` + palletId + `' >` + palletName + `</option>`;
  85. }
  86. $('.select_new_Palette').append(html);
  87. }
  88. let palettid = '';
  89. $('.designsPreviewAppend').find(".select_new_Palette").change(function () {
  90. instance.onEditPalettes = $(this).find(":checked").val().toString();
  91. });
  92. $(`.BindData_` + containerid + ``).find(".select_new_Palette option").each(function () {
  93. var val = $(this).val();
  94. if (val == instance.onEditPalettes) {
  95. $(`.BindData_` + containerid + ``).find(".select_new_Palette option").removeAttr("checked");
  96. $(this).attr('selected', 'selected');
  97. }
  98. });
  99. palettid = instance.onEditPalettes;
  100. $(`.BindData_` + containerid + ``).find(".select_new_Palette").change(function () {
  101. $(".lob_summary").html('');
  102. palettid = $(this).find(":checked").val().toString();
  103. instance.loadPaletts(palettid);
  104. });
  105. if (palettid.length == 0) {
  106. palettid = $(`.BindData_` + containerid + ``).find(".select_new_Palette").find(":checked").val().toString();
  107. instance.loadPaletts(palettid);
  108. }
  109. else {
  110. instance.loadPaletts(palettid);
  111. }
  112. }
  113. else {
  114. instance.loadChart();
  115. }
  116. });
  117. });
  118. }
  119. loadPaletts(palettid) {
  120. let instance = this;
  121. Bizgaze.Apps.Crm.Palettes.Managers.PaletteManager.Instance().getPalletteColors(palettid).then((response) => {
  122. var data = Array();
  123. for (let i = 0; i < response.result.length; i++) {
  124. data.push(response.result[i]);
  125. }
  126. data.sort(function (a, b) {
  127. var a1 = a.palletteindex, b1 = b.palletteindex;
  128. if (a1 == b1)
  129. return 0;
  130. return a1 > b1 ? 1 : -1;
  131. });
  132. this.palettecolors = [];
  133. for (let i = 0; i < data.length; i++) {
  134. if (i < 5) {
  135. let getcolor = data[i].colorcode;
  136. this.palettecolors.push(getcolor);
  137. }
  138. }
  139. instance.loadChart();
  140. });
  141. }
  142. loadChart() {
  143. var instance = this;
  144. instance.fileCacheHelper.loadJsFiles(['apps/transact/managers/invoicemanager.js', "libs/chartjs/chart.min.js"], () => {
  145. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getlobsummary().then((res) => {
  146. let child_id = '';
  147. let child_lob;
  148. let child_lobid;
  149. let count = 0;
  150. if (res.result != null) {
  151. for (let i = 0; i < res.result.length; i++) {
  152. let data = JSON.parse(res.result[i]);
  153. let values = [];
  154. let breakup = [];
  155. let totalvalue = 0;
  156. count++;
  157. if (data.Data.length > 0) {
  158. let charts = data.Data;
  159. let chartlob = JSON.parse(charts);
  160. let lobsData = {};
  161. for (let j = 0; j < chartlob.length; j++) {
  162. let child_lobname = chartlob[j].lobname;
  163. child_id = chartlob[j].lobid;
  164. let child_value = chartlob[j].value;
  165. let child_breakup = chartlob[j].breakup;
  166. child_lobid = chartlob[j].lobid;
  167. if (lobsData[child_lobname] == undefined) {
  168. lobsData[child_lobname] = {
  169. name: child_lobname,
  170. id: child_lobid,
  171. values: [child_value],
  172. breakup: [child_breakup],
  173. };
  174. child_lob = child_lobname;
  175. let check = $(".lob_summary").find(`.pie_chart_` + child_lob + `_` + child_lobid + ``).length;
  176. if (check == 0) {
  177. var piechatstructure = `<li class="col-sm-4 p-1"><div class="card m-0 p-2">
  178. <div class="card-header p-2"><div class="d-flex align-items-center justify-content-between"><span class="list-item-main-title font-weight-600"> ` + child_lob + ` <span class="biz-highlight-text-color">(<span class='total_` + child_lobid + `'></span>)</span></span> <span class="text-right"><a class="btn btn-icon btn-flush-biz-theme btn-rounded flush-soft-hover w-30p h-30p report-maximize-btn lob_outstanding_summary_report_btn" data-lobidforreoport ='` + child_lobid + `' ><span class="btn-icon-wrap"><i class="las la-table font-18"></i></span></a></span></div></div>
  179. <div class="card-body">
  180. <canvas id=".pie_chart_` + child_lob + `_` + child_lobid + `" class=".pie_chart_` + child_lob + `_` + child_lobid + `" style = "width:100%;" data-lobid =` + child_lobid + `> </canvas>
  181. </div>
  182. </div></li>`;
  183. $(".lob_summary").append(piechatstructure);
  184. }
  185. }
  186. else {
  187. lobsData[child_lobname].values.push(child_value);
  188. lobsData[child_lobname].breakup.push(child_breakup);
  189. }
  190. }
  191. for (let objInner in lobsData) {
  192. var filters = [];
  193. if (this.palettecolors.length == 0) {
  194. this.palettecolors = [];
  195. this.palettecolors.push("#117899", "#f16c20", "#ecaa38", "#a2b86c", "#0f5b78");
  196. }
  197. var barColors = this.palettecolors;
  198. child_lobid = lobsData[objInner].id;
  199. child_lob = lobsData[objInner].name;
  200. let lob_xvalues = lobsData[objInner].values;
  201. for (let i = 0; i < lob_xvalues.length; i++) {
  202. totalvalue = totalvalue + lob_xvalues[i];
  203. }
  204. $('.total_' + child_lobid + '').html(`${totalvalue}`);
  205. let lob_yvalues = lobsData[objInner].breakup;
  206. new Chart(`.pie_chart_` + child_lob + `_` + child_lobid + ``, {
  207. type: "pie",
  208. data: {
  209. labels: lob_yvalues,
  210. datasets: [{
  211. backgroundColor: barColors,
  212. data: lob_xvalues
  213. }]
  214. },
  215. options: {
  216. responsive: true,
  217. onClick(e, item) {
  218. filters = [];
  219. if (item.length == 1) {
  220. var getcanvas = $(this)[0].canvas;
  221. var getlobid = $(getcanvas).attr("data-lobid");
  222. let lobactivepart = $(this)[0].tooltip.dataPoints[0].label;
  223. let checkingAnd = lobactivepart.toString();
  224. let Expid = 1;
  225. let check = checkingAnd.includes("and");
  226. if (check == true) {
  227. var breakpoints = checkingAnd.split("and");
  228. var breakpoints_One = breakpoints[0];
  229. var breakpoint = parseInt(breakpoints_One.replace(/[^0-9.]/g, "")).toString();
  230. if (breakpoints_One.includes("<") == true) {
  231. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.LessThan;
  232. }
  233. if (breakpoints_One.includes(">") == true) {
  234. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.GreaterThan;
  235. }
  236. if (breakpoints_One.includes("<=") == true) {
  237. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.LessThanOrEquals;
  238. }
  239. if (breakpoints_One.includes(">=") == true) {
  240. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.GreaterThanOrEquals;
  241. }
  242. filters.push({ 'Key': 'duedays', 'Value': breakpoint, ExpOp: Expid });
  243. var breakpoints_Two = breakpoints[1];
  244. var breakpoint = parseInt(breakpoints_Two.replace(/[^0-9.]/g, "")).toString();
  245. if (breakpoints_Two.includes("<") == true) {
  246. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.LessThan;
  247. }
  248. if (breakpoints_Two.includes(">") == true) {
  249. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.GreaterThan;
  250. }
  251. if (breakpoints_Two.includes("<=") == true) {
  252. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.LessThanOrEquals;
  253. }
  254. if (breakpoints_Two.includes(">=") == true) {
  255. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.GreaterThanOrEquals;
  256. }
  257. filters = filters.concat({ 'Key': 'duedays', 'Value': breakpoint, ExpOp: Expid });
  258. }
  259. else {
  260. var breakpoint = parseInt(checkingAnd.replace(/[^0-9.]/g, "")).toString();
  261. if (checkingAnd.includes("<=") == true) {
  262. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.LessThanOrEquals;
  263. }
  264. if (checkingAnd.includes(">=") == true) {
  265. Expid = Unibase.Platform.Core.Enums.ExpressionOperator.GreaterThanOrEquals;
  266. }
  267. filters.push({ 'Key': 'duedays', 'Value': breakpoint, ExpOp: Expid });
  268. }
  269. var dynamicfilters = [];
  270. dynamicfilters.push({ 'Key': 'lobid', 'Value': getlobid, ExpOp: 1 });
  271. dynamicfilters = dynamicfilters.concat(filters);
  272. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId('Bizgaze_Platform_Analytics_Reports_Lob_Outstanding_details_Summary', null, dynamicfilters, null);
  273. }
  274. },
  275. legend: {
  276. display: true,
  277. position: 'right'
  278. },
  279. },
  280. });
  281. }
  282. }
  283. }
  284. }
  285. $(".lob_outstanding_summary_report_btn").click(function () {
  286. let lobid = $(this).attr("data-lobidforreoport");
  287. var dynamicfilters = [];
  288. dynamicfilters.push({ 'Key': 'lobid', 'Value': lobid, ExpOp: 1 });
  289. dynamicfilters = dynamicfilters.concat(filters);
  290. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId('Bizgaze_Platform_Analytics_Reports_Lob_Outstanding_details_Summary', null, dynamicfilters, null);
  291. });
  292. });
  293. });
  294. }
  295. static Instance() {
  296. if (this._instance === undefined)
  297. this._instance = new LobSummary();
  298. return this._instance;
  299. }
  300. }
  301. Invoices.LobSummary = LobSummary;
  302. })(Invoices = Components.Invoices || (Components.Invoices = {}));
  303. })(Components = Transact.Components || (Transact.Components = {}));
  304. })(Transact = Apps.Transact || (Apps.Transact = {}));
  305. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  306. })(Bizgaze || (Bizgaze = {}));