/modifica.php
PHP | 454 lines | 401 code | 44 blank | 9 comment | 84 complexity | afcc99300fc398414c3886d897aab1e2 MD5 | raw file
- <?php
- session_start();
- include 'CSS/templateTop.html';
-
- require_once 'login.php';
-
- if(!isset($_SESSION['changeover_IDutente'])){
- header("location: index.php");
- }
- else
- {
- /*
- /* per far accedere alla pagina solo un amministratore
- if($_SESSION['nonconf_DBA']=='Y')
- {
- */
-
- include 'barramenu.php';
-
- $ID = $_POST['ID'];
-
- if(isset($_POST['elimina'])){
- $query = "DELETE FROM interventi WHERE ID=\"$ID\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- echo "RICHIESTA ELIMINATA CON SUCCESSO!!";
- }
- else{
-
- $query = "SELECT * FROM interventi WHERE ID = $ID ";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $row = mysql_fetch_row($result);
- $tipo = $row[1];
-
- $codbene = $row[2];
- if($tipo=='sost'){
- $query = "SELECT * FROM pc WHERE ID=$codbene";
- $result2 = mysql_query($query);
- if (!$result2) die ("Database access failed: " . mysql_error());
- $row2 = mysql_fetch_row($result2);
- $ID_bene = $row2[1];
- $modello= $row2[2];
- $monitor = $row2[3];
- $pollici= $row2[4];
- }else{
- $ID_bene = '';
- $modello= '';
- $monitor = '';
- $pollici= '';
- }
-
- $collocazione= $row[3];
-
- $query = "SELECT * FROM collocazione WHERE ID=$collocazione";
- $result2 = mysql_query($query);
- if (!$result2) die ("Database access failed: " . mysql_error());
- $row2 = mysql_fetch_row($result2);
- $ubicazione = $row2[1];
- $sc= $row2[2];
- $ufficio = $row2[3];
-
- $cognome_nome_utente = $row[4];
- $telefono = $row[5];
-
- $presarete=$row[6];
- $attiva=$row[7];
-
- $n1 = $row[8];
- $n2 = $row[9];
- $n3 = $row[10];
-
- $data = $row[15];
- list($data_a,$data_m,$data_g) = explode("-",$data);
- $time = mktime(0,0,0, $data_m, $data_g, $data_a);
- $data= date ('d-m-Y',$time);
-
- $sopralluogo = $row[11];
-
- if($n1!=0)
- {
- $query = "SELECT nota FROM note WHERE ID=$n1";
- $result2 = mysql_query($query);
- if (!$result2) die ("Database access failed: " . mysql_error());
- $row2 = mysql_fetch_row($result2);
- $nota1 = $row2[0];
- }else{
- $nota1="";
- }
- if($n2!=0)
- {
- $query = "SELECT nota FROM note WHERE ID=$n2";
- $result2 = mysql_query($query);
- if (!$result2) die ("Database access failed: " . mysql_error());
- $row2 = mysql_fetch_row($result2);
- $nota2 = $row2[0];
- }else{
- $nota2="";
- }
- if($n3!=0)
- {
- $query = "SELECT nota FROM note WHERE ID=$n3";
- $result2 = mysql_query($query);
- if (!$result2) die ("Database access failed: " . mysql_error());
- $row2 = mysql_fetch_row($result2);
- $nota3 = $row2[0];
- }else{
- $nota3="";
- }
-
- if(isset($_POST['ID_bene']))
- $ID_bene = $_POST['ID_bene'];
- if(isset($_POST['modello']))
- $modello = $_POST['modello'];
- if(isset($_POST['monitor']))
- $monitor =$_POST['monitor'];
- if(isset($_POST['pollici']))
- $pollici =$_POST['pollici'] ;
-
- if(isset($_POST['presarete']))
- $presarete = $_POST['presarete'] ;
- if(isset($_POST['attiva']))
- $attiva =$_POST['attiva'] ;
-
- if(isset($_POST['ubicazione']))
- $ubicazione = $_POST['ubicazione'] ;
- if(isset($_POST['sc']))
- $sc = $_POST['sc'];
- if(isset($_POST['ufficio']))
- $ufficio = $_POST['ufficio'] ;
-
- if (isset($_POST['cognome_nome_utente']))
- $cognome_nome_utente =$_POST['cognome_nome_utente'] ;
- if(isset($_POST['telefono']))
- $telefono = $_POST['telefono'] ;
-
- if(isset($_POST['nota1']))
- $nota1 = $_POST['nota1'] ;
- if(isset($_POST['nota2']))
- $nota2 = $_POST['nota2'] ;
- if(isset($_POST['nota3']))
- $nota3 = $_POST['nota3'] ;
-
- if(isset($_POST['tipo']))
- $tipo= $_POST['tipo'] ;
-
- if(isset($_POST['data']))
- $data= $_POST['data'] ;
-
- if(isset($_POST['salva']))
- {
- /*salvo le note*/
- if ($n1!=0){
- if(!empty($nota1)){
- $query = "UPDATE note SET nota=\"$nota1\" WHERE ID=\"$n1\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- }
- else{
- $n1=0;
- }
- }
- else{
- if(!empty($nota1))
- {
- $query = "INSERT INTO note(nota ) VALUES (\"$nota1\")";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $n1= mysql_insert_id();
- }
- }
-
- if ($n2!=0){
- if(!empty($nota2)){
- $query = "UPDATE note SET nota=\"$nota2\" WHERE ID=\"$n2\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- }
- else{
- $n2=0;
- }
- }
- else{
- if(!empty($nota2))
- {
- $query = "INSERT INTO note(nota ) VALUES (\"$nota2\")";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $n2= mysql_insert_id();
- }
- }
-
- if ($n3!=0){
- if(!empty($nota3)){
- $query = "UPDATE note SET nota=\"$nota3\" WHERE ID=\"$n3\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- }
- else{
- $n3=0;
- }
- }
- else{
- if(!empty($nota3))
- {
- $query = "INSERT INTO note(nota ) VALUES (\"$nota3\")";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $n3= mysql_insert_id();
- }
- }
-
- if($tipo == "sost")
- {
- /* INSERIMANTO BENE*/
-
- if($codbene==0){
- $query = "INSERT INTO pc(ID_bene, marcamodello, ID_monitor, pollici ) VALUES (\"$ID_bene\", \"$modello\", \"$monitor\", \"$pollici\")";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $codbene= mysql_insert_id();
- }else{
- $query = "UPDATE pc SET ID_bene = \"$ID_bene\", marcamodello = \"$modello\", ID_monitor = \"$monitor\", pollici = \"$pollici\" WHERE ID=\"$codbene\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- }
- }else{
- $codbene=0;
- }
-
-
- if(!empty($data)){
- list($data_g,$data_m,$data_a) = explode("-",$data);
- $time = mktime(0,0,0, $data_m, $data_g, $data_a);
- $data= date ('Y-m-d',$time);
- }else{
- $data= date ('Y-m-d');
- }
-
- $operatore = $_SESSION['changeover_IDutente'];
-
- /* INSERIMANTO COLLOCAZIONE*/
-
- $query = "UPDATE collocazione SET ubicazione = \"$ubicazione\", sc = \"$sc\", ufficio =\"$ufficio\" WHERE ID=\"$collocazione\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
-
- /* INSERIMANTO RICHIESTA*/
-
- $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\"";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- echo "MODIFICA EFFETTUATA CON SUCCESSO!!";
-
- }
-
-
-
-
-
- echo <<<_END
- <form action="modifica.php" method="post" name="inserimento"><pre>
- <br><br>
- <font class="titolo">RICHIESTA PC </font><font class="rosso">ID: $ID</font>
-                                                         <input type="submit" name="elimina" value="ELIMINA" />
- <br>
- <table>
- <tr>
- <td><input
- _END;
- if($tipo == "sost")
- echo "checked=\"checked\" ";
- echo <<<_END
- type="radio" id="sost" name="tipo" value="sost" onclick="document.forms['inserimento'].submit()"/><label for="sost">SOSTITUZIONE</label></td>
- <td><input
- _END;
- if($tipo == "nuovo")
- echo "checked=\"checked\" ";
- echo <<<_END
- type="radio" id="nuovo" name="tipo" value="nuovo" onclick="document.forms['inserimento'].submit()"/><label for="nuovo">NUOVO</label></td>
- </tr>
- </table>
- <br><br>
- <table class="ret">
- <tr>
- <td>
- <p class="blue">DATA richiesta</p>
- formato gg-mm-yyyy <input type="date" name="data" value="$data"/><br>
- <br><br>
- </td>
- </tr>
- </table>
- _END;
-
- if($tipo == 'sost')
- {
- echo <<<_END
- <table class="ret">
- <tr>
- <td>
- <p class="blue">Bene da sostituire</p>
- ID_bene * <input type="text" name="ID_bene" value="$ID_bene"/><br>
- Marca-modello <input type="text" name="modello" value="$modello"/><br>
- ID monitor <input type="text" name="monitor" value="$monitor"/><br>
- Pollici monitor <input type="text" name="pollici" value="$pollici"/><br>
- <br><br>
- </tr>
- </table>
- _END;
- }
- else{
- echo <<<_END
- <table class="ret">
- <tr>
- <td>
- <p class="blue">Presa di rete</p>
- Presa di rete <input type="text" name="presarete" value="$presarete" size="10"/>
- <select name="attiva" size="1">
- <option
- _END;
- if ($attiva == "")
- echo "selected=\"selected\" ";
- echo <<<_END
- value=""></option>
- <option
- _END;
- if ($attiva == "da attivare")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="da attivare">da attivare</option>
- <option
- _END;
- if ($attiva == "attiva")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="attiva">attiva</option>
- </select><br>
- <br><br>
- </tr>
- </table>
- _END;
- }
-
- echo <<<_END
- <table class="ret">
- <tr>
- <td>
- <p class="blue">Collocazione *</p>
- Ubicazione <select name="ubicazione" size="1">
- <option
- _END;
- if ($ubicazione == "")
- echo "selected=\"selected\" ";
- echo <<<_END
- value=""></option>
- <option
- _END;
- if ($ubicazione == "Via Guido Rey")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="Via Guido Rey">Via Guido Rey</option>
- <option
- _END;
- if ($ubicazione == "Parini")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="Parini">Parini</option>
- <option
- _END;
- if ($ubicazione == "Saint-Martin-de-Corléans")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="Saint-Martin-de-Corléans">Saint-Martin-de-Corléans</option>
- <option
- _END;
- if ($ubicazione == "Beauregard")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="Beauregard">Beauregard</option>
- <option
- _END;
- if ($ubicazione == "territorio")
- echo "selected=\"selected\" ";
- echo <<<_END
- value="territorio">territorio</option>
- </select><br>
- S.C.: <select name="sc" size="1">
- <option
- _END;
- if($sc == "")
- echo "selected=\"selected\" ";
- echo "value=\"\"></option>";
-
- $query = "SELECT * FROM sc ";
- $result = mysql_query($query);
- if (!$result) die ("Database access failed: " . mysql_error());
- $righe = mysql_num_rows($result);
-
- for ($j = 0 ; $j < $righe ; ++$j)
- {
- $row = mysql_fetch_row($result);
- $numrepartoj = $row[0];
- $repartoj = $row[1];
- echo "<option ";
- if($sc == $numrepartoj)
- echo "selected=\"selected\" ";
- echo "value=\"$numrepartoj\">$repartoj</option>";
- }
- echo <<<_END
- </select><br>
- Ufficio <input type="text" name="ufficio" value="$ufficio"/ size="50"><br>
- <br><br>
- </tr>
- </table>
- <table class="ret">
- <tr>
- <td>
- <p class="blue">UTENTE DI RIFERIMENTO *</p>
- Cognome nome <input type="text" name="cognome_nome_utente" value="$cognome_nome_utente"/ size="50"><br>
- Recapito telefonico <input type="text" name="telefono" value="$telefono"/ size="50"><br>
- <br><br>
- </tr>
- </table>
- <table class="ret">
- <tr>
- <td>
- <p class="blue">Note</p>
- Programmi particolari da installare<br>
- <textarea rows="2" cols="50" name="nota1">$nota1</textarea><br>
- Esigenze particolari di orario per l'installazione<br>
- <textarea rows="2" cols="50" name="nota2">$nota2</textarea><br>
- note<br>
- <textarea rows="2" cols="50" name="nota3">$nota3</textarea><br>
- <br><br>
- </tr>
- </table>
- <br>
- <input type="hidden" name="ID" value="$ID">
- <input type="submit" name="salva" value="SALVA" />
- </pre></form>
-
- _END;
-
- /*
- } else
- {
- echo "protezione pagina - no diritti di amministrazine";
- }
- */
- }
- }
- include 'CSS/templateEnd.html';
-
- ?>