1 | <script>
|
---|
2 | 'use strict';
|
---|
3 | var ctr;
|
---|
4 | var testdata = "old data";
|
---|
5 | var pastdata = false;
|
---|
6 |
|
---|
7 | function clearNode(node){
|
---|
8 | var child = node.childNodes[0];
|
---|
9 | while(child != null)
|
---|
10 | {
|
---|
11 | node.removeChild(child);
|
---|
12 | child = node.childNodes[0];
|
---|
13 | }
|
---|
14 | }
|
---|
15 |
|
---|
16 | function addRow(table){
|
---|
17 | var targetView = table;
|
---|
18 | var cctr=$('.dataTable tr').length;
|
---|
19 | ctr=cctr+1;
|
---|
20 | var input_data;
|
---|
21 | var select;
|
---|
22 | var option;
|
---|
23 | var selection;
|
---|
24 | // CREATE ELEMENT
|
---|
25 | var newtr = document.createElement("tr");
|
---|
26 | newtr.setAttribute("class","tr");
|
---|
27 | var newtd_c1 = document.createElement("td");
|
---|
28 | newtd_c1.setAttribute("width","147");
|
---|
29 | newtd_c1.setAttribute("align","center");
|
---|
30 | newtd_c1.appendChild(
|
---|
31 | input_data = document.createElement("input"),
|
---|
32 | input_data.setAttribute("type","time"),
|
---|
33 | input_data.setAttribute("size","10"),
|
---|
34 | input_data.setAttribute("autofocus","true"),
|
---|
35 | input_data.setAttribute("hidden","true")
|
---|
36 | );
|
---|
37 | var newtd_c2 = document.createElement("td");
|
---|
38 | newtd_c2.setAttribute("width","138");
|
---|
39 | newtd_c2.setAttribute("align","center");
|
---|
40 | newtd_c2.appendChild(
|
---|
41 | select = document.createElement("select"),
|
---|
42 | select.setAttribute("class","measure"),
|
---|
43 | $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
|
---|
44 | type:"post",
|
---|
45 | url:"Transaction/measurement.php",
|
---|
46 | success:function(data){
|
---|
47 | var obj=$.parseJSON(data);
|
---|
48 | $.each(obj,function(){
|
---|
49 | select.appendChild(
|
---|
50 | option = document.createElement("option"),
|
---|
51 | option.setAttribute('value',this['fMeasurementKey']),
|
---|
52 | option.appendChild(document.createTextNode(this['fMeasurement']))
|
---|
53 | )
|
---|
54 | })
|
---|
55 | }
|
---|
56 | }) // End of retrieving
|
---|
57 | );
|
---|
58 | newtd_c2.setAttribute("width","115");
|
---|
59 | newtd_c2.setAttribute("align","center");
|
---|
60 | newtd_c2.appendChild(
|
---|
61 | input_data = document.createElement("input"),
|
---|
62 | input_data.setAttribute("type","button"),
|
---|
63 | input_data.setAttribute("value","+"),
|
---|
64 | input_data.onclick = function(){ return addRow(newtr);
|
---|
65 | ctr++;
|
---|
66 | }
|
---|
67 | );
|
---|
68 | var newtd_c3 = document.createElement("td");
|
---|
69 | newtd_c3.setAttribute("width","98");
|
---|
70 | newtd_c3.setAttribute("align","center");
|
---|
71 | newtd_c3.appendChild(
|
---|
72 | selection = document.createElement("select"),
|
---|
73 | selection.setAttribute("class","source"),
|
---|
74 | $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
|
---|
75 | type:"post",
|
---|
76 | url:"Transaction/source.php",
|
---|
77 | success:function(data)
|
---|
78 | {
|
---|
79 | var obj = $.parseJSON(data);
|
---|
80 | $.each(obj,function(){
|
---|
81 | selection.appendChild(
|
---|
82 | option=document.createElement('option'),
|
---|
83 | option.setAttribute('value',this['fSourceKEY']),
|
---|
84 | option.appendChild(document.createTextNode(this['fSourceName']))
|
---|
85 | )
|
---|
86 | });
|
---|
87 | }
|
---|
88 | }) // End of retrieving
|
---|
89 | );
|
---|
90 | var newtd_c4 = document.createElement("td");
|
---|
91 | newtd_c4.setAttribute("width","119");
|
---|
92 | newtd_c4.setAttribute("align","center");
|
---|
93 | newtd_c4.appendChild(
|
---|
94 | input_data = document.createElement("input"),
|
---|
95 | input_data.setAttribute("type","text"),
|
---|
96 | input_data.setAttribute("class","selected"),
|
---|
97 | input_data.setAttribute("size","12"),
|
---|
98 | input_data.setAttribute("placeholder","Value")
|
---|
99 | );
|
---|
100 | var newtd_c5 = document.createElement("td");
|
---|
101 | newtd_c5.setAttribute("width","115");
|
---|
102 | newtd_c5.setAttribute("align","center");
|
---|
103 | newtd_c5.appendChild(
|
---|
104 | input_data = document.createElement("input"),
|
---|
105 | input_data.setAttribute("type","button"),
|
---|
106 | input_data.setAttribute("value","Delete"),
|
---|
107 | input_data.onclick = function(){ return clearNode(newtr); }
|
---|
108 | );
|
---|
109 |
|
---|
110 | newtr.appendChild(newtd_c2);
|
---|
111 | newtr.appendChild(newtd_c3);
|
---|
112 | newtr.appendChild(newtd_c4);
|
---|
113 | newtr.appendChild(newtd_c5);
|
---|
114 |
|
---|
115 | $(targetView).after(newtr);
|
---|
116 | }
|
---|
117 | function deleteRow(tableID){
|
---|
118 | try{
|
---|
119 | var table = document.getElementById(tableID);
|
---|
120 | var rowCount = table.rows.length;
|
---|
121 |
|
---|
122 | for(var i = 0; i < rowCount; i++){
|
---|
123 | var row = table.rows[i];
|
---|
124 | var chkbox = row.cells[0].childNodes[0];
|
---|
125 | if(null != chkbox && true == chkbox.checked){
|
---|
126 | if(rowCount <= 1){
|
---|
127 | alert("Cannot delete all the rows.");
|
---|
128 | break;
|
---|
129 | }
|
---|
130 | table.deleteRow(i);
|
---|
131 | rowCount--;
|
---|
132 | i--;
|
---|
133 | }
|
---|
134 | }
|
---|
135 | }catch(e){
|
---|
136 | alert(e);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | <?php
|
---|
141 | $cnt=0;
|
---|
142 | $pastdate = 'false';
|
---|
143 | $day=0;
|
---|
144 | if(isset($_GET['days']))
|
---|
145 | {
|
---|
146 | $day = $_GET['days'];
|
---|
147 | ?> addRowClone(); <?php
|
---|
148 | }
|
---|
149 | else
|
---|
150 | {
|
---|
151 | $day =date("Y-m-d");
|
---|
152 | }
|
---|
153 | $prev_time = array();
|
---|
154 | ?>
|
---|
155 |
|
---|
156 | function addRowCloneNew(nextrow){
|
---|
157 | var targetView = document.getElementById("Data");
|
---|
158 | // CREATE ELEMENT
|
---|
159 | // COUNT LIST
|
---|
160 | var list = $(".datalisting").length;
|
---|
161 | var newlist = list+1;
|
---|
162 | var cctr=$('.dataTable tr').length;
|
---|
163 | ctr=cctr+1;
|
---|
164 | var input_data;
|
---|
165 | var select;
|
---|
166 | var option;
|
---|
167 | var selection;
|
---|
168 | var newdiv = document.createElement("div");
|
---|
169 | newdiv.setAttribute("id","list_"+newlist);
|
---|
170 | newdiv.setAttribute("class","datalisting");
|
---|
171 | newdiv.setAttribute("style","margin:5px 0;");
|
---|
172 | var newtable = document.createElement("table");
|
---|
173 | newtable.setAttribute("class","dataTable");
|
---|
174 | newtable.setAttribute("width","100%");
|
---|
175 | newtable.setAttribute("border","1");
|
---|
176 | newtable.setAttribute("cellspacing","0");
|
---|
177 | newtable.setAttribute("cellpadding","0");
|
---|
178 | var newInnertable = document.createElement("table");
|
---|
179 | newInnertable.setAttribute("class","dataTable");
|
---|
180 | newInnertable.setAttribute("width","100%");
|
---|
181 | newInnertable.setAttribute("border","1");
|
---|
182 |
|
---|
183 | newInnertable.setAttribute("cellspacing","0");
|
---|
184 | newInnertable.setAttribute("cellpadding","0");
|
---|
185 |
|
---|
186 | var newtr = document.createElement("tr");
|
---|
187 | newtr.setAttribute('class','tr');
|
---|
188 | var newtd_c1 = document.createElement("td");
|
---|
189 | newtd_c1.setAttribute("width","200");
|
---|
190 | newtd_c1.setAttribute("align","center");
|
---|
191 | newtd_c1.setAttribute("valign", "top");
|
---|
192 | newtd_c1.appendChild(
|
---|
193 | input_data = document.createElement("input"),
|
---|
194 | input_data.setAttribute("type","time"),
|
---|
195 | input_data.setAttribute("class","time"),
|
---|
196 | input_data.setAttribute("size","10"),
|
---|
197 | input_data.setAttribute("autofocus","true")
|
---|
198 | );
|
---|
199 | newtd_c1.appendChild(
|
---|
200 | input_data = document.createElement("input"),
|
---|
201 | input_data.setAttribute("type","button"),
|
---|
202 | input_data.setAttribute("value","+"),
|
---|
203 | input_data.onclick = function(){
|
---|
204 | addRowCloneNew("list_"+newlist);
|
---|
205 | }
|
---|
206 | );
|
---|
207 | var newtd_c2 = document.createElement("td");
|
---|
208 |
|
---|
209 | newtd_c2.setAttribute("width","138");
|
---|
210 | newtd_c2.setAttribute("align","center");
|
---|
211 | newtd_c2.appendChild(
|
---|
212 | select = document.createElement("select"),
|
---|
213 | select.setAttribute("class","measure"),
|
---|
214 | $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
|
---|
215 | type:"post",
|
---|
216 | url:"Transaction/measurement.php",
|
---|
217 | success:function(data){
|
---|
218 | var obj=$.parseJSON(data);
|
---|
219 | $.each(obj,function(){
|
---|
220 | select.appendChild(
|
---|
221 | option = document.createElement("option"),
|
---|
222 | option.setAttribute('value',this['fMeasurementKey']),
|
---|
223 | option.appendChild(document.createTextNode(this['fMeasurement']))
|
---|
224 | )
|
---|
225 | })
|
---|
226 |
|
---|
227 | }
|
---|
228 | }) // End of retrieving
|
---|
229 |
|
---|
230 | );
|
---|
231 | newtd_c2.setAttribute("width","115");
|
---|
232 | newtd_c2.setAttribute("align","center");
|
---|
233 | newtd_c2.appendChild(
|
---|
234 | input_data = document.createElement("input"),
|
---|
235 | input_data.setAttribute("type","button"),
|
---|
236 | input_data.setAttribute("value","+"),
|
---|
237 | input_data.onclick = function(){
|
---|
238 | return addRow(newtr);
|
---|
239 | ctr++;
|
---|
240 | });
|
---|
241 | var newtd_c3 = document.createElement("td");
|
---|
242 | newtd_c3.setAttribute("width","98");
|
---|
243 | newtd_c3.setAttribute("align","center");
|
---|
244 | newtd_c3.appendChild(
|
---|
245 | selection = document.createElement("select"),
|
---|
246 | selection.setAttribute("class","source"),
|
---|
247 | $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
|
---|
248 | type:"post",
|
---|
249 | url:"Transaction/source.php",
|
---|
250 | success:function(data)
|
---|
251 | {
|
---|
252 | var obj = $.parseJSON(data);
|
---|
253 | $.each(obj,function(){
|
---|
254 | selection.appendChild(
|
---|
255 | option=document.createElement('option'),
|
---|
256 | option.setAttribute('value',this['fSourceKEY']),
|
---|
257 | option.appendChild(document.createTextNode(this['fSourceName']))
|
---|
258 | )
|
---|
259 | });
|
---|
260 | }
|
---|
261 | }) // End of retrieving
|
---|
262 | );
|
---|
263 | var newtd_c4 = document.createElement("td");
|
---|
264 | newtd_c4.setAttribute("width","119");
|
---|
265 | newtd_c4.setAttribute("align","center");
|
---|
266 | newtd_c4.appendChild(
|
---|
267 | input_data = document.createElement("input"),
|
---|
268 | input_data.setAttribute("type","text"),
|
---|
269 | input_data.setAttribute("class","selected"),
|
---|
270 | input_data.setAttribute("size","12"),
|
---|
271 | input_data.setAttribute("placeholder","Value")
|
---|
272 | );
|
---|
273 | var newtd_c5 = document.createElement("td");
|
---|
274 | newtd_c5.setAttribute("width","115");
|
---|
275 | newtd_c5.setAttribute("align","center");
|
---|
276 | newtd_c5.setAttribute("width","115");
|
---|
277 | newtd_c5.setAttribute("align","center");
|
---|
278 | newtd_c5.appendChild(
|
---|
279 | input_data = document.createElement("input"),
|
---|
280 | input_data.setAttribute("type","button"),
|
---|
281 | input_data.setAttribute("value","Delete"),
|
---|
282 | input_data.onclick = function(){ return clearNode(newtr);
|
---|
283 | }
|
---|
284 | );
|
---|
285 | newtr.appendChild(newtd_c2);
|
---|
286 | newtr.appendChild(newtd_c3);
|
---|
287 | newtr.appendChild(newtd_c4);
|
---|
288 | newtr.appendChild(newtd_c5);
|
---|
289 | newInnertable.appendChild(newtr);
|
---|
290 | var newtd_c6 = document.createElement("td");
|
---|
291 | newtd_c6.appendChild(newInnertable);
|
---|
292 |
|
---|
293 | var newtd_c7 = document.createElement("td");
|
---|
294 | newtd_c7.setAttribute("width","115");
|
---|
295 | newtd_c7.setAttribute("align","center");
|
---|
296 | newtd_c7.setAttribute("valign", "top");
|
---|
297 | newtd_c7.appendChild(
|
---|
298 | input_data = document.createElement("input"),
|
---|
299 | input_data.setAttribute("type","button"),
|
---|
300 | input_data.setAttribute("value","Delete Main"),
|
---|
301 | input_data.onclick = function(){ return clearNode(newdiv); }
|
---|
302 | );
|
---|
303 |
|
---|
304 | var newOutertr = document.createElement("tr");
|
---|
305 |
|
---|
306 | newtable.appendChild(newtd_c1);
|
---|
307 | newtable.appendChild(newtd_c6);
|
---|
308 | newtable.appendChild(newtd_c7);
|
---|
309 |
|
---|
310 | newdiv.appendChild(newtable);
|
---|
311 | if(nextrow != null){
|
---|
312 | var doc = document.getElementById(nextrow);
|
---|
313 | $(doc).after(newdiv);
|
---|
314 | }else{
|
---|
315 | targetView.appendChild(newdiv);
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 | function addRowClone(nextrow){
|
---|
320 | <?php
|
---|
321 | $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error());
|
---|
322 | $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$day'");
|
---|
323 | $cnt3=0;
|
---|
324 | $cnt2=0;
|
---|
325 | $cnt4 = 0;
|
---|
326 | $cnt5 = 0;
|
---|
327 | $cnt = 0;
|
---|
328 | $cntrow = 0;
|
---|
329 | $pastdate = 'false';
|
---|
330 | $pasttime = 'false';
|
---|
331 | date_default_timezone_set("UTC");
|
---|
332 | //$data = array();
|
---|
333 | //$counter=0;
|
---|
334 | while($times = mysql_fetch_array($observationsTime))
|
---|
335 | {
|
---|
336 | $timestamp=strtotime($times['fStart']);
|
---|
337 | $testdate = date('Y-m-d H:i:s', $times['fStart']);
|
---|
338 | $testing = date('Y-m-d H:i', $timestamp);
|
---|
339 | $actualtime = date('Y-m-d H:i:s', $timestamp);
|
---|
340 | if(strtotime(date('Y-m-d', $timestamp)) == strtotime(date('Y-m-d', time()))) {
|
---|
341 | $fetch_next = mysql_query("SELECT * FROM schedule WHERE (fStart > '$testing' AND date(fStart) = '$day') ORDER BY fStart LIMIT 1");
|
---|
342 | $next_data = mysql_fetch_array($fetch_next);
|
---|
343 | if (mysql_num_rows($fetch_next) > 0) {
|
---|
344 | $next_date = strtotime($next_data['fStart']);
|
---|
345 | $test = date('Y-m-d H:i', $next_date);
|
---|
346 | if(strtotime(date('Y-m-d H:i', $next_date)) > strtotime(date('Y-m-d H:i', time()))) {
|
---|
347 | $pasttime = 'true';
|
---|
348 | } else {
|
---|
349 | $pasttime = 'false';
|
---|
350 | }
|
---|
351 | } else {
|
---|
352 | $pasttime = 'true';
|
---|
353 | }
|
---|
354 | }
|
---|
355 | else {
|
---|
356 | $pasttime = 'false';
|
---|
357 | }
|
---|
358 | $timestamp2 = date('Y-m-d',$timestamp);
|
---|
359 | $date_time = date('H:i',$timestamp);
|
---|
360 | $prev_time[$cnt3]= $date_time;
|
---|
361 |
|
---|
362 |
|
---|
363 | if(strtotime(date('Y-m-d H:i', $timestamp)) < strtotime(date('Y-m-d H:i', time()))) {
|
---|
364 | $pastdate = 'true';
|
---|
365 | }
|
---|
366 | else {
|
---|
367 | $pastdate = 'false';
|
---|
368 | }
|
---|
369 | ?>
|
---|
370 | $('#save').attr('value','UPDATE');
|
---|
371 | var targetView = document.getElementById("Data");
|
---|
372 | // CREATE ELEMENT
|
---|
373 | // COUNT LIST
|
---|
374 | var list = $(".datalisting").length;
|
---|
375 | var newlist = list+1;
|
---|
376 | <?php $cnt++;?>
|
---|
377 |
|
---|
378 | var cctr=$('.dataTable tr').length;
|
---|
379 | ctr=cctr+1;
|
---|
380 | var select;
|
---|
381 | var input_data;
|
---|
382 | var option;
|
---|
383 | var selection;
|
---|
384 |
|
---|
385 | var newdiv<?php echo $cnt; ?> = document.createElement("div");
|
---|
386 | newdiv<?php echo $cnt; ?>.setAttribute("id", "list_<?php echo $cnt; ?>");
|
---|
387 | newdiv<?php echo $cnt; ?>.setAttribute("class","datalisting");
|
---|
388 | newdiv<?php echo $cnt; ?>.setAttribute("style","margin:5px 0;");
|
---|
389 |
|
---|
390 | var newtable = document.createElement("table");
|
---|
391 | newtable.setAttribute("class","dataTable");
|
---|
392 | newtable.setAttribute("width","100%");
|
---|
393 | newtable.setAttribute("border","1");
|
---|
394 | newtable.setAttribute("cellspacing","0");
|
---|
395 | newtable.setAttribute("cellpadding","0");
|
---|
396 |
|
---|
397 |
|
---|
398 | var newInnertable = document.createElement("table");
|
---|
399 | newInnertable.setAttribute("class","dataTable");
|
---|
400 | newInnertable.setAttribute("width","100%");
|
---|
401 | newInnertable.setAttribute("border","1");
|
---|
402 |
|
---|
403 | newInnertable.setAttribute("cellspacing","0");
|
---|
404 | newInnertable.setAttribute("cellpadding","0");
|
---|
405 |
|
---|
406 | var newtd_c1 = document.createElement("td");
|
---|
407 | newtd_c1.setAttribute("width","200");
|
---|
408 | newtd_c1.setAttribute("align","center");
|
---|
409 | newtd_c1.setAttribute("valign", "top");
|
---|
410 | <?php if ($pastdate == 'true') { ?>
|
---|
411 | newtd_c1.appendChild(
|
---|
412 | input_data = document.createElement("input"),
|
---|
413 | input_data.setAttribute("type","time"),
|
---|
414 | input_data.setAttribute("class","time"),
|
---|
415 | input_data.setAttribute("size","10"),
|
---|
416 | input_data.setAttribute("value","<?php echo $date_time; ?>"),
|
---|
417 | input_data.setAttribute("autofocus","true"),
|
---|
418 | input_data.setAttribute("disabled", "disabled")
|
---|
419 | );
|
---|
420 | <?php } else { ?>
|
---|
421 | newtd_c1.appendChild(
|
---|
422 | input_data = document.createElement("input"),
|
---|
423 | input_data.setAttribute("type","time"),
|
---|
424 | input_data.setAttribute("class","time"),
|
---|
425 | input_data.setAttribute("size","10"),
|
---|
426 | input_data.setAttribute("value","<?php echo $date_time; ?>"),
|
---|
427 | input_data.setAttribute("autofocus","true")
|
---|
428 | );
|
---|
429 | <?php }
|
---|
430 | if($pasttime == 'true') { ?>
|
---|
431 | newtd_c1.appendChild(
|
---|
432 | input_data = document.createElement("input"),
|
---|
433 | input_data.setAttribute("type","button"),
|
---|
434 | input_data.setAttribute("value","+"),
|
---|
435 | input_data.onclick = function(){
|
---|
436 | addRowCloneNew("list_<?php echo $cnt; ?>");
|
---|
437 | }
|
---|
438 | );
|
---|
439 | <?php } else { if ($pastdate == 'true') { ?>
|
---|
440 | newtd_c1.appendChild(
|
---|
441 | input_data = document.createElement("input"),
|
---|
442 | input_data.setAttribute("type","button"),
|
---|
443 | input_data.setAttribute("value","+"),
|
---|
444 | input_data.setAttribute("disabled", "disabled"),
|
---|
445 | input_data.onclick = function(){
|
---|
446 | addRowCloneNew("list_<?php echo $cnt; ?>");
|
---|
447 | }
|
---|
448 | );
|
---|
449 | <?php } else { ?>
|
---|
450 | newtd_c1.appendChild(
|
---|
451 | input_data = document.createElement("input"),
|
---|
452 | input_data.setAttribute("type","button"),
|
---|
453 | input_data.setAttribute("value","+"),
|
---|
454 | input_data.onclick = function(){
|
---|
455 | addRowCloneNew("list_<?php echo $cnt; ?>");
|
---|
456 | }
|
---|
457 | );
|
---|
458 | <?php } }
|
---|
459 | $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'");
|
---|
460 |
|
---|
461 | while($rows = mysql_fetch_array($observations))
|
---|
462 | {
|
---|
463 | $cntrow++;
|
---|
464 | ?>
|
---|
465 |
|
---|
466 | var newtr<?php echo $cntrow; ?> = document.createElement("tr");
|
---|
467 | newtr<?php echo $cntrow; ?>.setAttribute('class','tr');
|
---|
468 |
|
---|
469 | <?php if ($pastdate == 'true') { ?>
|
---|
470 | var newtd_c2 = document.createElement("td");
|
---|
471 | newtd_c2.setAttribute("width","138");
|
---|
472 | newtd_c2.setAttribute("align","center");
|
---|
473 | <?php
|
---|
474 | $cur_measurement = $rows[fMeasurementTypeKey];
|
---|
475 | $selectm = mysql_query("SELECT fMeasurement FROM measurement WHERE fMeasurementKey = '$cur_measurement'");
|
---|
476 | $rowmeasure = mysql_fetch_array($selectm);
|
---|
477 | ?>
|
---|
478 | newtd_c2.appendChild(
|
---|
479 | selection = document.createElement("input"),
|
---|
480 | selection.setAttribute("value", "<?php echo $rowmeasure['fMeasurement']; ?>"),
|
---|
481 | selection.setAttribute("type","text"),
|
---|
482 | selection.setAttribute("class","selected"),
|
---|
483 | selection.setAttribute("size", "12"),
|
---|
484 | selection.setAttribute("placeholder", "Value"),
|
---|
485 | selection.setAttribute("disabled", "disabled")
|
---|
486 | );
|
---|
487 | newtd_c2.setAttribute("width","115");
|
---|
488 | newtd_c2.setAttribute("align","center");
|
---|
489 | newtd_c2.appendChild(
|
---|
490 | input_data = document.createElement("input"),
|
---|
491 | input_data.setAttribute("type","button"),
|
---|
492 | input_data.setAttribute("value","+"),
|
---|
493 | input_data.setAttribute("disabled", "disabled"),
|
---|
494 | input_data.onclick = function(){
|
---|
495 | return addRow(newtr<?php echo $cntrow; ?>);
|
---|
496 | ctr++;
|
---|
497 | });
|
---|
498 |
|
---|
499 | var newtd_c3 = document.createElement("td");
|
---|
500 | newtd_c3.setAttribute("width","98");
|
---|
501 | newtd_c3.setAttribute("align","center");
|
---|
502 | <?php
|
---|
503 | $cur_source = $rows['fSourceKey'];
|
---|
504 | $select = mysql_query("SELECT fSourceName FROM source WHERE fSourceKey = '$cur_source'");
|
---|
505 | $rowsource = mysql_fetch_array($select); ?>
|
---|
506 | newtd_c3.appendChild(
|
---|
507 | selection = document.createElement("input"),
|
---|
508 | selection.setAttribute("value", "<?php echo $rowsource['fSourceName']; ?>"),
|
---|
509 | selection.setAttribute("type","text"),
|
---|
510 | selection.setAttribute("class","selected"),
|
---|
511 | selection.setAttribute("size", "12"),
|
---|
512 | selection.setAttribute("placeholder", "Value"),
|
---|
513 | selection.setAttribute("disabled", "disabled")
|
---|
514 | );
|
---|
515 |
|
---|
516 | var newtd_c4 = document.createElement("td");
|
---|
517 | newtd_c4.setAttribute("width","119");
|
---|
518 | newtd_c4.setAttribute("align","center");
|
---|
519 | newtd_c4.appendChild(
|
---|
520 | input_data = document.createElement("input"),
|
---|
521 | input_data.setAttribute("type","text"),
|
---|
522 | input_data.setAttribute("class","selected"),
|
---|
523 | input_data.setAttribute("size","12"),
|
---|
524 | input_data.setAttribute("value","<?php echo $rows['fData']; ?>"),
|
---|
525 | input_data.setAttribute("placeholder","Value"),
|
---|
526 | input_data.setAttribute("disabled", "disbaled")
|
---|
527 | );
|
---|
528 |
|
---|
529 | var newtd_c5 = document.createElement("td");
|
---|
530 | newtd_c5.setAttribute("width","115");
|
---|
531 | newtd_c5.setAttribute("align","center");
|
---|
532 | newtd_c5.setAttribute("width","115");
|
---|
533 | newtd_c5.setAttribute("align","center");
|
---|
534 | newtd_c5.appendChild(
|
---|
535 | input_data = document.createElement("input"),
|
---|
536 | input_data.setAttribute("type","button"),
|
---|
537 | input_data.setAttribute("value","Delete"),
|
---|
538 | input_data.setAttribute("disabled", "disabled"),
|
---|
539 | input_data.onclick = function(){
|
---|
540 | return clearNode(newtr<?php echo $cntrow; ?>);
|
---|
541 | }
|
---|
542 | );
|
---|
543 | <?php } else { ?>
|
---|
544 | var newtd_c2 = document.createElement("td");
|
---|
545 | newtd_c2.setAttribute("width","138");
|
---|
546 | newtd_c2.setAttribute("align","center");
|
---|
547 | newtd_c2.appendChild(
|
---|
548 | selection = document.createElement("select"),
|
---|
549 | <?php
|
---|
550 | $selectm = mysql_query("SELECT * FROM measurement");
|
---|
551 | while($rowmeasure = mysql_fetch_array($selectm))
|
---|
552 | {
|
---|
553 | ?>
|
---|
554 | selection.appendChild(
|
---|
555 | option = document.createElement("option"),
|
---|
556 | option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),
|
---|
557 | <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
|
---|
558 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
---|
559 | ),
|
---|
560 | <?php
|
---|
561 | }
|
---|
562 | ?>
|
---|
563 | selection.setAttribute('id','measure'),
|
---|
564 | selection.setAttribute('class','measure')
|
---|
565 | );
|
---|
566 | newtd_c2.setAttribute("width","115");
|
---|
567 | newtd_c2.setAttribute("align","center");
|
---|
568 | newtd_c2.appendChild(
|
---|
569 | input_data = document.createElement("input"),
|
---|
570 | input_data.setAttribute("type","button"),
|
---|
571 | input_data.setAttribute("value","+"),
|
---|
572 | input_data.onclick = function(){
|
---|
573 | return addRow(newtr<?php echo $cntrow; ?>);
|
---|
574 | ctr++;
|
---|
575 | });
|
---|
576 |
|
---|
577 | var newtd_c3 = document.createElement("td");
|
---|
578 | newtd_c3.setAttribute("width","98");
|
---|
579 | newtd_c3.setAttribute("align","center");
|
---|
580 | newtd_c3.appendChild(
|
---|
581 | selection = document.createElement("select"),
|
---|
582 | <?php
|
---|
583 | $select = mysql_query("SELECT * FROM source");
|
---|
584 | while($rowsource = mysql_fetch_array($select))
|
---|
585 | {
|
---|
586 | ?>
|
---|
587 | selection.appendChild(
|
---|
588 | option = document.createElement("option"),
|
---|
589 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
---|
590 | <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?>
|
---|
591 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
---|
592 | ),
|
---|
593 | <?php
|
---|
594 | }
|
---|
595 | ?>
|
---|
596 | selection.setAttribute('id','source'), // End of retrieving
|
---|
597 | selection.setAttribute('class','source') // End of retrieving
|
---|
598 | );
|
---|
599 |
|
---|
600 | var newtd_c4 = document.createElement("td");
|
---|
601 | newtd_c4.setAttribute("width","119");
|
---|
602 | newtd_c4.setAttribute("align","center");
|
---|
603 | newtd_c4.appendChild(
|
---|
604 | input_data = document.createElement("input"),
|
---|
605 | input_data.setAttribute("type","text"),
|
---|
606 | input_data.setAttribute("class","selected"),
|
---|
607 | input_data.setAttribute("size","12"),
|
---|
608 | input_data.setAttribute("value","<?php echo $rows['fData']; ?>"),
|
---|
609 | input_data.setAttribute("placeholder","Value")
|
---|
610 | );
|
---|
611 |
|
---|
612 | var newtd_c5 = document.createElement("td");
|
---|
613 | newtd_c5.setAttribute("width","115");
|
---|
614 | newtd_c5.setAttribute("align","center");
|
---|
615 | newtd_c5.setAttribute("width","115");
|
---|
616 | newtd_c5.setAttribute("align","center");
|
---|
617 | newtd_c5.appendChild(
|
---|
618 | input_data = document.createElement("input"),
|
---|
619 | input_data.setAttribute("type","button"),
|
---|
620 | input_data.setAttribute("value","Delete"),
|
---|
621 | input_data.onclick = function(){ return clearNode(newtr<?php echo $cntrow; ?>);
|
---|
622 |
|
---|
623 | }
|
---|
624 | );
|
---|
625 | <?php } ?>
|
---|
626 | newtr<?php echo $cntrow; ?>.appendChild(newtd_c2);
|
---|
627 | newtr<?php echo $cntrow; ?>.appendChild(newtd_c3);
|
---|
628 | newtr<?php echo $cntrow; ?>.appendChild(newtd_c4);
|
---|
629 | newtr<?php echo $cntrow; ?>.appendChild(newtd_c5);
|
---|
630 | newInnertable.appendChild(newtr<?php echo $cntrow; ?>);
|
---|
631 |
|
---|
632 | <?php
|
---|
633 |
|
---|
634 | $prevtimestamp = $timestamp;
|
---|
635 | }
|
---|
636 | ?>
|
---|
637 |
|
---|
638 | var newtd_c6 = document.createElement("td");
|
---|
639 | newtd_c6.appendChild(newInnertable);
|
---|
640 |
|
---|
641 | var newtd_c7 = document.createElement("td");
|
---|
642 | newtd_c7.setAttribute("width","115");
|
---|
643 | newtd_c7.setAttribute("align","center");
|
---|
644 | newtd_c7.setAttribute("valign", "top");
|
---|
645 | <?php if ($pastdate == 'true') { ?>
|
---|
646 | newtd_c7.appendChild(
|
---|
647 | input_data = document.createElement("input"),
|
---|
648 | input_data.setAttribute("type","button"),
|
---|
649 | input_data.setAttribute("value","Delete Main"),
|
---|
650 | input_data.setAttribute("disabled", "disabled"),
|
---|
651 | input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); }
|
---|
652 | );
|
---|
653 | <?php } else { ?>
|
---|
654 | newtd_c7.appendChild(
|
---|
655 | input_data = document.createElement("input"),
|
---|
656 | input_data.setAttribute("type","button"),
|
---|
657 | input_data.setAttribute("value","Delete Main"),
|
---|
658 | input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); }
|
---|
659 | );
|
---|
660 | <?php } ?>
|
---|
661 |
|
---|
662 | var newOutertr = document.createElement("tr");
|
---|
663 |
|
---|
664 | newtable.appendChild(newtd_c1);
|
---|
665 | newtable.appendChild(newtd_c6);
|
---|
666 | newtable.appendChild(newtd_c7);
|
---|
667 |
|
---|
668 | newdiv<?php echo $cnt; ?>.appendChild(newtable);
|
---|
669 | if(nextrow != null){
|
---|
670 | var doc = document.getElementById(nextrow);
|
---|
671 | $(doc).after(newdiv<?php echo $cnt;?>);
|
---|
672 | }else{
|
---|
673 | targetView.appendChild(newdiv<?php echo $cnt;?>);
|
---|
674 | //$(targetView).after(newtr<?php echo $cnt; ?>);
|
---|
675 | }
|
---|
676 | <?php
|
---|
677 | }
|
---|
678 | if(mysql_num_rows($fetch)<1)
|
---|
679 | {
|
---|
680 | ?>
|
---|
681 | $('#save').attr('value','SAVE');
|
---|
682 | addRowCloneNew();
|
---|
683 | <?php
|
---|
684 | }
|
---|
685 |
|
---|
686 | ?>
|
---|
687 |
|
---|
688 |
|
---|
689 | }
|
---|
690 |
|
---|
691 | $('#LoadPrev').click(function() {
|
---|
692 | });
|
---|
693 | </script>
|
---|
694 |
|
---|