| 1 | <script type="text/javascript">
|
|---|
| 2 | $(document).ready(function(){
|
|---|
| 3 | var name='';
|
|---|
| 4 | var value='';
|
|---|
| 5 | var timeValue;
|
|---|
| 6 | var meas;
|
|---|
| 7 | var meas2;
|
|---|
| 8 | var getTableId;
|
|---|
| 9 | var is=0;
|
|---|
| 10 | window.cnt=0;
|
|---|
| 11 | var x = 0;
|
|---|
| 12 | <?php
|
|---|
| 13 | include '../include/factdb.php';
|
|---|
| 14 | if(isset($_GET['days']))
|
|---|
| 15 | {
|
|---|
| 16 | $day = $_GET['days'];
|
|---|
| 17 | }
|
|---|
| 18 | else
|
|---|
| 19 | {
|
|---|
| 20 | $day =date("Y-m-d");
|
|---|
| 21 | }
|
|---|
| 22 | $days = Date('Y-m-d',strtotime($day));
|
|---|
| 23 | $fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
|
|---|
| 24 | while($rows = mysql_fetch_array($fetch))
|
|---|
| 25 | {
|
|---|
| 26 | $timestamp=strtotime($rows['fStart']);
|
|---|
| 27 | $timestamp2 = date('Y-m-d',$timestamp);
|
|---|
| 28 | $date_time = date('H:i',$timestamp);
|
|---|
| 29 |
|
|---|
| 30 | if($days == $timestamp2)
|
|---|
| 31 | {
|
|---|
| 32 | ?>
|
|---|
| 33 | cnt++;
|
|---|
| 34 |
|
|---|
| 35 | $('#save').hide();
|
|---|
| 36 | $('#update').show();
|
|---|
| 37 |
|
|---|
| 38 | var div= document.createElement("div");
|
|---|
| 39 | div.setAttribute('id','TableHolder');
|
|---|
| 40 | var table = document.createElement("table");
|
|---|
| 41 | table.setAttribute('id',"table"+cnt);
|
|---|
| 42 | table.setAttribute('width','100%');
|
|---|
| 43 | var tr = document.createElement('tr');
|
|---|
| 44 | var td3=document.createElement('td');
|
|---|
| 45 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 46 | td3.appendChild(
|
|---|
| 47 | input = document.createElement("input"),
|
|---|
| 48 | input.setAttribute("type","time"),
|
|---|
| 49 | input.setAttribute("id","Time"),
|
|---|
| 50 | input.setAttribute("max","24"),
|
|---|
| 51 | input.setAttribute("min","1"),
|
|---|
| 52 | input.setAttribute("required",true),
|
|---|
| 53 | input.setAttribute("value",'<?php echo $date_time; ?>')
|
|---|
| 54 |
|
|---|
| 55 | );
|
|---|
| 56 | td3.appendChild(
|
|---|
| 57 | button=document.createElement('input'),
|
|---|
| 58 | button.setAttribute('type','button'),
|
|---|
| 59 | button.setAttribute('value','[+]'),
|
|---|
| 60 | button.setAttribute('id','btnAddTime'),
|
|---|
| 61 | button.setAttribute('name','#table'+cnt),
|
|---|
| 62 | button.onclick=function(){
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 01;
|
|---|
| 67 |
|
|---|
| 68 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 69 |
|
|---|
| 70 | function pad(number, length) {
|
|---|
| 71 |
|
|---|
| 72 | var str = '' + number;
|
|---|
| 73 | while (str.length < length) {
|
|---|
| 74 | str = '0' + str;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | return str;
|
|---|
| 78 |
|
|---|
| 79 | }
|
|---|
| 80 | var s = 0; var get;
|
|---|
| 81 | var nn;
|
|---|
| 82 | nn = $(this).attr('name');
|
|---|
| 83 | $("table").each(function() {
|
|---|
| 84 | if($(this).attr("name")==nn){
|
|---|
| 85 |
|
|---|
| 86 | get = "#"+$(this).attr("id");
|
|---|
| 87 | //get = $(this).attr("name");
|
|---|
| 88 | s =1;
|
|---|
| 89 | }else{
|
|---|
| 90 | if(s==0){
|
|---|
| 91 | get = '#table'+cnt;
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 | });
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | getTableId =get;
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | name="name"; value=""; meas = "name"; meas2 = "time"; //getTableId = $(this).attr('name');
|
|---|
| 102 | split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | }
|
|---|
| 106 | );
|
|---|
| 107 | var td=document.createElement('td');
|
|---|
| 108 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 109 | td.appendChild(
|
|---|
| 110 | sourcecbo= document.createElement('select'),
|
|---|
| 111 | sourcecbo.setAttribute('id','source'),
|
|---|
| 112 | <?php
|
|---|
| 113 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 114 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 115 | {
|
|---|
| 116 | ?>
|
|---|
| 117 | sourcecbo.appendChild(
|
|---|
| 118 | option=document.createElement('option'),
|
|---|
| 119 |
|
|---|
| 120 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 121 | <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | ),
|
|---|
| 128 | <?php
|
|---|
| 129 | }
|
|---|
| 130 | ?>
|
|---|
| 131 | sourcecbo.setAttribute('id','source')
|
|---|
| 132 |
|
|---|
| 133 | );
|
|---|
| 134 | var td1=document.createElement('td');
|
|---|
| 135 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 136 | td1.appendChild(
|
|---|
| 137 | measurementcbo= document.createElement('select'),
|
|---|
| 138 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 139 | <?php
|
|---|
| 140 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 141 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 142 | {
|
|---|
| 143 | ?>
|
|---|
| 144 | measurementcbo.appendChild(
|
|---|
| 145 | option=document.createElement('option'),
|
|---|
| 146 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 147 |
|
|---|
| 148 | <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
|
|---|
| 149 |
|
|---|
| 150 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 151 | ),
|
|---|
| 152 | <?php
|
|---|
| 153 | }
|
|---|
| 154 | ?>
|
|---|
| 155 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 156 | );
|
|---|
| 157 | td1.appendChild(
|
|---|
| 158 | button=document.createElement('input'),
|
|---|
| 159 | button.setAttribute('type','button'),
|
|---|
| 160 | button.setAttribute('value','[+]'),
|
|---|
| 161 | button.setAttribute('id','btnAddTime'),
|
|---|
| 162 | button.setAttribute('name','#table'+cnt),
|
|---|
| 163 | button.onclick=function(){
|
|---|
| 164 | if($('#Time').val() != ""){ timeValue = $('#Time').val(); name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; is=1; getTableId = $(this).attr('name'); split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | }
|
|---|
| 168 | );
|
|---|
| 169 | var td2=document.createElement('td');
|
|---|
| 170 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 171 | td2.appendChild(
|
|---|
| 172 | input = document.createElement('input'),
|
|---|
| 173 | input.setAttribute('type','text'),
|
|---|
| 174 | input.setAttribute('id','txtData'),
|
|---|
| 175 | input.setAttribute('value','<?php echo $rows['fData']; ?>')
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | );
|
|---|
| 179 | var td4=document.createElement('td');
|
|---|
| 180 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 181 | td4.appendChild(
|
|---|
| 182 | button=document.createElement('input'),
|
|---|
| 183 | button.setAttribute('type','button'),
|
|---|
| 184 | button.setAttribute('value','Delete'),
|
|---|
| 185 | button.setAttribute('id','btnDelete'),
|
|---|
| 186 | button.onclick=function(){
|
|---|
| 187 | $('#table'+cnt).remove();
|
|---|
| 188 | }
|
|---|
| 189 | );
|
|---|
| 190 |
|
|---|
| 191 | tr.appendChild(td3);
|
|---|
| 192 | tr.appendChild(td1);
|
|---|
| 193 | tr.appendChild(td);
|
|---|
| 194 |
|
|---|
| 195 | tr.appendChild(td2);
|
|---|
| 196 | tr.appendChild(td4);
|
|---|
| 197 | table.appendChild(tr);
|
|---|
| 198 | div.appendChild(table);
|
|---|
| 199 | $('#TableH1').append(div);
|
|---|
| 200 |
|
|---|
| 201 | <?php
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 | ?>
|
|---|
| 205 |
|
|---|
| 206 | if(cnt==0)
|
|---|
| 207 | {
|
|---|
| 208 | $('#save').show();
|
|---|
| 209 | $('#update').hide();
|
|---|
| 210 | var div= document.createElement("div");
|
|---|
| 211 | div.setAttribute('id','TableHolder');
|
|---|
| 212 | var table = document.createElement("table");
|
|---|
| 213 | table.setAttribute('id',"table2");
|
|---|
| 214 | table.setAttribute('width','100%');
|
|---|
| 215 | var tr = document.createElement('tr');
|
|---|
| 216 | tr.setAttribute('id','');
|
|---|
| 217 | tr.setAttribute('class','');
|
|---|
| 218 | var td3=document.createElement('td');
|
|---|
| 219 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 220 | td3.appendChild(
|
|---|
| 221 | input = document.createElement("input"),
|
|---|
| 222 | input.setAttribute("type","time"),
|
|---|
| 223 | input.setAttribute("id","Time"),
|
|---|
| 224 | input.setAttribute("max","24"),
|
|---|
| 225 | input.setAttribute("min","1"),
|
|---|
| 226 | input.setAttribute("required",true)
|
|---|
| 227 | );
|
|---|
| 228 | td3.appendChild(
|
|---|
| 229 | button=document.createElement('input'),
|
|---|
| 230 | button.setAttribute('type','button'),
|
|---|
| 231 | button.setAttribute('value','[+]'),
|
|---|
| 232 | button.setAttribute('id','btnAddTime'),
|
|---|
| 233 | button.setAttribute('name','#table2'),
|
|---|
| 234 | button.onclick=function(){
|
|---|
| 235 | var aa;
|
|---|
| 236 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 237 | aa = $(this).val();
|
|---|
| 238 | });
|
|---|
| 239 | if(aa != ""){ var splitting =aa.split(':'); var add = 01;
|
|---|
| 240 |
|
|---|
| 241 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 242 |
|
|---|
| 243 | function pad(number, length) {
|
|---|
| 244 |
|
|---|
| 245 | var str = '' + number;
|
|---|
| 246 | while (str.length < length) {
|
|---|
| 247 | str = '0' + str;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | return str;
|
|---|
| 251 |
|
|---|
| 252 | };
|
|---|
| 253 |
|
|---|
| 254 | var s = 0; var get;
|
|---|
| 255 |
|
|---|
| 256 | $("table").each(function() {
|
|---|
| 257 | if($(this).attr("name")=='#table2'){
|
|---|
| 258 | get = "#"+$(this).attr("id");
|
|---|
| 259 |
|
|---|
| 260 | s =1;
|
|---|
| 261 | }else{
|
|---|
| 262 | if(s==0){
|
|---|
| 263 | get = '#table'+cnt;
|
|---|
| 264 | }
|
|---|
| 265 | }
|
|---|
| 266 | });
|
|---|
| 267 | getTableId =get;
|
|---|
| 268 | name="name"; value="";
|
|---|
| 269 | name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
|
|---|
| 270 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 | }
|
|---|
| 274 | );
|
|---|
| 275 | var td=document.createElement('td');
|
|---|
| 276 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 277 | td.appendChild(
|
|---|
| 278 | sourcecbo= document.createElement('select'),
|
|---|
| 279 | sourcecbo.setAttribute('id','source'),
|
|---|
| 280 | <?php
|
|---|
| 281 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 282 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 283 | {
|
|---|
| 284 | ?>
|
|---|
| 285 | sourcecbo.appendChild(
|
|---|
| 286 | option=document.createElement('option'),
|
|---|
| 287 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 288 | option.setAttribute('selected',true),
|
|---|
| 289 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 290 |
|
|---|
| 291 | ),
|
|---|
| 292 | <?php
|
|---|
| 293 | }
|
|---|
| 294 | ?>
|
|---|
| 295 | sourcecbo.setAttribute('id','source')
|
|---|
| 296 |
|
|---|
| 297 | );
|
|---|
| 298 | var td1=document.createElement('td');
|
|---|
| 299 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 300 | td1.appendChild(
|
|---|
| 301 | measurementcbo= document.createElement('select'),
|
|---|
| 302 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 303 | <?php
|
|---|
| 304 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 305 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 306 | {
|
|---|
| 307 | ?>
|
|---|
| 308 | measurementcbo.appendChild(
|
|---|
| 309 | option=document.createElement('option'),
|
|---|
| 310 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 311 | option.setAttribute('selected',true),
|
|---|
| 312 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 313 | ),
|
|---|
| 314 | <?php
|
|---|
| 315 | }
|
|---|
| 316 | ?>
|
|---|
| 317 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 318 | );
|
|---|
| 319 | td1.appendChild(
|
|---|
| 320 | button=document.createElement('input'),
|
|---|
| 321 | button.setAttribute('type','button'),
|
|---|
| 322 | button.setAttribute('value','[+]'),
|
|---|
| 323 | button.setAttribute('id','btnAddTime'),
|
|---|
| 324 | button.setAttribute('name','#table2'),
|
|---|
| 325 | button.onclick=function(){
|
|---|
| 326 | var aa;
|
|---|
| 327 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 328 | aa = $(this).val();
|
|---|
| 329 | });
|
|---|
| 330 | if(aa != ""){ timeValue =aa; name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 | }
|
|---|
| 334 | );
|
|---|
| 335 | var td2=document.createElement('td');
|
|---|
| 336 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 337 | td2.appendChild(
|
|---|
| 338 | input = document.createElement('input'),
|
|---|
| 339 | input.setAttribute('type','text'),
|
|---|
| 340 | input.setAttribute('id','txtData')
|
|---|
| 341 |
|
|---|
| 342 | );
|
|---|
| 343 | var td4=document.createElement('td');
|
|---|
| 344 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 345 |
|
|---|
| 346 | td4.appendChild(
|
|---|
| 347 | button=document.createElement('input'),
|
|---|
| 348 | button.setAttribute('type','button'),
|
|---|
| 349 | button.setAttribute('value','Delete'),
|
|---|
| 350 | button.setAttribute('id','btnDelete'),
|
|---|
| 351 | button.onclick=function(){
|
|---|
| 352 | $('#table2').remove();
|
|---|
| 353 |
|
|---|
| 354 | }
|
|---|
| 355 | );
|
|---|
| 356 |
|
|---|
| 357 | tr.appendChild(td3);
|
|---|
| 358 | tr.appendChild(td1);
|
|---|
| 359 | tr.appendChild(td);
|
|---|
| 360 |
|
|---|
| 361 | tr.appendChild(td2);
|
|---|
| 362 | tr.appendChild(td4);
|
|---|
| 363 | table.appendChild(tr);
|
|---|
| 364 | div.appendChild(table);
|
|---|
| 365 | $('#TableH1').append(div);
|
|---|
| 366 |
|
|---|
| 367 | var div= document.createElement("div");
|
|---|
| 368 | div.setAttribute('id','TableHolder');
|
|---|
| 369 | var table = document.createElement("table");
|
|---|
| 370 | table.setAttribute('id',"table1");
|
|---|
| 371 | table.setAttribute('width','100%');
|
|---|
| 372 | var tr = document.createElement('tr');
|
|---|
| 373 | tr.setAttribute('id','');
|
|---|
| 374 | tr.setAttribute('class','');
|
|---|
| 375 | var td3=document.createElement('td');
|
|---|
| 376 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 377 | td3.appendChild(
|
|---|
| 378 | input = document.createElement("input"),
|
|---|
| 379 | input.setAttribute("type","time"),
|
|---|
| 380 | input.setAttribute("id","Time"),
|
|---|
| 381 | input.setAttribute("max","24"),
|
|---|
| 382 | input.setAttribute("min","1"),
|
|---|
| 383 | input.setAttribute("required",true)
|
|---|
| 384 | );
|
|---|
| 385 | td3.appendChild(
|
|---|
| 386 | button=document.createElement('input'),
|
|---|
| 387 | button.setAttribute('type','button'),
|
|---|
| 388 | button.setAttribute('value','[+]'),
|
|---|
| 389 | button.setAttribute('id','btnAddTime'),
|
|---|
| 390 | button.setAttribute('name','#table1'),
|
|---|
| 391 | button.onclick=function(){
|
|---|
| 392 | var aa;
|
|---|
| 393 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 394 | aa = $(this).val();
|
|---|
| 395 | });
|
|---|
| 396 | if(aa !='') { var splitting =aa.split(':'); var add = 01;
|
|---|
| 397 |
|
|---|
| 398 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 399 |
|
|---|
| 400 | function pad(number, length) {
|
|---|
| 401 |
|
|---|
| 402 | var str = '' + number;
|
|---|
| 403 | while (str.length < length) {
|
|---|
| 404 | str = '0' + str;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | return str;
|
|---|
| 408 |
|
|---|
| 409 | };
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 | var s = 0; var get;
|
|---|
| 413 |
|
|---|
| 414 | $("table").each(function() {
|
|---|
| 415 | if($(this).attr("name")=='#table2'){
|
|---|
| 416 | get = "#"+$(this).attr("id");
|
|---|
| 417 |
|
|---|
| 418 | s =1;
|
|---|
| 419 | }else{
|
|---|
| 420 | if(s==0){
|
|---|
| 421 | get = '#table'+cnt;
|
|---|
| 422 | }
|
|---|
| 423 | }
|
|---|
| 424 | });
|
|---|
| 425 | getTableId =get;
|
|---|
| 426 | name="name"; value="";
|
|---|
| 427 |
|
|---|
| 428 | name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
|
|---|
| 429 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 | }
|
|---|
| 433 | );
|
|---|
| 434 | var td=document.createElement('td');
|
|---|
| 435 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 436 | td.appendChild(
|
|---|
| 437 | sourcecbo= document.createElement('select'),
|
|---|
| 438 | sourcecbo.setAttribute('id','source'),
|
|---|
| 439 | <?php
|
|---|
| 440 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 441 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 442 | {
|
|---|
| 443 | ?>
|
|---|
| 444 | sourcecbo.appendChild(
|
|---|
| 445 | option=document.createElement('option'),
|
|---|
| 446 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 447 | option.setAttribute('selected',true),
|
|---|
| 448 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 449 |
|
|---|
| 450 | ),
|
|---|
| 451 | <?php
|
|---|
| 452 | }
|
|---|
| 453 | ?>
|
|---|
| 454 | sourcecbo.setAttribute('id','source')
|
|---|
| 455 |
|
|---|
| 456 | );
|
|---|
| 457 | var td1=document.createElement('td');
|
|---|
| 458 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 459 | td1.appendChild(
|
|---|
| 460 | measurementcbo= document.createElement('select'),
|
|---|
| 461 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 462 | <?php
|
|---|
| 463 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 464 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 465 | {
|
|---|
| 466 | ?>
|
|---|
| 467 | measurementcbo.appendChild(
|
|---|
| 468 | option=document.createElement('option'),
|
|---|
| 469 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 470 | option.setAttribute('selected',true),
|
|---|
| 471 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 472 | ),
|
|---|
| 473 | <?php
|
|---|
| 474 | }
|
|---|
| 475 | ?>
|
|---|
| 476 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 477 | );
|
|---|
| 478 | td1.appendChild(
|
|---|
| 479 | button=document.createElement('input'),
|
|---|
| 480 | button.setAttribute('type','button'),
|
|---|
| 481 | button.setAttribute('value','[+]'),
|
|---|
| 482 | button.setAttribute('id','btnAddTime'),
|
|---|
| 483 | button.setAttribute('name','#table1'),
|
|---|
| 484 | button.onclick=function(){
|
|---|
| 485 | $('div#TableHolder #table1 #Time').each(function(){
|
|---|
| 486 | aa = $(this).val();
|
|---|
| 487 | });
|
|---|
| 488 |
|
|---|
| 489 | if(aa != ""){ timeValue = aa; name="name"; value="#table1"; meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 | }
|
|---|
| 493 | );
|
|---|
| 494 | var td2=document.createElement('td');
|
|---|
| 495 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 496 | td2.appendChild(
|
|---|
| 497 | input = document.createElement('input'),
|
|---|
| 498 | input.setAttribute('type','text'),
|
|---|
| 499 | input.setAttribute('id','txtData')
|
|---|
| 500 |
|
|---|
| 501 | );
|
|---|
| 502 | var td4=document.createElement('td');
|
|---|
| 503 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 504 |
|
|---|
| 505 | td4.appendChild(
|
|---|
| 506 | button=document.createElement('input'),
|
|---|
| 507 | button.setAttribute('type','button'),
|
|---|
| 508 | button.setAttribute('value','Delete'),
|
|---|
| 509 | button.setAttribute('id','btnDelete'),
|
|---|
| 510 | button.onclick=function(){
|
|---|
| 511 | $('#table1').remove();
|
|---|
| 512 |
|
|---|
| 513 | }
|
|---|
| 514 | );
|
|---|
| 515 |
|
|---|
| 516 | tr.appendChild(td3);
|
|---|
| 517 | tr.appendChild(td1);
|
|---|
| 518 | tr.appendChild(td);
|
|---|
| 519 |
|
|---|
| 520 | tr.appendChild(td2);
|
|---|
| 521 | tr.appendChild(td4);
|
|---|
| 522 | table.appendChild(tr);
|
|---|
| 523 | div.appendChild(table);
|
|---|
| 524 | $('#TableH1').append(div);
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 | }
|
|---|
| 528 | var meas;
|
|---|
| 529 | var timeValue;
|
|---|
| 530 | var pad;
|
|---|
| 531 | if(cnt==0){ cnt=2; }
|
|---|
| 532 | function split2()
|
|---|
| 533 | {
|
|---|
| 534 |
|
|---|
| 535 | cnt++;
|
|---|
| 536 | var div= document.createElement("div");
|
|---|
| 537 | div.setAttribute('id','TableHolder');
|
|---|
| 538 | var table = document.createElement("table");
|
|---|
| 539 | table.setAttribute('id',"table"+cnt);
|
|---|
| 540 | table.setAttribute('width','100%');
|
|---|
| 541 | table.setAttribute(name,value);
|
|---|
| 542 | var tr = document.createElement('tr');
|
|---|
| 543 | tr.setAttribute('id','');
|
|---|
| 544 | tr.setAttribute('class','');
|
|---|
| 545 |
|
|---|
| 546 | var td3=document.createElement('td');
|
|---|
| 547 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 548 | td3.setAttribute('class','first');
|
|---|
| 549 |
|
|---|
| 550 | td3.appendChild(
|
|---|
| 551 | input = document.createElement("input"),
|
|---|
| 552 | input.setAttribute("type","time"),
|
|---|
| 553 | input.setAttribute("id","Time"),
|
|---|
| 554 | input.setAttribute("max","24"),
|
|---|
| 555 | input.setAttribute("min","1"),
|
|---|
| 556 | input.setAttribute("required",true),
|
|---|
| 557 | input.setAttribute(meas,meas2),
|
|---|
| 558 | input.setAttribute("value",timeValue)
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|
| 561 | );
|
|---|
| 562 | td3.appendChild(
|
|---|
| 563 | button=document.createElement('input'),
|
|---|
| 564 | button.setAttribute('type','button'),
|
|---|
| 565 | button.setAttribute('value','[+]'),
|
|---|
| 566 | button.setAttribute('id','btnAddTime'),
|
|---|
| 567 | button.setAttribute(meas,meas2),
|
|---|
| 568 | button.setAttribute('name','#table'+cnt),
|
|---|
| 569 |
|
|---|
| 570 | button.onclick=function(){
|
|---|
| 571 | var aa;
|
|---|
| 572 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 573 | aa = $(this).val();
|
|---|
| 574 | });
|
|---|
| 575 | if(aa != ""){var splitting = aa.split(':'); var add = 01;
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 579 |
|
|---|
| 580 | function pad(number, length) {
|
|---|
| 581 |
|
|---|
| 582 | var str = '' + number;
|
|---|
| 583 | while (str.length < length) {
|
|---|
| 584 | str = '0' + str;
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | return str;
|
|---|
| 588 |
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | var s = 0; var get;
|
|---|
| 592 | var nn;
|
|---|
| 593 | nn = $(this).attr('name');
|
|---|
| 594 | $("table").each(function() {
|
|---|
| 595 | if($(this).attr("name")==nn){
|
|---|
| 596 |
|
|---|
| 597 | get = "#"+$(this).attr("id");
|
|---|
| 598 | //get = $(this).attr("name");
|
|---|
| 599 | s =1;
|
|---|
| 600 | }else{
|
|---|
| 601 | if(s==0){
|
|---|
| 602 | get = '#table'+cnt;
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 | });
|
|---|
| 606 |
|
|---|
| 607 | name="name"; value=$(this).attr('name');
|
|---|
| 608 | meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 | }
|
|---|
| 612 | );
|
|---|
| 613 |
|
|---|
| 614 | var td=document.createElement('td');
|
|---|
| 615 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 616 | td.appendChild(
|
|---|
| 617 | sourcecbo= document.createElement('select'),
|
|---|
| 618 | sourcecbo.setAttribute('id','source'),
|
|---|
| 619 | <?php
|
|---|
| 620 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 621 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 622 | {
|
|---|
| 623 | ?>
|
|---|
| 624 | sourcecbo.appendChild(
|
|---|
| 625 | option=document.createElement('option'),
|
|---|
| 626 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 627 | option.setAttribute('selected',true),
|
|---|
| 628 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 629 |
|
|---|
| 630 | ),
|
|---|
| 631 | <?php
|
|---|
| 632 | }
|
|---|
| 633 | ?>
|
|---|
| 634 | sourcecbo.setAttribute('id','source')
|
|---|
| 635 |
|
|---|
| 636 | );
|
|---|
| 637 | var td1=document.createElement('td');
|
|---|
| 638 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 639 | td1.appendChild(
|
|---|
| 640 | measurementcbo= document.createElement('select'),
|
|---|
| 641 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 642 | <?php
|
|---|
| 643 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 644 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 645 | {
|
|---|
| 646 | ?>
|
|---|
| 647 | measurementcbo.appendChild(
|
|---|
| 648 | option=document.createElement('option'),
|
|---|
| 649 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 650 | option.setAttribute('selected',true),
|
|---|
| 651 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 652 | ),
|
|---|
| 653 | <?php
|
|---|
| 654 | }
|
|---|
| 655 | ?>
|
|---|
| 656 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 657 | );
|
|---|
| 658 | td1.appendChild(
|
|---|
| 659 | button=document.createElement('input'),
|
|---|
| 660 | button.setAttribute('type','button'),
|
|---|
| 661 | button.setAttribute('value','[+]'),
|
|---|
| 662 | button.setAttribute('id','btnAddTime'),
|
|---|
| 663 | button.setAttribute('name','#table'+cnt),
|
|---|
| 664 | button.onclick=function(){
|
|---|
| 665 | var aa;
|
|---|
| 666 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 667 | aa = $(this).val();
|
|---|
| 668 | });
|
|---|
| 669 | if(aa != "")
|
|---|
| 670 | {
|
|---|
| 671 | name = "name";
|
|---|
| 672 | value = "#table"+cnt;
|
|---|
| 673 | timeValue = aa;
|
|---|
| 674 | meas = "hidden";
|
|---|
| 675 | meas2 = true;
|
|---|
| 676 | getTableId = $(this).attr('name');
|
|---|
| 677 | split1();
|
|---|
| 678 | }
|
|---|
| 679 | else
|
|---|
| 680 | {
|
|---|
| 681 | alert("please enter value for time to add measurement");
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 |
|
|---|
| 685 | }
|
|---|
| 686 | );
|
|---|
| 687 |
|
|---|
| 688 | var td2=document.createElement('td');
|
|---|
| 689 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 690 | td2.appendChild(
|
|---|
| 691 | input = document.createElement('input'),
|
|---|
| 692 | input.setAttribute('type','text'),
|
|---|
| 693 | input.setAttribute('id','txtData')
|
|---|
| 694 |
|
|---|
| 695 | );
|
|---|
| 696 | var td4=document.createElement('td');
|
|---|
| 697 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 698 |
|
|---|
| 699 | td4.appendChild(
|
|---|
| 700 | button=document.createElement('input'),
|
|---|
| 701 | button.setAttribute('type','button'),
|
|---|
| 702 | button.setAttribute('value','Delete'),
|
|---|
| 703 | button.setAttribute('id','btnDelete'),
|
|---|
| 704 | button.onclick=function(){
|
|---|
| 705 | $('#table'+cnt).remove();
|
|---|
| 706 | cnt--;
|
|---|
| 707 | }
|
|---|
| 708 | );
|
|---|
| 709 |
|
|---|
| 710 | tr.appendChild(td3);
|
|---|
| 711 | tr.appendChild(td1);
|
|---|
| 712 | tr.appendChild(td);
|
|---|
| 713 |
|
|---|
| 714 | tr.appendChild(td2);
|
|---|
| 715 | tr.appendChild(td4);
|
|---|
| 716 | table.appendChild(tr);
|
|---|
| 717 | div.appendChild(table);
|
|---|
| 718 | $(div).insertAfter($(getTableId));
|
|---|
| 719 |
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 | }
|
|---|
| 723 | function split1()
|
|---|
| 724 | {
|
|---|
| 725 |
|
|---|
| 726 | cnt++;
|
|---|
| 727 | var div= document.createElement("div");
|
|---|
| 728 | div.setAttribute('id','TableHolder');
|
|---|
| 729 | var table = document.createElement("table");
|
|---|
| 730 | table.setAttribute('id',"table"+cnt);
|
|---|
| 731 | table.setAttribute('width','100%');
|
|---|
| 732 | table.setAttribute(name,value);
|
|---|
| 733 | var tr = document.createElement('tr');
|
|---|
| 734 | tr.setAttribute('id','');
|
|---|
| 735 | tr.setAttribute('class','');
|
|---|
| 736 |
|
|---|
| 737 | var td3=document.createElement('td');
|
|---|
| 738 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 739 | td3.setAttribute('class','first');
|
|---|
| 740 | td3.appendChild(
|
|---|
| 741 | input = document.createElement("input"),
|
|---|
| 742 | input.setAttribute("type","time"),
|
|---|
| 743 | input.setAttribute("id","Time"),
|
|---|
| 744 | input.setAttribute("max","24"),
|
|---|
| 745 | input.setAttribute("min","1"),
|
|---|
| 746 | input.setAttribute("required",true),
|
|---|
| 747 | input.setAttribute(meas,meas2),
|
|---|
| 748 | input.setAttribute("value",timeValue)
|
|---|
| 749 | );
|
|---|
| 750 | td3.appendChild(
|
|---|
| 751 | button=document.createElement('input'),
|
|---|
| 752 | button.setAttribute('type','button'),
|
|---|
| 753 | button.setAttribute('value','[+]'),
|
|---|
| 754 | button.setAttribute('id','btnAddTime'),
|
|---|
| 755 | button.setAttribute(meas,meas2),
|
|---|
| 756 | button.setAttribute('name','#table'+cnt),
|
|---|
| 757 |
|
|---|
| 758 | button.onclick=function(){
|
|---|
| 759 | var aa;
|
|---|
| 760 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 761 | aa = $(this).val();
|
|---|
| 762 | });
|
|---|
| 763 | if(aa != ""){ var splitting = aa.split(':'); var add = 01;
|
|---|
| 764 |
|
|---|
| 765 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 766 |
|
|---|
| 767 | function pad(number, length) {
|
|---|
| 768 |
|
|---|
| 769 | var str = '' + number;
|
|---|
| 770 | while (str.length < length) {
|
|---|
| 771 | str = '0' + str;
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 | return str;
|
|---|
| 775 |
|
|---|
| 776 | }
|
|---|
| 777 | var s = 0; var get;
|
|---|
| 778 | var nn;
|
|---|
| 779 | nn = $(this).attr('name');
|
|---|
| 780 | $("table").each(function() {
|
|---|
| 781 | if($(this).attr("name")==nn){
|
|---|
| 782 |
|
|---|
| 783 | get = "#"+$(this).attr("id");
|
|---|
| 784 | //get = $(this).attr("name");
|
|---|
| 785 | s =1;
|
|---|
| 786 | }else{
|
|---|
| 787 | if(s==0){
|
|---|
| 788 | get = '#table'+cnt;
|
|---|
| 789 | }
|
|---|
| 790 | }
|
|---|
| 791 | });
|
|---|
| 792 |
|
|---|
| 793 | name="name"; value=""; meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 | }
|
|---|
| 797 | );
|
|---|
| 798 |
|
|---|
| 799 | var td=document.createElement('td');
|
|---|
| 800 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 801 | td.appendChild(
|
|---|
| 802 | sourcecbo= document.createElement('select'),
|
|---|
| 803 | sourcecbo.setAttribute('id','source'),
|
|---|
| 804 | <?php
|
|---|
| 805 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 806 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 807 | {
|
|---|
| 808 | ?>
|
|---|
| 809 | sourcecbo.appendChild(
|
|---|
| 810 | option=document.createElement('option'),
|
|---|
| 811 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 812 | option.setAttribute('selected',true),
|
|---|
| 813 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 814 |
|
|---|
| 815 | ),
|
|---|
| 816 | <?php
|
|---|
| 817 | }
|
|---|
| 818 | ?>
|
|---|
| 819 | sourcecbo.setAttribute('id','source')
|
|---|
| 820 |
|
|---|
| 821 | );
|
|---|
| 822 | var td1=document.createElement('td');
|
|---|
| 823 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 824 |
|
|---|
| 825 | td1.appendChild(
|
|---|
| 826 | measurementcbo= document.createElement('select'),
|
|---|
| 827 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 828 | <?php
|
|---|
| 829 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 830 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 831 | {
|
|---|
| 832 | ?>
|
|---|
| 833 | measurementcbo.appendChild(
|
|---|
| 834 | option=document.createElement('option'),
|
|---|
| 835 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 836 | option.setAttribute('selected',true),
|
|---|
| 837 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 838 | ),
|
|---|
| 839 | <?php
|
|---|
| 840 | }
|
|---|
| 841 | ?>
|
|---|
| 842 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 843 | );
|
|---|
| 844 | td1.appendChild(
|
|---|
| 845 | button=document.createElement('input'),
|
|---|
| 846 | button.setAttribute('type','button'),
|
|---|
| 847 | button.setAttribute('value','[+]'),
|
|---|
| 848 | button.setAttribute('id','btnAddTime'),
|
|---|
| 849 | button.setAttribute('name','#table'+cnt),
|
|---|
| 850 | button.onclick=function(){
|
|---|
| 851 |
|
|---|
| 852 | if($('#Time').val() != ""){ timeValue = $('#Time').val();
|
|---|
| 853 | name = "name"; value = $(this).attr('name'); meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 854 |
|
|---|
| 855 |
|
|---|
| 856 | }
|
|---|
| 857 | );
|
|---|
| 858 |
|
|---|
| 859 | var td2=document.createElement('td');
|
|---|
| 860 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 861 | td2.appendChild(
|
|---|
| 862 | input = document.createElement('input'),
|
|---|
| 863 | input.setAttribute('type','text'),
|
|---|
| 864 | input.setAttribute('id','txtData')
|
|---|
| 865 |
|
|---|
| 866 | );
|
|---|
| 867 | var td4=document.createElement('td');
|
|---|
| 868 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 869 |
|
|---|
| 870 | td4.appendChild(
|
|---|
| 871 | button=document.createElement('input'),
|
|---|
| 872 | button.setAttribute('type','button'),
|
|---|
| 873 | button.setAttribute('value','Delete'),
|
|---|
| 874 | button.setAttribute('id','btnDelete'),
|
|---|
| 875 | button.onclick=function(){
|
|---|
| 876 | $('#table'+cnt).remove();
|
|---|
| 877 | cnt--;
|
|---|
| 878 | });
|
|---|
| 879 |
|
|---|
| 880 | tr.appendChild(td3);
|
|---|
| 881 | tr.appendChild(td1);
|
|---|
| 882 | tr.appendChild(td);
|
|---|
| 883 |
|
|---|
| 884 | tr.appendChild(td2);
|
|---|
| 885 | tr.appendChild(td4);
|
|---|
| 886 | table.appendChild(tr);
|
|---|
| 887 | div.appendChild(table);
|
|---|
| 888 | $(div).insertAfter($(getTableId));
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | });
|
|---|
| 892 | </script> |
|---|