/cuentas/cuentaDELEGS.php
PHP | 351 lines | 263 code | 81 blank | 7 comment | 20 complexity | 2f1afe656297cfdbf52b601b3e09516c MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
- <?php
- include ("php-jpgraph/jpgraph.php");
- include ("php-jpgraph/jpgraph_line.php");
- include_once('../conexion.php');
- //mysql_set_charset('utf8',$conexion);
- $con = new DBManager;
- if (!$con->conectar()) {
- echo "<H2>CONEXION CON LA BASE FALLIDA</H2>"; }
- mysql_set_charset('utf8',$con->conexion());
- function calculaInd($dia,$mes,$anio, $mesIni,$anioIni){
- return $res=371*($anio-$anioIni)+31*($mes-($mesIni+1))+($dia-1);
- }
- // =============
- // ------- CONEXION A BASE DE DATOS --------
- // -- (poniendo charset a utf8) --
- $quien=mysql_real_escape_string($_GET['usu']);
- $mesFin=mysql_real_escape_string($_GET['mesFin']);
- $anioIni=mysql_real_escape_string($_GET['anioIni']);
- $anioFin=mysql_real_escape_string($_GET['anioFin']);
- $titulo="Cuantos casos sospechosos hubo en cada mes";
- //generando matrices de datos
- $dateLocale = new DateLocale();
- //$dateLocale->Set('es_MX');
- $i=0;
- //$quien = 36;
- $ParteFija = "
- SELECT (year( reporteRutinario.Fecha ) *100 + week( reporteRutinario.Fecha )) AS semana, count(*) as cuantos
- FROM reporteRutinario, reporteUsuarios
- WHERE (reporteRutinario.IDUsuario = reporteUsuarios.IDUsuario)
- AND ( reporteRutinario.`19` >178) AND ((reporteRutinario.`R268` =1)OR (reporteRutinario.`R260` =1))
- AND Estado = 9
- AND year( reporteRutinario.Fecha ) >= 2009 ";
- $sql="
- SELECT (year( reporteRutinario.Fecha ) *100 + week( reporteRutinario.Fecha )) AS semana, count(*) as cuantos
- FROM reporteRutinario, reporteUsuarios
- WHERE (reporteRutinario.IDUsuario = reporteUsuarios.IDUsuario)
- AND year( reporteRutinario.Fecha ) >= 2009
- AND ( reporteRutinario.`19` >178) AND ((reporteRutinario.`R268` =1)OR (reporteRutinario.`R260` =1))
- AND Estado = 9
- GROUP BY semana ORDER by semana
- ";
- $res = mysql_query($sql);
- $sqlU=$ParteFija."
- AND MPO = \"Álvaro Obegón\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU = mysql_query($sqlU);
- $rowU = mysql_fetch_array($resU);
- $sqlU2=$ParteFija."
- AND MPO = \"Azcapotzalco\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU2 = mysql_query($sqlU2);
- $rowU2 = mysql_fetch_array($resU2);
- $sqlU3=$ParteFija."
- AND MPO = \"Benito Juárez\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU3 = mysql_query($sqlU3);
- $rowU3 = mysql_fetch_array($resU3);
- $sqlU4=$ParteFija."
- AND MPO = \"Coyoacán\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU4 = mysql_query($sqlU4);
- $rowU4 = mysql_fetch_array($resU4);
- $sqlU5=$ParteFija."
- AND MPO = \"Cuajimalpa de Morelos\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU5 = mysql_query($sqlU5);
- $rowU5 = mysql_fetch_array($resU5);
- $sqlU6=$ParteFija."
- AND MPO = \"Cuauhtémoc\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU6 = mysql_query($sqlU6);
- $rowU6 = mysql_fetch_array($resU6);
- $sqlU7=$ParteFija."
- AND MPO = \"Gustavo A. Madero\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU7 = mysql_query($sqlU7);
- $rowU7 = mysql_fetch_array($resU7);
- $sqlU8=$ParteFija."
- AND MPO = \"Iztacalco\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU8 = mysql_query($sqlU8);
- $rowU8 = mysql_fetch_array($resU8);
- $sqlU9=$ParteFija."
- AND MPO = \"Iztapalapa\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU9 = mysql_query($sqlU9);
- $rowU9 = mysql_fetch_array($resU9);
- $sqlU10=$ParteFija."
- AND MPO = \"La Magdalena Contreras\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU10 = mysql_query($sqlU10);
- $rowU10 = mysql_fetch_array($resU10);
- $sqlU11=$ParteFija."
- AND MPO = \"Miguel Hidalgo\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU11 = mysql_query($sqlU11);
- $rowU11 = mysql_fetch_array($resU11);
- $sqlU12=$ParteFija."
- AND MPO = \"Milpa Alta\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU12 = mysql_query($sqlU12);
- $rowU12 = mysql_fetch_array($resU12);
- $sqlU13=$ParteFija."
- AND MPO = \"Tláhuac\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU13 = mysql_query($sqlU13);
- $rowU13 = mysql_fetch_array($resU13);
- $sqlU14=$ParteFija."
- AND MPO = \"Tlalpan\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU14 = mysql_query($sqlU14);
- $rowU14 = mysql_fetch_array($resU14);
- $sqlU15=$ParteFija."
- AND MPO = \"Venustiano Carranza\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU15 = mysql_query($sqlU15);
- $rowU15 = mysql_fetch_array($resU15);
- $sqlU16=$ParteFija."
- AND MPO = \"Xochimilco\"
- GROUP BY semana,MPO ORDER by MPO,semana
- ";
- $resU16 = mysql_query($sqlU16);
- $rowU16 = mysql_fetch_array($resU16);
- $ydata = array();
- $ydata2 = array();
- $ydata3 = array();
- $ydata4 = array();
- $ydata5 = array();
- $ydata6 = array();
- $ydata7 = array();
- $ydata8 = array();
- $ydata9 = array();
- $ydata10 = array();
- $ydata11 = array();
- $ydata12 = array();
- $ydata13 = array();
- $ydata14 = array();
- $ydata15 = array();
- $ydata16 = array();
- $dataZ = array();
- $j = 0;
- if ($rowU['semana']==NULL)
- {
- $rowU = mysql_fetch_array($resU);
- }
- while ($row=mysql_fetch_array($res))
- {
- if ($row['semana']!=NULL)
- {
- $datax[$j] = $row['semana'];
- $dataZ[$j] = $row['cuantos'];
- if (strcasecmp($row['semana'],$rowU['semana'])==0)
- { $ydata[$j] = $rowU['cuantos']; $rowU = mysql_fetch_array($resU); }
- else
- { $ydata[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU2['semana'])==0)
- { $ydata2[$j] = $rowU2['cuantos']; $rowU2 = mysql_fetch_array($resU2); }
- else
- { $ydata2[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU3['semana'])==0)
- { $ydata3[$j] = $rowU3['cuantos']; $rowU3 = mysql_fetch_array($resU3); }
- else
- { $ydata3[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU4['semana'])==0)
- { $ydata4[$j] = $rowU4['cuantos']; $rowU4 = mysql_fetch_array($resU4); }
- else
- { $ydata4[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU5['semana'])==0)
- { $ydata5[$j] = $rowU5['cuantos']; $rowU5 = mysql_fetch_array($resU5); }
- else
- { $ydata5[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU6['semana'])==0)
- { $ydata6[$j] = $rowU6['cuantos']; $rowU6 = mysql_fetch_array($resU6); }
- else
- { $ydata6[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU7['semana'])==0)
- { $ydata7[$j] = $rowU7['cuantos']; $rowU7 = mysql_fetch_array($resU7); }
- else
- { $ydata7[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU8['semana'])==0)
- { $ydata8[$j] = $rowU8['cuantos']; $rowU8 = mysql_fetch_array($resU8); }
- else
- { $ydata8[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU9['semana'])==0)
- { $ydata9[$j] = $rowU9['cuantos']; $rowU9 = mysql_fetch_array($resU9); }
- else
- { $ydata9[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU10['semana'])==0)
- { $ydata10[$j] = $rowU10['cuantos']; $rowU10 = mysql_fetch_array($resU10); }
- else
- { $ydata10[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU11['semana'])==0)
- { $ydata11[$j] = $rowU11['cuantos']; $rowU11 = mysql_fetch_array($resU11); }
- else
- { $ydata11[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU12['semana'])==0)
- { $ydata12[$j] = $rowU12['cuantos']; $rowU12 = mysql_fetch_array($resU12); }
- else
- { $ydata12[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU13['semana'])==0)
- { $ydata13[$j] = $rowU13['cuantos']; $rowU13 = mysql_fetch_array($resU13); }
- else
- { $ydata13[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU14['semana'])==0)
- { $ydata14[$j] = $rowU14['cuantos']; $rowU14 = mysql_fetch_array($resU14); }
- else
- { $ydata14[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU15['semana'])==0)
- { $ydata15[$j] = $rowU15['cuantos']; $rowU15 = mysql_fetch_array($resU15); }
- else
- { $ydata15[$j] = 0; }
- if (strcasecmp($row['semana'],$rowU16['semana'])==0)
- { $ydata16[$j] = $rowU16['cuantos']; $rowU16 = mysql_fetch_array($resU16); }
- else
- { $ydata16[$j] = 0; }
- print ($datax[$j]);
- print ("; ");
- print ($ydata[$j]);
- print ("; ");
- print ($ydata2[$j]);
- print ("; ");
- print ($ydata3[$j]);
- print ("; ");
- print ($ydata4[$j]);
- print ("; ");
- print ($ydata5[$j]);
- print ("; ");
- print ($ydata6[$j]);
- print ("; ");
- print ($ydata7[$j]);
- print ("; ");
- print ($ydata8[$j]);
- print ("; ");
- print ($ydata9[$j]);
- print ("; ");
- print ($ydata10[$j]);
- print ("; ");
- print ($ydata11[$j]);
- print ("; ");
- print ($ydata12[$j]);
- print ("; ");
- print ($ydata13[$j]);
- print ("; ");
- print ($ydata14[$j]);
- print ("; ");
- print ($ydata15[$j]);
- print ("; ");
- print ($ydata16[$j]);
- print ("; ");
- print ($dataZ[$j]);
- print ("\n\n<br>");
- $j = $j+1;
- }
- }
- ?>