PageRenderTime 94ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/approvazione.php

https://bitbucket.org/amorello/changeover
PHP | 256 lines | 210 code | 35 blank | 11 comment | 35 complexity | 1b5ba93df97f5bdc91d1bd0146f07ade MD5 | raw file
  1. <?php
  2. session_start();
  3. include 'CSS/templateTop.html';
  4. require_once 'login.php';
  5. if(!isset($_SESSION['changeover_IDutente'])){
  6. header("location: index.php");
  7. }
  8. else
  9. {
  10. /*
  11. /* per far accedere solo CAVALIERI
  12. if($_SESSION['changeover_IDutente']=='4')
  13. {
  14. */
  15. include 'barramenu.php';
  16. $query = "SELECT * FROM interventi WHERE STATO1=\"R\" && STATO2 =\"S\" && STATO3 =\"D\" ORDER BY datarichiesta";
  17. $result = mysql_query($query);
  18. if (!$result) die ("Database access failed: " . mysql_error());
  19. echo <<<_END
  20. <form action="approvazione.php" method="post" name="inserimento">
  21. <p class="blue"> APPROVAZIONE: </p>
  22. <table border="5" bordercolor= "#6FD1D2" rules="rows" cellspacing="5" width="900" >
  23. <tr bgcolor="#6FD1D2" bordercolor= "#6FD1D2" >
  24. <td>ID</td>
  25. <td >Tipologia</td>
  26. <td>bene</td>
  27. <td>Riferimento</td>
  28. <td>Struttura</td>
  29. <td width="5" >Note</td>
  30. <td width="5">Sopralluogo</td>
  31. <td bgcolor="#FF0000" bordercolor= "#FF0000" >APPROVAZIONE</td>
  32. </tr>
  33. _END;
  34. $righe = mysql_num_rows($result);
  35. for ($j = 0 ; $j < $righe ; ++$j)
  36. {
  37. $row = mysql_fetch_row($result);
  38. $ID = $row[0];
  39. $tipo = $row[1];
  40. if($tipo=='sost'){
  41. $bene = $row[2];
  42. $query = "SELECT * FROM pc WHERE ID=$bene";
  43. $result2 = mysql_query($query);
  44. if (!$result2) die ("Database access failed: " . mysql_error());
  45. $row2 = mysql_fetch_row($result2);
  46. $ID_bene = $row2[1];
  47. $marcamodello= $row2[2];
  48. $ID_monitor = $row2[3];
  49. $pollici= $row2[4];
  50. }else{
  51. $bene = '';
  52. $ID_bene = '';
  53. $marcamodello= '';
  54. $ID_monitor = '';
  55. $pollici= '';
  56. }
  57. $collocazione= $row[3];
  58. $query = "SELECT * FROM collocazione WHERE ID=$collocazione";
  59. $result2 = mysql_query($query);
  60. if (!$result2) die ("Database access failed: " . mysql_error());
  61. $row2 = mysql_fetch_row($result2);
  62. $ubicazione = $row2[1];
  63. $sc= $row2[2];
  64. $ufficio = $row2[3];
  65. $query = "SELECT * FROM sc WHERE ID=$sc";
  66. $result2 = mysql_query($query);
  67. if (!$result2) die ("Database access failed: " . mysql_error());
  68. $row2 = mysql_fetch_row($result2);
  69. $sc = $row2[1];
  70. $cognome_nome_utente = $row[4];
  71. $telefono = $row[5];
  72. $n1 = $row[8];
  73. $n2 = $row[9];
  74. $n3 = $row[10];
  75. $presadirete=$row[6];
  76. $attiva=$row[5];
  77. $sopralluogo = $row[11];
  78. $esito= $row[13];
  79. $datarichiesta = $row[15];
  80. list($data_a,$data_m,$data_g) = explode("-",$datarichiesta);
  81. $time = mktime(0,0,0, $data_m, $data_g, $data_a);
  82. $datarichiesta= date ('d-m-Y',$time);
  83. if($n1!=0)
  84. {
  85. $query = "SELECT nota FROM note WHERE ID=$n1";
  86. $result2 = mysql_query($query);
  87. if (!$result2) die ("Database access failed: " . mysql_error());
  88. $row2 = mysql_fetch_row($result2);
  89. $nota1 = $row2[0];
  90. }else{
  91. $nota1="";
  92. }
  93. if($n2!=0)
  94. {
  95. $query = "SELECT nota FROM note WHERE ID=$n2";
  96. $result2 = mysql_query($query);
  97. if (!$result2) die ("Database access failed: " . mysql_error());
  98. $row2 = mysql_fetch_row($result2);
  99. $nota2 = $row2[0];
  100. }else{
  101. $nota2="";
  102. }
  103. if($n3!=0)
  104. {
  105. $query = "SELECT nota FROM note WHERE ID=$n3";
  106. $result2 = mysql_query($query);
  107. if (!$result2) die ("Database access failed: " . mysql_error());
  108. $row2 = mysql_fetch_row($result2);
  109. $nota3 = $row2[0];
  110. }else{
  111. $nota3="";
  112. }
  113. $query = "SELECT * FROM sopralluogo WHERE ID=\"$sopralluogo\"";
  114. $result2 = mysql_query($query);
  115. if (!$result2) die ("Database access failed: " . mysql_error());
  116. $row2 = mysql_fetch_row($result2);
  117. $presarete = $row2[1];
  118. $corrente = $row2[2];
  119. $nsop = $row2[3];
  120. $operatsop = $row2[4];
  121. $query = "SELECT nome FROM utenti WHERE ID=$operatsop";
  122. $result2 = mysql_query($query);
  123. if (!$result2) die ("Database access failed: " . mysql_error());
  124. $row2 = mysql_fetch_row($result2);
  125. $operatsop = $row2[0];
  126. if($nsop!=0)
  127. {
  128. $query = "SELECT nota FROM note WHERE ID=\"$nsop\"";
  129. $result2 = mysql_query($query);
  130. if (!$result2) die ("Database access failed: " . mysql_error());
  131. $row2 = mysql_fetch_row($result2);
  132. $notasop = $row2[0];
  133. }
  134. else{
  135. $notasop='';
  136. }
  137. echo <<<_END
  138. <tr>
  139. <td><font class="rosso">$ID</font></td>
  140. <td width="5">
  141. _END;
  142. if($tipo=='sost')
  143. echo "<font class=\"blue\">SOST</font>";
  144. if($tipo=='nuovo')
  145. echo"<font class=\"blue\">NUOVO</font>";
  146. echo <<<_END
  147. </td>
  148. <td><u><a title="modello:$marcamodello monitor:$ID_monitor da $pollici pollici"> $ID_bene</a></u></td>
  149. <td><u><a title="telefono $telefono">$cognome_nome_utente</a></u></td>
  150. <td><u><a title="$ubicazione ufficio: $ufficio">$sc</a></u></td>
  151. _END;
  152. if(!empty($nota1) || !empty($nota2) || !empty($nota3)){
  153. echo <<<_END
  154. <td><a title="Programmi: $nota1 \nOrario: $nota2 \nVarie: $nota3"> <img src="CSS/note.JPG" width="20" heigt="20"></a> </td>
  155. _END;
  156. }else{
  157. echo <<<_END
  158. <td></td>
  159. _END;
  160. }
  161. echo <<<_END
  162. <td><u><a title="$operatsop\n
  163. _END;
  164. if($tipo=='nuovo'){
  165. echo "corrente:$corrente presarete:$presarete $presadirete $attiva\n";
  166. }
  167. echo <<<_END
  168. $notasop">S</a><u></td>
  169. _END;
  170. $appro='D';
  171. if(isset($_POST["$ID"])){
  172. $appro= $_POST["$ID"];
  173. if(isset($_POST['salva'])){
  174. if($appro=='S'){
  175. $stato1='A';
  176. }
  177. if($appro=='N'){
  178. $stato1='S';
  179. }
  180. $query = "UPDATE interventi SET STATO1=\"$stato1\", STATO3=\"$appro\" WHERE ID=\"$ID\"";
  181. $result2 = mysql_query($query);
  182. if (!$result2) die ("Database access failed: " . mysql_error());
  183. echo "<td><font class=\"rossop\">SALVATO!</font></td>";
  184. }
  185. }else{
  186. echo <<<_END
  187. <td width="5"><table><tr><td><input
  188. _END;
  189. if ($appro == 'S')
  190. echo "checked ";
  191. echo <<<_END
  192. type="radio" id="pos" name="$ID" value="S" /></td>
  193. <td><label for="pos"><font class="rossop">APPROVATO</font></label></td>
  194. <td><input
  195. _END;
  196. if ($appro == 'N')
  197. echo "checked ";
  198. echo <<<_END
  199. type="radio" id="neg" name="$ID" value="N" /></td>
  200. <td><label for="neg"><font class="rossop">SOSPESO</font></label></td>
  201. </tr></table></td>
  202. _END;
  203. }
  204. echo <<<_END
  205. </tr>
  206. _END;
  207. }
  208. echo <<<_END
  209. </table>
  210. <input type="submit" name="salva" value="SALVA" />
  211. </form>
  212. _END;
  213. /*
  214. } else
  215. {
  216. echo "protezione pagina - no diritti ";
  217. }
  218. */
  219. }
  220. include 'CSS/templateEnd.html';
  221. ?>