Changeset 16982 for schedule/function
- Timestamp:
- 07/24/13 04:31:08 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/function/SplitDelete.php
r16953 r16982 1 <?php include '../include/factdb.php'; ?> 1 2 <script src="js/jquery-1.7.1.js"></script> 2 3 <script language="javascript"> 4 3 5 var timeval = 0; 4 6 var name = ""; … … 14 16 } 15 17 } 18 19 16 20 function addRow(table){ 21 $(this).prepend("tableID"); 17 22 var targetView = table; 18 23 // CREATE ELEMENT … … 25 30 input_data = document.createElement("input"), 26 31 input_data.setAttribute("type","time"), 32 input_data.setAttribute("size","10"), 27 33 input_data.setAttribute("autofocus","true"), 28 input_data.setAttribute("id","Time"), 29 input_data.setAttribute("max","24"), 30 input_data.setAttribute("min","1"), 31 input_data.setAttribute("required",true), 32 input_data.setAttribute("hidden",true), 33 input_data.setAttribute("value",timeval) 34 input_data.setAttribute("hidden",true) 34 35 ); 35 36 var newtd_c2 = document.createElement("td"); … … 45 46 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))), 46 47 <?php } ?> 47 48 49 50 selection.setAttribute('id','source') 51 ); 48 selection.setAttribute('id','source') 49 ); 50 51 //var newtd_c2 = document.createElement("td"); 52 newtd_c2.setAttribute("width","115"); 53 newtd_c2.setAttribute("align","center"); 52 54 newtd_c2.appendChild( 53 input_data = document.createElement("input"), 54 input_data.setAttribute("class","button"), 55 input_data.setAttribute("type","button"), 56 input_data.setAttribute("value","+"), 57 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){ 58 val = $(this).val(); 59 60 }); 61 timeval = val; return addRow(table); } 62 ); 55 input_data = document.createElement("input"), 56 input_data.setAttribute("type","button"), 57 input_data.setAttribute("value","[ + ]"), 58 input_data.onclick = function(){ return addRow(table); } 59 ); 60 63 61 var newtd_c3 = document.createElement("td"); 64 62 newtd_c3.setAttribute("width","88"); … … 78 76 ); 79 77 var newtd_c4 = document.createElement("td"); 80 newtd_c4.setAttribute("width","180"); 81 newtd_c4.setAttribute("align","center"); 82 newtd_c4.appendChild( 83 input_data = document.createElement("input"), 84 input_data.setAttribute("type","text"), 85 input_data.setAttribute("size","20"), 86 input_data.setAttribute("placeholder","Value") 87 ); 88 var newtd_c5 = document.createElement("td"); 89 newtd_c5.setAttribute("width","95"); 90 newtd_c5.setAttribute("align","center"); 91 newtd_c5.appendChild( 92 input_data = document.createElement("input"), 93 input_data.setAttribute("type","button"), 94 input_data.setAttribute("class","button"), 95 input_data.setAttribute("value","Delete"), 96 input_data.onclick = function(){ return clearNode(newtr); } 97 ); 98 78 newtd_c4.setAttribute("width","180"); 79 newtd_c4.setAttribute("align","center"); 80 newtd_c4.appendChild( 81 input_data = document.createElement("input"), 82 input_data.setAttribute("type","text"), 83 input_data.setAttribute("size","12"), 84 input_data.setAttribute("placeholder","Value") 85 ); 86 var newtd_c5 = document.createElement("td"); 87 newtd_c5.setAttribute("width","95"); 88 newtd_c5.setAttribute("align","center"); 89 newtd_c5.appendChild( 90 input_data = document.createElement("input"), 91 input_data.setAttribute("type","button"), 92 input_data.setAttribute("value","[ Delete ]"), 93 input_data.onclick = function(){ return clearNode(newtr); } 94 ); 99 95 100 96 newtr.appendChild(newtd_c1); … … 103 99 newtr.appendChild(newtd_c4); 104 100 newtr.appendChild(newtd_c5); 105 106 107 $(targetView).append(newtr); 108 } 101 //newtr.appendChild(newtd_c6); 102 103 targetView.appendChild(newtr); 104 105 } 106 109 107 function deleteRow(tableID){ 110 108 try{ … … 130 128 131 129 132 function addRowClone( ){130 function addRowClone(nextrow){ 133 131 var targetView = document.getElementById("Data"); 134 132 // CREATE ELEMENT 133 // COUNT LIST 134 var list = $(".datalisting").length; 135 var newlist = list+1; 135 136 136 137 var newdiv = document.createElement("div"); 137 newdiv.setAttribute("style","margin:30px 0;"); 138 newdiv.setAttribute("id","list_"+newlist); 139 newdiv.setAttribute("class","datalisting"); 140 newdiv.setAttribute("style","margin:5px 0;"); 138 141 var newtable = document.createElement("table"); 139 142 newtable.setAttribute("class","dataTable"); 140 143 newtable.setAttribute("width","100%"); 141 newtable.setAttribute("border"," 1");144 newtable.setAttribute("border","3"); 142 145 newtable.setAttribute("cellspacing","0"); 143 146 newtable.setAttribute("cellpadding","0"); … … 149 152 newtd_c1.setAttribute("align","center"); 150 153 newtd_c1.appendChild( 151 input_data = document.createElement("input"), 152 input_data.setAttribute("type","time"), 153 input_data.setAttribute("autofocus","true"), 154 input_data.setAttribute("id","Time"), 155 input_data.setAttribute("max","24"), 156 input_data.setAttribute("min","1"), 157 input_data.setAttribute("required",true) 158 154 input_data = document.createElement("input"), 155 input_data.setAttribute("type","time"), 156 input_data.setAttribute("size","10"), 157 input_data.setAttribute("autofocus","true") 158 ); 159 newtd_c1.appendChild( 160 input_data = document.createElement("input"), 161 input_data.setAttribute("type","button"), 162 input_data.setAttribute("value","[ + ]"), 163 input_data.onclick = function(){ 164 addRowClone("list_"+newlist); 165 } 159 166 ); 160 167 var newtd_c2 = document.createElement("td"); … … 162 169 newtd_c2.setAttribute("align","center"); 163 170 newtd_c2.appendChild( 164 165 171 selection = document.createElement("select"), 172 <?php 166 173 $selectm = mysql_query("SELECT * FROM measurement"); 167 174 while($rowmeasure = mysql_fetch_array($selectm)){ … … 174 181 selection.setAttribute('id','source') 175 182 ); 176 newtd_c2.appendChild( 183 184 // var newtd_c6 = document.createElement("td"); 185 newtd_c2.setAttribute("width","115"); 186 newtd_c2.setAttribute("align","center"); 187 newtd_c2.appendChild( 177 188 input_data = document.createElement("input"), 178 input_data.setAttribute("class","button"),179 189 input_data.setAttribute("type","button"), 180 input_data.setAttribute("value","+"), 181 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){ 182 val = $(this).val(); 183 184 }); 185 timeval = val; 186 return addRow(newtable);} 187 ); 188 var newtd_c3 = document.createElement("td"); 189 newtd_c3.setAttribute("width","88"); 190 newtd_c3.setAttribute("align","center"); 191 newtd_c3.appendChild( 192 selection = document.createElement("select"), 193 <?php 190 input_data.setAttribute("value","[ + ]"), 191 input_data.onclick = function(){ return addRow(newtable); } 192 ); 193 var newtd_c3 = document.createElement("td"); 194 newtd_c3.setAttribute("width","98"); 195 newtd_c3.setAttribute("align","center"); 196 newtd_c3.appendChild( 197 selection = document.createElement("select"), 198 <?php 194 199 195 200 $select = mysql_query("SELECT * FROM source"); … … 203 208 selection.setAttribute('id','measurement') 204 209 ); 205 var newtd_c4 = document.createElement("td"); 206 newtd_c4.setAttribute("width","180"); 207 newtd_c4.setAttribute("align","center"); 208 newtd_c4.appendChild( 209 input_data = document.createElement("input"), 210 input_data.setAttribute("type","text"), 211 input_data.setAttribute("size","20"), 212 input_data.setAttribute("placeholder","Value") 213 ); 214 var newtd_c5 = document.createElement("td"); 215 newtd_c5.setAttribute("width","95"); 216 newtd_c5.setAttribute("align","center"); 217 newtd_c5.appendChild( 218 input_data = document.createElement("input"), 219 input_data.setAttribute("type","button"), 220 input_data.setAttribute("class","button"), 221 input_data.setAttribute("value","Delete Main"), 222 input_data.onclick = function(){ return clearNode(newdiv); } 223 ); 224 225 210 var newtd_c4 = document.createElement("td"); 211 newtd_c4.setAttribute("width","180"); 212 newtd_c4.setAttribute("align","center"); 213 newtd_c4.appendChild( 214 input_data = document.createElement("input"), 215 input_data.setAttribute("type","text"), 216 input_data.setAttribute("size","25"), 217 input_data.setAttribute("placeholder","Value") 218 ); 219 var newtd_c5 = document.createElement("td"); 220 newtd_c5.setAttribute("width","95"); 221 newtd_c5.setAttribute("align","center"); 222 newtd_c5.appendChild( 223 input_data = document.createElement("input"), 224 input_data.setAttribute("type","button"), 225 input_data.setAttribute("value","[ Delete Main ]"), 226 input_data.onclick = function(){ return clearNode(newdiv); } 227 ); 228 226 229 newtr.appendChild(newtd_c1); 227 230 newtr.appendChild(newtd_c2); … … 229 232 newtr.appendChild(newtd_c4); 230 233 newtr.appendChild(newtd_c5); 231 234 //newtr.appendChild(newtd_c6); 232 235 233 236 newtable.appendChild(newtr); 234 237 newdiv.appendChild(newtable); 235 238 236 targetView.appendChild(newdiv); 239 if(nextrow != null){ 240 var doc = document.getElementById(nextrow); 241 $(doc).after(newdiv); 242 }else{ 243 targetView.appendChild(newdiv); 244 } 237 245 } 238 239 240 241 242 <?php243 244 if(isset($_GET['days']))245 {246 $day = $_GET['days'];247 }248 else249 {250 $day =date("Y-m-d");251 }252 $days = Date('Y-m-d',strtotime($day));253 $fetch = mysql_query("SELECT * FROM schedule ORDER BY fScheduleID ASC") or die(mysql_error());254 while($rows = mysql_fetch_array($fetch))255 {256 $timestamp=strtotime($rows['fStart']);257 $timestamp2 = date('Y-m-d',$timestamp);258 $date_time = date('H:i',$timestamp);259 260 if($days == $timestamp2)261 {262 ?>263 cnt++;264 265 $('#save').attr('value','UPDATE');266 267 var targetView = document.getElementById("Data");268 // CREATE ELEMENT269 var newdiv = document.createElement("div");270 newdiv.setAttribute("style","margin:5px 0;");271 var newtable = document.createElement("table");272 newtable.setAttribute("class","dataTable");273 newtable.setAttribute("id","dataTable"+cnt);274 newtable.setAttribute("width","100%");275 newtable.setAttribute("border","1");276 newtable.setAttribute("cellspacing","0");277 newtable.setAttribute("cellpadding","0");278 279 var newtr = document.createElement("tr");280 281 var newtd_c1 = document.createElement("td");282 newtd_c1.setAttribute("width","115");283 newtd_c1.setAttribute("align","center");284 newtd_c1.appendChild(285 input_data = document.createElement("input"),286 input_data.setAttribute("type","time"),287 input_data.setAttribute("autofocus","true"),288 input_data.setAttribute("id","Time"),289 input_data.setAttribute("max","24"),290 input_data.setAttribute("min","1"),291 input_data.setAttribute("required",true),292 input_data.setAttribute("value",'<?php echo $date_time; ?>')293 );294 var newtd_c2 = document.createElement("td");295 newtd_c2.setAttribute("width","40");296 newtd_c2.setAttribute("align","center");297 newtd_c2.appendChild(298 selection = document.createElement("select"),299 <?php300 $selectm = mysql_query("SELECT * FROM measurement");301 while($rowmeasure = mysql_fetch_array($selectm)){302 303 ?>304 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),305 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} } ?>306 307 308 selection.setAttribute('id','source')309 );310 newtd_c2.appendChild(311 input_data = document.createElement("input"),312 input_data.setAttribute("class","button"),313 input_data.setAttribute("type","button"),314 input_data.setAttribute("value","+"),315 input_data.setAttribute("name","dataTable"+cnt),316 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){317 val = $(this).val();318 319 });320 timeval = val; //alert();321 return addRow("#"+$(this).attr('name')); }322 );323 var newtd_c3 = document.createElement("td");324 newtd_c3.setAttribute("width","88");325 newtd_c3.setAttribute("align","center");326 newtd_c3.appendChild(327 selection = document.createElement("select"),328 329 <?php330 331 $select = mysql_query("SELECT * FROM source");332 333 while($rowsource = mysql_fetch_array($select)){334 335 ?>336 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),337 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>338 339 <?php } ?>340 selection.setAttribute('id','measurement')341 );342 var newtd_c4 = document.createElement("td");343 newtd_c4.setAttribute("width","180");344 newtd_c4.setAttribute("align","center");345 newtd_c4.appendChild(346 input_data = document.createElement("input"),347 input_data.setAttribute("type","text"),348 input_data.setAttribute("size","20"),349 input_data.setAttribute("placeholder","Value"),350 input_data.setAttribute('value','<?php echo $rows['fData']; ?>')351 );352 var newtd_c5 = document.createElement("td");353 newtd_c5.setAttribute("width","95");354 newtd_c5.setAttribute("align","center");355 newtd_c5.appendChild(356 input_data = document.createElement("input"),357 input_data.setAttribute("type","button"),358 input_data.setAttribute("class","button"),359 input_data.setAttribute("value","Delete Main"),360 input_data.onclick = function(){ return clearNode(newdiv); }361 );362 363 364 newtr.appendChild(newtd_c1);365 newtr.appendChild(newtd_c2);366 newtr.appendChild(newtd_c3);367 newtr.appendChild(newtd_c4);368 newtr.appendChild(newtd_c5);369 370 371 newtable.appendChild(newtr);372 newdiv.appendChild(newtable);373 374 targetView.appendChild(newdiv);375 376 377 378 <?php } } ?>379 380 381 382 383 384 385 386 246 window.onload = function(){ 387 388 389 390 391 if(cnt==0){ 392 393 var targetView = document.getElementById("Data"); 394 // CREATE ELEMENT 395 var newdiv = document.createElement("div"); 396 newdiv.setAttribute("style","margin:5px 0;"); 397 var newtable = document.createElement("table"); 398 newtable.setAttribute("class","dataTable"); 399 newtable.setAttribute("width","100%"); 400 newtable.setAttribute("border","1"); 401 newtable.setAttribute("cellspacing","0"); 402 newtable.setAttribute("cellpadding","0"); 403 404 var newtr = document.createElement("tr"); 405 406 var newtd_c1 = document.createElement("td"); 407 newtd_c1.setAttribute("width","115"); 408 newtd_c1.setAttribute("align","center"); 409 newtd_c1.appendChild( 410 input_data = document.createElement("input"), 411 input_data.setAttribute("type","time"), 412 input_data.setAttribute("autofocus","true"), 413 input_data.setAttribute("id","Time"), 414 input_data.setAttribute("max","24"), 415 input_data.setAttribute("min","1"), 416 input_data.setAttribute("required",true) 417 ); 418 var newtd_c2 = document.createElement("td"); 419 newtd_c2.setAttribute("width","40"); 420 newtd_c2.setAttribute("align","center"); 421 newtd_c2.appendChild( 422 selection = document.createElement("select"), 423 <?php 424 $selectm = mysql_query("SELECT * FROM measurement"); 425 while($rowmeasure = mysql_fetch_array($selectm)){ 426 427 ?> 428 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))), 429 <?php } ?> 430 431 432 selection.setAttribute('id','source') 433 ); 434 newtd_c2.appendChild( 435 input_data = document.createElement("input"), 436 input_data.setAttribute("class","button"), 437 input_data.setAttribute("type","button"), 438 input_data.setAttribute("value","+"), 439 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){ 440 val = $(this).val(); 441 442 }); 443 timeval = val; return addRow(newtable);} 444 ); 445 var newtd_c3 = document.createElement("td"); 446 newtd_c3.setAttribute("width","88"); 447 newtd_c3.setAttribute("align","center"); 448 newtd_c3.appendChild( 449 selection = document.createElement("select"), 450 <?php 451 452 $select = mysql_query("SELECT * FROM source"); 453 454 while($rowsource = mysql_fetch_array($select)){ 455 456 ?> 457 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))), 458 <?php } ?> 459 460 selection.setAttribute('id','measurement') 461 ); 462 var newtd_c4 = document.createElement("td"); 463 newtd_c4.setAttribute("width","180"); 464 newtd_c4.setAttribute("align","center"); 465 newtd_c4.appendChild( 466 input_data = document.createElement("input"), 467 input_data.setAttribute("type","text"), 468 input_data.setAttribute("size","20"), 469 input_data.setAttribute("placeholder","Value") 470 ); 471 var newtd_c5 = document.createElement("td"); 472 newtd_c5.setAttribute("width","95"); 473 newtd_c5.setAttribute("align","center"); 474 newtd_c5.appendChild( 475 input_data = document.createElement("input"), 476 input_data.setAttribute("type","button"), 477 input_data.setAttribute("class","button"), 478 input_data.setAttribute("value","Delete Main"), 479 input_data.onclick = function(){ return clearNode(newdiv); } 480 ); 481 482 483 newtr.appendChild(newtd_c1); 484 newtr.appendChild(newtd_c2); 485 newtr.appendChild(newtd_c3); 486 newtr.appendChild(newtd_c4); 487 newtr.appendChild(newtd_c5); 488 489 newtable.appendChild(newtr); 490 newdiv.appendChild(newtable); 491 492 targetView.appendChild(newdiv); 247 addRowClone(); 493 248 } 494 }495 496 497 249 498 250 </script> 251 252 253 </head> 254 <body> 255 256 <div id="Data"> 257 </div> 258 </body> 259 </html>
Note:
See TracChangeset
for help on using the changeset viewer.