<https://lh3.googleusercontent.com/-Ks4jSDoO-Es/Wnwz7p2HGmI/AAAAAAAAAI4/1xG1XMfT02AbZ_lixscHz9yPjfNhrwISwCLcBGAs/s1600/172%2B17%2B0%2B2%2Breportpsql%2Basm_report_dashboard%2Bphp%2Btqx%2Bout%2B3Acsv%2B3B.png>
dear team this is my code and i want to export all data into excelsheet 
please help me .as soon as possible.



<html>
  <head>

  <?php

    require_once "dashlet_config.php";

        $con = pg_connect("host=$creds[0] port=5432 user=$creds[1] 
password=$creds[2] dbname=$creds[3]");

        $query = 'SELECT a.ticket_number,
       a.subject,
       a.queue_name,
       a.create_time,
       a.ticket_priority,
       a.ticket_type,
       a.ticket_state,
       a.sla,
       a.ticket_agent,
       a.response_time,
       a.solution_time,
       to_char(a.ticket_Max_time - a.create_time, \'DD" D "HH24 h":"MI 
m\')as age from
        ( SELECT DISTINCT(concat(\'#\',t.tn)) as ticket_number,t.title as 
subject,(SELECT q.name from queue q WHERE q.id = t.queue_id) as queue_name,
        t.create_time,
        (select tp.name from ticket_priority tp where tp.id = 
t.ticket_priority_id) as ticket_priority,
        (select tt.name from ticket_type tt where tt.id = t.type_id) as 
ticket_type,
        (select ts.name from ticket_state ts where ts.id = 
t.ticket_state_id) as ticket_state,
        (select s.name from sla s where s.id = t.sla_id) as sla,

        (select u.first_name||\' \'||u.last_name from users u where u.id = 
t.user_id) as ticket_agent,
        TO_CHAR((s.first_response_time || \' minute\')::interval, \'MI m\') 
as response_time,
        TO_CHAR((s.solution_time || \' minute\')::interval, \'HH24 h:MI 
m\') AS solution_time,

  (SELECT max(create_time)
   FROM ticket_history
   WHERE ticket_id = t.id
     AND history_type_id=27
     AND t.ticket_state_id = 10
   GROUP BY create_time
   LIMIT 1) AS ticket_Max_time
FROM ticket t
JOIN sla s ON s.id = t.sla_id)a';

          $result = pg_query($query);

        if (pg_num_rows($result) == 0) {
            echo "No rows found, nothing to print so am exiting";
        }
  ?>

    <link rel="stylesheet" type="text/css" 
href="clients/bootstrap/css/bootstrap.css">
    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['table']});
      google.charts.setOnLoadCallback(sendAndDraw);

      function sendAndDraw(queryString) {

        var container = document.getElementById('table');
        var data = new google.visualization.DataTable(container);
         visualization = new google.visualization.DataTable(container);
         new 
google.visualization.Query('https://spreadsheets.google.com/tq?key=pCQbetd-CptHnwJEfo8tALA').
          send(queryCallback);
        var data = google.visualization.arrayToDataTable([
              ['Ticket#','age','Created','Type','Subject','Queue','First 
Response Time','Solution Time','Sla','Priority','State','Owner'],
              <?php
                while($row = pg_fetch_assoc($result)){
                  echo 
"['".$row["ticket_number"]."','".$row["age"]."','".$row["create_time"]."','".$row["ticket_type"]."',
 
'".$row["subject"]."', '".$row["queue_name"]."', 
'".$row["response_time"]."', '".$row["solution_time"]."', 
'".$row["sla"]."','".$row["ticket_priority"]."','".$row["ticket_state"]."','".$row["ticket_agent"]."'],";
                }    
              ?>
              ]);

        var table = new 
google.visualization.Table(document.getElementById('container'));

        table.draw(data, {page: 'enable',pageSize:'10', width: '100%'});

        function selectHandler() {
            var selection = table.getSelection();
            var message = '';
              for (var i = 0; i < selection.length; i++) {
                var item = selection[i];
                  if (item.row != null && item.column != null) {
                var str = data.getFormattedValue(item.row, item.column);
                  message += ' = ' + str + '\n';
              } else if (item.row != null) {
                var str = data.getFormattedValue(item.row, 0);
                  message += 'value = ' + str + '\n';
              } else if (item.column != null) {
                var str = data.getFormattedValue(0, item.column);
                 message += 'value = ' + str + '\n';
              }
            }
              if (message == '') {
                message = 'nothing';
              }
            alert('You selected ' + message);
          }
          /********** function for refresh the page**************/
          setTimeout(function(){
             window.location.reload(1);
          }, 30000);
          drawToolbar();
        }
         function queryCallback(response) {
      visualization.draw(response.getDataTable(), {is3D: true});
    }

        /***************function for export csv *************/
    function drawToolbar() {
        var components = [
            {type: 'csv', datasource: 
'https://spreadsheets.google.com/tq?key=pCQbetd-CptHnwJEfo8tALA',
             style: 'width: 800px; height: 700px; border: 3px solid 
purple;'}
        ];

        var container = document.getElementById('toolbar_div');
        google.visualization.drawToolbar(container, components);
    };
     
    </script>
  </head>
  <link rel="stylesheet" href="custom.css" type="text/css">
  <body>
    <div class="tkt-con">
      <h6>All Tickets</h6>
      <div id="container" class="cus-grid"></div>
      <div id="toolbar_div"></div>
    </div>
  </body>
</html>

-- 
*Disclaimer :* The contents of this e-mail and attachment(s) thereto are 
confidential and intended for the named recipient(s) only. It shall not 
attach any liability on the originator or Unotech Software Pvt. Ltd. or its 
affiliates. Any views or opinions presented in this email are solely those 
of the author and may not necessarily reflect the opinions of Unotech 
Software Pvt. Ltd. or its affiliates. Any form of reproduction, 
dissemination, copying, disclosure, modification, distribution and / or 
publication of this message without the prior written consent of the author 
of this e-mail is strictly prohibited. If you have received this email in 
error please delete it and notify the sender immediately.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/43ca1736-04e5-478d-9951-9f2fedc3ac4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to