frigeri_galvao

Indicador

Feb 13th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.41 KB | None | 0 0
  1. <?php
  2.  
  3. function Feriados($ano,$posicao)
  4.     {
  5.     $dia = 86400;
  6.     $datas = array();
  7.     $datas['pascoa'] = easter_date($ano);
  8.     $datas['sexta_santa'] = $datas['pascoa'] - (2 * $dia);
  9.     $datas['carnaval'] = $datas['pascoa'] - (47 * $dia);
  10.     $datas['corpus_cristi'] = $datas['pascoa'] + (60 * $dia);
  11.     $feriados = array (
  12.                 '01/01',
  13.                 //'02/02',
  14.                 //date('d/m',$datas['carnaval']),
  15.                 date('d/m',$datas['sexta_santa']),
  16.                 date('d/m',$datas['pascoa']),
  17.                 '21/04',
  18.                 '01/05',
  19.                 '26/05',
  20.                 date('d/m',$datas['corpus_cristi']),
  21.                 '20/09', // Revolução Farroupilha \m/
  22.                 '12/10',
  23.                 '02/11',
  24.                 '15/11',
  25.                 '25/12',
  26.                );
  27.    
  28.     return $feriados[$posicao]."/".$ano;
  29.     }
  30.  
  31. function Soma1dia($data)
  32.     {  
  33.     $ano = substr($data, 6,4);
  34.     $mes = substr($data, 3,2);
  35.     $dia = substr($data, 0,2);
  36.     return date("d/m/Y", mktime(0, 0, 0, $mes, $dia+1, $ano));
  37.     }
  38.  
  39. function dataToTimestamp($data)
  40.     {
  41.     $ano = substr($data, 6,4);
  42.     $mes = substr($data, 3,2);
  43.     $dia = substr($data, 0,2);
  44.     return mktime(0, 0, 0, $mes, $dia, $ano);  
  45.     }
  46.  
  47. function CalculaDias($xDataInicial, $xDataFinal)
  48.    {
  49.    $time1 = dataToTimestamp($xDataInicial);  
  50.    $time2 = dataToTimestamp($xDataFinal);  
  51.  
  52.    $tMaior = $time1>$time2 ? $time1 : $time2;  
  53.    $tMenor = $time1<$time2 ? $time1 : $time2;  
  54.  
  55.    $diff = $tMaior-$tMenor;  
  56.    $numDias = $diff/86400;
  57.    return $numDias;
  58.    }
  59.  
  60. function DiasUteis($yDataInicial,$yDataFinal)
  61.    {
  62.    $diaFDS = 0;
  63.    $calculoDias = CalculaDias($yDataInicial, $yDataFinal); //número de dias entre a data inicial e a final
  64.    $diasUteis = 0;
  65.    
  66.    while($yDataInicial!=$yDataFinal){
  67.       $diaSemana = date("w", dataToTimestamp($yDataInicial));
  68.       if($diaSemana==0 || $diaSemana==6){
  69.          //se SABADO OU DOMINGO, SOMA 01
  70.          $diaFDS++;
  71.       }else{
  72.       //senão vemos se este dia é FERIADO
  73.          for($i=0; $i<=12; $i++){
  74.             if($yDataInicial==Feriados(date("Y"),$i)){
  75.                $diaFDS++;  
  76.             }
  77.          }
  78.       }
  79.       $yDataInicial = Soma1dia($yDataInicial); //dia + 1
  80.    }
  81. return $calculoDias - $diaFDS;
  82. }
  83.  
  84. mysql_connect("192.168.0.11", "root", "50ny") or die(mysql_error());
  85. mysql_select_db("glpi2") or die(mysql_error());
  86.  
  87. switch (date("m")){
  88.                 case "01":    $mes_extenso = Janeiro;     break;
  89.                 case "02":    $mes_extenso = Fevereiro;   break;
  90.                 case "03":    $mes_extenso = Março;       break;
  91.                 case "04":    $mes_extenso = Abril;       break;
  92.                 case "05":    $mes_extenso = Maio;        break;
  93.                 case "06":    $mes_extenso = Junho;       break;
  94.                 case "07":    $mes_extenso = Julho;       break;
  95.                 case "08":    $mes_extenso = Agosto;      break;
  96.                 case "09":    $mes_extenso = Setembro;    break;
  97.                 case "10":    $mes_extenso = Outubro;     break;
  98.                 case "11":    $mes_extenso = Novembro;    break;
  99.                 case "12":    $mes_extenso = Dezembro;    break;
  100.             }
  101.  
  102. $datainicio      = "01/02/2013";
  103. $datafim         = "28/02/2013";
  104. $hoje            = date("d/m/Y");
  105. $horas_uteis_dia = 8.8;
  106.  
  107. //##########################################################################################################
  108.  
  109. echo  "<!DOCTYPE HTML>
  110.     <html>
  111.     <head>
  112.     <title>Indicadores de atendimento Marelli </title>";
  113. //echo  "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>";
  114. echo  "</head>
  115.     <body>";
  116. echo  "<font face = 'Verdana'>";
  117.  
  118. echo "<p>M&ecirc;s atual: ";
  119. echo $mes_extenso;
  120. echo "</p>";
  121.  
  122. echo "<p>N&uacute;mero de Horas &Uacute;teis por dia: ";
  123.     echo $horas_uteis_dia;
  124. echo "</p>";
  125.  
  126. echo "<p>N&uacute;mero de dias corridos do at&eacute; hoje: ";
  127.     $dias_corridos = CalculaDias($datainicio, $hoje) + 1;
  128.     echo $dias_corridos;     
  129. echo "</p>";
  130.  
  131. echo "<p>N&uacute;mero de dias &Uacute;teis do M&ecirc;s at&eacute; hoje: ";
  132.     $diasuteis = DiasUteis($datainicio, $hoje) + 1;
  133.     echo $diasuteis;
  134. echo "</p>";
  135.  
  136. echo "<p>N&uacute;mero de horas &Uacute;teis do M&ecirc;s at&eacute; hoje: ";
  137.     $horassuteis = round((DiasUteis($datainicio, $hoje) + 1) * $horas_uteis_dia = 8.8, 2);
  138.     echo $horassuteis;
  139. echo "</p>";
  140.  
  141. echo "<p>N&uacute;mero de dias &Uacute;teis do M&ecirc;s: ";
  142.     $diasuteismes = (int)DiasUteis($datainicio, $datafim) + 1;
  143.     echo $diasuteismes;
  144. echo "</p>";
  145.  
  146. $q_tot_chamados_novos         = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'new'") or die(mysql_error());
  147. //$q_tot_chamados_novos_flavio  = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'new' and users_id_lastupdater = 135") or die(mysql_error());
  148. //$q_tot_chamados_novos_igor    = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'new' and users_id_lastupdater = 157") or die(mysql_error());
  149. //$q_tot_chamados_novos_rodrigo = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'new' and users_id_lastupdater = 332") or die(mysql_error());
  150. //$tot_chamados_novos         = mysql_fetch_array( $q_tot_chamados_novos );
  151. //$tot_chamados_novos_flavio  = mysql_fetch_array( $q_tot_chamados_novos_flavio );
  152. //$tot_chamados_novos_igor    = mysql_fetch_array( $q_tot_chamados_novos_igor );
  153. //$tot_chamados_novos_rodrigo = mysql_fetch_array( $q_tot_chamados_novos_rodrigo );
  154.  
  155. echo "<p align = 'center'>";
  156. echo "<font size = '6' color = '#FF0000'>";
  157. echo "N&uacute;mero de chamados n&atilde;o atendidos: ";
  158.     $tot_chamados_novos = mysql_fetch_array( $q_tot_chamados_novos );
  159.     echo $tot_chamados_novos[0];
  160. echo "</p>";
  161.  
  162.  
  163.  
  164. echo "<table align = 'center' border='1'>";
  165. echo "<tr>
  166.          <th> </th> <th width='90'>Geral</th> <th width='90'>Flavio</th> <th width='90'>Igor</th> <th width='90'>Rodrigo</th>
  167.      </tr>";
  168.  
  169. $q_tot_chamados_geral   = mysql_query("SELECT count(*) FROM glpi_tickets WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59'") or die(mysql_error());
  170. $q_tot_chamados_flavio  = mysql_query("SELECT count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id_lastupdater = 135") or die(mysql_error());
  171. $q_tot_chamados_igor    = mysql_query("SELECT count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id_lastupdater = 157") or die(mysql_error());
  172. $q_tot_chamados_rodrigo = mysql_query("SELECT count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id_lastupdater = 332") or die(mysql_error());
  173. $tot_chamados_geral   = mysql_fetch_array( $q_tot_chamados_geral );
  174. $tot_chamados_flavio  = mysql_fetch_array( $q_tot_chamados_flavio );
  175. $tot_chamados_igor    = mysql_fetch_array( $q_tot_chamados_igor );
  176. $tot_chamados_rodrigo = mysql_fetch_array( $q_tot_chamados_rodrigo );
  177.  
  178. echo    "<tr align=center>";
  179.         echo "<td align=left>Total de Chamados</td> <td>";
  180.         echo $tot_chamados_geral[0] - $tot_chamados_novos[0];
  181.         echo "</td>";
  182.         echo "<td>";
  183.         echo "$tot_chamados_flavio[0]";
  184.         echo "</td>";
  185.         echo "<td>";
  186.         echo "$tot_chamados_igor[0]";
  187.         echo "</td>";
  188.         echo "<td>";
  189.         echo "$tot_chamados_rodrigo[0]";
  190.         echo "</td>";
  191. echo    "</tr>";
  192.  
  193. $q_tot_chamados_abertos         = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'assign'") or die(mysql_error());
  194. $q_tot_chamados_abertos_flavio  = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'assign' and users_id_lastupdater = 135") or die(mysql_error());
  195. $q_tot_chamados_abertos_igor    = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'assign' and users_id_lastupdater = 157") or die(mysql_error());
  196. $q_tot_chamados_abertos_rodrigo = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'assign' and users_id_lastupdater = 332") or die(mysql_error());
  197. $tot_chamados_abertos         = mysql_fetch_array( $q_tot_chamados_abertos );
  198. $tot_chamados_abertos_flavio  = mysql_fetch_array( $q_tot_chamados_abertos_flavio );
  199. $tot_chamados_abertos_igor    = mysql_fetch_array( $q_tot_chamados_abertos_igor );
  200. $tot_chamados_abertos_rodrigo = mysql_fetch_array( $q_tot_chamados_abertos_rodrigo );
  201.  
  202. echo    "<tr align=center>";
  203.         echo "<td align=left>Chamados Abertos</td> <td>";
  204.         echo "$tot_chamados_abertos[0]";
  205.         echo "</td>";
  206.         echo "<td>";
  207.         echo "$tot_chamados_abertos_flavio[0]";
  208.         echo "</td>";
  209.         echo "<td>";
  210.         echo "$tot_chamados_abertos_igor[0]";
  211.         echo "</td>";
  212.         echo "<td>";
  213.         echo "$tot_chamados_abertos_rodrigo[0]";
  214.         echo "</td>";
  215. echo    "</tr>";
  216.  
  217. $q_tot_chamados_fechados         = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'closed'") or die(mysql_error());
  218. $q_tot_chamados_fechados_flavio  = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'closed' and users_id_lastupdater = 135") or die(mysql_error());
  219. $q_tot_chamados_fechados_igor    = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'closed' and users_id_lastupdater = 157") or die(mysql_error());
  220. $q_tot_chamados_fechados_rodrigo = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'closed' and users_id_lastupdater = 332") or die(mysql_error());
  221. $tot_chamados_fechados         = mysql_fetch_array( $q_tot_chamados_fechados );
  222. $tot_chamados_fechados_flavio  = mysql_fetch_array( $q_tot_chamados_fechados_flavio );
  223. $tot_chamados_fechados_igor    = mysql_fetch_array( $q_tot_chamados_fechados_igor );
  224. $tot_chamados_fechados_rodrigo = mysql_fetch_array( $q_tot_chamados_fechados_rodrigo );
  225.  
  226. echo    "<tr align=center>";
  227.         echo "<td align=left>Chamados Fechados</td> <td>";
  228.         echo "$tot_chamados_fechados[0]";
  229.         echo "</td>";
  230.         echo "<td>";
  231.         echo "$tot_chamados_fechados_flavio[0]";
  232.         echo "</td>";
  233.         echo "<td>";
  234.         echo "$tot_chamados_fechados_igor[0]";
  235.         echo "</td>";
  236.         echo "<td>";
  237.         echo "$tot_chamados_fechados_rodrigo[0]";
  238.         echo "</td>";
  239. echo    "</tr>";
  240.  
  241. $q_tot_chamados_solucionados         = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'solved'") or die(mysql_error());
  242. $q_tot_chamados_solucionados_flavio  = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'solved' and users_id_lastupdater = 135") or die(mysql_error());
  243. $q_tot_chamados_solucionados_igor    = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'solved' and users_id_lastupdater = 157") or die(mysql_error());
  244. $q_tot_chamados_solucionados_rodrigo = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and status = 'solved' and users_id_lastupdater = 332") or die(mysql_error());
  245. $tot_chamados_solucionados         = mysql_fetch_array( $q_tot_chamados_solucionados );
  246. $tot_chamados_solucionados_flavio  = mysql_fetch_array( $q_tot_chamados_solucionados_flavio );
  247. $tot_chamados_solucionados_igor    = mysql_fetch_array( $q_tot_chamados_solucionados_igor );
  248. $tot_chamados_solucionados_rodrigo = mysql_fetch_array( $q_tot_chamados_solucionados_rodrigo );
  249.  
  250. echo    "<tr align=center>";
  251.         echo "<td align=left>Chamados Solucionados</td> <td>";
  252.         echo "$tot_chamados_solucionados[0]";
  253.         echo "</td>";
  254.         echo "<td>";
  255.         echo "$tot_chamados_solucionados_flavio[0]";
  256.         echo "</td>";
  257.         echo "<td>";
  258.         echo "$tot_chamados_solucionados_igor[0]";
  259.         echo "</td>";
  260.         echo "<td>";
  261.         echo "$tot_chamados_solucionados_rodrigo[0]";
  262.         echo "</td>";
  263. echo    "</tr>";
  264.  
  265. $q_tot_chamados_pendentes         = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2000-01-01 00:00:00' AND '2013-01-31 23:59:59' and status = 'assign'") or die(mysql_error());
  266. $q_tot_chamados_pendentes_flavio  = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2000-01-01 00:00:00' AND '2013-01-31 23:59:59' and status = 'assign' and users_id_lastupdater = 135") or die(mysql_error());
  267. $q_tot_chamados_pendentes_igor    = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2000-01-01 00:00:00' AND '2013-01-31 23:59:59' and status = 'assign' and users_id_lastupdater = 157") or die(mysql_error());
  268. $q_tot_chamados_pendentes_rodrigo = mysql_query("select count(*) FROM `glpi_tickets` WHERE date BETWEEN '2000-01-01 00:00:00' AND '2013-01-31 23:59:59' and status = 'assign' and users_id_lastupdater = 332") or die(mysql_error());
  269. $tot_chamados_pendentes           = mysql_fetch_array( $q_tot_chamados_pendentes );
  270. $tot_chamados_pendentes_flavio  = mysql_fetch_array( $q_tot_chamados_pendentes_flavio );
  271. $tot_chamados_pendentes_igor    = mysql_fetch_array( $q_tot_chamados_pendentes_igor );
  272. $tot_chamados_pendentes_rodrigo = mysql_fetch_array( $q_tot_chamados_pendentes_rodrigo );
  273.  
  274. echo    "<tr align=center>";
  275.         echo "<td align=left>Chamados Pendentes</td> <td>";
  276.         echo "$tot_chamados_pendentes[0]";
  277.         echo "</td>";
  278.         echo "<td>";
  279.         echo "$tot_chamados_pendentes_flavio[0]";
  280.         echo "</td>";
  281.         echo "<td>";
  282.         echo "$tot_chamados_pendentes_igor[0]";
  283.         echo "</td>";
  284.         echo "<td>";
  285.         echo "$tot_chamados_pendentes_rodrigo[0]";
  286.         echo "</td>";
  287. echo    "</tr>";
  288.  
  289. $q_tot_chamados_segundos         = mysql_query("select sum(actiontime) from glpi_tickettasks where date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59'") or die(mysql_error());
  290. $q_tot_chamados_segundos_flavio  = mysql_query("select sum(actiontime) from glpi_tickettasks where date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id = 135") or die(mysql_error());
  291. $q_tot_chamados_segundos_igor    = mysql_query("select sum(actiontime) from glpi_tickettasks where date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id = 157") or die(mysql_error());
  292. $q_tot_chamados_segundos_rodrigo = mysql_query("select sum(actiontime) from glpi_tickettasks where date BETWEEN '2013-02-01 00:00:00' AND '2013-02-28 23:59:59' and users_id = 332") or die(mysql_error());
  293. $tot_chamados_segundos         = mysql_fetch_array( $q_tot_chamados_segundos );
  294. $tot_chamados_segundos_flavio  = mysql_fetch_array( $q_tot_chamados_segundos_flavio );
  295. $tot_chamados_segundos_igor    = mysql_fetch_array( $q_tot_chamados_segundos_igor );
  296. $tot_chamados_segundos_rodrigo = mysql_fetch_array( $q_tot_chamados_segundos_rodrigo );
  297.  
  298. //echo    "<tr align=center>";
  299. //        echo "<td align=left>Total em Segundos de atendimentos</td> <td>";
  300. //        echo "$tot_chamados_segundos[0]";
  301. //        echo "</td>";
  302. //        echo "<td>";
  303. //        echo "$tot_chamados_segundos_flavio[0]";
  304. //        echo "</td>";
  305. //        echo "<td>";
  306. //        echo "$tot_chamados_segundos_igor[0]";
  307. //        echo "</td>";
  308. //        echo "<td>";
  309. //        echo "$tot_chamados_segundos_rodrigo[0]";
  310. //        echo "</td>";
  311. //echo    "</tr>";
  312.  
  313. echo    "<tr align=center>";
  314.         echo "<td align=left>Total em Horas de atendimentos</td> <td>";
  315.      $hgeral   = round ($tot_chamados_segundos[0]/3600, 2);
  316.      $hflavio  = round ($tot_chamados_segundos_flavio[0]/3600, 2);
  317.      $higor    = round ($tot_chamados_segundos_igor[0]/3600, 2);
  318.      $hrodrigo = round ($tot_chamados_segundos_rodrigo[0]/3600, 2);
  319.         echo "$hgeral";
  320.         echo "</td>";
  321.         echo "<td>";
  322.         echo "$hflavio";
  323.         echo "</td>";
  324.         echo "<td>";
  325.         echo "$higor";
  326.         echo "</td>";
  327.         echo "<td>";
  328.         echo "$hrodrigo";
  329.         echo "</td>";
  330. echo    "</tr>";
  331. echo    "<tr align=center>";
  332.         echo "<td align=left>Total em Dias &uacute;teis de atendimentos</td> <td>";
  333.      $dugeral   = round ($hgeral/$horas_uteis_dia, 2);
  334.      $duflavio  = round ($hflavio/$horas_uteis_dia, 2);
  335.      $duigor    = round ($higor/$horas_uteis_dia, 2);
  336.      $durodrigo = round ($hrodrigo/$horas_uteis_dia, 2);
  337.         echo "$dugeral";
  338.         echo "</td>";
  339.         echo "<td>";
  340.         echo "$duflavio";
  341.         echo "</td>";
  342.         echo "<td>";
  343.         echo "$duigor";
  344.         echo "</td>";
  345.         echo "<td>";
  346.         echo "$durodrigo";
  347.         echo "</td>";
  348. echo    "</tr>";
  349.  
  350. echo    "</table>";
  351.  
  352. //##########################################################################################################
  353.  
  354. echo "<p align=center>";
  355. echo "<img src=\"http://chart.apis.google.com/chart?chs=400x150&chd=t:70,30&cht=p3&chl=Homens|Mulheres&chl=70%|30%&chdl=Homens|Mulheres&chco=c60000|1da3f8&chf=bg,s,58e015\" />";
  356.  
  357. echo "<img src=\"http://chart.apis.google.com/chart?chs=400x150&chd=t:70,30&cht=p3&chl=Homens|Mulheres&chl=70%|30%&chdl=Homens|Mulheres&chco=c60000|1da3f8&chf=bg,s,58e015\" />";
  358. echo "</p>";
  359.  
  360. echo  "</center>
  361.     </body>
  362.     </html>";
  363. ?>
Advertisement
Add Comment
Please, Sign In to add comment