vendor/uvdesk/core-framework/Resources/views/dashboard.html.twig line 1

Open in your IDE?
  1. {% extends "@UVDeskCoreFramework//Templates//layout.html.twig" %}
  2. {% block title %}Dashboard{% endblock %}
  3. {% block pageContent %}
  4.     <style>
  5.         .btn{
  6.             border: 1px solid #1a1a1a;
  7.             display: inline-block;
  8.             padding: 10px;
  9.             position: relative;
  10.             text-align: center;
  11.             transition: background 600ms ease, color 600ms ease;
  12.             margin-right: 0px !important;
  13.         }
  14.         input[type="radio"].toggle {
  15.             display: none;
  16.         }
  17.         input[type=radio]:checked + label {
  18.             background: blue;
  19.             color:white;
  20.         }
  21.         .uv-action-bar .uv-field-block.date {
  22.             display: inline-block;
  23.             margin-right: 8px;
  24.         }
  25.         .uv-action-bar label {
  26.             font-size: 16px;
  27.             vertical-align: middle;
  28.             margin-right: 10px;
  29.         }
  30.         .uv-inner-section .uv-action-bar label{
  31.             font-size: 15px;
  32.         }
  33.         @media screen and (min-width: 1100px) and (max-width: 1260px) {
  34.             .uv-inner-section .uv-action-bar .uv-action-bar-col-lt, .uv-inner-section .uv-action-bar .uv-action-bar-col-rt {
  35.                 width: 55% !important;
  36.             }
  37.         }
  38.         .graficosTortaBarra{
  39.             font-size:11px;width: 520px;border:1px solid #d3d3d3;height: 300px;padding:10px;
  40.         }
  41.         .graficosTortaBarra label{
  42.             line-height: 2;
  43.             padding: 0 8px;
  44.             display: inline-block;
  45.         }
  46.         .boch {
  47.             display:inline-block;
  48.             height: 10px;
  49.             width: 10px;
  50.             margin-right: 3px;
  51.             border-radius: 50%;
  52.         }
  53.         .box-graficos {
  54.             display: flex;
  55.             flex-wrap: wrap;
  56.             gap: 10px;
  57.         }
  58.         .uv-activity-wrapper {
  59.             margin-top: 60px;
  60.         }
  61.         .uv-activity-wrapper .uv-activity-chart-col-lt {
  62.             width: 80%;
  63.             float: left;
  64.         }
  65.         ul.uv-activity-brick-wrapper {
  66.             list-style: none;
  67.             margin: 0;
  68.             padding: 0;
  69.             width: 100%;
  70.             display: inline-block;
  71.         }
  72.         ul.uv-activity-brick-wrapper li {
  73.             width: 25%;
  74.             display: inline-block;
  75.             float: left;
  76.             padding-left: 10px;
  77.             padding-right: 10px;
  78.             color: #fff;
  79.         }
  80.         ul.uv-activity-brick-wrapper .uv-activity-brick {
  81.             border-radius: 3px;
  82.             padding: 10px;
  83.             text-align: center;
  84.         }
  85.         ul.uv-activity-brick-wrapper li a {
  86.             color: #fff;
  87.             font-size: 45px;
  88.             width: 100%;
  89.             display: inline-block;
  90.         }
  91.         ul.uv-activity-brick-wrapper li label {
  92.             font-size: 18px;
  93.             width: 100%;
  94.             display: inline-block;
  95.         }
  96.         .uv-activity-chart-bottom-row .uv-pannel-body {
  97.             height: 450px;
  98.         }
  99.         .kudos-overview {
  100.             width: 40%;
  101.             float: left;
  102.             padding-right: 10px;
  103.         }
  104.         .recent-notification {
  105.             width: 30%;
  106.             float: left;
  107.             padding-left: 10px;
  108.         }
  109.         .completion-chart {
  110.             width: 300px;
  111.             margin: 0 auto;
  112.         }
  113.         .progress-meter .background {
  114.             fill: #EFEFEF;
  115.         }
  116.         .progress-meter text {
  117.             font-size: 30px;
  118.         }
  119.         .kudos-overview .uv-pannel-body {
  120.             text-align: center;
  121.             padding-top: 50px;
  122.         }
  123.         .kudos-overview .uv-pannel-body label {
  124.             margin-top: 10px;
  125.             display: inline-block;
  126.         }
  127.         .recent-notification ul {
  128.             list-style: none;
  129.             padding: 0;
  130.             margin: 0;
  131.             overflow-y: auto;
  132.             max-height: 400px !important;
  133.         }
  134.         .recent-notification .uv-pannel-body {
  135.             padding: 0;
  136.         }
  137.         .recent-notification ul li {
  138.             color: #333333;
  139.             border-bottom: solid 1px #D3D3D3;
  140.             padding: 15px 20px;
  141.         }
  142.         .recent-notification ul li:first-child {
  143.             border-top: none;
  144.         }
  145.         .recent-notification ul li:last-child {
  146.             border-bottom: none;
  147.         }
  148.         .recent-notification ul li * {
  149.             display: inline-block !important;
  150.         }
  151.         .recent-notification ul li .timeago {
  152.             color: #9E9E9E;
  153.             margin-top: 5px;
  154.             font-size: 13px;
  155.         }
  156.         .recent-notification label {
  157.             text-align: center;
  158.             display: inline-block;
  159.             width: 100%;
  160.             padding-top: 15px;
  161.             border-top: 1px solid #d3d3d3;
  162.         }
  163.         .recent-notification span.uv-notification-message {
  164.             float: left;
  165.             width: 100%;
  166.         }
  167.         .kudos-count {
  168.             width: 30%;
  169.             float: left;
  170.             padding-right: 10px;
  171.             padding-left: 10px;
  172.         }
  173.         .kudos-count .uv-pannel-body {
  174.             padding-top: 50px;
  175.             overflow-y: auto;
  176.         }
  177.         .kudos-count ul {
  178.             list-style: none;
  179.             padding: 0;
  180.             margin: 0;
  181.         }
  182.         .kudos-count ul li {
  183.             width: 100%;
  184.             display: inline-block;
  185.             padding: 15px 0;
  186.         }
  187.         .kudos-count ul li .uv-icon-kudos  {
  188.             vertical-align: middle;
  189.             margin-right: 10px;
  190.         }
  191.         .uv-activity-wrapper .uv-activity-chart-col-rt {
  192.             width: 20%;
  193.             float: left;
  194.         }
  195.         .uv-activity-chart-col-rt ul {
  196.             padding: 0;
  197.             margin: 0;
  198.             list-style: none;
  199.         }
  200.         .uv-activity-chart-col-rt ul li {
  201.             margin-bottom: 10px
  202.         }
  203.         .uv-activity-chart-col-rt ul li span {
  204.             width: 100%;
  205.             display: inline-block;
  206.             color: #6f6f6f;
  207.         }
  208.         .uv-middle {
  209.             margin: 0 auto;
  210.             display: inline-block;
  211.             margin-top: 200px;
  212.             text-align: center;
  213.             width: 100%;
  214.         }
  215.         @media screen and (max-width: 1024px) {
  216.             .uv-activity-wrapper .uv-activity-chart-col-lt {
  217.                 width: 100%;
  218.                 padding: 0;
  219.             }
  220.             .uv-activity-wrapper .uv-activity-chart-col-rt {
  221.                 width: 100%;
  222.             }
  223.             .kudos-overview {
  224.                 width: 100%;
  225.                 padding: 0;
  226.             }
  227.             .kudos-count {
  228.                 width: 100%;
  229.                 padding: 0;
  230.             }
  231.             .recent-notification {
  232.                 width: 100%;
  233.                 padding: 0;
  234.             }
  235.             ul.uv-activity-brick-wrapper li {
  236.                 width: 50%;
  237.                 margin: 10px 0;
  238.             }
  239.         }
  240.         @media screen and (max-width: 768px) {
  241.             ul.uv-activity-brick-wrapper li {
  242.                 width: 100%;
  243.             }
  244.         }
  245.         @media screen and (max-width: 467px) {
  246.             .completion-chart {
  247.                 width: 100%;
  248.             }
  249.         }
  250.         span.uv-notification-message a:link, span.uv-notification-message a:visited, label a:link, label a:visited {
  251.             color: #2750C4;
  252.             font-size: 15px;
  253.         }
  254.         .uv-mob-aside {
  255.             display: none;
  256.         }
  257.         {# .uv-copyright {
  258.             text-align: center;
  259.         } #}
  260.     </style>
  261.     <div class="uv-area">
  262.         <div>
  263.             <div class="uv-action-bar">
  264.                 <div class="uv-action-bar-col-lt">
  265.                     <label>{{ 'From'|trans }}</label>
  266.                     <div class="uv-field-block date">
  267.                         <input type="text" class="uv-field uv-date-picker date date-from" id="from" value="">
  268.                     </div>
  269.                     <label>{{ 'To'|trans }}</label>
  270.                     <div class="uv-field-block date">
  271.                         <input type="text" class="uv-field uv-date-picker date date-to"  id="to" value="">
  272.                     </div>
  273.                     <input value="year" type="radio" class="toggle " name="options" id="year" autocomplete="off" >
  274.                     <label class="btn" for="year">Last Year</label>
  275.                     <input value="month" type="radio" class="toggle " name="options" id="month" autocomplete="off">
  276.                     <label class="btn" for="month">Last Month</label>
  277.                     <input value="week" type="radio" class="toggle " name="options" id="week" autocomplete="off" >
  278.                     <label class="btn" for="week">Last Week</label>
  279.                     <input value="day" type="radio" class="toggle " name="options" id="day" autocomplete="off" >
  280.                     <label class="btn" for="day">Last Day</label>
  281.                 </div>
  282.                 {# <input value="year" type="radio" class="toggle " name="options" id="year" autocomplete="off" >
  283.                  <label class="btn" for="year">Last Year</label>
  284.                  <input value="month" type="radio" class="toggle " name="options" id="month" autocomplete="off">
  285.                  <label class="btn" for="month">Last Month</label>
  286.                  <input value="week" type="radio" class="toggle " name="options" id="week" autocomplete="off" >
  287.                  <label class="btn" for="week">Last Week</label>
  288.                  <input value="day" type="radio" class="toggle " name="options" id="day" autocomplete="off" >
  289.                  <label class="btn" for="day">Last Day</label>#}
  290.             </div>
  291.             <div class="box-graficos">
  292.                 <div>
  293.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  294.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  295.                     </svg>
  296.                     <b>{{  'Tickets by Status' |trans }}</b><br><br>
  297.                     <div class="graficosTortaBarra" >
  298.                         <span id="contenidoticketsByStatus">
  299.                             {% for tStatus in report_service.ticketsByStatus %}
  300.                                 <label>
  301.                                    <span class='boch'  style="background: {{ tStatus.Color }}"> </span>
  302.                                     ({{ tStatus.Cantidad }}) - {{  tStatus.Nombre }}
  303.                                </label>
  304.                             {% endfor %}
  305.                         </span>
  306.                         <div style="padding:25px;" >
  307.                             <canvas id="ticketsByStatus"   width="700" height="350"></canvas>
  308.                         </div>
  309.                     </div>
  310.                 </div>
  311.                 <div>
  312.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  313.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  314.                     </svg>
  315.                     <b>{{ 'Tickets by Type' |trans }}</b><br><br>
  316.                     <div class="graficosTortaBarra" >
  317.                         <span id="contenidoticketsByType">
  318.                             {% for tStatus in report_service.ticketsByType %}
  319.                                 <label>
  320.                                     <span class='boch'  style="background: {{ tStatus.Color }}"> </span>
  321.                                     ({{ tStatus.Cantidad }}) - {{  tStatus.Nombre }}
  322.                                 </label>
  323.                             {% endfor %}
  324.                         </span>
  325.                         <div style="width: 220px;  margin: 0 auto;padding:25px;">
  326.                             <canvas id="ticketsByType" ></canvas>
  327.                         </div>
  328.                     </div>
  329.                 </div>
  330.                 <div>
  331.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  332.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  333.                     </svg>
  334.                     <b>{{ 'Tickets by Priority' |trans }}</b><br><br>
  335.                     <div class="graficosTortaBarra" >
  336.                         <span id="contenidoticketsByPriority">
  337.                             {% for tPriority in report_service.ticketsByPriority %}
  338.                                 <label>
  339.                                     <span class='boch'  style="background: {{ tPriority.Color }}"> </span>
  340.                                     ({{ tPriority.Cantidad }}) - {{ tPriority.Nombre }}
  341.                                 </label>
  342.                             {% endfor %}
  343.                         </span>
  344.                         <div style="padding:25px;">
  345.                             <canvas id="ticketsByPriority" width="700" height="350"  ></canvas>
  346.                         </div>
  347.                     </div>
  348.                 </div>
  349.                 <div>
  350.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  351.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  352.                     </svg>
  353.                     <b>{{ 'Tickets per Agent' |trans }}</b><br><br>
  354.                     <div class="graficosTortaBarra" >
  355.                         <span id="contenidoticketsPerAgent">
  356.                             {% for tAgent in report_service.ticketsPerAgent %}
  357.                                 <label>
  358.                                     <span class='boch'  style="background: {{ tAgent.Color }}"> </span>
  359.                                     ({{ tAgent.Cantidad }}) - {{  tAgent.Nombre }}
  360.                                 </label>
  361.                             {% endfor %}
  362.                         </span>
  363.                         <div style="padding:25px;width: 220px;  margin: 0 auto;">
  364.                             <canvas id="ticketsPerAgent" ></canvas>
  365.                         </div>
  366.                     </div>
  367.                 </div>
  368.                 <div>
  369.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  370.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  371.                     </svg>
  372.                     <b>{{ 'Tickets per Team' |trans }}</b><br><br>
  373.                     <div class="graficosTortaBarra" >
  374.                         <span id="contenidoticketsPerTeam">
  375.                             {% for tTeam in report_service.ticketsPerTeam %}
  376.                                 <label>
  377.                                     <span class='boch'  style="background: {{ tTeam.Color }}"> </span>
  378.                                     ({{ tTeam.Cantidad }}) - {{  tTeam.Nombre }}
  379.                                 </label>
  380.                             {% endfor %}
  381.                         </span>
  382.                         <div  style="padding:25px;width: 220px;  margin: 0 auto;">
  383.                             <canvas id="ticketsPerTeam" ></canvas>
  384.                         </div>
  385.                     </div>
  386.                 </div>
  387.                 <div>
  388.                     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bar-chart" viewBox="0 0 16 16">
  389.                         <path d="M4 11H2v3h2v-3zm5-4H7v7h2V7zm5-5v12h-2V2h2zm-2-1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1h-2zM6 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm-5 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-3z"/>
  390.                     </svg>
  391.                     <b>{{ 'Kudos' |trans }}</b><br><br>
  392.                     <div class="graficosTortaBarra" >
  393.                         <span id="contenidokudos">
  394.                             {% for tKudos in report_service.Kudos %}
  395.                                 <label>
  396.                                     <span class='boch'  style="background: {{ tKudos.Color }}"> </span>
  397.                                     ({{ tKudos.Cantidad }}) - {{ tKudos.Nombre }}
  398.                                 </label>
  399.                             {% endfor %}
  400.                         </span>
  401.                         <div style="padding:25px;">
  402.                             <canvas id="kudos" width="700" height="350" ></canvas>
  403.                         </div>
  404.                     </div>
  405.                 </div>
  406.             </div>
  407.         </div>
  408.         <div class="uv-copyright">
  409.             <span class="uv-credit-text">Powered by <a href="https://www.uvdesk.com" target="_blank">UVdesk</a></span>
  410.         </div>
  411.     </div>
  412. {% endblock %}
  413. {% block footer %}
  414.     {{ parent() }}
  415.     <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
  416.     <script>
  417.         let startGlobalDate = "";
  418.         let endGlobalDate = "";
  419.         let date = new Date();
  420.         let currentMonth = date.getMonth();
  421.         let currentDate = date.getDate();
  422.         let currentYear = date.getFullYear();
  423.         //Filtros año, mes, semana, dia
  424.         $("input[type='radio']").click(function(){
  425.             currentDate = new Date();
  426.             start = new Date();
  427.             end = new Date();
  428.             $('.uv-action-bar .date').find("#to").val(currentDate.getFullYear() + "-" + (currentDate.getMonth()+1) + "-" + currentDate.getDate());
  429.             var hasta = new Date($('.uv-action-bar .date').find("#to").val());
  430.             switch ($('input[name="options"]:checked').val()) {
  431.                 case "year":
  432.                     start.setFullYear(currentDate.getFullYear() - 1);
  433.                     start.setMonth(0);
  434.                     start.setDate(1);
  435.                     start.setHours(0, 0, 0, 0);
  436.                     end.setFullYear(currentDate.getFullYear() - 1);
  437.                     end.setMonth(11);
  438.                     end.setDate(new Date(currentDate.getFullYear() - 1, 12, 0).getDate())
  439.                     end.setHours(0, 0, 0, 0);
  440.                     datestringStart = start.getFullYear() + "-" + (start.getMonth()+1) + "-" + start.getDate();
  441.                     datestringEnd = end.getFullYear() + "-" + (end.getMonth()+1) + "-" + end.getDate();
  442.                     $('.uv-action-bar .date').find("#from").val(datestringStart)
  443.                     $('.uv-action-bar .date').find("#to").val(datestringEnd).trigger('change');
  444.                     break;
  445.                 case "month":
  446.                     start.setMonth(currentDate.getMonth() - 1);
  447.                     start.setDate(1);
  448.                     start.setHours(0, 0, 0, 0);
  449.                     end.setMonth(currentDate.getMonth() - 1);
  450.                     end.setDate(new Date(end.getFullYear(), end.getMonth(), 0).getDate())
  451.                     end.setHours(0, 0, 0, 0);
  452.                     datestringStart = start.getFullYear() + "-" + (start.getMonth()+1) + "-" + start.getDate();
  453.                     datestringEnd = end.getFullYear() + "-" + (end.getMonth()+1) + "-" + end.getDate();
  454.                     $('.uv-action-bar .date').find("#from").val(datestringStart);
  455.                     $('.uv-action-bar .date').find("#to").val(datestringEnd).trigger('change');
  456.                     break;
  457.                 case "week":
  458.                     var beforeOneWeek = new Date(new Date().getTime() - 60 * 60 * 24 * 7 * 1000)
  459.                     var beforeOneWeek2 = new Date(beforeOneWeek);
  460.                     day = beforeOneWeek.getDay()
  461.                     diffToMonday = beforeOneWeek.getDate() - day + (day === 0 ? -6 : 1)
  462.                     lastMonday = new Date(beforeOneWeek.setDate(diffToMonday))
  463.                     lastSunday = new Date(beforeOneWeek2.setDate(diffToMonday + 6));
  464.                     datestringStart = lastMonday.getFullYear() + "-" + (lastMonday.getMonth()+1) + "-" + lastMonday.getDate();
  465.                     datestringEnd = lastSunday.getFullYear() + "-" + (lastSunday.getMonth()+1) + "-" + lastSunday.getDate();
  466.                     $('.uv-action-bar .date').find("#from").val(datestringStart);
  467.                     $('.uv-action-bar .date').find("#to").val(datestringEnd).trigger('change');
  468.                     break;
  469.                 case "day":
  470.                     start.setFullYear(hasta.getFullYear());
  471.                     start.setMonth(hasta.getMonth());
  472.                     start.setDate(hasta.getDate());
  473.                     start.setHours(0, 0, 0, 0);
  474.                     datestring =  start.getFullYear() + "-" + (start.getMonth()+1) + "-" + start.getDate();
  475.                     $('.uv-action-bar .date').find("#from").val(datestring);
  476.                     $('.uv-action-bar .date').find("#to").val(datestring).trigger('change');
  477.                     break;
  478.             }
  479.         })
  480.         let ticketsByStatus = {{report_service.ticketsByStatus|json_encode|raw}};
  481.         let ticketsByType = {{report_service.ticketsByType|json_encode|raw}};
  482.         let ticketsByPriority = {{report_service.ticketsByPriority|json_encode|raw}};
  483.         let ticketsPerAgent = {{report_service.ticketsPerAgent|json_encode|raw}};
  484.         let ticketsPerTeam = {{report_service.ticketsPerTeam|json_encode|raw}};
  485.         let kudos = {{report_service.kudos|json_encode|raw}};
  486.         $('.uv-action-bar .date #from').datetimepicker({
  487.             maxDate: new Date(currentYear, currentMonth, currentDate),
  488.             format: 'YYYY-MM-DD',
  489.         }).on('dp.change', function(e) {
  490.             filtroFechas();
  491.         });
  492.         $('.uv-action-bar .date #to').datetimepicker({
  493.             maxDate: new Date(currentYear, currentMonth, currentDate),
  494.             format: 'YYYY-MM-DD',
  495.         }).on('dp.change', function(e) {
  496.             filtroFechas();
  497.         });
  498.         const filtroFechas = () => {
  499.             //Filtro fechas
  500.             $.ajax({
  501.                 type: "POST",
  502.                 url: "{{ path('helpdesk_member_report_charts_xhr') }}",
  503.                 data: {
  504.                     'from': $('.uv-action-bar .date').find("#from").val(),
  505.                     'to': $('.uv-action-bar .date').find("#to").val()
  506.                 },
  507.                 dataType: "json",
  508.                 success: function(msg){
  509.                     ticketsByStatus = msg['ticketsByStatus']
  510.                     ticketsByType = msg['ticketsByType']
  511.                     ticketsByPriority = msg['ticketsByPriority']
  512.                     ticketsPerAgent = msg['ticketsPerAgent']
  513.                     ticketsPerTeam = msg['ticketsPerTeam']
  514.                     kudos = msg['kudos']
  515.                     actualizarGraficos();
  516.                     //actualizarGraficos(new Date($('.uv-action-bar .date').find("#from").val()),new Date($('.uv-action-bar .date').find("#to").val()))
  517.                 }
  518.             });
  519.         }
  520.         const capitalizeFirstLetter = (string) => {
  521.             return string.charAt(0).toUpperCase() + string.slice(1);
  522.         }
  523.         const crearGrafico = (tickets, nombre) => {
  524.             let tipo = 'pie'
  525.             let labels = Object.values(tickets).map(function (el) {return el.Nombre })
  526.             let label = ''
  527.             switch(nombre) {
  528.                 case 'kudos':
  529.                     tipo = 'horizontalBar';
  530.                     break;
  531.                 case 'ticketsByStatus':
  532.                     tipo = 'horizontalBar';
  533.                     break;
  534.                 case 'ticketsByPriority':
  535.                     tipo = 'horizontalBar';
  536.                     break;
  537.             }
  538.             return new Chart(
  539.                 document.getElementById(nombre),
  540.                 {
  541.                     type: tipo,
  542.                     data: {
  543.                         labels: labels,
  544.                         datasets: [{
  545.                             label: label,
  546.                             data: Object.values(tickets).map(function (el) { return el.Cantidad }),
  547.                             backgroundColor: Object.values(tickets).map(function (el) { return el.Color }),
  548.                             hoverOffset: 4
  549.                         }]
  550.                     },options: {
  551.                         legend: { display: false }
  552.                     }
  553.                 }
  554.             )
  555.         }
  556.         const actualizaGrafico = (grafico, tickets, nombre) => {
  557.             let labels = Object.values(tickets).map(function (el) {return el.Nombre })
  558.             const data = {
  559.                 labels: labels,
  560.                 datasets: [
  561.                     {
  562.                         label: '',
  563.                         data: Object.values(tickets).map(function (el) { return el.Cantidad }),
  564.                         backgroundColor: Object.values(tickets).map(function (el) { return el.Color }),
  565.                         hoverOffset: 4
  566.                     }
  567.                 ]
  568.             };
  569.             grafico.data.labels = data.labels;
  570.             grafico.data.datasets = data.datasets;
  571.             grafico.update();
  572.             let html = '';
  573.             $.each(tickets, function (key, value) {
  574.                 let Color = value.Color;
  575.                 let Cantidad = value.Cantidad;
  576.                 let Nombre = value.Nombre;
  577.                 html += '<label><span class="boch" style="background: '+ Color +'"></span>  '+ Cantidad +' - '+ Nombre +' </label>';
  578.             });
  579.             $('#'+nombre).html(html);
  580.         }
  581.         //Tickets by Status
  582.         let graficoTicketByStatus = crearGrafico(ticketsByStatus, 'ticketsByStatus')
  583.         //Tickets by type
  584.         let graficoTicketByType = crearGrafico(ticketsByType, 'ticketsByType')
  585.         //Tickets by priority
  586.         let graficoTicketByPriority = crearGrafico(ticketsByPriority, 'ticketsByPriority')
  587.         //Tickets per agent
  588.         let graficoPerAgent = crearGrafico(ticketsPerAgent, 'ticketsPerAgent')
  589.         //Tickets per team
  590.         let graficoPerTeam = crearGrafico(ticketsPerTeam, 'ticketsPerTeam')
  591.         //Kudos
  592.         let graficoKudos = crearGrafico(kudos, 'kudos')
  593.         const actualizarGraficos = () => {
  594.             actualizaGrafico(graficoTicketByStatus, ticketsByStatus, 'contenidoticketsByStatus');
  595.             actualizaGrafico(graficoTicketByType, ticketsByType, 'contenidoticketsByType');
  596.             actualizaGrafico(graficoTicketByPriority, ticketsByPriority, 'contenidoticketsByPriority');
  597.             actualizaGrafico(graficoPerAgent, ticketsPerAgent, 'contenidoticketsPerAgent');
  598.             actualizaGrafico(graficoPerTeam, ticketsPerTeam, 'contenidoticketsPerTeam');
  599.             actualizaGrafico(graficoKudos, kudos, 'contenidokudos');
  600.         }
  601.     </script>
  602. {% endblock %}