PageRenderTime 57ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/sopralluogo.php

https://bitbucket.org/amorello/changeover
PHP | 359 lines | 326 code | 31 blank | 2 comment | 38 complexity | 980f6597d774d5f28878d331685bbabb 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. include 'barramenu.php';
  11. ?>
  12. <SCRIPT LANGUAGE="JavaScript">
  13. function radioChecked(radioObj) {
  14. if(!radioObj)
  15. return alert("Non hai indicato l'esito!");
  16. var radioLength = radioObj.length;
  17. if(radioLength == undefined)
  18. if(radioObj.checked)
  19. return document.form1.submit();
  20. else
  21. return alert("Non hai indicato l'esito!");;
  22. for(var i = 0; i < radioLength; i++) {
  23. if(radioObj[i].checked) {
  24. return document.form1.submit();
  25. }
  26. }
  27. return alert("Non hai indicato l'esito!");;
  28. }
  29. </SCRIPT>
  30. <?php
  31. $ID = $_POST['ID'];
  32. $presarete = (isset($_POST['presarete'])) ? $_POST['presarete'] : "assente";
  33. $corrente = (isset($_POST['corrente'])) ? $_POST['corrente'] : "assente";
  34. $notasop = (isset($_POST['notasop'])) ? $_POST['notasop'] : '';
  35. $esito = (isset($_POST['esito'])) ? $_POST['esito'] : '';
  36. //recupera i dati dell'intervento
  37. $query = "SELECT * FROM interventi WHERE ID = $ID ";
  38. $result = mysql_query($query);
  39. if (!$result) die ("Database access failed: " . mysql_error());
  40. $row = mysql_fetch_row($result);
  41. $tipo = $row[1];
  42. $codbene = $row[2];
  43. if($tipo=='sost'){
  44. $query = "SELECT * FROM pc WHERE ID=$codbene";
  45. $result2 = mysql_query($query);
  46. if (!$result2) die ("Database access failed: " . mysql_error());
  47. $row2 = mysql_fetch_row($result2);
  48. $ID_bene = $row2[1];
  49. $modello= $row2[2];
  50. $monitor = $row2[3];
  51. $pollici= $row2[4];
  52. }else{
  53. $ID_bene = '';
  54. $modello= '';
  55. $monitor = '';
  56. $pollici= '';
  57. }
  58. $collocazione= $row[3];
  59. $query = "SELECT * FROM collocazione WHERE ID=$collocazione";
  60. $result2 = mysql_query($query);
  61. if (!$result2) die ("Database access failed: " . mysql_error());
  62. $row2 = mysql_fetch_row($result2);
  63. $ubicazione = $row2[1];
  64. $sc= $row2[2];
  65. $ufficio = $row2[3];
  66. $query = "SELECT * FROM sc WHERE ID=$sc";
  67. $result2 = mysql_query($query);
  68. if (!$result2) die ("Database access failed: " . mysql_error());
  69. $row2 = mysql_fetch_row($result2);
  70. $sc = $row2[1];
  71. $cognome_nome_utente = $row[4];
  72. $telefono = $row[5];
  73. $npresarete=$row[6];
  74. $attiva=$row[7];
  75. $n1 = $row[8];
  76. $n2 = $row[9];
  77. $n3 = $row[10];
  78. $data = $row[15];
  79. list($data_a,$data_m,$data_g) = explode("-",$data);
  80. $time = mktime(0,0,0, $data_m, $data_g, $data_a);
  81. $data= date ('d-m-Y',$time);
  82. $sopralluogo = $row[11];
  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. //<<<<<<
  114. if(isset($_POST['esito'])) ///salvataggio dati
  115. {
  116. $nota1 = (isset($_POST['nota1'])) ? $_POST['nota1'] : '';
  117. $nota2 = (isset($_POST['nota2'])) ? $_POST['nota2'] : '';
  118. $nota3 = (isset($_POST['nota3'])) ? $_POST['nota3'] : '';
  119. $npresarete = (isset($_POST['npresarete'])) ? $_POST['npresarete'] : '';
  120. $attiva = (isset($_POST['attiva'])) ? $_POST['attiva'] : '';
  121. if ($n1!=0){
  122. if(!empty($nota1)){
  123. $query = "UPDATE note SET nota=\"$nota1\" WHERE ID=\"$n1\"";
  124. $result = mysql_query($query);
  125. if (!$result) die ("Database access failed: " . mysql_error());
  126. }
  127. else{
  128. $n1=0;
  129. }
  130. }
  131. else{
  132. if(!empty($nota1))
  133. {
  134. $query = "INSERT INTO note(nota ) VALUES (\"$nota1\")";
  135. $result = mysql_query($query);
  136. if (!$result) die ("Database access failed: " . mysql_error());
  137. $n1= mysql_insert_id();
  138. }
  139. }
  140. if ($n2!=0){
  141. if(!empty($nota2)){
  142. $query = "UPDATE note SET nota=\"$nota2\" WHERE ID=\"$n2\"";
  143. $result = mysql_query($query);
  144. if (!$result) die ("Database access failed: " . mysql_error());
  145. }
  146. else{
  147. $n2=0;
  148. }
  149. }
  150. else{
  151. if(!empty($nota2))
  152. {
  153. $query = "INSERT INTO note(nota ) VALUES (\"$nota2\")";
  154. $result = mysql_query($query);
  155. if (!$result) die ("Database access failed: " . mysql_error());
  156. $n2= mysql_insert_id();
  157. }
  158. }
  159. if ($n3!=0){
  160. if(!empty($nota3)){
  161. $query = "UPDATE note SET nota=\"$nota3\" WHERE ID=\"$n3\"";
  162. $result = mysql_query($query);
  163. if (!$result) die ("Database access failed: " . mysql_error());
  164. }
  165. else{
  166. $n3=0;
  167. }
  168. }
  169. else{
  170. if(!empty($nota3))
  171. {
  172. $query = "INSERT INTO note(nota ) VALUES (\"$nota3\")";
  173. $result = mysql_query($query);
  174. if (!$result) die ("Database access failed: " . mysql_error());
  175. $n3= mysql_insert_id();
  176. }
  177. }
  178. if(!empty($notasop))
  179. {
  180. $query = "INSERT INTO note(nota ) VALUES (\"$notasop\")";
  181. $result = mysql_query($query);
  182. if (!$result) die ("Database access failed: " . mysql_error());
  183. $nsop= mysql_insert_id();
  184. }
  185. else{
  186. $nsop=0;
  187. }
  188. $operatore = $_SESSION['changeover_IDutente'];
  189. $query = "INSERT INTO sopralluogo (presarete,corrente,nota,operatore ) VALUES (\"$presarete\",\"$corrente\",\"$nsop\", \"$operatore\")";
  190. $result = mysql_query($query);
  191. if (!$result) die ("Database access failed: " . mysql_error());
  192. $sopralluogo= mysql_insert_id();
  193. $query = "UPDATE interventi SET sopralluogo= \"$sopralluogo\", nota1=\"$n1\", nota2=\"$n2\", nota3=\"$n3\", STATO2=\"$esito\", presadirete=\"$npresarete\",attiva=\"$attiva\" WHERE ID= \"$ID\"";
  194. $result = mysql_query($query);
  195. if (!$result) die ("Database access failed: " . mysql_error());
  196. echo"SOPRALLUOGO INSERITO CON SUCCESSO!<br><br>";
  197. }
  198. //visualizza il form >>>>>
  199. echo <<<_END
  200. <font class="blue">PC</font>&nbsp &nbsp &nbsp &nbsp<font class="rosso">ID: $ID </font>
  201. <table class="ret">
  202. <tr>
  203. <td>
  204. _END;
  205. if($tipo=='sost'){
  206. echo "SOSTITUZIONE:<br>$ID_bene $modello $monitor $pollici <br>";
  207. }
  208. if($tipo=='nuovo'){
  209. echo "NUOVO:<br>";
  210. }
  211. echo <<<_END
  212. $cognome_nome_utente $telefono <br>
  213. $ubicazione $sc $ufficio <br>
  214. _END;
  215. echo <<<_END
  216. <form action="sopralluogo.php" method="post" name="form1"><pre>
  217. <input type="hidden" name="ID" value="$ID">
  218. <input type="hidden" name="tipo" value="$tipo">
  219. Note:
  220. Programmi particolari da installare<br>
  221. <textarea rows="2" cols="50" name="nota1">$nota1</textarea><br>
  222. Esigenze particolari di orario per l'installazione<br>
  223. <textarea rows="2" cols="50" name="nota2">$nota2</textarea><br>
  224. note<br>
  225. <textarea rows="2" cols="50" name="nota3">$nota3</textarea><br>
  226. <br><br>
  227. </td>
  228. </tr>
  229. </table>
  230. <p class="giallo">SOPRALLUOGO</p>
  231. <table>
  232. <tr>
  233. <td id="retg">
  234. _END;
  235. if($tipo=='nuovo'){
  236. echo <<<_END
  237. <table>
  238. <tr>
  239. <td>
  240. <input
  241. _END;
  242. if ($presarete == "presente")
  243. echo "checked ";
  244. echo <<<_END
  245. type="checkbox" name="presarete" value="presente"/>
  246. Presa di rete &nbsp <input type="text" name="npresarete" value="$npresarete" size="10"/>
  247. <select name="attiva" size="1">
  248. <option
  249. _END;
  250. if ($attiva == "")
  251. echo "selected=\"selected\" ";
  252. echo <<<_END
  253. value=""></option>
  254. <option
  255. _END;
  256. if ($attiva == "da attivare")
  257. echo "selected=\"selected\" ";
  258. echo <<<_END
  259. value="da attivare">da attivare</option>
  260. <option
  261. _END;
  262. if ($attiva == "attiva")
  263. echo "selected=\"selected\" ";
  264. echo <<<_END
  265. value="attiva">attiva</option>
  266. </select>
  267. </td>
  268. </tr>
  269. <tr>
  270. <td align="left">
  271. <input
  272. _END;
  273. if ($corrente == "presente")
  274. echo "checked ";
  275. echo <<<_END
  276. type="checkbox" name="corrente" value="presente"/> corrente
  277. </td>
  278. </tr>
  279. </table>
  280. <br>
  281. _END;
  282. }
  283. echo <<<_END
  284. <br>Note:<br>
  285. <textarea rows="4" cols="50" name="notasop">$notasop</textarea><br>
  286. <br>
  287. <table>
  288. <tr>
  289. <td><p class="giallo">ESITO:</p></td>
  290. <td>&nbsp &nbsp<input
  291. _END;
  292. if ($esito == 'S')
  293. echo "checked ";
  294. echo <<<_END
  295. type="radio" id="pos" name="esito" value="S" /></td>
  296. <td><label for="pos"><p class="giallop">POSITIVO</p></label></td>
  297. <td>&nbsp &nbsp</td>
  298. <td><input
  299. _END;
  300. if ($esito == 'N')
  301. echo "checked ";
  302. echo <<<_END
  303. type="radio" id="neg" name="esito" value="N" /></td>
  304. <td><label for="neg"><p class="giallop">NEGATIVO</p></label></td>
  305. </tr>
  306. </table>
  307. <br>
  308. <input type="button" name="salva" value="SALVA" onclick="radioChecked(document.form1.esito)"/></td>
  309. </pre></form>
  310. </td>
  311. </tr>
  312. </table>
  313. _END;
  314. //>>>>>
  315. }
  316. include 'CSS/templateEnd.html';
  317. ?>