-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactioneffectinsert.php
142 lines (86 loc) · 4.3 KB
/
actioneffectinsert.php
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
<?php
$errorp = ""; // Variable To Store Error Message
if (isset($_POST['submit'])) {
$action_id=$_POST['act'];
$change=$_POST['change'];
$observation=$_POST['observation'];
$status=$_POST['status'];
$year=strval(date("Y"));
$month=strval(date("m"));
$day=strval(date("d"));
$phrase="ACT";
$date=date("Y-m-d");
$phrase="TRK";
if (empty($_POST['act']) || empty($_POST['change'])
|| empty($_POST['observation'])
)
{
$errorp = "Complete all required fields";
}
else
{
if($status=="closed")
{
$errorp="The action has already been closed a cannot be updated";
}
else
{
$sqlsent1="SELECT * FROM action_effectiveness;";
$result1=mysqli_query($conn, $sqlsent1);
$item = mysqli_num_rows($result1);
$item1=++$item;
$action_effect_id="$phrase$year$month$day$item";
$sqlsent2="SELECT * FROM action WHERE action.action_id='$action_effect_id';";
$result2=mysqli_query($conn, $sqlsent2);
$result2check = mysqli_num_rows($result2);
if ($result2check > 0)
{
$result3check=$result2check;
while ($result3check > 0)
{
$item1=++$item;
$action_effect_id="$phrase$year$month$day$item";
//Esto no hace falta
}
}
if($change=="Conforme")
{
$queryupdate="UPDATE action SET action_status_id =2 WHERE action.action_id='$action_id'";
$sentupdate= mysqli_query($conn,$queryupdate);
$changed="YES";
if (!$sentupdate)
{
die('Error: ' . mysqli_error($conn));
}
}
else
{
$changed="NO";
}
$field1 = mysqli_real_escape_string($conn,$action_id);
$field2 = mysqli_real_escape_string($conn,$changed);
$field3 = mysqli_real_escape_string($conn,$observation);
$field4 = mysqli_real_escape_string($conn,$date);
$field5 = mysqli_real_escape_string($conn,$action_effect_id);
$query1 = "INSERT INTO action_effectiveness (action_effect_id, action_id, verification_date, status_changed, observations)
VALUES ('{$field5}','{$field1}','{$field4}','{$field2}','{$field3}')";
echo "$query1";
$sent1= mysqli_query($conn,$query1);
if (!$sent1 )
{
die('Error: ' . mysqli_error($conn));
}
//end first query
else
{
$errorp="Action Trace".$action_effect_id." for action ".$action_id." added";
require_once('ip.php');
$mess="Action Trace".$action_effect_id." for action ".$action_id." added Successfuly";//log message
require_once ('log.php'); //including the log function
$username=$_SESSION['login_user'];
logap($mess, $username, $ip);//function call
}
}
}
}
?>