-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataEntry.php
292 lines (278 loc) · 11.3 KB
/
dataEntry.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
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
<!DOCTYPE html>
<head>
<title>Enter your Branch Audit Details</title>
<script type="text/javascript" src="js/jquery-latest.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/otherObservationUtils.js"></script>
<link rel="stylesheet" href="css/jquery-ui.min.css">
<link rel="stylesheet" href="css/pure-min.css">
<?php
session_start();
$con = new mysqli("localhost", "root", "", "electrical_audit");
if ($con->connect_errno) {
die("Connection failed: " . $conn->connect_error);
}
//Session Validation
if(!(isset($_SESSION["esa_brcode"]) && $_SESSION["esa_brcode"] != "")){
redirect("loginPage.php");
return;
}
if($_SESSION["esa_brcode"] === "admin")
redirect("adminPage.php");
$branch_code=$_SESSION["esa_brcode"];
$query=mysqli_query($con,"select branch_name as 'branch_name' from branch_master where branch_code = '$branch_code'");
$row = mysqli_fetch_array($query);
$branch_name = $row['branch_name'];
if(alreadyExistingEntry($branch_code))
{
redirect("editDataEntry.php");
return;
}
function redirect($url, $statusCode = 303)
{
header('Location: ' . $url, true, $statusCode);
die();
}
function alreadyExistingEntry($branch_code)
{
global $con;
$query=mysqli_query($con,"select count(*) as 'branch_code' from audit_information where branch_code = '".$branch_code."'");
$row = mysqli_fetch_array($query);
$no_entries = $row['branch_code'];
if($no_entries <= 0)
return false;
else if($no_entries == 1)
return true;
else
die("processing error: more than one entry found for ".$branch_code." branch");
}
?>
<style type="text/css">
.topHeader th{
font-size:14px;
color:white;
background-color:rgb(80, 66, 172);
border-bottom-width:1px;
}
td {
text-align:center;
}
p{
font-size:12px;
}
td p{
margin:0;
}
.subHead{
text-align:left;
font-weight:bold;
}
.pageTitle{
text-align:center;
font-size:2em;
font-weight:bold;
padding:0.5em 0 1em 0;
}
.date_picker{
background: white url(img/calendar.png) right no-repeat;
padding-right: 17px;
}
</style>
</head>
<body style="font-family:verdana">
<script type="text/javascript">
$(document).ready(function () {
$("#header").load("header.php");
//Changing the size of the data picker text and date format
$( ".date_picker" ).datepicker({ autoSize: true,
dateFormat: "dd/mm/yy",
beforeShow: function(){
$(".ui-datepicker").css('font-size', 12)
}
});
$('.date_picker').attr('readonly', true);
$('#formid').bind("keyup keypress", function (e) {
var code = e.keyCode || e.which;
if (code == 13) {
e.preventDefault();
return false;
}
});
});
function submitForm(){
var all_radio_checked = true;
var no_checked_fields = 0;
var all_date_chosen = true;
var otherObservations_text_present = true;
//Checking whether all the radio buttons groups are checked and
// if checked corresponding dates should be given.
$('input:radio:checked').each(function() {
no_checked_fields++;
var radio_name = $(this).attr('name');
if(radio_name == "otherObservations_r") return; //No date fields for this hence returning.
var date_name = radio_name.slice(0, -2);
date_name = date_name + "_d";
var date_obj = $("input[name='"+ date_name +"']")
if($(this).val() == "Yes")
{
if($(date_obj).val() == '') {
all_date_chosen = false;
}
}
else{
$(date_obj).val('');
}
});
//Checking whether the required number of radio buttons are checked
var observationCount = parseInt($('input[name=observationCountHidden]').val());
if(no_checked_fields < (10 + observationCount)) all_radio_checked = false;
//Verifying whether the other observations are all filled
$('.otherComp_text').each(function() {
if($(this).val() === "") otherObservations_text_present = false;
});
//Alerting the user when he forgets the fields
if(!all_radio_checked || !all_date_chosen || !otherObservations_text_present) {
alert("Please fill all the options and dates");
return false;
}
else if (!$("input[name='acceptConfirmation']").is(':checked'))
{
alert("Please accept the CONDITION given at the bottom");
$(".conditionBox").effect("highlight",{color: 'yellow'}, 500);
}
else{
document.getElementById("formid").submit();
}
}
</script>
<div id="header"> </div>
<div style="padding-left:2em;">
<div style="margin-bottom:1em;font-size:14px;font-weight:bold">
<div style="margin-left:2em; display:inline"><p id="branchCodeSpace" style="display:inline">Branch Code : <?php echo $branch_code ?></p></div>
<div style="margin-left:3em; display:inline;"><p id="branchNameSpace" style="display:inline">Branch Name : <?php echo $branch_name ?></p></div>
</div>
<form id="formid" action="processDataEntry.php" method="post" >
<input type="hidden" name="post_from" value="newEntry"/>
<input type="hidden" name="observationCountHidden" value="0"/>
<table border=1 class = "pure-table" id="table_id">
<tr class="topHeader">
<th rowspan="2">S.No</th>
<th rowspan="2"> Major Observations</th>
<th colspan="3"> Whether Rectified/Replaced</th>
<th rowspan="2"> Date of Completion</th>
</tr>
<tr class="OptionsHeader">
<th>Yes</th>
<th>No</th>
<th>NA</th>
</tr>
<tr class="pure-table-odd">
<td>1</td>
<td><p class="subHead">Balancing and Distribution of Electrical loads </td>
<td><input type="radio" name="balancingAndDistribution_r" value="Yes"/></td>
<td><input type="radio" name="balancingAndDistribution_r" value="No"/></td>
<td><input type="radio" name="balancingAndDistribution_r" value="NA"/></td>
<td><input type="text" name="balancingAndDistribution_d" id="balancingAndDistribution_d" class="date_picker" value=""/><!--img src="img/calendar.png" /--></td>
</tr>
<tr>
<td><p>2</p></td>
<td><p class="subHead">MCCB/ELCB/MCB are in working condition, with proper rating/capacity </p></td>
<td><input type="radio" name="mccb_r" value="Yes"/></td>
<td><input type="radio" name="mccb_r" value="No"/></td>
<td><input type="radio" name="mccb_r" value="NA"/></td>
<td><input type="text" name="mccb_d" id="mccb_d" class="date_picker" value=""/></td>
</tr>
<tr class="pure-table-odd">
<td><p>3</p></td>
<td><p class="subHead">Proper earthing carried out/connected and reports are in palce</p> </td>
<td><input type="radio" name="earthing_r" value="Yes"/></td>
<td><input type="radio" name="earthing_r" value="No"/></td>
<td><input type="radio" name="earthing_r" value="NA"/></td>
<td><input type="text" name="earthing_d" id="earthing_d" class="date_picker" value=""/></td>
</tr>
<tr>
<td><p>4</p></td>
<td><p class="subHead">Replacement of old wires, if any</p> </td>
<td><input type="radio" name="oldWireReplace_r" value="Yes"/></td>
<td><input type="radio" name="oldWireReplace_r" value="No"/></td>
<td><input type="radio" name="oldWireReplace_r" value="NA"/></td>
<td><input type="text" name="oldWireReplace_d" id="oldWireReplace_d" class="date_picker" value=""/></td>
</tr>
<tr class="pure-table-odd">
<td><p>5</p></td>
<td><p class="subHead">Provision of emergency lights</p> </td>
<td><input type="radio" name="emergencyLamp_r" value="Yes"/></td>
<td><input type="radio" name="emergencyLamp_r" value="No"/></td>
<td><input type="radio" name="emergencyLamp_r" value="NA"/></td>
<td><input type="text" name="emergencyLamp_d" id="emergencyLamp_d" class="date_picker" value=""/></td>
</tr>
<tr>
<td><p>6</p></td>
<td><p class="subHead">Removal of scraps/old materials in electrical panel rooms/UPS/Batteries/DBs</p> </td>
<td><input type="radio" name="scrapsRemoval_r" value="Yes"/></td>
<td><input type="radio" name="scrapsRemoval_r" value="No"/></td>
<td><input type="radio" name="scrapsRemoval_r" value="NA"/></td>
<td><input type="text" name="scrapsRemoval_d" id="scrapsRemoval_d" class="date_picker" value=""/></td>
</tr>
<tr class="pure-table-odd">
<td><p>7</p></td>
<td><p class="subHead">Proper ventilation arrangements for panel room/UPS room/electrical room provided</p> </td>
<td><input type="radio" name="ventilation_r" value="Yes"/></td>
<td><input type="radio" name="ventilation_r" value="No"/></td>
<td><input type="radio" name="ventilation_r" value="NA"/></td>
<td><input type="text" name="ventilation_d" id="ventilation_d" class="date_picker" value=""/></td>
</tr>
<tr>
<td><p>8</p></td>
<td><p class="subHead">Periodical Electrical maintenance is carried out </p></td>
<td><input type="radio" name="maintenance_r" value="Yes"/></td>
<td><input type="radio" name="maintenance_r" value="No"/></td>
<td><input type="radio" name="maintenance_r" value="NA"/></td>
<td><input type="text" name="maintenance_d" id="maintenance_d" class="date_picker" value=""/></td>
</tr>
<tr class="pure-table-odd">
<td><p>9</p></td>
<td><p class="subHead">AC timers are working </p></td>
<td><input type="radio" name="acTimers_r" value="Yes"/></td>
<td><input type="radio" name="acTimers_r" value="No"/></td>
<td><input type="radio" name="acTimers_r" value="NA"/></td>
<td><input type="text" name="acTimers_d" id="acTimers_d" class="date_picker" value=""/></td>
</tr>
<tr>
<td><p>10</p></td>
<td><p class="subHead">Power factor correction panels are provided</p> </td>
<td><input type="radio" name="powerFactor_r" value="Yes"/></td>
<td><input type="radio" name="powerFactor_r" value="No"/></td>
<td><input type="radio" name="powerFactor_r" value="NA"/></td>
<td><input type="text" name="powerFactor_d" id="powerFactor_d" class="date_picker" value=""/></td>
</tr>
<tr class="pure-table-odd">
<td><p>11</p></td>
<td colspan="5">
<p class="subHead" style="display:table-cell;">
Any other observation made in the Electrical Safety Audit Report pending for compliance
</p>
<div style="display:table-cell; padding-left:1em;">
<button id="otherComp_button_add" class="otherComp_button" type="button" onClick="javascript:addNewObservation('table_id');"> Add new </button>
<button id="otherComp_button_add" class="otherComp_button" type="button" onClick="javascript:deleteLastObservation('table_id');"> Delete Last Entry </button>
<div>
</td>
</tr>
</table>
<p>
NOTE: The above are major observations based on the Electrical Safety Audit Report submitted by
External Agency. These are only illustrative and the Branch has to rectify all the observations
pointed out in the respective Branch Electrical Safety Audit Report.
</p>
<p class="conditionBox">
<input type="checkbox" name="acceptConfirmation" value="confirmed"/> I, the branch manager, confirm that all the observations pointed out in the
Electrical Safety Audit report have been attended.
</p>
<div style="text-align:center">
<button type="button" class="pure-button pure-button-primary" name ="submitBtn" onClick="submitForm()">Save and Preview</button>
</div>
<br/>
</form>
</div>
</body>
</html>