changeover /modsopralluogo.php

Language PHP Lines 369
MD5 Hash 39b2693ff495764cab6ce5dcaaa03cc7 Estimated Cost $8,113 (why?)
Repository https://bitbucket.org/amorello/changeover.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php
session_start();
include 'CSS/templateTop.html';

require_once 'login.php';

if(!isset($_SESSION['changeover_IDutente'])){
    header("location: index.php");
}
else 
{
    
include 'barramenu.php';


$ID = $_POST['ID'];


//recupera i dati dell'intervento

$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];
        
        $query = "SELECT * FROM sc WHERE ID=$sc";
        $result2 = mysql_query($query);
        if (!$result2) die ("Database access failed: " . mysql_error());
        $row2 = mysql_fetch_row($result2);
        $sc = $row2[1];
        
        $cognome_nome_utente = $row[4];
        $telefono = $row[5];
        
        $npresarete=$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];
        $esito = $row[13];
 
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="";
}

//recupra dati del sopralluogo

$query = "SELECT * FROM sopralluogo WHERE ID=\"$sopralluogo\"";
        $result2 = mysql_query($query);
        if (!$result2) die ("Database access failed: " . mysql_error());
        $row2 = mysql_fetch_row($result2);
        $presarete = $row2[1];
        $corrente = $row2[2];
        $nsop = $row2[3];
        
    if($nsop!=0)       
    {
        $query = "SELECT nota FROM note WHERE ID=\"$nsop\"";
        $result2 = mysql_query($query);
        if (!$result2) die ("Database access failed: " . mysql_error());
        $row2 = mysql_fetch_row($result2);
        $notasop = $row2[0];  
    }
    else{
        $notasop='';
    }



if(isset($_POST['salva']))     ///salvataggio dati
{
    
$presarete = (isset($_POST['presarete'])) ? $_POST['presarete'] :  "assente";
$corrente = (isset($_POST['corrente'])) ? $_POST['corrente'] :  "assente";

$notasop = $_POST['notasop'];

$notasop = (isset($_POST['notasop'])) ? $_POST['notasop'] : '';

$nota1 = (isset($_POST['nota1'])) ? $_POST['nota1'] :  '';
$nota2 = (isset($_POST['nota2'])) ? $_POST['nota2'] :  '';
$nota3 = (isset($_POST['nota3'])) ? $_POST['nota3'] :  '';

$npresarete = (isset($_POST['npresarete'])) ? $_POST['npresarete'] :  '';
$attiva = (isset($_POST['attiva'])) ? $_POST['attiva'] :  '';

$esito = $_POST['esito'];

    
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 ($nsop!=0){
    if(!empty($notasop)){
    $query = "UPDATE note SET nota=\"$notasop\" WHERE ID=\"$nsop\"";
        $result = mysql_query($query);
        if (!$result) die ("Database access failed: " . mysql_error());
    }else{
        $nsop=0;
    }
}
else{
    if(!empty($notasop))
    {
        $query = "INSERT INTO note(nota ) VALUES (\"$notasop\")";
        $result = mysql_query($query);
        if (!$result) die ("Database access failed: " . mysql_error());
        $nsop= mysql_insert_id(); 
    }
}

    $operatore = $_SESSION['changeover_IDutente'];
    
$query = "UPDATE sopralluogo SET presarete = \"$presarete\",corrente = \"$corrente\" ,nota= \"$nsop\" ,operatore =\"$operatore\" WHERE ID=\"$sopralluogo\"";
        $result = mysql_query($query);
        if (!$result) die ("Database access failed: " . mysql_error());   

$query = "UPDATE interventi SET STATO2=\"$esito\", nota1=\"$n1\", nota2=\"$n2\", nota3=\"$n3\", presadirete=\"$npresarete\", attiva=\"$attiva\" WHERE ID=\"$ID\"";
    $result = mysql_query($query);
    if (!$result) die ("Database access failed: " . mysql_error());
    echo"SOPRALLUOGO MODIFICATO CON SUCCESSO!";
}
   
//visualizza il form >>>>>
echo <<<_END
<p class="blue">PC</p>
<table class="ret">
<tr>
<td>
_END;
if($tipo=='sost'){
    echo "SOSTITUZIONE:<br>$ID_bene     $modello      $monitor      $pollici <br>";
}
if($tipo=='nuovo'){
    echo "NUOVO:<br>";
}
echo <<<_END
$cognome_nome_utente        $telefono <br>
$ubicazione      $sc        $ufficio  <br>
_END;

echo <<<_END
<form action="modsopralluogo.php" method="post" name="form1"><pre>
    <input type="hidden" name="ID" value="$ID">
    <input type="hidden" name="tipo" value="$tipo">
Note:
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>
</td>
</tr>
</table>
<p class="giallo">SOPRALLUOGO</p>

<table>
<tr>
<td id="retg">
_END;
if($tipo=='nuovo'){
echo <<<_END
<table>
<tr>
<td>
<input 
_END;
if ($presarete == "presente")
    echo "checked ";
echo <<<_END
type="checkbox" name="presarete" value="presente"/>
Presa di rete &nbsp <input type="text" name="npresarete" value="$npresarete" 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>
</td>
</tr>
<tr>
<td align="left">
<input 
_END;
if ($corrente == "presente")
    echo "checked ";
echo <<<_END
type="checkbox" name="corrente" value="presente"/> corrente
</td>
</tr>
</table>
<br>
_END;
}
echo <<<_END
<br>Note:<br>
<textarea rows="4" cols="50" name="notasop">$notasop</textarea><br>
<br>

<table>
<tr>
<td><p class="giallo">ESITO:</p></td>
<td>&nbsp &nbsp<input 
_END;
if ($esito == 'S')
    echo "checked ";
echo <<<_END
type="radio" id="pos" name="esito" value="S" /></td>
<td><label for="pos"><p class="giallop">POSITIVO</p></label></td>
<td>&nbsp &nbsp</td>
<td><input 
_END;
if ($esito == 'N')
    echo "checked ";
echo <<<_END
type="radio" id="neg" name="esito" value="N" /></td>
<td><label for="neg"><p class="giallop">NEGATIVO</p></label></td>
</tr>
</table>
<br>
<input type="submit" name="salva" value="SALVA"/></td>
</pre></form>
</td>
</tr>
</table>
_END;

    
//>>>>>
}

include 'CSS/templateEnd.html';
?>
Back to Top