PageRenderTime 173ms CodeModel.GetById 39ms RepoModel.GetById 2ms app.codeStats 1ms

/modifica.php

https://bitbucket.org/amorello/changeover
PHP | 454 lines | 401 code | 44 blank | 9 comment | 84 complexity | afcc99300fc398414c3886d897aab1e2 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 alla pagina solo un amministratore
  12. if($_SESSION['nonconf_DBA']=='Y')
  13. {
  14. */
  15. include 'barramenu.php';
  16. $ID = $_POST['ID'];
  17. if(isset($_POST['elimina'])){
  18. $query = "DELETE FROM interventi WHERE ID=\"$ID\"";
  19. $result = mysql_query($query);
  20. if (!$result) die ("Database access failed: " . mysql_error());
  21. echo "RICHIESTA ELIMINATA CON SUCCESSO!!";
  22. }
  23. else{
  24. $query = "SELECT * FROM interventi WHERE ID = $ID ";
  25. $result = mysql_query($query);
  26. if (!$result) die ("Database access failed: " . mysql_error());
  27. $row = mysql_fetch_row($result);
  28. $tipo = $row[1];
  29. $codbene = $row[2];
  30. if($tipo=='sost'){
  31. $query = "SELECT * FROM pc WHERE ID=$codbene";
  32. $result2 = mysql_query($query);
  33. if (!$result2) die ("Database access failed: " . mysql_error());
  34. $row2 = mysql_fetch_row($result2);
  35. $ID_bene = $row2[1];
  36. $modello= $row2[2];
  37. $monitor = $row2[3];
  38. $pollici= $row2[4];
  39. }else{
  40. $ID_bene = '';
  41. $modello= '';
  42. $monitor = '';
  43. $pollici= '';
  44. }
  45. $collocazione= $row[3];
  46. $query = "SELECT * FROM collocazione WHERE ID=$collocazione";
  47. $result2 = mysql_query($query);
  48. if (!$result2) die ("Database access failed: " . mysql_error());
  49. $row2 = mysql_fetch_row($result2);
  50. $ubicazione = $row2[1];
  51. $sc= $row2[2];
  52. $ufficio = $row2[3];
  53. $cognome_nome_utente = $row[4];
  54. $telefono = $row[5];
  55. $presarete=$row[6];
  56. $attiva=$row[7];
  57. $n1 = $row[8];
  58. $n2 = $row[9];
  59. $n3 = $row[10];
  60. $data = $row[15];
  61. list($data_a,$data_m,$data_g) = explode("-",$data);
  62. $time = mktime(0,0,0, $data_m, $data_g, $data_a);
  63. $data= date ('d-m-Y',$time);
  64. $sopralluogo = $row[11];
  65. if($n1!=0)
  66. {
  67. $query = "SELECT nota FROM note WHERE ID=$n1";
  68. $result2 = mysql_query($query);
  69. if (!$result2) die ("Database access failed: " . mysql_error());
  70. $row2 = mysql_fetch_row($result2);
  71. $nota1 = $row2[0];
  72. }else{
  73. $nota1="";
  74. }
  75. if($n2!=0)
  76. {
  77. $query = "SELECT nota FROM note WHERE ID=$n2";
  78. $result2 = mysql_query($query);
  79. if (!$result2) die ("Database access failed: " . mysql_error());
  80. $row2 = mysql_fetch_row($result2);
  81. $nota2 = $row2[0];
  82. }else{
  83. $nota2="";
  84. }
  85. if($n3!=0)
  86. {
  87. $query = "SELECT nota FROM note WHERE ID=$n3";
  88. $result2 = mysql_query($query);
  89. if (!$result2) die ("Database access failed: " . mysql_error());
  90. $row2 = mysql_fetch_row($result2);
  91. $nota3 = $row2[0];
  92. }else{
  93. $nota3="";
  94. }
  95. if(isset($_POST['ID_bene']))
  96. $ID_bene = $_POST['ID_bene'];
  97. if(isset($_POST['modello']))
  98. $modello = $_POST['modello'];
  99. if(isset($_POST['monitor']))
  100. $monitor =$_POST['monitor'];
  101. if(isset($_POST['pollici']))
  102. $pollici =$_POST['pollici'] ;
  103. if(isset($_POST['presarete']))
  104. $presarete = $_POST['presarete'] ;
  105. if(isset($_POST['attiva']))
  106. $attiva =$_POST['attiva'] ;
  107. if(isset($_POST['ubicazione']))
  108. $ubicazione = $_POST['ubicazione'] ;
  109. if(isset($_POST['sc']))
  110. $sc = $_POST['sc'];
  111. if(isset($_POST['ufficio']))
  112. $ufficio = $_POST['ufficio'] ;
  113. if (isset($_POST['cognome_nome_utente']))
  114. $cognome_nome_utente =$_POST['cognome_nome_utente'] ;
  115. if(isset($_POST['telefono']))
  116. $telefono = $_POST['telefono'] ;
  117. if(isset($_POST['nota1']))
  118. $nota1 = $_POST['nota1'] ;
  119. if(isset($_POST['nota2']))
  120. $nota2 = $_POST['nota2'] ;
  121. if(isset($_POST['nota3']))
  122. $nota3 = $_POST['nota3'] ;
  123. if(isset($_POST['tipo']))
  124. $tipo= $_POST['tipo'] ;
  125. if(isset($_POST['data']))
  126. $data= $_POST['data'] ;
  127. if(isset($_POST['salva']))
  128. {
  129. /*salvo le note*/
  130. if ($n1!=0){
  131. if(!empty($nota1)){
  132. $query = "UPDATE note SET nota=\"$nota1\" WHERE ID=\"$n1\"";
  133. $result = mysql_query($query);
  134. if (!$result) die ("Database access failed: " . mysql_error());
  135. }
  136. else{
  137. $n1=0;
  138. }
  139. }
  140. else{
  141. if(!empty($nota1))
  142. {
  143. $query = "INSERT INTO note(nota ) VALUES (\"$nota1\")";
  144. $result = mysql_query($query);
  145. if (!$result) die ("Database access failed: " . mysql_error());
  146. $n1= mysql_insert_id();
  147. }
  148. }
  149. if ($n2!=0){
  150. if(!empty($nota2)){
  151. $query = "UPDATE note SET nota=\"$nota2\" WHERE ID=\"$n2\"";
  152. $result = mysql_query($query);
  153. if (!$result) die ("Database access failed: " . mysql_error());
  154. }
  155. else{
  156. $n2=0;
  157. }
  158. }
  159. else{
  160. if(!empty($nota2))
  161. {
  162. $query = "INSERT INTO note(nota ) VALUES (\"$nota2\")";
  163. $result = mysql_query($query);
  164. if (!$result) die ("Database access failed: " . mysql_error());
  165. $n2= mysql_insert_id();
  166. }
  167. }
  168. if ($n3!=0){
  169. if(!empty($nota3)){
  170. $query = "UPDATE note SET nota=\"$nota3\" WHERE ID=\"$n3\"";
  171. $result = mysql_query($query);
  172. if (!$result) die ("Database access failed: " . mysql_error());
  173. }
  174. else{
  175. $n3=0;
  176. }
  177. }
  178. else{
  179. if(!empty($nota3))
  180. {
  181. $query = "INSERT INTO note(nota ) VALUES (\"$nota3\")";
  182. $result = mysql_query($query);
  183. if (!$result) die ("Database access failed: " . mysql_error());
  184. $n3= mysql_insert_id();
  185. }
  186. }
  187. if($tipo == "sost")
  188. {
  189. /* INSERIMANTO BENE*/
  190. if($codbene==0){
  191. $query = "INSERT INTO pc(ID_bene, marcamodello, ID_monitor, pollici ) VALUES (\"$ID_bene\", \"$modello\", \"$monitor\", \"$pollici\")";
  192. $result = mysql_query($query);
  193. if (!$result) die ("Database access failed: " . mysql_error());
  194. $codbene= mysql_insert_id();
  195. }else{
  196. $query = "UPDATE pc SET ID_bene = \"$ID_bene\", marcamodello = \"$modello\", ID_monitor = \"$monitor\", pollici = \"$pollici\" WHERE ID=\"$codbene\"";
  197. $result = mysql_query($query);
  198. if (!$result) die ("Database access failed: " . mysql_error());
  199. }
  200. }else{
  201. $codbene=0;
  202. }
  203. if(!empty($data)){
  204. list($data_g,$data_m,$data_a) = explode("-",$data);
  205. $time = mktime(0,0,0, $data_m, $data_g, $data_a);
  206. $data= date ('Y-m-d',$time);
  207. }else{
  208. $data= date ('Y-m-d');
  209. }
  210. $operatore = $_SESSION['changeover_IDutente'];
  211. /* INSERIMANTO COLLOCAZIONE*/
  212. $query = "UPDATE collocazione SET ubicazione = \"$ubicazione\", sc = \"$sc\", ufficio =\"$ufficio\" WHERE ID=\"$collocazione\"";
  213. $result = mysql_query($query);
  214. if (!$result) die ("Database access failed: " . mysql_error());
  215. /* INSERIMANTO RICHIESTA*/
  216. $query = "UPDATE interventi SET tipo=\"$tipo\", bene = \"$codbene\", cognome_nome_utente = \"$cognome_nome_utente\", telefono=\"$telefono\", presadirete= \"$presarete\", attiva = \"$attiva\", nota1=\"$n1\", nota2=\"$n2\", nota3=\"$n3\", datarichiesta=\"$data\",operatore=\"$operatore\" WHERE ID=\"$ID\"";
  217. $result = mysql_query($query);
  218. if (!$result) die ("Database access failed: " . mysql_error());
  219. echo "MODIFICA EFFETTUATA CON SUCCESSO!!";
  220. }
  221. echo <<<_END
  222. <form action="modifica.php" method="post" name="inserimento"><pre>
  223. <br><br>
  224. <font class="titolo">RICHIESTA PC </font><font class="rosso">ID: $ID</font>
  225. &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <input type="submit" name="elimina" value="ELIMINA" />
  226. <br>
  227. <table>
  228. <tr>
  229. <td><input
  230. _END;
  231. if($tipo == "sost")
  232. echo "checked=\"checked\" ";
  233. echo <<<_END
  234. type="radio" id="sost" name="tipo" value="sost" onclick="document.forms['inserimento'].submit()"/><label for="sost">SOSTITUZIONE</label></td>
  235. <td><input
  236. _END;
  237. if($tipo == "nuovo")
  238. echo "checked=\"checked\" ";
  239. echo <<<_END
  240. type="radio" id="nuovo" name="tipo" value="nuovo" onclick="document.forms['inserimento'].submit()"/><label for="nuovo">NUOVO</label></td>
  241. </tr>
  242. </table>
  243. <br><br>
  244. <table class="ret">
  245. <tr>
  246. <td>
  247. <p class="blue">DATA richiesta</p>
  248. formato gg-mm-yyyy <input type="date" name="data" value="$data"/><br>
  249. <br><br>
  250. </td>
  251. </tr>
  252. </table>
  253. _END;
  254. if($tipo == 'sost')
  255. {
  256. echo <<<_END
  257. <table class="ret">
  258. <tr>
  259. <td>
  260. <p class="blue">Bene da sostituire</p>
  261. ID_bene * <input type="text" name="ID_bene" value="$ID_bene"/><br>
  262. Marca-modello <input type="text" name="modello" value="$modello"/><br>
  263. ID monitor <input type="text" name="monitor" value="$monitor"/><br>
  264. Pollici monitor <input type="text" name="pollici" value="$pollici"/><br>
  265. <br><br>
  266. </tr>
  267. </table>
  268. _END;
  269. }
  270. else{
  271. echo <<<_END
  272. <table class="ret">
  273. <tr>
  274. <td>
  275. <p class="blue">Presa di rete</p>
  276. Presa di rete <input type="text" name="presarete" value="$presarete" size="10"/>
  277. <select name="attiva" size="1">
  278. <option
  279. _END;
  280. if ($attiva == "")
  281. echo "selected=\"selected\" ";
  282. echo <<<_END
  283. value=""></option>
  284. <option
  285. _END;
  286. if ($attiva == "da attivare")
  287. echo "selected=\"selected\" ";
  288. echo <<<_END
  289. value="da attivare">da attivare</option>
  290. <option
  291. _END;
  292. if ($attiva == "attiva")
  293. echo "selected=\"selected\" ";
  294. echo <<<_END
  295. value="attiva">attiva</option>
  296. </select><br>
  297. <br><br>
  298. </tr>
  299. </table>
  300. _END;
  301. }
  302. echo <<<_END
  303. <table class="ret">
  304. <tr>
  305. <td>
  306. <p class="blue">Collocazione *</p>
  307. Ubicazione <select name="ubicazione" size="1">
  308. <option
  309. _END;
  310. if ($ubicazione == "")
  311. echo "selected=\"selected\" ";
  312. echo <<<_END
  313. value=""></option>
  314. <option
  315. _END;
  316. if ($ubicazione == "Via Guido Rey")
  317. echo "selected=\"selected\" ";
  318. echo <<<_END
  319. value="Via Guido Rey">Via Guido Rey</option>
  320. <option
  321. _END;
  322. if ($ubicazione == "Parini")
  323. echo "selected=\"selected\" ";
  324. echo <<<_END
  325. value="Parini">Parini</option>
  326. <option
  327. _END;
  328. if ($ubicazione == "Saint-Martin-de-Corléans")
  329. echo "selected=\"selected\" ";
  330. echo <<<_END
  331. value="Saint-Martin-de-Corléans">Saint-Martin-de-Corléans</option>
  332. <option
  333. _END;
  334. if ($ubicazione == "Beauregard")
  335. echo "selected=\"selected\" ";
  336. echo <<<_END
  337. value="Beauregard">Beauregard</option>
  338. <option
  339. _END;
  340. if ($ubicazione == "territorio")
  341. echo "selected=\"selected\" ";
  342. echo <<<_END
  343. value="territorio">territorio</option>
  344. </select><br>
  345. S.C.: <select name="sc" size="1">
  346. <option
  347. _END;
  348. if($sc == "")
  349. echo "selected=\"selected\" ";
  350. echo "value=\"\"></option>";
  351. $query = "SELECT * FROM sc ";
  352. $result = mysql_query($query);
  353. if (!$result) die ("Database access failed: " . mysql_error());
  354. $righe = mysql_num_rows($result);
  355. for ($j = 0 ; $j < $righe ; ++$j)
  356. {
  357. $row = mysql_fetch_row($result);
  358. $numrepartoj = $row[0];
  359. $repartoj = $row[1];
  360. echo "<option ";
  361. if($sc == $numrepartoj)
  362. echo "selected=\"selected\" ";
  363. echo "value=\"$numrepartoj\">$repartoj</option>";
  364. }
  365. echo <<<_END
  366. </select><br>
  367. Ufficio <input type="text" name="ufficio" value="$ufficio"/ size="50"><br>
  368. <br><br>
  369. </tr>
  370. </table>
  371. <table class="ret">
  372. <tr>
  373. <td>
  374. <p class="blue">UTENTE DI RIFERIMENTO *</p>
  375. Cognome nome <input type="text" name="cognome_nome_utente" value="$cognome_nome_utente"/ size="50"><br>
  376. Recapito telefonico <input type="text" name="telefono" value="$telefono"/ size="50"><br>
  377. <br><br>
  378. </tr>
  379. </table>
  380. <table class="ret">
  381. <tr>
  382. <td>
  383. <p class="blue">Note</p>
  384. Programmi particolari da installare<br>
  385. <textarea rows="2" cols="50" name="nota1">$nota1</textarea><br>
  386. Esigenze particolari di orario per l'installazione<br>
  387. <textarea rows="2" cols="50" name="nota2">$nota2</textarea><br>
  388. note<br>
  389. <textarea rows="2" cols="50" name="nota3">$nota3</textarea><br>
  390. <br><br>
  391. </tr>
  392. </table>
  393. <br>
  394. <input type="hidden" name="ID" value="$ID">
  395. <input type="submit" name="salva" value="SALVA" />
  396. </pre></form>
  397. _END;
  398. /*
  399. } else
  400. {
  401. echo "protezione pagina - no diritti di amministrazine";
  402. }
  403. */
  404. }
  405. }
  406. include 'CSS/templateEnd.html';
  407. ?>