PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/cuentas/cuentaDELEGS.php

https://bitbucket.org/sergiohzlz/reportaprod
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
  1. <?php
  2. include ("php-jpgraph/jpgraph.php");
  3. include ("php-jpgraph/jpgraph_line.php");
  4. include_once('../conexion.php');
  5. //mysql_set_charset('utf8',$conexion);
  6. $con = new DBManager;
  7. if (!$con->conectar()) {
  8. echo "<H2>CONEXION CON LA BASE FALLIDA</H2>"; }
  9. mysql_set_charset('utf8',$con->conexion());
  10. function calculaInd($dia,$mes,$anio, $mesIni,$anioIni){
  11. return $res=371*($anio-$anioIni)+31*($mes-($mesIni+1))+($dia-1);
  12. }
  13. // =============
  14. // ------- CONEXION A BASE DE DATOS --------
  15. // -- (poniendo charset a utf8) --
  16. $quien=mysql_real_escape_string($_GET['usu']);
  17. $mesFin=mysql_real_escape_string($_GET['mesFin']);
  18. $anioIni=mysql_real_escape_string($_GET['anioIni']);
  19. $anioFin=mysql_real_escape_string($_GET['anioFin']);
  20. $titulo="Cuantos casos sospechosos hubo en cada mes";
  21. //generando matrices de datos
  22. $dateLocale = new DateLocale();
  23. //$dateLocale->Set('es_MX');
  24. $i=0;
  25. //$quien = 36;
  26. $ParteFija = "
  27. SELECT (year( reporteRutinario.Fecha ) *100 + week( reporteRutinario.Fecha )) AS semana, count(*) as cuantos
  28. FROM reporteRutinario, reporteUsuarios
  29. WHERE (reporteRutinario.IDUsuario = reporteUsuarios.IDUsuario)
  30. AND ( reporteRutinario.`19` >178) AND ((reporteRutinario.`R268` =1)OR (reporteRutinario.`R260` =1))
  31. AND Estado = 9
  32. AND year( reporteRutinario.Fecha ) >= 2009 ";
  33. $sql="
  34. SELECT (year( reporteRutinario.Fecha ) *100 + week( reporteRutinario.Fecha )) AS semana, count(*) as cuantos
  35. FROM reporteRutinario, reporteUsuarios
  36. WHERE (reporteRutinario.IDUsuario = reporteUsuarios.IDUsuario)
  37. AND year( reporteRutinario.Fecha ) >= 2009
  38. AND ( reporteRutinario.`19` >178) AND ((reporteRutinario.`R268` =1)OR (reporteRutinario.`R260` =1))
  39. AND Estado = 9
  40. GROUP BY semana ORDER by semana
  41. ";
  42. $res = mysql_query($sql);
  43. $sqlU=$ParteFija."
  44. AND MPO = \"Álvaro Obegón\"
  45. GROUP BY semana,MPO ORDER by MPO,semana
  46. ";
  47. $resU = mysql_query($sqlU);
  48. $rowU = mysql_fetch_array($resU);
  49. $sqlU2=$ParteFija."
  50. AND MPO = \"Azcapotzalco\"
  51. GROUP BY semana,MPO ORDER by MPO,semana
  52. ";
  53. $resU2 = mysql_query($sqlU2);
  54. $rowU2 = mysql_fetch_array($resU2);
  55. $sqlU3=$ParteFija."
  56. AND MPO = \"Benito Juárez\"
  57. GROUP BY semana,MPO ORDER by MPO,semana
  58. ";
  59. $resU3 = mysql_query($sqlU3);
  60. $rowU3 = mysql_fetch_array($resU3);
  61. $sqlU4=$ParteFija."
  62. AND MPO = \"Coyoacán\"
  63. GROUP BY semana,MPO ORDER by MPO,semana
  64. ";
  65. $resU4 = mysql_query($sqlU4);
  66. $rowU4 = mysql_fetch_array($resU4);
  67. $sqlU5=$ParteFija."
  68. AND MPO = \"Cuajimalpa de Morelos\"
  69. GROUP BY semana,MPO ORDER by MPO,semana
  70. ";
  71. $resU5 = mysql_query($sqlU5);
  72. $rowU5 = mysql_fetch_array($resU5);
  73. $sqlU6=$ParteFija."
  74. AND MPO = \"Cuauhtémoc\"
  75. GROUP BY semana,MPO ORDER by MPO,semana
  76. ";
  77. $resU6 = mysql_query($sqlU6);
  78. $rowU6 = mysql_fetch_array($resU6);
  79. $sqlU7=$ParteFija."
  80. AND MPO = \"Gustavo A. Madero\"
  81. GROUP BY semana,MPO ORDER by MPO,semana
  82. ";
  83. $resU7 = mysql_query($sqlU7);
  84. $rowU7 = mysql_fetch_array($resU7);
  85. $sqlU8=$ParteFija."
  86. AND MPO = \"Iztacalco\"
  87. GROUP BY semana,MPO ORDER by MPO,semana
  88. ";
  89. $resU8 = mysql_query($sqlU8);
  90. $rowU8 = mysql_fetch_array($resU8);
  91. $sqlU9=$ParteFija."
  92. AND MPO = \"Iztapalapa\"
  93. GROUP BY semana,MPO ORDER by MPO,semana
  94. ";
  95. $resU9 = mysql_query($sqlU9);
  96. $rowU9 = mysql_fetch_array($resU9);
  97. $sqlU10=$ParteFija."
  98. AND MPO = \"La Magdalena Contreras\"
  99. GROUP BY semana,MPO ORDER by MPO,semana
  100. ";
  101. $resU10 = mysql_query($sqlU10);
  102. $rowU10 = mysql_fetch_array($resU10);
  103. $sqlU11=$ParteFija."
  104. AND MPO = \"Miguel Hidalgo\"
  105. GROUP BY semana,MPO ORDER by MPO,semana
  106. ";
  107. $resU11 = mysql_query($sqlU11);
  108. $rowU11 = mysql_fetch_array($resU11);
  109. $sqlU12=$ParteFija."
  110. AND MPO = \"Milpa Alta\"
  111. GROUP BY semana,MPO ORDER by MPO,semana
  112. ";
  113. $resU12 = mysql_query($sqlU12);
  114. $rowU12 = mysql_fetch_array($resU12);
  115. $sqlU13=$ParteFija."
  116. AND MPO = \"Tláhuac\"
  117. GROUP BY semana,MPO ORDER by MPO,semana
  118. ";
  119. $resU13 = mysql_query($sqlU13);
  120. $rowU13 = mysql_fetch_array($resU13);
  121. $sqlU14=$ParteFija."
  122. AND MPO = \"Tlalpan\"
  123. GROUP BY semana,MPO ORDER by MPO,semana
  124. ";
  125. $resU14 = mysql_query($sqlU14);
  126. $rowU14 = mysql_fetch_array($resU14);
  127. $sqlU15=$ParteFija."
  128. AND MPO = \"Venustiano Carranza\"
  129. GROUP BY semana,MPO ORDER by MPO,semana
  130. ";
  131. $resU15 = mysql_query($sqlU15);
  132. $rowU15 = mysql_fetch_array($resU15);
  133. $sqlU16=$ParteFija."
  134. AND MPO = \"Xochimilco\"
  135. GROUP BY semana,MPO ORDER by MPO,semana
  136. ";
  137. $resU16 = mysql_query($sqlU16);
  138. $rowU16 = mysql_fetch_array($resU16);
  139. $ydata = array();
  140. $ydata2 = array();
  141. $ydata3 = array();
  142. $ydata4 = array();
  143. $ydata5 = array();
  144. $ydata6 = array();
  145. $ydata7 = array();
  146. $ydata8 = array();
  147. $ydata9 = array();
  148. $ydata10 = array();
  149. $ydata11 = array();
  150. $ydata12 = array();
  151. $ydata13 = array();
  152. $ydata14 = array();
  153. $ydata15 = array();
  154. $ydata16 = array();
  155. $dataZ = array();
  156. $j = 0;
  157. if ($rowU['semana']==NULL)
  158. {
  159. $rowU = mysql_fetch_array($resU);
  160. }
  161. while ($row=mysql_fetch_array($res))
  162. {
  163. if ($row['semana']!=NULL)
  164. {
  165. $datax[$j] = $row['semana'];
  166. $dataZ[$j] = $row['cuantos'];
  167. if (strcasecmp($row['semana'],$rowU['semana'])==0)
  168. { $ydata[$j] = $rowU['cuantos']; $rowU = mysql_fetch_array($resU); }
  169. else
  170. { $ydata[$j] = 0; }
  171. if (strcasecmp($row['semana'],$rowU2['semana'])==0)
  172. { $ydata2[$j] = $rowU2['cuantos']; $rowU2 = mysql_fetch_array($resU2); }
  173. else
  174. { $ydata2[$j] = 0; }
  175. if (strcasecmp($row['semana'],$rowU3['semana'])==0)
  176. { $ydata3[$j] = $rowU3['cuantos']; $rowU3 = mysql_fetch_array($resU3); }
  177. else
  178. { $ydata3[$j] = 0; }
  179. if (strcasecmp($row['semana'],$rowU4['semana'])==0)
  180. { $ydata4[$j] = $rowU4['cuantos']; $rowU4 = mysql_fetch_array($resU4); }
  181. else
  182. { $ydata4[$j] = 0; }
  183. if (strcasecmp($row['semana'],$rowU5['semana'])==0)
  184. { $ydata5[$j] = $rowU5['cuantos']; $rowU5 = mysql_fetch_array($resU5); }
  185. else
  186. { $ydata5[$j] = 0; }
  187. if (strcasecmp($row['semana'],$rowU6['semana'])==0)
  188. { $ydata6[$j] = $rowU6['cuantos']; $rowU6 = mysql_fetch_array($resU6); }
  189. else
  190. { $ydata6[$j] = 0; }
  191. if (strcasecmp($row['semana'],$rowU7['semana'])==0)
  192. { $ydata7[$j] = $rowU7['cuantos']; $rowU7 = mysql_fetch_array($resU7); }
  193. else
  194. { $ydata7[$j] = 0; }
  195. if (strcasecmp($row['semana'],$rowU8['semana'])==0)
  196. { $ydata8[$j] = $rowU8['cuantos']; $rowU8 = mysql_fetch_array($resU8); }
  197. else
  198. { $ydata8[$j] = 0; }
  199. if (strcasecmp($row['semana'],$rowU9['semana'])==0)
  200. { $ydata9[$j] = $rowU9['cuantos']; $rowU9 = mysql_fetch_array($resU9); }
  201. else
  202. { $ydata9[$j] = 0; }
  203. if (strcasecmp($row['semana'],$rowU10['semana'])==0)
  204. { $ydata10[$j] = $rowU10['cuantos']; $rowU10 = mysql_fetch_array($resU10); }
  205. else
  206. { $ydata10[$j] = 0; }
  207. if (strcasecmp($row['semana'],$rowU11['semana'])==0)
  208. { $ydata11[$j] = $rowU11['cuantos']; $rowU11 = mysql_fetch_array($resU11); }
  209. else
  210. { $ydata11[$j] = 0; }
  211. if (strcasecmp($row['semana'],$rowU12['semana'])==0)
  212. { $ydata12[$j] = $rowU12['cuantos']; $rowU12 = mysql_fetch_array($resU12); }
  213. else
  214. { $ydata12[$j] = 0; }
  215. if (strcasecmp($row['semana'],$rowU13['semana'])==0)
  216. { $ydata13[$j] = $rowU13['cuantos']; $rowU13 = mysql_fetch_array($resU13); }
  217. else
  218. { $ydata13[$j] = 0; }
  219. if (strcasecmp($row['semana'],$rowU14['semana'])==0)
  220. { $ydata14[$j] = $rowU14['cuantos']; $rowU14 = mysql_fetch_array($resU14); }
  221. else
  222. { $ydata14[$j] = 0; }
  223. if (strcasecmp($row['semana'],$rowU15['semana'])==0)
  224. { $ydata15[$j] = $rowU15['cuantos']; $rowU15 = mysql_fetch_array($resU15); }
  225. else
  226. { $ydata15[$j] = 0; }
  227. if (strcasecmp($row['semana'],$rowU16['semana'])==0)
  228. { $ydata16[$j] = $rowU16['cuantos']; $rowU16 = mysql_fetch_array($resU16); }
  229. else
  230. { $ydata16[$j] = 0; }
  231. print ($datax[$j]);
  232. print ("; ");
  233. print ($ydata[$j]);
  234. print ("; ");
  235. print ($ydata2[$j]);
  236. print ("; ");
  237. print ($ydata3[$j]);
  238. print ("; ");
  239. print ($ydata4[$j]);
  240. print ("; ");
  241. print ($ydata5[$j]);
  242. print ("; ");
  243. print ($ydata6[$j]);
  244. print ("; ");
  245. print ($ydata7[$j]);
  246. print ("; ");
  247. print ($ydata8[$j]);
  248. print ("; ");
  249. print ($ydata9[$j]);
  250. print ("; ");
  251. print ($ydata10[$j]);
  252. print ("; ");
  253. print ($ydata11[$j]);
  254. print ("; ");
  255. print ($ydata12[$j]);
  256. print ("; ");
  257. print ($ydata13[$j]);
  258. print ("; ");
  259. print ($ydata14[$j]);
  260. print ("; ");
  261. print ($ydata15[$j]);
  262. print ("; ");
  263. print ($ydata16[$j]);
  264. print ("; ");
  265. print ($dataZ[$j]);
  266. print ("\n\n<br>");
  267. $j = $j+1;
  268. }
  269. }
  270. ?>